public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Stefani <luca.stefani.ge1@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: Export blk_alloc_discard_bio
Date: Tue, 3 Sep 2024 18:02:37 +0200	[thread overview]
Message-ID: <8f7269b0-e8f1-47cc-9ad7-1f1c2e452b02@gmail.com> (raw)
In-Reply-To: <8d5a0a41-0112-4c53-a7c4-67bfc5332ba9@kernel.dk>



On 03/09/24 17:49, Jens Axboe wrote:
> On 9/3/24 1:39 AM, Luca Stefani wrote:
>> The fs trim loops over ranges and sends discard requests, some ranges
>> can be large so it's all transparently handled by blkdev_issue_discard()
>> and processed in smaller chunks.
>>
>> To support cancellation (or suspend) requests we need to insert checks
>> into the the loop, exporting the symbol allows to reimplement
>> such loop with the desired behavior.
>>
>> Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
>> ---
>>   block/blk-lib.c        | 1 +
>>   include/linux/blkdev.h | 2 ++
>>   2 files changed, 3 insertions(+)
>>
>> diff --git a/block/blk-lib.c b/block/blk-lib.c
>> index 4c9f20a689f7..ebaef47d8ce7 100644
>> --- a/block/blk-lib.c
>> +++ b/block/blk-lib.c
>> @@ -59,6 +59,7 @@ struct bio *blk_alloc_discard_bio(struct block_device *bdev,
>>   	cond_resched();
>>   	return bio;
>>   }
>> +EXPORT_SYMBOL_GPL(blk_alloc_discard_bio);
>>   
>>   int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>>   		sector_t nr_sects, gfp_t gfp_mask, struct bio **biop)
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index b7664d593486..f3631044d905 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -1088,6 +1088,8 @@ static inline long nr_blockdev_pages(void)
>>   
>>   extern void blk_io_schedule(void);
>>   
>> +struct bio *blk_alloc_discard_bio(struct block_device *bdev,
>> +		sector_t *sector, sector_t *nr_sects, gfp_t gfp_mask);
>>   int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>>   		sector_t nr_sects, gfp_t gfp_mask);
>>   int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
> 
> Since blk_alloc_discard_bio() is already defined in a header (otherwise
> it would've been static and your export symbol above would have failed
> miserably), why add it to another header?
> 

ACK, will remove the header change in v4,

Thanks.

  reply	other threads:[~2024-09-03 16:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03  7:16 [PATCH v3 0/2] btrfs: Don't block suspend during fstrim Luca Stefani
2024-09-03  7:16 ` [PATCH v3 1/3] btrfs: Always update fstrim_range on failure Luca Stefani
2024-09-03  7:16 ` [PATCH v3 2/3] btrfs: Split remaining space to discard in chunks Luca Stefani
2024-09-03  7:27   ` Christoph Hellwig
2024-09-03  7:39     ` [PATCH] block: Export blk_alloc_discard_bio Luca Stefani
2024-09-03 15:49       ` Jens Axboe
2024-09-03 16:02         ` Luca Stefani [this message]
2024-09-03  9:43     ` [PATCH v3 2/3] btrfs: Split remaining space to discard in chunks Qu Wenruo
2024-09-04  4:13       ` Christoph Hellwig
2024-09-04  5:34         ` Qu Wenruo
2024-09-03 10:39   ` Luca Stefani
2024-09-03 19:39   ` David Sterba
2024-09-06 20:10   ` kernel test robot
2024-09-03  7:16 ` [PATCH v3 3/3] btrfs: Don't block system suspend during fstrim Luca Stefani

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=8f7269b0-e8f1-47cc-9ad7-1f1c2e452b02@gmail.com \
    --to=luca.stefani.ge1@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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