diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2015-01-20 20:06:30 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-01-21 10:41:46 -0700 |
commit | d93ba7a5a97c9f315bacdcdb8de4e5f368e7b396 (patch) | |
tree | 08ed637d3982f9c87e5334d42e2f7a3670867876 /block/ioctl.c | |
parent | c6ce194325cef342313e3d27620411ce90a89c50 (diff) | |
download | op-kernel-dev-d93ba7a5a97c9f315bacdcdb8de4e5f368e7b396.zip op-kernel-dev-d93ba7a5a97c9f315bacdcdb8de4e5f368e7b396.tar.gz |
block: Add discard flag to blkdev_issue_zeroout() function
blkdev_issue_discard() will zero a given block range. This is done by
way of explicit writing, thus provisioning or allocating the blocks on
disk.
There are use cases where the desired behavior is to zero the blocks but
unprovision them if possible. The blocks must deterministically contain
zeroes when they are subsequently read back.
This patch adds a flag to blkdev_issue_zeroout() that provides this
variant. If the discard flag is set and a block device guarantees
discard_zeroes_data we will use REQ_DISCARD to clear the block range. If
the device does not support discard_zeroes_data or if the discard
request fails we will fall back to first REQ_WRITE_SAME and then a
regular REQ_WRITE.
Also update the callers of blkdev_issue_zero() to reflect the new flag
and make sb_issue_zeroout() prefer the discard approach.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/ioctl.c')
-rw-r--r-- | block/ioctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/ioctl.c b/block/ioctl.c index 6c7bf90..7d8befd 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -198,7 +198,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, uint64_t start, if (start + len > (i_size_read(bdev->bd_inode) >> 9)) return -EINVAL; - return blkdev_issue_zeroout(bdev, start, len, GFP_KERNEL); + return blkdev_issue_zeroout(bdev, start, len, GFP_KERNEL, false); } static int put_ushort(unsigned long arg, unsigned short val) |