diff options
author | Dave Young <hidave.darkstar@gmail.com> | 2011-01-08 05:09:13 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-01-16 11:30:19 -0500 |
commit | 20b450773d17e325190c158e10bfdb25dc21d2d6 (patch) | |
tree | c99c3d8cedbf8fb5f01ed42d7d3c5b5bd5fd9d69 | |
parent | 42838bb265b9cff3de9587fcacc398b5112dc2d9 (diff) |
btrfs: mount failure return value fix
I happened to pass swap partition as root partition in cmdline,
then kernel panic and tell me about "Cannot open root device".
It is not correct, in fact it is a fs type mismatch instead of 'no device'.
Eventually I found btrfs mounting failed with -EIO, it should be -EINVAL.
The logic in init/do_mounts.c:
for (p = fs_names; *p; p += strlen(p)+1) {
int err = do_mount_root(name, p, flags, root_mount_data);
switch (err) {
case 0:
goto out;
case -EACCES:
flags |= MS_RDONLY;
goto retry;
case -EINVAL:
continue;
}
print "Cannot open root device"
panic
}
SO fs type after btrfs will have no chance to mount
Here fix the return value as -EINVAL
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r-- | fs/btrfs/disk-io.c | 4 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f88eb2ce7919..f9efb68fc2e3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1713,8 +1713,10 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1713 | fs_info, BTRFS_ROOT_TREE_OBJECTID); | 1713 | fs_info, BTRFS_ROOT_TREE_OBJECTID); |
1714 | 1714 | ||
1715 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); | 1715 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); |
1716 | if (!bh) | 1716 | if (!bh) { |
1717 | err = -EINVAL; | ||
1717 | goto fail_iput; | 1718 | goto fail_iput; |
1719 | } | ||
1718 | 1720 | ||
1719 | memcpy(&fs_info->super_copy, bh->b_data, sizeof(fs_info->super_copy)); | 1721 | memcpy(&fs_info->super_copy, bh->b_data, sizeof(fs_info->super_copy)); |
1720 | memcpy(&fs_info->super_for_commit, &fs_info->super_copy, | 1722 | memcpy(&fs_info->super_for_commit, &fs_info->super_copy, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0c7f478cf645..e8be478178aa 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -600,8 +600,10 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
600 | set_blocksize(bdev, 4096); | 600 | set_blocksize(bdev, 4096); |
601 | 601 | ||
602 | bh = btrfs_read_dev_super(bdev); | 602 | bh = btrfs_read_dev_super(bdev); |
603 | if (!bh) | 603 | if (!bh) { |
604 | ret = -EINVAL; | ||
604 | goto error_close; | 605 | goto error_close; |
606 | } | ||
605 | 607 | ||
606 | disk_super = (struct btrfs_super_block *)bh->b_data; | 608 | disk_super = (struct btrfs_super_block *)bh->b_data; |
607 | devid = btrfs_stack_device_id(&disk_super->dev_item); | 609 | devid = btrfs_stack_device_id(&disk_super->dev_item); |
@@ -702,7 +704,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
702 | goto error_close; | 704 | goto error_close; |
703 | bh = btrfs_read_dev_super(bdev); | 705 | bh = btrfs_read_dev_super(bdev); |
704 | if (!bh) { | 706 | if (!bh) { |
705 | ret = -EIO; | 707 | ret = -EINVAL; |
706 | goto error_close; | 708 | goto error_close; |
707 | } | 709 | } |
708 | disk_super = (struct btrfs_super_block *)bh->b_data; | 710 | disk_super = (struct btrfs_super_block *)bh->b_data; |
@@ -1302,7 +1304,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1302 | set_blocksize(bdev, 4096); | 1304 | set_blocksize(bdev, 4096); |
1303 | bh = btrfs_read_dev_super(bdev); | 1305 | bh = btrfs_read_dev_super(bdev); |
1304 | if (!bh) { | 1306 | if (!bh) { |
1305 | ret = -EIO; | 1307 | ret = -EINVAL; |
1306 | goto error_close; | 1308 | goto error_close; |
1307 | } | 1309 | } |
1308 | disk_super = (struct btrfs_super_block *)bh->b_data; | 1310 | disk_super = (struct btrfs_super_block *)bh->b_data; |