From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: Nikolay Borisov <nborisov@suse.com>, David Sterba <dsterba@suse.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/5] btrfs: remove use of buffer_heads from superblock writeout
Date: Wed, 22 Jan 2020 15:48:51 +0000 [thread overview]
Message-ID: <251DEF36-9630-4A9F-A26A-D52D01ECF873@wdc.com> (raw)
In-Reply-To: <6bdb46de-db12-27da-016d-773c362de254@suse.com>
On 17/01/2020, 16:01, "linux-btrfs-owner@vger.kernel.org on behalf of Nikolay Borisov" <linux-btrfs-owner@vger.kernel.org on behalf of nborisov@suse.com> wrote:
On 17.01.20 г. 14:51 ч., Johannes Thumshirn wrote:
> Similar to the superblock read path, change the write path to using BIOs
> and pages instead of buffer_heads.
>
> This is based on a patch originally authored by Nikolay Borisov.
>
> Co-developed-by: Nikolay Borisov <nborisov@suse.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/disk-io.c | 107 ++++++++++++++++++++++++++-------------------
> 1 file changed, 61 insertions(+), 46 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 50c93ffe8d03..51e7b832c8fd 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3353,25 +3353,33 @@ int __cold open_ctree(struct super_block *sb,
> }
> ALLOW_ERROR_INJECTION(open_ctree, ERRNO);
>
> -static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
> +static void btrfs_end_super_write(struct bio *bio)
> {
> - if (uptodate) {
> - set_buffer_uptodate(bh);
> - } else {
> - struct btrfs_device *device = (struct btrfs_device *)
> - bh->b_private;
> -
> - btrfs_warn_rl_in_rcu(device->fs_info,
> - "lost page write due to IO error on %s",
> - rcu_str_deref(device->name));
> - /* note, we don't set_buffer_write_io_error because we have
> - * our own ways of dealing with the IO errors
> - */
> - clear_buffer_uptodate(bh);
> - btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_WRITE_ERRS);
> + struct btrfs_device *device = bio->bi_private;
> + struct bio_vec *bvec;
> + struct bvec_iter_all iter_all;
> + struct page *page;
> +
> + bio_for_each_segment_all(bvec, bio, iter_all) {
> + page = bvec->bv_page;
> +
> + if (blk_status_to_errno(bio->bi_status)) {
> + btrfs_warn_rl_in_rcu(device->fs_info,
> + "lost page write due to IO error on %s",
> + rcu_str_deref(device->name));
> + ClearPageUptodate(page);
> + SetPageError(page);
> + btrfs_dev_stat_inc_and_print(device,
> + BTRFS_DEV_STAT_WRITE_ERRS);
> + } else {
> + SetPageUptodate(page);
> + }
> +
> + put_page(page);
Isn't this extra put page? Perhahps it's not because that would be the
reference from find_or_create_page in write_dev_supers. In any case I'd
rather have it in that function.
No we can't do the put_page() in in write_dev_supers() as btrfs_end_super_write()
is the bio endio hook and it's called upon completion of the bio. This happens
asynchronous to write_dev_supers().
next prev parent reply other threads:[~2020-01-22 15:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 12:51 [PATCH 0/5] btrfs: remove buffer heads form superblock handling Johannes Thumshirn
2020-01-17 12:51 ` [PATCH 1/5] btrfs: remove buffer heads from super block reading Johannes Thumshirn
2020-01-17 13:31 ` David Sterba
2020-01-17 14:30 ` Nikolay Borisov
2020-01-17 12:51 ` [PATCH 2/5] btrfs: remove use of buffer_heads from superblock writeout Johannes Thumshirn
2020-01-17 13:38 ` David Sterba
2020-01-17 14:51 ` David Sterba
2020-01-17 15:01 ` Nikolay Borisov
2020-01-17 15:11 ` David Sterba
2020-01-22 15:48 ` Johannes Thumshirn [this message]
2020-01-17 12:51 ` [PATCH 3/5] btrfs: remove btrfsic_submit_bh() Johannes Thumshirn
2020-01-17 15:05 ` Nikolay Borisov
2020-01-17 12:51 ` [PATCH 4/5] btrfs: remove buffer_heads from btrfsic_process_written_block() Johannes Thumshirn
2020-01-17 12:51 ` [PATCH 5/5] btrfs: remove buffer_heads form superblock mirror integrity checking Johannes Thumshirn
2020-01-17 15:10 ` Nikolay Borisov
2020-01-17 15:13 ` 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=251DEF36-9630-4A9F-A26A-D52D01ECF873@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=dsterba@suse.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;
as well as URLs for NNTP newsgroup(s).