pnfs: factor GETDEVICEINFO implementations
Add support to the common pNFS core to issue GETDEVICEINFO calls on a device ID cache miss. The code is taken from the well debugged file layout implementation and calls out to the layoutdriver through a new alloc_deviceid_node method. The calling conventions for nfs4_find_get_deviceid are changed so that all information needed to send a GETDEVICEINFO request is passed to the common code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:

committed by
Trond Myklebust

parent
848746bd24
commit
661373b13d
@@ -574,76 +574,6 @@ loop_done:
|
||||
dprintk("%s: Return\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get Device Info API for io engines
|
||||
*/
|
||||
struct objlayout_deviceinfo {
|
||||
struct page *page;
|
||||
struct pnfs_osd_deviceaddr da; /* This must be last */
|
||||
};
|
||||
|
||||
/* Initialize and call nfs_getdeviceinfo, then decode and return a
|
||||
* "struct pnfs_osd_deviceaddr *" Eventually objlayout_put_deviceinfo()
|
||||
* should be called.
|
||||
*/
|
||||
int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
|
||||
struct nfs4_deviceid *d_id, struct pnfs_osd_deviceaddr **deviceaddr,
|
||||
gfp_t gfp_flags)
|
||||
{
|
||||
struct objlayout_deviceinfo *odi;
|
||||
struct pnfs_device pd;
|
||||
struct page *page, **pages;
|
||||
u32 *p;
|
||||
int err;
|
||||
|
||||
page = alloc_page(gfp_flags);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
pages = &page;
|
||||
pd.pages = pages;
|
||||
|
||||
memcpy(&pd.dev_id, d_id, sizeof(*d_id));
|
||||
pd.layout_type = LAYOUT_OSD2_OBJECTS;
|
||||
pd.pages = &page;
|
||||
pd.pgbase = 0;
|
||||
pd.pglen = PAGE_SIZE;
|
||||
pd.mincount = 0;
|
||||
pd.maxcount = PAGE_SIZE;
|
||||
|
||||
err = nfs4_proc_getdeviceinfo(NFS_SERVER(pnfslay->plh_inode), &pd,
|
||||
pnfslay->plh_lc_cred);
|
||||
dprintk("%s nfs_getdeviceinfo returned %d\n", __func__, err);
|
||||
if (err)
|
||||
goto err_out;
|
||||
|
||||
p = page_address(page);
|
||||
odi = kzalloc(sizeof(*odi), gfp_flags);
|
||||
if (!odi) {
|
||||
err = -ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
pnfs_osd_xdr_decode_deviceaddr(&odi->da, p);
|
||||
odi->page = page;
|
||||
*deviceaddr = &odi->da;
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
__free_page(page);
|
||||
return err;
|
||||
}
|
||||
|
||||
void objlayout_put_deviceinfo(struct pnfs_osd_deviceaddr *deviceaddr)
|
||||
{
|
||||
struct objlayout_deviceinfo *odi = container_of(deviceaddr,
|
||||
struct objlayout_deviceinfo,
|
||||
da);
|
||||
|
||||
__free_page(odi->page);
|
||||
kfree(odi);
|
||||
}
|
||||
|
||||
enum {
|
||||
OBJLAYOUT_MAX_URI_LEN = 256, OBJLAYOUT_MAX_OSDNAME_LEN = 64,
|
||||
OBJLAYOUT_MAX_SYSID_HEX_LEN = OSD_SYSTEMID_LEN * 2 + 1,
|
||||
|
Reference in New Issue
Block a user