ovl: make consistent use of OVL_FS()
authorAndrea Righi <andrea.righi@canonical.com>
Sun, 21 May 2023 08:28:12 +0000 (10:28 +0200)
committerAmir Goldstein <amir73il@gmail.com>
Sat, 12 Aug 2023 16:02:54 +0000 (19:02 +0300)
Always use OVL_FS() to retrieve the corresponding struct ovl_fs from a
struct super_block.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
fs/overlayfs/copy_up.c
fs/overlayfs/export.c
fs/overlayfs/inode.c
fs/overlayfs/namei.c
fs/overlayfs/ovl_entry.h
fs/overlayfs/params.c
fs/overlayfs/super.c
fs/overlayfs/util.c

index 618651b548185fd5b35b9e255cc8b5a7e3bd8d76..bae404a1bad48f8fa3611986a8bb77c77b2d8d32 100644 (file)
@@ -932,7 +932,7 @@ out:
 static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
                                  int flags)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 
        if (!ofs->config.metacopy)
                return false;
index 6d54f3fc24c55c40e3aa90e5736e61f0cc58c915..c8c8588bd98caf4a29cd31d9e0e873de70fcec28 100644 (file)
@@ -183,7 +183,7 @@ static int ovl_connect_layer(struct dentry *dentry)
  */
 static int ovl_check_encode_origin(struct dentry *dentry)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        bool decodable = ofs->config.nfs_export;
 
        /* Lower file handle for non-upper non-decodable */
@@ -444,7 +444,7 @@ static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
                                            struct dentry *real,
                                            const struct ovl_layer *layer)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        struct dentry *index = NULL;
        struct dentry *this = NULL;
        struct inode *inode;
@@ -665,7 +665,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb,
                                     struct ovl_path *lowerpath,
                                     struct dentry *index)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer;
        struct dentry *real = upper ?: (index ?: lowerpath->dentry);
 
@@ -690,7 +690,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb,
 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
                                        struct ovl_fh *fh)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        struct dentry *dentry;
        struct dentry *upper;
 
@@ -710,7 +710,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
                                        struct ovl_fh *fh)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        struct ovl_path origin = { };
        struct ovl_path *stack = &origin;
        struct dentry *dentry = NULL;
