From: Christoph Hellwig <hch@infradead.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
Nikolay Borisov <nborisov@suse.com>,
"linux-btrfs @ vger . kernel . org" <linux-btrfs@vger.kernel.org>,
Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH v3 2/5] btrfs: remove use of buffer_heads from superblock writeout
Date: Tue, 28 Jan 2020 03:52:39 -0800 [thread overview]
Message-ID: <20200128115239.GB17444@infradead.org> (raw)
In-Reply-To: <20200127155931.10818-3-johannes.thumshirn@wdc.com>
On Tue, Jan 28, 2020 at 12:59:28AM +0900, Johannes Thumshirn wrote:
> Similar to the superblock read path, change the write path to using BIOs
> and pages instead of buffer_heads. This allows us to skip over the
> buffer_head code, for writing the superblock to disk.
Hmm, the previous patch already changed one place that wrote the sb..
> - /* One reference for us, and we leave it for the caller */
> - bh = __getblk(device->bdev, bytenr / BTRFS_BDEV_BLOCKSIZE,
> - BTRFS_SUPER_INFO_SIZE);
> - if (!bh) {
> + page = find_or_create_page(mapping, bytenr >> PAGE_SHIFT,
> + gfp_mask);
> + if (!page) {
> btrfs_err(device->fs_info,
> - "couldn't get super buffer head for bytenr %llu",
> + "couldn't get superblock page for bytenr %llu",
> bytenr);
> errors++;
> continue;
> }
>
> - memcpy(bh->b_data, sb, BTRFS_SUPER_INFO_SIZE);
> + /* Bump the refcount for wait_dev_supers() */
> + get_page(page);
>
> - /* one reference for submit_bh */
> - get_bh(bh);
> -
> - set_buffer_uptodate(bh);
> - lock_buffer(bh);
> - bh->b_end_io = btrfs_end_buffer_write_sync;
> - bh->b_private = device;
> + ptr = kmap(page);
> + memcpy(ptr, sb, BTRFS_SUPER_INFO_SIZE);
> + kunmap(page);
What is the point of using the page cache here given that you are
always using a local copy of the data anyway?
> + wait_on_page_locked(page);
> + if (PageError(page)) {
> errors++;
> if (i == 0)
> primary_failed = true;
> }
>
> /* drop our reference */
> - brelse(bh);
> + put_page(page);
>
> /* drop the reference from the writing run */
> - brelse(bh);
> + put_page(page);
Why not use an inflight count + completion instead of messing
with the page lock like that?
next prev parent reply other threads:[~2020-01-28 11:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-27 15:59 [PATCH v3 0/5] btrfs: remove buffer heads form superblock handling Johannes Thumshirn
2020-01-27 15:59 ` [PATCH v3 1/5] btrfs: remove buffer heads from super block reading Johannes Thumshirn
2020-01-28 11:47 ` Christoph Hellwig
2020-01-30 10:12 ` Johannes Thumshirn
2020-01-27 15:59 ` [PATCH v3 2/5] btrfs: remove use of buffer_heads from superblock writeout Johannes Thumshirn
2020-01-28 11:52 ` Christoph Hellwig [this message]
2020-01-27 15:59 ` [PATCH v3 3/5] btrfs: remove btrfsic_submit_bh() Johannes Thumshirn
2020-01-27 15:59 ` [PATCH v3 4/5] btrfs: remove buffer_heads from btrfsic_process_written_block() Johannes Thumshirn
2020-01-27 15:59 ` [PATCH v3 5/5] btrfs: remove buffer_heads form superblock mirror integrity checking Johannes Thumshirn
2020-01-29 14:25 ` [PATCH v3 0/5] btrfs: remove buffer heads form superblock handling David Sterba
2020-01-30 11:23 ` Johannes Thumshirn
2020-01-30 12:15 ` David Sterba
2020-01-30 13:39 ` Christoph Hellwig
2020-01-30 15:53 ` Johannes Thumshirn
2020-01-30 15:56 ` Christoph Hellwig
2020-01-30 16:09 ` Johannes Thumshirn
2020-01-30 16:15 ` Christoph Hellwig
2020-01-30 16:16 ` David Sterba
2020-01-31 13:43 ` Johannes Thumshirn
2020-02-03 8:29 ` 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=20200128115239.GB17444@infradead.org \
--to=hch@infradead.org \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@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