2007-08-30 13:16:09

by Christoph Hellwig

[permalink] [raw]
Subject: [PATH 04/19] ext2: new export ops

Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig <[email protected]>

Index: linux-2.6/fs/ext2/super.c
===================================================================
--- linux-2.6.orig/fs/ext2/super.c 2007-03-13 18:19:43.000000000 +0100
+++ linux-2.6/fs/ext2/super.c 2007-03-13 19:06:57.000000000 +0100
@@ -251,13 +251,10 @@ static const struct super_operations ext
#endif
};

-static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *ext2_nfs_get_inode(struct super_block *sb,
+ u64 ino, u32 generation)
{
- __u32 *objp = vobjp;
- unsigned long ino = objp[0];
- __u32 generation = objp[1];
struct inode *inode;
- struct dentry *result;

if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
return ERR_PTR(-ESTALE);
@@ -278,15 +275,19 @@ static struct dentry *ext2_get_dentry(st
iput(inode);
return ERR_PTR(-ESTALE);
}
- /* now to find a dentry.
- * If possible, get a well-connected one
- */
- result = d_alloc_anon(inode);
- if (!result) {
- iput(inode);
- return ERR_PTR(-ENOMEM);
- }
- return result;
+ return inode;
+}
+
+static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
+ int fh_len, int fh_type)
+{
+ return generic_fh_to_dentry(sb, fid, fh_len, fh_type, ext2_nfs_get_inode);
+}
+
+static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
+ int fh_len, int fh_type)
+{
+ return generic_fh_to_parent(sb, fid, fh_len, fh_type, ext2_nfs_get_inode);
}

/* Yes, most of these are left as NULL!!
@@ -295,8 +296,9 @@ static struct dentry *ext2_get_dentry(st
* Currently only get_parent is required.
*/
static struct export_operations ext2_export_ops = {
+ .fh_to_dentry = ext2_fh_to_dentry,
+ .fh_to_parent = ext2_fh_to_parent,
.get_parent = ext2_get_parent,
- .get_dentry = ext2_get_dentry,
};

static unsigned long get_sb_block(void **data)

--


2007-09-14 14:57:53

by Greg Banks

[permalink] [raw]
Subject: Re: [PATH 04/19] ext2: new export ops

On Thu, Aug 30, 2007 at 03:16:09PM +0200, Christoph Hellwig wrote:
> +
> +static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
> + int fh_len, int fh_type)
> +{
> + return generic_fh_to_dentry(sb, fid, fh_len, fh_type, ext2_nfs_get_inode);
> +}
> +
> +static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
> + int fh_len, int fh_type)
> +{
> + return generic_fh_to_parent(sb, fid, fh_len, fh_type, ext2_nfs_get_inode);
> }
>

These patches look good, and cleanup in this area is certainly a
good thing. One small comment: the easy filesystems (ext[234], efs,
ntfs) might be cleaner if the per-fs get_inode function were a member
of export_ops instead of an extra argument to generic_fh_to_dentry().
That way you wouldn't need these two little helper functions in each
filesystem, because you could point export_ops.fh_to_dentry directly
at generic_fh_to_dentry.

Greg.
--
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
Apparently, I'm Bedevere. Which MPHG character are you?
I don't speak for SGI.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-14 15:01:09

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [NFS] [PATH 04/19] ext2: new export ops

On Sat, Sep 15, 2007 at 12:58:03AM +1000, Greg Banks wrote:
> These patches look good, and cleanup in this area is certainly a
> good thing. One small comment: the easy filesystems (ext[234], efs,
> ntfs) might be cleaner if the per-fs get_inode function were a member
> of export_ops instead of an extra argument to generic_fh_to_dentry().
> That way you wouldn't need these two little helper functions in each
> filesystem, because you could point export_ops.fh_to_dentry directly
> at generic_fh_to_dentry.

I was pondering this, but in the end I prefer the cleaner layering of
the callback version. This also mirrors what we do in other areas
(e.g. address_space operations)