aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-10-12 19:24:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2023-10-12 19:24:42 -0700
commit4ee22162ae5fa34ac70e4ae06330395409921c5c (patch)
tree2c9d147a6ea608fc85623c34eb65baee371c522b
parent20f4757fa5ed2d9a7746d01b8950cfe04d593a0a (diff)
parent1364a3c391aedfeb32aa025303ead3d7c91cdf9d (diff)
downloadlinux-riscv-keystone-4ee22162ae5fa34ac70e4ae06330395409921c5c.tar.gz
Merge tag 'block-6.6-2023-10-12' of git://git.kernel.dk/linux
Pull block fix from Jens Axboe: "Just a single fix for a longstanding regression with using fallocate on a block device" * tag 'block-6.6-2023-10-12' of git://git.kernel.dk/linux: block: Don't invalidate pagecache for invalid falloc modes
-rw-r--r--block/fops.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/block/fops.c b/block/fops.c
index acff3d5d22d461..73e42742543f6a 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -772,24 +772,35 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
filemap_invalidate_lock(inode->i_mapping);
- /* Invalidate the page cache, including dirty pages. */
- error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end);
- if (error)
- goto fail;
-
+ /*
+ * Invalidate the page cache, including dirty pages, for valid
+ * de-allocate mode calls to fallocate().
+ */
switch (mode) {
case FALLOC_FL_ZERO_RANGE:
case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
+ error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end);
+ if (error)
+ goto fail;
+
error = blkdev_issue_zeroout(bdev, start >> SECTOR_SHIFT,
len >> SECTOR_SHIFT, GFP_KERNEL,
BLKDEV_ZERO_NOUNMAP);
break;
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE:
+ error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end);
+ if (error)
+ goto fail;
+
error = blkdev_issue_zeroout(bdev, start >> SECTOR_SHIFT,
len >> SECTOR_SHIFT, GFP_KERNEL,
BLKDEV_ZERO_NOFALLBACK);
break;
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
+ error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end);
+ if (error)
+ goto fail;
+
error = blkdev_issue_discard(bdev, start >> SECTOR_SHIFT,
len >> SECTOR_SHIFT, GFP_KERNEL);
break;