alistair23-linux/fs/btrfs
Misono, Tomohiro 312c89fbca btrfs: cleanup btrfs_mount() using btrfs_mount_root()
Cleanup btrfs_mount() by using btrfs_mount_root(). This avoids getting
btrfs_mount() called twice in mount path.

Old btrfs_mount() will do:
0. VFS layer calls vfs_kern_mount() with registered file_system_type
   (for btrfs, btrfs_fs_type). btrfs_mount() is called on the way.
1. btrfs_parse_early_options() parses "subvolid=" mount option and set the
   value to subvol_objectid. Otherwise, subvol_objectid has the initial
   value of 0
2. check subvol_objectid is 5 or not. Assume this time id is not 5, then
   btrfs_mount() returns by calling mount_subvol()
3. In mount_subvol(), original mount options are modified to contain
   "subvolid=0" in setup_root_args(). Then, vfs_kern_mount() is called with
   btrfs_fs_type and new options
4. btrfs_mount() is called again
5. btrfs_parse_early_options() parses "subvolid=0" and set 5 (instead of 0)
   to subvol_objectid
6. check subvol_objectid is 5 or not. This time id is 5 and mount_subvol()
   is not called. btrfs_mount() finishes mounting a root
7. (in mount_subvol()) with using a return vale of vfs_kern_mount(), it
   calls mount_subtree()
8. return subvolume's dentry

Reusing the same file_system_type (and btrfs_mount()) for vfs_kern_mount()
is the cause of complication.

Instead, new btrfs_mount() will do:
1. parse subvol id related options for later use in mount_subvol()
2. mount device's root by calling vfs_kern_mount() with
   btrfs_root_fs_type, which is not registered to VFS by
   register_filesystem(). As a result, btrfs_mount_root() is called
3. return by calling mount_subvol()

The code of 2. is moved from the first part of mount_subvol().

The semantics of device holder changes from btrfs_fs_type to
btrfs_root_fs_type and has to be used in all contexts. Otherwise we'd
get wrong results when mount and dev scan would not check the same
thing. (this has been found indendently and the fix is folded into this
patch)

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ fold the btrfs_control_ioctl fixup, extend the comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22 16:08:18 +01:00
..
tests btrfs: Remove redundant FLAG_VACANCY 2018-01-22 16:08:14 +01:00
acl.c btrfs: preserve i_mode if __btrfs_set_acl() fails 2017-08-21 17:47:42 +02:00
async-thread.c Btrfs: fix confusing worker helper info in stacktrace 2017-10-30 12:27:57 +01:00
async-thread.h
backref.c btrfs: make function update_share_count static 2018-01-22 16:08:14 +01:00
backref.h btrfs: add a flag to iterate_inodes_from_logical to find all extent refs for uncompressed extents 2017-11-01 20:45:34 +01:00
btrfs_inode.h btrfs: make the delalloc block rsv per inode 2017-11-01 20:45:35 +01:00
check-integrity.c btrfs: Fix bug for misused dev_t when lookup in dev state hash table. 2017-11-01 20:45:36 +01:00
check-integrity.h
compression.c btrfs: compression: add helper for type to string conversion 2018-01-22 16:08:16 +01:00
compression.h btrfs: compression: add helper for type to string conversion 2018-01-22 16:08:16 +01:00
ctree.c btrfs: Rename bin_search -> btrfs_bin_search 2018-01-22 16:08:18 +01:00
ctree.h btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
dedupe.h
delayed-inode.c btrfs: Move checks from btrfs_wq_run_delayed_node to btrfs_balance_delayed_items 2018-01-22 16:08:11 +01:00
delayed-inode.h
delayed-ref.c Btrfs: add __init macro to btrfs init functions 2018-01-22 16:08:11 +01:00
delayed-ref.h Btrfs: add __init macro to btrfs init functions 2018-01-22 16:08:11 +01:00
dev-replace.c btrfs: cleanup device states define BTRFS_DEV_STATE_REPLACE_TGT 2018-01-22 16:08:15 +01:00
dev-replace.h
dir-item.c btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
disk-io.c btrfs: cleanup device states define BTRFS_DEV_STATE_FLUSH_SENT 2018-01-22 16:08:15 +01:00
disk-io.h btrfs: sink get_extent parameter to read_extent_buffer_pages 2018-01-22 16:08:13 +01:00
export.c btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
export.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extent-tree.c btrfs: cleanup device states define BTRFS_DEV_STATE_REPLACE_TGT 2018-01-22 16:08:15 +01:00
extent_io.c btrfs: unify extent_page_data type passed as void 2018-01-22 16:08:18 +01:00
extent_io.h btrfs: sink extent_write_full_page tree argument 2018-01-22 16:08:16 +01:00
extent_map.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extent_map.h btrfs: Remove redundant FLAG_VACANCY 2018-01-22 16:08:14 +01:00
file-item.c
file.c Btrfs: set plug for fsync 2018-01-22 16:08:13 +01:00
free-space-cache.c btrfs: sink gfp parameter to clear_extent_bit 2018-01-22 16:08:12 +01:00
free-space-cache.h
free-space-tree.c btrfs: Clean up unused variables in free-space-tree.c 2017-10-30 12:27:59 +01:00
free-space-tree.h
hash.c
hash.h
inode-item.c
inode-map.c Btrfs: rework outstanding_extents 2017-11-01 20:45:35 +01:00
inode-map.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
inode.c btrfs: sink extent_write_full_page tree argument 2018-01-22 16:08:16 +01:00
ioctl.c btrfs: SETFLAGS ioctl: use helper for compression type conversion 2018-01-22 16:08:16 +01:00
Kconfig Btrfs: add a extent ref verify tool 2017-10-30 12:28:00 +01:00
locking.c
locking.h
lzo.c btrfs: allow to set compression level for zlib 2017-11-01 20:45:29 +01:00
Makefile Merge branch 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux 2017-11-14 13:35:29 -08:00
math.h
ordered-data.c Btrfs: rework outstanding_extents 2017-11-01 20:45:35 +01:00
ordered-data.h
orphan.c
print-tree.c Btrfs: add one more sanity check for shared ref type 2017-08-21 17:47:43 +02:00
print-tree.h
props.c btrfs: prop: use common helper for type to string conversion 2018-01-22 16:08:16 +01:00
props.h
qgroup.c btrfs: sink gfp parameter to clear_extent_bit 2018-01-22 16:08:12 +01:00
qgroup.h
raid56.c Btrfs: remove unused variable wait in lock_stripe_add 2018-01-22 16:08:15 +01:00
raid56.h
rcu-string.h
reada.c
ref-verify.c btrfs: ref-verify: Remove unused parameter from walk_up_tree() to kill warning 2018-01-22 16:08:13 +01:00
ref-verify.h Btrfs: add a extent ref verify tool 2017-10-30 12:28:00 +01:00
relocation.c Btrfs: fix reported number of inode blocks after buffered append writes 2017-11-15 17:27:46 +01:00
root-tree.c btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
scrub.c Btrfs: use struct completion in scrub_submit_raid56_bio_wait 2018-01-22 16:08:15 +01:00
send.c btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
send.h btrfs: fix send ioctl on 32bit with 64bit kernel 2017-10-30 12:27:59 +01:00
struct-funcs.c
super.c btrfs: cleanup btrfs_mount() using btrfs_mount_root() 2018-01-22 16:08:18 +01:00
sysfs.c Btrfs: add __init macro to btrfs init functions 2018-01-22 16:08:11 +01:00
sysfs.h Merge branch 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux 2017-11-14 13:35:29 -08:00
transaction.c btrfs: switch to refcount_t type for btrfs_trans_handle::use_count 2018-01-22 16:08:14 +01:00
transaction.h btrfs: reorder btrfs_transaction members for better packing 2018-01-22 16:08:14 +01:00
tree-checker.c btrfs: tree-checker: use %zu format string for size_t 2018-01-22 16:08:15 +01:00
tree-checker.h btrfs: tree-checker: Fix false panic for sanity test 2017-11-28 14:59:09 +01:00
tree-defrag.c
tree-log.c btrfs: btrfs_inode_log_parent should use defined inode_only values. 2018-01-22 16:08:14 +01:00
tree-log.h
ulist.c
ulist.h
uuid-tree.c
volumes.c btrfs: Remove pair of bio_get/put in btrfs_schedule_bio 2018-01-22 16:08:16 +01:00
volumes.h btrfs: cleanup device states define BTRFS_DEV_STATE_FLUSH_SENT 2018-01-22 16:08:15 +01:00
xattr.c btrfs: Cleanup existing name_len checks 2018-01-22 16:08:12 +01:00
xattr.h
zlib.c btrfs: allow to set compression level for zlib 2017-11-01 20:45:29 +01:00
zstd.c btrfs: move some zstd work data from stack to workspace 2018-01-22 16:08:14 +01:00