lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1521457240-153390-1-git-send-email-shunki-fujita@cybozu.co.jp>
Date:   Mon, 19 Mar 2018 20:00:40 +0900
From:   shunki-fujita <shunki-fujita@...ozu.co.jp>
To:     akpm@...ux-foundation.org
Cc:     linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        viro@...iv.linux.org.uk, axboe@...nel.dk,
        shunki-fujita@...ozu.co.jp
Subject: [PATCH v2] fs: don't flush pagecache when expanding block device

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@...ozu.co.jp>
---
Changes in v2:
   - Remove unnecessary changes (Since bdev-> bd_invalidated always 0 after check_disk_size_change ()[1])
   - Add document of check_disk_size_change ()

   [1] https://github.com/torvalds/linux/blob/master/fs/block_dev.c#L1365-L1366

 fs/block_dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index fe09ef9..63f1269 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1324,7 +1324,8 @@ static void flush_disk(struct block_device *bdev, bool kill_dirty)
  * @bdev: struct bdev to adjust.
  *
  * This routine checks to see if the bdev size does not match the disk size
- * and adjusts it if it differs.
+ * and adjusts it if it differs. When shrinking the bdev size, its all caches 
+ * are freed.
  */
 void check_disk_size_change(struct gendisk *disk, struct block_device *bdev)
 {
@@ -1337,7 +1338,8 @@ 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);
 	}
 }
 EXPORT_SYMBOL(check_disk_size_change);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