ovl: use OVL_E() and OVL_E_FLAGS() accessors
authorAmir Goldstein <amir73il@gmail.com>
Wed, 15 Mar 2023 02:31:37 +0000 (04:31 +0200)
committerAmir Goldstein <amir73il@gmail.com>
Mon, 19 Jun 2023 11:01:12 +0000 (14:01 +0300)
Instead of open coded instances, because we are about to split
the two apart.

Reviewed-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/export.c
fs/overlayfs/namei.c
fs/overlayfs/ovl_entry.h
fs/overlayfs/super.c
fs/overlayfs/util.c

index 5c36fb3..2cfdfcc 100644 (file)
@@ -341,7 +341,7 @@ out_iput:
 /* Get the upper or lower dentry in stack whose on layer @idx */
 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
        int i;
 
        if (!idx)
index 100a492..e66352f 100644 (file)
@@ -790,7 +790,7 @@ fail:
  */
 int ovl_path_next(int idx, struct dentry *dentry, struct path *path)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        BUG_ON(idx < 0);
        if (idx == 0) {
@@ -833,8 +833,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
        struct ovl_entry *oe;
        const struct cred *old_cred;
        struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
-       struct ovl_entry *poe = dentry->d_parent->d_fsdata;
-       struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata;
+       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;
        struct dentry *upperdir, *upperdentry = NULL;
        struct dentry *origin = NULL;
@@ -1157,7 +1157,7 @@ out:
 
 bool ovl_lower_positive(struct dentry *dentry)
 {
-       struct ovl_entry *poe = dentry->d_parent->d_fsdata;
+       struct ovl_entry *poe = OVL_E(dentry->d_parent);
        const struct qstr *name = &dentry->d_name;
        const struct cred *old_cred;
        unsigned int i;
index fd11fe6..4c73121 100644 (file)
@@ -124,6 +124,11 @@ static inline struct ovl_entry *OVL_E(struct dentry *dentry)
        return (struct ovl_entry *) dentry->d_fsdata;
 }
 
+static inline unsigned long *OVL_E_FLAGS(struct dentry *dentry)
+{
+       return &OVL_E(dentry)->flags;
+}
+
 struct ovl_inode {
        union {
                struct ovl_dir_cache *cache;    /* directory */
index ae1058f..ea34edd 100644 (file)
@@ -138,7 +138,7 @@ static int ovl_revalidate_real(struct dentry *d, unsigned int flags, bool weak)
 static int ovl_dentry_revalidate_common(struct dentry *dentry,
                                        unsigned int flags, bool weak)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
        struct inode *inode = d_inode_rcu(dentry);
        struct dentry *upper;
        unsigned int i;
index fb12e7f..73a5316 100644 (file)
@@ -143,7 +143,7 @@ bool ovl_dentry_weird(struct dentry *dentry)
 
 enum ovl_path_type ovl_path_type(struct dentry *dentry)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
        enum ovl_path_type type = 0;
 
        if (ovl_dentry_upper(dentry)) {
@@ -176,7 +176,7 @@ void ovl_path_upper(struct dentry *dentry, struct path *path)
 
 void ovl_path_lower(struct dentry *dentry, struct path *path)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        if (oe->numlower) {
                path->mnt = oe->lowerstack[0].layer->mnt;
@@ -188,7 +188,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
 
 void ovl_path_lowerdata(struct dentry *dentry, struct path *path)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        if (oe->numlower) {
                path->mnt = oe->lowerstack[oe->numlower - 1].layer->mnt;
@@ -231,14 +231,14 @@ struct dentry *ovl_dentry_upper(struct dentry *dentry)
 
 struct dentry *ovl_dentry_lower(struct dentry *dentry)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        return oe->numlower ? oe->lowerstack[0].dentry : NULL;
 }
 
 const struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        return oe->numlower ? oe->lowerstack[0].layer : NULL;
 }
@@ -251,7 +251,7 @@ const struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
  */
 struct dentry *ovl_dentry_lowerdata(struct dentry *dentry)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        return oe->numlower ? oe->lowerstack[oe->numlower - 1].dentry : NULL;
 }
@@ -331,17 +331,17 @@ void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache)
 
 void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry)
 {
-       set_bit(flag, &OVL_E(dentry)->flags);
+       set_bit(flag, OVL_E_FLAGS(dentry));
 }
 
 void ovl_dentry_clear_flag(unsigned long flag, struct dentry *dentry)
 {
-       clear_bit(flag, &OVL_E(dentry)->flags);
+       clear_bit(flag, OVL_E_FLAGS(dentry));
 }
 
 bool ovl_dentry_test_flag(unsigned long flag, struct dentry *dentry)
 {
-       return test_bit(flag, &OVL_E(dentry)->flags);
+       return test_bit(flag, OVL_E_FLAGS(dentry));
 }
 
 bool ovl_dentry_is_opaque(struct dentry *dentry)
@@ -1017,7 +1017,7 @@ out:
 
 bool ovl_is_metacopy_dentry(struct dentry *dentry)
 {
-       struct ovl_entry *oe = dentry->d_fsdata;
+       struct ovl_entry *oe = OVL_E(dentry);
 
        if (!d_is_reg(dentry))
                return false;