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
9595 }
9696 EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
9797
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+
98123 /**
99124 * blk_queue_make_request - define an alternate make_request function for a device
100125 * @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
123148 * set defaults
124149 */
125150 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);
130151
131152 q->make_request_fn = mfn;
132− blk_queue_max_sectors(q, SAFE_MAX_SECTORS);
133− blk_queue_logical_block_size(q, 512);
134153 blk_queue_dma_alignment(q, 511);
135154 blk_queue_congestion_threshold(q);
136155 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
143162 q->unplug_timer.function = blk_unplug_timeout;
144163 q->unplug_timer.data = (unsigned long)q;
145164
165+ blk_set_default_limits(&q->limits);
166+
146167 /*
147168 * by default assume old behaviour and bounce for any highmem page
148169 */
include/linux/blkdev.h+1−0
@@ -926,6 +926,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q, · 925 unmodified lines
926926 unsigned int alignment);
927927 extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
928928 extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
929+extern void blk_set_default_limits(struct queue_limits *lim);
929930 extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
930931 sector_t offset);
931932 extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,