cleanup: rename key and item_head accessors to more friendly names

This patch does a quick search and replace:
B_N_PITEM_HEAD() -> item_head()
B_N_PDELIM_KEY() -> internal_key()
B_N_PKEY() -> leaf_key()
B_N_PITEM() -> item_body()

And the item_head version:
B_I_PITEM() -> ih_item_body()
I_ENTRY_COUNT() -> ih_entry_count()

And the treepath variants:
get_ih() -> tp_item_head()
PATH_PITEM_HEAD() -> tp_item_head()
get_item() -> tp_item_body()

... which makes the code much easier on the eyes.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2013-08-26 17:15:33 -04:00
1 parent 290bb8c378
commit c1ff1d5d2d
28 files changed
+354 -355

No files matched your search

+36 -36
View File
@@ -58,7 +58,7 @@ static int balance_leaf_when_delete( /*struct reiserfs_transaction_handle *th, *
int n;
struct item_head *ih;
ih = B_N_PITEM_HEAD(tbS0, item_pos);
ih = item_head(tbS0, item_pos);
/* Delete or truncate the item */
@@ -241,7 +241,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
/* for indirect item pos_in_item is measured in unformatted node
pointers. Recalculate to bytes */
if (flag != M_INSERT
&& I_IS_INDIRECT_ITEM(B_N_PITEM_HEAD(tbS0, item_pos)))
&& I_IS_INDIRECT_ITEM(item_head(tbS0, item_pos)))
pos_in_item *= UNFM_P_SIZE;
if (tb->lnum[0] > 0) {
@@ -327,7 +327,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
&& tb->lbytes != -1) {
/* we must shift the part of the appended item */
if (I_IS_DIRECTORY_ITEM
(B_N_PITEM_HEAD(tbS0, item_pos))) {
(item_head(tbS0, item_pos))) {
/* directory item */
if (tb->lbytes > pos_in_item) {
/* new directory entry falls into L[0] */
@@ -349,7 +349,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
if (ret_val
&& !item_pos) {
pasted =
B_N_PITEM_HEAD
item_head
(tb->L[0],
B_NR_ITEMS
(tb->
@@ -438,7 +438,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
lnum
[0],
get_ih_item_len
(B_N_PITEM_HEAD
(item_head
(tbS0,
item_pos)));
/* Append to body of item in L[0] */
@@ -453,7 +453,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
n + item_pos -
ret_val,
get_ih_item_len
(B_N_PITEM_HEAD
(item_head
(tb->L[0],
n + item_pos -
ret_val)), l_n,
@@ -464,10 +464,10 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
/* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
//B_N_PKEY (tbS0, 0)->k_offset += l_n;z
key = B_N_PKEY(tbS0, 0);
key = leaf_key(tbS0, 0);
temp_n =
is_indirect_ih
(B_N_PITEM_HEAD
(item_head
(tb->L[0],
n + item_pos -
ret_val))
@@ -484,9 +484,9 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
(key) +
temp_n);
//B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0])->k_offset += l_n;
//internal_key(tb->CFL[0],tb->lkey[0])->k_offset += l_n;
key =
B_N_PDELIM_KEY(tb->
internal_key(tb->
CFL
[0],
tb->
@@ -531,7 +531,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
if (!item_pos && is_left_mergeable(tb->tb_fs, tb->tb_path) == 1) { /* if we paste into first item of S[0] and it is left mergable */
/* then increment pos_in_item by the size of the last item in L[0] */
pasted =
B_N_PITEM_HEAD(tb->L[0],
item_head(tb->L[0],
n - 1);
if (I_IS_DIRECTORY_ITEM(pasted))
pos_in_item +=
@@ -562,7 +562,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
/* if appended item is directory, paste entry */
pasted =
B_N_PITEM_HEAD(tb->L[0],
item_head(tb->L[0],
n + item_pos -
ret_val);
if (I_IS_DIRECTORY_ITEM(pasted))
@@ -720,13 +720,13 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
&& tb->rbytes != -1) {
/* we must shift the part of the appended item */
if (I_IS_DIRECTORY_ITEM
(B_N_PITEM_HEAD(tbS0, item_pos))) {
(item_head(tbS0, item_pos))) {
/* we append to directory item */
int entry_count;
entry_count =
get_ih_entry_count
(B_N_PITEM_HEAD
(item_head
(tbS0, item_pos));
if (entry_count - tb->rbytes <
pos_in_item) {
@@ -835,7 +835,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
n_rem;
if (is_indirect_key
(B_N_PKEY
(leaf_key
(tb->R[0], 0)))
temp_rem =
(n_rem /
@@ -844,9 +844,9 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
tb->tb_fs->
fs_blocksize;
//B_N_PKEY(tb->R[0],0)->k_offset += n_rem;
//leaf_key(tb->R[0],0)->k_offset += n_rem;
key =
B_N_PKEY(tb->R[0],
leaf_key(tb->R[0],
0);
set_offset(key_format
(key), key,
@@ -854,9 +854,9 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
(key) +
temp_rem);
//B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])->k_offset += n_rem;
//internal_key(tb->CFR[0],tb->rkey[0])->k_offset += n_rem;
key =
B_N_PDELIM_KEY(tb->
internal_key(tb->
CFR
[0],
tb->
@@ -902,10 +902,10 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
r_zeros_number);
if (I_IS_INDIRECT_ITEM
(B_N_PITEM_HEAD
(item_head
(tb->R[0], 0))) {
set_ih_free_space
(B_N_PITEM_HEAD
(item_head
(tb->R[0], 0), 0);
}
@@ -944,7 +944,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
/* paste new entry, if item is directory item */
pasted =
B_N_PITEM_HEAD(tb->R[0],
item_head(tb->R[0],
item_pos - n +
tb->rnum[0]);
if (I_IS_DIRECTORY_ITEM(pasted)
@@ -1006,8 +1006,8 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
if (!tb->CFR[0])
reiserfs_panic(tb->tb_fs,
"vs-12195: balance_leaf: CFR not initialized");
copy_key(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]));
copy_key(internal_key(tb->CFL[0], tb->lkey[0]),
internal_key(tb->CFR[0], tb->rkey[0]));
mark_buffer_dirty(tb->CFL[0]);
}
@@ -1131,7 +1131,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
if (I_IS_DIRECTORY_ITEM
(aux_ih =
B_N_PITEM_HEAD(tbS0, item_pos))) {
item_head(tbS0, item_pos))) {
/* we append to directory item */
int entry_count;
@@ -1248,7 +1248,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
r_body,
r_zeros_number);
tmp =
B_N_PITEM_HEAD(S_new[i], 0);
item_head(S_new[i], 0);
if (I_IS_INDIRECT_ITEM(tmp)) {
/*
if (n_rem)
@@ -1280,7 +1280,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
ih_key) +
n_rem);
//B_N_PKEY(S_new[i],0)->k_offset += n_rem;
//leaf_key(S_new[i],0)->k_offset += n_rem;
//
tb->insert_size[0] = n_rem;
@@ -1308,7 +1308,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
zeros_number);
pasted =
B_N_PITEM_HEAD(S_new[i],
item_head(S_new[i],
item_pos - n +
snum[i]);
if (I_IS_DIRECTORY_ITEM(pasted)) {
@@ -1348,7 +1348,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
"UNKNOWN"), flag);
}
memcpy(insert_key + i, B_N_PKEY(S_new[i], 0), KEY_SIZE);
memcpy(insert_key + i, leaf_key(S_new[i], 0), KEY_SIZE);
insert_ptr[i] = S_new[i];
}
@@ -1377,7 +1377,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
case M_PASTE:{ /* append item in S[0] */
struct item_head *pasted;
pasted = B_N_PITEM_HEAD(tbS0, item_pos);
pasted = item_head(tbS0, item_pos);
/* when directory, may be new entry already pasted */
if (I_IS_DIRECTORY_ITEM(pasted)) {
if (pos_in_item >= 0
@@ -1511,11 +1511,11 @@ void replace_key(reiserfs_filsys_t *fs,
if (dest) {
if (is_leaf_node(src))
/* source buffer contains leaf node */
memcpy(B_N_PDELIM_KEY(dest, n_dest),
B_N_PITEM_HEAD(src, n_src), KEY_SIZE);
memcpy(internal_key(dest, n_dest),
item_head(src, n_src), KEY_SIZE);
else
memcpy(B_N_PDELIM_KEY(dest, n_dest),
B_N_PDELIM_KEY(src, n_src), KEY_SIZE);
memcpy(internal_key(dest, n_dest),
internal_key(src, n_src), KEY_SIZE);
mark_buffer_dirty(dest);
}
@@ -1631,12 +1631,12 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure
/*item_pos */ == -1) {
/* get delimiting key from buffer in tree */
copy_key(&insert_key[0].ih_key,
B_N_PKEY(PATH_PLAST_BUFFER(tb->tb_path), 0));
leaf_key(PATH_PLAST_BUFFER(tb->tb_path), 0));
/*insert_ptr[0]->b_item_order = 0; */
} else {
/* get delimiting key from new buffer */
copy_key(&insert_key[0].ih_key,
B_N_PKEY((struct buffer_head *)body, 0));
leaf_key((struct buffer_head *)body, 0));
/*insert_ptr[0]->b_item_order = item_pos; */
}
+12 -12
View File
@@ -160,7 +160,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item);
/* first item in the node */
ih = B_N_PITEM_HEAD(Sh, 0);
ih = item_head(Sh, 0);
/* define the mergeability for 0-th item (if it is not being deleted) */
if (is_left_mergeable(tb->tb_fs, tb->tb_path) == 1
@@ -246,7 +246,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
/* set right merge flag we take right delimiting key and check whether it is a mergeable item */
if (tb->CFR[0]) {
ih = (struct item_head *)B_N_PDELIM_KEY(tb->CFR[0],
ih = (struct item_head *)internal_key(tb->CFR[0],
tb->rkey[0]);
if (is_right_mergeable(tb->tb_fs, tb->tb_path) == 1
&& (vn->vn_mode != M_DELETE
@@ -911,7 +911,7 @@ static struct buffer_head *get_left_neighbor(reiserfs_filsys_t *s,
struct reiserfs_path path_to_left_neighbor;
struct buffer_head *bh;
copy_key(&key, B_N_PKEY(PATH_PLAST_BUFFER(path), 0));
copy_key(&key, leaf_key(PATH_PLAST_BUFFER(path), 0));
decrement_key(&key);
init_path(&path_to_left_neighbor);
@@ -960,14 +960,14 @@ int is_left_mergeable(reiserfs_filsys_t *s, struct reiserfs_path *path)
struct buffer_head *bh;
int retval;
right = B_N_PITEM_HEAD(PATH_PLAST_BUFFER(path), 0);
right = item_head(PATH_PLAST_BUFFER(path), 0);
bh = get_left_neighbor(s, path);
if (bh == 0) {
return 0;
}
retval =
are_items_mergeable(B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1), right,
are_items_mergeable(item_head(bh, B_NR_ITEMS(bh) - 1), right,
bh->b_size);
brelse(bh);
return retval;
@@ -980,14 +980,14 @@ int is_right_mergeable(reiserfs_filsys_t *s, struct reiserfs_path *path)
int retval;
left =
B_N_PITEM_HEAD(PATH_PLAST_BUFFER(path),
item_head(PATH_PLAST_BUFFER(path),
B_NR_ITEMS(PATH_PLAST_BUFFER(path)) - 1);
bh = get_right_neighbor(s, path);
if (bh == 0) {
return 0;
}
retval = are_items_mergeable(left, B_N_PITEM_HEAD(bh, 0), bh->b_size);
retval = are_items_mergeable(left, item_head(bh, 0), bh->b_size);
brelse(bh);
return retval;
}
@@ -1055,10 +1055,10 @@ static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree)
/* there was only one item and it will be deleted */
struct item_head *ih;
ih = B_N_PITEM_HEAD(S0, 0);
ih = item_head(S0, 0);
if (tb->CFR[0]
&& !not_of_one_file(&(ih->ih_key),
B_N_PDELIM_KEY(tb->CFR[0],
internal_key(tb->CFR[0],
tb->rkey[0])))
if (I_IS_DIRECTORY_ITEM(ih)) {
/* we can delete any directory item in fsck (if it is unreachable) */
@@ -1078,7 +1078,7 @@ static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree)
("vs-8135: are_leaves_removable: "
"empty node in the tree");
last =
B_N_PITEM_HEAD(left,
item_head(left,
B_NR_ITEMS
(left) - 1);
if (!comp_short_keys
@@ -1382,7 +1382,7 @@ static int get_far_parent(struct tree_balance *p_s_tb,
/* Form key to get parent of the left/right neighbor. */
copy_key(&s_lr_father_key,
B_N_PDELIM_KEY(*pp_s_com_father,
internal_key(*pp_s_com_father,
(c_lr_par ==
LEFT_PARENTS) ? (p_s_tb->lkey[n_h - 1] =
n_position -
@@ -1505,7 +1505,7 @@ static inline int can_node_be_removed(int mode, int lfree, int sfree, int rfree,
if (tb->CFR[h])
r_ih =
(struct item_head *)B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]);
(struct item_head *)internal_key(tb->CFR[h], tb->rkey[h]);
if (lfree + rfree + sfree < (int)(MAX_CHILD_SIZE(Sh->b_size) + levbytes
/* shifting may merge items which might save space */
+11 -11
View File
@@ -134,7 +134,7 @@ static void internal_insert_childs(reiserfs_filsys_t *fs,
/* prepare space for 'count' items */
from = ((to == -1) ? 0 : to);
key = B_N_PDELIM_KEY(cur, from);
key = internal_key(cur, from);
memmove(key + count, key,
(nr - from /*to */ ) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
@@ -190,7 +190,7 @@ static void internal_delete_pointers_items(reiserfs_filsys_t *fs,
dc = B_N_CHILD(cur, first_p);
memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE);
key = B_N_PDELIM_KEY(cur, first_i);
key = internal_key(cur, first_i);
memmove(key, key + del_num,
(nr - first_i - del_num) * KEY_SIZE + (nr + 1 -
del_num) * DC_SIZE);
@@ -269,13 +269,13 @@ static void internal_copy_pointers_items(reiserfs_filsys_t *fs,
memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num);
/* prepare space for cpy_num - 1 item headers */
key = B_N_PDELIM_KEY(dest, dest_order);
key = internal_key(dest, dest_order);
memmove(key + cpy_num - 1, key,
KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest +
cpy_num));
/* insert headers */
memcpy(key, B_N_PDELIM_KEY(src, src_order), KEY_SIZE * (cpy_num - 1));
memcpy(key, internal_key(src, src_order), KEY_SIZE * (cpy_num - 1));
/* sizes, item number */
set_blkh_nr_items(blkh, get_blkh_nr_items(blkh) + cpy_num - 1);
@@ -345,12 +345,12 @@ static void internal_insert_key(reiserfs_filsys_t *fs, struct buffer_info *dest_
nr = get_blkh_nr_items(blkh);
/* prepare space for inserting key */
key = B_N_PDELIM_KEY(dest, dest_position_before);
key = internal_key(dest, dest_position_before);
memmove(key + 1, key,
(nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
/* insert key */
memcpy(key, B_N_PDELIM_KEY(src, src_position), KEY_SIZE);
memcpy(key, internal_key(src, src_position), KEY_SIZE);
/* Change dirt, free space, item number fields. */
set_blkh_nr_items(blkh, get_blkh_nr_items(blkh) + 1);
@@ -585,7 +585,7 @@ void replace_lkey(struct tree_balance *tb, int h, struct item_head *key)
if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0)
return;
memcpy(B_N_PDELIM_KEY(tb->CFL[h], tb->lkey[h]), key, KEY_SIZE);
memcpy(internal_key(tb->CFL[h], tb->lkey[h]), key, KEY_SIZE);
mark_buffer_dirty(tb->CFL[h]);
}
@@ -593,7 +593,7 @@ void replace_lkey(struct tree_balance *tb, int h, struct item_head *key)
/* Replace delimiting key of buffers S[h] and R[h] by the given key.*/
void replace_rkey(struct tree_balance *tb, int h, struct item_head *key)
{
memcpy(B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]), key, KEY_SIZE);
memcpy(internal_key(tb->CFR[h], tb->rkey[h]), key, KEY_SIZE);
mark_buffer_dirty(tb->CFR[h]);
}
@@ -842,7 +842,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* new items don't fall into S_new */
/* store the delimiting key for the next level */
/* new_insert_key = (n - snum)'th key in S[h] */
memcpy(&new_insert_key, B_N_PDELIM_KEY(tbSh, n - snum),
memcpy(&new_insert_key, internal_key(tbSh, n - snum),
KEY_SIZE);
/* last parameter is del_par */
internal_move_pointers_items(tb->tb_fs, &dest_bi,
@@ -853,7 +853,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* store the delimiting key for the next level */
/* new_insert_key = (n + insert_item - snum)'th key in S[h] */
memcpy(&new_insert_key,
B_N_PDELIM_KEY(tbSh, n + insert_num - snum),
internal_key(tbSh, n + insert_num - snum),
KEY_SIZE);
/* last parameter is del_par */
internal_move_pointers_items(tb->tb_fs, &dest_bi,
@@ -930,7 +930,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* insert_child (tb->S[h], tb->S[h-1], child_pos, insert_num, B_N_ITEM_HEAD(tb->S[0],0), insert_ptr); */
internal_insert_childs(tb->tb_fs, &bi, child_pos,
insert_num,
B_N_PITEM_HEAD(PATH_PLAST_BUFFER
item_head(PATH_PLAST_BUFFER
(tb->tb_path), 0),
insert_ptr);
} else
+26 -26
View File
@@ -38,7 +38,7 @@ static void leaf_copy_dir_entries(reiserfs_filsys_t *fs,
int copy_records_len; /* length of all records in item to be copied */
char *records;
ih = B_N_PITEM_HEAD(source, item_num);
ih = item_head(source, item_num);
/* length of all record to be copied and first byte of the last of them */
deh = B_I_DEH(source, ih);
@@ -65,11 +65,11 @@ static void leaf_copy_dir_entries(reiserfs_filsys_t *fs,
/* if there are no items in dest or the first/last item in dest is not item of the same directory */
if ((item_num_in_dest == -1) ||
(last_first == FIRST_TO_LAST
&& are_items_mergeable(B_N_PITEM_HEAD(dest, item_num_in_dest), ih,
&& are_items_mergeable(item_head(dest, item_num_in_dest), ih,
dest->b_size) == 0)
|| (last_first == LAST_TO_FIRST
&& are_items_mergeable(ih,
B_N_PITEM_HEAD(dest, item_num_in_dest),
item_head(dest, item_num_in_dest),
dest->b_size) == 0)) {
/* create new item in dest */
struct item_head new_ih;
@@ -119,7 +119,7 @@ static void leaf_copy_dir_entries(reiserfs_filsys_t *fs,
leaf_paste_entries(dest_bi->bi_bh, item_num_in_dest,
(last_first ==
FIRST_TO_LAST) ?
get_ih_entry_count(B_N_PITEM_HEAD
get_ih_entry_count(item_head
(dest, item_num_in_dest)) : 0,
copy_count, deh + from, records,
DEH_SIZE * copy_count + copy_records_len);
@@ -145,8 +145,8 @@ static int leaf_copy_boundary_item(reiserfs_filsys_t *fs,
/* if ( DEST is empty or first item of SOURCE and last item of DEST are the items of different objects
or of different types ) then there is no need to treat this item differently from the other items
that we copy, so we return */
ih = B_N_PITEM_HEAD(src, 0);
dih = B_N_PITEM_HEAD(dest, dest_nr_item - 1);
ih = item_head(src, 0);
dih = item_head(dest, dest_nr_item - 1);
if (!dest_nr_item
|| (are_items_mergeable(dih, ih, src->b_size) == 0))
/* there is nothing to merge */
@@ -171,7 +171,7 @@ static int leaf_copy_boundary_item(reiserfs_filsys_t *fs,
item of dest buffer. Both are of the same file */
leaf_paste_in_buffer(fs, dest_bi, dest_nr_item - 1,
get_ih_item_len(dih), bytes_or_entries,
B_I_PITEM(src, ih), 0);
ih_item_body(src, ih), 0);
if (I_IS_INDIRECT_ITEM(dih)) {
if (bytes_or_entries == get_ih_item_len(ih))
@@ -188,8 +188,8 @@ static int leaf_copy_boundary_item(reiserfs_filsys_t *fs,
are the items of different object or of different types )
*/
src_nr_item = B_NR_ITEMS(src);
ih = B_N_PITEM_HEAD(src, src_nr_item - 1);
dih = B_N_PITEM_HEAD(dest, 0);
ih = item_head(src, src_nr_item - 1);
dih = item_head(dest, 0);
if (!dest_nr_item || are_items_mergeable(ih, dih, src->b_size) == 0)
return 0;
@@ -242,7 +242,7 @@ static int leaf_copy_boundary_item(reiserfs_filsys_t *fs,
}
leaf_paste_in_buffer(fs, dest_bi, 0, 0, bytes_or_entries,
B_I_PITEM(src,
ih_item_body(src,
ih) + get_ih_item_len(ih) -
bytes_or_entries, 0);
return 1;
@@ -277,13 +277,13 @@ static void leaf_copy_items_entirely(reiserfs_filsys_t *fs,
dest_before = (last_first == LAST_TO_FIRST) ? 0 : nr;
/* location of head of first new item */
ih = B_N_PITEM_HEAD(dest, dest_before);
ih = item_head(dest, dest_before);
/* prepare space for headers */
memmove(ih + cpy_num, ih, (nr - dest_before) * IH_SIZE);
/* copy item headers */
memcpy(ih, B_N_PITEM_HEAD(src, first), cpy_num * IH_SIZE);
memcpy(ih, item_head(src, first), cpy_num * IH_SIZE);
set_blkh_free_space(blkh,
get_blkh_free_space(blkh) - IH_SIZE * cpy_num);
@@ -307,7 +307,7 @@ static void leaf_copy_items_entirely(reiserfs_filsys_t *fs,
/* copy items */
memcpy(dest->b_data + last_inserted_loc,
B_N_PITEM(src, (first + cpy_num - 1)), j - last_inserted_loc);
item_body(src, (first + cpy_num - 1)), j - last_inserted_loc);
/* sizes, item number */
set_blkh_nr_items(blkh, get_blkh_nr_items(blkh) + cpy_num);
@@ -339,7 +339,7 @@ static void leaf_item_bottle(reiserfs_filsys_t *fs,
if (last_first == FIRST_TO_LAST) {
/* if ( if item in position item_num in buffer SOURCE is directory item ) */
if (I_IS_DIRECTORY_ITEM(ih = B_N_PITEM_HEAD(src, item_num)))
if (I_IS_DIRECTORY_ITEM(ih = item_head(src, item_num)))
leaf_copy_dir_entries(fs, dest_bi, src, FIRST_TO_LAST,
item_num, 0, cpy_bytes);
else {
@@ -359,12 +359,12 @@ static void leaf_item_bottle(reiserfs_filsys_t *fs,
set_ih_key_format(&n_ih, get_ih_key_format(ih));
set_ih_flags(&n_ih, get_ih_flags(ih));
leaf_insert_into_buf(fs, dest_bi, B_NR_ITEMS(dest),
&n_ih, B_N_PITEM(src, item_num),
&n_ih, item_body(src, item_num),
0);
}
} else {
/* if ( if item in position item_num in buffer SOURCE is directory item ) */
if (I_IS_DIRECTORY_ITEM(ih = B_N_PITEM_HEAD(src, item_num)))
if (I_IS_DIRECTORY_ITEM(ih = item_head(src, item_num)))
leaf_copy_dir_entries(fs, dest_bi, src, LAST_TO_FIRST,
item_num,
get_ih_entry_count(ih) -
@@ -411,7 +411,7 @@ static void leaf_item_bottle(reiserfs_filsys_t *fs,
set_ih_key_format(&n_ih, get_ih_key_format(ih));
set_ih_flags(&n_ih, get_ih_flags(ih));
leaf_insert_into_buf(fs, dest_bi, 0, &n_ih,
B_N_PITEM(src,
item_body(src,
item_num) +
get_ih_item_len(ih) - cpy_bytes,
0);
@@ -681,7 +681,7 @@ void leaf_delete_items(reiserfs_filsys_t *fs,
del_num - 1);
if (I_IS_DIRECTORY_ITEM
(ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1)))
(ih = item_head(bh, B_NR_ITEMS(bh) - 1)))
/* the last item is directory */
/* len = numbers of directory entries in this item */
len = get_ih_entry_count(ih);
@@ -717,7 +717,7 @@ void leaf_insert_into_buf(reiserfs_filsys_t *s,
nr = get_blkh_nr_items(blkh);
/* get item new item must be inserted before */
ih = B_N_PITEM_HEAD(bh, before);
ih = item_head(bh, before);
/* prepare space for the body of new item */
last_loc = nr ? get_ih_location(&ih[nr - before - 1]) : bh->b_size;
@@ -793,7 +793,7 @@ void leaf_paste_in_buffer(reiserfs_filsys_t *fs,
nr = get_blkh_nr_items(blkh);
/* item to be appended */
ih = B_N_PITEM_HEAD(bh, affected_item_num);
ih = item_head(bh, affected_item_num);
last_loc = get_ih_location(&ih[nr - affected_item_num - 1]);
unmoved_loc = affected_item_num ? get_ih_location(ih - 1) : bh->b_size;
@@ -877,7 +877,7 @@ static int leaf_cut_entries(struct buffer_head *bh,
int entry_count;
/* first byte of item */
item = B_I_PITEM(bh, ih);
item = ih_item_body(bh, ih);
/* entry head array */
deh = B_I_DEH(bh, ih);
@@ -959,7 +959,7 @@ void leaf_cut_from_buffer(reiserfs_filsys_t *fs,
nr = get_blkh_nr_items(blkh);
/* item head of truncated item */
ih = B_N_PITEM_HEAD(bh, cut_item_num);
ih = item_head(bh, cut_item_num);
if (I_IS_DIRECTORY_ITEM(ih)) {
/* first cut entry () */
@@ -1063,7 +1063,7 @@ static void leaf_delete_items_entirely(reiserfs_filsys_t *fs,
return;
}
ih = B_N_PITEM_HEAD(bh, first);
ih = item_head(bh, first);
/* location of unmovable item */
j = (first == 0) ? bh->b_size : get_ih_location(ih - 1);
@@ -1122,10 +1122,10 @@ void leaf_paste_entries(struct buffer_head *bh,
if (new_entry_count == 0)
return;
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
/* first byte of dest item */
item = B_I_PITEM(bh, ih);
item = ih_item_body(bh, ih);
/* entry head array */
deh = B_I_DEH(bh, ih);
@@ -1148,7 +1148,7 @@ void leaf_paste_entries(struct buffer_head *bh,
get_deh_location(deh + i) + paste_size);
old_entry_num = get_ih_entry_count(ih);
//I_ENTRY_COUNT(ih) += new_entry_count;
//ih_entry_count(ih) += new_entry_count;
set_ih_entry_count(ih, old_entry_num + new_entry_count);
/* prepare space for pasted records */
+1 -1
View File
@@ -842,7 +842,7 @@ void for_every_item(struct buffer_head *bh, item_head_action_t action,
struct item_head *ih;
item_action_t iaction;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
for (i = 0; i < get_blkh_nr_items(B_BLK_HEAD(bh)); i++, ih++) {
if (action)
action(ih);
+10 -10
View File
@@ -365,8 +365,8 @@ void print_indirect_item(FILE * fp, struct buffer_head *bh, int item_num)
__u32 *unp, prev = INT_MAX;
int num = 0;
ih = B_N_PITEM_HEAD(bh, item_num);
unp = (__u32 *) B_I_PITEM(bh, ih);
ih = item_head(bh, item_num);
unp = (__u32 *) ih_item_body(bh, ih);
if (get_ih_item_len(ih) % UNFM_P_SIZE)
reiserfs_warning(fp, "print_indirect_item: invalid item len");
@@ -400,7 +400,7 @@ static int print_stat_data(FILE * fp, struct buffer_head *bh,
macro. Stat data's key looks identical in both formats */
if (get_ih_key_format(ih) == KEY_FORMAT_1) {
struct stat_data_v1 *sd_v1 =
(struct stat_data_v1 *)B_I_PITEM(bh, ih);
(struct stat_data_v1 *)ih_item_body(bh, ih);
reiserfs_warning(fp,
"(OLD SD), mode %M, size %u, nlink %u, uid %u, FDB %u, mtime %s blocks %u",
sd_v1_mode(sd_v1), sd_v1_size(sd_v1),
@@ -414,7 +414,7 @@ static int print_stat_data(FILE * fp, struct buffer_head *bh,
timestamp(sd_v1_ctime(sd_v1)),
timestamp(sd_v1_atime(sd_v1)));
} else {
struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
struct stat_data *sd = (struct stat_data *)ih_item_body(bh, ih);
reiserfs_warning(fp,
"(NEW SD), mode %M, size %Lu, nlink %u, mtime %s blocks %u, uid %u",
sd_v2_mode(sd), sd_v2_size(sd),
@@ -438,14 +438,14 @@ void reiserfs_print_item(FILE * fp, struct buffer_head *bh,
reiserfs_warning(fp, "block %lu, item %d: %H\n",
bh->b_blocknr,
(ih -
B_N_PITEM_HEAD(bh, 0)) / sizeof(struct item_head),
item_head(bh, 0)) / sizeof(struct item_head),
ih);
if (is_stat_data_ih(ih)) {
print_stat_data(fp, bh, ih, 0 /*all times */ );
return;
}
if (is_indirect_ih(ih)) {
print_indirect_item(fp, bh, ih - B_N_PITEM_HEAD(bh, 0));
print_indirect_item(fp, bh, ih - item_head(bh, 0));
return;
}
if (is_direct_ih(ih)) {
@@ -487,7 +487,7 @@ static int print_internal(FILE * fp, struct buffer_head *bh, int first,
dc = B_N_CHILD(bh, from);
reiserfs_warning(fp, "PTR %d: %y ", from, dc);
for (i = from, key = B_N_PDELIM_KEY(bh, from), dc++; i < to;
for (i = from, key = internal_key(bh, from), dc++; i < to;
i++, key++, dc++) {
reiserfs_warning(fp, "KEY %d: %20k PTR %d: %20y ", i, key,
i + 1, dc);
@@ -510,7 +510,7 @@ static int print_leaf(FILE * fp, reiserfs_filsys_t *fs, struct buffer_head *bh,
if (!is_tree_node(bh, DISK_LEAF_NODE_LEVEL))
return 1;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
real_nr = leaf_count_ih(bh->b_data, bh->b_size);
nr = get_blkh_nr_items((struct block_head *)bh->b_data);
@@ -566,11 +566,11 @@ static int print_leaf(FILE * fp, reiserfs_filsys_t *fs, struct buffer_head *bh,
if (is_symlink || print_mode & PRINT_DIRECT_ITEMS) {
reiserfs_warning(fp, "\"");
while (j < get_ih_item_len(&ih[i])) {
if (B_I_PITEM(bh, ih + i)[j] == 10)
if (ih_item_body(bh, ih + i)[j] == 10)
reiserfs_warning(fp, "\\n");
else
reiserfs_warning(fp, "%c",
B_I_PITEM(bh,
ih_item_body(bh,
ih +
i)
[j]);
+19 -19
View File
@@ -470,7 +470,7 @@ static int reiserfs_search_by_key_x(reiserfs_filsys_t *fs,
return ITEM_NOT_FOUND;
}
retval =
reiserfs_bin_search(key, B_N_PKEY(bh, 0), B_NR_ITEMS(bh),
reiserfs_bin_search(key, leaf_key(bh, 0), B_NR_ITEMS(bh),
is_leaf_node(bh) ? IH_SIZE : KEY_SIZE,
&curr->pe_position,
key_length ==
@@ -517,7 +517,7 @@ int usearch_by_position(reiserfs_filsys_t *s, struct reiserfs_key *key,
struct reiserfs_key *next_key;
if (reiserfs_search_by_key_3(s, key, path) == ITEM_FOUND) {
ih = get_ih(path);
ih = tp_item_head(path);
if (!is_direct_ih(ih) && !is_indirect_ih(ih))
return DIRECTORY_FOUND;
@@ -527,7 +527,7 @@ int usearch_by_position(reiserfs_filsys_t *s, struct reiserfs_key *key,
}
bh = get_bh(path);
ih = get_ih(path);
ih = tp_item_head(path);
if (PATH_LAST_POSITION(path) == 0) {
/* previous item does not exist, that means we are in leftmost leaf of
@@ -550,7 +550,7 @@ int usearch_by_position(reiserfs_filsys_t *s, struct reiserfs_key *key,
PATH_LAST_POSITION(path)++;
if (PATH_LAST_POSITION(path) < B_NR_ITEMS(bh))
/* next key is in the same node */
next_key = B_N_PKEY(bh, PATH_LAST_POSITION(path));
next_key = leaf_key(bh, PATH_LAST_POSITION(path));
else
next_key = uget_rkey(path);
if (next_key == 0 || not_of_one_file(next_key, key)) {
@@ -638,7 +638,7 @@ struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
/* Return delimiting key if position in the parent is not equal to zero. */
if (pos)
return B_N_PDELIM_KEY(bh, pos - 1);
return internal_key(bh, pos - 1);
}
/* there is no left delimiting key */
@@ -675,7 +675,7 @@ struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
/* Return delimiting key if position in the parent is not the last one. */
if (pos != B_NR_ITEMS(bh))
return B_N_PDELIM_KEY(bh, pos);
return internal_key(bh, pos);
}
/* there is no right delimiting key */
@@ -685,7 +685,7 @@ struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
struct reiserfs_key *reiserfs_next_key(struct reiserfs_path *path)
{
if (get_item_pos(path) < B_NR_ITEMS(get_bh(path)) - 1)
return B_N_PKEY(get_bh(path), get_item_pos(path) + 1);
return leaf_key(get_bh(path), get_item_pos(path) + 1);
return uget_rkey(path);
}
@@ -708,7 +708,7 @@ int reiserfs_search_by_entry_key(reiserfs_filsys_t *fs,
bh = get_bh(path);
item_pos = get_item_pos(path);
ih = get_ih(path);
ih = tp_item_head(path);
if (item_pos == 0) {
/* key is less than the smallest key in the tree */
@@ -817,7 +817,7 @@ int reiserfs_remove_entry(reiserfs_filsys_t *fs, struct reiserfs_key *key)
return 1;
}
ih = get_ih(&path);
ih = tp_item_head(&path);
if (get_ih_entry_count(ih) == 1) {
init_tb_struct(&tb, fs, &path,
-(IH_SIZE + get_ih_item_len(ih)));
@@ -903,7 +903,7 @@ int reiserfs_locate_entry(reiserfs_filsys_t *fs, struct reiserfs_key *dir,
}
do {
ih = get_ih(path);
ih = tp_item_head(path);
deh = B_I_DEH(get_bh(path), ih) + path->pos_in_item;
for (i = path->pos_in_item; i < get_ih_entry_count(ih);
i++, deh++) {
@@ -978,7 +978,7 @@ int reiserfs_find_entry(reiserfs_filsys_t *fs, struct reiserfs_key *dir,
}
do {
ih = get_ih(&path);
ih = tp_item_head(&path);
deh = B_I_DEH(get_bh(&path), ih) + path.pos_in_item;
for (i = path.pos_in_item; i < get_ih_entry_count(ih);
i++, deh++) {
@@ -1210,14 +1210,14 @@ void make_sure_root_dir_exists(reiserfs_filsys_t *fs,
root_dir_format =
create_dir_sd(fs, &path, &root_dir_key, modify_item);
} else {
struct item_head *ih = get_ih(&path);
struct item_head *ih = tp_item_head(&path);
if (!is_stat_data_ih(ih))
reiserfs_panic("It must be root's stat data %k\n",
&ih->ih_key);
root_dir_format =
(get_ih_item_len(get_ih(&path)) ==
(get_ih_item_len(tp_item_head(&path)) ==
SD_SIZE) ? KEY_FORMAT_2 : KEY_FORMAT_1;
pathrelse(&path);
}
@@ -1371,7 +1371,7 @@ void badblock_list(reiserfs_filsys_t *fs, badblock_func_t action, void *data)
break;
}
rd_key = get_ih(&badblock_path)->ih_key;
rd_key = tp_item_head(&badblock_path)->ih_key;
if (get_key_dirid(&rd_key) != BADBLOCK_DIRID ||
get_key_objectid(&rd_key) != BADBLOCK_OBJID ||
@@ -1399,12 +1399,12 @@ static void callback_badblock_rm(reiserfs_filsys_t *fs,
struct tree_balance tb;
struct item_head *tmp_ih;
tmp_ih = get_ih(badblock_path);
memset(get_item(badblock_path), 0, get_ih_item_len(tmp_ih));
tmp_ih = tp_item_head(badblock_path);
memset(tp_item_body(badblock_path), 0, get_ih_item_len(tmp_ih));
init_tb_struct(&tb, fs, badblock_path,
-(IH_SIZE +
get_ih_item_len(PATH_PITEM_HEAD(badblock_path))));
get_ih_item_len(tp_item_head(badblock_path))));
if (fix_nodes(M_DELETE, &tb, 0) != CARRY_ON)
die("%s: fix_nodes failed", __FUNCTION__);
@@ -1423,8 +1423,8 @@ void mark_badblock(reiserfs_filsys_t *fs,
if (!fs->fs_badblocks_bm)
create_badblock_bitmap(fs, NULL);
tmp_ih = get_ih(badblock_path);
ind_item = (__u32 *) get_item(badblock_path);
tmp_ih = tp_item_head(badblock_path);
ind_item = (__u32 *) tp_item_body(badblock_path);
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
reiserfs_bitmap_set_bit(fs->fs_badblocks_bm,
+3 -3
View File
@@ -214,7 +214,7 @@ struct reiserfs_key *get_lkey(struct reiserfs_path *p_s_chk_path,
return &MAX_KEY;
/* Return delimiting key if position in the parent is not equal to zero. */
if (n_position)
return B_N_PDELIM_KEY(p_s_parent, n_position - 1);
return internal_key(p_s_parent, n_position - 1);
}
/* Return MIN_KEY if we are in the root of the buffer tree. */
if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
@@ -252,7 +252,7 @@ struct reiserfs_key *get_rkey(struct reiserfs_path *p_s_chk_path,
return &MIN_KEY;
/* Return delimiting key if position in the parent is not the last one. */
if (n_position != B_NR_ITEMS(p_s_parent))
return B_N_PDELIM_KEY(p_s_parent, n_position);
return internal_key(p_s_parent, n_position);
}
/* Return MAX_KEY if we are in the root of the buffer tree. */
if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
@@ -379,7 +379,7 @@ int search_by_key(reiserfs_filsys_t *fs, struct reiserfs_key *p_s_key, /* Key to
/* ok, we have acquired next formatted node in the tree */
n_retval =
bin_search(p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
bin_search(p_s_key, item_head(p_s_bh, 0),
B_NR_ITEMS(p_s_bh),
is_leaf_node(p_s_bh) ? IH_SIZE : KEY_SIZE,
&(p_s_last_element->pe_position));