Skip to content

Commit 2800aac

Browse files
martinkpetersenJens Axboe
authored andcommitted
block: Update blk_queue_max_sectors and documentation
Clarify blk_queue_max_sectors and update documentation. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 024f906 commit 2800aac

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

‎block/blk-settings.c‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,30 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
212212
/**
213213
* blk_queue_max_sectors - set max sectors for a request for this queue
214214
* @q: the request queue for the device
215-
* @max_sectors: max sectors in the usual 512b unit
215+
* @max_hw_sectors: max hardware sectors in the usual 512b unit
216216
*
217217
* Description:
218-
* Enables a low level driver to set an upper limit on the size of
219-
* received requests.
218+
* Enables a low level driver to set a hard upper limit,
219+
* max_hw_sectors, on the size of requests. max_hw_sectors is set by
220+
* the device driver based upon the combined capabilities of I/O
221+
* controller and storage device.
222+
*
223+
* max_sectors is a soft limit imposed by the block layer for
224+
* filesystem type requests. This value can be overridden on a
225+
* per-device basis in /sys/block/<device>/queue/max_sectors_kb.
226+
* The soft limit can not exceed max_hw_sectors.
220227
**/
221-
void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors)
228+
void blk_queue_max_sectors(struct request_queue *q, unsigned int max_hw_sectors)
222229
{
223-
if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
224-
max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
230+
if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {
231+
max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
225232
printk(KERN_INFO "%s: set to minimum %d\n",
226-
__func__, max_sectors);
233+
__func__, max_hw_sectors);
227234
}
228235

229-
if (BLK_DEF_MAX_SECTORS > max_sectors)
230-
q->limits.max_hw_sectors = q->limits.max_sectors = max_sectors;
231-
else {
232-
q->limits.max_sectors = BLK_DEF_MAX_SECTORS;
233-
q->limits.max_hw_sectors = max_sectors;
234-
}
236+
q->limits.max_hw_sectors = max_hw_sectors;
237+
q->limits.max_sectors = min_t(unsigned int, max_hw_sectors,
238+
BLK_DEF_MAX_SECTORS);
235239
}
236240
EXPORT_SYMBOL(blk_queue_max_sectors);
237241

0 commit comments

Comments
 (0)