Loading fs/ocfs2/extent_map.c +22 −7 Original line number Original line Diff line number Diff line Loading @@ -298,7 +298,7 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, ret = ocfs2_extent_map_insert(inode, rec, ret = ocfs2_extent_map_insert(inode, rec, le16_to_cpu(el->l_tree_depth)); le16_to_cpu(el->l_tree_depth)); if (ret) { if (ret && (ret != -EEXIST)) { mlog_errno(ret); mlog_errno(ret); goto out_free; goto out_free; } } Loading Loading @@ -427,6 +427,11 @@ static int ocfs2_extent_map_insert_entry(struct ocfs2_extent_map *em, /* /* * Simple rule: on any return code other than -EAGAIN, anything left * Simple rule: on any return code other than -EAGAIN, anything left * in the insert_context will be freed. * 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, static int ocfs2_extent_map_try_insert(struct inode *inode, struct ocfs2_extent_rec *rec, struct ocfs2_extent_rec *rec, Loading @@ -448,22 +453,32 @@ static int ocfs2_extent_map_try_insert(struct inode *inode, goto out_unlock; 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), old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters), NULL, le32_to_cpu(rec->e_clusters), NULL); NULL, NULL); BUG_ON(!old_ent); BUG_ON(!old_ent); if (old_ent->e_tree_depth < tree_depth) { /* Another thread beat us to the lower tree_depth */ ret = -EEXIST; ret = -EEXIST; if (old_ent->e_tree_depth < tree_depth) goto out_unlock; goto out_unlock; } if (old_ent->e_tree_depth == tree_depth) { 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, if (!memcmp(rec, &old_ent->e_rec, sizeof(struct ocfs2_extent_rec))) sizeof(struct ocfs2_extent_rec))) ret = 0; ret = 0; else /* FIXME: Should this be ESRCH/EBADR??? */ /* FIXME: Should this be ESRCH/EBADR??? */ ret = -EEXIST; goto out_unlock; goto out_unlock; } } Loading Loading @@ -599,7 +614,7 @@ static int ocfs2_extent_map_insert(struct inode *inode, tree_depth, &ctxt); tree_depth, &ctxt); } while (ret == -EAGAIN); } while (ret == -EAGAIN); if (ret < 0) if ((ret < 0) && (ret != -EEXIST)) mlog_errno(ret); mlog_errno(ret); if (ctxt.left_ent) if (ctxt.left_ent) Loading Loading
fs/ocfs2/extent_map.c +22 −7 Original line number Original line Diff line number Diff line Loading @@ -298,7 +298,7 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, ret = ocfs2_extent_map_insert(inode, rec, ret = ocfs2_extent_map_insert(inode, rec, le16_to_cpu(el->l_tree_depth)); le16_to_cpu(el->l_tree_depth)); if (ret) { if (ret && (ret != -EEXIST)) { mlog_errno(ret); mlog_errno(ret); goto out_free; goto out_free; } } Loading Loading @@ -427,6 +427,11 @@ static int ocfs2_extent_map_insert_entry(struct ocfs2_extent_map *em, /* /* * Simple rule: on any return code other than -EAGAIN, anything left * Simple rule: on any return code other than -EAGAIN, anything left * in the insert_context will be freed. * 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, static int ocfs2_extent_map_try_insert(struct inode *inode, struct ocfs2_extent_rec *rec, struct ocfs2_extent_rec *rec, Loading @@ -448,22 +453,32 @@ static int ocfs2_extent_map_try_insert(struct inode *inode, goto out_unlock; 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), old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters), NULL, le32_to_cpu(rec->e_clusters), NULL); NULL, NULL); BUG_ON(!old_ent); BUG_ON(!old_ent); if (old_ent->e_tree_depth < tree_depth) { /* Another thread beat us to the lower tree_depth */ ret = -EEXIST; ret = -EEXIST; if (old_ent->e_tree_depth < tree_depth) goto out_unlock; goto out_unlock; } if (old_ent->e_tree_depth == tree_depth) { 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, if (!memcmp(rec, &old_ent->e_rec, sizeof(struct ocfs2_extent_rec))) sizeof(struct ocfs2_extent_rec))) ret = 0; ret = 0; else /* FIXME: Should this be ESRCH/EBADR??? */ /* FIXME: Should this be ESRCH/EBADR??? */ ret = -EEXIST; goto out_unlock; goto out_unlock; } } Loading Loading @@ -599,7 +614,7 @@ static int ocfs2_extent_map_insert(struct inode *inode, tree_depth, &ctxt); tree_depth, &ctxt); } while (ret == -EAGAIN); } while (ret == -EAGAIN); if (ret < 0) if ((ret < 0) && (ret != -EEXIST)) mlog_errno(ret); mlog_errno(ret); if (ctxt.left_ent) if (ctxt.left_ent) Loading