Skip to content

Commit 15bfd21

Browse files
Keith Buschaxboe
authored andcommitted
block: Fix transfer when chunk sectors exceeds max
A device may have boundary restrictions where the number of sectors between boundaries exceeds its max transfer size. In this case, we need to cap the max size to the smaller of the two limits. Reported-by: Jitendra Bhivare <[email protected]> Tested-by: Jitendra Bhivare <[email protected]> Cc: <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Signed-off-by: Keith Busch <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent f5e350f commit 15bfd21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/blkdev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
11191119
if (!q->limits.chunk_sectors)
11201120
return q->limits.max_sectors;
11211121

1122-
return q->limits.chunk_sectors -
1123-
(offset & (q->limits.chunk_sectors - 1));
1122+
return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
1123+
(offset & (q->limits.chunk_sectors - 1))));
11241124
}
11251125

11261126
static inline unsigned int blk_rq_get_max_sectors(struct request *rq,

0 commit comments

Comments
 (0)