From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <jth@kernel.org>
Cc: linux-btrfs@vger.kernel.org,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH v4] btrfs: handle bio_split() error
Date: Fri, 29 Nov 2024 17:34:17 +0100 [thread overview]
Message-ID: <20241129163417.GY31418@twin.jikos.cz> (raw)
In-Reply-To: <3b491cb4fcb7c34bd8cd5265871ff115395fca79.1732786874.git.jth@kernel.org>
On Thu, Nov 28, 2024 at 10:42:01AM +0100, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
> Commit bfebde92bd31 ("block: Rework bio_split() return value") changed
> bio_split() so that it can return errors.
>
> Add error handling for it in btrfs_split_bio() and ultimately
> btrfs_submit_chunk().
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>
> Changes to v3:
> - decrement bio counter
Is it possible to have some sanity checks for the bio counter? The
missing decrement could be hard to spot, but as it's a global counter
and possibly spanning unbounded time we'd have to add some checkpoints
like do per transaction accounting.
Otherwise,
Reviewed-by: David Sterba <dsterba@suse.com>
> Changes to v2:
> - assign the split bbio to a new variable, so we can keep the old error
> paths and end the original bbio
>
> Changes to v1:
> - convert ERR_PTR to blk_status_t
> - correctly fail already split bbios
> ---
> fs/btrfs/bio.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
> index 1f216d07eff6..af3db0a7ae4d 100644
> --- a/fs/btrfs/bio.c
> +++ b/fs/btrfs/bio.c
> @@ -81,6 +81,9 @@ static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info,
>
> bio = bio_split(&orig_bbio->bio, map_length >> SECTOR_SHIFT, GFP_NOFS,
> &btrfs_clone_bioset);
> + if (IS_ERR(bio))
> + return ERR_CAST(bio);
The cast is not strictly needed here as the pointer matches the return
type.
> +
> bbio = btrfs_bio(bio);
> btrfs_bio_init(bbio, fs_info, NULL, orig_bbio);
> bbio->inode = orig_bbio->inode;
> @@ -678,7 +681,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
> &bioc, &smap, &mirror_num);
> if (error) {
> ret = errno_to_blk_status(error);
> - goto fail;
> + btrfs_bio_counter_dec(fs_info);
> + goto end_bbio;
> }
>
> map_length = min(map_length, length);
prev parent reply other threads:[~2024-11-29 16:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 9:42 [PATCH v4] btrfs: handle bio_split() error Johannes Thumshirn
2024-11-28 14:50 ` David Sterba
2024-11-28 15:40 ` Johannes Thumshirn
2024-11-28 16:06 ` David Sterba
2024-11-29 16:34 ` David Sterba [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241129163417.GY31418@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=johannes.thumshirn@wdc.com \
--cc=jth@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox