hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/btrfs/export.c
....@@ -33,7 +33,7 @@
3333 type = FILEID_BTRFS_WITHOUT_PARENT;
3434
3535 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;
3737 fid->gen = inode->i_generation;
3838
3939 if (parent) {
....@@ -41,7 +41,7 @@
4141
4242 fid->parent_objectid = BTRFS_I(parent)->location.objectid;
4343 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;
4545
4646 if (parent_root_id != fid->root_objectid) {
4747 fid->parent_root_objectid = parent_root_id;
....@@ -58,42 +58,24 @@
5858 }
5959
6060 struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
61
- u64 root_objectid, u32 generation,
61
+ u64 root_objectid, u64 generation,
6262 int check_generation)
6363 {
6464 struct btrfs_fs_info *fs_info = btrfs_sb(sb);
6565 struct btrfs_root *root;
6666 struct inode *inode;
67
- struct btrfs_key key;
68
- int index;
69
- int err = 0;
7067
7168 if (objectid < BTRFS_FIRST_FREE_OBJECTID)
7269 return ERR_PTR(-ESTALE);
7370
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);
7774
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);
9779
9880 if (check_generation && generation != inode->i_generation) {
9981 iput(inode);
....@@ -101,9 +83,6 @@
10183 }
10284
10385 return d_obtain_alias(inode);
104
-fail:
105
- srcu_read_unlock(&fs_info->subvol_srcu, index);
106
- return ERR_PTR(err);
10786 }
10887
10988 static struct dentry *btrfs_fh_to_parent(struct super_block *sb, struct fid *fh,
....@@ -212,9 +191,7 @@
212191 found_key.offset, 0, 0);
213192 }
214193
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));
218195 fail:
219196 btrfs_free_path(path);
220197 return ERR_PTR(ret);