mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Cc: Luca Stefani <luca.stefani.ge1@gmail.com>,
	Jens Axboe <axboe@kernel.dk>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-btrfs@vger.kernel.org
Subject: [PATCH v2 1/3] block: Export bio_discard_limit
Date: Mon,  2 Sep 2024 22:56:10 +0200	[thread overview]
Message-ID: <20240902205828.943155-2-luca.stefani.ge1@gmail.com> (raw)
In-Reply-To: <20240902205828.943155-1-luca.stefani.ge1@gmail.com>

It can be used to calculate the sector size limit of each
discard call allowing filesystem to implement their own
chunked discard logic with customized behavior, for example
cancellation due to signals.

Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
---
 block/blk-lib.c        | 3 ++-
 include/linux/blkdev.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 4c9f20a689f7..501cbfc4f112 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -10,7 +10,7 @@
 
 #include "blk.h"
 
-static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
+sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
 {
 	unsigned int discard_granularity = bdev_discard_granularity(bdev);
 	sector_t granularity_aligned_sector;
@@ -34,6 +34,7 @@ static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
 	 */
 	return round_down(UINT_MAX, discard_granularity) >> SECTOR_SHIFT;
 }
+EXPORT_SYMBOL(bio_discard_limit);
 
 struct bio *blk_alloc_discard_bio(struct block_device *bdev,
 		sector_t *sector, sector_t *nr_sects, gfp_t gfp_mask)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b7664d593486..42d63400025b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1088,6 +1088,7 @@ static inline long nr_blockdev_pages(void)
 
 extern void blk_io_schedule(void);
 
+sector_t bio_discard_limit(struct block_device *bdev, sector_t sector);
 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,
-- 
2.46.0


  reply	other threads:[~2024-09-02 21:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 20:56 [PATCH v2 0/3] btrfs: Don't block suspend during fstrim Luca Stefani
2024-09-02 20:56 ` Luca Stefani [this message]
2024-09-02 21:57   ` [PATCH v2 1/3] block: Export bio_discard_limit David Sterba
2024-09-03  5:07     ` Christoph Hellwig
2024-09-02 20:56 ` [PATCH v2 2/3] btrfs: Split remaining space to discard in chunks Luca Stefani
2024-09-02 22:31   ` Qu Wenruo
2024-09-02 23:41     ` David Sterba
2024-09-02 20:56 ` [PATCH v2 3/3] btrfs: Don't block system suspend during fstrim Luca Stefani
2024-09-02 22:36   ` Qu Wenruo

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=20240902205828.943155-2-luca.stefani.ge1@gmail.com \
    --to=luca.stefani.ge1@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@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

all inboxes | Powered by JetHome®