From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f228.google.com (mail-pf1-f228.google.com [209.85.210.228]) (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 0C9DD3C9886 for ; Thu, 27 Aug 2026 18:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.228 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787857071; cv=none; b=lPWAPDJYQhqJzX8bpUDgFVhUXAaeLd4rWp7FUkdOLol/o/iYgVyBSegzfA9XC9W54xexddXKaFICJ38DXvpalSRRhiNIOM/9YZQyghLz8K/4NWyJ3lGfGQqhhl6rpYucxaW1h9bgsfvsHd7CSNCX0M2+TCgqjpQP1X6moRa2/24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787857071; c=relaxed/simple; bh=bId58P1f3rx83kEyCFQCmbOQueTyIg0Jg1Ag1a5jGfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAnGOX9V/L2mQEq8AUqAfb29C6QIQZk22Mv4bmwRXGY28Hl+NIL7uC36nFCcY62teAluDShxEB75vAyJKpv59nCcQnzukmqNLB+JX//A9ff5YBHdYzdECqWlGNlRUyI7kc9OkUsjuJvikpwxJxYf/70NWyXeJ1mNkhLb1Qs13TY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=pass smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Q9rrg5rA; arc=none smtp.client-ip=209.85.210.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=pass 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="Q9rrg5rA" Received: by mail-pf1-f228.google.com with SMTP id d2e1a72fcca58-85237ffb172so17879b3a.3 for ; Thu, 27 Aug 2026 11:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1787857052; x=1788461852; 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:content-type; bh=Ex+RB5aItdA3h/bx30wNaWsAq7n74S1CMmypqWLJ+1k=; b=Q9rrg5rARoepcGhMNERctdSNthFuFWKbtn0YACk+MDoFqExmU3YFRTvG4ddSXeXGLJ ZjOTr7Ezz8nshhwzVsbdrmg3gYansSJK9e/QTsJP2bESpb3QEJz2jtmfpTJjuRSdYNMu aaZCMl7Yy+5xfIj+vZI+Q+ta2uBdSzlmlpwwa8izr7BTDocl3P69ejOOb/bEMlKBoAhl kdD+4ZbDp3ve0Ph6K/GhwDG/SyTHQV8BU9IM2YaIsO+j4edvVUURTqXDbaHUdBm5eHHb oPdddvES6u1xiuAyc+VDqmxWLO0Y0d3vwmTbrqOJQSq4FcKAeKXYfQR3aRWr3NY2/pxG PPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787857052; x=1788461852; 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:content-type; bh=Ex+RB5aItdA3h/bx30wNaWsAq7n74S1CMmypqWLJ+1k=; b=oFsA8Eg6Mb6AviuST1BYo6uaKHc5Fjbz1dHSWv1eKtbRVp6F4fOGQD1cIhA/Te7p41 WQPCNkSrhZatzTCegXHjydJYp28GbcRbivIlNgs4Lq6Gs1Te6uQvHMRoSUjYboFQ6FfS Z/b1rGfHh0INLnJ2p0pOzPORoROrsBQzBb4U0MCToZf7jG+z0xt8aIFVhzra7P6Z9bnL C7pZOmM6vvYWo+469CD82DNzHFF4qikzA9kIbYg/6L44gpAmY2EOQicQ1qksvXqSWj2p irjbwQ/Ke14Q9BjsMZ3AnNUg5PDLV/FHmQeQfK8i2qqzhhW3Yoz7BAiqqsmRhIKuHWe2 Q11g== X-Forwarded-Encrypted: i=1; AHgh+RquQIsvnKXpjKtY1Xr1fNAcuNrTZX2c96Iwet7d7pDXezLNSV6S9fgFDHywnOkSG0cpDv+yr8engw==@vger.kernel.org X-Gm-Message-State: AFuF++kh6rwMMh+zbEk0hcGl0dpH5eYqT7VWgbJwc5A8RcSlBwrFWfD2 YPv9X9zOdIaV5UsvSs59oofIBEdk/3IIrUx4+SDtdyn13oTVB0s9Lj9tUtCulLzqvs2b5AZ/PiC SkNXWH2zcnS5KM2+UrGtblOAA9LPNNH6tRzGwzggnJQmb64qnIATe X-Gm-Gg: AR+sD12vDd5vtgttMG6I8Q5jEGyhvcvKSPBRH6ldkfFrNBZbqoDzN7QWIymlIhWD755 Hu/s4fL4x0AO9Xpftrl9HRRhqJgCbc3toqdt6IbAVjTdpoLjNri7jygdX7T1l31DQ/bm+ykVGmG H5zH2gksZgrSH/7vE6PQv7o+iri4XE80YXF8RKpKvuSbbaJtMCdth9fIk9+2rcqnxNCZ2yTeCUe +zwaU4cPpjPxhAZc0bihLbhQeuJyaIFyFe04f2pZc7cNSGqIPKVNBzm/SRbuPXdG3bEXS1BEsFb ktDWrgZupEoBTE+lFNHgHAuRuWIDkHRqUqgz5gmC2XlGmefbhQ5xvDL2CKk9NDtp6I/ExVxBObE u0R6doWYnYN6/KHiaJg== X-Received: by 2002:a05:6a00:4449:b0:851:c2bd:43d1 with SMTP id d2e1a72fcca58-85628a85b9amr829996b3a.1.1787857051450; Thu, 27 Aug 2026 11:57:31 -0700 (PDT) Received: from c7-smtp-2026.dev.purestorage.com ([2620:125:9017:12:36:3:6:0]) by smtp-relay.gmail.com with ESMTPS id d2e1a72fcca58-8538d0c4935sm2212871b3a.7.2026.08.27.11.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2026 11:57:31 -0700 (PDT) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.12.104]) by c7-smtp-2026.dev.purestorage.com (Postfix) with ESMTP id A24254030A; Thu, 27 Aug 2026 12:57:30 -0600 (MDT) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 9F60AE404C2; Thu, 27 Aug 2026 12:57:30 -0600 (MDT) From: Caleb Sander Mateos To: Jens Axboe , Ming Lei , Keith Busch , Christoph Hellwig , Sagi Grimberg , "James E.J. Bottomley" , "Martin K. Petersen" , Chris Mason , David Sterba , Bernd Schubert , Joanne Koong , Miklos Szeredi Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, linux-btrfs@vger.kernel.org, fuse-devel@lists.linux.dev, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 2/2] nvme/ioctl: call io_uring_cmd_set_res32() in ->end_io() Date: Thu, 27 Aug 2026 12:57:21 -0600 Message-ID: <20260827185722.3234622-3-csander@purestorage.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260827185722.3234622-1-csander@purestorage.com> References: <20260827185722.3234622-1-csander@purestorage.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 io_uring_cmd_set_res32() only performs loads and stores to the io_uring request state, so it's safe to call in interrupt context. Move the call from the nvme_uring_task_cb() task work to nvme_uring_cmd_end_io(). This unifies the 2 io_uring_cmd_set_res32() callers and removes the need to pass result and status through struct nvme_uring_cmd_pdu, saving 16 bytes and a couple memory accesses. Signed-off-by: Caleb Sander Mateos --- drivers/nvme/host/ioctl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 131959c00287..b50bba207818 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -421,12 +421,10 @@ struct nvme_uring_data { * Expect build errors if this grows larger than that. */ struct nvme_uring_cmd_pdu { struct request *req; struct bio *bio; - u64 result; - int status; }; static inline struct nvme_uring_cmd_pdu *nvme_uring_cmd_pdu( struct io_uring_cmd *ioucmd) { @@ -438,29 +436,30 @@ static void nvme_uring_task_cb(struct io_tw_req tw_req, io_tw_token_t tw) struct io_uring_cmd *ioucmd = io_uring_cmd_from_tw(tw_req); struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd); if (pdu->bio) blk_rq_unmap_user(pdu->bio); - io_uring_cmd_set_res32(ioucmd, pdu->status, pdu->result); io_uring_cmd_done(ioucmd, IO_URING_CMD_TASK_WORK_ISSUE_FLAGS); } static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req, blk_status_t err, const struct io_comp_batch *iob) { struct io_uring_cmd *ioucmd = req->end_io_data; struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd); + u64 result = le64_to_cpu(nvme_req(req)->result.u64); + int status; if (nvme_req(req)->flags & NVME_REQ_CANCELLED) { - pdu->status = -EINTR; + status = -EINTR; } else { - pdu->status = nvme_req(req)->status; - if (!pdu->status) - pdu->status = blk_status_to_errno(err); + status = nvme_req(req)->status; + if (!status) + status = blk_status_to_errno(err); } - pdu->result = le64_to_cpu(nvme_req(req)->result.u64); + io_uring_cmd_set_res32(ioucmd, status, result); /* * For IOPOLL, check if this completion is happening in the context * of the same io_ring that owns the request (local context). If so, * we can complete inline without task_work overhead. Otherwise, we @@ -469,11 +468,10 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req, */ if (blk_rq_is_poll(req) && iob && iob->poll_ctx == io_uring_cmd_ctx_handle(ioucmd)) { if (pdu->bio) blk_rq_unmap_user(pdu->bio); - io_uring_cmd_set_res32(ioucmd, pdu->status, pdu->result); io_uring_cmd_done(ioucmd, 0); } else { io_uring_cmd_do_in_task_lazy(ioucmd, nvme_uring_task_cb); } return RQ_END_IO_FREE; -- 2.55.0