index c1c9ff62caad6952c019fabec4416056c0a1d7f8..b395cd84bfce7c8006481eec7b614ba9e1042a65 100644 (file)
@@ -341,7 +341,7 @@ static const char *ovl_get_link(struct dentry *dentry,
 
 bool ovl_is_private_xattr(struct super_block *sb, const char *name)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        if (ofs->config.userxattr)
                return strncmp(name, OVL_XATTR_USER_PREFIX,
@@ -696,7 +696,7 @@ int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
 {
        if (flags & S_ATIME) {
-               struct ovl_fs *ofs = inode->i_sb->s_fs_info;
+               struct ovl_fs *ofs = OVL_FS(inode->i_sb);
                struct path upperpath = {
                        .mnt = ovl_upper_mnt(ofs),
                        .dentry = ovl_upperdentry_dereference(OVL_I(inode)),
@@ -1291,7 +1291,7 @@ struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir)
 static bool ovl_hash_bylower(struct super_block *sb, struct dentry *upper,
                             struct dentry *lower, bool index)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        /* No, if pure upper */
        if (!lower)
index 84c06512fb71bd2bc8e9cdea463e3a0ff3ff734c..80391c687c2ad83975f661905414f924d927a155 100644 (file)
@@ -892,7 +892,7 @@ static int ovl_fix_origin(struct ovl_fs *ofs, struct dentry *dentry,
 
 static int ovl_maybe_validate_verity(struct dentry *dentry)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        struct inode *inode = d_inode(dentry);
        struct path datapath, metapath;
        int err;
@@ -1002,7 +1002,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 {
        struct ovl_entry *oe = NULL;
        const struct cred *old_cred;
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        struct ovl_entry *poe = OVL_E(dentry->d_parent);
        struct ovl_entry *roe = OVL_E(dentry->d_sb->s_root);
        struct ovl_path *stack = NULL, *origin_path = NULL;
index 5d03f449adb1f0fab214b2316e32c607b77c9894..edb457544b5f63709038d17ea3acb9a2a0551607 100644 (file)
@@ -117,6 +117,8 @@ static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
        return mnt_idmap(ovl_upper_mnt(ofs));
 }
 
+extern struct file_system_type ovl_fs_type;
+
 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
 {
        return (struct ovl_fs *)sb->s_fs_info;
index 3fc01feb5f12468434f2ea8f135c39946febf359..b9355bb6d75a33128c8ad84903dd0358b4edcd96 100644 (file)
@@ -662,7 +662,7 @@ static void ovl_free(struct fs_context *fc)
 static int ovl_reconfigure(struct fs_context *fc)
 {
        struct super_block *sb = fc->root->d_sb;
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        struct super_block *upper_sb;
        int ret = 0;
 
@@ -947,7 +947,7 @@ int ovl_fs_params_verify(const struct ovl_fs_context *ctx,
 int ovl_show_options(struct seq_file *m, struct dentry *dentry)
 {
        struct super_block *sb = dentry->d_sb;
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        size_t nr, nr_merged_lower = ofs->numlayer - ofs->numdatalayer;
        const struct ovl_layer *data_layers = &ofs->layers[nr_merged_lower];
 
index 9107e548257896c7db1e11578996ac69f834e0d9..def266b5e2a33b0aa630662286827227f952e513 100644 (file)
@@ -185,7 +185,7 @@ static void ovl_destroy_inode(struct inode *inode)
 
 static void ovl_put_super(struct super_block *sb)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        if (ofs)
                ovl_free_fs(ofs);
@@ -194,7 +194,7 @@ static void ovl_put_super(struct super_block *sb)
 /* Sync real dirty inodes in upper filesystem (if it exists) */
 static int ovl_sync_fs(struct super_block *sb, int wait)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
        struct super_block *upper_sb;
        int ret;
 
@@ -1501,7 +1501,7 @@ out_err:
        return err;
 }
 
-static struct file_system_type ovl_fs_type = {
+struct file_system_type ovl_fs_type = {
        .owner                  = THIS_MODULE,
        .name                   = "overlay",
        .init_fs_context        = ovl_init_fs_context,
index 9ebb9598e7ece5cfc4fe57605c6156139559df45..0f387092450e9bff43a599dcd3848c653ed7eb20 100644 (file)
 
 int ovl_want_write(struct dentry *dentry)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        return mnt_want_write(ovl_upper_mnt(ofs));
 }
 
 void ovl_drop_write(struct dentry *dentry)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        mnt_drop_write(ovl_upper_mnt(ofs));
 }
 
 struct dentry *ovl_workdir(struct dentry *dentry)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        return ofs->workdir;
 }
 
 const struct cred *ovl_override_creds(struct super_block *sb)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        return override_creds(ofs->creator_cred);
 }
@@ -63,7 +63,7 @@ int ovl_can_decode_fh(struct super_block *sb)
 
 struct dentry *ovl_indexdir(struct super_block *sb)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        return ofs->indexdir;
 }
@@ -71,7 +71,7 @@ struct dentry *ovl_indexdir(struct super_block *sb)
 /* Index all files on copy up. For now only enabled for NFS export */
 bool ovl_index_all(struct super_block *sb)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        return ofs->config.nfs_export && ofs->config.index;
 }
@@ -79,7 +79,7 @@ bool ovl_index_all(struct super_block *sb)
 /* Verify lower origin on lookup. For now only enabled for NFS export */
 bool ovl_verify_lower(struct super_block *sb)
 {
-       struct ovl_fs *ofs = sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(sb);
 
        return ofs->config.nfs_export && ofs->config.index;
 }
@@ -204,7 +204,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
 
 void ovl_path_upper(struct dentry *dentry, struct path *path)
 {
-       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 
        path->mnt = ovl_upper_mnt(ofs);
        path->dentry = ovl_dentry_upper(dentry);