mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: John Garry <john.g.garry@oracle.com>,
	Johannes Thumshirn <jth@kernel.org>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	"open list:BTRFS FILE SYSTEM" <linux-btrfs@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH v3] btrfs: handle bio_split() error
Date: Wed, 13 Nov 2024 10:08:36 +0000	[thread overview]
Message-ID: <d892421f-3ecb-428a-b65e-4f0d0f5f08fe@wdc.com> (raw)
In-Reply-To: <9eec1ccb-6e56-4701-83bf-3397d1bc5197@oracle.com>

On 13.11.24 10:51, John Garry wrote:
> On 04/11/2024 12:13, Johannes Thumshirn wrote:
>> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>
>> Now that bio_split() can return errors, add error handling for it in
>> btrfs_split_bio() and ultimately btrfs_submit_chunk().
> 
> I have a couple of comments, below; However, since I am not familiar
> with the code, maybe they are invalid.
> 
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> ---
>>
>> This is based on top of John Garry's series "bio_split() error handling
>> rework" explicitly on the patch titled "block: Rework bio_split() return
>> value", which are as of now (Tue Oct 29 10:02:16 2024) not yet merged into
>> any tree.
>>
>> 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 | 15 +++++++++++++--
>>    1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
>> index 1f216d07eff6..7a0998d0abe3 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);
>> +
>>    	bbio = btrfs_bio(bio);
>>    	btrfs_bio_init(bbio, fs_info, NULL, orig_bbio);
>>    	bbio->inode = orig_bbio->inode;
>> @@ -678,7 +681,7 @@ 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;
>> +		goto end_bbio;
> 
> eh, I am not sure why this has changed (and we now skip the "fail" label
> actions)

Because we want to skip the 'if (map_length < length) {' part below the 
'fail' label and directly go to btrfs_bio_end_io().


>>    	}
>>    
>>    	map_length = min(map_length, length);
>> @@ -686,7 +689,14 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
>>    		map_length = btrfs_append_map_length(bbio, map_length);
>>    
>>    	if (map_length < length) {
>> -		bbio = btrfs_split_bio(fs_info, bbio, map_length);
>> +		struct btrfs_bio *split;
>> +
>> +		split = btrfs_split_bio(fs_info, bbio, map_length);
>> +		if (IS_ERR(split)) {
>> +			ret = errno_to_blk_status(PTR_ERR(split));
>> +			goto end_bbio;
> 
> Do we need to undo the btrfs_bio_counter_inc() (not shown)?

Yes we do.

> 
>> +		}
>> +		bbio = split;
>>    		bio = &bbio->bio;
>>    	}
>>    
>> @@ -760,6 +770,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
>>    
>>    		btrfs_bio_end_io(remaining, ret);
>>    	}
>> +end_bbio:
>>    	btrfs_bio_end_io(bbio, ret);
>>    	/* Do not submit another chunk */
>>    	return true;
> 
> 


  reply	other threads:[~2024-11-13 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 12:13 Johannes Thumshirn
2024-11-13  9:51 ` John Garry
2024-11-13 10:08   ` Johannes Thumshirn [this message]
2024-12-02 10:34     ` John Garry

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=d892421f-3ecb-428a-b65e-4f0d0f5f08fe@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=john.g.garry@oracle.com \
    --cc=josef@toxicpanda.com \
    --cc=jth@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®