[GFS2] glock debugging and inode cache changes

This adds some extra debugging to glock.c and changes
inode.c's deallocation code to call the debugging code
at a suitable moment. I'm chasing down a particular bug
to do with deallocation at the moment and the code can
go again once the bug is fixed.

Also this includes the first part of some changes to unify
the Linux struct inode and GFS2's struct gfs2_inode. This
transformation will happen in small parts over the next short
period.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 27fbcd9..c2c7d2b 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -504,7 +504,7 @@
 
 	error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr,
 				  &gfs2_inode_glops, LM_ST_EXCLUSIVE,
-				  LM_FLAG_TRY_1CB, &i_gh);
+				  LM_FLAG_TRY_1CB|GL_DUMP, &i_gh);
 	switch(error) {
 	case 0:
 		break;
@@ -724,9 +724,8 @@
 	if ((name->len == 1 && memcmp(name->name, ".", 1) == 0) ||
 	    (name->len == 2 && memcmp(name->name, "..", 2) == 0 &&
 	     dir == sb->s_root->d_inode)) {
-		gfs2_inode_hold(dip);
-		ipp = dip;
-		goto done;
+		igrab(dir);
+		return dir;
 	}
 
 	error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
@@ -734,7 +733,7 @@
 		return ERR_PTR(error);
 
 	if (!is_root) {
-		error = gfs2_repermission(dip->i_vnode, MAY_EXEC, NULL);
+		error = gfs2_repermission(dir, MAY_EXEC, NULL);
 		if (error)
 			goto out;
 	}
@@ -756,7 +755,6 @@
 
 out:
 	gfs2_glock_dq_uninit(&d_gh);
-done:
 	if (error == -ENOENT)
 		return NULL;
 	if (error == 0) {
@@ -1058,7 +1056,6 @@
 	int error;
 
 	munge_mode_uid_gid(dip, &mode, &uid, &gid);
-
 	gfs2_alloc_get(dip);
 
 	error = gfs2_quota_lock(dip, uid, gid);
@@ -1069,19 +1066,14 @@
 	if (error)
 		goto out_quota;
 
-	error = gfs2_trans_begin(sdp, RES_DINODE + RES_UNLINKED +
-				 RES_QUOTA, 0);
+	error = gfs2_trans_begin(sdp, RES_DINODE + RES_UNLINKED + RES_QUOTA, 0);
 	if (error)
 		goto out_quota;
 
 	ul->ul_ut.ut_flags = 0;
 	error = gfs2_unlinked_ondisk_munge(sdp, ul);
-
-	init_dinode(dip, gl, &ul->ul_ut.ut_inum,
-		     mode, uid, gid);
-
+	init_dinode(dip, gl, &ul->ul_ut.ut_inum, mode, uid, gid);
 	gfs2_quota_change(dip, +1, uid, gid);
-
 	gfs2_trans_end(sdp);
 
  out_quota:
@@ -1089,7 +1081,6 @@
 
  out:
 	gfs2_alloc_put(dip);
-
 	return error;
 }
 
@@ -1123,8 +1114,7 @@
 		if (error)
 			goto fail_quota_locks;
 
-		error = gfs2_trans_begin(sdp,
-					 sdp->sd_max_dirres +
+		error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
 					 al->al_rgd->rd_ri.ri_length +
 					 2 * RES_DINODE + RES_UNLINKED +
 					 RES_STATFS + RES_QUOTA, 0);
@@ -1157,19 +1147,18 @@
 
 	return 0;
 
- fail_end_trans:
+fail_end_trans:
 	gfs2_trans_end(sdp);
 
- fail_ipreserv:
+fail_ipreserv:
 	if (dip->i_alloc.al_rgd)
 		gfs2_inplace_release(dip);
 
- fail_quota_locks:
+fail_quota_locks:
 	gfs2_quota_unlock(dip);
 
- fail:
+fail:
 	gfs2_alloc_put(dip);
-
 	return error;
 }
 
@@ -1226,11 +1215,9 @@
 	if (ul->ul_ut.ut_inum.no_addr < dip->i_num.no_addr) {
 		gfs2_glock_dq(ghs);
 
-		error = gfs2_glock_nq_num(sdp,
-					  ul->ul_ut.ut_inum.no_addr,
-					  &gfs2_inode_glops,
-					  LM_ST_EXCLUSIVE, GL_SKIP,
-					  ghs + 1);
+		error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr,
+					  &gfs2_inode_glops, LM_ST_EXCLUSIVE,
+					  GL_SKIP, ghs + 1);
 		if (error) {
 			gfs2_unlinked_put(sdp, ul);
 			return ERR_PTR(error);
@@ -1248,11 +1235,9 @@
 		if (error)
 			goto fail_gunlock2;
 	} else {
-		error = gfs2_glock_nq_num(sdp,
-					  ul->ul_ut.ut_inum.no_addr,
-					  &gfs2_inode_glops,
-					  LM_ST_EXCLUSIVE, GL_SKIP,
-					  ghs + 1);
+		error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr,
+					  &gfs2_inode_glops, LM_ST_EXCLUSIVE,
+					  GL_SKIP, ghs + 1);
 		if (error)
 			goto fail_gunlock;
 	}
@@ -1285,18 +1270,17 @@
 		return ERR_PTR(-ENOMEM);
 	return inode;
 
- fail_iput:
+fail_iput:
 	gfs2_inode_put(ip);
 
- fail_gunlock2:
+fail_gunlock2:
 	gfs2_glock_dq_uninit(ghs + 1);
 
- fail_gunlock:
+fail_gunlock:
 	gfs2_glock_dq(ghs);
 
- fail:
+fail:
 	gfs2_unlinked_put(sdp, ul);
-
 	return ERR_PTR(error);
 }