Example #1
0
/* Audited by: green(2002.06.15) */
reiser4_key *item_key_by_coord(const coord_t * coord /* coord to query */ ,
			       reiser4_key * key /* result */ )
{
	assert("nikita-338", coord != NULL);
	assert("nikita-339", coord->node != NULL);
	assert("nikita-340", znode_is_loaded(coord->node));

	return node_plugin_by_node(coord->node)->key_at(coord, key);
}
Example #2
0
/* return length of item at @coord */
pos_in_node_t item_length_by_coord(const coord_t * coord /* coord to query */ )
{
	int len;

	assert("nikita-327", coord != NULL);
	assert("nikita-328", coord->node != NULL);
	assert("nikita-329", znode_is_loaded(coord->node));

	len = node_plugin_by_node(coord->node)->length_by_coord(coord);
	return len;
}
Example #3
0
/* Audited by: green(2002.06.15) */
item_id item_id_by_coord(const coord_t * coord /* coord to query */ )
{
	assert("vs-539", coord != NULL);
	assert("vs-538", coord->node != NULL);
	assert("vs-537", znode_is_loaded(coord->node));
	assert("vs-536", item_plugin_by_coord(coord) != NULL);
	assert("vs-540",
	       item_id_by_plugin(item_plugin_by_coord(coord)) < LAST_ITEM_ID);

	return item_id_by_plugin(item_plugin_by_coord(coord));
}
Example #4
0
/* return pointer to item body */
void item_body_by_coord_hard(coord_t * coord /* coord to query */ )
{
	assert("nikita-324", coord != NULL);
	assert("nikita-325", coord->node != NULL);
	assert("nikita-326", znode_is_loaded(coord->node));
	assert("nikita-3200", coord->offset == INVALID_OFFSET);

	coord->offset =
	    node_plugin_by_node(coord->node)->item_by_coord(coord) -
	    zdata(coord->node);
	ON_DEBUG(coord->body_v = coord->node->times_locked);
}
Example #5
0
/* return the biggest key contained the unit @coord */
reiser4_key *max_unit_key_by_coord(const coord_t * coord /* coord to query */ ,
				   reiser4_key * key /* result */ )
{
	assert("nikita-772", coord != NULL);
	assert("nikita-774", coord->node != NULL);
	assert("nikita-775", znode_is_loaded(coord->node));

	if (item_plugin_by_coord(coord)->b.max_unit_key != NULL)
		return item_plugin_by_coord(coord)->b.max_unit_key(coord, key);
	else
		return unit_key_by_coord(coord, key);
}
Example #6
0
void obtain_item_plugin(const coord_t * coord)
{
	assert("nikita-330", coord != NULL);
	assert("nikita-331", coord->node != NULL);
	assert("nikita-332", znode_is_loaded(coord->node));

	coord_set_iplug((coord_t *) coord,
			node_plugin_by_node(coord->node)->
			plugin_by_coord(coord));
	assert("nikita-2479",
	       coord_iplug(coord) ==
	       node_plugin_by_node(coord->node)->plugin_by_coord(coord));
}
Example #7
0
/* this returns max key in the item */
reiser4_key *max_item_key_by_coord(const coord_t * coord /* coord to query */ ,
				   reiser4_key * key /* result */ )
{
	coord_t last;

	assert("nikita-338", coord != NULL);
	assert("nikita-339", coord->node != NULL);
	assert("nikita-340", znode_is_loaded(coord->node));

	/* make coord pointing to last item's unit */
	coord_dup(&last, coord);
	last.unit_pos = coord_num_units(&last) - 1;
	assert("vs-1560", coord_is_existing_unit(&last));

	max_unit_key_by_coord(&last, key);
	return key;
}
Example #8
0
/**
 * reiser4_replace_extent - replace extent and paste 1 or 2 after it
 * @un_extent: coordinate of extent to be overwritten
 * @lh: need better comment
 * @key: need better comment
 * @exts_to_add: data prepared for insertion into tree
 * @replace: need better comment
 * @flags: need better comment
 * @return_insert_position: need better comment
 *
 * Overwrites one extent, pastes 1 or 2 more ones after overwritten one.  If
 * @return_inserted_position is 1 - @un_extent and @lh are returned set to
 * first of newly inserted units, if it is 0 - @un_extent and @lh are returned
 * set to extent which was overwritten.
 */
int reiser4_replace_extent(struct replace_handle *h,
                           int return_inserted_position)
{
    int result;
    znode *orig_znode;
    /*ON_DEBUG(reiser4_extent orig_ext);*/	/* this is for debugging */

    assert("vs-990", coord_is_existing_unit(h->coord));
    assert("vs-1375", znode_is_write_locked(h->coord->node));
    assert("vs-1426", extent_get_width(&h->overwrite) != 0);
    assert("vs-1427", extent_get_width(&h->new_extents[0]) != 0);
    assert("vs-1427", ergo(h->nr_new_extents == 2,
                           extent_get_width(&h->new_extents[1]) != 0));

    /* compose structure for paste */
    init_new_extent(&h->item, &h->new_extents[0], h->nr_new_extents);

    coord_dup(&h->coord_after, h->coord);
    init_lh(&h->lh_after);
    copy_lh(&h->lh_after, h->lh);
    reiser4_tap_init(&h->watch, &h->coord_after, &h->lh_after, ZNODE_WRITE_LOCK);
    reiser4_tap_monitor(&h->watch);

    ON_DEBUG(h->orig_ext = *extent_by_coord(h->coord));
    orig_znode = h->coord->node;

#if REISER4_DEBUG
    /* make sure that key is set properly */
    unit_key_by_coord(h->coord, &h->tmp);
    set_key_offset(&h->tmp,
                   get_key_offset(&h->tmp) +
                   extent_get_width(&h->overwrite) * current_blocksize);
    assert("vs-1080", keyeq(&h->tmp, &h->paste_key));
#endif

    /* set insert point after unit to be replaced */
    h->coord->between = AFTER_UNIT;

    result = insert_into_item(h->coord, return_inserted_position ? h->lh : NULL,
                              &h->paste_key, &h->item, h->flags);
    if (!result) {
        /* now we have to replace the unit after which new units were
           inserted. Its position is tracked by @watch */
        reiser4_extent *ext;
        znode *node;

        node = h->coord_after.node;
        if (node != orig_znode) {
            coord_clear_iplug(&h->coord_after);
            result = zload(node);
        }

        if (likely(!result)) {
            ext = extent_by_coord(&h->coord_after);

            assert("vs-987", znode_is_loaded(node));
            assert("vs-988", !memcmp(ext, &h->orig_ext, sizeof(*ext)));

            /* overwrite extent unit */
            memcpy(ext, &h->overwrite, sizeof(reiser4_extent));
            znode_make_dirty(node);

            if (node != orig_znode)
                zrelse(node);

            if (return_inserted_position == 0) {
                /* coord and lh are to be set to overwritten
                   extent */
                assert("vs-1662",
                       WITH_DATA(node, !memcmp(&h->overwrite,
                                               extent_by_coord(
                                                   &h->coord_after),
                                               sizeof(reiser4_extent))));

                *h->coord = h->coord_after;
                done_lh(h->lh);
                copy_lh(h->lh, &h->lh_after);
            } else {
                /* h->coord and h->lh are to be set to first of
                   inserted units */
                assert("vs-1663",
                       WITH_DATA(h->coord->node,
                                 !memcmp(&h->new_extents[0],
                                         extent_by_coord(h->coord),
                                         sizeof(reiser4_extent))));
                assert("vs-1664", h->lh->node == h->coord->node);
            }
        }
    }
    reiser4_tap_done(&h->watch);

    return result;
}