Skip to content

Commit 9dd2fcd

Browse files
Christoph Hellwigtrondmypd
authored andcommitted
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>
1 parent 661373b commit 9dd2fcd

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎fs/nfs/pnfs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *);
277277
void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node);
278278
bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node);
279279
void nfs4_deviceid_purge_client(const struct nfs_client *);
280+
int nfs4_deviceid_getdevicelist(struct nfs_server *server,
281+
const struct nfs_fh *fh);
280282

281283
static inline struct pnfs_layout_segment *
282284
pnfs_get_lseg(struct pnfs_layout_segment *lseg)

‎fs/nfs/pnfs_dev.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,32 @@ nfs4_deviceid_mark_client_invalid(struct nfs_client *clp)
359359
rcu_read_unlock();
360360
}
361361

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);

0 commit comments

Comments
 (0)