[Ocfs2-commits] khackel commits r2834 - branches/ocfs2-1.2/fs/ocfs2

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Tue Apr 11 17:40:27 CDT 2006


Author: khackel
Signed-off-by: jlbec
Date: 2006-04-11 17:40:27 -0500 (Tue, 11 Apr 2006)
New Revision: 2834

Modified:
   branches/ocfs2-1.2/fs/ocfs2/extent_map.c
Log:
* silence -EEXIST from ocfs2_extent_map_insert/lookup

Signed-off-by: jlbec


Modified: branches/ocfs2-1.2/fs/ocfs2/extent_map.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/extent_map.c	2006-04-11 18:16:48 UTC (rev 2833)
+++ branches/ocfs2-1.2/fs/ocfs2/extent_map.c	2006-04-11 22:40:27 UTC (rev 2834)
@@ -296,7 +296,7 @@
 
 		ret = ocfs2_extent_map_insert(inode, rec,
 					      le16_to_cpu(el->l_tree_depth));
-		if (ret) {
+		if (ret && (ret != -EEXIST)) {
 			mlog_errno(ret);
 			goto out_free;
 		}
@@ -425,6 +425,11 @@
 /*
  * Simple rule: on any return code other than -EAGAIN, anything left
  * in the insert_context will be freed.
+ *
+ * Simple rule #2: A return code of -EEXIST from this function or
+ * its calls to ocfs2_extent_map_insert_entry() signifies that another
+ * thread beat us to the insert.  It is not an actual error, but it
+ * tells the caller we have no more work to do.
  */
 static int ocfs2_extent_map_try_insert(struct inode *inode,
 				       struct ocfs2_extent_rec *rec,
@@ -446,23 +451,32 @@
 		goto out_unlock;
 	}
 
+	/* Since insert_entry failed, the map MUST have old_ent */
 	old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos),
-					  le32_to_cpu(rec->e_clusters), NULL,
-					  NULL);
-
+					  le32_to_cpu(rec->e_clusters),
+					  NULL, NULL);
 	if (!old_ent)
 		BUG();
 
-	ret = -EEXIST;
-	if (old_ent->e_tree_depth < tree_depth)
+	if (old_ent->e_tree_depth < tree_depth) {
+		/* Another thread beat us to the lower tree_depth */
+		ret = -EEXIST;
 		goto out_unlock;
+	}
 
 	if (old_ent->e_tree_depth == tree_depth) {
+		/*
+		 * Another thread beat us to this tree_depth.
+		 * Let's make sure we agree with that thread (the
+		 * extent_rec should be identical).
+		 */
 		if (!memcmp(rec, &old_ent->e_rec,
 			    sizeof(struct ocfs2_extent_rec)))
 			ret = 0;
+		else
+			/* FIXME: Should this be ESRCH/EBADR??? */
+			ret = -EEXIST;
 
-		/* FIXME: Should this be ESRCH/EBADR??? */
 		goto out_unlock;
 	}
 
@@ -597,7 +611,7 @@
 						  tree_depth, &ctxt);
 	} while (ret == -EAGAIN);
 
-	if (ret < 0)
+	if ((ret < 0) && (ret != -EEXIST))
 		mlog_errno(ret);
 
 	if (ctxt.left_ent)




More information about the Ocfs2-commits mailing list