Re: [RFC 03/12] bio: add bio_set_errno

Christoph Hellwig
2025-12-16T07:58:13Z

On Mon, Dec 08, 2025 at 12:10:10PM +0000, Andreas Gruenbacher wrote:
> Add a bio_set_errno(bio, errno) helper that sets bio->bi_status to
> errno_to_blk_status(errno) if errno != 0. Replace instances of this
> pattern in the code with a call to the new helper.
>
> The WRITE_ONCE() in bio_set_errno() ensures that the compiler won't
> reorder things in a weird way, but it isn't needed to prevent tearing
> because a single-byte field like bi_status cannot tear.

Not a fan of this. We should not be doing that very often (and as
seen by the diff don't), so don't add a helper for it that makes
people do it more often.