From: David Sterba <dsterba@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Qu Wenruo <wqu@suse.com>
Subject: Re: [PATCH 13/21] btrfs: don't use btrfs_bio_ctrl for extent buffer writing
Date: Fri, 26 May 2023 15:15:49 +0200 [thread overview]
Message-ID: <20230526131549.GB14830@suse.cz> (raw)
In-Reply-To: <20230524055003.GB19255@lst.de>
On Wed, May 24, 2023 at 07:50:03AM +0200, Christoph Hellwig wrote:
> On Tue, May 23, 2023 at 08:45:41PM +0200, David Sterba wrote:
> > On Wed, May 03, 2023 at 05:24:33PM +0200, Christoph Hellwig wrote:
> > > The btrfs_bio_ctrl machinery is overkill for writing extent_buffers
> > > as we always operate on PAGE SIZE chunks (or one smaller one for the
> > > subpage case) that are contigous and are guaranteed to fit into a
> > > single bio. Replace it with open coded btrfs_bio_alloc, __bio_add_page
> > > and btrfs_submit_bio calls.
> >
> > submit_extent_page hasn't been open coded completely, there's still call
> > to wbc_account_cgroup_owner() but it's probably skipped for other
> > reasons as this is metadata inode.
>
> Hmm, I was under the impression that we never did cgroup accounting for
> metadata. While that is true for the rest of the kernel, I fear I might
> have changed semantics for btrfs here (for better or worse). Let me
> dig into the code again, but I suspect I'll need to add
> wbc_account_cgroup_owner and wbc_init_bio back to not change semantics
> vs the old code.
Until we know for sure I'd rather keep the call, so something like that
(untested):
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fcd0563f7a15..a6480fa0366c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1833,6 +1833,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
wbc->nr_to_write--;
}
__bio_add_page(&bbio->bio, p, eb->len, eb->start - page_offset(p));
+ if (bio_ctrl->wbc)
+ wbc_account_cgroup_owner(bio_ctrl->wbc, p, len);
unlock_page(p);
} else {
for (int i = 0; i < num_extent_pages(eb); i++) {
@@ -1842,6 +1844,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
clear_page_dirty_for_io(p);
set_page_writeback(p);
__bio_add_page(&bbio->bio, p, PAGE_SIZE, 0);
+ if (bio_ctrl->wbc)
+ wbc_account_cgroup_owner(bio_ctrl->wbc, p, len);
wbc->nr_to_write--;
unlock_page(p);
}
@@ -4090,9 +4094,15 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
if (eb->fs_info->nodesize < PAGE_SIZE) {
__bio_add_page(&bbio->bio, eb->pages[0], eb->len,
eb->start - page_offset(eb->pages[0]));
+ if (bio_ctrl->wbc)
+ wbc_account_cgroup_owner(bio_ctrl->wbc, eb->pages[0], len);
} else {
- for (i = 0; i < num_pages; i++)
+ for (i = 0; i < num_pages; i++) {
__bio_add_page(&bbio->bio, eb->pages[i], PAGE_SIZE, 0);
+ if (bio_ctrl->wbc)
+ wbc_account_cgroup_owner(bio_ctrl->wbc,
+ eb->pages[i], len);
+ }
}
btrfs_submit_bio(bbio, mirror_num);
---
I can fold it to the patches.
next prev parent reply other threads:[~2023-05-26 13:22 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 [this message]
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
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 13/21] btrfs: don't use btrfs_bio_ctrl 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=20230526131549.GB14830@suse.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--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