Commit cd5875fe authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: Use layout credentials for get_deviceinfo calls

This is not strictly needed, since get_deviceinfo is not allowed to
return NFS4ERR_ACCESS or NFS4ERR_WRONG_CRED, but lets do it anyway
for consistency with other pNFS operations.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent ab7cb0df
...@@ -1091,7 +1091,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh, ...@@ -1091,7 +1091,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
dev->mincount = 0; dev->mincount = 0;
dprintk("%s: dev_id: %s\n", __func__, dev->dev_id.data); dprintk("%s: dev_id: %s\n", __func__, dev->dev_id.data);
rc = nfs4_proc_getdeviceinfo(server, dev); rc = nfs4_proc_getdeviceinfo(server, dev, NULL);
dprintk("%s getdevice info returns %d\n", __func__, rc); dprintk("%s getdevice info returns %d\n", __func__, rc);
if (rc) { if (rc) {
rv = ERR_PTR(rc); rv = ERR_PTR(rc);
......
...@@ -643,7 +643,8 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, ...@@ -643,7 +643,8 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo,
d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode)->pnfs_curr_ld, d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode)->pnfs_curr_ld,
NFS_SERVER(lo->plh_inode)->nfs_client, id); NFS_SERVER(lo->plh_inode)->nfs_client, id);
if (d == NULL) { if (d == NULL) {
dsaddr = filelayout_get_device_info(lo->plh_inode, id, gfp_flags); dsaddr = filelayout_get_device_info(lo->plh_inode, id,
lo->plh_lc_cred, gfp_flags);
if (dsaddr == NULL) if (dsaddr == NULL)
goto out; goto out;
} else } else
......
...@@ -150,6 +150,7 @@ struct nfs4_pnfs_ds *nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, ...@@ -150,6 +150,7 @@ struct nfs4_pnfs_ds *nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg,
extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr); extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr); extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
struct nfs4_file_layout_dsaddr * struct nfs4_file_layout_dsaddr *
filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags); filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id,
struct rpc_cred *cred, gfp_t gfp_flags);
#endif /* FS_NFS_NFS4FILELAYOUT_H */ #endif /* FS_NFS_NFS4FILELAYOUT_H */
...@@ -668,7 +668,10 @@ decode_and_add_device(struct inode *inode, struct pnfs_device *dev, gfp_t gfp_fl ...@@ -668,7 +668,10 @@ decode_and_add_device(struct inode *inode, struct pnfs_device *dev, gfp_t gfp_fl
* of available devices, and return it. * of available devices, and return it.
*/ */
struct nfs4_file_layout_dsaddr * struct nfs4_file_layout_dsaddr *
filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags) filelayout_get_device_info(struct inode *inode,
struct nfs4_deviceid *dev_id,
struct rpc_cred *cred,
gfp_t gfp_flags)
{ {
struct pnfs_device *pdev = NULL; struct pnfs_device *pdev = NULL;
u32 max_resp_sz; u32 max_resp_sz;
...@@ -709,7 +712,7 @@ filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gf ...@@ -709,7 +712,7 @@ filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gf
pdev->pglen = max_resp_sz; pdev->pglen = max_resp_sz;
pdev->mincount = 0; pdev->mincount = 0;
rc = nfs4_proc_getdeviceinfo(server, pdev); rc = nfs4_proc_getdeviceinfo(server, pdev, cred);
dprintk("%s getdevice info returns %d\n", __func__, rc); dprintk("%s getdevice info returns %d\n", __func__, rc);
if (rc) if (rc)
goto out_free; goto out_free;
......
...@@ -6547,7 +6547,9 @@ int nfs4_proc_getdevicelist(struct nfs_server *server, ...@@ -6547,7 +6547,9 @@ int nfs4_proc_getdevicelist(struct nfs_server *server,
EXPORT_SYMBOL_GPL(nfs4_proc_getdevicelist); EXPORT_SYMBOL_GPL(nfs4_proc_getdevicelist);
static int static int
_nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev) _nfs4_proc_getdeviceinfo(struct nfs_server *server,
struct pnfs_device *pdev,
struct rpc_cred *cred)
{ {
struct nfs4_getdeviceinfo_args args = { struct nfs4_getdeviceinfo_args args = {
.pdev = pdev, .pdev = pdev,
...@@ -6559,6 +6561,7 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev) ...@@ -6559,6 +6561,7 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev)
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETDEVICEINFO], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETDEVICEINFO],
.rpc_argp = &args, .rpc_argp = &args,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred,
}; };
int status; int status;
...@@ -6569,14 +6572,16 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev) ...@@ -6569,14 +6572,16 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev)
return status; return status;
} }
int nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *pdev) int nfs4_proc_getdeviceinfo(struct nfs_server *server,
struct pnfs_device *pdev,
struct rpc_cred *cred)
{ {
struct nfs4_exception exception = { }; struct nfs4_exception exception = { };
int err; int err;
do { do {
err = nfs4_handle_exception(server, err = nfs4_handle_exception(server,
_nfs4_proc_getdeviceinfo(server, pdev), _nfs4_proc_getdeviceinfo(server, pdev, cred),
&exception); &exception);
} while (exception.retry); } while (exception.retry);
return err; return err;
......
...@@ -614,7 +614,8 @@ int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay, ...@@ -614,7 +614,8 @@ int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
pd.pglen = PAGE_SIZE; pd.pglen = PAGE_SIZE;
pd.mincount = 0; pd.mincount = 0;
err = nfs4_proc_getdeviceinfo(NFS_SERVER(pnfslay->plh_inode), &pd); err = nfs4_proc_getdeviceinfo(NFS_SERVER(pnfslay->plh_inode), &pd,
pnfslay->plh_lc_cred);
dprintk("%s nfs_getdeviceinfo returned %d\n", __func__, err); dprintk("%s nfs_getdeviceinfo returned %d\n", __func__, err);
if (err) if (err)
goto err_out; goto err_out;
......
...@@ -170,7 +170,8 @@ extern int nfs4_proc_getdevicelist(struct nfs_server *server, ...@@ -170,7 +170,8 @@ extern int nfs4_proc_getdevicelist(struct nfs_server *server,
const struct nfs_fh *fh, const struct nfs_fh *fh,
struct pnfs_devicelist *devlist); struct pnfs_devicelist *devlist);
extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
struct pnfs_device *dev); struct pnfs_device *dev,
struct rpc_cred *cred);
extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags); extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags);
extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp); extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment