Commit 84613bed authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: cleanup variable naming in get_max_io_size

get_max_io_size has a very odd choice of variables names and
initialization patterns.  Switch to more descriptive names and more
clear initialization of them.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220614090934.570632-5-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c8875190
...@@ -164,18 +164,16 @@ static struct bio *blk_bio_write_zeroes_split(struct request_queue *q, ...@@ -164,18 +164,16 @@ static struct bio *blk_bio_write_zeroes_split(struct request_queue *q,
static inline unsigned get_max_io_size(struct request_queue *q, static inline unsigned get_max_io_size(struct request_queue *q,
struct bio *bio) struct bio *bio)
{ {
unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
unsigned max_sectors = sectors;
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT; unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT; unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
unsigned start_offset = bio->bi_iter.bi_sector & (pbs - 1); unsigned max_sectors, start, end;
max_sectors += start_offset; max_sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
max_sectors &= ~(pbs - 1); start = bio->bi_iter.bi_sector & (pbs - 1);
if (max_sectors > start_offset) end = (start + max_sectors) & ~(pbs - 1);
return max_sectors - start_offset; if (end > start)
return end - start;
return sectors & ~(lbs - 1); return max_sectors & ~(lbs - 1);
} }
static inline unsigned get_max_segment_size(const struct request_queue *q, static inline unsigned get_max_segment_size(const struct request_queue *q,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment