.. | .. |
---|
33 | 33 | type = FILEID_BTRFS_WITHOUT_PARENT; |
---|
34 | 34 | |
---|
35 | 35 | fid->objectid = btrfs_ino(BTRFS_I(inode)); |
---|
36 | | - fid->root_objectid = BTRFS_I(inode)->root->objectid; |
---|
| 36 | + fid->root_objectid = BTRFS_I(inode)->root->root_key.objectid; |
---|
37 | 37 | fid->gen = inode->i_generation; |
---|
38 | 38 | |
---|
39 | 39 | if (parent) { |
---|
.. | .. |
---|
41 | 41 | |
---|
42 | 42 | fid->parent_objectid = BTRFS_I(parent)->location.objectid; |
---|
43 | 43 | fid->parent_gen = parent->i_generation; |
---|
44 | | - parent_root_id = BTRFS_I(parent)->root->objectid; |
---|
| 44 | + parent_root_id = BTRFS_I(parent)->root->root_key.objectid; |
---|
45 | 45 | |
---|
46 | 46 | if (parent_root_id != fid->root_objectid) { |
---|
47 | 47 | fid->parent_root_objectid = parent_root_id; |
---|
.. | .. |
---|
58 | 58 | } |
---|
59 | 59 | |
---|
60 | 60 | struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, |
---|
61 | | - u64 root_objectid, u32 generation, |
---|
| 61 | + u64 root_objectid, u64 generation, |
---|
62 | 62 | int check_generation) |
---|
63 | 63 | { |
---|
64 | 64 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
---|
65 | 65 | struct btrfs_root *root; |
---|
66 | 66 | struct inode *inode; |
---|
67 | | - struct btrfs_key key; |
---|
68 | | - int index; |
---|
69 | | - int err = 0; |
---|
70 | 67 | |
---|
71 | 68 | if (objectid < BTRFS_FIRST_FREE_OBJECTID) |
---|
72 | 69 | return ERR_PTR(-ESTALE); |
---|
73 | 70 | |
---|
74 | | - key.objectid = root_objectid; |
---|
75 | | - key.type = BTRFS_ROOT_ITEM_KEY; |
---|
76 | | - key.offset = (u64)-1; |
---|
| 71 | + root = btrfs_get_fs_root(fs_info, root_objectid, true); |
---|
| 72 | + if (IS_ERR(root)) |
---|
| 73 | + return ERR_CAST(root); |
---|
77 | 74 | |
---|
78 | | - index = srcu_read_lock(&fs_info->subvol_srcu); |
---|
79 | | - |
---|
80 | | - root = btrfs_read_fs_root_no_name(fs_info, &key); |
---|
81 | | - if (IS_ERR(root)) { |
---|
82 | | - err = PTR_ERR(root); |
---|
83 | | - goto fail; |
---|
84 | | - } |
---|
85 | | - |
---|
86 | | - key.objectid = objectid; |
---|
87 | | - key.type = BTRFS_INODE_ITEM_KEY; |
---|
88 | | - key.offset = 0; |
---|
89 | | - |
---|
90 | | - inode = btrfs_iget(sb, &key, root, NULL); |
---|
91 | | - if (IS_ERR(inode)) { |
---|
92 | | - err = PTR_ERR(inode); |
---|
93 | | - goto fail; |
---|
94 | | - } |
---|
95 | | - |
---|
96 | | - srcu_read_unlock(&fs_info->subvol_srcu, index); |
---|
| 75 | + inode = btrfs_iget(sb, objectid, root); |
---|
| 76 | + btrfs_put_root(root); |
---|
| 77 | + if (IS_ERR(inode)) |
---|
| 78 | + return ERR_CAST(inode); |
---|
97 | 79 | |
---|
98 | 80 | if (check_generation && generation != inode->i_generation) { |
---|
99 | 81 | iput(inode); |
---|
.. | .. |
---|
101 | 83 | } |
---|
102 | 84 | |
---|
103 | 85 | return d_obtain_alias(inode); |
---|
104 | | -fail: |
---|
105 | | - srcu_read_unlock(&fs_info->subvol_srcu, index); |
---|
106 | | - return ERR_PTR(err); |
---|
107 | 86 | } |
---|
108 | 87 | |
---|
109 | 88 | static struct dentry *btrfs_fh_to_parent(struct super_block *sb, struct fid *fh, |
---|
.. | .. |
---|
212 | 191 | found_key.offset, 0, 0); |
---|
213 | 192 | } |
---|
214 | 193 | |
---|
215 | | - key.type = BTRFS_INODE_ITEM_KEY; |
---|
216 | | - key.offset = 0; |
---|
217 | | - return d_obtain_alias(btrfs_iget(fs_info->sb, &key, root, NULL)); |
---|
| 194 | + return d_obtain_alias(btrfs_iget(fs_info->sb, key.objectid, root)); |
---|
218 | 195 | fail: |
---|
219 | 196 | btrfs_free_path(path); |
---|
220 | 197 | return ERR_PTR(ret); |
---|