ocfs2: silence -EEXIST from ocfs2_extent_map_insert/lookup

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

authored by Joel Becker and committed by Mark Fasheh a43db30c 8169cae5

+22 -7
+22 -7
fs/ocfs2/extent_map.c
··· 298 299 ret = ocfs2_extent_map_insert(inode, rec, 300 le16_to_cpu(el->l_tree_depth)); 301 - if (ret) { 302 mlog_errno(ret); 303 goto out_free; 304 } ··· 427 /* 428 * Simple rule: on any return code other than -EAGAIN, anything left 429 * in the insert_context will be freed. 430 */ 431 static int ocfs2_extent_map_try_insert(struct inode *inode, 432 struct ocfs2_extent_rec *rec, ··· 453 goto out_unlock; 454 } 455 456 old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), 457 - le32_to_cpu(rec->e_clusters), NULL, 458 - NULL); 459 460 BUG_ON(!old_ent); 461 462 - ret = -EEXIST; 463 - if (old_ent->e_tree_depth < tree_depth) 464 goto out_unlock; 465 466 if (old_ent->e_tree_depth == tree_depth) { 467 if (!memcmp(rec, &old_ent->e_rec, 468 sizeof(struct ocfs2_extent_rec))) 469 ret = 0; 470 471 - /* FIXME: Should this be ESRCH/EBADR??? */ 472 goto out_unlock; 473 } 474 ··· 614 tree_depth, &ctxt); 615 } while (ret == -EAGAIN); 616 617 - if (ret < 0) 618 mlog_errno(ret); 619 620 if (ctxt.left_ent)
··· 298 299 ret = ocfs2_extent_map_insert(inode, rec, 300 le16_to_cpu(el->l_tree_depth)); 301 + if (ret && (ret != -EEXIST)) { 302 mlog_errno(ret); 303 goto out_free; 304 } ··· 427 /* 428 * Simple rule: on any return code other than -EAGAIN, anything left 429 * in the insert_context will be freed. 430 + * 431 + * Simple rule #2: A return code of -EEXIST from this function or 432 + * its calls to ocfs2_extent_map_insert_entry() signifies that another 433 + * thread beat us to the insert. It is not an actual error, but it 434 + * tells the caller we have no more work to do. 435 */ 436 static int ocfs2_extent_map_try_insert(struct inode *inode, 437 struct ocfs2_extent_rec *rec, ··· 448 goto out_unlock; 449 } 450 451 + /* Since insert_entry failed, the map MUST have old_ent */ 452 old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), 453 + le32_to_cpu(rec->e_clusters), 454 + NULL, NULL); 455 456 BUG_ON(!old_ent); 457 458 + if (old_ent->e_tree_depth < tree_depth) { 459 + /* Another thread beat us to the lower tree_depth */ 460 + ret = -EEXIST; 461 goto out_unlock; 462 + } 463 464 if (old_ent->e_tree_depth == tree_depth) { 465 + /* 466 + * Another thread beat us to this tree_depth. 467 + * Let's make sure we agree with that thread (the 468 + * extent_rec should be identical). 469 + */ 470 if (!memcmp(rec, &old_ent->e_rec, 471 sizeof(struct ocfs2_extent_rec))) 472 ret = 0; 473 + else 474 + /* FIXME: Should this be ESRCH/EBADR??? */ 475 + ret = -EEXIST; 476 477 goto out_unlock; 478 } 479 ··· 599 tree_depth, &ctxt); 600 } while (ret == -EAGAIN); 601 602 + if ((ret < 0) && (ret != -EEXIST)) 603 mlog_errno(ret); 604 605 if (ctxt.left_ent)