* [PATCH] loop: Use bdev limit helpers for configuring discard
@ 2024-10-30 11:19 John Garry
2024-10-30 13:24 ` Jens Axboe
2024-10-30 14:06 ` Christoph Hellwig
0 siblings, 2 replies; 6+ messages in thread
From: John Garry @ 2024-10-30 11:19 UTC (permalink / raw)
To: axboe, hch; +Cc: linux-block, John Garry
Instead of directly looking at the request_queue limits, use the bdev
limits helpers, which is preferable.
Signed-off-by: John Garry <john.g.garry@oracle.com>
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 78a7bb28defe..7719858c49bb 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -786,11 +786,11 @@ static void loop_config_discard(struct loop_device *lo,
* file-backed loop devices: discarded regions read back as zero.
*/
if (S_ISBLK(inode->i_mode)) {
- struct request_queue *backingq = bdev_get_queue(I_BDEV(inode));
+ struct block_device *bdev = I_BDEV(inode);
- max_discard_sectors = backingq->limits.max_write_zeroes_sectors;
- granularity = bdev_discard_granularity(I_BDEV(inode)) ?:
- queue_physical_block_size(backingq);
+ max_discard_sectors = bdev_write_zeroes_sectors(bdev);
+ granularity = bdev_discard_granularity(bdev) ?:
+ bdev_physical_block_size(bdev);
/*
* We use punch hole to reclaim the free space used by the
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] loop: Use bdev limit helpers for configuring discard
2024-10-30 11:19 [PATCH] loop: Use bdev limit helpers for configuring discard John Garry
@ 2024-10-30 13:24 ` Jens Axboe
2024-10-30 14:06 ` Christoph Hellwig
1 sibling, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2024-10-30 13:24 UTC (permalink / raw)
To: hch, John Garry; +Cc: linux-block
On Wed, 30 Oct 2024 11:19:00 +0000, John Garry wrote:
> Instead of directly looking at the request_queue limits, use the bdev
> limits helpers, which is preferable.
>
>
Applied, thanks!
[1/1] loop: Use bdev limit helpers for configuring discard
commit: 8d3fd059dd289e6c322e5741ad56794bcce699a2
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loop: Use bdev limit helpers for configuring discard
2024-10-30 11:19 [PATCH] loop: Use bdev limit helpers for configuring discard John Garry
2024-10-30 13:24 ` Jens Axboe
@ 2024-10-30 14:06 ` Christoph Hellwig
2024-10-30 14:13 ` John Garry
1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2024-10-30 14:06 UTC (permalink / raw)
To: John Garry; +Cc: axboe, hch, linux-block
On Wed, Oct 30, 2024 at 11:19:00AM +0000, John Garry wrote:
> + granularity = bdev_discard_granularity(bdev) ?:
> + bdev_physical_block_size(bdev);
The discard granularity is always set to at least the physical block
size, so this can be simplified to:
granularity = bdev_discard_granularity(bdev);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loop: Use bdev limit helpers for configuring discard
2024-10-30 14:06 ` Christoph Hellwig
@ 2024-10-30 14:13 ` John Garry
2024-11-01 9:08 ` John Garry
0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2024-10-30 14:13 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: axboe, linux-block
On 30/10/2024 14:06, Christoph Hellwig wrote:
> On Wed, Oct 30, 2024 at 11:19:00AM +0000, John Garry wrote:
>> + granularity = bdev_discard_granularity(bdev) ?:
>> + bdev_physical_block_size(bdev);
> The discard granularity is always set to at least the physical block
> size, so this can be simplified to:
>
> granularity = bdev_discard_granularity(bdev);
ok, I see that set in blk_validate_limits()
Jens has already queued this and it is now buried beneath other patches,
so I suppose that this change can be made in the follow on patch.
Cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loop: Use bdev limit helpers for configuring discard
2024-10-30 14:13 ` John Garry
@ 2024-11-01 9:08 ` John Garry
2024-11-04 7:47 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2024-11-01 9:08 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: axboe, linux-block
On 30/10/2024 14:13, John Garry wrote:
>> On Wed, Oct 30, 2024 at 11:19:00AM +0000, John Garry wrote:
>>> + granularity = bdev_discard_granularity(bdev) ?:
>>> + bdev_physical_block_size(bdev);
>> The discard granularity is always set to at least the physical block
>> size, so this can be simplified to:
>>
>> granularity = bdev_discard_granularity(bdev);
>
> ok, I see that set in blk_validate_limits()
BTW, can the check for granularity ever fail in
queue_limit_discard_alignment()
static unsigned int queue_limit_discard_alignment(...)
{
...
granularity = lim->discard_granularity >> SECTOR_SHIFT;
if (!granularity)
return 0;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loop: Use bdev limit helpers for configuring discard
2024-11-01 9:08 ` John Garry
@ 2024-11-04 7:47 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2024-11-04 7:47 UTC (permalink / raw)
To: John Garry; +Cc: Christoph Hellwig, axboe, linux-block
On Fri, Nov 01, 2024 at 09:08:51AM +0000, John Garry wrote:
>> ok, I see that set in blk_validate_limits()
>
> BTW, can the check for granularity ever fail in
> queue_limit_discard_alignment()
>
> static unsigned int queue_limit_discard_alignment(...)
> {
> ...
>
> granularity = lim->discard_granularity >> SECTOR_SHIFT;
> if (!granularity)
> return 0;
lim->discard_granularity is always set to SECTOR_SIZE or large,
so granularity can't be 0 here.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-04 7:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 11:19 [PATCH] loop: Use bdev limit helpers for configuring discard John Garry
2024-10-30 13:24 ` Jens Axboe
2024-10-30 14:06 ` Christoph Hellwig
2024-10-30 14:13 ` John Garry
2024-11-01 9:08 ` John Garry
2024-11-04 7:47 ` Christoph Hellwig
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).