public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: linux-btrfs@vger.kernel.org, Naohiro Aota <Naohiro.Aota@wdc.com>
Subject: Re: [PATCH v4 3/9] btrfs: add support for inserting raid stripe extents
Date: Mon, 12 Dec 2022 14:27:35 -0500	[thread overview]
Message-ID: <Y5eAp1+zNz2bv9dD@localhost.localdomain> (raw)
In-Reply-To: <238cc419b3cbc18c4a93ad7827d33961fafd4196.1670422590.git.johannes.thumshirn@wdc.com>

On Wed, Dec 07, 2022 at 06:22:12AM -0800, Johannes Thumshirn wrote:
> Add support for inserting stripe extents into the raid stripe tree on
> completion of every write that needs an extra logical-to-physical
> translation when using RAID.
> 
> Inserting the stripe extents happens after the data I/O has completed,
> this is done to a) support zone-append and b) rule out the possibility of
> a RAID-write-hole.
> 
> This is done by creating in-memory ordered stripe extents, just like the
> in memory ordered extents, on I/O completion and the on-disk raid stripe
> extents get created once we're running the delayed_refs for the extent
> item this stripe extent is tied to.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/Makefile           |   3 +-
>  fs/btrfs/bio.c              |  30 +++++-
>  fs/btrfs/bio.h              |   2 +
>  fs/btrfs/delayed-ref.c      |   5 +-
>  fs/btrfs/disk-io.c          |   3 +
>  fs/btrfs/extent-tree.c      |  49 +++++++++
>  fs/btrfs/fs.h               |   3 +
>  fs/btrfs/inode.c            |   6 ++
>  fs/btrfs/raid-stripe-tree.c | 195 ++++++++++++++++++++++++++++++++++++
>  fs/btrfs/raid-stripe-tree.h |  69 +++++++++++++
>  fs/btrfs/volumes.c          |   5 +-
>  fs/btrfs/volumes.h          |  12 +--
>  fs/btrfs/zoned.c            |   4 +
>  13 files changed, 376 insertions(+), 10 deletions(-)
>  create mode 100644 fs/btrfs/raid-stripe-tree.c
>  create mode 100644 fs/btrfs/raid-stripe-tree.h
> 
> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
> index 555c962fdad6..63236ae2a87b 100644
> --- a/fs/btrfs/Makefile
> +++ b/fs/btrfs/Makefile
> @@ -31,7 +31,8 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
>  	   backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
>  	   uuid-tree.o props.o free-space-tree.o tree-checker.o space-info.o \
>  	   block-rsv.o delalloc-space.o block-group.o discard.o reflink.o \
> -	   subpage.o tree-mod-log.o extent-io-tree.o fs.o messages.o bio.o
> +	   subpage.o tree-mod-log.o extent-io-tree.o fs.o messages.o bio.o \
> +	   raid-stripe-tree.o
>  
>  btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
>  btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
> diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
> index 4ccbc120e869..b60a50165703 100644
> --- a/fs/btrfs/bio.c
> +++ b/fs/btrfs/bio.c
> @@ -15,6 +15,7 @@
>  #include "rcu-string.h"
>  #include "zoned.h"
>  #include "file-item.h"
> +#include "raid-stripe-tree.h"
>  
>  static struct bio_set btrfs_bioset;
>  static struct bio_set btrfs_clone_bioset;
> @@ -350,6 +351,21 @@ static void btrfs_raid56_end_io(struct bio *bio)
>  	btrfs_put_bioc(bioc);
>  }
>  
> +static void btrfs_raid_stripe_update(struct work_struct *work)
> +{
> +	struct btrfs_bio *bbio =
> +		container_of(work, struct btrfs_bio, raid_stripe_work);
> +	struct btrfs_io_stripe *stripe = bbio->bio.bi_private;
> +	struct btrfs_io_context *bioc = stripe->bioc;
> +	int ret;
> +
> +	ret = btrfs_add_ordered_stripe(bioc);
> +	if (ret)
> +		bbio->bio.bi_status = errno_to_blk_status(ret);
> +	btrfs_orig_bbio_end_io(bbio);
> +	btrfs_put_bioc(bioc);
> +}
> +
>  static void btrfs_orig_write_end_io(struct bio *bio)
>  {
>  	struct btrfs_io_stripe *stripe = bio->bi_private;
> @@ -372,6 +388,15 @@ static void btrfs_orig_write_end_io(struct bio *bio)
>  	else
>  		bio->bi_status = BLK_STS_OK;
>  
> +	if (bio_op(bio) == REQ_OP_ZONE_APPEND)
> +		stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT;
> +
> +	if (btrfs_need_stripe_tree_update(bioc->fs_info, bioc->map_type)) {
> +		INIT_WORK(&bbio->raid_stripe_work, btrfs_raid_stripe_update);
> +		schedule_work(&bbio->raid_stripe_work);
> +		return;
> +	}
> +
>  	btrfs_orig_bbio_end_io(bbio);
>  	btrfs_put_bioc(bioc);
>  }
> @@ -383,7 +408,9 @@ static void btrfs_clone_write_end_io(struct bio *bio)
>  	if (bio->bi_status) {
>  		atomic_inc(&stripe->bioc->error);
>  		btrfs_log_dev_io_error(bio, stripe->dev);
> -	}
> +	} else if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
> +		stripe->physical = bio->bi_iter.bi_sector << SECTOR_SHIFT;
> + 	}

Whitespace error here.  Thanks,

Josef

  parent reply	other threads:[~2022-12-12 19:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 14:22 [PATCH v4 0/9] btrfs: introduce RAID stripe tree Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 1/9] btrfs: add raid stripe tree definitions Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 2/9] btrfs: read raid-stripe-tree from disk Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 3/9] btrfs: add support for inserting raid stripe extents Johannes Thumshirn
2022-12-12  7:22   ` Christoph Hellwig
2022-12-13  8:15     ` Johannes Thumshirn
2022-12-13  8:36       ` hch
2022-12-13  8:47         ` Johannes Thumshirn
2022-12-13  8:54           ` hch
2022-12-13  9:01             ` Johannes Thumshirn
2022-12-12 19:27   ` Josef Bacik [this message]
2022-12-13  8:17     ` Johannes Thumshirn
2022-12-13 16:14   ` Josef Bacik
2022-12-13 17:48     ` Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 4/9] btrfs: delete stripe extent on extent deletion Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 5/9] btrfs: lookup physical address from stripe extent Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 6/9] btrfs: add raid stripe tree pretty printer Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 7/9] btrfs: zoned: allow zoned RAID Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 8/9] btrfs: check for leaks of ordered stripes on umount Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 9/9] btrfs: add tracepoints for ordered stripes Johannes Thumshirn

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=Y5eAp1+zNz2bv9dD@localhost.localdomain \
    --to=josef@toxicpanda.com \
    --cc=Naohiro.Aota@wdc.com \
    --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