aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-block37
-rw-r--r--block/Kconfig11
-rw-r--r--block/blk-settings.c77
-rw-r--r--include/linux/blkdev.h1
4 files changed, 77 insertions, 49 deletions
diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block
index cbbd3e069945..5f3bedaf8e35 100644
--- a/Documentation/ABI/testing/sysfs-block
+++ b/Documentation/ABI/testing/sysfs-block
@@ -94,28 +94,37 @@ What: /sys/block/<disk>/queue/physical_block_size
94Date: May 2009 94Date: May 2009
95Contact: Martin K. Petersen <martin.petersen@oracle.com> 95Contact: Martin K. Petersen <martin.petersen@oracle.com>
96Description: 96Description:
97 This is the smallest unit the storage device can write 97 This is the smallest unit a physical storage device can
98 without resorting to read-modify-write operation. It is 98 write atomically. It is usually the same as the logical
99 usually the same as the logical block size but may be 99 block size but may be bigger. One example is SATA
100 bigger. One example is SATA drives with 4KB sectors 100 drives with 4KB sectors that expose a 512-byte logical
101 that expose a 512-byte logical block size to the 101 block size to the operating system. For stacked block
102 operating system. 102 devices the physical_block_size variable contains the
103 maximum physical_block_size of the component devices.
103 104
104What: /sys/block/<disk>/queue/minimum_io_size 105What: /sys/block/<disk>/queue/minimum_io_size
105Date: April 2009 106Date: April 2009
106Contact: Martin K. Petersen <martin.petersen@oracle.com> 107Contact: Martin K. Petersen <martin.petersen@oracle.com>
107Description: 108Description:
108 Storage devices may report a preferred minimum I/O size, 109 Storage devices may report a granularity or preferred
109 which is the smallest request the device can perform 110 minimum I/O size which is the smallest request the
110 without incurring a read-modify-write penalty. For disk 111 device can perform without incurring a performance
111 drives this is often the physical block size. For RAID 112 penalty. For disk drives this is often the physical
112 arrays it is often the stripe chunk size. 113 block size. For RAID arrays it is often the stripe
114 chunk size. A properly aligned multiple of
115 minimum_io_size is the preferred request size for
116 workloads where a high number of I/O operations is
117 desired.
113 118
114What: /sys/block/<disk>/queue/optimal_io_size 119What: /sys/block/<disk>/queue/optimal_io_size
115Date: April 2009 120Date: April 2009
116Contact: Martin K. Petersen <martin.petersen@oracle.com> 121Contact: Martin K. Petersen <martin.petersen@oracle.com>
117Description: 122Description:
118 Storage devices may report an optimal I/O size, which is 123 Storage devices may report an optimal I/O size, which is
119 the device's preferred unit of receiving I/O. This is 124 the device's preferred unit for sustained I/O. This is
120 rarely reported for disk drives. For RAID devices it is 125 rarely reported for disk drives. For RAID arrays it is
121 usually the stripe width or the internal block size. 126 usually the stripe width or the internal track size. A
127 properly aligned multiple of optimal_io_size is the
128 preferred request size for workloads where sustained
129 throughput is desired. If no optimal I/O size is
130 reported this file contains 0.
diff --git a/block/Kconfig b/block/Kconfig
index 95a86adc33a1..9be0b56eaee1 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -48,9 +48,9 @@ config LBDAF
48 If unsure, say Y. 48 If unsure, say Y.
49 49
50config BLK_DEV_BSG 50config BLK_DEV_BSG
51 bool "Block layer SG support v4 (EXPERIMENTAL)" 51 bool "Block layer SG support v4"
52 depends on EXPERIMENTAL 52 default y
53 ---help--- 53 help
54 Saying Y here will enable generic SG (SCSI generic) v4 support 54 Saying Y here will enable generic SG (SCSI generic) v4 support
55 for any block device. 55 for any block device.
56 56
@@ -60,7 +60,10 @@ config BLK_DEV_BSG
60 protocols (e.g. Task Management Functions and SMP in Serial 60 protocols (e.g. Task Management Functions and SMP in Serial
61 Attached SCSI). 61 Attached SCSI).
62 62
63 If unsure, say N. 63 This option is required by recent UDEV versions to properly
64 access device serial numbers, etc.
65
66 If unsure, say Y.
64 67
65config BLK_DEV_INTEGRITY 68config BLK_DEV_INTEGRITY
66 bool "Block layer data integrity support" 69 bool "Block layer data integrity support"
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 8a3ea3bba10d..476d87065073 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -7,6 +7,7 @@
7#include <linux/bio.h> 7#include <linux/bio.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ 9#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
10#include <linux/gcd.h>
10 11
11#include "blk.h" 12#include "blk.h"
12 13
@@ -384,8 +385,8 @@ void blk_queue_alignment_offset(struct request_queue *q, unsigned int offset)
384EXPORT_SYMBOL(blk_queue_alignment_offset); 385EXPORT_SYMBOL(blk_queue_alignment_offset);
385 386
386/** 387/**
387 * blk_queue_io_min - set minimum request size for the queue 388 * blk_limits_io_min - set minimum request size for a device
388 * @q: the request queue for the device 389 * @limits: the queue limits
389 * @min: smallest I/O size in bytes 390 * @min: smallest I/O size in bytes
390 * 391 *
391 * Description: 392 * Description:
@@ -394,15 +395,35 @@ EXPORT_SYMBOL(blk_queue_alignment_offset);
394 * smallest I/O the device can perform without incurring a performance 395 * smallest I/O the device can perform without incurring a performance
395 * penalty. 396 * penalty.
396 */ 397 */
397void blk_queue_io_min(struct request_queue *q, unsigned int min) 398void blk_limits_io_min(struct queue_limits *limits, unsigned int min)
398{ 399{
399 q->limits.io_min = min; 400 limits->io_min = min;
400 401
401 if (q->limits.io_min < q->limits.logical_block_size) 402 if (limits->io_min < limits->logical_block_size)
402 q->limits.io_min = q->limits.logical_block_size; 403 limits->io_min = limits->logical_block_size;
403 404
404 if (q->limits.io_min < q->limits.physical_block_size) 405 if (limits->io_min < limits->physical_block_size)
405 q->limits.io_min = q->limits.physical_block_size; 406 limits->io_min = limits->physical_block_size;
407}
408EXPORT_SYMBOL(blk_limits_io_min);
409
410/**
411 * blk_queue_io_min - set minimum request size for the queue
412 * @q: the request queue for the device
413 * @min: smallest I/O size in bytes
414 *
415 * Description:
416 * Storage devices may report a granularity or preferred minimum I/O
417 * size which is the smallest request the device can perform without
418 * incurring a performance penalty. For disk drives this is often the
419 * physical block size. For RAID arrays it is often the stripe chunk
420 * size. A properly aligned multiple of minimum_io_size is the
421 * preferred request size for workloads where a high number of I/O
422 * operations is desired.
423 */
424void blk_queue_io_min(struct request_queue *q, unsigned int min)
425{
426 blk_limits_io_min(&q->limits, min);
406} 427}
407EXPORT_SYMBOL(blk_queue_io_min); 428EXPORT_SYMBOL(blk_queue_io_min);
408 429
@@ -412,8 +433,12 @@ EXPORT_SYMBOL(blk_queue_io_min);
412 * @opt: optimal request size in bytes 433 * @opt: optimal request size in bytes
413 * 434 *
414 * Description: 435 * Description:
415 * Drivers can call this function to set the preferred I/O request 436 * Storage devices may report an optimal I/O size, which is the
416 * size for devices that report such a value. 437 * device's preferred unit for sustained I/O. This is rarely reported
438 * for disk drives. For RAID arrays it is usually the stripe width or
439 * the internal track size. A properly aligned multiple of
440 * optimal_io_size is the preferred request size for workloads where
441 * sustained throughput is desired.
417 */ 442 */
418void blk_queue_io_opt(struct request_queue *q, unsigned int opt) 443void blk_queue_io_opt(struct request_queue *q, unsigned int opt)
419{ 444{
@@ -433,27 +458,7 @@ EXPORT_SYMBOL(blk_queue_io_opt);
433 **/ 458 **/
434void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) 459void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
435{ 460{
436 /* zero is "infinity" */ 461 blk_stack_limits(&t->limits, &b->limits, 0);
437 t->limits.max_sectors = min_not_zero(queue_max_sectors(t),
438 queue_max_sectors(b));
439
440 t->limits.max_hw_sectors = min_not_zero(queue_max_hw_sectors(t),
441 queue_max_hw_sectors(b));
442
443 t->limits.seg_boundary_mask = min_not_zero(queue_segment_boundary(t),
444 queue_segment_boundary(b));
445
446 t->limits.max_phys_segments = min_not_zero(queue_max_phys_segments(t),
447 queue_max_phys_segments(b));
448
449 t->limits.max_hw_segments = min_not_zero(queue_max_hw_segments(t),
450 queue_max_hw_segments(b));
451
452 t->limits.max_segment_size = min_not_zero(queue_max_segment_size(t),
453 queue_max_segment_size(b));
454
455 t->limits.logical_block_size = max(queue_logical_block_size(t),
456 queue_logical_block_size(b));
457 462
458 if (!t->queue_lock) 463 if (!t->queue_lock)
459 WARN_ON_ONCE(1); 464 WARN_ON_ONCE(1);
@@ -523,6 +528,16 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
523 return -1; 528 return -1;
524 } 529 }
525 530
531 /* Find lcm() of optimal I/O size */
532 if (t->io_opt && b->io_opt)
533 t->io_opt = (t->io_opt * b->io_opt) / gcd(t->io_opt, b->io_opt);
534 else if (b->io_opt)
535 t->io_opt = b->io_opt;
536
537 /* Verify that optimal I/O size is a multiple of io_min */
538 if (t->io_min && t->io_opt % t->io_min)
539 return -1;
540
526 return 0; 541 return 0;
527} 542}
528EXPORT_SYMBOL(blk_stack_limits); 543EXPORT_SYMBOL(blk_stack_limits);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e7cb5dbf6c26..69103e053c92 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -913,6 +913,7 @@ extern void blk_queue_logical_block_size(struct request_queue *, unsigned short)
913extern void blk_queue_physical_block_size(struct request_queue *, unsigned short); 913extern void blk_queue_physical_block_size(struct request_queue *, unsigned short);
914extern void blk_queue_alignment_offset(struct request_queue *q, 914extern void blk_queue_alignment_offset(struct request_queue *q,
915 unsigned int alignment); 915 unsigned int alignment);
916extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
916extern void blk_queue_io_min(struct request_queue *q, unsigned int min); 917extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
917extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); 918extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
918extern void blk_set_default_limits(struct queue_limits *lim); 919extern void blk_set_default_limits(struct queue_limits *lim);