linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Christoph Hellwig <hch@lst.de>, David Sterba <dsterba@suse.com>,
	Josef Bacik <josef@toxicpanda.com>, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 10/10] btrfs: remove bioc->stripes_pending
Date: Mon, 20 Jun 2022 10:53:40 +0200	[thread overview]
Message-ID: <20220620085340.GA13344@lst.de> (raw)
In-Reply-To: <bc18e270-371c-98ee-28c2-fd4305206d7a@suse.com>

On Mon, Jun 20, 2022 at 11:18:03AM +0300, Nikolay Borisov wrote:
> What if the the currently completed stripe bio is the last - then bio_endio 
> would be called for orig_bio, which will executed bi_end_io() in softirq 
> context, but for reads we want to execute this in process context (as per 
> the below code) ?

> The old code guaranteed that btrfs_end_bioc() is executed when the last 
> stripe bio was completed. With this new scheme, say we have 3 bios - 2 
> cloned, 1 being the orig, what guarantees that the orig_bio won't be 
> finished before the remaining 2 (or 1) cloned/stripe bios thus calling 
> btrfs_end_bio() on orig bio with __bi_remaining potentially being 2 or 1 
> and finally calling orig_bio->bi_end_io() again with __bi_remaining being 
> elevated?

This is what the bio_inc_remaining after the bio_alloc_clone takes care
of.  With that the remaining count in the original btrfs_bio is
incremented, which ensures that ->end_io for the originl bio is only
called when all other bios and the original one have completed.

Take a look at bio_endio and bio_remaining_done for the glory details.

>>   	if (clone) {
>> -		bio = bio_alloc_clone(dev->bdev, orig_bio, GFP_NOFS, &fs_bio_set);
>> +		bio = bio_alloc_clone(NULL, orig_bio, GFP_NOFS, &fs_bio_set);
>> +		bio_inc_remaining(orig_bio);
>
> When cloning why aren't you passing dev->bdev but instead set it after the 
> checks via bio_set_dev ? Is it because of the
>
> if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION))
>
> check inside bio_endio in case bio_io_error is called in submit_stripe_bio?

It is because we don't know if we have a valid bdev until after
the checks a few line down that call bio_io_error.  We need those
checks to be done later now so that all error handling goes through
the bio end_io handler.

  parent reply	other threads:[~2022-06-20  8:54 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 10:04 cleanup btrfs bio submission v2 Christoph Hellwig
2022-06-17 10:04 ` [PATCH 01/10] btrfs: remove a bunch of pointles stripe_len arguments Christoph Hellwig
2022-06-20 17:16   ` David Sterba
2022-06-20 17:38     ` Christoph Hellwig
2022-06-22  4:19       ` Christoph Hellwig
2022-06-22 14:07         ` David Sterba
2022-06-22  4:30     ` Qu Wenruo
2022-06-17 10:04 ` [PATCH 02/10] btrfs: return proper mapped length for RAID56 profiles in __btrfs_map_block() Christoph Hellwig
2022-06-17 10:04 ` [PATCH 03/10] btrfs: remove the btrfs_map_bio return value Christoph Hellwig
2022-06-17 10:04 ` [PATCH 04/10] btrfs: remove the raid56_parity_write " Christoph Hellwig
2022-06-17 10:38   ` Qu Wenruo
2022-06-18 11:04   ` Johannes Thumshirn
2022-06-17 10:04 ` [PATCH 05/10] btrfs: remove the raid56_parity_recover " Christoph Hellwig
2022-06-18 11:06   ` Johannes Thumshirn
2022-06-19  6:35     ` Christoph Hellwig
2022-06-19 10:35   ` Qu Wenruo
2022-06-17 10:04 ` [PATCH 06/10] btrfs: transfer the bio counter reference to the raid submission helpers Christoph Hellwig
2022-06-19 10:45   ` Qu Wenruo
2022-06-19 21:50     ` Qu Wenruo
2022-06-20  7:47       ` Christoph Hellwig
2022-06-20  8:03         ` Qu Wenruo
2022-06-20  8:09           ` Christoph Hellwig
2022-06-20  7:37     ` Christoph Hellwig
2022-06-20  7:45       ` Qu Wenruo
2022-06-20  7:49         ` Christoph Hellwig
2022-06-17 10:04 ` [PATCH 07/10] btrfs: simplify the reloc root check in btrfs_submit_data_write_bio Christoph Hellwig
2022-06-17 10:04 ` [PATCH 08/10] btrfs: handle allocation failure in btrfs_wq_submit_bio gracefully Christoph Hellwig
2022-06-28 15:20   ` Boris Burkov
2022-06-17 10:04 ` [PATCH 09/10] btrfs: remove the btrfs_submit_dio_bio return value Christoph Hellwig
2022-06-17 10:04 ` [PATCH 10/10] btrfs: remove bioc->stripes_pending Christoph Hellwig
2022-06-20  8:18   ` Nikolay Borisov
2022-06-20  8:34     ` Nikolay Borisov
2022-06-20  8:53     ` Christoph Hellwig [this message]
2022-06-20  9:34       ` Nikolay Borisov
2022-06-20 11:23         ` Christoph Hellwig
2022-06-22 16:07   ` David Sterba
2022-06-22 16:15     ` Christoph Hellwig
2022-07-07 18:34       ` David Sterba
2022-06-20 13:04 ` cleanup btrfs bio submission v2 Nikolay Borisov
2022-07-07 18:35 ` David Sterba

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=20220620085340.GA13344@lst.de \
    --to=hch@lst.de \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=wqu@suse.com \
    /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;
as well as URLs for NNTP newsgroup(s).