From: Christoph Hellwig <hch@lst.de>
To: Qu Wenruo <wqu@suse.com>
Cc: Christoph Hellwig <hch@lst.de>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Naohiro Aota <naohiro.aota@wdc.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 09/10] btrfs: refactor btrfs_map_bio
Date: Mon, 25 Apr 2022 11:17:55 +0200 [thread overview]
Message-ID: <20220425091755.GA16446@lst.de> (raw)
In-Reply-To: <9ae89d00-7047-a207-6fd0-3223871576ca@suse.com>
On Mon, Apr 25, 2022 at 04:56:21PM +0800, Qu Wenruo wrote:
>> + if (!dev || !dev->bdev ||
>> + test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) ||
>> + (btrfs_op(orig_bio) == BTRFS_MAP_WRITE &&
>> + !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))) {
>> + atomic_inc(&bioc->error);
>> + if (atomic_dec_and_test(&bioc->stripes_pending))
>> + btrfs_end_bioc(bioc, false);
>
> The bioc is allocated by btrfs_map_block(), but freed inside a helper.
>
> This makes the allocation and free happening at different levels, not sure
> if it's a good idea.
It is always freed by the end_io handler, this helper just decrements
the pending count and potentially invokes the orig bio end I/O handling
if we never made it to a bio submission for the pending mirror.
> I doubt this fallback would improve the readability.
>
> But you're also right, the original check condition for the RAID56 branch
> is also not ideal.
I think it helps. But the next series will do away with this anyway.
>> }
>> - for (dev_nr = 0; dev_nr < total_devs; dev_nr++) {
>> - dev = bioc->stripes[dev_nr].dev;
>> - if (!dev || !dev->bdev || test_bit(BTRFS_DEV_STATE_MISSING,
>> - &dev->dev_state) ||
>> - (btrfs_op(first_bio) == BTRFS_MAP_WRITE &&
>> - !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))) {
>
> Maybe just make the complex if () condition into a helper?
>
> In fact I see some other locations uses similar complex expressions to
> check it's a missing device.
>
> Thus it should help a lot of call sites.
I'll see if a helper could be useful here.
next prev parent reply other threads:[~2022-04-25 9:18 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 7:54 cleanup btrfs bio handling, part 2 Christoph Hellwig
2022-04-25 7:54 ` [PATCH 01/10] btrfs: move more work into btrfs_end_bioc Christoph Hellwig
2022-04-26 7:19 ` Johannes Thumshirn
2022-04-25 7:54 ` [PATCH 02/10] btrfs: cleanup btrfs_submit_dio_bio Christoph Hellwig
2022-04-25 8:45 ` Qu Wenruo
2022-04-26 7:21 ` Johannes Thumshirn
2022-04-25 7:54 ` [PATCH 03/10] btrfs: split btrfs_submit_data_bio Christoph Hellwig
2022-04-25 9:11 ` Qu Wenruo
2022-04-25 9:19 ` Christoph Hellwig
2022-04-25 9:37 ` Qu Wenruo
2022-04-25 11:09 ` Christoph Hellwig
2022-04-25 11:16 ` Qu Wenruo
2022-04-25 11:19 ` Christoph Hellwig
2022-04-25 11:31 ` Qu Wenruo
2022-04-25 11:34 ` Christoph Hellwig
2022-04-25 11:40 ` Qu Wenruo
2022-04-25 11:43 ` Qu Wenruo
2022-04-25 17:17 ` Christoph Hellwig
2022-04-26 1:24 ` Qu Wenruo
2022-04-25 7:54 ` [PATCH 04/10] btrfs: don't double-defer bio completions for compressed reads Christoph Hellwig
2022-04-25 7:54 ` [PATCH 05/10] btrfs: defer I/O completion based on the btrfs_raid_bio Christoph Hellwig
2022-04-25 7:54 ` [PATCH 06/10] btrfs: don't use btrfs_bio_wq_end_io for compressed writes Christoph Hellwig
2022-04-25 7:54 ` [PATCH 07/10] btrfs: centralize setting REQ_META Christoph Hellwig
2022-04-25 9:06 ` Qu Wenruo
2022-04-25 7:54 ` [PATCH 08/10] btrfs: remove btrfs_end_io_wq Christoph Hellwig
2022-04-25 7:54 ` [PATCH 09/10] btrfs: refactor btrfs_map_bio Christoph Hellwig
2022-04-25 8:56 ` Qu Wenruo
2022-04-25 9:17 ` Christoph Hellwig [this message]
2022-04-26 13:24 ` Christoph Hellwig
2022-04-25 7:54 ` [PATCH 10/10] btrfs: do not allocate a btrfs_bio for low-level bios Christoph Hellwig
2022-04-25 9:01 ` Qu Wenruo
2022-04-25 9:18 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2022-04-29 14:30 cleanup btrfs bio handling, part 2 v2 Christoph Hellwig
2022-04-29 14:30 ` [PATCH 09/10] btrfs: refactor btrfs_map_bio Christoph Hellwig
2022-05-04 12:25 cleanup btrfs bio handling, part 2 v3 Christoph Hellwig
2022-05-04 12:25 ` [PATCH 09/10] btrfs: refactor btrfs_map_bio Christoph Hellwig
2022-05-04 12:46 ` Qu Wenruo
2022-05-26 7:36 cleanup btrfs bio handling, part 2 v4 Christoph Hellwig
2022-05-26 7:36 ` [PATCH 09/10] btrfs: refactor btrfs_map_bio Christoph Hellwig
2022-06-01 19:36 ` 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=20220425091755.GA16446@lst.de \
--to=hch@lst.de \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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