[pnfs] [PATCH 09/10] pnfs: Move getdevicelist client to draft 19
Dean Hildebrand
seattleplus at gmail.com
Thu Feb 7 21:58:56 EST 2008
Signed-off-by: Dean Hildebrand <dhildeb at us.ibm.com>
---
fs/nfs/nfs4filelayout.c | 7 +----
fs/nfs/nfs4filelayout.h | 3 ++
fs/nfs/nfs4filelayoutdev.c | 29 +++++++++++++---------
fs/nfs/nfs4xdr.c | 56 ++++++++++++++-----------------------------
include/linux/nfs4_pnfs.h | 8 ++----
5 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 3453f2b..03b64e0 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -111,11 +111,8 @@ filelayout_initialize_mountpoint(struct super_block *sb, struct nfs_fh *fh)
if (status)
goto cleanup_mt;
- /*
- * Decode opaque devicelist and add to list of available
- * devices (data servers
- */
- status = decode_and_add_devicelist(fl_mt, dlist);
+ /* Retrieve and add all available devices */
+ status = process_deviceid_list(fl_mt, fh, dlist);
if (status)
goto cleanup_mt;
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
index f92f76a..e401da8 100644
--- a/fs/nfs/nfs4filelayout.h
+++ b/fs/nfs/nfs4filelayout.h
@@ -116,6 +116,9 @@ int nfs4_pnfs_dserver_get(struct inode *inode,
size_t count,
struct nfs4_pnfs_dserver *dserver);
int decode_and_add_devicelist(struct filelayout_mount_type *mt, struct pnfs_devicelist *devlist);
+int process_deviceid_list(struct filelayout_mount_type *mt,
+ struct nfs_fh *fh,
+ struct pnfs_devicelist *devlist);
#define READ32(x) (x) = ntohl(*p++)
#define READ64(x) do { \
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
index 0b447b8..7d18230 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -64,6 +64,10 @@ extern int _nfs4_proc_exchange_id(struct nfs_client *, struct rpc_cred *);
extern struct pnfs_client_operations *pnfs_callback_ops;
+struct nfs4_pnfs_dev_item *nfs4_pnfs_device_item_get(struct filelayout_mount_type *mt,
+ struct nfs_fh *fh,
+ pnfs_deviceid *dev_id);
+
void
print_ds_list(struct nfs4_pnfs_dev *fdev)
{
@@ -610,28 +614,29 @@ decode_and_add_device(struct filelayout_mount_type *mt, struct pnfs_device *dev)
return file_dev;
}
-/* Decode the opaque device list in 'devlist'
- * and add it to the list of available devices for this
+/* For each deviceid, if not already in the cache,
+ * call getdeviceinfo and add the devices associated with
+ * the deviceid to the list of available devices for this
* mount point.
* Must at some point be followed up with device_destroy.
*/
int
-decode_and_add_devicelist(struct filelayout_mount_type *mt, struct pnfs_devicelist *devlist)
+process_deviceid_list(struct filelayout_mount_type *mt,
+ struct nfs_fh *fh,
+ struct pnfs_devicelist *devlist)
{
- int i, cnt;
+ int i;
- dprintk("%s invoked. num_devs=%d\n", __FUNCTION__, devlist->num_devs);
+ dprintk("%s num_devs=%d\n", __func__, devlist->num_devs);
- for (i = 0, cnt = 0;
- i < devlist->num_devs && cnt < NFS4_PNFS_DEV_MAXNUM;
- i++) {
- if (!decode_and_add_device(mt, &devlist->devs[cnt])) {
- dprintk("%s error count=%d\n", __FUNCTION__, cnt);
+ for (i = 0; i < devlist->num_devs; i++) {
+ if (!nfs4_pnfs_device_item_get(mt, fh, &devlist->dev_id[i])) {
+ printk(KERN_WARNING "%s Error retrieving device %d\n",
+ __func__, i);
return 1;
}
- cnt++;
}
- dprintk("%s success\n", __FUNCTION__);
+ dprintk("%s success\n", __func__);
return 0;
}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index e2e4f45..67e5262 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -270,12 +270,12 @@ static int nr_sequence_quads;
XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
#endif /* CONFIG_NFS_V4_1 */
#if defined(CONFIG_PNFS)
-#define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \
- (NFS4_VERIFIER_SIZE >> 2))
-#define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + 6 + \
- NFS4_PNFS_DEV_MAXNUM * \
- (NFS4_PNFS_DEVICEID4_SIZE + 2 + \
- NFS4_PNFS_DEV_MAXSIZE))
+#define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \
+ encode_verifier_maxsz)
+#define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + \
+ decode_verifier_maxsz + \
+ XDR_QUADLEN(NFS4_PNFS_DEV_MAXNUM * \
+ NFS4_PNFS_DEVICEID4_SIZE))
#define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \
XDR_QUADLEN(NFS4_PNFS_DEVICEID4_SIZE))
#define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + 4 + \
@@ -1812,9 +1812,9 @@ static int encode_getdevicelist(struct xdr_stream *xdr, const struct nfs4_pnfs_g
RESERVE_SPACE(20);
WRITE32(OP_GETDEVICELIST);
- WRITE32(args->layoutclass); /* layout type */
- WRITE32(NFS4_PNFS_DEV_MAXNUM * NFS4_PNFS_DEV_MAXSIZE); /* maxcount */
- WRITE64(0ULL); /* cookie */
+ WRITE32(args->layoutclass);
+ WRITE32(NFS4_PNFS_DEV_MAXNUM);
+ WRITE64(0ULL); /* cookie */
encode_nfs4_verifier(xdr, &dummy);
return 0;
@@ -5461,13 +5461,12 @@ static int decode_sequence(struct xdr_stream *xdr,
#ifdef CONFIG_PNFS
/*
* Decode getdevicelist results for pNFS.
- * TODO: Need to match this xdr with the server.
+ * TODO: Need to handle case when EOF != true;
*/
static int decode_getdevicelist(struct xdr_stream *xdr, struct pnfs_devicelist *res)
{
- uint32_t *p;
- int status, i, cnt;
- uint32_t len = 0, total_len = 0;
+ __be32 *p;
+ int status, i;
struct nfs_writeverf verftemp;
status = decode_op_hdr(xdr, OP_GETDEVICELIST);
@@ -5485,36 +5484,17 @@ static int decode_getdevicelist(struct xdr_stream *xdr, struct pnfs_devicelist *
READ_BUF(4);
READ32(res->num_devs);
- for (i = 0, cnt = 0;
- i < res->num_devs && cnt < NFS4_PNFS_DEV_MAXNUM;
- i++) {
- READ_BUF(NFS4_PNFS_DEVICEID4_SIZE);
- COPYMEM(res->devs[cnt].dev_id.data, NFS4_PNFS_DEVICEID4_SIZE);
+ dprintk("%s: num_dev %d \n", __func__, res->num_devs);
- READ_BUF(4);
- READ32(res->layout_type);
+ if (res->num_devs > NFS4_PNFS_DEV_MAXNUM)
+ return -NFS4ERR_REP_TOO_BIG;
- READ_BUF(4);
- READ32(len);
- dprintk("%s: num_dev %d i %d cnt %d len %d\n",
- __FUNCTION__, res->num_devs, i, cnt, len);
-
- READ_BUF(len);
-
- /* DH-TODO: Can I decode this inline? Is the xdr_stream
- * memory valid after the completion of this function?
- */
- /* decode_opaque_inline(xdr, &len, &r_addr); */
- COPYMEM(&res->devs[cnt].dev_addr_buf, len);
- res->devs[cnt].dev_addr_len = len;
-
- total_len += len;
- cnt++;
+ for (i = 0; i < res->num_devs; i++) {
+ READ_BUF(NFS4_PNFS_DEVICEID4_SIZE);
+ COPYMEM(res->dev_id[i].data, NFS4_PNFS_DEVICEID4_SIZE);
}
READ_BUF(4);
READ32(res->eof);
-
- res->devs_len = total_len;
return 0;
}
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index ed230f4..67fb309 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -191,11 +191,9 @@ struct pnfs_device {
};
struct pnfs_devicelist {
- unsigned int layout_type;
- unsigned int num_devs;
- unsigned int eof;
- unsigned int devs_len;
- struct pnfs_device devs[NFS4_PNFS_DEV_MAXNUM];
+ unsigned int eof;
+ unsigned int num_devs;
+ pnfs_deviceid dev_id[NFS4_PNFS_DEV_MAXNUM];
};
/* pNFS client callback functions.
--
1.5.3.3
More information about the pNFS
mailing list