mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits
@ 2025-05-02 14:39 John Garry
  2025-05-04 10:05 ` Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: John Garry @ 2025-05-02 14:39 UTC (permalink / raw)
  To: agk, snitzer, mpatocka
  Cc: dm-devel, linux-kernel, martin.petersen, John Garry

Feature flag BLK_FEAT_ATOMIC_WRITES is not being properly set for the
target queue limits, and this means that atomic writes are not being
enabled for any dm personalities.

When calling dm_set_device_limits() -> blk_stack_limits() ->
... -> blk_stack_atomic_writes_limits(), the bottom device limits
(which corresponds to intermediate target queue limits) does not have
BLK_FEAT_ATOMIC_WRITES set, and so atomic writes can never be enabled.

Typically such a flag would be inherited from the stacked device in
dm_set_device_limits() -> blk_stack_limits() via BLK_FEAT_INHERIT_MASK,
but BLK_FEAT_ATOMIC_WRITES is not inherited as it's preferred to manually
enable on a per-personality basis.

Set BLK_FEAT_ATOMIC_WRITES manually for the intermediate target queue
limits from the stacked device to get atomic writes working.

Fixes: 3194e36488e2 ("dm-table: atomic writes support")
Signed-off-by: John Garry <john.g.garry@oracle.com>

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 9e175c5e0634..b35e48fed641 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -431,6 +431,12 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
 		return 0;
 	}
 
+	/*
+	 * BLK_FEAT_ATOMIC_WRITES is not inherited from the bottom device in
+	 * blk_stack_limits(), so do it manually.
+	 */
+	limits->features |= (q->limits.features & BLK_FEAT_ATOMIC_WRITES);
+
 	if (blk_stack_limits(limits, &q->limits,
 			get_start_sect(bdev) + start) < 0)
 		DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits
  2025-05-02 14:39 [PATCH] dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits John Garry
@ 2025-05-04 10:05 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2025-05-04 10:05 UTC (permalink / raw)
  To: John Garry; +Cc: agk, snitzer, dm-devel, linux-kernel, martin.petersen

Hi

I applied the patch, thanks.

Mikulas



On Fri, 2 May 2025, John Garry wrote:

> Feature flag BLK_FEAT_ATOMIC_WRITES is not being properly set for the
> target queue limits, and this means that atomic writes are not being
> enabled for any dm personalities.
> 
> When calling dm_set_device_limits() -> blk_stack_limits() ->
> ... -> blk_stack_atomic_writes_limits(), the bottom device limits
> (which corresponds to intermediate target queue limits) does not have
> BLK_FEAT_ATOMIC_WRITES set, and so atomic writes can never be enabled.
> 
> Typically such a flag would be inherited from the stacked device in
> dm_set_device_limits() -> blk_stack_limits() via BLK_FEAT_INHERIT_MASK,
> but BLK_FEAT_ATOMIC_WRITES is not inherited as it's preferred to manually
> enable on a per-personality basis.
> 
> Set BLK_FEAT_ATOMIC_WRITES manually for the intermediate target queue
> limits from the stacked device to get atomic writes working.
> 
> Fixes: 3194e36488e2 ("dm-table: atomic writes support")
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 9e175c5e0634..b35e48fed641 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -431,6 +431,12 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
>  		return 0;
>  	}
>  
> +	/*
> +	 * BLK_FEAT_ATOMIC_WRITES is not inherited from the bottom device in
> +	 * blk_stack_limits(), so do it manually.
> +	 */
> +	limits->features |= (q->limits.features & BLK_FEAT_ATOMIC_WRITES);
> +
>  	if (blk_stack_limits(limits, &q->limits,
>  			get_start_sect(bdev) + start) < 0)
>  		DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
> -- 
> 2.31.1
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-04 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-02 14:39 [PATCH] dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits John Garry
2025-05-04 10:05 ` Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®