diff options
author | Christoph Hellwig <hch@lst.de> | 2014-09-03 00:27:58 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-09-10 15:47:04 -0400 |
commit | 9dd2fcd32f488ea89c2227cc56069446147376e8 (patch) | |
tree | 30ea4e772c5c64cdf8120ad960b0910f622a92bf /fs/nfs | |
parent | 661373b13d0490ff410a2133d4a7a117f2dd037e (diff) |
pnfs: add a common GETDEVICELIST implementation
At a simple helper to issue a GETDEVICELIST operation and pre-load
the device id cache based on the result.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/pnfs.h | 2 | ||||
-rw-r--r-- | fs/nfs/pnfs_dev.c | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index ce89ae364bb8..3eeca49d9ca2 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -277,6 +277,8 @@ bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *); | |||
277 | void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node); | 277 | void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node); |
278 | bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); | 278 | bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); |
279 | void nfs4_deviceid_purge_client(const struct nfs_client *); | 279 | void nfs4_deviceid_purge_client(const struct nfs_client *); |
280 | int nfs4_deviceid_getdevicelist(struct nfs_server *server, | ||
281 | const struct nfs_fh *fh); | ||
280 | 282 | ||
281 | static inline struct pnfs_layout_segment * | 283 | static inline struct pnfs_layout_segment * |
282 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) | 284 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) |
diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c index 791f8b3c4cff..82c2836fdb38 100644 --- a/fs/nfs/pnfs_dev.c +++ b/fs/nfs/pnfs_dev.c | |||
@@ -359,3 +359,32 @@ nfs4_deviceid_mark_client_invalid(struct nfs_client *clp) | |||
359 | rcu_read_unlock(); | 359 | rcu_read_unlock(); |
360 | } | 360 | } |
361 | 361 | ||
362 | int | ||
363 | nfs4_deviceid_getdevicelist(struct nfs_server *server, | ||
364 | const struct nfs_fh *fh) | ||
365 | { | ||
366 | struct pnfs_devicelist *dlist; | ||
367 | struct nfs4_deviceid_node *d; | ||
368 | int error = 0, i; | ||
369 | |||
370 | dlist = kzalloc(sizeof(struct pnfs_devicelist), GFP_NOFS); | ||
371 | if (!dlist) | ||
372 | return -ENOMEM; | ||
373 | |||
374 | while (!dlist->eof) { | ||
375 | error = nfs4_proc_getdevicelist(server, fh, dlist); | ||
376 | if (error) | ||
377 | break; | ||
378 | |||
379 | for (i = 0; i < dlist->num_devs; i++) { | ||
380 | d = nfs4_find_get_deviceid(server, &dlist->dev_id[i], | ||
381 | NULL, GFP_NOFS); | ||
382 | if (d) | ||
383 | nfs4_put_deviceid_node(d); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | kfree(dlist); | ||
388 | return error; | ||
389 | } | ||
390 | EXPORT_SYMBOL_GPL(nfs4_deviceid_getdevicelist); | ||