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.
Unified · Split
| @@ -95,6 +95,31 @@ void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn) · 94 unmodified lines | ||
| 95 | 95 | } |
| 96 | 96 | EXPORT_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 | + */ | |
| 107 | +void 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 | +} | |
| 121 | +EXPORT_SYMBOL(blk_set_default_limits); | |
| 122 | + | |
| 98 | 123 | /** |
| 99 | 124 | * blk_queue_make_request - define an alternate make_request function for a device |
| 100 | 125 | * @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 | 148 | * set defaults |
| 124 | 149 | */ |
| 125 | 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 | 152 | q->make_request_fn = mfn; |
| 132 | − blk_queue_max_sectors(q, SAFE_MAX_SECTORS); | |
| 133 | − blk_queue_logical_block_size(q, 512); | |
| 134 | 153 | blk_queue_dma_alignment(q, 511); |
| 135 | 154 | blk_queue_congestion_threshold(q); |
| 136 | 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 | 162 | q->unplug_timer.function = blk_unplug_timeout; |
| 144 | 163 | q->unplug_timer.data = (unsigned long)q; |
| 145 | 164 | |
| 165 | + blk_set_default_limits(&q->limits); | |
| 166 | + | |
| 146 | 167 | /* |
| 147 | 168 | * by default assume old behaviour and bounce for any highmem page |
| 148 | 169 | */ |
| @@ -926,6 +926,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q, · 925 unmodified lines | ||
| 926 | 926 | unsigned int alignment); |
| 927 | 927 | extern void blk_queue_io_min(struct request_queue *q, unsigned int min); |
| 928 | 928 | extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); |
| 929 | +extern void blk_set_default_limits(struct queue_limits *lim); | |
| 929 | 930 | extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, |
| 930 | 931 | sector_t offset); |
| 931 | 932 | extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, |