[PATCH] Remove hlist_for_each_rcu() API, convert existing use to hlist_for_each_entry_rcu
[powerpc.git] / fs / dcache.c
index a15a2e1..17e4391 100644 (file)
@@ -102,7 +102,8 @@ static inline void dentry_iput(struct dentry * dentry)
                list_del_init(&dentry->d_alias);
                spin_unlock(&dentry->d_lock);
                spin_unlock(&dcache_lock);
-               fsnotify_inoderemove(inode);
+               if (!inode->i_nlink)
+                       fsnotify_inoderemove(inode);
                if (dentry->d_op && dentry->d_op->d_iput)
                        dentry->d_op->d_iput(dentry, inode);
                else
@@ -337,12 +338,10 @@ struct dentry * d_find_alias(struct inode *inode)
  */
 void d_prune_aliases(struct inode *inode)
 {
-       struct list_head *tmp, *head = &inode->i_dentry;
+       struct dentry *dentry;
 restart:
        spin_lock(&dcache_lock);
-       tmp = head;
-       while ((tmp = tmp->next) != head) {
-               struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
+       list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
                spin_lock(&dentry->d_lock);
                if (!atomic_read(&dentry->d_count)) {
                        __dget_locked(dentry);
@@ -463,10 +462,7 @@ void shrink_dcache_sb(struct super_block * sb)
         * superblock to the most recent end of the unused list.
         */
        spin_lock(&dcache_lock);
-       next = dentry_unused.next;
-       while (next != &dentry_unused) {
-               tmp = next;
-               next = tmp->next;
+       list_for_each_safe(tmp, next, &dentry_unused) {
                dentry = list_entry(tmp, struct dentry, d_lru);
                if (dentry->d_sb != sb)
                        continue;
@@ -478,10 +474,7 @@ void shrink_dcache_sb(struct super_block * sb)
         * Pass two ... free the dentries for this superblock.
         */
 repeat:
-       next = dentry_unused.next;
-       while (next != &dentry_unused) {
-               tmp = next;
-               next = tmp->next;
+       list_for_each_safe(tmp, next, &dentry_unused) {
                dentry = list_entry(tmp, struct dentry, d_lru);
                if (dentry->d_sb != sb)
                        continue;
@@ -651,7 +644,7 @@ void shrink_dcache_parent(struct dentry * parent)
  *
  * Prune the dentries that are anonymous
  *
- * parsing d_hash list does not hlist_for_each_rcu() as it
+ * parsing d_hash list does not hlist_for_each_entry_rcu() as it
  * done under dcache_lock.
  *
  */
@@ -696,7 +689,7 @@ void shrink_dcache_anon(struct hlist_head *head)
  *
  * In this case we return -1 to tell the caller that we baled.
  */
-static int shrink_dcache_memory(int nr, unsigned int gfp_mask)
+static int shrink_dcache_memory(int nr, gfp_t gfp_mask)
 {
        if (nr) {
                if (!(gfp_mask & __GFP_FS))
@@ -1050,15 +1043,13 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
        struct hlist_head *head = d_hash(parent,hash);
        struct dentry *found = NULL;
        struct hlist_node *node;
+       struct dentry *dentry;
 
        rcu_read_lock();
        
-       hlist_for_each_rcu(node, head) {
-               struct dentry *dentry; 
+       hlist_for_each_entry_rcu(dentry, node, head, d_hash) {
                struct qstr *qstr;
 
-               dentry = hlist_entry(node, struct dentry, d_hash);
-
                if (dentry->d_name.hash != hash)
                        continue;
                if (dentry->d_parent != parent)
@@ -1130,7 +1121,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
        spin_lock(&dcache_lock);
        base = d_hash(dparent, dentry->d_name.hash);
        hlist_for_each(lhp,base) { 
-               /* hlist_for_each_rcu() not required for d_hash list
+               /* hlist_for_each_entry_rcu() not required for d_hash list
                 * as it is parsed under dcache_lock
                 */
                if (dentry == hlist_entry(lhp, struct dentry, d_hash)) {