From patchwork Tue Jun 16 14:47:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 6618861 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 764039F1C1 for ; Tue, 16 Jun 2015 14:49:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90C6B207DC for ; Tue, 16 Jun 2015 14:49:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FF7C207DF for ; Tue, 16 Jun 2015 14:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756554AbbFPOtT (ORCPT ); Tue, 16 Jun 2015 10:49:19 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:33572 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756631AbbFPOtT (ORCPT ); Tue, 16 Jun 2015 10:49:19 -0400 Received: by pdjn11 with SMTP id n11so16064619pdj.0 for ; Tue, 16 Jun 2015 07:49:18 -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=UOKg0dyYR2dsw+nLpc0zIDkZ+Zpe3FDbmPQFEzD5gO8=; b=FZUt+A/svFsLWEQ3RIGY+ikmp6k/lJJbLbfXNO6jw/E5BiTc6/SWii+hvLFb1ahFw7 HIat9c2hBLULMVqF0PKikQkjfMoYYwePkFBEB83A8zSy27P0zOpm59kbOjgX5BoVNdVd Poz4ItS2EmoQ3nz4pXn6yazTYrMLWblZ0bHWMw8qmhEkv3yfIrXxNcD25FFoy8koUsc3 QZ+gDPWlvcQ1DKV3ylJ/k87ffcS90vkxFqrpBIwpxZSEP8Z8YbvTQlCXtmFdHWPuU/JQ +4X8LdXawa0w+Tq4fSzPfsEJ1Noy5IQeHRMojMfWSGDLp7sz8vrDJ6pu14SIjwWeAXUL z7jw== X-Gm-Message-State: ALoCoQnmEtRn+VKziEdW2reaKLqS8CRDIpSMPaFxh1k8unV3R970nBjelQHqAxO1cUAiedNw24vx X-Received: by 10.68.245.67 with SMTP id xm3mr1282654pbc.45.1434466158533; Tue, 16 Jun 2015 07:49:18 -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 wa4sm1698677pab.17.2015.06.16.07.49.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2015 07:49:18 -0700 (PDT) From: Peng Tao To: linux-nfs Cc: Peng Tao Subject: [PATCH 10/11] nfs42: serialize LAYOUTSTATS calls of the same file Date: Tue, 16 Jun 2015 22:47:31 +0800 Message-Id: <1434466052-10491-11-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1434466052-10491-1-git-send-email-tao.peng@primarydata.com> References: <1434466052-10491-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=-7.5 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. 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) {