All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: don't flush pagecache when expanding block device
@ 2018-03-16  6:55 shunki-fujita
  2018-03-16 22:22 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: shunki-fujita @ 2018-03-16  6:55 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel; +Cc: viro, akpm, shunki-fujita

When changing the size of a block device, its all caches are freed.
It's necessary on shrinking to prevent spurious I/Os to the disappeared region.
However, on expanding, such kind of I/Os doesn't happen.

Similar things can be considered for btrfs filesystem resize and resize2fs,
but they are designed not to cache drops when expanding.
Therefore this patch removes unnecessary cache drop.

Signed-off-by: Shunki Fujita <shunki-fujita@cybozu.co.jp>
---
 fs/block_dev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index fe09ef9..243f4002 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1337,7 +1337,14 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev)
 		       "%s: detected capacity change from %lld to %lld\n",
 		       disk->disk_name, bdev_size, disk_size);
 		i_size_write(bdev->bd_inode, disk_size);
-		flush_disk(bdev, false);
+		if (bdev_size > disk_size) {
+			flush_disk(bdev, false);
+		} else {
+			if (!bdev->bd_disk)
+				return;
+			if (disk_part_scan_enabled(bdev->bd_disk))
+				bdev->bd_invalidated = 1;
+		}
 	}
 }
 EXPORT_SYMBOL(check_disk_size_change);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-19 11:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-16  6:55 [PATCH] fs: don't flush pagecache when expanding block device shunki-fujita
2018-03-16 22:22 ` Andrew Morton
2018-03-19 10:52 ` Shunki Fujita
2018-03-19 11:00 ` [PATCH v2] " shunki-fujita

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.