From patchwork Sun Dec 15 15:51:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 3350441 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 022229F32E for ; Sun, 15 Dec 2013 15:51:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FD6520145 for ; Sun, 15 Dec 2013 15:51:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BB5B20121 for ; Sun, 15 Dec 2013 15:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793Ab3LOPv4 (ORCPT ); Sun, 15 Dec 2013 10:51:56 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:38835 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790Ab3LOPvz (ORCPT ); Sun, 15 Dec 2013 10:51:55 -0500 Received: by mail-ee0-f53.google.com with SMTP id b57so1723771eek.26 for ; Sun, 15 Dec 2013 07:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7wletbk+Y811YDoqahHQDfCuGn9qFi05MY6bUfyJ7ww=; b=fkVh2vtjjHjqV0MhjBiZyrVW9AMFo5mH8qIfELOz9+jf/ildTyfrQy3Lt22s5ZqXHq rKqgaQg01qcUTKiNLD2SUyB9/eLn42JAyGhTZ8ma2Th64E3G3s3xLNC5Ij09PCwFeWnM 7dzDNnqcnU0oMWT+vK7JqZfha/CK8ZjDtdUqdhfTRGC4tIB71KfFGeKKqjWORgUCW/LL PwRrTKoh0ybalG8KbNqtYyjEgVm/4tW9aKrwTwO0oKsofyBUS8gK+kPbE/rHMVOKu+79 Dbm8zruHSSPpQp2kcCQlUWXUiCuguEUix3Nv0CGC6PKbr1t8rvHnd/dCb66tL6zWAFO4 hgVg== X-Received: by 10.14.174.129 with SMTP id x1mr12446939eel.19.1387122714536; Sun, 15 Dec 2013 07:51:54 -0800 (PST) Received: from localhost.il.tonian.com (bzq-80-49-130.static.bezeqint.net. [82.80.49.130]) by mx.google.com with ESMTPSA id o47sm31405438eem.21.2013.12.15.07.51.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2013 07:51:53 -0800 (PST) From: Benny Halevy To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org, Benny Halevy Subject: [PATCH v2 1/2] nfsd4: break from inner lookup loop in nfsd4_release_lockowner on first match Date: Sun, 15 Dec 2013 17:51:50 +0200 Message-Id: <1387122710-23603-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <52ADCFC2.7060504@gmail.com> References: <52ADCFC2.7060504@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Otherwise the lockowner may by added to "matches" more than once. Signed-off-by: Benny Halevy --- fs/nfsd/nfs4state.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 0874998..b04f765 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4192,6 +4192,7 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, str /* It is the openowner seqid that will be incremented in encode in the * case of new lockowners; so increment the lock seqid manually: */ lo->lo_owner.so_seqid = lock->lk_new_lock_seqid + 1; + INIT_LIST_HEAD(&lo->lo_list); hash_lockowner(lo, strhashval, clp, open_stp); return lo; } @@ -4646,7 +4647,6 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, if (status) goto out; - status = nfserr_locks_held; INIT_LIST_HEAD(&matches); list_for_each_entry(sop, &nn->ownerstr_hashtbl[hashval], so_strhash) { @@ -4654,25 +4654,30 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, continue; if (!same_owner_str(sop, owner, clid)) continue; + lo = lockowner(sop); list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { - lo = lockowner(sop); - if (check_for_locks(stp->st_file, lo)) - goto out; + if (check_for_locks(stp->st_file, lo)) { + status = nfserr_locks_held; + goto locks_held; + } list_add(&lo->lo_list, &matches); + break; } } /* Clients probably won't expect us to return with some (but not all) * of the lockowner state released; so don't release any until all * have been checked. */ status = nfs_ok; +locks_held: while (!list_empty(&matches)) { - lo = list_entry(matches.next, struct nfs4_lockowner, + lo = list_first_entry(&matches, struct nfs4_lockowner, lo_list); /* unhash_stateowner deletes so_perclient only * for openowners. */ list_del(&lo->lo_list); - release_lockowner(lo); + if (status == nfs_ok) + release_lockowner(lo); } out: nfs4_unlock_state();