[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [RFC 1/3] GFS2 rename race - refresh inode



This patch yanks inode refresh logic out of gfs2_get_dentry() (currently used by NFS serving) so rename and NFS can share the same logic. It may look big but actually doesn't change any logic.




--- gfs2-2.6/fs/gfs2/inode.h	2006-12-05 15:22:48.000000000 -0500
+++ gfs2-kernel/fs/gfs2/inode.h	2006-12-11 00:19:58.000000000 -0500
@@ -52,6 +52,7 @@ int gfs2_ok_to_move(struct gfs2_inode *t
 int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
 int gfs2_glock_nq_atime(struct gfs2_holder *gh);
 int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
+struct inode *gfs2_refresh_iobj(struct super_block *sb, void *inum_obj);
 struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
 
 #endif /* __INODE_DOT_H__ */
--- gfs2-2.6/fs/gfs2/ops_export.c	2006-12-05 15:22:48.000000000 -0500
+++ gfs2-kernel/fs/gfs2/ops_export.c	2006-12-11 00:20:52.000000000 -0500
@@ -192,7 +192,19 @@ static struct dentry *gfs2_get_parent(st
 	return dentry;
 }
 
-static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj)
+/**
+ * gfs2_refresh_inum_obj -
+ *
+ *  This function was part of gfs2_get_dentry where it
+ *  - find the gfs2 inum_obj 
+ *  - read in on-disk inode if required
+ *  - allocate a vfs inode if required
+ *
+ *  We yank it out to allow other functions such as rename to re-use
+ *  this logic.
+ */
+
+struct inode *gfs2_refresh_iobj(struct super_block *sb, void *inum_obj)
 {
 	struct gfs2_sbd *sdp = sb->s_fs_info;
 	struct gfs2_fh_obj *fh_obj = (struct gfs2_fh_obj *)inum_obj;
@@ -200,18 +212,15 @@ static struct dentry *gfs2_get_dentry(st
 	struct gfs2_holder i_gh, ri_gh, rgd_gh;
 	struct gfs2_rgrpd *rgd;
 	struct inode *inode;
-	struct dentry *dentry;
 	int error;
 
-	/* System files? */
-
 	inode = gfs2_ilookup(sb, inum);
 	if (inode) {
 		if (GFS2_I(inode)->i_num.no_formal_ino != inum->no_formal_ino) {
 			iput(inode);
 			return ERR_PTR(-ESTALE);
 		}
-		goto out_inode;
+		return inode;
 	}
 
 	error = gfs2_glock_nq_num(sdp, inum->no_addr, &gfs2_inode_glops,
@@ -262,14 +271,7 @@ static struct dentry *gfs2_get_dentry(st
 
 	gfs2_glock_dq_uninit(&i_gh);
 
-out_inode:
-	dentry = d_alloc_anon(inode);
-	if (!dentry) {
-		iput(inode);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	return dentry;
+	return inode;
 
 fail_rgd:
 	gfs2_glock_dq_uninit(&rgd_gh);
@@ -282,6 +284,26 @@ fail:
 	return ERR_PTR(error);
 }
 
+static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj)
+{
+	struct gfs2_fh_obj *fh_obj = (struct gfs2_fh_obj *)inum_obj;
+	struct gfs2_inum_host *inum = &fh_obj->this;
+	struct inode *inode;
+	struct dentry *dentry;
+
+	inode = gfs2_refresh_inode(sb, inum_obj);
+	if (IS_ERR(inode))
+		return ERR_PTR((long)inode);
+
+	dentry = d_alloc_anon(inode);
+	if (!dentry) {
+		iput(inode);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	return dentry;
+}
+
 struct export_operations gfs2_export_ops = {
 	.decode_fh = gfs2_decode_fh,
 	.encode_fh = gfs2_encode_fh,

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]