From: Sarthak Kukreti <sarthakkukreti@chromium.org>
To: Mike Snitzer <snitzer@kernel.org>
Cc: dm-devel@redhat.com, linux-block@vger.kernel.org,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
"Theodore Ts'o" <tytso@mit.edu>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Darrick J. Wong" <djwong@kernel.org>,
Jason Wang <jasowang@redhat.com>,
Bart Van Assche <bvanassche@google.com>,
Christoph Hellwig <hch@infradead.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Stefan Hajnoczi <stefanha@redhat.com>,
Brian Foster <bfoster@redhat.com>,
Alasdair Kergon <agk@redhat.com>
Subject: Re: [PATCH v6 4/5] dm-thin: Add REQ_OP_PROVISION support
Date: Thu, 11 May 2023 13:03:23 -0700 [thread overview]
Message-ID: <CAG9=OMOMrFcy6UdL8-3wZGwOr1nqLm1bpvL+G1g2dvBhJWU2Kw@mail.gmail.com> (raw)
In-Reply-To: <ZFp7ykxGFUbPG1ON@redhat.com>
On Tue, May 9, 2023 at 9:58 AM Mike Snitzer <snitzer@kernel.org> wrote:
>
> On Sat, May 06 2023 at 2:29P -0400,
> Sarthak Kukreti <sarthakkukreti@chromium.org> wrote:
>
> > dm-thinpool uses the provision request to provision
> > blocks for a dm-thin device. dm-thinpool currently does not
> > pass through REQ_OP_PROVISION to underlying devices.
> >
> > For shared blocks, provision requests will break sharing and copy the
> > contents of the entire block. Additionally, if 'skip_block_zeroing'
> > is not set, dm-thin will opt to zero out the entire range as a part
> > of provisioning.
> >
> > Signed-off-by: Sarthak Kukreti <sarthakkukreti@chromium.org>
> > ---
> > drivers/md/dm-thin.c | 70 +++++++++++++++++++++++++++++++++++++++++---
> > 1 file changed, 66 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
> > index 2b13c949bd72..3f94f53ac956 100644
> > --- a/drivers/md/dm-thin.c
> > +++ b/drivers/md/dm-thin.c
> > @@ -274,6 +274,7 @@ struct pool {
> >
> > process_bio_fn process_bio;
> > process_bio_fn process_discard;
> > + process_bio_fn process_provision;
> >
> > process_cell_fn process_cell;
> > process_cell_fn process_discard_cell;
> > @@ -913,7 +914,8 @@ static void __inc_remap_and_issue_cell(void *context,
> > struct bio *bio;
> >
> > while ((bio = bio_list_pop(&cell->bios))) {
> > - if (op_is_flush(bio->bi_opf) || bio_op(bio) == REQ_OP_DISCARD)
> > + if (op_is_flush(bio->bi_opf) || bio_op(bio) == REQ_OP_DISCARD ||
> > + bio_op(bio) == REQ_OP_PROVISION)
> > bio_list_add(&info->defer_bios, bio);
> > else {
> > inc_all_io_entry(info->tc->pool, bio);
> > @@ -1245,8 +1247,8 @@ static int io_overlaps_block(struct pool *pool, struct bio *bio)
> >
> > static int io_overwrites_block(struct pool *pool, struct bio *bio)
> > {
> > - return (bio_data_dir(bio) == WRITE) &&
> > - io_overlaps_block(pool, bio);
> > + return (bio_data_dir(bio) == WRITE) && io_overlaps_block(pool, bio) &&
> > + bio_op(bio) != REQ_OP_PROVISION;
> > }
> >
> > static void save_and_set_endio(struct bio *bio, bio_end_io_t **save,
> > @@ -1953,6 +1955,51 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block
> > }
> > }
> >
> > +static void process_provision_bio(struct thin_c *tc, struct bio *bio)
> > +{
> > + int r;
> > + struct pool *pool = tc->pool;
> > + dm_block_t block = get_bio_block(tc, bio);
> > + struct dm_bio_prison_cell *cell;
> > + struct dm_cell_key key;
> > + struct dm_thin_lookup_result lookup_result;
> > +
> > + /*
> > + * If cell is already occupied, then the block is already
> > + * being provisioned so we have nothing further to do here.
> > + */
> > + build_virtual_key(tc->td, block, &key);
> > + if (bio_detain(pool, &key, bio, &cell))
> > + return;
> > +
> > + if (tc->requeue_mode) {
> > + cell_requeue(pool, cell);
> > + return;
> > + }
> > +
> > + r = dm_thin_find_block(tc->td, block, 1, &lookup_result);
> > + switch (r) {
> > + case 0:
> > + if (lookup_result.shared) {
> > + process_shared_bio(tc, bio, block, &lookup_result, cell);
> > + } else {
> > + bio_endio(bio);
> > + cell_defer_no_holder(tc, cell);
> > + }
> > + break;
> > + case -ENODATA:
> > + provision_block(tc, bio, block, cell);
> > + break;
> > +
> > + default:
> > + DMERR_LIMIT("%s: dm_thin_find_block() failed: error = %d",
> > + __func__, r);
> > + cell_defer_no_holder(tc, cell);
> > + bio_io_error(bio);
> > + break;
> > + }
> > +}
> > +
> > static void process_cell(struct thin_c *tc, struct dm_bio_prison_cell *cell)
> > {
> > int r;
> > @@ -2228,6 +2275,8 @@ static void process_thin_deferred_bios(struct thin_c *tc)
> >
> > if (bio_op(bio) == REQ_OP_DISCARD)
> > pool->process_discard(tc, bio);
> > + else if (bio_op(bio) == REQ_OP_PROVISION)
> > + pool->process_provision(tc, bio);
> > else
> > pool->process_bio(tc, bio);
> >
> > @@ -2579,6 +2628,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
> > dm_pool_metadata_read_only(pool->pmd);
> > pool->process_bio = process_bio_fail;
> > pool->process_discard = process_bio_fail;
> > + pool->process_provision = process_bio_fail;
> > pool->process_cell = process_cell_fail;
> > pool->process_discard_cell = process_cell_fail;
> > pool->process_prepared_mapping = process_prepared_mapping_fail;
> > @@ -2592,6 +2642,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
> > dm_pool_metadata_read_only(pool->pmd);
> > pool->process_bio = process_bio_read_only;
> > pool->process_discard = process_bio_success;
> > + pool->process_provision = process_bio_fail;
> > pool->process_cell = process_cell_read_only;
> > pool->process_discard_cell = process_cell_success;
> > pool->process_prepared_mapping = process_prepared_mapping_fail;
> > @@ -2612,6 +2663,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
> > pool->out_of_data_space = true;
> > pool->process_bio = process_bio_read_only;
> > pool->process_discard = process_discard_bio;
> > + pool->process_provision = process_bio_fail;
> > pool->process_cell = process_cell_read_only;
> > pool->process_prepared_mapping = process_prepared_mapping;
> > set_discard_callbacks(pool);
> > @@ -2628,6 +2680,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
> > dm_pool_metadata_read_write(pool->pmd);
> > pool->process_bio = process_bio;
> > pool->process_discard = process_discard_bio;
> > + pool->process_provision = process_provision_bio;
> > pool->process_cell = process_cell;
> > pool->process_prepared_mapping = process_prepared_mapping;
> > set_discard_callbacks(pool);
> > @@ -2749,7 +2802,8 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
> > return DM_MAPIO_SUBMITTED;
> > }
> >
> > - if (op_is_flush(bio->bi_opf) || bio_op(bio) == REQ_OP_DISCARD) {
> > + if (op_is_flush(bio->bi_opf) || bio_op(bio) == REQ_OP_DISCARD ||
> > + bio_op(bio) == REQ_OP_PROVISION) {
> > thin_defer_bio_with_throttle(tc, bio);
> > return DM_MAPIO_SUBMITTED;
> > }
> > @@ -3396,6 +3450,9 @@ static int pool_ctr(struct dm_target *ti, unsigned int argc, char **argv)
> > pt->adjusted_pf = pt->requested_pf = pf;
> > ti->num_flush_bios = 1;
> > ti->limit_swap_bios = true;
> > + ti->num_provision_bios = 1;
> > + ti->provision_supported = true;
> > + ti->max_provision_granularity = true;
> >
> > /*
> > * Only need to enable discards if the pool should pass
> > @@ -4114,6 +4171,8 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
> > * The pool uses the same discard limits as the underlying data
> > * device. DM core has already set this up.
> > */
> > +
> > + limits->max_provision_sectors = pool->sectors_per_block;
> > }
> >
> > static struct target_type pool_target = {
> > @@ -4288,6 +4347,9 @@ static int thin_ctr(struct dm_target *ti, unsigned int argc, char **argv)
> > ti->max_discard_granularity = true;
> > }
> >
> > + ti->num_provision_bios = 1;
> > + ti->provision_supported = true;
> > +
>
> We need this in thin_ctr: ti->max_provision_granularity = true;
>
> More needed in the thin target than thin-pool; otherwise provision bio
> issued to thin devices won't be split appropriately. But I do think
> its fine to set in both thin_ctr and pool_ctr.
>
> Otherwise, looks good.
>
Thanks! I'll add it to the next iteration (in addition to any other
feedback that's added to v6).
Given that this series covers multiple subsystems, would there be a
preferred way of queueing this for merge?
Best
Sarthak
> Thanks,
> Mike
next prev parent reply other threads:[~2023-05-11 20:03 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221229071647.437095-1-sarthakkukreti@chromium.org>
2023-04-14 0:02 ` [PATCH v3 0/3] Introduce provisioning primitives for thinly provisioned storage Sarthak Kukreti
2023-04-14 0:02 ` [PATCH v3 1/3] block: Introduce provisioning primitives Sarthak Kukreti
2023-04-17 17:35 ` Brian Foster
2023-04-18 22:13 ` Sarthak Kukreti
2023-04-14 0:02 ` [PATCH v3 2/3] dm: Add support for block provisioning Sarthak Kukreti
[not found] ` <CAJ0trDbyqoKEDN4kzcdn+vWhx+hk6pTM4ndf-E02f3uT9YZ3Uw@mail.gmail.com>
2023-04-14 18:14 ` Mike Snitzer
2023-04-14 21:58 ` Mike Snitzer
2023-04-18 22:13 ` Sarthak Kukreti
2023-04-14 0:02 ` [PATCH v3 3/3] loop: Add support for provision requests Sarthak Kukreti
2023-04-18 22:12 ` [PATCH v4 0/4] Introduce provisioning primitives for thinly provisioned storage Sarthak Kukreti
2023-04-18 22:12 ` [PATCH v4 1/4] block: Introduce provisioning primitives Sarthak Kukreti
2023-04-18 22:43 ` Bart Van Assche
2023-04-20 17:41 ` Sarthak Kukreti
2023-04-19 15:36 ` [dm-devel] " Darrick J. Wong
2023-04-19 16:17 ` Mike Snitzer
2023-04-19 17:26 ` Darrick J. Wong
2023-04-19 23:21 ` Dave Chinner
2023-04-20 0:53 ` Sarthak Kukreti
2023-04-18 22:12 ` [PATCH v4 2/4] dm: Add block provisioning support Sarthak Kukreti
2023-04-18 22:12 ` [PATCH v4 3/4] dm-thin: Add REQ_OP_PROVISION support Sarthak Kukreti
2023-04-18 22:12 ` [PATCH v4 4/4] loop: Add support for provision requests Sarthak Kukreti
2023-04-20 0:48 ` [PATCH v5 0/5] Introduce block provisioning primitives Sarthak Kukreti
2023-04-20 0:48 ` [PATCH v5 1/5] block: Don't invalidate pagecache for invalid falloc modes Sarthak Kukreti
2023-04-20 1:22 ` Darrick J. Wong
2023-04-20 1:48 ` Sarthak Kukreti
2023-04-20 1:47 ` [PATCH v5-fix " Sarthak Kukreti
2023-04-20 16:20 ` Mike Snitzer
2023-04-20 17:28 ` Sarthak Kukreti
2023-04-20 18:17 ` Sarthak Kukreti
2023-04-20 18:15 ` Sarthak Kukreti
2023-04-24 15:54 ` [PATCH v5 " kernel test robot
2023-05-04 8:50 ` kernel test robot
2023-04-20 0:48 ` [PATCH v5 2/5] block: Introduce provisioning primitives Sarthak Kukreti
2023-04-20 0:48 ` [PATCH v5 3/5] dm: Add block provisioning support Sarthak Kukreti
2023-04-20 0:48 ` [PATCH v5 4/5] dm-thin: Add REQ_OP_PROVISION support Sarthak Kukreti
2023-05-01 19:15 ` Mike Snitzer
2023-05-06 6:32 ` Sarthak Kukreti
2023-04-20 0:48 ` [PATCH v5 5/5] loop: Add support for provision requests Sarthak Kukreti
2023-05-06 6:29 ` [PATCH v6 0/5] Introduce block provisioning primitives Sarthak Kukreti
2023-05-06 6:29 ` [PATCH v6 1/5] block: Don't invalidate pagecache for invalid falloc modes Sarthak Kukreti
2023-05-09 16:51 ` Mike Snitzer
2023-05-12 18:31 ` Darrick J. Wong
2023-05-06 6:29 ` [PATCH v6 2/5] block: Introduce provisioning primitives Sarthak Kukreti
2023-05-09 16:52 ` Mike Snitzer
2023-05-12 18:37 ` Darrick J. Wong
2023-05-15 21:55 ` Sarthak Kukreti
2023-05-06 6:29 ` [PATCH v6 3/5] dm: Add block provisioning support Sarthak Kukreti
2023-05-09 16:52 ` Mike Snitzer
2023-05-06 6:29 ` [PATCH v6 4/5] dm-thin: Add REQ_OP_PROVISION support Sarthak Kukreti
2023-05-09 16:58 ` Mike Snitzer
2023-05-11 20:03 ` Sarthak Kukreti [this message]
2023-05-12 14:34 ` Mike Snitzer
2023-05-12 17:32 ` Mike Snitzer
2023-05-15 21:19 ` Sarthak Kukreti
2023-05-06 6:29 ` [PATCH v6 5/5] loop: Add support for provision requests Sarthak Kukreti
2023-05-15 12:40 ` Brian Foster
2023-05-15 21:31 ` Sarthak Kukreti
2023-05-12 18:28 ` [PATCH v6 0/5] Introduce block provisioning primitives Darrick J. Wong
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='CAG9=OMOMrFcy6UdL8-3wZGwOr1nqLm1bpvL+G1g2dvBhJWU2Kw@mail.gmail.com' \
--to=sarthakkukreti@chromium.org \
--cc=adilger.kernel@dilger.ca \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=bfoster@redhat.com \
--cc=bvanassche@google.com \
--cc=djwong@kernel.org \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=jasowang@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=snitzer@kernel.org \
--cc=stefanha@redhat.com \
--cc=tytso@mit.edu \
/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).