Skip to content

Commit

Permalink
block: Update blk_queue_max_sectors and documentation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Martin K. Petersen authored and Jens Axboe committed Feb 26, 2010
1 parent 024f906 commit 2800aac
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions block/blk-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,30 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
/**
* blk_queue_max_sectors - set max sectors for a request for this queue
* @q: the request queue for the device
* @max_sectors: max sectors in the usual 512b unit
* @max_hw_sectors: max hardware sectors in the usual 512b unit
*
* Description:
* Enables a low level driver to set an upper limit on the size of
* received requests.
* Enables a low level driver to set a hard upper limit,
* max_hw_sectors, on the size of requests. max_hw_sectors is set by
* the device driver based upon the combined capabilities of I/O
* controller and storage device.
*
* max_sectors is a soft limit imposed by the block layer for
* filesystem type requests. This value can be overridden on a
* per-device basis in /sys/block/<device>/queue/max_sectors_kb.
* The soft limit can not exceed max_hw_sectors.
**/
void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors)
void blk_queue_max_sectors(struct request_queue *q, unsigned int max_hw_sectors)
{
if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {
max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
printk(KERN_INFO "%s: set to minimum %d\n",
__func__, max_sectors);
__func__, max_hw_sectors);
}

if (BLK_DEF_MAX_SECTORS > max_sectors)
q->limits.max_hw_sectors = q->limits.max_sectors = max_sectors;
else {
q->limits.max_sectors = BLK_DEF_MAX_SECTORS;
q->limits.max_hw_sectors = max_sectors;
}
q->limits.max_hw_sectors = max_hw_sectors;
q->limits.max_sectors = min_t(unsigned int, max_hw_sectors,
BLK_DEF_MAX_SECTORS);
}
EXPORT_SYMBOL(blk_queue_max_sectors);

Expand Down

0 comments on commit 2800aac

Please sign in to comment.