cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: wcheng@sourceware.org <wcheng@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs-kernel/src/gfs inode.h ops_export.c
Date: 16 Jan 2007 20:39:03 -0000	[thread overview]
Message-ID: <20070116203903.15912.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	wcheng at 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 = {



             reply	other threads:[~2007-01-16 20:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-16 20:39 wcheng [this message]
2007-01-17 14:12 ` [Cluster-devel] cluster/gfs-kernel/src/gfs inode.h ops_export.c Steven Whitehouse
2007-01-17 23:05   ` Wendy Cheng
2007-01-18  9:56     ` Steven Whitehouse
2007-01-18 15:17       ` Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070116203903.15912.qmail@sourceware.org \
    --to=wcheng@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).