Linux: osi_vcache: Fix loop for the hlist case
authorMarc Dionne <marc.c.dionne@gmail.com>
Fri, 12 Oct 2012 20:25:43 +0000 (16:25 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Sat, 13 Oct 2012 01:31:19 +0000 (18:31 -0700)
An hlist is not circular, and the end is marked by a NULL next
pointer.

Change-Id: Iec7ad7e3e7ee989d548233b045aa8def1ebfb1dc
Reviewed-on: http://gerrit.openafs.org/8233
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/afs/LINUX/osi_vcache.c

index cd61c65..dc3685b 100644 (file)
@@ -20,9 +20,9 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
     struct dentry *dentry;
     struct inode *inode = AFSTOV(avc);
 #if defined(D_ALIAS_IS_HLIST)
-    struct hlist_node *cur, *head;
+    struct hlist_node *cur, *head, *list_end;
 #else
-    struct list_head *cur, *head;
+    struct list_head *cur, *head, *list_end;
 #endif
 
     /* First, see if we can evict the inode from the dcache */
@@ -59,13 +59,15 @@ restart:
        spin_lock(&inode->i_lock);
 #if defined(D_ALIAS_IS_HLIST)
        head = inode->i_dentry.first;
+       list_end = NULL;
 #else
        head = &inode->i_dentry;
+       list_end = head;
 #endif
 
 restart:
        cur = head;
-       while ((cur = cur->next) != head) {
+       while ((cur = cur->next) != list_end) {
 #if defined(D_ALIAS_IS_HLIST)
            dentry = hlist_entry(cur, struct dentry, d_alias);
 #else