History

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.

Martin K. Petersen committed 17 years ago

Commit e475bba1 parent 69237152 files · +28 −6Browse files

Unified · Split

2 files
  1. block/blk-settings.c +27 −6
  2. include/linux/blkdev.h +1 −0
block/blk-settings.c+27−6
@@ -95,6 +95,31 @@ void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn) · 94 unmodified lines
95}95}
96EXPORT_SYMBOL_GPL(blk_queue_lld_busy);96EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
97 97
98/**
99 * blk_set_default_limits - reset limits to default values
100 * @limits: the queue_limits structure to reset
101 *
102 * Description:
103 * Returns a queue_limit struct to its default state. Can be used by
104 * stacking drivers like DM that stage table swaps and reuse an
105 * existing device queue.
106 */
107void blk_set_default_limits(struct queue_limits *lim)
108{
109 lim->max_phys_segments = MAX_PHYS_SEGMENTS;
110 lim->max_hw_segments = MAX_HW_SEGMENTS;
111 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
112 lim->max_segment_size = MAX_SEGMENT_SIZE;
113 lim->max_sectors = lim->max_hw_sectors = SAFE_MAX_SECTORS;
114 lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
115 lim->bounce_pfn = BLK_BOUNCE_ANY;
116 lim->alignment_offset = 0;
117 lim->io_opt = 0;
118 lim->misaligned = 0;
119 lim->no_cluster = 0;
120}
121EXPORT_SYMBOL(blk_set_default_limits);
122
98/**123/**
99 * blk_queue_make_request - define an alternate make_request function for a device124 * blk_queue_make_request - define an alternate make_request function for a device
100 * @q: the request queue for the device to be affected125 * @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) · 22 unmodified lines
123 * set defaults148 * set defaults
124 */149 */
125 q->nr_requests = BLKDEV_MAX_RQ;150 q->nr_requests = BLKDEV_MAX_RQ;
126 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
127 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
128 blk_queue_segment_boundary(q, BLK_SEG_BOUNDARY_MASK);
129 blk_queue_max_segment_size(q, MAX_SEGMENT_SIZE);
130 151
131 q->make_request_fn = mfn;152 q->make_request_fn = mfn;
132 blk_queue_max_sectors(q, SAFE_MAX_SECTORS);
133 blk_queue_logical_block_size(q, 512);
134 blk_queue_dma_alignment(q, 511);153 blk_queue_dma_alignment(q, 511);
135 blk_queue_congestion_threshold(q);154 blk_queue_congestion_threshold(q);
136 q->nr_batching = BLK_BATCH_REQ;155 q->nr_batching = BLK_BATCH_REQ;
@@ -143,6 +162,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn) · 6 unmodified lines
143 q->unplug_timer.function = blk_unplug_timeout;162 q->unplug_timer.function = blk_unplug_timeout;
144 q->unplug_timer.data = (unsigned long)q;163 q->unplug_timer.data = (unsigned long)q;
145 164
165 blk_set_default_limits(&q->limits);
166
146 /*167 /*
147 * by default assume old behaviour and bounce for any highmem page168 * by default assume old behaviour and bounce for any highmem page
148 */169 */
include/linux/blkdev.h+1−0
@@ -926,6 +926,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q, · 925 unmodified lines
926 unsigned int alignment);926 unsigned int alignment);
927extern void blk_queue_io_min(struct request_queue *q, unsigned int min);927extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
928extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);928extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
929extern void blk_set_default_limits(struct queue_limits *lim);
929extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,930extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
930 sector_t offset);931 sector_t offset);
931extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,932extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,