From nobody Thu Apr 2 21:53:23 2026 Received: from mail-yx1-f97.google.com (mail-yx1-f97.google.com [74.125.224.97]) (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 695DF1AA7A6 for ; Fri, 13 Feb 2026 03:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770952892; cv=none; b=INXWf6cqjwA+Vb3XNqmqt1otr05eF9q/3uuPj+RFzQ8pLkut76zPQIxkNS9p938cf4YlMdHDH129gVaqic+Z2TKLWqD5ku8DbRBgn355EDNaIr6IHAoJJiYmtYUfqXSb2A6qwxpRj/yhAPDqABrHPYwttnqG5Gybrk6QHfOc50g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770952892; c=relaxed/simple; bh=lZe3fxg+VQ5lhyCBMGop87GGnO7ejMyIhE9/3qGM+vI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HZfGfqNHbej5nADrptYh06cxYusRNP4vEL4H8RMYCSvoqj5Pd0kz/R0382wYFxeoYfkDTx306zK7XRvyI2spIB1yETRN2KCXO1HbNnaRwAeqGryTHkUq43LklFR5fW3jr5hV9lBy8GbbZMpu6gqnAWz4zHMdGOUA37qfwEYSlO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=BAq4MNg0; arc=none smtp.client-ip=74.125.224.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="BAq4MNg0" Received: by mail-yx1-f97.google.com with SMTP id 956f58d0204a3-64ad4839e3cso34854d50.0 for ; Thu, 12 Feb 2026 19:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1770952888; x=1771557688; darn=vger.kernel.org; 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=HDAVuczYme2L/3ZbykT5XhXGRZz1afWAoembS53B+4k=; b=BAq4MNg0mKL6GrhnFpnoIoHPtbzZWwLOpvaJUubnl9L/FZqztJtKJ11fZh9UQDEZvB fsdLb4Y32VCdrsRzRNYe/eJLORY8KjoHJM52tRaV7/oyg4FUHhn31/+8M/4Utx3jjx+0 3hdXPMhQdlLukGtqQ2T2vGbfWqQhGXobUllEPVX8ozOasbP0/t2iwqoC5JjMlOzdZYj8 kCs5crCwyG1GnJUHye2gal0xoIXgo7dcU9xET4Wl+Zdxh5ffy5xc4ysgBh1fyDvhjtfD axOV8SYCk0ChcFT4p6KwVAXJfeeWS7e1nDc6Ap38NZ7vpqQRmYBaaYlMpKVEhD0o6yKV YIzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770952888; x=1771557688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HDAVuczYme2L/3ZbykT5XhXGRZz1afWAoembS53B+4k=; b=gmW6zWM6spfiqLbrYGsXZCGXH/8EYQjlREtkSDyBaMP2wNWQamZ/xIVrGu0p70iF8N 23TKaaOXF3zjudmMfLYMSaIKTjG4DpQeSgc43w9JVyriqZteQLvleNu/yvuDU1m4DPqW CHOncgr2fdHAS0w5+hunl9bLAd0KLuk7v+PQB+Q1gmPZ1SgDwdAX2/NViLHdJ3V+EaFT tIM+IfTbRVm+ucr6AHvYOhgZaTHFqlLQhIWasWYpo/miegFqL/V4MvMP+pUjTojaB2cF z83tSjLpceWBCJ3bhFlWPg84EHqHjkwOU1Xv81H0WFyveBxZyZRAx+MXWaiplqfJlM1E bBhA== X-Forwarded-Encrypted: i=1; AJvYcCWom4BN8VYlDIn4W/c1d3irsnbCBeLUILS46vhExnTerp/b1RNhlKGm//JSQ1w9kxZT6i/VM/smIOZn1uI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxk3ZQNMfJvouyaYSAGyeMVRD3zTSt5SdnzdhDsMSKYHzZC3shM Wea56eAb3pB+1WFfUx7/wbQ1+HgyOjIwWKyf9hwq9fOT9qXw1w27nBnt213ErUQCYtvjUbgdYq/ UNKFAuqEITJPISH8uzbBa3ycGSY2whtgdDf6+ X-Gm-Gg: AZuq6aJenSKDG6IB+nOj5NBdPzT8p0405+83Vo1K0nTbahwsvrJtUd4XyDONpZjx+ti pLeE4PN/wtVJonsuj6MqxTkYGwG9Guqlnm2AVUEdivbEDh0n/EiT+dS22uCIvXsc+52Thts8MC7 oixOmRKdmfHyJnbKuq61LOGI8IByDnwraohd3H89VDQrfSsGdwcnNOTVj4HpMy3AsmsHzelwWyR yoUKVFPy4uUs7F0nlm0j5nI3u3dFcwE4A53LqEs3hyZeAJJ6m52RTlR7MQhqGbVMQFt7bKruf4l LS3IV8iatka2ijpfbxHVdjvRUEnhJR5li+BU5ZMVYWp5d4o/Eo1fv+ULzgTggL5i+AdKiSHzd3S OvAdvRyWizpRgGQWJ5w8BEcy8bBYYOlAsIgwib3U+9DDqG0wH2A2X5w== X-Received: by 2002:a05:690e:bcc:b0:64a:dafd:2d5b with SMTP id 956f58d0204a3-64c14d8e089mr1001606d50.3.1770952888480; Thu, 12 Feb 2026 19:21:28 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id 956f58d0204a3-64afc969f13sm637387d50.11.2026.02.12.19.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 19:21:28 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id E0187342181; Thu, 12 Feb 2026 20:21:27 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id DA782E41DCC; Thu, 12 Feb 2026 20:21:27 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe , Christoph Hellwig , Keith Busch , Sagi Grimberg Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 2/3] io_uring/uring_cmd: allow non-iopoll cmds with IORING_SETUP_IOPOLL Date: Thu, 12 Feb 2026 20:21:18 -0700 Message-ID: <20260213032119.1125331-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260213032119.1125331-1-csander@purestorage.com> References: <20260213032119.1125331-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, creating an io_uring with IORING_SETUP_IOPOLL requires all requests issued to it to support iopoll. This prevents, for example, using ublk zero-copy together with IORING_SETUP_IOPOLL, as ublk zero-copy buffer registrations are performed using a uring_cmd. There's no technical reason why these non-iopoll uring_cmds can't be supported. They will either complete synchronously or via an external mechanism that calls io_uring_cmd_done(), so they don't need to be polled. Allow uring_cmd requests to be issued to IORING_SETUP_IOPOLL io_urings even if their files don't implement ->uring_cmd_iopoll(). For these uring_cmd requests, skip initializing struct io_kiocb's iopoll fields, don't insert the request into iopoll_list, and take the io_req_complete_defer() or io_req_task_work_add() path in __io_uring_cmd_done() instead of setting the iopoll_completed flag. Also allow io_uring_cmd_mark_cancelable() to be called on these uring_cmds. Assert that io_uring_cmd_mark_cancelable() is only called on non-IORING_SETUP_IOPOLL io_urings or uring_cmds to files that don't implement ->uring_cmd_iopoll(). Signed-off-by: Caleb Sander Mateos --- io_uring/io_uring.c | 4 +++- io_uring/uring_cmd.c | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index c45af82dda3d..4e68a5168894 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1417,11 +1417,13 @@ static int io_issue_sqe(struct io_kiocb *req, unsig= ned int issue_flags) =20 if (ret =3D=3D IOU_ISSUE_SKIP_COMPLETE) { ret =3D 0; =20 /* If the op doesn't have a file, we're not polling for it */ - if ((req->ctx->flags & IORING_SETUP_IOPOLL) && def->iopoll_queue) + if ((req->ctx->flags & IORING_SETUP_IOPOLL) && + def->iopoll_queue && (!io_is_uring_cmd(req) || + req->file->f_op->uring_cmd_iopoll)) io_iopoll_req_issued(req, issue_flags); } return ret; } =20 diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index ee7b49f47cb5..8df52e8f1c1b 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -108,12 +108,12 @@ void io_uring_cmd_mark_cancelable(struct io_uring_cmd= *cmd, * Doing cancelations on IOPOLL requests are not supported. Both * because they can't get canceled in the block stack, but also * because iopoll completion data overlaps with the hash_node used * for tracking. */ - if (ctx->flags & IORING_SETUP_IOPOLL) - return; + WARN_ON_ONCE(ctx->flags & IORING_SETUP_IOPOLL && + req->file->f_op->uring_cmd_iopoll); =20 if (!(cmd->flags & IORING_URING_CMD_CANCELABLE)) { cmd->flags |=3D IORING_URING_CMD_CANCELABLE; io_ring_submit_lock(ctx, issue_flags); hlist_add_head(&req->hash_node, &ctx->cancelable_uring_cmd); @@ -165,11 +165,12 @@ void __io_uring_cmd_done(struct io_uring_cmd *ioucmd,= s32 ret, u64 res2, if (req->ctx->flags & IORING_SETUP_CQE_MIXED) req->cqe.flags |=3D IORING_CQE_F_32; io_req_set_cqe32_extra(req, res2, 0); } io_req_uring_cleanup(req, issue_flags); - if (req->ctx->flags & IORING_SETUP_IOPOLL) { + if (req->ctx->flags & IORING_SETUP_IOPOLL && + req->file->f_op->uring_cmd_iopoll) { /* order with io_iopoll_req_issued() checking ->iopoll_complete */ smp_store_release(&req->iopoll_completed, 1); } else if (issue_flags & IO_URING_F_COMPLETE_DEFER) { if (WARN_ON_ONCE(issue_flags & IO_URING_F_UNLOCKED)) return; @@ -255,13 +256,11 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int i= ssue_flags) issue_flags |=3D IO_URING_F_SQE128; if (ctx->flags & (IORING_SETUP_CQE32 | IORING_SETUP_CQE_MIXED)) issue_flags |=3D IO_URING_F_CQE32; if (io_is_compat(ctx)) issue_flags |=3D IO_URING_F_COMPAT; - if (ctx->flags & IORING_SETUP_IOPOLL) { - if (!file->f_op->uring_cmd_iopoll) - return -EOPNOTSUPP; + if (ctx->flags & IORING_SETUP_IOPOLL && file->f_op->uring_cmd_iopoll) { issue_flags |=3D IO_URING_F_IOPOLL; req->iopoll_completed =3D 0; if (ctx->flags & IORING_SETUP_HYBRID_IOPOLL) { /* make sure every req only blocks once */ req->flags &=3D ~REQ_F_IOPOLL_STATE; --=20 2.45.2