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 298 299 299 ret = ocfs2_extent_map_insert(inode, rec, 300 300 le16_to_cpu(el->l_tree_depth)); 301 - if (ret) { 301 + if (ret && (ret != -EEXIST)) { 302 302 mlog_errno(ret); 303 303 goto out_free; 304 304 } ··· 427 427 /* 428 428 * Simple rule: on any return code other than -EAGAIN, anything left 429 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. 430 435 */ 431 436 static int ocfs2_extent_map_try_insert(struct inode *inode, 432 437 struct ocfs2_extent_rec *rec, ··· 453 448 goto out_unlock; 454 449 } 455 450 451 + /* Since insert_entry failed, the map MUST have old_ent */ 456 452 old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), 457 - le32_to_cpu(rec->e_clusters), NULL, 458 - NULL); 453 + le32_to_cpu(rec->e_clusters), 454 + NULL, NULL); 459 455 460 456 BUG_ON(!old_ent); 461 457 462 - ret = -EEXIST; 463 - if (old_ent->e_tree_depth < tree_depth) 458 + if (old_ent->e_tree_depth < tree_depth) { 459 + /* Another thread beat us to the lower tree_depth */ 460 + ret = -EEXIST; 464 461 goto out_unlock; 462 + } 465 463 466 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 + */ 467 470 if (!memcmp(rec, &old_ent->e_rec, 468 471 sizeof(struct ocfs2_extent_rec))) 469 472 ret = 0; 473 + else 474 + /* FIXME: Should this be ESRCH/EBADR??? */ 475 + ret = -EEXIST; 470 476 471 - /* FIXME: Should this be ESRCH/EBADR??? */ 472 477 goto out_unlock; 473 478 } 474 479 ··· 614 599 tree_depth, &ctxt); 615 600 } while (ret == -EAGAIN); 616 601 617 - if (ret < 0) 602 + if ((ret < 0) && (ret != -EEXIST)) 618 603 mlog_errno(ret); 619 604 620 605 if (ctxt.left_ent)