소스 검색

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>
Chris Mason 13 년 전
부모
커밋
3c4bb26b21
2개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      fs/btrfs/disk-io.c
  2. 3 0
      fs/btrfs/volumes.c

+ 1 - 0
fs/btrfs/disk-io.c

@@ -2031,6 +2031,7 @@ int open_ctree(struct super_block *sb,
 	__setup_root(4096, 4096, 4096, 4096, tree_root,
 	__setup_root(4096, 4096, 4096, 4096, tree_root,
 		     fs_info, BTRFS_ROOT_TREE_OBJECTID);
 		     fs_info, BTRFS_ROOT_TREE_OBJECTID);
 
 
+	invalidate_bdev(fs_devices->latest_bdev);
 	bh = btrfs_read_dev_super(fs_devices->latest_bdev);
 	bh = btrfs_read_dev_super(fs_devices->latest_bdev);
 	if (!bh) {
 	if (!bh) {
 		err = -EINVAL;
 		err = -EINVAL;

+ 3 - 0
fs/btrfs/volumes.c

@@ -622,6 +622,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
 			printk(KERN_INFO "open %s failed\n", device->name);
 			printk(KERN_INFO "open %s failed\n", device->name);
 			goto error;
 			goto error;
 		}
 		}
+		filemap_write_and_wait(bdev->bd_inode->i_mapping);
+		invalidate_bdev(bdev);
 		set_blocksize(bdev, 4096);
 		set_blocksize(bdev, 4096);
 
 
 		bh = btrfs_read_dev_super(bdev);
 		bh = btrfs_read_dev_super(bdev);
@@ -1354,6 +1356,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 		}
 		}
 
 
 		set_blocksize(bdev, 4096);
 		set_blocksize(bdev, 4096);
+		invalidate_bdev(bdev);
 		bh = btrfs_read_dev_super(bdev);
 		bh = btrfs_read_dev_super(bdev);
 		if (!bh) {
 		if (!bh) {
 			ret = -EINVAL;
 			ret = -EINVAL;