Commit c0c907a4 authored by Marcos Paulo de Souza's avatar Marcos Paulo de Souza Committed by David Sterba

btrfs: export helpers for subvolume name/id resolution

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: default avatarMarcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ split from the next patch ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 748449cd
...@@ -2999,6 +2999,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, ...@@ -2999,6 +2999,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
int btrfs_parse_options(struct btrfs_fs_info *info, char *options, int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
unsigned long new_flags); unsigned long new_flags);
int btrfs_sync_fs(struct super_block *sb, int wait); int btrfs_sync_fs(struct super_block *sb, int wait);
char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
u64 subvol_objectid);
static inline __printf(2, 3) __cold static inline __printf(2, 3) __cold
void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
......
...@@ -57,7 +57,7 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len, ...@@ -57,7 +57,7 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
return type; return type;
} }
static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
u64 root_objectid, u32 generation, u64 root_objectid, u32 generation,
int check_generation) int check_generation)
{ {
...@@ -153,7 +153,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh, ...@@ -153,7 +153,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
return btrfs_get_dentry(sb, objectid, root_objectid, generation, 1); return btrfs_get_dentry(sb, objectid, root_objectid, generation, 1);
} }
static struct dentry *btrfs_get_parent(struct dentry *child) struct dentry *btrfs_get_parent(struct dentry *child)
{ {
struct inode *dir = d_inode(child); struct inode *dir = d_inode(child);
struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
......
...@@ -18,4 +18,9 @@ struct btrfs_fid { ...@@ -18,4 +18,9 @@ struct btrfs_fid {
u64 parent_root_objectid; u64 parent_root_objectid;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
u64 root_objectid, u32 generation,
int check_generation);
struct dentry *btrfs_get_parent(struct dentry *child);
#endif #endif
...@@ -1024,7 +1024,7 @@ static int btrfs_parse_subvol_options(const char *options, char **subvol_name, ...@@ -1024,7 +1024,7 @@ static int btrfs_parse_subvol_options(const char *options, char **subvol_name,
return error; return error;
} }
static char *get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info, char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
u64 subvol_objectid) u64 subvol_objectid)
{ {
struct btrfs_root *root = fs_info->tree_root; struct btrfs_root *root = fs_info->tree_root;
...@@ -1442,8 +1442,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid, ...@@ -1442,8 +1442,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
goto out; goto out;
} }
} }
subvol_name = get_subvol_name_from_objectid(btrfs_sb(mnt->mnt_sb), subvol_name = btrfs_get_subvol_name_from_objectid(
subvol_objectid); btrfs_sb(mnt->mnt_sb), subvol_objectid);
if (IS_ERR(subvol_name)) { if (IS_ERR(subvol_name)) {
root = ERR_CAST(subvol_name); root = ERR_CAST(subvol_name);
subvol_name = NULL; subvol_name = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment