@@ -91,7 +91,8 @@ void blk_set_default_limits(struct queue_limits *lim)
9191 lim -> seg_boundary_mask = BLK_SEG_BOUNDARY_MASK ;
9292 lim -> virt_boundary_mask = 0 ;
9393 lim -> max_segment_size = BLK_MAX_SEGMENT_SIZE ;
94- lim -> max_sectors = lim -> max_hw_sectors = BLK_SAFE_MAX_SECTORS ;
94+ lim -> max_sectors = lim -> max_dev_sectors = lim -> max_hw_sectors =
95+ BLK_SAFE_MAX_SECTORS ;
9596 lim -> chunk_sectors = 0 ;
9697 lim -> max_write_same_sectors = 0 ;
9798 lim -> max_discard_sectors = 0 ;
@@ -127,6 +128,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
127128 lim -> max_hw_sectors = UINT_MAX ;
128129 lim -> max_segment_size = UINT_MAX ;
129130 lim -> max_sectors = UINT_MAX ;
131+ lim -> max_dev_sectors = UINT_MAX ;
130132 lim -> max_write_same_sectors = UINT_MAX ;
131133}
132134EXPORT_SYMBOL (blk_set_stacking_limits );
@@ -214,8 +216,8 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr)
214216EXPORT_SYMBOL (blk_queue_bounce_limit );
215217
216218/**
217- * blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request
218- * @limits: the queue limits
219+ * blk_queue_max_hw_sectors - set max sectors for a request for this queue
220+ * @q: the request queue for the device
219221 * @max_hw_sectors: max hardware sectors in the usual 512b unit
220222 *
221223 * Description:
@@ -224,36 +226,29 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
224226 * the device driver based upon the capabilities of the I/O
225227 * controller.
226228 *
229+ * max_dev_sectors is a hard limit imposed by the storage device for
230+ * READ/WRITE requests. It is set by the disk driver.
231+ *
227232 * max_sectors is a soft limit imposed by the block layer for
228233 * filesystem type requests. This value can be overridden on a
229234 * per-device basis in /sys/block/<device>/queue/max_sectors_kb.
230235 * The soft limit can not exceed max_hw_sectors.
231236 **/
232- void blk_limits_max_hw_sectors (struct queue_limits * limits , unsigned int max_hw_sectors )
237+ void blk_queue_max_hw_sectors (struct request_queue * q , unsigned int max_hw_sectors )
233238{
239+ struct queue_limits * limits = & q -> limits ;
240+ unsigned int max_sectors ;
241+
234242 if ((max_hw_sectors << 9 ) < PAGE_CACHE_SIZE ) {
235243 max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9 );
236244 printk (KERN_INFO "%s: set to minimum %d\n" ,
237245 __func__ , max_hw_sectors );
238246 }
239247
240248 limits -> max_hw_sectors = max_hw_sectors ;
241- limits -> max_sectors = min_t (unsigned int , max_hw_sectors ,
242- BLK_DEF_MAX_SECTORS );
243- }
244- EXPORT_SYMBOL (blk_limits_max_hw_sectors );
245-
246- /**
247- * blk_queue_max_hw_sectors - set max sectors for a request for this queue
248- * @q: the request queue for the device
249- * @max_hw_sectors: max hardware sectors in the usual 512b unit
250- *
251- * Description:
252- * See description for blk_limits_max_hw_sectors().
253- **/
254- void blk_queue_max_hw_sectors (struct request_queue * q , unsigned int max_hw_sectors )
255- {
256- blk_limits_max_hw_sectors (& q -> limits , max_hw_sectors );
249+ max_sectors = min_not_zero (max_hw_sectors , limits -> max_dev_sectors );
250+ max_sectors = min_t (unsigned int , max_sectors , BLK_DEF_MAX_SECTORS );
251+ limits -> max_sectors = max_sectors ;
257252}
258253EXPORT_SYMBOL (blk_queue_max_hw_sectors );
259254
@@ -527,6 +522,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
527522
528523 t -> max_sectors = min_not_zero (t -> max_sectors , b -> max_sectors );
529524 t -> max_hw_sectors = min_not_zero (t -> max_hw_sectors , b -> max_hw_sectors );
525+ t -> max_dev_sectors = min_not_zero (t -> max_dev_sectors , b -> max_dev_sectors );
530526 t -> max_write_same_sectors = min (t -> max_write_same_sectors ,
531527 b -> max_write_same_sectors );
532528 t -> bounce_pfn = min_not_zero (t -> bounce_pfn , b -> bounce_pfn );
0 commit comments