From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f226.google.com (mail-pf1-f226.google.com [209.85.210.226]) (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 A8DD5495050 for ; Thu, 27 Aug 2026 18:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787857067; cv=none; b=Xuvu8EirBKUOoPBg7XvrC6gyDWRYYvl3LVEhQTwYEFsMDUx8bjtabyLGdfQjiBHvFp6v90GH790ZuUBWfDHCuvJzv6L93FM8BPyisAeXuA4Ar//oly38T3E7/7kkR9L0ETRg68zYzLdnmNVgvo0D5Zgzc0bfxtR0+rK0CyiftPU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787857067; c=relaxed/simple; bh=bId58P1f3rx83kEyCFQCmbOQueTyIg0Jg1Ag1a5jGfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aVZrpHz7mPJp11QQActP5xzsUaD0AJdDuil7ltoIIXUcsSImI4CE8AA/IOFKp64F6wvygm1ofy/r/Ys+1+NxDhpAzzUtViHqCPcDLMhxzq4mt0v7TBJ2MTB97w5OH/QqC6GdSvEJvnhd4qC9oZnj89b5GuXQJIMOwmyV0scpT2Y= 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.226 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-f226.google.com with SMTP id d2e1a72fcca58-85457d780adso28300b3a.2 for ; Thu, 27 Aug 2026 11:57:33 -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=Aj+Z1wLrJTBnpd3MPHiuh5iwJuDCYjQIvlPfND+xf7/GIeJ4mWMOW4EEw2cw0giWTG IpIQeYIfZGpSul3vGlzAp82zR4ee0IAq84T/FRCQFUc4pPcuEJ5X/nYAnAqlmAVWwTQd hoRHW5G7ak93qd06WYm4/jVemil6Cpkh2MUK/+u4aMnoyV8AHhP+W6ZHQ6TXj+BM4PrP FPi4zonG18YHu9a9mVgKjD/H3neqYFXWKjDG8bDEJZ3+mfBcbD3t5L/3zKakj8zt8hia uAOUbWpdfLzu1R53bafvixrWlWI5MmivRZxI7kTwYFV/SihIvZWtmJ6M/EHUVx0NpUGi QXrQ== X-Gm-Message-State: AFuF++m7JuSYOYB2k9QTwYp7tAn0O/Nz4UodYScTOwbRXccAbSPFMyq9 ULsg2t/HY+lk0j3Kc59kzfFFcrySjQfwuRL3tQbDGFliL9+yBQ5TYBVN5teikPjL4yqy4fedY+w JM3amj9WsYkLqYmSCtEtXLaMyDrzn4eDqHFSK2hPipdRcCW+qKoTz X-Gm-Gg: AR+sD11VourSxFsqJva7+LEhEgDj2Noxxr9XjVGSx4uLoR3AYYV44zYAb+DiczbwaaB AkpsrMkJs/MQF7jYuEDBTveF/CgRvM4VrILrtyVKqfSPVYb8lVjj8EJFbZei2BSJDRzdpa8b1kq mV2p91G6o79YCBIcwFcfhu763nzG3PWW+pgvfNYNBcqkllWHfQSyvrBBVfkLc+ndUdDmOHOgZOP +IM3n8PYYnqzZQEbcg32jsTlfdqvGq9nKvyk0/BBalxm0gzW9i0GJK7OLqcJ34jzuGwXt/pCf9P 0uMxErOhmYr1K6fB1rP0BVSReIk7mGn4nmYk1pBIwLgKy2ZvNws0C515H1Njden0cn04LKAXMG1 7QZXAHrE4A39taafH4g== 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: linux-block@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