diff options
-rw-r--r-- | fs/nfs/nfs4filelayout.c | 19 | ||||
-rw-r--r-- | include/linux/sunrpc/metrics.h | 6 | ||||
-rw-r--r-- | include/linux/sunrpc/sched.h | 1 | ||||
-rw-r--r-- | net/sunrpc/stats.c | 8 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 5 |
5 files changed, 32 insertions, 7 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index 79be7acc9bae..47e8f3435d38 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/nfs_page.h> | 33 | #include <linux/nfs_page.h> |
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | 35 | ||
36 | #include <linux/sunrpc/metrics.h> | ||
37 | |||
36 | #include "internal.h" | 38 | #include "internal.h" |
37 | #include "nfs4filelayout.h" | 39 | #include "nfs4filelayout.h" |
38 | 40 | ||
@@ -189,6 +191,13 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data) | |||
189 | rdata->mds_ops->rpc_call_done(task, data); | 191 | rdata->mds_ops->rpc_call_done(task, data); |
190 | } | 192 | } |
191 | 193 | ||
194 | static void filelayout_read_count_stats(struct rpc_task *task, void *data) | ||
195 | { | ||
196 | struct nfs_read_data *rdata = (struct nfs_read_data *)data; | ||
197 | |||
198 | rpc_count_iostats(task, NFS_SERVER(rdata->inode)->client->cl_metrics); | ||
199 | } | ||
200 | |||
192 | static void filelayout_read_release(void *data) | 201 | static void filelayout_read_release(void *data) |
193 | { | 202 | { |
194 | struct nfs_read_data *rdata = (struct nfs_read_data *)data; | 203 | 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) | |||
268 | wdata->mds_ops->rpc_call_done(task, data); | 277 | wdata->mds_ops->rpc_call_done(task, data); |
269 | } | 278 | } |
270 | 279 | ||
280 | static void filelayout_write_count_stats(struct rpc_task *task, void *data) | ||
281 | { | ||
282 | struct nfs_write_data *wdata = (struct nfs_write_data *)data; | ||
283 | |||
284 | rpc_count_iostats(task, NFS_SERVER(wdata->inode)->client->cl_metrics); | ||
285 | } | ||
286 | |||
271 | static void filelayout_write_release(void *data) | 287 | static void filelayout_write_release(void *data) |
272 | { | 288 | { |
273 | struct nfs_write_data *wdata = (struct nfs_write_data *)data; | 289 | struct nfs_write_data *wdata = (struct nfs_write_data *)data; |
@@ -288,18 +304,21 @@ static void filelayout_commit_release(void *data) | |||
288 | struct rpc_call_ops filelayout_read_call_ops = { | 304 | struct rpc_call_ops filelayout_read_call_ops = { |
289 | .rpc_call_prepare = filelayout_read_prepare, | 305 | .rpc_call_prepare = filelayout_read_prepare, |
290 | .rpc_call_done = filelayout_read_call_done, | 306 | .rpc_call_done = filelayout_read_call_done, |
307 | .rpc_count_stats = filelayout_read_count_stats, | ||
291 | .rpc_release = filelayout_read_release, | 308 | .rpc_release = filelayout_read_release, |
292 | }; | 309 | }; |
293 | 310 | ||
294 | struct rpc_call_ops filelayout_write_call_ops = { | 311 | struct rpc_call_ops filelayout_write_call_ops = { |
295 | .rpc_call_prepare = filelayout_write_prepare, | 312 | .rpc_call_prepare = filelayout_write_prepare, |
296 | .rpc_call_done = filelayout_write_call_done, | 313 | .rpc_call_done = filelayout_write_call_done, |
314 | .rpc_count_stats = filelayout_write_count_stats, | ||
297 | .rpc_release = filelayout_write_release, | 315 | .rpc_release = filelayout_write_release, |
298 | }; | 316 | }; |
299 | 317 | ||
300 | struct rpc_call_ops filelayout_commit_call_ops = { | 318 | struct rpc_call_ops filelayout_commit_call_ops = { |
301 | .rpc_call_prepare = filelayout_write_prepare, | 319 | .rpc_call_prepare = filelayout_write_prepare, |
302 | .rpc_call_done = filelayout_write_call_done, | 320 | .rpc_call_done = filelayout_write_call_done, |
321 | .rpc_count_stats = filelayout_write_count_stats, | ||
303 | .rpc_release = filelayout_commit_release, | 322 | .rpc_release = filelayout_commit_release, |
304 | }; | 323 | }; |
305 | 324 | ||
diff --git a/include/linux/sunrpc/metrics.h b/include/linux/sunrpc/metrics.h index b6edbc0ea83d..1565bbe86d51 100644 --- a/include/linux/sunrpc/metrics.h +++ b/include/linux/sunrpc/metrics.h | |||
@@ -74,14 +74,16 @@ struct rpc_clnt; | |||
74 | #ifdef CONFIG_PROC_FS | 74 | #ifdef CONFIG_PROC_FS |
75 | 75 | ||
76 | struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *); | 76 | struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *); |
77 | void rpc_count_iostats(struct rpc_task *); | 77 | void rpc_count_iostats(const struct rpc_task *, |
78 | struct rpc_iostats *); | ||
78 | void rpc_print_iostats(struct seq_file *, struct rpc_clnt *); | 79 | void rpc_print_iostats(struct seq_file *, struct rpc_clnt *); |
79 | void rpc_free_iostats(struct rpc_iostats *); | 80 | void rpc_free_iostats(struct rpc_iostats *); |
80 | 81 | ||
81 | #else /* CONFIG_PROC_FS */ | 82 | #else /* CONFIG_PROC_FS */ |
82 | 83 | ||
83 | static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; } | 84 | static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; } |
84 | static inline void rpc_count_iostats(struct rpc_task *task) {} | 85 | static inline void rpc_count_iostats(const struct rpc_task *task, |
86 | struct rpc_iostats *stats) {} | ||
85 | static inline void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) {} | 87 | static inline void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) {} |
86 | static inline void rpc_free_iostats(struct rpc_iostats *stats) {} | 88 | static inline void rpc_free_iostats(struct rpc_iostats *stats) {} |
87 | 89 | ||
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 22dfc24013b6..dc0c3cc3ada3 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h | |||
@@ -103,6 +103,7 @@ typedef void (*rpc_action)(struct rpc_task *); | |||
103 | struct rpc_call_ops { | 103 | struct rpc_call_ops { |
104 | void (*rpc_call_prepare)(struct rpc_task *, void *); | 104 | void (*rpc_call_prepare)(struct rpc_task *, void *); |
105 | void (*rpc_call_done)(struct rpc_task *, void *); | 105 | void (*rpc_call_done)(struct rpc_task *, void *); |
106 | void (*rpc_count_stats)(struct rpc_task *, void *); | ||
106 | void (*rpc_release)(void *); | 107 | void (*rpc_release)(void *); |
107 | }; | 108 | }; |
108 | 109 | ||
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 3c4f6888c891..1eb3304bc105 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c | |||
@@ -133,20 +133,19 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats); | |||
133 | /** | 133 | /** |
134 | * rpc_count_iostats - tally up per-task stats | 134 | * rpc_count_iostats - tally up per-task stats |
135 | * @task: completed rpc_task | 135 | * @task: completed rpc_task |
136 | * @stats: array of stat structures | ||
136 | * | 137 | * |
137 | * Relies on the caller for serialization. | 138 | * Relies on the caller for serialization. |
138 | */ | 139 | */ |
139 | void rpc_count_iostats(struct rpc_task *task) | 140 | void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats) |
140 | { | 141 | { |
141 | struct rpc_rqst *req = task->tk_rqstp; | 142 | struct rpc_rqst *req = task->tk_rqstp; |
142 | struct rpc_iostats *stats; | ||
143 | struct rpc_iostats *op_metrics; | 143 | struct rpc_iostats *op_metrics; |
144 | ktime_t delta; | 144 | ktime_t delta; |
145 | 145 | ||
146 | if (!task->tk_client || !task->tk_client->cl_metrics || !req) | 146 | if (!stats || !req) |
147 | return; | 147 | return; |
148 | 148 | ||
149 | stats = task->tk_client->cl_metrics; | ||
150 | op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; | 149 | op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; |
151 | 150 | ||
152 | op_metrics->om_ops++; | 151 | op_metrics->om_ops++; |
@@ -164,6 +163,7 @@ void rpc_count_iostats(struct rpc_task *task) | |||
164 | delta = ktime_sub(ktime_get(), task->tk_start); | 163 | delta = ktime_sub(ktime_get(), task->tk_start); |
165 | op_metrics->om_execute = ktime_add(op_metrics->om_execute, delta); | 164 | op_metrics->om_execute = ktime_add(op_metrics->om_execute, delta); |
166 | } | 165 | } |
166 | EXPORT_SYMBOL_GPL(rpc_count_iostats); | ||
167 | 167 | ||
168 | static void _print_name(struct seq_file *seq, unsigned int op, | 168 | static void _print_name(struct seq_file *seq, unsigned int op, |
169 | struct rpc_procinfo *procs) | 169 | struct rpc_procinfo *procs) |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 739df8a11382..32e37945a840 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -1137,7 +1137,10 @@ void xprt_release(struct rpc_task *task) | |||
1137 | return; | 1137 | return; |
1138 | 1138 | ||
1139 | xprt = req->rq_xprt; | 1139 | xprt = req->rq_xprt; |
1140 | rpc_count_iostats(task); | 1140 | if (task->tk_ops->rpc_count_stats != NULL) |
1141 | task->tk_ops->rpc_count_stats(task, task->tk_calldata); | ||
1142 | else if (task->tk_client) | ||
1143 | rpc_count_iostats(task, task->tk_client->cl_metrics); | ||
1141 | spin_lock_bh(&xprt->transport_lock); | 1144 | spin_lock_bh(&xprt->transport_lock); |
1142 | xprt->ops->release_xprt(xprt, task); | 1145 | xprt->ops->release_xprt(xprt, task); |
1143 | if (xprt->ops->release_request) | 1146 | if (xprt->ops->release_request) |