btrfs: mount failure return value fix
authorDave Young <hidave.darkstar@gmail.com>
Sat, 8 Jan 2011 10:09:13 +0000 (10:09 +0000)
committerChris Mason <chris.mason@oracle.com>
Sun, 16 Jan 2011 16:30:19 +0000 (11:30 -0500)
commit20b450773d17e325190c158e10bfdb25dc21d2d6
treec99c3d8cedbf8fb5f01ed42d7d3c5b5bd5fd9d69
parent42838bb265b9cff3de9587fcacc398b5112dc2d9
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>
fs/btrfs/disk-io.c
fs/btrfs/volumes.c