diff options
author | Chris Mason <chris.mason@oracle.com> | 2012-03-27 18:56:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-03-28 20:33:58 -0400 |
commit | 3c4bb26b213e618473e486776483a5bad15ba6da (patch) | |
tree | 7a20f6ff0f6ec4dd9f0d7a51d787f2f65d89aa74 /fs/btrfs | |
parent | 98961a7e431735c791dbaaf0337029e219a5db5a (diff) |
Btrfs: flush out and clean up any block device pages during mount
Btrfs puts the filesystem metadata into its own address space, and
somehow the block device address space isn't getting onto disk properly
before a mount. The end result is that a loop of mkfs and mounting the
filesystem will sometimes find stale or incorrect data.
This commit should fix it by sprinkling fdatawrites and invalidate_bdev
calls around. This is a short term measure to make sure it is fixed.
The block devices really should be flushed and cleaned up higher in the
stack.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/disk-io.c | 1 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 7b55eee15a51..fd43f6b2f438 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2031,6 +2031,7 @@ int open_ctree(struct super_block *sb, | |||
2031 | __setup_root(4096, 4096, 4096, 4096, tree_root, | 2031 | __setup_root(4096, 4096, 4096, 4096, tree_root, |
2032 | fs_info, BTRFS_ROOT_TREE_OBJECTID); | 2032 | fs_info, BTRFS_ROOT_TREE_OBJECTID); |
2033 | 2033 | ||
2034 | invalidate_bdev(fs_devices->latest_bdev); | ||
2034 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); | 2035 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); |
2035 | if (!bh) { | 2036 | if (!bh) { |
2036 | err = -EINVAL; | 2037 | err = -EINVAL; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 68a1754fe367..a872b48be0ae 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -622,6 +622,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
622 | printk(KERN_INFO "open %s failed\n", device->name); | 622 | printk(KERN_INFO "open %s failed\n", device->name); |
623 | goto error; | 623 | goto error; |
624 | } | 624 | } |
625 | filemap_write_and_wait(bdev->bd_inode->i_mapping); | ||
626 | invalidate_bdev(bdev); | ||
625 | set_blocksize(bdev, 4096); | 627 | set_blocksize(bdev, 4096); |
626 | 628 | ||
627 | bh = btrfs_read_dev_super(bdev); | 629 | bh = btrfs_read_dev_super(bdev); |
@@ -1354,6 +1356,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1354 | } | 1356 | } |
1355 | 1357 | ||
1356 | set_blocksize(bdev, 4096); | 1358 | set_blocksize(bdev, 4096); |
1359 | invalidate_bdev(bdev); | ||
1357 | bh = btrfs_read_dev_super(bdev); | 1360 | bh = btrfs_read_dev_super(bdev); |
1358 | if (!bh) { | 1361 | if (!bh) { |
1359 | ret = -EINVAL; | 1362 | ret = -EINVAL; |