NFS: __nfs_find_lock_context needs to check ctx->lock_context for a match too
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 15 Mar 2013 22:11:31 +0000 (18:11 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 25 Mar 2013 16:04:10 +0000 (12:04 -0400)
Currently, we're forcing an unnecessary duplication of the
initial nfs_lock_context in calls to nfs_get_lock_context, since
__nfs_find_lock_context ignores the ctx->lock_context.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/inode.c

index 1f941674b08967e4204d67f92d66cd6650bbc9a1..55b840f05ab265aee86309300dd8afabe4b17e1a 100644 (file)
@@ -565,16 +565,17 @@ static void nfs_init_lock_context(struct nfs_lock_context *l_ctx)
 
 static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context *ctx)
 {
-       struct nfs_lock_context *pos;
+       struct nfs_lock_context *head = &ctx->lock_context;
+       struct nfs_lock_context *pos = head;
 
-       list_for_each_entry(pos, &ctx->lock_context.list, list) {
+       do {
                if (pos->lockowner.l_owner != current->files)
                        continue;
                if (pos->lockowner.l_pid != current->tgid)
                        continue;
                atomic_inc(&pos->count);
                return pos;
-       }
+       } while ((pos = list_entry(pos->list.next, typeof(*pos), list)) != head);
        return NULL;
 }