aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/export.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/export.c')
-rw-r--r--fs/btrfs/export.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 659f532d26a..b4ffad859ad 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -21,9 +21,13 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
21 int len = *max_len; 21 int len = *max_len;
22 int type; 22 int type;
23 23
24 if ((len < BTRFS_FID_SIZE_NON_CONNECTABLE) || 24 if (connectable && (len < BTRFS_FID_SIZE_CONNECTABLE)) {
25 (connectable && len < BTRFS_FID_SIZE_CONNECTABLE)) 25 *max_len = BTRFS_FID_SIZE_CONNECTABLE;
26 return 255; 26 return 255;
27 } else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) {
28 *max_len = BTRFS_FID_SIZE_NON_CONNECTABLE;
29 return 255;
30 }
27 31
28 len = BTRFS_FID_SIZE_NON_CONNECTABLE; 32 len = BTRFS_FID_SIZE_NON_CONNECTABLE;
29 type = FILEID_BTRFS_WITHOUT_PARENT; 33 type = FILEID_BTRFS_WITHOUT_PARENT;
@@ -65,7 +69,6 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
65{ 69{
66 struct btrfs_fs_info *fs_info = btrfs_sb(sb)->fs_info; 70 struct btrfs_fs_info *fs_info = btrfs_sb(sb)->fs_info;
67 struct btrfs_root *root; 71 struct btrfs_root *root;
68 struct dentry *dentry;
69 struct inode *inode; 72 struct inode *inode;
70 struct btrfs_key key; 73 struct btrfs_key key;
71 int index; 74 int index;
@@ -108,10 +111,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
108 return ERR_PTR(-ESTALE); 111 return ERR_PTR(-ESTALE);
109 } 112 }
110 113
111 dentry = d_obtain_alias(inode); 114 return d_obtain_alias(inode);
112 if (!IS_ERR(dentry))
113 dentry->d_op = &btrfs_dentry_operations;
114 return dentry;
115fail: 115fail:
116 srcu_read_unlock(&fs_info->subvol_srcu, index); 116 srcu_read_unlock(&fs_info->subvol_srcu, index);
117 return ERR_PTR(err); 117 return ERR_PTR(err);
@@ -166,7 +166,6 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
166static struct dentry *btrfs_get_parent(struct dentry *child) 166static struct dentry *btrfs_get_parent(struct dentry *child)
167{ 167{
168 struct inode *dir = child->d_inode; 168 struct inode *dir = child->d_inode;
169 struct dentry *dentry;
170 struct btrfs_root *root = BTRFS_I(dir)->root; 169 struct btrfs_root *root = BTRFS_I(dir)->root;
171 struct btrfs_path *path; 170 struct btrfs_path *path;
172 struct extent_buffer *leaf; 171 struct extent_buffer *leaf;
@@ -176,6 +175,8 @@ static struct dentry *btrfs_get_parent(struct dentry *child)
176 int ret; 175 int ret;
177 176
178 path = btrfs_alloc_path(); 177 path = btrfs_alloc_path();
178 if (!path)
179 return ERR_PTR(-ENOMEM);
179 180
180 if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) { 181 if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) {
181 key.objectid = root->root_key.objectid; 182 key.objectid = root->root_key.objectid;
@@ -223,10 +224,7 @@ static struct dentry *btrfs_get_parent(struct dentry *child)
223 224
224 key.type = BTRFS_INODE_ITEM_KEY; 225 key.type = BTRFS_INODE_ITEM_KEY;
225 key.offset = 0; 226 key.offset = 0;
226 dentry = d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL)); 227 return d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL));
227 if (!IS_ERR(dentry))
228 dentry->d_op = &btrfs_dentry_operations;
229 return dentry;
230fail: 228fail:
231 btrfs_free_path(path); 229 btrfs_free_path(path);
232 return ERR_PTR(ret); 230 return ERR_PTR(ret);