From patchwork Thu Jan 22 23:35:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Haynes X-Patchwork-Id: 5689511 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0233BC058D for ; Thu, 22 Jan 2015 23:37:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A2BA20272 for ; Thu, 22 Jan 2015 23:37:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 580022026F for ; Thu, 22 Jan 2015 23:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754369AbbAVXhS (ORCPT ); Thu, 22 Jan 2015 18:37:18 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:60596 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754290AbbAVXhR (ORCPT ); Thu, 22 Jan 2015 18:37:17 -0500 Received: by mail-pa0-f47.google.com with SMTP id lj1so4863213pab.6 for ; Thu, 22 Jan 2015 15:37:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZqeyuQ4HuLatsuRG2ako7OPGAL8X8j1xH3Vm86pQdZE=; b=D3gFA1BCd0PUuQG3ihdtOezUU61OqU6ETPTkG5LYThLLYTTlzvid93RW70aAi+fbqK xZQL4w925Ylo1nSETIl76Z1ptHBT19xJtUTIQTTrbnfrAY4jbYPj1RnDSDs+AJA29NzO tVCMyeXrzhElOmaD2/ZwRbvb8E4SB/Fu8OlR6PBivgYlalPm0PR+xYyyubBkIJ26s6S2 T9Z7r+4G4M2oHONRbc0V1ZglOk4HbskFSI+HgCULd5cAOOlRxTEgyU9CE4KyLsd1Cgqg pltResybakuLwEPfFeLtNyvUqFsM4tzx2rNzHdUOKJid8DrYBpgd0p6yXDJtD613KGg2 HdcA== X-Gm-Message-State: ALoCoQmTp4BTfuacgbN3gnTjTk0wyE1Mm2WtZW4LxQ5z04A1tSUzPMLOXIg03eSk1KO+LYK9YWjq X-Received: by 10.66.221.135 with SMTP id qe7mr6423382pac.26.1421969837145; Thu, 22 Jan 2015 15:37:17 -0800 (PST) Received: from localhost.localdomain ([50.242.95.105]) by mx.google.com with ESMTPSA id fu1sm366817pdb.80.2015.01.22.15.37.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 15:37:16 -0800 (PST) From: Tom Haynes X-Google-Original-From: Tom Haynes To: Trond Myklebust Cc: Linux NFS Mailing list Subject: [PATCH v5 20/51] nfs41: close a small race window when adding new layout to global list Date: Thu, 22 Jan 2015 15:35:52 -0800 Message-Id: <1421969783-92997-21-git-send-email-loghyr@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1421969783-92997-1-git-send-email-loghyr@primarydata.com> References: <1421969783-92997-1-git-send-email-loghyr@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 From: Peng Tao Signed-off-by: Peng Tao Signed-off-by: Tom Haynes --- fs/nfs/pnfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 2d25670..fa00b56 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1288,7 +1288,6 @@ pnfs_update_layout(struct inode *ino, struct nfs_client *clp = server->nfs_client; struct pnfs_layout_hdr *lo; struct pnfs_layout_segment *lseg = NULL; - bool first; if (!pnfs_enabled_sb(NFS_SERVER(ino))) goto out; @@ -1321,16 +1320,15 @@ pnfs_update_layout(struct inode *ino, if (pnfs_layoutgets_blocked(lo, 0)) goto out_unlock; atomic_inc(&lo->plh_outstanding); - - first = list_empty(&lo->plh_layouts) ? true : false; spin_unlock(&ino->i_lock); - if (first) { + if (list_empty(&lo->plh_layouts)) { /* The lo must be on the clp list if there is any * chance of a CB_LAYOUTRECALL(FILE) coming in. */ spin_lock(&clp->cl_lock); - list_add_tail(&lo->plh_layouts, &server->layouts); + if (list_empty(&lo->plh_layouts)) + list_add_tail(&lo->plh_layouts, &server->layouts); spin_unlock(&clp->cl_lock); }