From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381301; b=o+JvjA5VvKp2CEANq5XPFzwktW9i9p4uyntJCzPczG9+qhj/6Xic0/YRuXQxXS+yctjL R5GWZvTE0I+A9/WBCc8bbMoNHFS7yWFSl/38w7RTNbeeWTHvLUi7iHo1sUWDAfgVIgLCF jmXfcf6L+2sseo5WkIq74bk0HmMhnIuYt8XTiCrXCMFXZ5q1/mglE+GM+9nuaDZ2QTNoq xBzddrPbCwF6KomjcqdmgkOcXmQhVgAYM+PEbmF4AepZ14Xr/beQGLF92/cJ6yJrJ55mh QbPrmkligfx8E0rkhCSp7JpIja/yPM8/37T2vUPV0dN2+vAsRzLiCDZKNA5CnpIg9SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381301; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=TZeNCqSF1+FLLA6uF2CZzkXKIWiGx/GnC1p6aRvR0Mg=; b=dxfLvwYMZKz5exU4rQrhEpycggC52L4DBtqsfxv+NsuaTazov6XfEIxgLZcuMPYfR7bh E1t1SGKeWGrtsefxlYUYbakmjII5xiI+1ik/wehH6K1djCw1+IRKtVCaF0yTL8W0c4S88 Tw7NBmb/Sw5P36Ee2A1V4MaUznMLlQkTlNGYW3ffiD3YufdrcYQ5K8L12Hv/0dRE/BycG KFYFBdLSgG3NkneZyRD1B0S7FHAqX6zML2pPWCDTSueB8kBR/RRB7Qv3lPlcY2kyzM+ly uUDRURmJ16XK1uNRtgT845zSeJAOWDANZGzPwdKrXXpr5/icH4UCPnm3P7hNaC3JsvA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FEvMJBR8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF95F606A32D; Fri, 4 Dec 2026 10:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FEvMJBR8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F8981F000CE; Fri, 4 Dec 2026 10:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381301; bh=TZeNCqSF1+FLLA6uF2CZzkXKIWiGx/GnC1p6aRvR0Mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FEvMJBR8U9UwJXMcbC3RX4R/9OjdLETVvJZ4+BYWVQYGzVHG485wzKyr69d6PVUZX LhvPDUmvDtc0Qw0twC3gAMjq1sLv1tX6vIocZT80Ln4b6sULDhTHVRH0lIqFBPVsXC JB7+GKBzyB1pcJaFFPnJkV7g7TS6EnbaTZRnPyU8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Shao Mingyin , Keith Busch Subject: [PATCH 7.3 644/742] nvmet: handle short reads and writes in the file backend Date: Fri, 4 Dec 2026 19:08:28 +0900 Message-ID: <20261204100652.198522243@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shao Mingyin commit 1738de07a79b9abdcffe03571c442033b80e7fed upstream. When the file backend falls back to its bvec mempool, large requests are submitted in synchronous chunks. A short completion advances the file position by the full chunk length and is eventually overwritten with the total request length. The target reports success for an incomplete write or returns unread buffer contents as valid data. The common completion path has another short-I/O case: a zero-byte return, such as a read at EOF after the backing file is truncated, is passed to errno_to_nvme_status() and becomes success. Stop at any incomplete chunk and convert nonnegative short completions to -EIO in both paths. Preserve negative errors and full completions. Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support") Fixes: c6aa3542e010 ("nvmet: add error log support for file backend") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Shao Mingyin Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/io-cmd-file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -113,7 +113,7 @@ static void nvmet_file_io_done(struct ki } if (unlikely(ret != req->transfer_len)) - status = errno_to_nvme_status(req, ret); + status = errno_to_nvme_status(req, ret < 0 ? ret : -EIO); nvmet_req_complete(req, status); } @@ -150,8 +150,11 @@ static bool nvmet_file_execute_io(struct if (unlikely(is_sync) && (nr_bvec - 1 == 0 || bv_cnt == NVMET_MAX_MPOOL_BVEC)) { ret = nvmet_file_submit_bvec(req, pos, bv_cnt, len, 0); - if (ret < 0) + if (ret != len) { + if (ret >= 0) + ret = -EIO; goto complete; + } pos += len; bv_cnt = 0;