* [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock
@ 2025-05-30 14:50 Benjamin Marzinski
2025-06-02 10:08 ` John Garry
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Marzinski @ 2025-05-30 14:50 UTC (permalink / raw)
To: Mikulas Patocka, Mike Snitzer; +Cc: dm-devel, John Garry
dm_set_device_limits() should check q->limits.features for
BLK_FEAT_ATOMIC_WRITES while holding q->limits_lock, like it does for
the rest of the queue limits.
Fixes: b7c18b17a173 ("dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits")
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
drivers/md/dm-table.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 57573e8b5aa9..9f95f77687ef 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -430,13 +430,13 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
return 0;
}
+ mutex_lock(&q->limits_lock);
/*
* 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);
- mutex_lock(&q->limits_lock);
if (blk_stack_limits(limits, &q->limits,
get_start_sect(bdev) + start) < 0)
DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock
2025-05-30 14:50 [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock Benjamin Marzinski
@ 2025-06-02 10:08 ` John Garry
2025-06-02 16:25 ` Benjamin Marzinski
0 siblings, 1 reply; 5+ messages in thread
From: John Garry @ 2025-06-02 10:08 UTC (permalink / raw)
To: Benjamin Marzinski, Mikulas Patocka, Mike Snitzer; +Cc: dm-devel, hch
On 30/05/2025 15:50, Benjamin Marzinski wrote:
+
> dm_set_device_limits() should check q->limits.features for
> BLK_FEAT_ATOMIC_WRITES while holding q->limits_lock, like it does for
> the rest of the queue limits.
>
> Fixes: b7c18b17a173 ("dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits")
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
In itself, the change seems fine, but I have doubts whether it's
preferred to even grab the q->limits_lock outside block layer / its helpers.
And, apart from this, if the bottom device limits change later, do we
actually trigger a top device limits evaluation update?
> ---
> drivers/md/dm-table.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 57573e8b5aa9..9f95f77687ef 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -430,13 +430,13 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
> return 0;
> }
>
> + mutex_lock(&q->limits_lock);
> /*
> * 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);
>
> - mutex_lock(&q->limits_lock);
> if (blk_stack_limits(limits, &q->limits,
> get_start_sect(bdev) + start) < 0)
> DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock
2025-06-02 10:08 ` John Garry
@ 2025-06-02 16:25 ` Benjamin Marzinski
2025-06-03 7:57 ` John Garry
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Marzinski @ 2025-06-02 16:25 UTC (permalink / raw)
To: John Garry; +Cc: Mikulas Patocka, Mike Snitzer, dm-devel, hch
On Mon, Jun 02, 2025 at 11:08:46AM +0100, John Garry wrote:
> On 30/05/2025 15:50, Benjamin Marzinski wrote:
>
> +
>
> > dm_set_device_limits() should check q->limits.features for
> > BLK_FEAT_ATOMIC_WRITES while holding q->limits_lock, like it does for
> > the rest of the queue limits.
> >
> > Fixes: b7c18b17a173 ("dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits")
> > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
>
> In itself, the change seems fine, but I have doubts whether it's preferred
> to even grab the q->limits_lock outside block layer / its helpers.
I'm pretty sure Mikulas added the q->limits_lock around DM's queue
limits accesses as the result of a discussion with some block layer
developers.
>
> And, apart from this, if the bottom device limits change later, do we
> actually trigger a top device limits evaluation update?
DM will obviously re-evaluate the limits if you reload the table. In
some cases, DM will also disable features if turns out that they aren't
supported when it actually tries to use them. Dumb question: Is there
much chance of a SCSI device's atomic write support changing while it's
in-use?
-Ben
> > ---
> > drivers/md/dm-table.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> > index 57573e8b5aa9..9f95f77687ef 100644
> > --- a/drivers/md/dm-table.c
> > +++ b/drivers/md/dm-table.c
> > @@ -430,13 +430,13 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
> > return 0;
> > }
> > + mutex_lock(&q->limits_lock);
> > /*
> > * 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);
> > - mutex_lock(&q->limits_lock);
> > if (blk_stack_limits(limits, &q->limits,
> > get_start_sect(bdev) + start) < 0)
> > DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock
2025-06-02 16:25 ` Benjamin Marzinski
@ 2025-06-03 7:57 ` John Garry
2025-06-03 16:05 ` Benjamin Marzinski
0 siblings, 1 reply; 5+ messages in thread
From: John Garry @ 2025-06-03 7:57 UTC (permalink / raw)
To: Benjamin Marzinski; +Cc: Mikulas Patocka, Mike Snitzer, dm-devel, hch
On 02/06/2025 17:25, Benjamin Marzinski wrote:
> On Mon, Jun 02, 2025 at 11:08:46AM +0100, John Garry wrote:
>> On 30/05/2025 15:50, Benjamin Marzinski wrote:
>>
>> +
>>
>>> dm_set_device_limits() should check q->limits.features for
>>> BLK_FEAT_ATOMIC_WRITES while holding q->limits_lock, like it does for
>>> the rest of the queue limits.
>>>
>>> Fixes: b7c18b17a173 ("dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits")
>>> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
>>
>> In itself, the change seems fine, but I have doubts whether it's preferred
>> to even grab the q->limits_lock outside block layer / its helpers.
>
> I'm pretty sure Mikulas added the q->limits_lock around DM's queue
> limits accesses as the result of a discussion with some block layer
> developers.
Do you have a pointer for that?
>
>>
>> And, apart from this, if the bottom device limits change later, do we
>> actually trigger a top device limits evaluation update?
>
> DM will obviously re-evaluate the limits if you reload the table. In
> some cases, DM will also disable features if turns out that they aren't
> supported when it actually tries to use them. Dumb question: Is there
> much chance of a SCSI device's atomic write support changing while it's
> in-use?
No, I would not think so.
thanks,
John
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock
2025-06-03 7:57 ` John Garry
@ 2025-06-03 16:05 ` Benjamin Marzinski
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Marzinski @ 2025-06-03 16:05 UTC (permalink / raw)
To: John Garry; +Cc: Mikulas Patocka, Mike Snitzer, dm-devel, hch
On Tue, Jun 03, 2025 at 08:57:32AM +0100, John Garry wrote:
> On 02/06/2025 17:25, Benjamin Marzinski wrote:
> > On Mon, Jun 02, 2025 at 11:08:46AM +0100, John Garry wrote:
> > > On 30/05/2025 15:50, Benjamin Marzinski wrote:
> > >
> > > +
> > >
> > > > dm_set_device_limits() should check q->limits.features for
> > > > BLK_FEAT_ATOMIC_WRITES while holding q->limits_lock, like it does for
> > > > the rest of the queue limits.
> > > >
> > > > Fixes: b7c18b17a173 ("dm-table: Set BLK_FEAT_ATOMIC_WRITES for target queue limits")
> > > > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> > >
> > > In itself, the change seems fine, but I have doubts whether it's preferred
> > > to even grab the q->limits_lock outside block layer / its helpers.
> >
> > I'm pretty sure Mikulas added the q->limits_lock around DM's queue
> > limits accesses as the result of a discussion with some block layer
> > developers.
>
> Do you have a pointer for that?
https://lore.kernel.org/dm-devel/ee66a4f2-ecc4-68d2-4594-a0bcba7ffe9c@redhat.com/
Specifically, in that thread Ming Lei suggests it here:
https://lore.kernel.org/dm-devel/Z9t709DZs-Flq1qS@fedora/
and Jens agrees.
-Ben
>
> >
> > >
> > > And, apart from this, if the bottom device limits change later, do we
> > > actually trigger a top device limits evaluation update?
> >
> > DM will obviously re-evaluate the limits if you reload the table. In
> > some cases, DM will also disable features if turns out that they aren't
> > supported when it actually tries to use them. Dumb question: Is there
> > much chance of a SCSI device's atomic write support changing while it's
> > in-use?
>
> No, I would not think so.
>
> thanks,
> John
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-03 16:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-30 14:50 [PATCH] dm-table: check BLK_FEAT_ATOMIC_WRITES inside limits_lock Benjamin Marzinski
2025-06-02 10:08 ` John Garry
2025-06-02 16:25 ` Benjamin Marzinski
2025-06-03 7:57 ` John Garry
2025-06-03 16:05 ` Benjamin Marzinski
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).