]> git.baikalelectronics.ru Git - kernel.git/commit
block: Add discard flag to blkdev_issue_zeroout() function
authorMartin K. Petersen <martin.petersen@oracle.com>
Wed, 21 Jan 2015 01:06:30 +0000 (20:06 -0500)
committerJens Axboe <axboe@fb.com>
Wed, 21 Jan 2015 17:41:46 +0000 (10:41 -0700)
commit61aa182ecbae10440aec0ac6275a5b15bf65c167
tree08ed637d3982f9c87e5334d42e2f7a3670867876
parentca80aca0481faf83a36b8f6eddeef7d7b571a94f
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>
block/blk-lib.c
block/ioctl.c
drivers/block/drbd/drbd_receiver.c
include/linux/blkdev.h