Skip to contentSkip to conversation

ext2: new export ops

PATCH In review Christoph Hellwig 2 participants 3 messages Aug 30, 2007 – Sep 14, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 4/19 ext2: new export ops

Trivial switch over to the new generic helpers.

fs/ext2/super.c +17 -15
Index: linux-2.6/fs/ext2/super.c
===================================================================
@@ -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)

--

#1 lore raw

fs/ext2/super.c static struct dentry *ext2_get_dentry(st · line 291

Quoted 13 lines · Christoph Hellwig
fs/ext2/super.c +11 -0
+
+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.

Signature · 11 lines
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
#2 lore raw
Quoted 7 lines · Greg Banks

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)