diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2012-09-18 12:19:27 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-09-20 08:31:45 -0400 |
commit | 4363ac7c13a9a4b763c6e8d9fdbfc2468f3b8ca4 (patch) | |
tree | 010b05699eb9544b9cdfe5e1b3affdaea80132e7 /block/blk-merge.c | |
parent | f31dc1cd490539e2b62a126bc4dc2495b165d772 (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-merge.c')
-rw-r--r-- | block/blk-merge.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index 642b862608a1..936a110de0b9 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -419,6 +419,10 @@ static int attempt_merge(struct request_queue *q, struct request *req, | |||
419 | || next->special) | 419 | || next->special) |
420 | return 0; | 420 | return 0; |
421 | 421 | ||
422 | if (req->cmd_flags & REQ_WRITE_SAME && | ||
423 | !blk_write_same_mergeable(req->bio, next->bio)) | ||
424 | return 0; | ||
425 | |||
422 | /* | 426 | /* |
423 | * If we are allowed to merge, then append bio list | 427 | * If we are allowed to merge, then append bio list |
424 | * from next to rq and release next. merge_requests_fn | 428 | * from next to rq and release next. merge_requests_fn |
@@ -518,6 +522,11 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) | |||
518 | if (bio_integrity(bio) != blk_integrity_rq(rq)) | 522 | if (bio_integrity(bio) != blk_integrity_rq(rq)) |
519 | return false; | 523 | return false; |
520 | 524 | ||
525 | /* must be using the same buffer */ | ||
526 | if (rq->cmd_flags & REQ_WRITE_SAME && | ||
527 | !blk_write_same_mergeable(rq->bio, bio)) | ||
528 | return false; | ||
529 | |||
521 | return true; | 530 | return true; |
522 | } | 531 | } |
523 | 532 | ||