Commit 34045129 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block_dev: use blkdev_issue_zerout for hole punches

This gets us support for non-discard efficient write of zeroes (e.g. NVMe)
and prepares for removing the discard_zeroes_data flag.

Also remove a pointless discard support check, which is done in
blkdev_issue_discard already.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent cb365b96
...@@ -2069,7 +2069,6 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, ...@@ -2069,7 +2069,6 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
loff_t len) loff_t len)
{ {
struct block_device *bdev = I_BDEV(bdev_file_inode(file)); struct block_device *bdev = I_BDEV(bdev_file_inode(file));
struct request_queue *q = bdev_get_queue(bdev);
struct address_space *mapping; struct address_space *mapping;
loff_t end = start + len - 1; loff_t end = start + len - 1;
loff_t isize; loff_t isize;
...@@ -2108,15 +2107,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, ...@@ -2108,15 +2107,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
GFP_KERNEL, BLKDEV_ZERO_NOUNMAP); GFP_KERNEL, BLKDEV_ZERO_NOUNMAP);
break; break;
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE: case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE:
/* Only punch if the device can do zeroing discard. */ error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data) GFP_KERNEL, BLKDEV_ZERO_NOFALLBACK);
return -EOPNOTSUPP;
error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
GFP_KERNEL, 0);
break; break;
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE: case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
if (!blk_queue_discard(q))
return -EOPNOTSUPP;
error = blkdev_issue_discard(bdev, start >> 9, len >> 9, error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
GFP_KERNEL, 0); GFP_KERNEL, 0);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment