ovl: invalidate readdir cache on changes to dir with origin
[sfrench/cifs-2.6.git] / fs / overlayfs / util.c
index 2544694d40b9c6ef5e2f5c83da390b17064f675b..b9d03627f364c7b4a59c430c31f5d34176e1597f 100644 (file)
@@ -422,18 +422,20 @@ void ovl_inode_update(struct inode *inode, struct dentry *upperdentry)
        }
 }
 
-static void ovl_dentry_version_inc(struct dentry *dentry, bool impurity)
+static void ovl_dir_version_inc(struct dentry *dentry, bool impurity)
 {
        struct inode *inode = d_inode(dentry);
 
        WARN_ON(!inode_is_locked(inode));
+       WARN_ON(!d_is_dir(dentry));
        /*
-        * Version is used by readdir code to keep cache consistent.  For merge
-        * dirs all changes need to be noted.  For non-merge dirs, cache only
-        * contains impure (ones which have been copied up and have origins)
-        * entries, so only need to note changes to impure entries.
+        * Version is used by readdir code to keep cache consistent.
+        * For merge dirs (or dirs with origin) all changes need to be noted.
+        * For non-merge dirs, cache contains only impure entries (i.e. ones
+        * which have been copied up and have origins), so only need to note
+        * changes to impure entries.
         */
-       if (OVL_TYPE_MERGE(ovl_path_type(dentry)) || impurity)
+       if (!ovl_dir_is_real(dentry) || impurity)
                OVL_I(inode)->version++;
 }
 
@@ -442,7 +444,7 @@ void ovl_dir_modified(struct dentry *dentry, bool impurity)
        /* Copy mtime/ctime */
        ovl_copyattr(d_inode(ovl_dentry_upper(dentry)), d_inode(dentry));
 
-       ovl_dentry_version_inc(dentry, impurity);
+       ovl_dir_version_inc(dentry, impurity);
 }
 
 u64 ovl_dentry_version_get(struct dentry *dentry)
@@ -638,21 +640,6 @@ int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry)
        return err;
 }
 
-void ovl_set_flag(unsigned long flag, struct inode *inode)
-{
-       set_bit(flag, &OVL_I(inode)->flags);
-}
-
-void ovl_clear_flag(unsigned long flag, struct inode *inode)
-{
-       clear_bit(flag, &OVL_I(inode)->flags);
-}
-
-bool ovl_test_flag(unsigned long flag, struct inode *inode)
-{
-       return test_bit(flag, &OVL_I(inode)->flags);
-}
-
 /**
  * Caller must hold a reference to inode to prevent it from being freed while
  * it is marked inuse.