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=1794590686; b=F3/8hxRNjWblWyYDBb08PHo4txxrGL622ox2EWNxIEeARXvOHCNOXwaCFIbCEohdUzVS iyISQC6buNAtxZ2rPGKhhaw76kr19svGbzxKTz1n4gjplL4qyzpcLmXOdzMBTtyu5HbzW U3IAPACTBFllDTYzkDDsr0QzNA3/TXE0b4HePe6q109BH6wlS1N3gzZd3bgXT3GykMGXm 3qx7ScnFW5BVhczSohX8tgSxsVLaRa6zcyU54gmHcxA9U9FksLgxnIpEsvqyrFKXS1QfU 4IL3PdwMkxibQExwnK+lcyK0+yZ/5aO5VadsXcoFXif/ETKJMfjE0iNQv15ALtu+Tfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590686; 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=UTKJRbO6bgsTkeU6b4SKJJI3aZrTq2bMq7WvREWkr9o=; b=zMSnVlm5gc//qbB4wMhE2ewVLdHEV+W5VqLiX308njaeMyH454oPCY1jsOQiSdDt6N12 //U22y1+cB5CP9k4jVJ0tbewOny1ysZRvLhR7oBTxK6Ch9OmvR0hAlhJ6LTqjKpj/C5GP 1KurtxxyYt5pLPcKWQkR4boSOZQz+TmLbLQu8OY4ElmruG+drrHcJYdgj+eAkoouqO8Vg rFOtb3Yt/gwfBYaky0p5ti+lcpkzd7+Vova/PoBziV8XYzma+IT3vNbWx16qomcGlCge4 LC4RWGOUXbQGyDlL5fQeqss6qRcUHyJYMQF+hMbgRLpRpCaTFzOxl/KYOxF1Uy58hUw== 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=NgXgVJeA; 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 74B97606CED0; Fri, 13 Nov 2026 17:24:46 +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=NgXgVJeA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 206231F000C6; Fri, 13 Nov 2026 17:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794590686; bh=UTKJRbO6bgsTkeU6b4SKJJI3aZrTq2bMq7WvREWkr9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NgXgVJeAMV3+oRZB6ZLViau+8iZuMy4smz14ErJfymQuPbOnonpDJ8iwBNERTsGgd OYRnryT07S/ByrQYBHEPViYYv56+zWtckrjtLrtFen0dx3WSYx4w5ykdrYGF7+9ge5 D1bzOBvleH0gkUziTfgxt/rV1O8KS1Fo1OAzQeVY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Darrick J. Wong" , Pankaj Raghav , Andrea Parri , Christoph Hellwig , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 6.18 597/686] iomap: dont lose a failed direct I/O bios error when zeroing the tail Date: Fri, 13 Nov 2026 10:52:10 -0500 Message-ID: <20261113153842.164490655@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153820.902362109@linuxfoundation.org> References: <20261113153820.902362109@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: Andrea Parri [ Upstream commit a9fd24bcbe690ed4a5b8ea6a7516fa297fae9360 ] iomap_dio_bio_iter() falls through to the sub-block tail zeroing when the data bio submission fails, so that the rest of the block is still zeroed and stale data is not exposed. The zeroing result was assigned to ret, which overwrote the submission error with the successful zeroing result (zero) and the failed write was reported as success. iomap_dio_zero() can only return an error from a can't-happen WARN_ON_ONCE() (nr_vecs exceeding BIO_MAX_VECS, which the existing comment there says "shall never be reached" for any in-tree filesystem), so it isn't a real runtime failure worth reporting to userspace, let alone one worth losing the actual submission error for. Make iomap_dio_zero() return void and drop the error handling at both call sites instead of threading the result through a separate variable. Fixes: 10553a91652d ("iomap: fix iomap_dio_zero() for fs bs > system page size") Cc: stable@vger.kernel.org # v6.12 Reviewed-by: Darrick J. Wong Reviewed-by: Pankaj Raghav Signed-off-by: Andrea Parri Link: https://patch.msgid.link/0cbce1012f5333690be36a9adafb3e190fe2ca77.1790342457.git.parri.andrea@gmail.com Reviewed-by: Christoph Hellwig Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Sasha Levin --- fs/iomap/direct-io.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 5a97614507530..4301145674259 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -284,7 +284,7 @@ u32 iomap_finish_ioend_direct(struct iomap_ioend *ioend) return vec_count; } -static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, +static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, loff_t pos, unsigned len) { struct inode *inode = file_inode(dio->iocb->ki_filp); @@ -293,14 +293,14 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, int nr_vecs = max(1, i_blocksize(inode) / folio_size(zero_folio)); if (!len) - return 0; + return; /* * This limit shall never be reached as most filesystems have a * maximum blocksize of 64k. */ if (WARN_ON_ONCE(nr_vecs > BIO_MAX_VECS)) - return -EINVAL; + return; bio = iomap_dio_alloc_bio(iter, dio, nr_vecs, REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); @@ -317,8 +317,6 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, len -= io_len; } iomap_dio_submit_bio(iter, dio, bio, pos); - - return 0; } /* @@ -424,10 +422,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) if (need_zeroout) { /* zero out from the start of the block to the write offset */ pad = pos & (fs_block_size - 1); - - ret = iomap_dio_zero(iter, dio, pos - pad, pad); - if (ret) - goto out; + iomap_dio_zero(iter, dio, pos - pad, pad); } nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); @@ -509,8 +504,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) /* zero out from the end of the write to the end of the block */ pad = pos & (fs_block_size - 1); if (pad) - ret = iomap_dio_zero(iter, dio, pos, - fs_block_size - pad); + iomap_dio_zero(iter, dio, pos, fs_block_size - pad); } out: /* Undo iter limitation to current extent */ -- 2.53.0