From patchwork Wed Jul 30 01:34:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4644051 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 68A28C0338 for ; Wed, 30 Jul 2014 01:35:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B34A2012B for ; Wed, 30 Jul 2014 01:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CC3F20145 for ; Wed, 30 Jul 2014 01:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754537AbaG3Be7 (ORCPT ); Tue, 29 Jul 2014 21:34:59 -0400 Received: from mail-qa0-f49.google.com ([209.85.216.49]:42394 "EHLO mail-qa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754491AbaG3Be7 (ORCPT ); Tue, 29 Jul 2014 21:34:59 -0400 Received: by mail-qa0-f49.google.com with SMTP id dc16so589900qab.22 for ; Tue, 29 Jul 2014 18:34:58 -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=HhAjluOJjgZwaJ+t6UH6Z66+/FFbKa/IUbVN90d5BdE=; b=JwMGuZ4M0rF2npJEEOquxRJAa59frgXoDBvRpKT2DAX11JeSDpaHh/mmrfJhpzwk/a dsi0yuFoxflkfFo/EhG4umyjpui9vO9R99OG9jhKn7ePlLCMSLgpdcj41k2nsZ8xYdzq ISGG6XNsgJk15yaoTwEZwzWPQB2fMXdl3yTk1rNzgfYVwWfhRQQxz9djiGXgNchIwgP6 oRjQWG3WrkXKLZRo9bhoIH9chq/a5NTVd5Ytc3GGDdJJwSnRwBpzxi/MfhKM8GCWtAHI Xqc9gUINWS3KIY48zu1y1q+aWCwTNTk0dwMhBejW3Y0da6HSmjeX78ePwz18KvMBbxGm g4dw== X-Gm-Message-State: ALoCoQmKrOdTk0t6ul0kxMrnNi8yb1U3sgiv7HSp8Qyt/8Q/TZIZHpsayCYHGO60OAY5lUuBLQz9 X-Received: by 10.140.91.66 with SMTP id y60mr1247607qgd.58.1406684098407; Tue, 29 Jul 2014 18:34:58 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 81sm860946qgw.21.2014.07.29.18.34.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 18:34:57 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org Subject: [PATCH v3 06/38] nfsd: do filp_close in sc_free callback for lock stateids Date: Tue, 29 Jul 2014 21:34:11 -0400 Message-Id: <1406684083-19736-7-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406684083-19736-1-git-send-email-jlayton@primarydata.com> References: <1406684083-19736-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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Releasing locks when we unhash the stateid instead of doing so only when the stateid is actually released will be problematic in later patches when we need to protect the unhashing with spinlocks. Move it into the sc_free operation instead. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4state.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index bb37cc4dd573..8ce5894133aa 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -502,7 +502,7 @@ out_free: return NULL; } -static struct nfs4_ol_stateid * nfs4_alloc_stateid(struct nfs4_client *clp) +static struct nfs4_ol_stateid * nfs4_alloc_open_stateid(struct nfs4_client *clp) { struct nfs4_stid *stid; struct nfs4_ol_stateid *stp; @@ -907,16 +907,23 @@ static void nfs4_free_ol_stateid(struct nfs4_stid *stid) kmem_cache_free(stateid_slab, stid); } -static void __release_lock_stateid(struct nfs4_ol_stateid *stp) +static void nfs4_free_lock_stateid(struct nfs4_stid *stid) { + struct nfs4_ol_stateid *stp = openlockstateid(stid); + struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); struct file *file; + file = find_any_file(stp->st_stid.sc_file); + if (file) + filp_close(file, (fl_owner_t)lo); + nfs4_free_ol_stateid(stid); +} + +static void __release_lock_stateid(struct nfs4_ol_stateid *stp) +{ list_del(&stp->st_locks); unhash_generic_stateid(stp); unhash_stid(&stp->st_stid); - file = find_any_file(stp->st_stid.sc_file); - if (file) - filp_close(file, (fl_owner_t)lockowner(stp->st_stateowner)); nfs4_put_stid(&stp->st_stid); } @@ -3287,7 +3294,7 @@ new_owner: return nfserr_jukebox; open->op_openowner = oo; alloc_stateid: - open->op_stp = nfs4_alloc_stateid(clp); + open->op_stp = nfs4_alloc_open_stateid(clp); if (!open->op_stp) return nfserr_jukebox; return nfs_ok; @@ -4703,17 +4710,20 @@ alloc_init_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp, struct inode *inode, struct nfs4_ol_stateid *open_stp) { + struct nfs4_stid *s; struct nfs4_ol_stateid *stp; struct nfs4_client *clp = lo->lo_owner.so_client; - stp = nfs4_alloc_stateid(clp); - if (stp == NULL) + s = nfs4_alloc_stid(clp, stateid_slab); + if (s == NULL) return NULL; + stp = openlockstateid(s); stp->st_stid.sc_type = NFS4_LOCK_STID; list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); stp->st_stateowner = &lo->lo_owner; get_nfs4_file(fp); stp->st_stid.sc_file = fp; + stp->st_stid.sc_free = nfs4_free_lock_stateid; stp->st_access_bmap = 0; stp->st_deny_bmap = open_stp->st_deny_bmap; stp->st_openstp = open_stp;