From patchwork Tue Jun 23 11:52:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 6659921 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 CF8ABC05AC for ; Tue, 23 Jun 2015 11:52:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E35AA2063C for ; Tue, 23 Jun 2015 11:52:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BCED2063E for ; Tue, 23 Jun 2015 11:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754679AbbFWLww (ORCPT ); Tue, 23 Jun 2015 07:52:52 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34141 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754635AbbFWLwv (ORCPT ); Tue, 23 Jun 2015 07:52:51 -0400 Received: by pabvl15 with SMTP id vl15so5668214pab.1 for ; Tue, 23 Jun 2015 04:52:51 -0700 (PDT) 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=3N4g3m52iylVA4GiW8BiG/1uQplH9bHz5w6CipgTO24=; b=K8A28UU95F7RscZ0GUaw3WklV0p501QFoV2VzHBr33kRSGLLEHmHaaFqHpODYevqyQ D1P3fyBiB44f1hZO3wjgtwSfWXzfRm3CrX607C/IT9mxmuHr09wdveWZ8kq6PWKV5uFi Qt3ycVQKnIilS+dpLmSuJz6+h22GgRno+DQmRbeJoZORm2JnrCT9iv0VcOlBRZMbLq/I 2wr1OY6jKG565t0KmTwDegL8AZtDtlp5WTNZbKfLU+ByVLUQ9TRyqnzDetCa6uSrUWnM fjzBUl4nxWLJ29lo/jQ8zwDw4OGbSbYAJxcbGB9AzP2uTbTxWhyGr1fzi3n22KO3Vlaz 5s8Q== X-Gm-Message-State: ALoCoQnC6apAJgHdvRBdPI+6nKsnzWyP8nhf9KcxhYC4HAXnLmGO/mCc9oG6VbiGuLHhIkAIxTOr X-Received: by 10.68.250.194 with SMTP id ze2mr69258774pbc.24.1435060371178; Tue, 23 Jun 2015 04:52:51 -0700 (PDT) Received: from lear.localdomain (ec2-54-65-164-9.ap-northeast-1.compute.amazonaws.com. [54.65.164.9]) by mx.google.com with ESMTPSA id kh6sm22995755pbc.50.2015.06.23.04.52.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 04:52:50 -0700 (PDT) From: Peng Tao To: linux-nfs Cc: Trond Myklebust , Peng Tao Subject: [PATCH-v2 09/10] nfs42: serialize LAYOUTSTATS calls of the same file Date: Tue, 23 Jun 2015 19:52:03 +0800 Message-Id: <1435060324-13279-10-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1435060324-13279-1-git-send-email-tao.peng@primarydata.com> References: <1435060324-13279-1-git-send-email-tao.peng@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=-8.3 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 There is no need to report concurrently. Reviewed-by: Jeff Layton Signed-off-by: Peng Tao --- fs/nfs/nfs42proc.c | 3 +++ fs/nfs/pnfs.c | 7 +++++++ include/linux/nfs_fs.h | 1 + 3 files changed, 11 insertions(+) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index ee02483..06c74cd 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -204,6 +204,9 @@ nfs42_layoutstat_release(void *calldata) nfss->pnfs_curr_ld->cleanup_layoutstats(data); pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout); + smp_mb__before_atomic(); + clear_bit(NFS_INO_LAYOUTSTATS, &NFS_I(data->args.inode)->flags); + smp_mb__after_atomic(); nfs_iput_and_deactive(data->inode); kfree(data->args.devinfo); kfree(data); diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 389f7c9..e5bd626 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2254,6 +2254,7 @@ pnfs_report_layoutstat(struct inode *inode) { struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; struct nfs_server *server = NFS_SERVER(inode); + struct nfs_inode *nfsi = NFS_I(inode); struct nfs42_layoutstat_data *data; struct pnfs_layout_hdr *hdr; int status = 0; @@ -2261,6 +2262,9 @@ pnfs_report_layoutstat(struct inode *inode) if (!pnfs_enabled_sb(server) || !ld->prepare_layoutstats) goto out; + if (test_and_set_bit(NFS_INO_LAYOUTSTATS, &nfsi->flags)) + goto out; + spin_lock(&inode->i_lock); if (!NFS_I(inode)->layout) { spin_unlock(&inode->i_lock); @@ -2293,6 +2297,9 @@ out_free: kfree(data); out_put: pnfs_put_layout_hdr(hdr); + smp_mb__before_atomic(); + clear_bit(NFS_INO_LAYOUTSTATS, &nfsi->flags); + smp_mb__after_atomic(); goto out; } EXPORT_SYMBOL_GPL(pnfs_report_layoutstat); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index b95f914..f91b5ad 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -219,6 +219,7 @@ struct nfs_inode { #define NFS_INO_COMMIT (7) /* inode is committing unstable writes */ #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */ #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */ +#define NFS_INO_LAYOUTSTATS (11) /* layoutstats inflight */ static inline struct nfs_inode *NFS_I(const struct inode *inode) {