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=1796382708; b=JCujEN94Hn5AmPGqAILWJOiB9FGNWAUgVgn1k4SwME0TiXzbaUeyt2uyAMo0510KDsra qYmbzVs6t4gvrSlg+aFq4NDbgXqpGBGHBJrAj5TvwrdJHehiedTQPRGHQHFpVTWxx1ihm CI/8NvrzuJhM6WKvtiKFLd8/0UqBgcKPuidL7dKFrLD4xCcYONLkJ/+z/vbCHPobA09zd uwpPkxJNva1nnqOphaf5Ug4dNx/HPfuEVZHTOcFWcfo5tMRBGCAKXvpWtcfro/vmMOpKD tBFIX5tCmCuUYqoctf8DOUBvHzmBb1nZv4TkavAlvxhtNNdBHWSdeyK8l1ZGUG9vXMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382708; 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=lF9MFi1TTAB4pMFKUEmImUJknibRDic/idOr7meVDW4=; b=QmBKFX3cQzoxSekqYToT8EHgKDFqUbphzqjGygmYV0DQe9GX/G4WzWGuU8Z4RTejWGl0 tzEF+e6a1mMHgHwhT+MInPxw8d/5kocUxJubwcWXSNGHRPCvFeupsBviBubFRA+dteTOe hFxU32/i2w33HrfnuO+mDTLcf2hEAf8SpRYJuvKqVlz7bEXTIe5Ko44seJAVTR4mmLkBV dOqcXdf5SJd/btjMldqbYTEBH2DgxVHpxBAhpf3WhtoIKqw2LpXlG6j3LUi7bNWRKhEVQ 4rVRWR3UNO1if4OYEC3ZUN2VPwi28qosZG1Kg81UJPpfptLhXmVZ8flx7n59iuLP7bg== 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=fFnxE2Ga; 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 BAB6D606A322; Fri, 4 Dec 2026 11:11:48 +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=fFnxE2Ga Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3D771F000C2; Fri, 4 Dec 2026 11:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382708; bh=lF9MFi1TTAB4pMFKUEmImUJknibRDic/idOr7meVDW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fFnxE2GaxMT1pVALtCIm9hQ8TaqP2DgYxTYP4Wd0KwqRAu/izfPnq0mugn2zMKWBu HqWIYovbS2KLf3JX1U7hLl7t7RC8SJW1lGAkhf9utV/IkyCt3CW2dM2S3i+UGsJS99 s6MtmPVZM5G0nVW4Xw+eFqrlZoIXaH1A234jjzzA= 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 6.18 569/703] nvmet: handle short reads and writes in the file backend Date: Fri, 4 Dec 2026 19:07:48 +0900 Message-ID: <20261204100642.903429580@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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;