[Ocfs2-commits] mfasheh commits r2225 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed May 11 18:06:45 CDT 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-05-11 18:06:43 -0500 (Wed, 11 May 2005)
New Revision: 2225

Modified:
   trunk/fs/ocfs2/dlmglue.c
   trunk/fs/ocfs2/dlmglue.h
   trunk/fs/ocfs2/inode.c
   trunk/fs/ocfs2/journal.c
   trunk/fs/ocfs2/mmap.c
Log:
* add better consistency checking in ocfs2_meta_lock_update

* Turn some printks and error traces into debug traces - they were not
  actually errors.

* Cleanup the bh handling in the meta_lock path a little, there was a bug
  where we were getting a buffer twice

Signed-off-by: manish



Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c	2005-05-11 03:59:37 UTC (rev 2224)
+++ trunk/fs/ocfs2/dlmglue.c	2005-05-11 23:06:43 UTC (rev 2225)
@@ -1366,6 +1366,13 @@
 
 	mlog_entry_void();
 
+	spin_lock(&OCFS_I(inode)->ip_lock);
+	if (INODE_DELETED(inode))
+		mlog(ML_ERROR, "Orphaned inode %"MLFu64"was deleted while we "
+		     "were waiting on a lock. ip_flags = 0x%x\n",
+		     OCFS_I(inode)->ip_blkno, OCFS_I(inode)->ip_flags);
+	spin_unlock(&OCFS_I(inode)->ip_lock);
+
 	lockres = &OCFS_I(inode)->ip_meta_lockres;
 
 	if (!ocfs2_should_refresh_lock_res(lockres))
@@ -1390,11 +1397,20 @@
 
 		/* This is a good chance to make sure we're not
 		 * locking an invalid object. */
-		OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
-		OCFS_ASSERT(inode->i_generation == 
-			    le32_to_cpu(fe->i_generation));
-		if ((fe->i_dtime) || (!(fe->i_flags & OCFS2_VALID_FL)))
-			BUG();
+		mlog_bug_on_msg(!IS_VALID_FILE_ENTRY(fe),
+				"Invalid dinode %"MLFu64" Signature: %s\n",
+				OCFS_I(inode)->ip_blkno, fe->i_signature);
+		mlog_bug_on_msg(inode->i_generation !=
+				le32_to_cpu(fe->i_generation),
+				"Invalid dinode %"MLFu64" disk generation: %u "
+				"inode->i_generation: %u\n",
+				OCFS_I(inode)->ip_blkno,
+				le32_to_cpu(fe->i_generation),
+				inode->i_generation);
+		mlog_bug_on_msg(fe->i_dtime || !(fe->i_flags & OCFS2_VALID_FL),
+				"Stale dinode %"MLFu64" dtime: %"MLFu64" "
+				"flags: 0x%x\n", OCFS_I(inode)->ip_blkno,
+				fe->i_dtime, fe->i_flags);
 
 		ocfs_refresh_inode(inode, fe);
 	}
@@ -1417,16 +1433,43 @@
 	return status;
 }
 
+static int ocfs2_assign_bh(struct inode *inode,
+			   struct buffer_head **ret_bh,
+			   struct buffer_head *passed_bh)
+{
+	int status;
+
+	if (passed_bh) {
+		/* Ok, the update went to disk for us, use the
+		 * returned bh. */
+		*ret_bh = passed_bh;
+		get_bh(*ret_bh);
+
+		return 0;
+	}
+
+	status = ocfs_read_block(OCFS2_SB(inode->i_sb),
+				 OCFS_I(inode)->ip_blkno,
+				 ret_bh,
+				 OCFS_BH_CACHED,
+				 inode);
+	if (status < 0)
+		mlog_errno(status);
+
+	return status;
+}
+
 /* 
  * returns < 0 error if the callback will never be called, otherwise
  * the result of the lock will be communicated via the callback.
  */
-int ocfs2_meta_lock_flags_async(struct inode *inode,
-			        struct buffer_head **ret_bh,
-				int ex,
-				int flags,
-				ocfs2_lock_callback cb,
-				unsigned long cb_data)
+int ocfs2_meta_lock_full(struct inode *inode,
+			 ocfs_journal_handle *handle,
+			 struct buffer_head **ret_bh,
+			 int ex,
+			 int flags,
+			 ocfs2_lock_callback cb,
+			 unsigned long cb_data)
 {
 	int status, level, dlm_flags;
 	ocfs2_lock_res *lockres;
@@ -1475,23 +1518,45 @@
 			   ocfs_node_map_is_empty(osb,
 						  &osb->recovery_map));
 
