Message ID | 20230803140701.18515-3-nmi@metaspace.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1198890vqx; Thu, 3 Aug 2023 07:48:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2WPBvu/7LUOhsxDIA8U7cqdm3GuG60HFsVthUaN1mpANYgab3eaFF4Authi4aULdUXSuP X-Received: by 2002:a17:906:1d9:b0:997:c377:b41f with SMTP id 25-20020a17090601d900b00997c377b41fmr8035902ejj.64.1691074096935; Thu, 03 Aug 2023 07:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691074096; cv=none; d=google.com; s=arc-20160816; b=iZMiN0wvmOLWOApA5nax9Fz5z6qwHfS/fz1qNiP/s12saXtX1VjK2vq4xZCVbWcKQZ ILx7BKTflbm2ZL6xgUxSg0RQ6GQvGM28eT4H4IwG2CdNHiD7sojOXr4CV5PlI9++5FN1 am138SYj7LojI83yBQmOQ/pLzX51j+7OniOggSWzS6zbUFhax8G8puFZIpGG+mOdAL/M e4MZI/sDtxJTJxZf8OGRqdS3qIBKzItWLjYEeWg8u+SB94d4/Z+q4PEwxez68jy7rtUJ derZYHqwCv6aFbckyeycVAabrhrOd2R43ETz4AzX79Zmq77ElL1ve5YFd7PHj2bxHOjE lKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gsVd2fV3PA4EdIC1bmEF6WqQH4zyZJO6nSo1h8aq0xI=; fh=QJW5L728sGFmhbcrtK66zzIJZnMDyKTrS0wh75j5NKs=; b=NOYROElydmAjv2qlXvkJXG7gGd+bHk/fTFt5duB1OnMDAZUbqpwmqQCxBWZOXyhIoI 6XnSxG/wP2SQzjMhsxyZijuiA129hmQE/M6Ak7BGyBZ6LiwBm2ClA1eyfGP4UayYY0R4 0dTjwnz+N//lrK6h02jci+CLC7ypCk6+5juMXaMhqjrprffyZ035W6NEzmKV8m17LoUT 2gKZgYIVsJuqFpF38mTYqMPgVbRSb51NHyF57BC6VwYyFRNEO4le5MQGnApw2e4oQ6/E +2PKncLmJa6iMf66ySMvmLVY54mZ4LLq7+sXIzgXxRyeaxlnjj1XnqpZMLZPZcp1Se2t fzjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@metaspace-dk.20221208.gappssmtp.com header.s=20221208 header.b=cx7M2lq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j25-20020a170906255900b0099342fc2a87si3230559ejb.692.2023.08.03.07.47.50; Thu, 03 Aug 2023 07:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@metaspace-dk.20221208.gappssmtp.com header.s=20221208 header.b=cx7M2lq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236547AbjHCOJi (ORCPT <rfc822;guoshuai5156@gmail.com> + 99 others); Thu, 3 Aug 2023 10:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232362AbjHCOHj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 3 Aug 2023 10:07:39 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314E5198C for <linux-kernel@vger.kernel.org>; Thu, 3 Aug 2023 07:07:06 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc1218262so10325655e9.3 for <linux-kernel@vger.kernel.org>; Thu, 03 Aug 2023 07:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace-dk.20221208.gappssmtp.com; s=20221208; t=1691071624; x=1691676424; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gsVd2fV3PA4EdIC1bmEF6WqQH4zyZJO6nSo1h8aq0xI=; b=cx7M2lq8nRGQLStLg++95LrzEdbrHvRF3eQzkND5FRgpBY9rz8Q19Gbez0puuQEXPL aUV5YdlNBDPjigUzLE868SqkUfrHShLl2RzpK0LLSGsTiupjGX1MUJEZyUNO00kfx5SB nwCP5zcbZZZrEUNiQsZZ9KXe/n8qXNQnuWhL1jjLu2zFeFN4k+GYP1lHzbS8+4zX0H3c 5H4ver9HIYeX3ugd0PPmjB9Lq7GIUcmImGRglMvMI0kLi4SKIfXAY8wc4qj/XhWiIBAp dfm4p6iaRO5Y27y48vJh9uVZ0APV48ZUNgG4q9pOwMw53foN6C+GMMgC3T2LOg8Ec0YR XShQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071624; x=1691676424; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gsVd2fV3PA4EdIC1bmEF6WqQH4zyZJO6nSo1h8aq0xI=; b=SFg6qaVLCSpyXUqhEEy7glPJCWrKX73Elg7r4NzTdNCtX1mxLobNTRwEArtKfjahVl tP8avkmVLaGpTO05pOV7biRgY8KRTypqGcyya07t3SJKhy9dIfzE33T1EbMFvO4ibsog xG2rppe++tMXOCLXkwQi5dFU7vKxdat/DKmqjOkpXoZegIsqj9544b00NKapXPTzwKQ5 +XMUberV4Ymv2a1jhlqOO82AbISwvb5jVROOhBLlvFO7Oqgypl3hTenM0m0SCRdttrTZ uaniK6wUWPuFySB27WlAQSeWEfgXsb+ZtFDxqY3pRj87wAK42WeqEyH9JOX6f+CEJLmE 2UuQ== X-Gm-Message-State: ABy/qLa0u2xsrOWXqBXYwv1SCkh9mlL1jknbTubRVzFUiFj4TznEdKUu kozw5/XPdOFNtyZo8RuHnrrvOA== X-Received: by 2002:a5d:595b:0:b0:316:f3cf:6f12 with SMTP id e27-20020a5d595b000000b00316f3cf6f12mr7043606wri.48.1691071624574; Thu, 03 Aug 2023 07:07:04 -0700 (PDT) Received: from localhost ([147.161.155.117]) by smtp.gmail.com with ESMTPSA id z3-20020a5d4c83000000b002c70ce264bfsm21841029wrs.76.2023.08.03.07.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:07:04 -0700 (PDT) From: "Andreas Hindborg (Samsung)" <nmi@metaspace.dk> To: Ming Lei <ming.lei@redhat.com> Cc: Christoph Hellwig <hch@infradead.org>, gost.dev@samsung.com, linux-block@vger.kernel.org (open list:BLOCK LAYER), Hans Holmberg <Hans.Holmberg@wdc.com>, Matias Bjorling <Matias.Bjorling@wdc.com>, Andreas Hindborg <a.hindborg@samsung.com>, Minwoo Im <minwoo.im.dev@gmail.com>, Jens Axboe <axboe@kernel.dk>, Johannes Thumshirn <jth@kernel.org>, Aravind Ramesh <Aravind.Ramesh@wdc.com>, Damien Le Moal <dlemoal@kernel.org>, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 2/3] ublk: move check for empty address field on command submission Date: Thu, 3 Aug 2023 16:07:00 +0200 Message-ID: <20230803140701.18515-3-nmi@metaspace.dk> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803140701.18515-1-nmi@metaspace.dk> References: <20230803140701.18515-1-nmi@metaspace.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773219712245590032 X-GMAIL-MSGID: 1773219712245590032 |
Series |
ublk: enable zoned storage support
|
|
Commit Message
Andreas Hindborg
Aug. 3, 2023, 2:07 p.m. UTC
From: Andreas Hindborg <a.hindborg@samsung.com> In preparation for zoned storage support, move the check for empty `addr` field into the command handler case statement. Note that the check makes no sense for `UBLK_IO_NEED_GET_DATA` because the `addr` field must always be set for this command. Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com> --- drivers/block/ublk_drv.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Comments
Hi Andreas, On Thu, Aug 03, 2023 at 04:07:00PM +0200, Andreas Hindborg (Samsung) wrote: > From: Andreas Hindborg <a.hindborg@samsung.com> > > In preparation for zoned storage support, move the check for empty `addr` > field into the command handler case statement. Note that the check makes no > sense for `UBLK_IO_NEED_GET_DATA` because the `addr` field must always be > set for this command. > > Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com> > --- > drivers/block/ublk_drv.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c > index db3523e281a6..5a1ee17636ac 100644 > --- a/drivers/block/ublk_drv.c > +++ b/drivers/block/ublk_drv.c > @@ -1419,11 +1419,6 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, > ^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA)) > goto out; > > - if (ublk_support_user_copy(ubq) && ub_cmd->addr) { > - ret = -EINVAL; > - goto out; > - } > - > ret = ublk_check_cmd_op(cmd_op); > if (ret) > goto out; > @@ -1452,6 +1447,12 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, > goto out; > } > > + /* User copy requires addr to be unset */ > + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { > + ret = -EINVAL; > + goto out; > + } > + Given you have to post v11 for fixing build issue, please convert the above two 'if' into one 'if else': if (!ublk_support_user_copy(ubq)) { /* * FETCH_RQ has to provide IO buffer if NEED GET * DATA is not enabled */ if (!ub_cmd->addr && !ublk_need_get_data(ubq)) goto out; } else { if (ub_cmd->addr) { ret = -EINVAL; goto out; } } > ublk_fill_io_cmd(io, cmd, ub_cmd->addr); > ublk_mark_io_ready(ub, ubq); > break; > @@ -1470,6 +1471,13 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, > req_op(req) == REQ_OP_READ)) > goto out; > } > + > + /* User copy requires addr to be unset */ > + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { > + ret = -EINVAL; > + goto out; > + } > + Same with above. BTW, I have verified this patchset with ublk-zoned example in libublk-rs: https://github.com/ming1/libublk-rs/tree/zoned.v2 cargo run --example zoned -- add -1 10240 mkfs.btrfs -O zoned /dev/ublkb0 mount & git clone linux-kernel &umount Hope V11 can be merged. Thanks, Ming
Ming Lei <tom.leiming@gmail.com> writes: > Hi Andreas, > > On Thu, Aug 03, 2023 at 04:07:00PM +0200, Andreas Hindborg (Samsung) wrote: >> From: Andreas Hindborg <a.hindborg@samsung.com> >> >> In preparation for zoned storage support, move the check for empty `addr` >> field into the command handler case statement. Note that the check makes no >> sense for `UBLK_IO_NEED_GET_DATA` because the `addr` field must always be >> set for this command. >> >> Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com> >> --- >> drivers/block/ublk_drv.c | 18 +++++++++++++----- >> 1 file changed, 13 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c >> index db3523e281a6..5a1ee17636ac 100644 >> --- a/drivers/block/ublk_drv.c >> +++ b/drivers/block/ublk_drv.c >> @@ -1419,11 +1419,6 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, >> ^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA)) >> goto out; >> >> - if (ublk_support_user_copy(ubq) && ub_cmd->addr) { >> - ret = -EINVAL; >> - goto out; >> - } >> - >> ret = ublk_check_cmd_op(cmd_op); >> if (ret) >> goto out; >> @@ -1452,6 +1447,12 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, >> goto out; >> } >> >> + /* User copy requires addr to be unset */ >> + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { >> + ret = -EINVAL; >> + goto out; >> + } >> + > > Given you have to post v11 for fixing build issue, please convert the > above two 'if' into one 'if else': > > if (!ublk_support_user_copy(ubq)) { > /* > * FETCH_RQ has to provide IO buffer if NEED GET > * DATA is not enabled > */ > if (!ub_cmd->addr && !ublk_need_get_data(ubq)) > goto out; > } else { > if (ub_cmd->addr) { > ret = -EINVAL; > goto out; > } > } Alright. I was debating with myself one over the other 😅 > >> ublk_fill_io_cmd(io, cmd, ub_cmd->addr); >> ublk_mark_io_ready(ub, ubq); >> break; >> @@ -1470,6 +1471,13 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, >> req_op(req) == REQ_OP_READ)) >> goto out; >> } >> + >> + /* User copy requires addr to be unset */ >> + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { >> + ret = -EINVAL; >> + goto out; >> + } >> + > > Same with above. > > BTW, I have verified this patchset with ublk-zoned example in > libublk-rs: > > https://github.com/ming1/libublk-rs/tree/zoned.v2 > > cargo run --example zoned -- add -1 10240 > mkfs.btrfs -O zoned /dev/ublkb0 > mount & git clone linux-kernel &umount Thanks! BR Andreas
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index db3523e281a6..5a1ee17636ac 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1419,11 +1419,6 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, ^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA)) goto out; - if (ublk_support_user_copy(ubq) && ub_cmd->addr) { - ret = -EINVAL; - goto out; - } - ret = ublk_check_cmd_op(cmd_op); if (ret) goto out; @@ -1452,6 +1447,12 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, goto out; } + /* User copy requires addr to be unset */ + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { + ret = -EINVAL; + goto out; + } + ublk_fill_io_cmd(io, cmd, ub_cmd->addr); ublk_mark_io_ready(ub, ubq); break; @@ -1470,6 +1471,13 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, req_op(req) == REQ_OP_READ)) goto out; } + + /* User copy requires addr to be unset */ + if (ublk_support_user_copy(ubq) && ub_cmd->addr) { + ret = -EINVAL; + goto out; + } + ublk_fill_io_cmd(io, cmd, ub_cmd->addr); ublk_commit_completion(ub, ub_cmd); break;