it key) header.d=redhat.com header.i=@redhat.com header.b=KOOhwequ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761216245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=AQdpr7tiqgHdbDQVg93+dG/eG3fbl9u/USI4T+1JorE=; b=KOOhwequ5CS910jPOowIRAH0lbSigIaVejjC4/d/Gy/MF6zBHtVcnlB/Zrn69AF6CFcSKx Cgj/0PKJ/6GIQ8ZsOA1hvUPcuC20zDv6PQTK15tRpKpChl+us9QdMcW58mJ5tLE8rh0pyk wc8r2mKxkiY3d478wD5g+cQ73wFB9Dw= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-PNDzfMH5O6aZaXItZu2qpw-1; Thu, 23 Oct 2025 06:44:04 -0400 X-MC-Unique: PNDzfMH5O6aZaXItZu2qpw-1 X-Mimecast-MFC-AGG-ID: PNDzfMH5O6aZaXItZu2qpw_1761216243 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4E7D31800741; Thu, 23 Oct 2025 10:44:03 +0000 (UTC) Received: from localhost (unknown [10.72.120.30]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC9AD180057E; Thu, 23 Oct 2025 10:44:01 +0000 (UTC) From: Ming Lei To: Jens Axboe , io-uring@vger.kernel.org Cc: Caleb Sander Mateos , Ming Lei Subject: [PATCH] io_uring: fix buffer auto-commit for multishot uring_cmd Date: Thu, 23 Oct 2025 18:43:50 +0800 Message-ID: <20251023104350.2515079-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-DKIM: signer='redhat.com' status='pass' reason='' DKIMCheck: Server passes DKIM test, 0 Spam score X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "witcher.mxrouting.net", has performed the tests listed below against this email. Information: https://mxroutedocs.com/directadmin/spamfilters/ --- Content analysis details: (0.4 points) --- pts rule name description ---- ---------------------- ----------------------------------------- 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block for more information. [142.0.200.124 listed in list.dnswl.org] 1.5 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender SpamTally: Final spam score: 4 Commit 620a50c92700 ("io_uring: uring_cmd: add multishot support") added multishot uring_cmd support with explicit buffer upfront commit via io_uring_mshot_cmd_post_cqe(). However, the buffer selection path in io_ring_buffer_select() was auto-committing buffers for non-pollable files, which conflicts with uring_cmd's explicit upfront commit model. This way consumes the whole selected buffer immediately, and causes failure on the following buffer selection. Fix this by adding io_commit_kbuf_upfront() to identify operations that handle buffer commit explicitly (currently only IORING_OP_URING_CMD), and skip auto-commit for these operations. Cc: Caleb Sander Mateos Fixes: 620a50c92700 ("io_uring: uring_cmd: add multishot support") Signed-off-by: Ming Lei --- io_uring/kbuf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index aad655e38672..e3f3dec8b135 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -155,6 +155,12 @@ static int io_provided_buffers_select(struct io_kiocb *req, size_t *len, return 1; } +/* So far, uring_cmd commits kbuf upfront, no need to auto-commit */ +static bool io_commit_kbuf_upfront(const struct io_kiocb *req) +{ + return req->opcode == IORING_OP_URING_CMD; +} + static struct io_br_sel io_ring_buffer_select(struct io_kiocb *req, size_t *len, struct io_buffer_list *bl, unsigned int issue_flags) @@ -181,7 +187,8 @@ static struct io_br_sel io_ring_buffer_select(struct io_kiocb *req, size_t *len, sel.buf_list = bl; sel.addr = u64_to_user_ptr(buf->addr); - if (issue_flags & IO_URING_F_UNLOCKED || !io_file_can_poll(req)) { + if (issue_flags & IO_URING_F_UNLOCKED || (!io_file_can_poll(req) && + !io_commit_kbuf_upfront(req))) { /* * If we came in unlocked, we have no choice but to consume the * buffer here, otherwise nothing ensures that the buffer won't -- 2.47.1 From - Thu Oct 23 10:51:52 2025 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-Path: Delivered-To: hi@josie.lol Received: from witcher.mxrouting.net by witcher.mxrouting.net with LMTP id wP/wEsUI+mj6sBgAYBR5ng (envelope-from ) for ; Thu, 23 Oct 2025 10:51:49 +0000 Return-path: Envelope-to: hi@josie.lol Delivery-date: Thu, 23 Oct 2025 10:51:49 +0000 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by witcher.mxrouting.net with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98) (envelope-from ) id 1vBsv7-000000071CG-09Ko for hi@josie.lol; Thu, 23 Oct 2025 10:51:49 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E77303A477A for ; Thu, 23 Oct 2025 10:51:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62E5930ACF1; Thu, 23 Oct 2025 10:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HNQZ+/yO" X-Original-To: stable@vger.kernel.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3323D30AACB for ; Thu, 23 Oct 2025 10:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761216704; cv=none; b=EQUxfEcXmivgenIpDm8U+Tj+sx3TUbFzjZgRaIq3Mxs+oI571n5JBsVKOkxju6m ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2025 05:06:45 -0700 X-CSE-ConnectionGUID: tSitkFo/QTyDESIgSNDvwA== X-CSE-MsgGUID: 0Auo8vX1RCWbkqL2ng1u1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,249,1754982000"; d="scan'208";a="184916161" Received: from lkp-server02.sh.intel.com (HELO 66d7546c76b2) ([10.239.97.151]) by fmviesa010.fm.intel.com with ESMTP; 23 Oct 2025 05:06:37 -0700 Received: from kbuild by 66d7546c76b2 with local (Exim 4.96) (envelope-from ) id 1vBu5S-000DRp-2V; Thu, 23 Oct 2025 12:06:34 +0000 Date: Thu, 23 Oct 2025 20:05:39 +0800 From: kernel test robot To: Caleb Sander Mateos , Jens Axboe , Miklos Szeredi , Ming Lei , Keith Busch , Christoph Hellwig , Sagi Grimberg , Chris Mason , David Sterba Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: Re: [PATCH 3/3] io_uring/uring_cmd: avoid double indirect call in task work dispatch Message-ID: <202510231952.gAXMcT2A-lkp@intel.com> References: <20251022231326.2527838-4-csander@purestorage.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251022231326.2527838-4-csander@purestorage.com> X-DKIM: signer='intel.com' status='pass' reason='' DKIMCheck: Server passes DKIM test, 0 Spam score X-DKIM: signer='@intel.com' status='pass' reason='' X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "witcher.mxrouting.net", has performed the tests listed below against this email. Information: https://mxroutedocs.com/directadmin/spamfilters/ --- Content analysis details: (0.4 points) --- pts rule name description ---- ---------------------- ----------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: 01.org] 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block for more information. [213.196.21.55 listed in list.dnswl.org] 1.5 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender SpamTally: Final spam score: 4 Hi Caleb, kernel test robot noticed the following build errors: [auto build test ERROR on axboe-block/for-next] [also build test ERROR on kdave/for-next linus/master v6.18-rc2] [cannot apply to mszeredi-fuse/for-next linux-nvme/for-next next-20251023] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Caleb-Sander-Mateos/io_uring-expose-io_should_terminate_tw/20251023-071617 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next patch link: https://lore.kernel.org/r/20251022231326.2527838-4-csander%40purestorage.com patch subject: [PATCH 3/3] io_uring/uring_cmd: avoid double indirect call in task work dispatch config: x86_64-buildonly-randconfig-005-20251023 (https://download.01.org/0day-ci/archive/20251023/202510231952.gAXMcT2A-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251023/202510231952.gAXMcT2A-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202510231952.gAXMcT2A-lkp@intel.com/ All errors (new ones prefixed by >>): >> block/ioctl.c:783:1: error: invalid storage class specifier in function declarator 783 | static void bio_cmd_bio_end_io(struct bio *bio) | ^ >> block/ioctl.c:783:13: error: parameter named 'bio_cmd_bio_end_io' is missing 783 | static void bio_cmd_bio_end_io(struct bio *bio) | ^ >> block/ioctl.c:783:48: error: expected ';' at end of declaration 783 | static void bio_cmd_bio_end_io(struct bio *bio) | ^ | ; >> block/ioctl.c:781:38: error: parameter 'blk_cmd_complete' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 781 | static DEFINE_IO_URING_CMD_TASK_WORK(blk_cmd_complete) | ^ 782 | 783 | static void bio_cmd_bio_end_io(struct bio *bio) 784 | { >> block/ioctl.c:781:8: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 781 | static DEFINE_IO_URING_CMD_TASK_WORK(blk_cmd_complete) | ~~~~~~ ^ | int >> block/ioctl.c:785:29: error: use of undeclared identifier 'bio' 785 | struct io_uring_cmd *cmd = bio->bi_private; | ^ block/ioctl.c:788:15: error: use of undeclared identifier 'bio' 788 | if (unlikely(bio->bi_status) && !bic->res) | ^ block/ioctl.c:789:34: error: use of undeclared identifier 'bio' 789 | bic->res = blk_status_to_errno(bio->bi_status); | ^ >> block/ioctl.c:791:2: error: call to undeclared function 'IO_URING_CMD_TASK_WORK'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 791 | io_uring_cmd_do_in_task_lazy(cmd, blk_cmd_complete); | ^ include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^ block/ioctl.c:791:2: note: did you mean 'DEFINE_IO_URING_CMD_TASK_WORK'? include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^ block/ioctl.c:781:8: note: 'DEFINE_IO_URING_CMD_TASK_WORK' declared here 781 | static DEFINE_IO_URING_CMD_TASK_WORK(blk_cmd_complete) | ^ >> block/ioctl.c:791:2: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'io_req_tw_func_t' (aka 'void (*)(struct io_kiocb *, struct io_tw_state)') [-Wint-conversion] 791 | io_uring_cmd_do_in_task_lazy(cmd, blk_cmd_complete); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/io_uring/cmd.h:123:25: note: passing argument to parameter 'task_work_cb' here 123 | io_req_tw_func_t task_work_cb, unsigned flags) | ^ block/ioctl.c:792:10: error: use of undeclared identifier 'bio'; did you mean 'bic'? 792 | bio_put(bio); | ^~~ | bic block/ioctl.c:786:22: note: 'bic' declared here 786 | struct blk_iou_cmd *bic = io_uring_cmd_to_pdu(cmd, struct blk_iou_cmd); | ^ >> block/ioctl.c:781:8: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Werror,-Wdeprecated-non-prototype] 781 | static DEFINE_IO_URING_CMD_TASK_WORK(blk_cmd_complete) | ^ >> block/ioctl.c:847:20: error: use of undeclared identifier 'bio_cmd_bio_end_io' 847 | prev->bi_end_io = bio_cmd_bio_end_io; | ^ 13 errors generated. -- >> drivers/nvme/host/ioctl.c:412:1: error: invalid storage class specifier in function declarator 412 | static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req, | ^ >> drivers/nvme/host/ioctl.c:412:27: error: parameter named 'nvme_uring_cmd_end_io' is missing 412 | static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req, | ^ >> drivers/nvme/host/ioctl.c:413:24: error: expected ';' at end of declaration 413 | blk_status_t err) | ^ | ; >> drivers/nvme/host/ioctl.c:410:38: error: parameter 'nvme_uring_task_cb' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 410 | static DEFINE_IO_URING_CMD_TASK_WORK(nvme_uring_task_cb) | ^ 411 | 412 | static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req, 413 | blk_status_t err) 414 | { >> drivers/nvme/host/ioctl.c:410:8: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 410 | static DEFINE_IO_URING_CMD_TASK_WORK(nvme_uring_task_cb) | ~~~~~~ ^ | int >> drivers/nvme/host/ioctl.c:415:32: error: use of undeclared identifier 'req' 415 | struct io_uring_cmd *ioucmd = req->end_io_data; | ^ drivers/nvme/host/ioctl.c:418:15: error: use of undeclared identifier 'req' 418 | if (nvme_req(req)->flags & NVME_REQ_CANCELLED) { | ^ drivers/nvme/host/ioctl.c:421:26: error: use of undeclared identifier 'req' 421 | pdu->status = nvme_req(req)->status; | ^ >> drivers/nvme/host/ioctl.c:423:38: error: use of undeclared identifier 'err' 423 | pdu->status = blk_status_to_errno(err); | ^ drivers/nvme/host/ioctl.c:425:37: error: use of undeclared identifier 'req' 425 | pdu->result = le64_to_cpu(nvme_req(req)->result.u64); | ^ include/linux/byteorder/generic.h:87:21: note: expanded from macro 'le64_to_cpu' 87 | #define le64_to_cpu __le64_to_cpu | ^ >> drivers/nvme/host/ioctl.c:435:2: error: call to undeclared function 'IO_URING_CMD_TASK_WORK'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 435 | io_uring_cmd_do_in_task_lazy(ioucmd, nvme_uring_task_cb); | ^ include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^ drivers/nvme/host/ioctl.c:435:2: note: did you mean 'DEFINE_IO_URING_CMD_TASK_WORK'? include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^ drivers/nvme/host/ioctl.c:410:8: note: 'DEFINE_IO_URING_CMD_TASK_WORK' declared here 410 | static DEFINE_IO_URING_CMD_TASK_WORK(nvme_uring_task_cb) | ^ >> drivers/nvme/host/ioctl.c:435:2: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'io_req_tw_func_t' (aka 'void (*)(struct io_kiocb *, struct io_tw_state)') [-Wint-conversion] 435 | io_uring_cmd_do_in_task_lazy(ioucmd, nvme_uring_task_cb); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/io_uring/cmd.h:149:7: note: expanded from macro 'io_uring_cmd_do_in_task_lazy' 149 | IO_URING_CMD_TASK_WORK(uring_cmd_cb), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/io_uring/cmd.h:123:25: note: passing argument to parameter 'task_work_cb' here 123 | io_req_tw_func_t task_work_cb, unsigned flags) | ^ >> drivers/nvme/host/ioctl.c:410:8: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Werror,-Wdeprecated-non-prototype] 410 | static DEFINE_IO_URING_CMD_TASK_WORK(nvme_uring_task_cb) | ^ >> drivers/nvme/host/ioctl.c:524:16: error: use of undeclared identifier 'nvme_uring_cmd_end_io'; did you mean 'nvme_uring_cmd_io'? 524 | req->end_io = nvme_uring_cmd_end_io; | ^~~~~~~~~~~~~~~~~~~~~ | nvme_uring_cmd_io drivers/nvme/host/ioctl.c:439:12: note: 'nvme_uring_cmd_io' declared here 439 | static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, | ^ 14 errors generated. vim +783 block/ioctl.c 50c52250e2d74b Pavel Begunkov 2024-09-11 771 50c52250e2d74b Pavel Begunkov 2024-09-11 772 static void blk_cmd_complete(struct io_uring_cmd *cmd, unsigned int issue_flags) 50c52250e2d74b Pavel Begunkov 2024-09-11 773 { 50c52250e2d74b Pavel Begunkov 2024-09-11 774 struct blk_iou_cmd *bic = io_uring_cmd_to_pdu(cmd, struct blk_iou_cmd); 50c52250e2d74b Pavel Begunkov 2024-09-11 775 50c52250e2d74b Pavel Begunkov 2024-09-11 776 if (bic->res == -EAGAIN && bic->nowait) 50c52250e2d74b Pavel Begunkov 2024-09-11 777 io_uring_cmd_issue_blocking(cmd); 50c52250e2d74b Pavel Begunkov 2024-09-11 778 else ef9f603fd3d4b7 Caleb Sander Mateos 2025-09-22 779 io_uring_cmd_done(cmd, bic->res, issue_flags); 50c52250e2d74b Pavel Begunkov 2024-09-11 780 } c004e50b1d8661 Caleb Sander Mateos 2025-10-22 @781 static DEFINE_IO_URING_CMD_TASK_WORK(blk_cmd_complete) 50c52250e2d74b Pavel Begunkov 2024-09-11 782 50c52250e2d74b Pavel Begunkov 2024-09-11 @783 static void bio_cmd_bio_end_io(struct bio *bio) 50c52250e2d74b Pavel Begunkov 2024-09-11 784 { 50c52250e2d74b Pavel Begunkov 2024-09-11 @785 struct io_uring_cmd *cmd = bio->bi_private; 50c52250e2d74b Pavel Begunkov 2024-09-11 786 struct blk_iou_cmd *bic = io_uring_cmd_to_pdu(cmd, struct blk_iou_cmd); 50c52250e2d74b Pavel Begunkov 2024-09-11 787 50c52250e2d74b Pavel Begunkov 2024-09-11 788 if (unlikely(bio->bi_status) && !bic->res) 50c52250e2d74b Pavel Begunkov 2024-09-11 789 bic->res = blk_status_to_errno(bio->bi_status); 50c52250e2d74b Pavel Begunkov 2024-09-11 790 50c52250e2d74b Pavel Begunkov 2024-09-11 @791 io_uring_cmd_do_in_task_lazy(cmd, blk_cmd_complete); 50c52250e2d74b Pavel Begunkov 2024-09-11 792 bio_put(bio); 50c52250e2d74b Pavel Begunkov 2024-09-11 793 } 50c52250e2d74b Pavel Begunkov 2024-09-11 794 50c52250e2d74b Pavel Begunkov 2024-09-11 795 static int blkdev_cmd_discard(struct io_uring_cmd *cmd, 50c52250e2d74b Pavel Begunkov 2024-09-11 796 struct block_device *bdev, 50c52250e2d74b Pavel Begunkov 2024-09-11 797 uint64_t start, uint64_t len, bool nowait) 50c52250e2d74b Pavel Begunkov 2024-09-11 798 { 50c52250e2d74b Pavel Begunkov 2024-09-11 799 struct blk_iou_cmd *bic = io_uring_cmd_to_pdu(cmd, struct blk_iou_cmd); 50c52250e2d74b Pavel Begunkov 2024-09-11 800 gfp_t gfp = nowait ? GFP_NOWAIT : GFP_KERNEL; 50c52250e2d74b Pavel Begunkov 2024-09-11 801 sector_t sector = start >> SECTOR_SHIFT; 50c52250e2d74b Pavel Begunkov 2024-09-11 802 sector_t nr_sects = len >> SECTOR_SHIFT; 50c52250e2d74b Pavel Begunkov 2024-09-11 803 struct bio *prev = NULL, *bio; 50c52250e2d74b Pavel Begunkov 2024-09-11 804 int err; 50c52250e2d74b Pavel Begunkov 2024-09-11 805 50c52250e2d74b Pavel Begunkov 2024-09-11 806 if (!bdev_max_discard_sectors(bdev)) 50c52250e2d74b Pavel Begunkov 2024-09-11 807 return -EOPNOTSUPP; 50c52250e2d74b Pavel Begunkov 2024-09-11 808 if (!(file_to_blk_mode(cmd->file) & BLK_OPEN_WRITE)) 50c52250e2d74b Pavel Begunkov 2024-09-11 809 return -EBADF; 50c52250e2d74b Pavel Begunkov 2024-09-11 810 if (bdev_read_only(bdev)) 50c52250e2d74b Pavel Begunkov 2024-09-11 811 return -EPERM; 50c52250e2d74b Pavel Begunkov 2024-09-11 812 err = blk_validate_byte_range(bdev, start, len); 50c52250e2d74b Pavel Begunkov 2024-09-11 813 if (err) 50c52250e2d74b Pavel Begunkov 2024-09-11 814 return err; 50c52250e2d74b Pavel Begunkov 2024-09-11 815 50c52250e2d74b Pavel Begunkov 2024-09-11 816 err = filemap_invalidate_pages(bdev->bd_mapping, start, 50c52250e2d74b Pavel Begunkov 2024-09-11 817 start + len - 1, nowait); 50c52250e2d74b Pavel Begunkov 2024-09-11 818 if (err) 50c52250e2d74b Pavel Begunkov 2024-09-11 819 return err; 50c52250e2d74b Pavel Begunkov 2024-09-11 820 50c52250e2d74b Pavel Begunkov 2024-09-11 821 while (true) { 50c52250e2d74b Pavel Begunkov 2024-09-11 822 bio = blk_alloc_discard_bio(bdev, §or, &nr_sects, gfp); 50c52250e2d74b Pavel Begunkov 2024-09-11 823 if (!bio) 50c52250e2d74b Pavel Begunkov 2024-09-11 824 break; 50c52250e2d74b Pavel Begunkov 2024-09-11 825 if (nowait) { 50c52250e2d74b Pavel Begunkov 2024-09-11 826 /* 50c52250e2d74b Pavel Begunkov 2024-09-11 827 * Don't allow multi-bio non-blocking submissions as 50c52250e2d74b Pavel Begunkov 2024-09-11 828 * subsequent bios may fail but we won't get a direct 50c52250e2d74b Pavel Begunkov 2024-09-11 829 * indication of that. Normally, the caller should 50c52250e2d74b Pavel Begunkov 2024-09-11 830 * retry from a blocking context. 50c52250e2d74b Pavel Begunkov 2024-09-11 831 */ 50c52250e2d74b Pavel Begunkov 2024-09-11 832 if (unlikely(nr_sects)) { 50c52250e2d74b Pavel Begunkov 2024-09-11 833 bio_put(bio); 50c52250e2d74b Pavel Begunkov 2024-09-11 834 return -EAGAIN; 50c52250e2d74b Pavel Begunkov 2024-09-11 835 } 50c52250e2d74b Pavel Begunkov 2024-09-11 836 bio->bi_opf |= REQ_NOWAIT; 50c52250e2d74b Pavel Begunkov 2024-09-11 837 } 50c52250e2d74b Pavel Begunkov 2024-09-11 838 50c52250e2d74b Pavel Begunkov 2024-09-11 839 prev = bio_chain_and_submit(prev, bio); 50c52250e2d74b Pavel Begunkov 2024-09-11 840 } 50c52250e2d74b Pavel Begunkov 2024-09-11 841 if (unlikely(!prev)) 50c52250e2d74b Pavel Begunkov 2024-09-11 842 return -EAGAIN; 50c52250e2d74b Pavel Begunkov 2024-09-11 843 if (unlikely(nr_sects)) 50c52250e2d74b Pavel Begunkov 2024-09-11 844 bic->res = -EAGAIN; 50c52250e2d74b Pavel Begunkov 2024-09-11 845 50c52250e2d74b Pavel Begunkov 2024-09-11 846 prev->bi_private = cmd; 50c52250e2d74b Pavel Begunkov 2024-09-11 @847 prev->bi_end_io = bio_cmd_bio_end_io; 50c52250e2d74b Pavel Begunkov 2024-09-11 848 submit_bio(prev); 50c52250e2d74b Pavel Begunkov 2024-09-11 849 return -EIOCBQUEUED; 50c52250e2d74b Pavel Begunkov 2024-09-11 850 } 50c52250e2d74b Pavel Begunkov 2024-09-11 851 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From - Thu Oct 23 12:09:35 2025 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-Path: Delivered-To: hi@josie.lol Received: from witcher.mxrouting.net by witcher.mxrouting.net with LMTP id wOoOGfwa+mgX2x8AYBR5ng (envelope-from ) for ; Thu, 23 Oct 2025 12:09:32 +0000 Return-path: Envelope-to: hi@josie.lol Delivery-date: Thu, 23 Oct 2025 12:09:32 +0000 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by witcher.mxrouting.net with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98) (envelope-from ) id 1vBu8J-00000009O3g-43Ts for hi@josie.lol; Thu, 23 Oct 2025 12:09:32 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C04BE3A2BC3 for ; Thu, 23 Oct 2025 12:09:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A68963093A5; Thu, 23 Oct 2025 12:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="JRAcOFX+" X-Original-To: linux-s390@vger.kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F79C298CA6; Thu, 23 Oct 2025 12:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761221369; cv=none; b=eh2nlu4fPZZIi0Ya9mSvr+FK7LPu3v9HNYn3iyphH2zMJrj6viBVZyHdPQX9HJL7t4YK8t9XNAQ9lBxmcDWFdu6WYJEIQrYKClmMzmKaXIs7nQ3kZkXrKO7r+4YA1JGGBoUnpepJ2VlXQjDV1i53zp1K2gtNu4MFvWbMbzvW64E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761221369; c=relaxed/simple; bh=/DcS6meh8ToFHcZVBznALSdZkmmnpxUxjcWcARCG0XY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=iGlQpZkm8630rqmdlBz1a8jNSxc3EF4mO8BVBvm81WdUlf27cLkUHA58F0E7O9HNXrqm6nU8PwNT0QUy8JytB3OtWj76dAyb22tcwxbLAIb85VETC23MPcti1pmD/ioepWXATEP+X1F5b0BBjJ7DYU1m80wbHuNUezc9Xt2Nrj0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=JRAcOFX+; arc=none smtp.