aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2015-01-20 20:06:30 -0500
committerJens Axboe <axboe@fb.com>2015-01-21 12:41:46 -0500
commitd93ba7a5a97c9f315bacdcdb8de4e5f368e7b396 (patch)
tree08ed637d3982f9c87e5334d42e2f7a3670867876 /include/linux/blkdev.h
parentc6ce194325cef342313e3d27620411ce90a89c50 (diff)
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 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e9086be6d9a0..4c4b732d7556 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1162,7 +1162,7 @@ extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
1162extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, 1162extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
1163 sector_t nr_sects, gfp_t gfp_mask, struct page *page); 1163 sector_t nr_sects, gfp_t gfp_mask, struct page *page);
1164extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, 1164extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
1165 sector_t nr_sects, gfp_t gfp_mask); 1165 sector_t nr_sects, gfp_t gfp_mask, bool discard);
1166static inline int sb_issue_discard(struct super_block *sb, sector_t block, 1166static inline int sb_issue_discard(struct super_block *sb, sector_t block,
1167 sector_t nr_blocks, gfp_t gfp_mask, unsigned long flags) 1167 sector_t nr_blocks, gfp_t gfp_mask, unsigned long flags)
1168{ 1168{
@@ -1176,7 +1176,7 @@ static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
1176 return blkdev_issue_zeroout(sb->s_bdev, 1176 return blkdev_issue_zeroout(sb->s_bdev,
1177 block << (sb->s_blocksize_bits - 9), 1177 block << (sb->s_blocksize_bits - 9),
1178 nr_blocks << (sb->s_blocksize_bits - 9), 1178 nr_blocks << (sb->s_blocksize_bits - 9),
1179 gfp_mask); 1179 gfp_mask, true);
1180} 1180}
1181 1181
1182extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 1182extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);