fs: Introduce DCACHE_DONTCACHE
[sfrench/cifs-2.6.git] / fs / dcache.c
index b280e07e162b1065203153115f320c77283998d4..0d07fb335b7883c2fa58e0d0823750c445e1ed40 100644 (file)
@@ -647,6 +647,10 @@ static inline bool retain_dentry(struct dentry *dentry)
                if (dentry->d_op->d_delete(dentry))
                        return false;
        }
+
+       if (unlikely(dentry->d_flags & DCACHE_DONTCACHE))
+               return false;
+
        /* retain; LRU fodder */
        dentry->d_lockref.count--;
        if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST)))
@@ -656,6 +660,21 @@ static inline bool retain_dentry(struct dentry *dentry)
        return true;
 }
 
+void d_mark_dontcache(struct inode *inode)
+{
+       struct dentry *de;
+
+       spin_lock(&inode->i_lock);
+       hlist_for_each_entry(de, &inode->i_dentry, d_u.d_alias) {
+               spin_lock(&de->d_lock);
+               de->d_flags |= DCACHE_DONTCACHE;
+               spin_unlock(&de->d_lock);
+       }
+       inode->i_state |= I_DONTCACHE;
+       spin_unlock(&inode->i_lock);
+}
+EXPORT_SYMBOL(d_mark_dontcache);
+
 /*
  * Finish off a dentry we've decided to kill.
  * dentry->d_lock must be held, returns with it unlocked.