public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Tao <tao.peng@primarydata.com>
To: linux-nfs <linux-nfs@vger.kernel.org>
Cc: Peng Tao <tao.peng@primarydata.com>
Subject: [PATCH 03/11] pnfs: add pnfs_report_layoutstat helper function
Date: Tue, 16 Jun 2015 22:47:24 +0800	[thread overview]
Message-ID: <1434466052-10491-4-git-send-email-tao.peng@primarydata.com> (raw)
In-Reply-To: <1434466052-10491-1-git-send-email-tao.peng@primarydata.com>

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
---
 fs/nfs/nfs42proc.c |  4 ++++
 fs/nfs/pnfs.c      | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/pnfs.h      |  3 +++
 3 files changed, 56 insertions(+)

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index a053041..ee02483 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -198,6 +198,10 @@ static void
 nfs42_layoutstat_release(void *calldata)
 {
 	struct nfs42_layoutstat_data *data = calldata;
+	struct nfs_server *nfss = NFS_SERVER(data->args.inode);
+
+	if (nfss->pnfs_curr_ld->cleanup_layoutstats)
+		nfss->pnfs_curr_ld->cleanup_layoutstats(data);
 
 	pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout);
 	nfs_iput_and_deactive(data->inode);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 2306062..389f7c9 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -35,6 +35,7 @@
 #include "iostat.h"
 #include "nfs4trace.h"
 #include "delegation.h"
+#include "nfs42.h"
 
 #define NFSDBG_FACILITY		NFSDBG_PNFS
 #define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ)
@@ -2247,3 +2248,51 @@ struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)
 	}
 	return thp;
 }
+
+int
+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 nfs42_layoutstat_data *data;
+	struct pnfs_layout_hdr *hdr;
+	int status = 0;
+
+	if (!pnfs_enabled_sb(server) || !ld->prepare_layoutstats)
+		goto out;
+
+	spin_lock(&inode->i_lock);
+	if (!NFS_I(inode)->layout) {
+		spin_unlock(&inode->i_lock);
+		goto out;
+	}
+	hdr = NFS_I(inode)->layout;
+	pnfs_get_layout_hdr(hdr);
+	spin_unlock(&inode->i_lock);
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data) {
+		status = -ENOMEM;
+		goto out_put;
+	}
+
+	data->args.fh = NFS_FH(inode);
+	data->args.inode = inode;
+	nfs4_stateid_copy(&data->args.stateid, &hdr->plh_stateid);
+	status = ld->prepare_layoutstats(&data->args);
+	if (status)
+		goto out_free;
+
+	status = nfs42_proc_layoutstats_generic(NFS_SERVER(inode), data);
+
+out:
+	dprintk("%s returns %d\n", __func__, status);
+	return status;
+
+out_free:
+	kfree(data);
+out_put:
+	pnfs_put_layout_hdr(hdr);
+	goto out;
+}
+EXPORT_SYMBOL_GPL(pnfs_report_layoutstat);
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 1e6308f..0a47239 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -178,6 +178,8 @@ struct pnfs_layoutdriver_type {
 	void (*encode_layoutcommit) (struct pnfs_layout_hdr *lo,
 				     struct xdr_stream *xdr,
 				     const struct nfs4_layoutcommit_args *args);
+	int (*prepare_layoutstats) (struct nfs42_layoutstat_args *args);
+	void (*cleanup_layoutstats) (struct nfs42_layoutstat_data *data);
 };
 
 struct pnfs_layout_hdr {
@@ -290,6 +292,7 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *);
 struct nfs4_threshold *pnfs_mdsthreshold_alloc(void);
 void pnfs_error_mark_layout_for_return(struct inode *inode,
 				       struct pnfs_layout_segment *lseg);
+int pnfs_report_layoutstat(struct inode *inode);
 
 /* nfs4_deviceid_flags */
 enum {
-- 
1.8.3.1


  parent reply	other threads:[~2015-06-16 14:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 14:47 [PATCH 00/11] pnfs/flexfiles: layoutstats support Peng Tao
2015-06-16 14:47 ` [PATCH 01/11] NFSv.2/pnfs Add a LAYOUTSTATS rpc function Peng Tao
2015-06-18 20:14   ` Jeff Layton
2015-06-16 14:47 ` [PATCH 02/11] pNFS: fill in nfs42_layoutstat_ops Peng Tao
2015-06-16 14:47 ` Peng Tao [this message]
2015-06-16 14:47 ` [PATCH 04/11] pNFS/flexfiles: Remove unused struct members user_name, group_name Peng Tao
2015-06-16 14:47 ` [PATCH 05/11] pNFS/flexfiles: add layoutstats tracking Peng Tao
2015-06-16 14:47 ` [PATCH 06/11] pNFS/flexfiles: track when layout is first used Peng Tao
2015-06-18 16:30   ` Jeff Layton
2015-06-16 14:47 ` [PATCH 07/11] pnfs/flexfiles: add ff_layout_prepare_layoutstats Peng Tao
2015-06-16 14:47 ` [PATCH 08/11] pnfs/flexfiles: encode LAYOUTSTATS flexfiles specific data Peng Tao
2015-06-16 14:47 ` [PATCH 09/11] pnfs/flexfiles: reset IO statistics upon LAYOUTSTATS success Peng Tao
2015-06-16 14:47 ` [PATCH 10/11] nfs42: serialize LAYOUTSTATS calls of the same file Peng Tao
2015-06-16 14:47 ` [PATCH 11/11] pnfs/flexfiles: report layoutstat regularly Peng Tao
2015-06-18 20:17 ` [PATCH 00/11] pnfs/flexfiles: layoutstats support Jeff Layton
2015-06-19  1:47   ` Peng Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434466052-10491-4-git-send-email-tao.peng@primarydata.com \
    --to=tao.peng@primarydata.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox