mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
block: make sure discard bio is aligned with logical block size
Obviously the created discard bio has to be aligned with logical block size. This patch introduces the helper of bio_allowed_max_sectors() for this purpose. Cc: [email protected] Cc: Mike Snitzer <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Xiao Ni <[email protected]> Cc: Mariusz Dabrowski <[email protected]> Fixes:744889b7cb("block: don't deal with discard limit in blkdev_issue_discard()") Fixes:a22c4d7e34("block: re-add discard_granularity and alignment checks") Reported-by: Rui Salvaterra <[email protected]> Tested-by: Rui Salvaterra <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
d39aa49792
commit
1adfc5e413
3 changed files with 13 additions and 3 deletions
10
block/blk.h
10
block/blk.h
|
|
@ -395,6 +395,16 @@ static inline unsigned long blk_rq_deadline(struct request *rq)
|
|||
return rq->__deadline & ~0x1UL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The max size one bio can handle is UINT_MAX becasue bvec_iter.bi_size
|
||||
* is defined as 'unsigned int', meantime it has to aligned to with logical
|
||||
* block size which is the minimum accepted unit by hardware.
|
||||
*/
|
||||
static inline unsigned int bio_allowed_max_sectors(struct request_queue *q)
|
||||
{
|
||||
return round_down(UINT_MAX, queue_logical_block_size(q)) >> 9;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal io_context interface
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue