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

[Cluster-devel] cluster/gfs-kernel/src/gfs inode.h ops_export.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	wcheng sourceware org	2007-01-16 20:39:03

Modified files:
	gfs-kernel/src/gfs: inode.h ops_export.c 

Log message:
	Bugzilla 190475 (rename 3-1)
	
	Yank get inode logic out of gfs_get_dentry() (currently only used by NFS
	file serving). This will allow gfs_rename (patch 3-3) to re-use (share)
	this logic to update its stale inode contents.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs-kernel/src/gfs/inode.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs-kernel/src/gfs/ops_export.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.2&r2=1.3.2.3

--- cluster/gfs-kernel/src/gfs/inode.h	2004/10/08 22:02:50	1.3
+++ cluster/gfs-kernel/src/gfs/inode.h	2007/01/16 20:39:03	1.3.2.1
@@ -53,6 +53,8 @@
 int gfs_alloc_qinode(struct gfs_sbd *sdp);
 int gfs_alloc_linode(struct gfs_sbd *sdp);
 
+struct inode *gfs_refresh_iobj(struct gfs_sbd *sdp, void *inum_obj, int *n);
+
 /*  Inlines  */
 
 static __inline__ int
--- cluster/gfs-kernel/src/gfs/ops_export.c	2007/01/11 18:52:18	1.3.2.2
+++ cluster/gfs-kernel/src/gfs/ops_export.c	2007/01/16 20:39:03	1.3.2.3
@@ -280,62 +280,57 @@
 }
 
 /**
- * gfs_get_dentry -
- * @param1: description
- * @param2: description
- * @param3: description
+ * gfs_refresh_iobj -
+ *  @sdp: pointer to struct gfs_sbd
+ *  @inum: pointer to struct gfs_inum
+ *  @refresh: set to true if inode refreshed
+ *  return: pointer to struct inode or errno
  *
- * Function description
+ *  This function was part of gfs_get_dentry where it
+ *  - allocated a gfs_inode "ip"
+ *  - disk-read in "ip"
+ *  - allocated a vfs inode for this "ip".
  *
- * Returns: what is returned
+ *  We yank it out to allow gfs_rename() to re-use
+ *  this logic.
  */
 
-struct dentry *
-gfs_get_dentry(struct super_block *sb, void *inump)
+struct inode *gfs_refresh_iobj(struct gfs_sbd *sdp, void *inum_obj, int *miss)
 {
-	struct gfs_sbd *sdp = vfs2sdp(sb);
-	struct inode_cookie *cookie = (struct inode_cookie *)inump;
-	struct gfs_inum inum;
 	struct gfs_holder i_gh, ri_gh, rgd_gh;
 	struct gfs_rgrpd *rgd;
 	struct buffer_head *bh;
 	struct gfs_dinode *di;
 	struct gfs_inode *ip;
 	struct inode *inode;
-	struct dentry *dentry;
+	struct gfs_inum *inum = (struct gfs_inum *) inum_obj;
 	int error;
 
-	atomic_inc(&sdp->sd_ops_export);
-
-	if (!cookie->formal_ino ||
-	    cookie->formal_ino == sdp->sd_jiinode->i_num.no_formal_ino ||
-	    cookie->formal_ino == sdp->sd_riinode->i_num.no_formal_ino ||
-	    cookie->formal_ino == sdp->sd_qinode->i_num.no_formal_ino ||
-	    cookie->formal_ino == sdp->sd_linode->i_num.no_formal_ino)
-		return ERR_PTR(-EINVAL);
-
-	inum.no_formal_ino = cookie->formal_ino;
-	inum.no_addr = cookie->formal_ino;
-
 	error = gfs_glock_nq_num(sdp,
-				 inum.no_formal_ino, &gfs_inode_glops,
+				 inum->no_formal_ino, &gfs_inode_glops,
 				 LM_ST_SHARED, LM_FLAG_ANY | GL_LOCAL_EXCL,
 				 &i_gh);
 	if (error)
 		return ERR_PTR(error);
 
-	error = gfs_inode_get(i_gh.gh_gl, &inum, NO_CREATE, &ip);
+	error = gfs_inode_get(i_gh.gh_gl, inum, NO_CREATE, &ip);
 	if (error)
 		goto fail;
 	if (ip)
 		goto out;
 
+	/*
+	 * Used by NFS support statistics for FHs that miss their dentres.
+	 */
+	if (miss)
+		*miss = 1;
+
 	error = gfs_rindex_hold(sdp, &ri_gh);
 	if (error)
 		goto fail;
 
 	error = -EINVAL;
-	rgd = gfs_blk2rgrpd(sdp, inum.no_addr);
+	rgd = gfs_blk2rgrpd(sdp, inum->no_addr);
 	if (!rgd)
 		goto fail_rindex;
 
@@ -344,10 +339,10 @@
 		goto fail_rindex;
 
 	error = -ESTALE;
-	if (gfs_get_block_type(rgd, inum.no_addr) != GFS_BLKST_USEDMETA)
+	if (gfs_get_block_type(rgd, inum->no_addr) != GFS_BLKST_USEDMETA)
 		goto fail_rgd;
 
-	error = gfs_dread(i_gh.gh_gl, inum.no_addr,
+	error = gfs_dread(i_gh.gh_gl, inum->no_addr,
 			  DIO_START | DIO_WAIT, &bh);
 	if (error)
 		goto fail_rgd;
@@ -368,8 +363,6 @@
 	if (error)
 		goto fail;
 
-	atomic_inc(&sdp->sd_fh2dentry_misses);
-
  out:
 	gfs_glock_dq_uninit(&i_gh);
 
@@ -379,6 +372,61 @@
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	return inode;
+
+ fail_relse:
+        brelse(bh);
+
+ fail_rgd:
+	gfs_glock_dq_uninit(&rgd_gh);
+
+ fail_rindex:
+	gfs_glock_dq_uninit(&ri_gh);
+
+ fail:
+	gfs_glock_dq_uninit(&i_gh);
+	return ERR_PTR(error);
+}
+
+/**
+ * gfs_get_dentry -
+ * @param1: description
+ * @param2: description
+ * @param3: description
+ *
+ * Function description
+ *
+ * Returns: what is returned
+ */
+
+struct dentry *
+gfs_get_dentry(struct super_block *sb, void *inump)
+{
+	struct gfs_sbd *sdp = vfs2sdp(sb);
+	struct inode_cookie *cookie = (struct inode_cookie *)inump;
+	struct gfs_inum inum;
+	struct inode *inode;
+	struct dentry *dentry;
+	int dentry_miss=0;
+
+	atomic_inc(&sdp->sd_ops_export);
+
+	if (!cookie->formal_ino ||
+	    cookie->formal_ino == sdp->sd_jiinode->i_num.no_formal_ino ||
+	    cookie->formal_ino == sdp->sd_riinode->i_num.no_formal_ino ||
+	    cookie->formal_ino == sdp->sd_qinode->i_num.no_formal_ino ||
+	    cookie->formal_ino == sdp->sd_linode->i_num.no_formal_ino)
+		return ERR_PTR(-EINVAL);
+
+	inum.no_formal_ino = cookie->formal_ino;
+	inum.no_addr = cookie->formal_ino;
+
+	inode = gfs_refresh_iobj(sdp, &inum, &dentry_miss);
+	if (dentry_miss)
+		atomic_inc(&sdp->sd_fh2dentry_misses);
+	if (IS_ERR(inode))
+		return ERR_PTR((long)inode);
+
 	/* inode->i_generation is GFS dinode's mh_incarn value */
 	if (cookie->gen_valid && cookie->gen != inode->i_generation) {
 		iput(inode);
@@ -393,19 +441,6 @@
 
 	dentry->d_op = &gfs_dops;
 	return dentry;
-
- fail_relse:
-        brelse(bh);
-
- fail_rgd:
-	gfs_glock_dq_uninit(&rgd_gh);
-
- fail_rindex:
-	gfs_glock_dq_uninit(&ri_gh);
-
- fail:
-	gfs_glock_dq_uninit(&i_gh);
-	return ERR_PTR(error);
 }
 
 struct export_operations gfs_export_ops = {


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