]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | Subject: Call flush_disk() after detecting an online resize. |
2 | From: Andrew Patterson <andrew.patterson@hp.com> | |
3 | Date: Thu Oct 9 08:56:13 2008 +0200: | |
4 | Git: 608aeef17a91747d6303de4df5e2c2e6899a95e8 | |
5 | References: FATE#302348,FATE#303786 | |
6 | ||
7 | We call flush_disk() to make sure the buffer cache for the disk is | |
8 | flushed after a disk resize. There are two resize cases, growing and | |
9 | shrinking. Given that users can shrink/then grow a disk before | |
10 | revalidate_disk() is called, we treat the grow case identically to | |
11 | shrinking. We need to flush the buffer cache after an online shrink | |
12 | because, as James Bottomley puts it, | |
13 | ||
14 | The two use cases for shrinking I can see are | |
15 | ||
16 | 1. planned: the fs is already shrunk to within the new boundaries | |
17 | and all data is relocated, so invalidate is fine (any dirty | |
18 | buffers that might exist in the shrunk region are there only | |
19 | because they were relocated but not yet written to their | |
20 | original location). | |
21 | 2. unplanned: In this case, the fs is probably toast, so whether | |
22 | we invalidate or not isn't going to make a whole lot of | |
23 | difference; it's still going to try to read or write from | |
24 | sectors beyond the new size and get I/O errors. | |
25 | ||
26 | Immediately invalidating shrunk disks will cause errors for outstanding | |
27 | I/Os for reads/write beyond the new end of the disk to be generated | |
28 | earlier then if we waited for the normal buffer cache operation. It also | |
29 | removes a potential security hole where we might keep old data around | |
30 | from beyond the end of the shrunk disk if the disk was not invalidated. | |
31 | ||
32 | Signed-off-by: Andrew Patterson <andrew.patterson@hp.com> | |
33 | Signed-off-by: Jens Axboe <jens.axboe@oracle.com> | |
34 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
35 | --- | |
36 | fs/block_dev.c | 1 + | |
37 | 1 file changed, 1 insertion(+) | |
38 | ||
39 | --- a/fs/block_dev.c | |
40 | +++ b/fs/block_dev.c | |
41 | @@ -918,6 +918,7 @@ void check_disk_size_change(struct gendi | |
42 | "%s: detected capacity change from %lld to %lld\n", | |
43 | name, bdev_size, disk_size); | |
44 | i_size_write(bdev->bd_inode, disk_size); | |
45 | + flush_disk(bdev); | |
46 | } | |
47 | } | |
48 | EXPORT_SYMBOL(check_disk_size_change); |