Qu Wenruo
2014-Jul-16 04:07 UTC
[PATCH 0/2] btrfs: allow findmnt(8) to find which subvol of btrfs is
Before this patchset, btrfs has 2 different routine to handle subvolume mount: 1) "subvol=" routine When subvol name is given by "subvol=" mount option, btrfs will mount the fs and then use mount_subtree() to mount the subvolume. This routine is good since vfs layer is aware of which subtree is mounted. So findmnt(8) can show the source subvol of a btrfs mount. 2) "subvolid=" and default subvolume routine When "subvolid=" or mounting default subvolume, btrfs will call get_default_root() to find subvolid or default subvolume. The problem is that, all the subvol searching are done internally, vfs is unaware of the return dentry is just a subtree. So findmnt(8) can't show the source subvol of a btrfs mount. This patchset will merge all this routine into 1) "subvol=" routine and make findmnt(8) able to show source subvol of a btrfs mount. After the patchset, btrfs will: 1) mount fs root under all situation first. If user gives "subvolid=5" mount option, then the mount is done. Or mount continues. 2) If no subvolume id or name is given, do default subvolume search. 3) If subvolume id is given(or searched by 2), do backref walk. Search backref in tree root to generate the subvolume path. 4) call mount_subtree() Whatever the subvolume path is generated by backref walk or just given by "subvol=" mount option, just call mount_subtree() to finish the mount. Qu Wenruo (2): btrfs: Call mount_subtree() even 'subvolid=' mount option is given. btrfs: Merge default subvolume mount codes into btrfs_mount_subvol(). fs/btrfs/super.c | 324 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 250 insertions(+), 74 deletions(-) -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html