···298298299299 ret = ocfs2_extent_map_insert(inode, rec,300300 le16_to_cpu(el->l_tree_depth));301301- if (ret) {301301+ if (ret && (ret != -EEXIST)) {302302 mlog_errno(ret);303303 goto out_free;304304 }···427427/*428428 * Simple rule: on any return code other than -EAGAIN, anything left429429 * in the insert_context will be freed.430430+ *431431+ * Simple rule #2: A return code of -EEXIST from this function or432432+ * its calls to ocfs2_extent_map_insert_entry() signifies that another433433+ * thread beat us to the insert. It is not an actual error, but it434434+ * tells the caller we have no more work to do.430435 */431436static int ocfs2_extent_map_try_insert(struct inode *inode,432437 struct ocfs2_extent_rec *rec,···453448 goto out_unlock;454449 }455450451451+ /* Since insert_entry failed, the map MUST have old_ent */456452 old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos),457457- le32_to_cpu(rec->e_clusters), NULL,458458- NULL);453453+ le32_to_cpu(rec->e_clusters),454454+ NULL, NULL);459455460456 BUG_ON(!old_ent);461457462462- ret = -EEXIST;463463- if (old_ent->e_tree_depth < tree_depth)458458+ if (old_ent->e_tree_depth < tree_depth) {459459+ /* Another thread beat us to the lower tree_depth */460460+ ret = -EEXIST;464461 goto out_unlock;462462+ }465463466464 if (old_ent->e_tree_depth == tree_depth) {465465+ /*466466+ * Another thread beat us to this tree_depth.467467+ * Let's make sure we agree with that thread (the468468+ * extent_rec should be identical).469469+ */467470 if (!memcmp(rec, &old_ent->e_rec,468471 sizeof(struct ocfs2_extent_rec)))469472 ret = 0;473473+ else474474+ /* FIXME: Should this be ESRCH/EBADR??? */475475+ ret = -EEXIST;470476471471- /* FIXME: Should this be ESRCH/EBADR??? */472477 goto out_unlock;473478 }474479···614599 tree_depth, &ctxt);615600 } while (ret == -EAGAIN);616601617617- if (ret < 0)602602+ if ((ret < 0) && (ret != -EEXIST))618603 mlog_errno(ret);619604620605 if (ctxt.left_ent)