From patchwork Mon Jun 30 15:48:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451181 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 145599F390 for ; Mon, 30 Jun 2014 15:50:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 284C22037D for ; Mon, 30 Jun 2014 15:50:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1989120379 for ; Mon, 30 Jun 2014 15:50:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754562AbaF3Puv (ORCPT ); Mon, 30 Jun 2014 11:50:51 -0400 Received: from mail-qc0-f180.google.com ([209.85.216.180]:43142 "EHLO mail-qc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754558AbaF3Puu (ORCPT ); Mon, 30 Jun 2014 11:50:50 -0400 Received: by mail-qc0-f180.google.com with SMTP id r5so7070935qcx.25 for ; Mon, 30 Jun 2014 08:50:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XfJEgX35kqjDjsSsVLquw1Y5toWKxYMKz4IbIj1zqeg=; b=AC992ohUmx6bvWxxOZDbK47mIQz8wCApa+VHsqj7g7iBufdwQFZ2qdUoFgXPcTf+y/ 8gWeKrjGs/p++5j/TTGJe3NdRuMrZy4xX4Tm76QYPQn+29zz7LV3Db8pplBS6BP6IfZO wYythbAVmFcmMKHtNBsJtnCRyMLxT70IDF3Noe1VKZx6/rMfbwRYE6r/EU2PclcOlwAt 5A+aYc0y3MWi13PMnazZwj5oIMtmjUxi55SGNipNi6u5hhoNjGIuv0deImYHK/DTUhKf evEk1TTsJHe2tg96XO2ctWe35liKKcpFghtOjWkF0TvN/QYl70PpyzZi6Y7KAiQG65pk WckQ== X-Gm-Message-State: ALoCoQlzNkt7PLYY+skTb+ywC8SB241Bu+K06lXCUpAlua6C+yWBtT4TFMxMgj2bFBXUQzDPaOIN X-Received: by 10.224.87.130 with SMTP id w2mr62048451qal.5.1404143449576; Mon, 30 Jun 2014 08:50:49 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id m1sm32584105qaz.27.2014.06.30.08.50.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:50:48 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 012/114] nfsd: clean up nfsd4_release_lockowner Date: Mon, 30 Jun 2014 11:48:41 -0400 Message-Id: <1404143423-24381-13-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404143423-24381-1-git-send-email-jlayton@primarydata.com> References: <1404143423-24381-1-git-send-email-jlayton@primarydata.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 Now that we know that we won't have several lockowners with the same, owner->data, we can simplify nfsd4_release_lockowner and get rid of the lo_list in the process. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4state.c | 46 ++++++++++++++++++++++------------------------ fs/nfsd/state.h | 1 - 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e7b77c0ff15a..65b093d2aa16 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4794,11 +4794,10 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *rlockowner) { clientid_t *clid = &rlockowner->rl_clientid; - struct nfs4_stateowner *sop; + struct nfs4_stateowner *sop = NULL, *tmp; struct nfs4_lockowner *lo; struct nfs4_ol_stateid *stp; struct xdr_netobj *owner = &rlockowner->rl_owner; - struct list_head matches; unsigned int hashval = ownerstr_hashval(clid->cl_id, owner); __be32 status; struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); @@ -4813,33 +4812,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, goto out; status = nfserr_locks_held; - INIT_LIST_HEAD(&matches); - list_for_each_entry(sop, &nn->ownerstr_hashtbl[hashval], so_strhash) { - if (sop->so_is_open_owner) - continue; - if (!same_owner_str(sop, owner, clid)) + /* Find the matching lock stateowner */ + list_for_each_entry(tmp, &nn->ownerstr_hashtbl[hashval], so_strhash) { + if (tmp->so_is_open_owner) continue; - list_for_each_entry(stp, &sop->so_stateids, - st_perstateowner) { - lo = lockowner(sop); - if (check_for_locks(stp->st_file, lo)) - goto out; - list_add(&lo->lo_list, &matches); + if (same_owner_str(tmp, owner, clid)) { + sop = tmp; + 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; - while (!list_empty(&matches)) { - lo = list_entry(matches.next, struct nfs4_lockowner, - lo_list); - /* unhash_stateowner deletes so_perclient only - * for openowners. */ - list_del(&lo->lo_list); - release_lockowner(lo); + + /* No matching owner found, maybe a replay? Just declare victory... */ + if (!sop) { + status = nfs_ok; + goto out; + } + + lo = lockowner(sop); + /* see if there are still any locks associated with it */ + list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { + if (check_for_locks(stp->st_file, lo)) + goto out; } + + status = nfs_ok; + release_lockowner(lo); out: nfs4_unlock_state(); return status; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 2fe58f5f4833..a7d13cd97921 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -364,7 +364,6 @@ struct nfs4_openowner { struct nfs4_lockowner { struct nfs4_stateowner lo_owner; /* must be first element */ - struct list_head lo_list; /* for temporary uses */ }; static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so)