提交 e475bba2 编写于 作者: M Martin K. Petersen 提交者: Jens Axboe

block: Introduce helper to reset queue limits to default values

DM reuses the request queue when swapping in a new device table
Introduce blk_set_default_limits() which can be used to reset the the
queue_limits prior to stacking devices.
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Acked-by: NAlasdair G Kergon <agk@redhat.com>
Acked-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 6923715a
...@@ -95,6 +95,31 @@ void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn) ...@@ -95,6 +95,31 @@ void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn)
} }
EXPORT_SYMBOL_GPL(blk_queue_lld_busy); EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
/**
* blk_set_default_limits - reset limits to default values
* @limits: the queue_limits structure to reset
*
* Description:
* Returns a queue_limit struct to its default state. Can be used by
* stacking drivers like DM that stage table swaps and reuse an
* existing device queue.
*/
void blk_set_default_limits(struct queue_limits *lim)
{
lim->max_phys_segments = MAX_PHYS_SEGMENTS;
lim->max_hw_segments = MAX_HW_SEGMENTS;
lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
lim->max_segment_size = MAX_SEGMENT_SIZE;
lim->max_sectors = lim->max_hw_sectors = SAFE_MAX_SECTORS;
lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
lim->bounce_pfn = BLK_BOUNCE_ANY;
lim->alignment_offset = 0;
lim->io_opt = 0;
lim->misaligned = 0;
lim->no_cluster = 0;
}
EXPORT_SYMBOL(blk_set_default_limits);
/** /**
* blk_queue_make_request - define an alternate make_request function for a device * blk_queue_make_request - define an alternate make_request function for a device
* @q: the request queue for the device to be affected * @q: the request queue for the device to be affected
...@@ -123,14 +148,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn) ...@@ -123,14 +148,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn)
* set defaults * set defaults
*/ */
q->nr_requests = BLKDEV_MAX_RQ; q->nr_requests = BLKDEV_MAX_RQ;
blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
blk_queue_segment_boundary(q, BLK_SEG_BOUNDARY_MASK);
blk_queue_max_segment_size(q, MAX_SEGMENT_SIZE);
q->make_request_fn = mfn; q->make_request_fn = mfn;
blk_queue_max_sectors(q, SAFE_MAX_SECTORS);
blk_queue_logical_block_size(q, 512);
blk_queue_dma_alignment(q, 511); blk_queue_dma_alignment(q, 511);
blk_queue_congestion_threshold(q); blk_queue_congestion_threshold(q);
q->nr_batching = BLK_BATCH_REQ; q->nr_batching = BLK_BATCH_REQ;
...@@ -143,6 +162,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn) ...@@ -143,6 +162,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn)
q->unplug_timer.function = blk_unplug_timeout; q->unplug_timer.function = blk_unplug_timeout;
q->unplug_timer.data = (unsigned long)q; q->unplug_timer.data = (unsigned long)q;
blk_set_default_limits(&q->limits);
/* /*
* by default assume old behaviour and bounce for any highmem page * by default assume old behaviour and bounce for any highmem page
*/ */
......
...@@ -926,6 +926,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q, ...@@ -926,6 +926,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q,
unsigned int alignment); unsigned int alignment);
extern void blk_queue_io_min(struct request_queue *q, unsigned int min); extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
extern void blk_set_default_limits(struct queue_limits *lim);
extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
sector_t offset); sector_t offset);
extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册