NFS: include filelayout DS rpc stats in mountstats
Subsystems (3)
PATCH 1/1 NFS: include filelayout DS rpc stats in mountstats
Include RPC statistics from all data servers in /proc/self/mountstats for pNFS filelayout mounts.
---
Cleaned up version after comments from Trond. This patch accumulates reads, writes and commits (the only DS operations) on the rpc_iostats of the nfs_server associated with the mount.
I was confused last week about where we breaking counting stats only for a mountpoint -- What I was seeing was two mounts sharing stats if they were the same server AND the same filesystem on the server. This patch does not address that issue.
This patch still counts DS operations on the DS::nfs_client::rpc_clnt's stats structures. Assuming this patch is OK, I plan on submitting a patch that will show MDS-only and individual DS stats somewhere in /proc/fs/nfsfs/.
fs/nfs/nfs4filelayout.c | 19 +++++++++++++++++++ include/linux/sunrpc/metrics.h | 6 ++++-- include/linux/sunrpc/sched.h | 1 + net/sunrpc/stats.c | 8 ++++---- net/sunrpc/xprt.c | 5 ++++- 5 files changed, 32 insertions(+), 7 deletions(-)
fs/nfs/nfs4filelayout.c +19 -0
@@ -33,6 +33,8 @@#include <linux/nfs_page.h> #include <linux/module.h> +#include <linux/sunrpc/metrics.h> +#include "internal.h" #include "nfs4filelayout.h"
@@ -189,6 +191,13 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data) rdata->mds_ops->rpc_call_done (task, data); } +static void filelayout_read_count_stats (struct rpc_task *task,void *data) +{ +struct nfs_read_data *rdata = (struct nfs_read_data *)data; + +rpc_count_iostats (task,NFS_SERVER (rdata->inode)->client->cl_metrics); +} +static void filelayout_read_release (void *data) {struct nfs_read_data *rdata = (struct nfs_read_data *)data;
@@ -268,6 +277,13 @@ static void filelayout_write_call_done(struct rpc_task *task, void *data) wdata->mds_ops->rpc_call_done (task, data); } +static void filelayout_write_count_stats (struct rpc_task *task,void *data) +{ +struct nfs_write_data *wdata = (struct nfs_write_data *)data; + +rpc_count_iostats (task,NFS_SERVER (wdata->inode)->client->cl_metrics); +} +static void filelayout_write_release (void *data) {struct nfs_write_data *wdata = (struct nfs_write_data *)data;
@@ -288,18 +304,21 @@ static void filelayout_commit_release(void *data)struct rpc_call_ops filelayout_read_call_ops = { .rpc_call_prepare = filelayout_read_prepare, .rpc_call_done = filelayout_read_call_done, + .rpc_count_stats = filelayout_read_count_stats, .rpc_release = filelayout_read_release, };struct rpc_call_ops filelayout_write_call_ops = { .rpc_call_prepare = filelayout_write_prepare, .rpc_call_done = filelayout_write_call_done, + .rpc_count_stats = filelayout_write_count_stats, .rpc_release = filelayout_write_release, };struct rpc_call_ops filelayout_commit_call_ops = { .rpc_call_prepare = filelayout_write_prepare, .rpc_call_done = filelayout_write_call_done, + .rpc_count_stats = filelayout_write_count_stats, .rpc_release = filelayout_commit_release, };
include/linux/sunrpc/metrics.h +4 -2
@@ -74,14 +74,16 @@ struct rpc_clnt;#ifdef CONFIG_PROC_FS struct rpc_iostats *rpc_alloc_iostats (struct rpc_clnt *); -void rpc_count_iostats (struct rpc_task *); +void rpc_count_iostats (const struct rpc_task *, +struct rpc_iostats *);void rpc_print_iostats (struct seq_file *,struct rpc_clnt *);void rpc_free_iostats (struct rpc_iostats *);#else /* CONFIG_PROC_FS */ static inline struct rpc_iostats *rpc_alloc_iostats (struct rpc_clnt *clnt) {return NULL ; } -static inline void rpc_count_iostats (struct rpc_task *task) {} +static inline void rpc_count_iostats (const struct rpc_task *task, +struct rpc_iostats *stats) {}static inline void rpc_print_iostats (struct seq_file *seq,struct rpc_clnt *clnt) {}static inline void rpc_free_iostats (struct rpc_iostats *stats) {}
include/linux/sunrpc/sched.h +1 -0
@@ -103,6 +103,7 @@ typedef void (*rpc_action)(struct rpc_task *);struct rpc_call_ops {void (*rpc_call_prepare)(struct rpc_task *,void *);void (*rpc_call_done)(struct rpc_task *,void *); +void (*rpc_count_stats)(struct rpc_task *,void *);void (*rpc_release)(void *); };
net/sunrpc/stats.c +4 -4
@@ -133,20 +133,19 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);/** * rpc_count_iostats - tally up per-task stats * @task: completed rpc_task +* @stats: array of stat structures * * Relies on the caller for serialization. */ -void rpc_count_iostats (struct rpc_task *task) +void rpc_count_iostats (const struct rpc_task *task,struct rpc_iostats *stats) {struct rpc_rqst *req = task->tk_rqstp; -struct rpc_iostats *stats;struct rpc_iostats *op_metrics;ktime_t delta; -if (!task->tk_client || !task->tk_client->cl_metrics || !req) +if (!stats || !req)return ; - stats = task->tk_client->cl_metrics; op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; op_metrics->om_ops++;
@@ -164,6 +163,7 @@ void rpc_count_iostats(struct rpc_task *task) delta =ktime_sub (ktime_get (), task->tk_start); op_metrics->om_execute =ktime_add (op_metrics->om_execute, delta); } +EXPORT_SYMBOL_GPL (rpc_count_iostats);static void _print_name (struct seq_file *seq,unsigned int op,struct rpc_procinfo *procs)
net/sunrpc/xprt.c +4 -1
@@ -1132,7 +1132,10 @@ void xprt_release(struct rpc_task *task)return ; xprt = req->rq_xprt; -rpc_count_iostats (task); +if (task->tk_client) +rpc_count_iostats (task, task->tk_client->cl_metrics); +if (task->tk_ops->rpc_count_stats !=NULL ) + task->tk_ops->rpc_count_stats (task, task->tk_calldata);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);if (xprt->ops->release_request)
Signature · 1 line
1.7.4.4
T24gTW9uLCAyMDEyLTAyLTEzIGF0IDE3OjIyIC0wNTAwLCBXZXN0b24gQW5kcm9zIEFkYW1zb24g d3JvdGU6DQo+IGRpZmYgLS1naXQgYS9uZXQvc3VucnBjL3hwcnQuYyBiL25ldC9zdW5ycGMveHBy dC5jDQo+IGluZGV4IGVmZTU0OTUuLmFiN2EyOGYgMTAwNjQ0DQo+IC0tLSBhL25ldC9zdW5ycGMv eHBydC5jDQo+ICsrKyBiL25ldC9zdW5ycGMveHBydC5jDQo+IEBAIC0xMTMyLDcgKzExMzIsMTAg QEAgdm9pZCB4cHJ0X3JlbGVhc2Uoc3RydWN0IHJwY190YXNrICp0YXNrKQ0KPiAgCQlyZXR1cm47 DQo+ICANCj4gIAl4cHJ0ID0gcmVxLT5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1c3RAbmV0YXBwLmNvbQ0Kd3d3Lm5ldGFw cC5jb20NCg0K
Quoted 20 lines · Trond
Quoted 6 lines · Weston Andros Adamson
net/sunrpc/xprt.c +0
-0@@ -1132,7 +1132,10 @@ void xprt_release(struct rpc_task *task)return ;net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1141
Quoted 10 lines
net/sunrpc/xprt.c +4
-1xprt = req->rq_xprt; -rpc_count_iostats (task); +if (task->tk_client) +rpc_count_iostats (task, task->tk_client->cl_metrics); +if (task->tk_ops->rpc_count_stats !=NULL ) + task->tk_ops->rpc_count_stats (task, task->tk_calldata);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);if (xprt->ops->release_request)2 nits:
Quoted 2 lines
1. Aren't we guaranteed that
task->tk_client!= NULL inxprt_release()?
I wasn't sure -- there is no other reference to tk_client in the xprt_release() path.
It worked fine for *me* without the if statement, but the old rpc_count_iostats (of which this was the only caller) checked if tk_client was NULL and I didn't want to break anything.
Quoted 4 lines
2. Shouldn't we be calling _either_
rpc_count_iostats(), _or_task->tk_ops->rpc_count_stats()? As far as I can see, the nfsstat output will now be double-counting and pNFS reads, writes and commits that are sent to the DS.
No, this doesn't double count with nfsstats. nfsstats uses rpc_clnt::cl_stats (and not rpc_clnt::cl_metrics).
I probably should have done an if/else for this patch -- with the current code, the DSs' rpc_clnt:cl_metrics will never be used.
I left it accumulating here because we want to have per-DS stats eventually and my plan was to print out stats in /proc/fs/nfsfs per *client* (so not separated by mountpoint).
I can repost with if/else, but looking at this some more made me realize that we are *still* doing this wrong :)
The callback method in this patch fails to accumulate stats for operations to the DS other than read/write/commit -- that seems right, but what about null, exchange_id, session heartbeats, etc?
In order to properly accumulate those we are back to two obvious choices:
1) add a count_iostats callback to the ~25 other rpc_call_ops in nfs-land (yuck)
2) add an 'additional stats' pointer to the rpc_task structure (trond already said you don't want to add to task struct)
Or do we just not care about displaying those operations? For my purposes (nfsometer perf testing), it'd be nice to have *all* of the operations.
-dros
Quoted 40 lines · Dros
Quoted 20 lines · Trond
Quoted 6 lines · Weston Andros Adamson
net/sunrpc/xprt.c +0
-0@@ -1132,7 +1132,10 @@ void xprt_release(struct rpc_task *task)return ;net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1141
Quoted 10 lines
net/sunrpc/xprt.c +4
-1xprt = req->rq_xprt; -rpc_count_iostats (task); +if (task->tk_client) +rpc_count_iostats (task, task->tk_client->cl_metrics); +if (task->tk_ops->rpc_count_stats !=NULL ) + task->tk_ops->rpc_count_stats (task, task->tk_calldata);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);if (xprt->ops->release_request)2 nits:
Quoted 2 lines
1. Aren't we guaranteed that
task->tk_client!= NULL inxprt_release()?I wasn't sure -- there is no other reference to
tk_clientin thexprt_release()path.
It worked fine for *me* without the if statement, but the oldrpc_count_iostats(of which this was the only caller) checked iftk_clientwas NULL and I didn't want to break anything.Quoted 4 lines
2. Shouldn't we be calling _either_
rpc_count_iostats(), _or_task->tk_ops->rpc_count_stats()? As far as I can see, the nfsstat output will now be double-counting and pNFS reads, writes and commits that are sent to the DS.No, this doesn't double count with nfsstats. nfsstats uses
rpc_clnt::cl_stats(and notrpc_clnt::cl_metrics).I probably should have done an if/else for this patch -- with the current code, the DSs' rpc_clnt:cl_metrics will never be used.
I left it accumulating here because we want to have per-DS stats eventually and my plan was to print out stats in/proc/fs/nfsfsper *client* (so not separated by mountpoint).
Quoted 6 lines
I can repost with if/else, but looking at this some more made me realize that we are *still* doing this wrong :)
The callback method in this patch fails to accumulate stats for operations to the DS other than read/write/commit -- that seems right, but what about null,
exchange_id, session heartbeats, etc?In order to properly accumulate those we are back to two obvious choices:
1) add acount_iostatscallback to the ~25 otherrpc_call_opsin nfs-land (yuck)
^^ i guess it wouldn't have to be all of them, but this gets ugly quick.
Quoted 5 lines
2) add an 'additional stats' pointer to the
rpc_taskstructure (trond already said you don't want to add to task struct)Or do we just not care about displaying those operations? For my purposes (nfs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hlIG9wZXJhdGlvbnMuDQoNCkFzIGZhciBh cyBJJ20gY29uY2VybmVkLCB0aGUgYWRtaW5pc3RyYXRpdmUgdHJhZmZpYyB0byB0aGUgRFMgc2hv dWxkIG5vdA0KYmUgYWNjb3VudGVkIGZvciBpbiB0aGUgbW91bnRzdGF0czogdGhhdCB3b3VsZCBi ZSB3cm9uZyBzaW5jZSBEU2VzIGNhbg0KYmUgc2hhcmVkIG5vdCBvbmx5IGJ5IGRpZmZlcmVudCBm aWxlc3lzdGVtcyBidXQgZXZlbiBieSBkaWZmZXJlbnQgTURTZXMuDQoNClNvIHRoZSBwZXJmb3Jt YW5jZSBvdmVyaGVhZCBvZiBsZWFzZSBhbmQgc2Vzc2lvbiBzZXR1cCB0byB0aGUgRFNlcyBuZWVk cw0KdG8gYmUgYWNjb3VudGVkIGZvciBieSBzb21lIG90aGVyIG1lY2hhbmlzbS4NCg0KLS0gDQpU cm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lcg0KDQpOZXRBcHANClRy b25kLk15a2xlYnVzdEBuZXRhcHAuY29tDQp3d3cubmV0YXBwLmNvbQ0KDQo=
Quoted 21 lines · Trond
Quoted 20 lines · Dros
Quoted 4 lines · Trond
2. Shouldn't we be calling _either_
rpc_count_iostats(), _or_task->tk_ops->rpc_count_stats()? As far as I can see, the nfsstat output will now be double-counting and pNFS reads, writes and commits that are sent to the DS.No, this doesn't double count with nfsstats. nfsstats uses
rpc_clnt::cl_stats(and notrpc_clnt::cl_metrics).I probably should have done an if/else for this patch -- with the current code, the DSs' rpc_clnt:cl_metrics will never be used.
I left it accumulating here because we want to have per-DS stats eventually and my plan was to print out stats in/proc/fs/nfsfsper *client* (so not separated by mountpoint).I can repost with if/else, but looking at this some more made me realize that we are *still* doing this wrong :)
The callback method in this patch fails to accumulate stats for operations to the DS other than read/write/commit -- that seems right, but what about null,
exchange_id, session heartbeats, etc?In order to properly accumulate those we are back to two obvious choices:
1) add acount_iostatscallback to the ~25 otherrpc_call_opsin nfs-land (yuck)
2) add an 'additional stats' pointer to therpc_taskstructure (trond already said you don't want to add to task struct)
Quoted 8 lines
Quoted 1 line
Or do we just not care about displaying those operations? For my purposes (nfsometer perf testing), it'd be nice to have *all* of the operations.
As far as I'm concerned, the administrative traffic to the DS should not be accounted for in the mountstats: that would be wrong since DSes can be shared not only by different filesystems but even by different MDSes.
So the performance overhead of lease and session setup to the DSes needs to be accounted for by some other mechanism.
Fair enough. The per-client stats should help me with that.
I'll repost with if/else and change it back with the next stats patch.
-dros