All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@hammerspace.com>
To: John Garry <john.g.garry@oracle.com>
Cc: axboe@kernel.dk, agk@redhat.com, hch@lst.de, mpatocka@redhat.com,
	martin.petersen@oracle.com, linux-block@vger.kernel.org,
	dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 3/5] dm-table: Atomic writes support
Date: Mon, 6 Jan 2025 12:49:23 -0500	[thread overview]
Message-ID: <Z3wXoytvSU96ZAHj@hammerspace.com> (raw)
In-Reply-To: <20250106124119.1318428-4-john.g.garry@oracle.com>

On Mon, Jan 06, 2025 at 12:41:17PM +0000, John Garry wrote:
> Support stacking atomic write limits for DM devices.
> 
> All the pre-existing code in blk_stack_atomic_writes_limits() already takes
> care of finding the aggregate limits from the bottom devices.
> 
> Feature flag DM_TARGET_ATOMIC_WRITES is introduced so that atomic writes
> can be enabled on personalities selectively. This is to ensure that atomic
> writes are only enabled when verified to be working properly (for a
> specific personality). In addition, it just may not make sense to enable
> atomic writes on some personalities (so this flag also helps there).
> 
> When testing for bottom device atomic writes support, only the bdev
> queue limits are tested. There is no need to test the bottom bdev
> start sector (like which bdev_can_atomic_write() does), as this would
> already be checked in the dm_calculate_queue_limits() -> ..
> iterate_devices() -> dm_set_device_limits() -> blk_stack_limits()
> callchain.
> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>  drivers/md/dm-table.c         | 12 ++++++++++++
>  include/linux/device-mapper.h |  3 +++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index bd8b796ae683..1e0b7e364546 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -1593,6 +1593,7 @@ int dm_calculate_queue_limits(struct dm_table *t,
>  	struct queue_limits ti_limits;
>  	unsigned int zone_sectors = 0;
>  	bool zoned = false;
> +	bool atomic_writes = true;
>  
>  	dm_set_stacking_limits(limits);
>  
> @@ -1602,8 +1603,12 @@ int dm_calculate_queue_limits(struct dm_table *t,
>  
>  		if (!dm_target_passes_integrity(ti->type))
>  			t->integrity_supported = false;
> +		if (!dm_target_supports_atomic_writes(ti->type))
> +			atomic_writes = false;
>  	}
>  
> +	if (atomic_writes)
> +		limits->features |= BLK_FEAT_ATOMIC_WRITES_STACKED;
>  	for (unsigned int i = 0; i < t->num_targets; i++) {
>  		struct dm_target *ti = dm_table_get_target(t, i);
>  
> @@ -1616,6 +1621,13 @@ int dm_calculate_queue_limits(struct dm_table *t,
>  			goto combine_limits;
>  		}
>  
> +		/*
> +		 * dm_set_device_limits() -> blk_stack_limits() considers
> +		 * ti_limits as 'top', so set BLK_FEAT_ATOMIC_WRITES_STACKED
> +		 * here also.
> +		 */
> +		if (atomic_writes)
> +			ti_limits.features |= BLK_FEAT_ATOMIC_WRITES_STACKED;
>  		/*
>  		 * Combine queue limits of all the devices this target uses.
>  		 */

You're referring to this code that immediately follows this ^ comment
which stacks up the limits of a target's potential to have N component
data devices:

                ti->type->iterate_devices(ti, dm_set_device_limits,
                                          &ti_limits);

Your comment and redundant feature flag setting is feels wrong.  I'd
expect code comparable to what is done for zoned, e.g.:

                if (!zoned && (ti_limits.features & BLK_FEAT_ZONED)) {
                        /*
                         * After stacking all limits, validate all devices
                         * in table support this zoned model and zone sectors.
                         */
                        zoned = (ti_limits.features & BLK_FEAT_ZONED);
                        zone_sectors = ti_limits.chunk_sectors;
                }

Meaning, for zoned devices, a side-effect of the
ti->type->iterate_devices() call (and N blk_stack_limits calls) is
ti_limits.features having BLK_FEAT_ZONED enabled.  Why wouldn't the same
side-effect happen for BLK_FEAT_ATOMIC_WRITES_STACKED (speaks to
blk_stack_limits being different/wrong for atomic writes support)?

Just feels not quite right... but I could be wrong, please see if
there is any "there" there ;)

Thanks,
Mike


> diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
> index 8321f65897f3..bcc6d7b69470 100644
> --- a/include/linux/device-mapper.h
> +++ b/include/linux/device-mapper.h
> @@ -299,6 +299,9 @@ struct target_type {
>  #define dm_target_supports_mixed_zoned_model(type) (false)
>  #endif
>  
> +#define DM_TARGET_ATOMIC_WRITES		0x00000400
> +#define dm_target_supports_atomic_writes(type) ((type)->features & DM_TARGET_ATOMIC_WRITES)
> +
>  struct dm_target {
>  	struct dm_table *table;
>  	struct target_type *type;
> -- 
> 2.31.1
> 

  reply	other threads:[~2025-01-06 17:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06 12:41 [PATCH RFC 0/5] device mapper atomic write support John Garry
2025-01-06 12:41 ` [PATCH 1/5] block: Ensure start sector is aligned for stacking atomic writes John Garry
2025-01-06 15:36   ` Christoph Hellwig
2025-01-06 12:41 ` [PATCH RFC 2/5] block: Change blk_stack_atomic_writes_limits() unit_min check John Garry
2025-01-06 15:37   ` Christoph Hellwig
2025-01-06 12:41 ` [PATCH RFC 3/5] dm-table: Atomic writes support John Garry
2025-01-06 17:49   ` Mike Snitzer [this message]
2025-01-06 18:18     ` John Garry
2025-01-06 12:41 ` [PATCH RFC 4/5] dm: Ensure cloned bio is same length for atomic write John Garry
2025-01-06 12:41 ` [PATCH RFC 5/5] dm-linear: Enable atomic writes John Garry
2025-01-06 17:26 ` [PATCH RFC 0/5] device mapper atomic write support Mike Snitzer
2025-01-06 18:14   ` John Garry
2025-01-07 17:13     ` Mikulas Patocka
2025-01-07 17:58       ` John Garry
2025-01-07 18:56         ` Mikulas Patocka
2025-01-16 11:28       ` John Garry
2025-01-16 12:59         ` Mikulas Patocka
2025-01-16 13:03           ` John Garry
2025-01-16 14:58             ` Mikulas Patocka
2025-01-16 15:01               ` John Garry

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=Z3wXoytvSU96ZAHj@hammerspace.com \
    --to=snitzer@hammerspace.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=hch@lst.de \
    --cc=john.g.garry@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpatocka@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.