-	/* it's pretty weak to do this possibly sync read here, but until
-	 * we have a real async version of it it's as good a place as any */
-	if (ret_bh == NULL)
-		ret_bh = &local_bh;
-	status = ocfs2_meta_lock_update(inode, ret_bh);
+	/* This is fun. The caller may want a bh back, or it may
+	 * not. ocfs2_meta_lock_update definitely wants one in, but
+	 * may or may not read one, depending on what's in the
+	 * LVB. The result of all of this is that we've *only* gone to
+	 * disk if we have to, so the complexity is worthwhile. */
+	status = ocfs2_meta_lock_update(inode, &local_bh);
 	if (status < 0) {
 		mlog_errno(status);
 		goto bail;
 	}
 
+	if (ret_bh) {
+		status = ocfs2_assign_bh(inode, ret_bh, local_bh);
+		if (status < 0) {
+			mlog_errno(status);
+			goto bail;
+		}
+	}
+
+	if (handle) {
+		status = ocfs_handle_add_lock(handle, inode);
+		if (status < 0)
+			mlog_errno(status);
+	}
+
 bail:
+	if (status < 0 && ret_bh && (*ret_bh)) {
+		brelse(*ret_bh);
+		*ret_bh = NULL;
+	}
+
 	if (local_bh)
 		brelse(local_bh);
+
 	mlog_exit(status);
 	return status;
 }
 
+#if 0
 /* grabs the meta lock synchronusly.  */
 int ocfs2_meta_lock_flags(struct inode *inode,
 			  ocfs_journal_handle *handle,
@@ -1499,7 +1564,6 @@
 			  int ex,
 			  int flags)
 {
-	struct buffer_head *bh = NULL;
 	int status;
 
 	mlog_entry_void();
@@ -1511,32 +1575,31 @@
 	if (status)
 		goto bail;
 
-	if (ret_bh && !bh) {
+	if (ret_bh && !(*ret_bh)) {
 		/* caller wants a buffer head but we haven't read it yet. */
 		status = ocfs_read_block(OCFS2_SB(inode->i_sb),
-					 OCFS_I(inode)->ip_blkno, &bh,
+					 OCFS_I(inode)->ip_blkno, ret_bh,
 					 OCFS_BH_CACHED, inode);
 		if (status < 0) {
 			mlog_errno(status);
 			goto bail;
 		}
 	}
-	if (ret_bh) {
-		*ret_bh = bh;
-		get_bh(*ret_bh);
-	}
 	if (handle) {
 		status = ocfs_handle_add_lock(handle, inode);
 		if (status < 0)
 			mlog_errno(status);
 	}
 bail:
-	if (bh)
-		brelse(bh);
+	if (status < 0 && ret_bh && (*ret_bh)) {
+		brelse(*ret_bh);
+		ret_bh = NULL;
+	}
 
 	mlog_exit(status);
 	return status;
 }
+#endif
 
 void ocfs2_meta_unlock(struct inode *inode,
 		       int ex)
@@ -1701,11 +1764,9 @@
 	dlm_status status;
 
 	if (lockres->l_flags & OCFS2_LOCK_BUSY)
-		printk("ocfs2: destroying busy lock! (%s)\n",
-		       lockres->l_name);
+		mlog(0,"destroying busy lock: \"%s\"\n", lockres->l_name);
 	if (lockres->l_flags & OCFS2_LOCK_BLOCKED)
-		printk("ocfs2: destroying blocked lock! (%s)\n",
-		       lockres->l_name);
+		mlog(0, "destroying blocked lock: \"%s\"\n", lockres->l_name);
 
 	if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) {
 		spin_unlock(&lockres->l_lock);
@@ -2292,13 +2353,14 @@
 					      ocfs2_lock_res *lockres)
 {
 	mlog_entry_void();
+
 	if (!igrab(inode)) {
-		mlog(ML_ERROR, "Inode %"MLFu64" asked to be scheduled during "
-			       "clear_inode!\n",
-		     OCFS_I(inode)->ip_blkno);
+		mlog(0, "Inode %"MLFu64" asked to be scheduled during "
+		     "clear_inode!\n", OCFS_I(inode)->ip_blkno);
 		return;
 	}
 
 	ocfs2_schedule_blocked_lock(OCFS2_SB(inode->i_sb), lockres);
+
 	mlog_exit_void();
 }

