Re: [PATCH v2 4/4] iomap: don't lose a failed direct I/O bio's error when zeroing the tail

From: Darrick J. Wong

Date: Thu Sep 24 2026 - 18:36:57 EST


On Thu, Sep 24, 2026 at 10:30:08PM +0200, Andrea Parri wrote:
> On Thu, Sep 24, 2026 at 11:53:17AM -0700, Darrick J. Wong wrote:
> > > Cc: stable@xxxxxxxxxxxxxxx
> >
> > Cc: <stable@xxxxxxxxxxxxxxx> # v6.12
>
> Fixed for v3.
>
> > > @@ -582,8 +578,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);
> >
> > I think this is the original cause of the bug, right? We might have
> > already had a nonzero ret, and the assignment here blows that away.
> > Right?
>
> Right. When iomap_dio_bio_iter_one() fails we break out of the loop
> with ret < 0 and fall through to the tail zeroing, and this assignment
> replaced that error with iomap_dio_zero()'s 0.
>
> > If the answer to that is yes, then
> > Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
>
> Thanks, picked up for v3.
>
> > (I should probably whine about how changing the function signature of
> > iomap_dio_zero should be a separate patch to make it more obvious what's
> > the actual fix...)
>
> Fair point. FWIW, before 10553a91652d iomap_dio_zero() returned void
> and neither call site touched ret; that commit made it return int and
> added both "ret = iomap_dio_zero(...)" assignments. So the signature
> change here is really undoing the part of 10553a91652d that introduced
> the bug, and keeping it in one patch makes the stable backport
> self-contained. If you'd still prefer a one-line fix followed by the
> void conversion, I'm happy to split it.

I'd prefer that, though I don't have a strong opinion. Someone in
another multiverse could have come along and decided "URrgghg,
iomap_dio_zero doesn't need a farking return value!" and accidentally
fixed this bug.

Eh, whatever, just leave it as it is. :)

--D

> Thanks!
> Andrea
>