Skip to content

Commit dd39b6f

Browse files
marcospsgregkh
authored andcommitted
btrfs: export helpers for subvolume name/id resolution
[ Upstream commit c0c907a ] The functions will be used outside of export.c and super.c to allow resolving subvolume name from a given id, eg. for subvolume deletion by id ioctl. Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> [ split from the next patch ] Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2ef7ebb commit dd39b6f

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

fs/btrfs/ctree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info);
32713271
int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
32723272
unsigned long new_flags);
32733273
int btrfs_sync_fs(struct super_block *sb, int wait);
3274+
char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
3275+
u64 subvol_objectid);
32743276

32753277
static inline __printf(2, 3) __cold
32763278
void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)

fs/btrfs/export.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
5757
return type;
5858
}
5959

60-
static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
61-
u64 root_objectid, u32 generation,
62-
int check_generation)
60+
struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
61+
u64 root_objectid, u32 generation,
62+
int check_generation)
6363
{
6464
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
6565
struct btrfs_root *root;
@@ -152,7 +152,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
152152
return btrfs_get_dentry(sb, objectid, root_objectid, generation, 1);
153153
}
154154

155-
static struct dentry *btrfs_get_parent(struct dentry *child)
155+
struct dentry *btrfs_get_parent(struct dentry *child)
156156
{
157157
struct inode *dir = d_inode(child);
158158
struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);

fs/btrfs/export.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ struct btrfs_fid {
1818
u64 parent_root_objectid;
1919
} __attribute__ ((packed));
2020

21+
struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
22+
u64 root_objectid, u32 generation,
23+
int check_generation);
24+
struct dentry *btrfs_get_parent(struct dentry *child);
25+
2126
#endif

fs/btrfs/super.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,8 @@ static int btrfs_parse_subvol_options(const char *options, char **subvol_name,
10001000
return error;
10011001
}
10021002

1003-
static char *get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
1004-
u64 subvol_objectid)
1003+
char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
1004+
u64 subvol_objectid)
10051005
{
10061006
struct btrfs_root *root = fs_info->tree_root;
10071007
struct btrfs_root *fs_root;
@@ -1412,8 +1412,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
14121412
goto out;
14131413
}
14141414
}
1415-
subvol_name = get_subvol_name_from_objectid(btrfs_sb(mnt->mnt_sb),
1416-
subvol_objectid);
1415+
subvol_name = btrfs_get_subvol_name_from_objectid(
1416+
btrfs_sb(mnt->mnt_sb), subvol_objectid);
14171417
if (IS_ERR(subvol_name)) {
14181418
root = ERR_CAST(subvol_name);
14191419
subvol_name = NULL;

0 commit comments

Comments
 (0)