From patchwork Mon Jun 30 15:48:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451351 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 4A8499F358 for ; Mon, 30 Jun 2014 15:51:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C05120142 for ; Mon, 30 Jun 2014 15:51:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 821CB2021F for ; Mon, 30 Jun 2014 15:51:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754651AbaF3PvO (ORCPT ); Mon, 30 Jun 2014 11:51:14 -0400 Received: from mail-qa0-f44.google.com ([209.85.216.44]:48548 "EHLO mail-qa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754624AbaF3PvN (ORCPT ); Mon, 30 Jun 2014 11:51:13 -0400 Received: by mail-qa0-f44.google.com with SMTP id hw13so6649521qab.31 for ; Mon, 30 Jun 2014 08:51:12 -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=59CN+BQqytQJXShJva6IocbFCUUhPSc/Fz1qrJJGXvI=; b=Y3tFl+Pqdokp7fR6gGIs4abiQTFhUdmg4gZ46FgQxiYaQgN/7Bj2P7CKMlThcIvg7o ZNtsM8Vq7NOBqYvmw7T/2Bxs7MmBMI9Arx36nRG31xMbd/wEOlaIV3vNaH5Lhy+LmoS+ ei95L595SLW3DoDcjWkJfDTiE+FM7z0OZEeyccx3x/E1sOGS3Z2+lZBXDJS8EYb9OJ5u +KU93HIr/k754kFOTMuWvSVfDcNP/MlZVVZQUWIFaZqdTt0qvs9+gSSFqmoV/husrliv RUSCREjTgpZ7YuLLamDWg5Jyjoy8hZGAKo5WEM3NhWEYyDNiBz+6A3Ml/IUYtYj9TgIR 9DQg== X-Gm-Message-State: ALoCoQm0uSdPqShOsFgovgP2+MwGBSooNCEP/sc/s3vkXDe5V9bzyut9bmYp2129HbS/93kM7vet X-Received: by 10.140.89.197 with SMTP id v63mr57811341qgd.71.1404143472244; Mon, 30 Jun 2014 08:51:12 -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.51.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:51:11 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 028/114] nfsd: set stateid access and deny bits in nfs4_get_vfs_file Date: Mon, 30 Jun 2014 11:48:57 -0400 Message-Id: <1404143423-24381-29-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 Cleanup -- ensure that the stateid bits are set at the same time that the file access refcounts are incremented. Keeping them coherent like this makes it easier to ensure that we account for all of the references. Since the initialization of the st_*_bmap fields is done when it's hashed, we go ahead and hash the stateid before getting access to the file and unhash it if that function returns error. This will be necessary anyway in a follow-on patch that will overhaul deny mode handling. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 9dba8b7baf3b..343b8de6309d 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3280,7 +3280,8 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh, } static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, - struct svc_fh *cur_fh, struct nfsd4_open *open) + struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, + struct nfsd4_open *open) { struct file *filp = NULL; __be32 status; @@ -3308,6 +3309,9 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, if (status) goto out_put_access; + /* Set access and deny bits in stateid */ + set_access(open->op_share_access, stp); + set_deny(open->op_share_deny, stp); return nfs_ok; out_put_access: @@ -3319,20 +3323,15 @@ out: static __be32 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open) { - u32 op_share_access = open->op_share_access; __be32 status; - if (!test_access(op_share_access, stp)) - status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open); + if (!test_access(open->op_share_access, stp)) + status = nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); else status = nfsd4_truncate(rqstp, cur_fh, open); if (status) return status; - - /* remember the open */ - set_access(op_share_access, stp); - set_deny(open->op_share_deny, stp); return nfs_ok; } @@ -3580,12 +3579,14 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf if (status) goto out; } else { - status = nfs4_get_vfs_file(rqstp, fp, current_fh, open); - if (status) - goto out; stp = open->op_stp; open->op_stp = NULL; init_open_stateid(stp, fp, open); + status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); + if (status) { + release_open_stateid(stp); + goto out; + } } update_stateid(&stp->st_stid.sc_stateid); memcpy(&open->op_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));