aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-settings.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2012-09-18 12:19:27 -0400
committerJens Axboe <axboe@kernel.dk>2012-09-20 08:31:45 -0400
commit4363ac7c13a9a4b763c6e8d9fdbfc2468f3b8ca4 (patch)
tree010b05699eb9544b9cdfe5e1b3affdaea80132e7 /block/blk-settings.c
parentf31dc1cd490539e2b62a126bc4dc2495b165d772 (diff)
block: Implement support for WRITE SAME
The WRITE SAME command supported on some SCSI devices allows the same block to be efficiently replicated throughout a block range. Only a single logical block is transferred from the host and the storage device writes the same data to all blocks described by the I/O. This patch implements support for WRITE SAME in the block layer. The blkdev_issue_write_same() function can be used by filesystems and block drivers to replicate a buffer across a block range. This can be used to efficiently initialize software RAID devices, etc. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-settings.c')
-rw-r--r--block/blk-settings.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 565a6786032f..779bb7646bcd 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -113,6 +113,7 @@ void blk_set_default_limits(struct queue_limits *lim)
113 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK; 113 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
114 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE; 114 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
115 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS; 115 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
116 lim->max_write_same_sectors = 0;
116 lim->max_discard_sectors = 0; 117 lim->max_discard_sectors = 0;
117 lim->discard_granularity = 0; 118 lim->discard_granularity = 0;
118 lim->discard_alignment = 0; 119 lim->discard_alignment = 0;
@@ -144,6 +145,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
144 lim->max_segments = USHRT_MAX; 145 lim->max_segments = USHRT_MAX;
145 lim->max_hw_sectors = UINT_MAX; 146 lim->max_hw_sectors = UINT_MAX;
146 lim->max_sectors = UINT_MAX; 147 lim->max_sectors = UINT_MAX;
148 lim->max_write_same_sectors = UINT_MAX;
147} 149}
148EXPORT_SYMBOL(blk_set_stacking_limits); 150EXPORT_SYMBOL(blk_set_stacking_limits);
149 151
@@ -286,6 +288,18 @@ void blk_queue_max_discard_sectors(struct request_queue *q,
286EXPORT_SYMBOL(blk_queue_max_discard_sectors); 288EXPORT_SYMBOL(blk_queue_max_discard_sectors);
287 289
288/** 290/**
291 * blk_queue_max_write_same_sectors - set max sectors for a single write same
292 * @q: the request queue for the device
293 * @max_write_same_sectors: maximum number of sectors to write per command
294 **/
295void blk_queue_max_write_same_sectors(struct request_queue *q,
296 unsigned int max_write_same_sectors)
297{
298 q->limits.max_write_same_sectors = max_write_same_sectors;
299}
300EXPORT_SYMBOL(blk_queue_max_write_same_sectors);
301
302/**
289 * blk_queue_max_segments - set max hw segments for a request for this queue 303 * blk_queue_max_segments - set max hw segments for a request for this queue
290 * @q: the request queue for the device 304 * @q: the request queue for the device
291 * @max_segments: max number of segments 305 * @max_segments: max number of segments
@@ -510,6 +524,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
510 524
511 t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors); 525 t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
512 t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors); 526 t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
527 t->max_write_same_sectors = min(t->max_write_same_sectors,
528 b->max_write_same_sectors);
513 t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn); 529 t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn);
514 530
515 t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask, 531 t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask,