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=1796384071; b=X6rBBzhAzw2+a/tKYeTJ+khXhvoshnfAzFqqL6uDFyBvLR8cN7n+zO3nHtSyb7rBFKj8 kTLFuK9GnfGjVbkPcEbfe5dnOOaF3jeIFFapASBQdaO5FRH+M6M9Svet2GmYdwGrOvoKf UdvqYK/h/BpcZviKyh50tMUpP5992A48nqk7lthO6MkFLedh0X4mzHx+9A+GXVDKPHGGI lD2M54qlLkeh4iYpzBz9yd0PBDbTAAZBgiLMCe3hnrvZM9mBEDz2lV6kg0NxRX7lcQYkF 2WhHIn3VJD5ZMZN01/fX3G/nOb1xQ6l/iibKIyv62y36zhvqB1CRlcggrDvm6q8+7eA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384071; 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=0o7qQrSt5FLxr9bAPkFz4obF5lflgSC2HNZSEXi0tCA=; b=Ail3U+XFai9bg/UfMx5tq7YQi4wHd5y6DkAk3RhKQbciQbFLWuLSRFitQ+acg86MBBDa CY0vClKJh8YwdB7TRrPjRCdty3xEl2PVHzKMUdYDqeoYSd204pZpipBexHggxcmnNzVoJ vef8YePwFWGoJmw/I2oo2tPVERF4sVQo000Bh9ZmL/r+ktE7fOvUtQxAOedYfvXFO0UkY FSo4yn/A/FSVGus0KIdUg//AVtObJ9DVLqngLEHHiiIGiWUXQtBjT+RZkZePA8ABLuHmV rDXW+78wPoMRJpb1ruq/REB8vQFwRONTrOVp3/HirXnKUSU26X/MOlAiL4IkB+y+B9A== 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=o7ZyEztL; 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 B8B35606A32C; Fri, 4 Dec 2026 11:34:31 +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=o7ZyEztL Received: by smtp.kernel.org (Postfix) with ESMTPSA id E57F11F00897; Fri, 4 Dec 2026 11:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384071; bh=0o7qQrSt5FLxr9bAPkFz4obF5lflgSC2HNZSEXi0tCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o7ZyEztLozgF5JUAU13MdOsKZUknBhpnc819PDyu/q2nwQ8uulpHOzclSP9MPbnTh tf/9nimbWTFHBSLMnxp8MmR01GV9pjYL1QhbQTws+RjXPnYXgJj9hWGqKyqI64ZJK1 3N/AkQMwWnFsn8Ew7vD2xUQaGgWIOEg0iRkCN60o= 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.12 483/555] nvmet: handle short reads and writes in the file backend Date: Fri, 4 Dec 2026 19:08:46 +0900 Message-ID: <20261204100627.546469232@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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;