[pnfs] [PATCH 03/13] pnfsd: Simplify getdeviceinfo export ops.
seattleplus at gmail.com
seattleplus at gmail.com
Thu Jan 10 16:38:54 EST 2008
From: Dean Hildebrand <dhildeb at hipernas.almaden.ibm.com>
The current device export ops retrieve the device, encode it, and them free it,
which is quite cumbersome and requires extra data copies. We want to move towards
an interface like readdir, which has only a single vfs op,
This patch replaces get_deviceinfo, devaddr_free, and devaddr_encode with
get_device_info, which will encode the device info for the supplied device
id onto the output stream.
get_device_info takes a function pointer pnfs_encodedev_t as an argument.
This argument allows NFSD to supply a function to encode the device, instead
of having the file system do the encoding. The file system takes the
pnfs_encodedev_t argument and uses it to encode its devices.
pnfs_encodedev_t is only useful for layout types which exist in the kernel,
i.e., only file layout for now, object andblock will set this
function pointer to NULL. In the future, when object or block
is in the kernel, they can use this function to move
device encoding into the common nfsd code.
Signed-off-by: Dean Hildebrand <dhildeb at us.ibm.com>
---
include/linux/exportfs.h | 45 +++++++++++++++++++++++++++++++++-----
include/linux/nfsd/nfsd4_pnfs.h | 11 ++++-----
2 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 384d957..77c27a7 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -35,6 +35,35 @@ enum fid_type {
FILEID_INO32_GEN_PARENT = 2,
};
+#if defined(CONFIG_PNFS)
+
+/* XDR stream arguments and results. Exported file system uses this
+ * struct to encode information and return how many bytes were encoded.
+ */
+struct pnfs_xdr_info {
+ u32 *p; /* in */
+ u32 *end; /* in */
+ u32 maxcount; /* in */
+ u32 bytes_written; /* out */
+};
+
+/* Used by get_device_info to encode a device (da_addr_body in spec)
+ * Args:
+ * xdr - xdr stream
+ * device - pointer to device to be encoded
+*/
+typedef int (*pnfs_encodedev_t)(struct pnfs_xdr_info *xdr, void *device);
+
+/* Arguments for get_device_info */
+struct pnfs_devinfo_arg {
+ u32 type;
+ u32 devid;
+ struct pnfs_xdr_info xdr;
+ pnfs_encodedev_t func;
+};
+
+#endif
+
struct fid {
union {
struct {
@@ -116,10 +145,16 @@ struct export_operations {
void (*get_verifier) (struct super_block *sb, u32 *p);
/* pNFS: Returns the supported pnfs_layouttype4. */
int (*layout_type)(void);
- /* pNFS: encodes opaque device list */
- int (*devaddr_encode)(u32 *p, u32 *end, void *devaddr);
- /* pNFS: free's opaque device list */
- void (*devaddr_free)(void *devaddr);
+ /* Retrieve and encode a device onto the xdr stream.
+ * Args:
+ * sb - superblock
+ * arg - layout type, device id, maxcount
+ * arg.xdr - xdr stream for encoding
+ * arg.func - Optional function called by file system to encode
+ * device on xdr stream.
+ */
+ int (*get_device_info) (struct super_block *sb,
+ struct pnfs_devinfo_arg *arg);
/* pNFS: returns the opaque device list */
int (*get_devicelist) (struct super_block *sb, void *buf);
/* pNFS: encodes opaque layout
@@ -138,8 +173,6 @@ struct export_operations {
* Arg: buf - struct nfsd4_pnfs_layoutget
*/
int (*layout_get) (struct inode *inode, void *buf);
- /* pNFS: returns the opaque device */
- int (*get_deviceinfo) (struct super_block *sb, void *p);
/* pNFS: commit changes to layout */
int (*layout_commit) (struct inode *inode, void *p);
/* pNFS: returns the layout */
diff --git a/include/linux/nfsd/nfsd4_pnfs.h b/include/linux/nfsd/nfsd4_pnfs.h
index 2f08ae9..69cc5a2 100644
--- a/include/linux/nfsd/nfsd4_pnfs.h
+++ b/include/linux/nfsd/nfsd4_pnfs.h
@@ -40,6 +40,7 @@
#include <linux/nfs.h>
#include <linux/nfs_xdr.h>
+#include <linux/exportfs.h>
/* pNFS structs */
@@ -64,12 +65,10 @@ struct nfsd4_pnfs_getdevlist {
};
struct nfsd4_pnfs_getdevinfo {
- u32 gd_type; /* request - response */
- u32 gd_dev_id; /* request */
- u32 gd_maxcnt; /* request */
- struct export_operations *gd_ops;
- u32 gd_devlist_len; /* response */
- void *gd_devaddr; /*response */
+ u32 gd_type; /* request */
+ u32 gd_devid; /* request */
+ u32 gd_maxcount; /* request */
+ struct svc_fh *gd_fhp; /* response */
};
struct nfsd4_layout_seg {
--
1.5.3.3
More information about the pNFS
mailing list