Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd5875fe authored by Trond Myklebust's avatar Trond Myklebust
Browse files

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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);
+2 −1
Original line number Original line Diff line number Diff line
@@ -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
+2 −1
Original line number Original line Diff line number Diff line
@@ -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 */
+5 −2
Original line number Original line Diff line number Diff line
@@ -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
	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;
+8 −3
Original line number Original line Diff line number Diff line
@@ -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)
		.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)
	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;
Loading