From patchwork Wed Sep 3 18:15:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 4836231 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 B4034C033A for ; Wed, 3 Sep 2014 18:15:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7C88200E3 for ; Wed, 3 Sep 2014 18:15:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA6862020E for ; Wed, 3 Sep 2014 18:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbaICSPt (ORCPT ); Wed, 3 Sep 2014 14:15:49 -0400 Received: from mx11.netapp.com ([216.240.18.76]:27693 "EHLO mx11.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbaICSPq (ORCPT ); Wed, 3 Sep 2014 14:15:46 -0400 X-IronPort-AV: E=Sophos;i="5.04,459,1406617200"; d="scan'208";a="144040992" Received: from vmwexchts04-prd.hq.netapp.com ([10.122.105.32]) by mx11-out.netapp.com with ESMTP; 03 Sep 2014 11:15:46 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS04-PRD.hq.netapp.com (10.122.105.32) with Microsoft SMTP Server id 15.0.913.22; Wed, 3 Sep 2014 11:15:43 -0700 Received: from davros.com (davros.ocarinaproject.vpn.netapp.com [10.63.237.75]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id s83IFgPK001751; Wed, 3 Sep 2014 11:15:44 -0700 (PDT) From: Anna Schumaker To: , Subject: [PATCH] NFS: Clear up state owner lock usage Date: Wed, 3 Sep 2014 14:15:40 -0400 Message-ID: <1409768140-3826-2-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1409768140-3826-1-git-send-email-Anna.Schumaker@Netapp.com> References: <1409768140-3826-1-git-send-email-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 can_open_cached() reads values out of the state structure, meaning that we need the so_lock to have a correct return value. As a bonus, this helps clear up some potentially confusing code. Signed-off-by: Anna Schumaker --- fs/nfs/nfs4proc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 7dd8aca..18eb31c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1307,15 +1307,13 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) int ret = -EAGAIN; for (;;) { + spin_lock(&state->owner->so_lock); if (can_open_cached(state, fmode, open_mode)) { - spin_lock(&state->owner->so_lock); - if (can_open_cached(state, fmode, open_mode)) { - update_open_stateflags(state, fmode); - spin_unlock(&state->owner->so_lock); - goto out_return_state; - } + update_open_stateflags(state, fmode); spin_unlock(&state->owner->so_lock); + goto out_return_state; } + spin_unlock(&state->owner->so_lock); rcu_read_lock(); delegation = rcu_dereference(nfsi->delegation); if (!can_open_delegated(delegation, fmode)) {