Modified: trunk/fs/ocfs2/dlmglue.h
===================================================================
--- trunk/fs/ocfs2/dlmglue.h	2005-05-11 03:59:37 UTC (rev 2224)
+++ trunk/fs/ocfs2/dlmglue.h	2005-05-11 23:06:43 UTC (rev 2225)
@@ -95,20 +95,16 @@
 #define OCFS2_META_LOCK_RECOVERY	(0x01)
 /* Instruct the dlm not to queue ourselves on the other node. */
 #define OCFS2_META_LOCK_NOQUEUE		(0x02)
+int ocfs2_meta_lock_full(struct inode *inode,
+			 ocfs_journal_handle *handle,
+			 struct buffer_head **ret_bh,
+			 int ex,
+			 int flags,
+			 ocfs2_lock_callback cb,
+			 unsigned long cb_data);
 /* 99% of the time we don't want to supply any additional flags --
  * those are for very specific cases only. */
-#define ocfs2_meta_lock(i, h, b, e) ocfs2_meta_lock_flags(i, h, b, e, 0)
-int ocfs2_meta_lock_flags(struct inode *inode,
-			  ocfs_journal_handle *handle,
-			  struct buffer_head **ret_bh,
-			  int ex,
-			  int flags);
-int ocfs2_meta_lock_flags_async(struct inode *inode,
-				struct buffer_head **ret_bh,
-				int ex,
-				int flags,
-				ocfs2_lock_callback cb,
-				unsigned long cb_data);
+#define ocfs2_meta_lock(i, h, b, e) ocfs2_meta_lock_full(i, h, b, e, 0, NULL, 0)
 void ocfs2_meta_unlock(struct inode *inode,
 		       int ex);
 int ocfs2_super_lock(ocfs_super *osb,

Modified: trunk/fs/ocfs2/inode.c
===================================================================
--- trunk/fs/ocfs2/inode.c	2005-05-11 03:59:37 UTC (rev 2224)
+++ trunk/fs/ocfs2/inode.c	2005-05-11 23:06:43 UTC (rev 2225)
@@ -158,6 +158,10 @@
 
 	args = opaque;
 
+	/* XXX: Can this actually ever be passed in as NULL? */
+	if (inode == NULL)
+		goto bail;
+
 	if (!inode->u.generic_ip) {
 		mlog(ML_ERROR, "inode %lu has no generic_ip (is_bad_inode = "
 			       "%d)!\n", inode->i_ino, is_bad_inode(inode));
@@ -168,9 +172,6 @@
 		BUG();
 	}
 
-	if (inode == NULL)
-		goto bail;
-
 	if (OCFS_I(inode)->ip_blkno != args->blkno)
 		goto bail;
 

Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c	2005-05-11 03:59:37 UTC (rev 2224)
+++ trunk/fs/ocfs2/journal.c	2005-05-11 23:06:43 UTC (rev 2225)
@@ -1103,8 +1103,8 @@
 	}
 	SET_INODE_JOURNAL(inode);
 
-	status = ocfs2_meta_lock_flags(inode, NULL, &bh, 1,
-				       OCFS2_META_LOCK_RECOVERY);
+	status = ocfs2_meta_lock_full(inode, NULL, &bh, 1,
+				      OCFS2_META_LOCK_RECOVERY, NULL, 0);
 	if (status < 0) {
 		mlog(0, "status returned from ocfs2_meta_lock=%d\n", status);
 		if (status != -ERESTARTSYS)
@@ -1289,7 +1289,7 @@
 	SET_INODE_JOURNAL(inode);
 
 	flags = OCFS2_META_LOCK_RECOVERY|OCFS2_META_LOCK_NOQUEUE;
-	status = ocfs2_meta_lock_flags(inode, NULL, NULL, 1, flags);
+	status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags, NULL, 0);
 	if (status < 0) {
 		if (status != -EAGAIN)
 			mlog_errno(status);

Modified: trunk/fs/ocfs2/mmap.c
===================================================================
--- trunk/fs/ocfs2/mmap.c	2005-05-11 03:59:37 UTC (rev 2224)
+++ trunk/fs/ocfs2/mmap.c	2005-05-11 23:06:43 UTC (rev 2225)
@@ -363,7 +363,7 @@
 		inode = binode->ba_inode;
 
 		if (!binode->ba_meta_locked) {
-			status = ocfs2_meta_lock_flags_async(inode, NULL,
+			status = ocfs2_meta_lock_full(inode, NULL, NULL,
 						binode->ba_lock_meta_level,
 						0,
 						ctxt->b_cb,



More information about the Ocfs2-commits mailing list