exportfs: add fid type
Subsystems (4)
PATCH 2/18 exportfs: add fid type
Add a structured fid type so that we don't have to pass an array of u32 values around everywhere. It's a union of possible layouts. As a start there's only the u32 array and the traditional 32bit inode format, but there will be more in one of my next patchset when I start to document the various filehandle formats we have in lowlevel filesystems better.
Also add an enum that gives the various filehandle types humand readable names.
Note: Some people might think the struct containing an anonymous union is ugly, but I didn't want to pass around a raw union type.
include/linux/exportfs.h +41 -3
@@ -7,6 +7,44 @@ struct dentry;struct super_block ;struct vfsmount ; +/* +* The fileid_type identifies how the file within the filesystem is encoded. +* In theory this is freely set and parsed by the filesystem, but we try to +* stick to conventions so we can share some generic code and don't confuse +* sniffers like ethereal/wireshark. +* +* The filesystem must not use the value '0' or '0xff'. +*/ +enum fid_type { +/* +* The root, or export point, of the filesystem. +* (Never actually passed down to the filesystem. +*/ +FILEID_ROOT =0 , + +/* +* 32bit inode number, 32 bit generation number. +*/ +FILEID_INO32_GEN =1 , + +/* +* 32bit inode number, 32 bit generation number, +* 32 bit parent directory inode number. +*/ +FILEID_INO32_GEN_PARENT =2 , +}; + +struct fid { +union { +struct { +u32 ino; +u32 gen; +u32 parent_ino; +u32 parent_gen; + } i32; +__u32 raw[6 ]; + }; +};/** * struct export_operations - for nfsd to communicate with file systems
@@ -117,9 +155,9 @@ extern struct dentry *find_exported_dent void *parent, int (*acceptable)(void *context, struct dentry *de), void *context); -extern int exportfs_encode_fh (struct dentry *dentry,__u32 *fh,int *max_len, -int connectable); -extern struct dentry *exportfs_decode_fh (struct vfsmount *mnt,__u32 *fh, +extern int exportfs_encode_fh (struct dentry *dentry,struct fid *fid, +int *max_len,int connectable); +extern struct dentry *exportfs_decode_fh (struct vfsmount *mnt,struct fid *fid,int fh_len,int fileid_type,int (*acceptable)(void *,struct dentry *),void *context);
fs/nfsd/nfsfh.c +30 -36
126 lines not on this page · raw message
fs/exportfs/expfs.c +16 -16
@@ -436,29 +436,29 @@ out:* can be used to check that it is still valid. It places them in the * filehandle fragment where export_decode_fh expects to find them. */ -static int export_encode_fh (struct dentry *dentry,__u32 *fh,int *max_len, -int connectable) +static int export_encode_fh (struct dentry *dentry,struct fid *fid, +int *max_len,int connectable) {struct inode * inode = dentry->d_inode;int len = *max_len; -int type =1 ; +int type =FILEID_INO32_GEN ;if (len <2 || (connectable && len <4 ))return 255 ; len =2 ; - fh[0 ] = inode->i_ino; - fh[1 ] = inode->i_generation; + fid->i32.ino = inode->i_ino; + fid->i32.gen = inode->i_generation;if (connectable && !S_ISDIR (inode->i_mode)) {struct inode *parent;spin_lock (&dentry->d_lock); parent = dentry->d_parent->d_inode; - fh[2 ] = parent->i_ino; - fh[3 ] = parent->i_generation; + fid->i32.parent_ino = parent->i_ino; + fid->i32.parent_gen = parent->i_generation;spin_unlock (&dentry->d_lock); len =4 ; - type =2 ; + type =FILEID_INO32_GEN_PARENT ; } *max_len = len;return type;
@@ -496,33 +496,33 @@ static struct dentry *export_decode_fh(s acceptable, context); } -int exportfs_encode_fh (struct dentry *dentry,__u32 *fh,int *max_len, +int exportfs_encode_fh (struct dentry *dentry,struct fid *fid,int *max_len,int connectable) {struct export_operations *nop = dentry->d_sb->s_export_op;int error;if (nop->encode_fh) - error = nop->encode_fh (dentry, fh, max_len, connectable); + error = nop->encode_fh (dentry, fid->raw, max_len, connectable);else - error =export_encode_fh (dentry, fh, max_len, connectable); + error =export_encode_fh (dentry, fid, max_len, connectable);return error; }EXPORT_SYMBOL_GPL (exportfs_encode_fh); -struct dentry *exportfs_decode_fh (struct vfsmount *mnt,__u32 *fh,int fh_len, -int fileid_type,int (*acceptable)(void *,struct dentry *), -void *context) +struct dentry *exportfs_decode_fh (struct vfsmount *mnt,struct fid *fid, +int fh_len,int fileid_type, +int (*acceptable)(void *,struct dentry *),void *context) {struct export_operations *nop = mnt->mnt_sb->s_export_op;struct dentry *result;if (nop->decode_fh) { - result = nop->decode_fh (mnt->mnt_sb, fh, fh_len, fileid_type, + result = nop->decode_fh (mnt->mnt_sb, fid->raw, fh_len, fileid_type, acceptable, context); }else { - result =export_decode_fh (mnt->mnt_sb, fh, fh_len, fileid_type, + result =export_decode_fh (mnt->mnt_sb, fid->raw, fh_len, fileid_type, acceptable, context); }
Quoted 7 lines · Christoph Hellwig
Add a structured fid type so that we don't have to pass an array of u32 values around everywhere. It's a union of possible layouts. As a start there's only the u32 array and the traditional 32bit inode format, but there will be more in one of my next patchset when I start to document the various filehandle formats we have in lowlevel filesystems better.
Quoted 5 lines
Also add an enum that gives the various filehandle types humand readable names.
Note: Some people might think the struct containing an anonymous union is ugly, but I didn't want to pass around a raw union type.
A basic question: what do these apply against? For example, I don't have this file:
include/linux/exportfs.h
Quoted 4 lines
Index:
linux-2.6/include/linux/exportfs.h
===================================================================include/linux/exportfs.h +0
-0
--b.
Quoted 1 line · J. Bruce Fields
A basic question: what do these apply against?
They're against current mainline plus my patchset from Match 7th (starting with [PATCH 0/8] exportfs cleanups)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs