From: Josef Bacik <josef@toxicpanda.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH 14/21] btrfs: use a separate end_io handler for extent_buffer writing
Date: Thu, 11 May 2023 11:02:24 -0400 [thread overview]
Message-ID: <20230511150224.GA75508@localhost.localdomain> (raw)
In-Reply-To: <20230503152441.1141019-15-hch@lst.de>
On Wed, May 03, 2023 at 05:24:34PM +0200, Christoph Hellwig wrote:
> Now that we always use a single bio to write an extent_buffer, the buffer
> can be passed to the end_io handler as private data. This allows
> to simplify the metadata write end I/O handler, and merge the subpage
> end_io handler into the main one.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/extent_io.c | 128 +++++++++----------------------------------
> 1 file changed, 27 insertions(+), 101 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 68cdc6bed60c19..28088b751f8021 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -1614,13 +1614,6 @@ void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
> TASK_UNINTERRUPTIBLE);
> }
>
> -static void end_extent_buffer_writeback(struct extent_buffer *eb)
> -{
> - clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags);
> - smp_mb__after_atomic();
> - wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK);
> -}
> -
> /*
> * Lock extent buffer status and pages for writeback.
> *
> @@ -1664,13 +1657,11 @@ static bool lock_extent_buffer_for_io(struct extent_buffer *eb,
> return ret;
> }
>
> -static void set_btree_ioerr(struct page *page, struct extent_buffer *eb)
> +static void set_btree_ioerr(struct extent_buffer *eb)
> {
> struct btrfs_fs_info *fs_info = eb->fs_info;
>
> - btrfs_page_set_error(fs_info, page, eb->start, eb->len);
> - if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags))
> - return;
> + set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags);
>
> /*
> * A read may stumble upon this buffer later, make sure that it gets an
> @@ -1684,7 +1675,7 @@ static void set_btree_ioerr(struct page *page, struct extent_buffer *eb)
> * return a 0 because we are readonly if we don't modify the err seq for
> * the superblock.
> */
> - mapping_set_error(page->mapping, -EIO);
> + mapping_set_error(eb->fs_info->btree_inode->i_mapping, -EIO);
>
> /*
> * If writeback for a btree extent that doesn't belong to a log tree
> @@ -1759,102 +1750,38 @@ static struct extent_buffer *find_extent_buffer_nolock(
> return NULL;
> }
>
> -/*
> - * The endio function for subpage extent buffer write.
> - *
> - * Unlike end_bio_extent_buffer_writepage(), we only call end_page_writeback()
> - * after all extent buffers in the page has finished their writeback.
> - */
> -static void end_bio_subpage_eb_writepage(struct btrfs_bio *bbio)
> +static void extent_buffer_write_end_io(struct btrfs_bio *bbio)
> {
> - struct bio *bio = &bbio->bio;
> - struct btrfs_fs_info *fs_info;
> - struct bio_vec *bvec;
> + struct extent_buffer *eb = bbio->private;
> + struct btrfs_fs_info *fs_info = eb->fs_info;
> + bool uptodate = !bbio->bio.bi_status;
> struct bvec_iter_all iter_all;
> + struct bio_vec *bvec;
> + u32 bio_offset = 0;
>
> - fs_info = btrfs_sb(bio_first_page_all(bio)->mapping->host->i_sb);
> - ASSERT(fs_info->nodesize < PAGE_SIZE);
> + if (!uptodate)
> + set_btree_ioerr(eb);
>
> - ASSERT(!bio_flagged(bio, BIO_CLONED));
> - bio_for_each_segment_all(bvec, bio, iter_all) {
> + bio_for_each_segment_all(bvec, &bbio->bio, iter_all) {
> + u64 start = eb->start + bio_offset;
> struct page *page = bvec->bv_page;
> - u64 bvec_start = page_offset(page) + bvec->bv_offset;
> - u64 bvec_end = bvec_start + bvec->bv_len - 1;
> - u64 cur_bytenr = bvec_start;
> -
> - ASSERT(IS_ALIGNED(bvec->bv_len, fs_info->nodesize));
> -
> - /* Iterate through all extent buffers in the range */
> - while (cur_bytenr <= bvec_end) {
> - struct extent_buffer *eb;
> - int done;
> -
> - /*
> - * Here we can't use find_extent_buffer(), as it may
> - * try to lock eb->refs_lock, which is not safe in endio
> - * context.
> - */
> - eb = find_extent_buffer_nolock(fs_info, cur_bytenr);
> - ASSERT(eb);
> -
> - cur_bytenr = eb->start + eb->len;
> -
> - ASSERT(test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags));
> - done = atomic_dec_and_test(&eb->io_pages);
> - ASSERT(done);
> -
> - if (bio->bi_status ||
> - test_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) {
> - btrfs_page_clear_uptodate(fs_info, page,
> - eb->start, eb->len);
> - set_btree_ioerr(page, eb);
> - }
> + u32 len = bvec->bv_len;
> +
Whitespace error here btw. Thanks,
Josef
next prev parent reply other threads:[~2023-05-11 15:02 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 15:24 simplify extent_buffer reading and writing v4 Christoph Hellwig
2023-05-03 15:24 ` [PATCH 01/21] btrfs: mark extent_buffer_under_io static Christoph Hellwig
2023-05-03 15:24 ` [PATCH 02/21] btrfs: fix sub-page error handling in end_bio_subpage_eb_writepage Christoph Hellwig
2023-05-03 15:24 ` [PATCH 03/21] btrfs: move setting the buffer uptodate out of validate_extent_buffer Christoph Hellwig
2023-05-03 15:24 ` [PATCH 04/21] btrfs: merge verify_parent_transid and btrfs_buffer_uptodate Christoph Hellwig
2023-05-03 15:24 ` [PATCH 05/21] btrfs: always read the entire extent_buffer Christoph Hellwig
2023-05-03 15:24 ` [PATCH 06/21] btrfs: don't use btrfs_bio_ctrl for extent buffer reading Christoph Hellwig
2023-05-03 15:24 ` [PATCH 07/21] btrfs: remove the mirror_num argument to btrfs_submit_compressed_read Christoph Hellwig
2023-05-03 15:24 ` [PATCH 08/21] btrfs: use a separate end_io handler for read_extent_buffer Christoph Hellwig
2023-05-03 15:24 ` [PATCH 09/21] btrfs: do not try to unlock the extent for non-subpage metadata reads Christoph Hellwig
2023-05-03 15:24 ` [PATCH 10/21] btrfs: return bool from lock_extent_buffer_for_io Christoph Hellwig
2023-05-23 18:43 ` David Sterba
2023-05-24 5:44 ` Christoph Hellwig
2023-05-26 13:34 ` David Sterba
2023-05-03 15:24 ` [PATCH 11/21] btrfs: submit a writeback bio per extent_buffer Christoph Hellwig
2023-05-03 15:24 ` [PATCH 12/21] btrfs: move page locking from lock_extent_buffer_for_io to write_one_eb Christoph Hellwig
2023-05-03 15:24 ` [PATCH 13/21] btrfs: don't use btrfs_bio_ctrl for extent buffer writing Christoph Hellwig
2023-05-23 18:45 ` David Sterba
2023-05-24 5:50 ` Christoph Hellwig
2023-05-26 13:15 ` David Sterba
2023-05-26 13:35 ` Christoph Hellwig
2023-05-03 15:24 ` [PATCH 14/21] btrfs: use a separate end_io handler for extent_buffer writing Christoph Hellwig
2023-05-11 15:02 ` Josef Bacik [this message]
2023-05-03 15:24 ` [PATCH 15/21] btrfs: remove the extent_buffer lookup in btree block checksumming Christoph Hellwig
2023-05-26 6:39 ` Qu Wenruo
2023-05-26 6:41 ` Christoph Hellwig
2023-05-26 6:43 ` Qu Wenruo
2023-05-26 7:03 ` Christoph Hellwig
2023-05-26 7:25 ` Qu Wenruo
2023-05-26 13:58 ` David Sterba
2023-05-03 15:24 ` [PATCH 16/21] btrfs: remove the io_pages field in struct extent_buffer Christoph Hellwig
2023-05-03 15:24 ` [PATCH 17/21] btrfs: stop using PageError for extent_buffers Christoph Hellwig
2023-05-03 15:24 ` [PATCH 18/21] btrfs: don't check for uptodate pages in read_extent_buffer_pages Christoph Hellwig
2023-05-03 15:24 ` [PATCH 19/21] btrfs: stop using lock_extent in btrfs_buffer_uptodate Christoph Hellwig
2023-05-03 15:24 ` [PATCH 20/21] btrfs: use per-buffer locking for extent_buffer reading Christoph Hellwig
2023-05-03 15:24 ` [PATCH 21/21] btrfs: merge write_one_subpage_eb into write_one_eb Christoph Hellwig
2023-05-11 15:08 ` simplify extent_buffer reading and writing v4 Josef Bacik
2023-05-23 19:42 ` David Sterba
-- strict thread matches above, loose matches on Subject: below --
2023-03-30 6:30 simplify extent_buffer reading and writing v3 Christoph Hellwig
2023-03-30 6:30 ` [PATCH 14/21] btrfs: use a separate end_io handler for extent_buffer writing Christoph Hellwig
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=20230511150224.GA75508@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--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