diff options
author | Peng Tao <tao.peng@primarydata.com> | 2015-06-23 07:51:57 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-06-24 10:17:37 -0400 |
commit | 8733408d6ed713d080c325262d7b51a780136d41 (patch) | |
tree | b9ea8f53679041ac09ce05f6bfd43d6d61c40c7e | |
parent | 1b4a4bd82c308aed36f13fff4beb33d3840cfa0e (diff) |
pnfs: add pnfs_report_layoutstat helper function
Reviewed-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r-- | fs/nfs/nfs42proc.c | 4 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 49 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 3 |
3 files changed, 56 insertions, 0 deletions
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index a0530418255f..ee0248340a42 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c | |||
@@ -198,6 +198,10 @@ static void | |||
198 | nfs42_layoutstat_release(void *calldata) | 198 | nfs42_layoutstat_release(void *calldata) |
199 | { | 199 | { |
200 | struct nfs42_layoutstat_data *data = calldata; | 200 | struct nfs42_layoutstat_data *data = calldata; |
201 | struct nfs_server *nfss = NFS_SERVER(data->args.inode); | ||
202 | |||
203 | if (nfss->pnfs_curr_ld->cleanup_layoutstats) | ||
204 | nfss->pnfs_curr_ld->cleanup_layoutstats(data); | ||
201 | 205 | ||
202 | pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout); | 206 | pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout); |
203 | nfs_iput_and_deactive(data->inode); | 207 | nfs_iput_and_deactive(data->inode); |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d47c188682b1..6279cff7df74 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "iostat.h" | 35 | #include "iostat.h" |
36 | #include "nfs4trace.h" | 36 | #include "nfs4trace.h" |
37 | #include "delegation.h" | 37 | #include "delegation.h" |
38 | #include "nfs42.h" | ||
38 | 39 | ||
39 | #define NFSDBG_FACILITY NFSDBG_PNFS | 40 | #define NFSDBG_FACILITY NFSDBG_PNFS |
40 | #define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ) | 41 | #define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ) |
@@ -2250,3 +2251,51 @@ struct nfs4_threshold *pnfs_mdsthreshold_alloc(void) | |||
2250 | } | 2251 | } |
2251 | return thp; | 2252 | return thp; |
2252 | } | 2253 | } |
2254 | |||
2255 | int | ||
2256 | pnfs_report_layoutstat(struct inode *inode) | ||
2257 | { | ||
2258 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; | ||
2259 | struct nfs_server *server = NFS_SERVER(inode); | ||
2260 | struct nfs42_layoutstat_data *data; | ||
2261 | struct pnfs_layout_hdr *hdr; | ||
2262 | int status = 0; | ||
2263 | |||
2264 | if (!pnfs_enabled_sb(server) || !ld->prepare_layoutstats) | ||
2265 | goto out; | ||
2266 | |||
2267 | spin_lock(&inode->i_lock); | ||
2268 | if (!NFS_I(inode)->layout) { | ||
2269 | spin_unlock(&inode->i_lock); | ||
2270 | goto out; | ||
2271 | } | ||
2272 | hdr = NFS_I(inode)->layout; | ||
2273 | pnfs_get_layout_hdr(hdr); | ||
2274 | spin_unlock(&inode->i_lock); | ||
2275 | |||
2276 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
2277 | if (!data) { | ||
2278 | status = -ENOMEM; | ||
2279 | goto out_put; | ||
2280 | } | ||
2281 | |||
2282 | data->args.fh = NFS_FH(inode); | ||
2283 | data->args.inode = inode; | ||
2284 | nfs4_stateid_copy(&data->args.stateid, &hdr->plh_stateid); | ||
2285 | status = ld->prepare_layoutstats(&data->args); | ||
2286 | if (status) | ||
2287 | goto out_free; | ||
2288 | |||
2289 | status = nfs42_proc_layoutstats_generic(NFS_SERVER(inode), data); | ||
2290 | |||
2291 | out: | ||
2292 | dprintk("%s returns %d\n", __func__, status); | ||
2293 | return status; | ||
2294 | |||
2295 | out_free: | ||
2296 | kfree(data); | ||
2297 | out_put: | ||
2298 | pnfs_put_layout_hdr(hdr); | ||
2299 | goto out; | ||
2300 | } | ||
2301 | EXPORT_SYMBOL_GPL(pnfs_report_layoutstat); | ||
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 1e6308f82fc3..0a4723945db2 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -178,6 +178,8 @@ struct pnfs_layoutdriver_type { | |||
178 | void (*encode_layoutcommit) (struct pnfs_layout_hdr *lo, | 178 | void (*encode_layoutcommit) (struct pnfs_layout_hdr *lo, |
179 | struct xdr_stream *xdr, | 179 | struct xdr_stream *xdr, |
180 | const struct nfs4_layoutcommit_args *args); | 180 | const struct nfs4_layoutcommit_args *args); |
181 | int (*prepare_layoutstats) (struct nfs42_layoutstat_args *args); | ||
182 | void (*cleanup_layoutstats) (struct nfs42_layoutstat_data *data); | ||
181 | }; | 183 | }; |
182 | 184 | ||
183 | struct pnfs_layout_hdr { | 185 | struct pnfs_layout_hdr { |
@@ -290,6 +292,7 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *); | |||
290 | struct nfs4_threshold *pnfs_mdsthreshold_alloc(void); | 292 | struct nfs4_threshold *pnfs_mdsthreshold_alloc(void); |
291 | void pnfs_error_mark_layout_for_return(struct inode *inode, | 293 | void pnfs_error_mark_layout_for_return(struct inode *inode, |
292 | struct pnfs_layout_segment *lseg); | 294 | struct pnfs_layout_segment *lseg); |
295 | int pnfs_report_layoutstat(struct inode *inode); | ||
293 | 296 | ||
294 | /* nfs4_deviceid_flags */ | 297 | /* nfs4_deviceid_flags */ |
295 | enum { | 298 | enum { |