* [PATCH] block: avoid fragmented discard splits
@ 2020-12-29 15:27 Tom Yan
0 siblings, 0 replies; only message in thread
From: Tom Yan @ 2020-12-29 15:27 UTC (permalink / raw)
To: axboe, linux-block; +Cc: Tom Yan
Make bio_aligned_discard max_sectors() return value that is divisible by
the max_discard_sectors queue limit to avoid fragmented discard splits.
Signed-off-by: Tom Yan <tom.ty89@gmail.com>
---
block/blk.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/block/blk.h b/block/blk.h
index 7550364c326c..e87324a227c6 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -268,8 +268,12 @@ static inline unsigned int bio_allowed_max_sectors(struct request_queue *q)
static inline unsigned int bio_aligned_discard_max_sectors(
struct request_queue *q)
{
- return round_down(UINT_MAX, q->limits.discard_granularity) >>
- SECTOR_SHIFT;
+ unsigned int badms = round_down(UINT_MAX,
+ q->limits.discard_granularity) >>
+ SECTOR_SHIFT;
+ if (badms > q->limits.max_discard_sectors)
+ badms = round_down(badms, q->limits.max_discard_sectors);
+ return badms;
}
/*
--
2.29.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-29 15:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-29 15:27 [PATCH] block: avoid fragmented discard splits Tom Yan
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).