linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATH 04/19] ext2: new export ops
@ 2007-08-30 13:16 Christoph Hellwig
  2007-09-14 14:58 ` Greg Banks
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2007-08-30 13:16 UTC (permalink / raw)
  To: nfs, linux-fsdevel

[-- Attachment #1: ext2-implement-fh_to_dentry --]
[-- Type: text/plain, Size: 1916 bytes --]

Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig <hch@lst.de>

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)

--

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATH 04/19] ext2: new export ops
  2007-08-30 13:16 [PATH 04/19] ext2: new export ops Christoph Hellwig
@ 2007-09-14 14:58 ` Greg Banks
  2007-09-14 15:01   ` [NFS] " Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Banks @ 2007-09-14 14:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, nfs

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  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [NFS] [PATH 04/19] ext2: new export ops
  2007-09-14 14:58 ` Greg Banks
@ 2007-09-14 15:01   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2007-09-14 15:01 UTC (permalink / raw)
  To: Greg Banks; +Cc: Christoph Hellwig, nfs, linux-fsdevel

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-14 15:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-30 13:16 [PATH 04/19] ext2: new export ops Christoph Hellwig
2007-09-14 14:58 ` Greg Banks
2007-09-14 15:01   ` [NFS] " Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).