On Tue, Nov 25, 2014 at 04:20:11PM +0800, Wang Shilong wrote:
> Steps to reproduce:
>  # mkfs.btrfs -f /dev/sdb
>  # mount -t btrfs /dev/sdb /mnt
>  # btrfs sub create /mnt/dir
>  # mount -t btrfs /dev/sdb /mnt -o subvol=dir,subvol=dir
> 
> It fails with:
>  mount: mount(2) failed: No such file or directory

The bug is real, but I don't like the fix. The mount path is hard to
read already, and I'm afraid your fix adds another unobvious step to the
whole processing.

setup_root_args replaces subvol= with subvolid=0 once. I suggest to
replace all occurences of subvol= here and not rely on the recursive
behaviour of the mount callbacks.

The (buggy) way how it works now is that the first occurence of subvol
will get parsed and passed as

newroot = vfs_kern_mount(",subvol=second,...,subvolid=0")

and this will call back again to btrfs_mount and will try to mount the
subvol 'second' but now relative to 'newroot'.

Try this:

# mkfs.btrfs -f /dev/sdb
# mount -t btrfs /dev/sdb /mnt
# btrfs sub create /mnt/dir
# btrfs sub create /mnt/dir/dir2
# mount -t btrfs /dev/sdb /mnt -o subvol=dir,subvol=dir2

mount succeeds and the mounted subvolume is dir2.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to