]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: export helpers for subvolume name/id resolution
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Fri, 21 Feb 2020 13:56:12 +0000 (14:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Aug 2020 08:29:54 +0000 (10:29 +0200)
[ Upstream commit c0c907a47dccf2cf26251a8fb4a8e7a3bf79ce84 ]

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>
fs/btrfs/ctree.h
fs/btrfs/export.c
fs/btrfs/export.h
fs/btrfs/super.c

index 5412b12491cb81f47bc418a2facc94aaedb6e3cf..de951987fd23d89eee999743f3d8cf080c2a768b 100644 (file)
@@ -3262,6 +3262,8 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
                        unsigned long new_flags);
 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)
 void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
index 3aeb5770f8965ba30bd40c5ce76938fb0809bf3e..b6ce765aa7f339f64000872caa6c8228bb09a51f 100644 (file)
@@ -56,9 +56,9 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
        return type;
 }
 
-static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
-                                      u64 root_objectid, u32 generation,
-                                      int check_generation)
+struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
+                               u64 root_objectid, u32 generation,
+                               int check_generation)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(sb);
        struct btrfs_root *root;
@@ -151,7 +151,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);
 }
 
-static struct dentry *btrfs_get_parent(struct dentry *child)
+struct dentry *btrfs_get_parent(struct dentry *child)
 {
        struct inode *dir = d_inode(child);
        struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
index 91b3908e7c5490904f760ba17a9d3a4409fa9028..15db024621414efab3eca2f04b581bd37eae898b 100644 (file)
@@ -17,4 +17,9 @@ struct btrfs_fid {
        u64 parent_root_objectid;
 } __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
index 17a8463ef35c1afb49d54b8c6fdf97a25b3e4899..ca95e57b60ee1123dfa7264518158a48005fc817 100644 (file)
@@ -939,8 +939,8 @@ out:
        return error;
 }
 
-static char *get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
-                                          u64 subvol_objectid)
+char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
+                                         u64 subvol_objectid)
 {
        struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_root *fs_root;
@@ -1427,8 +1427,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
                                goto out;
                        }
                }
-               subvol_name = get_subvol_name_from_objectid(btrfs_sb(mnt->mnt_sb),
-                                                           subvol_objectid);
+               subvol_name = btrfs_get_subvol_name_from_objectid(
+                                       btrfs_sb(mnt->mnt_sb), subvol_objectid);
                if (IS_ERR(subvol_name)) {
                        root = ERR_CAST(subvol_name);
                        subvol_name = NULL;