Commit 4cf5f7ad authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Jan Kara

reiserfs: cleanup, rename key and item 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.

I've also removed a few unused macros.

Checkpatch will complain about the 80 character limit for do_balan.c.
I've addressed that in a later patchset to split up balance_leaf().
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 797d9016
...@@ -819,9 +819,9 @@ static int get_left_neighbor(reiserfs_blocknr_hint_t * hint) ...@@ -819,9 +819,9 @@ static int get_left_neighbor(reiserfs_blocknr_hint_t * hint)
path = hint->path; path = hint->path;
bh = get_last_bh(path); bh = get_last_bh(path);
RFALSE(!bh, "green-4002: Illegal path specified to get_left_neighbor"); RFALSE(!bh, "green-4002: Illegal path specified to get_left_neighbor");
ih = get_ih(path); ih = tp_item_head(path);
pos_in_item = path->pos_in_item; pos_in_item = path->pos_in_item;
item = get_item(path); item = tp_item_body(path);
hint->search_start = bh->b_blocknr; hint->search_start = bh->b_blocknr;
......
...@@ -110,17 +110,17 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx) ...@@ -110,17 +110,17 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
item_num, B_NR_ITEMS(bh)); item_num, B_NR_ITEMS(bh));
/* and entry must be not more than number of entries in the item */ /* and entry must be not more than number of entries in the item */
RFALSE(I_ENTRY_COUNT(ih) < entry_num, RFALSE(ih_entry_count(ih) < entry_num,
"vs-9010: entry number is too big %d (%d)", "vs-9010: entry number is too big %d (%d)",
entry_num, I_ENTRY_COUNT(ih)); entry_num, ih_entry_count(ih));
if (search_res == POSITION_FOUND if (search_res == POSITION_FOUND
|| entry_num < I_ENTRY_COUNT(ih)) { || entry_num < ih_entry_count(ih)) {
/* go through all entries in the directory item beginning from the entry, that has been found */ /* go through all entries in the directory item beginning from the entry, that has been found */
struct reiserfs_de_head *deh = struct reiserfs_de_head *deh =
B_I_DEH(bh, ih) + entry_num; B_I_DEH(bh, ih) + entry_num;
for (; entry_num < I_ENTRY_COUNT(ih); for (; entry_num < ih_entry_count(ih);
entry_num++, deh++) { entry_num++, deh++) {
int d_reclen; int d_reclen;
char *d_name; char *d_name;
......
This diff is collapsed.
...@@ -105,7 +105,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) ...@@ -105,7 +105,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item); vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item);
/* first item in the node */ /* 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) */ /* define the mergeability for 0-th item (if it is not being deleted) */
if (op_is_left_mergeable(&(ih->ih_key), Sh->b_size) if (op_is_left_mergeable(&(ih->ih_key), Sh->b_size)
...@@ -128,7 +128,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) ...@@ -128,7 +128,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE; vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE;
vi->vi_ih = ih + j; vi->vi_ih = ih + j;
vi->vi_item = B_I_PITEM(Sh, ih + j); vi->vi_item = ih_item_body(Sh, ih + j);
vi->vi_uarea = vn->vn_free_ptr; vi->vi_uarea = vn->vn_free_ptr;
// FIXME: there is no check, that item operation did not // FIXME: there is no check, that item operation did not
...@@ -168,7 +168,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) ...@@ -168,7 +168,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
if (tb->CFR[0]) { if (tb->CFR[0]) {
struct reiserfs_key *key; struct reiserfs_key *key;
key = B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]); key = internal_key(tb->CFR[0], tb->rkey[0]);
if (op_is_left_mergeable(key, Sh->b_size) if (op_is_left_mergeable(key, Sh->b_size)
&& (vn->vn_mode != M_DELETE && (vn->vn_mode != M_DELETE
|| vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1)) || vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1))
...@@ -182,8 +182,8 @@ static void create_virtual_node(struct tree_balance *tb, int h) ...@@ -182,8 +182,8 @@ static void create_virtual_node(struct tree_balance *tb, int h)
/* we delete last item and it could be merged with right neighbor's first item */ /* we delete last item and it could be merged with right neighbor's first item */
if (! if (!
(B_NR_ITEMS(Sh) == 1 (B_NR_ITEMS(Sh) == 1
&& is_direntry_le_ih(B_N_PITEM_HEAD(Sh, 0)) && is_direntry_le_ih(item_head(Sh, 0))
&& I_ENTRY_COUNT(B_N_PITEM_HEAD(Sh, 0)) == 1)) { && ih_entry_count(item_head(Sh, 0)) == 1)) {
/* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */ /* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */
print_block(Sh, 0, -1, -1); print_block(Sh, 0, -1, -1);
reiserfs_panic(tb->tb_sb, "vs-8045", reiserfs_panic(tb->tb_sb, "vs-8045",
...@@ -675,10 +675,10 @@ static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree) ...@@ -675,10 +675,10 @@ static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree)
"vs-8125: item number must be 1: it is %d", "vs-8125: item number must be 1: it is %d",
B_NR_ITEMS(S0)); B_NR_ITEMS(S0));
ih = B_N_PITEM_HEAD(S0, 0); ih = item_head(S0, 0);
if (tb->CFR[0] if (tb->CFR[0]
&& !comp_short_le_keys(&(ih->ih_key), && !comp_short_le_keys(&(ih->ih_key),
B_N_PDELIM_KEY(tb->CFR[0], internal_key(tb->CFR[0],
tb->rkey[0]))) tb->rkey[0])))
if (is_direntry_le_ih(ih)) { if (is_direntry_le_ih(ih)) {
/* Directory must be in correct state here: that is /* Directory must be in correct state here: that is
...@@ -1036,7 +1036,7 @@ static int get_far_parent(struct tree_balance *tb, ...@@ -1036,7 +1036,7 @@ static int get_far_parent(struct tree_balance *tb,
/* Form key to get parent of the left/right neighbor. */ /* Form key to get parent of the left/right neighbor. */
le_key2cpu_key(&s_lr_father_key, le_key2cpu_key(&s_lr_father_key,
B_N_PDELIM_KEY(*pcom_father, internal_key(*pcom_father,
(c_lr_par == (c_lr_par ==
LEFT_PARENTS) ? (tb->lkey[h - 1] = LEFT_PARENTS) ? (tb->lkey[h - 1] =
position - position -
...@@ -1175,9 +1175,9 @@ static inline int can_node_be_removed(int mode, int lfree, int sfree, int rfree, ...@@ -1175,9 +1175,9 @@ static inline int can_node_be_removed(int mode, int lfree, int sfree, int rfree,
struct item_head *ih; struct item_head *ih;
struct reiserfs_key *r_key = NULL; struct reiserfs_key *r_key = NULL;
ih = B_N_PITEM_HEAD(Sh, 0); ih = item_head(Sh, 0);
if (tb->CFR[h]) if (tb->CFR[h])
r_key = B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]); r_key = internal_key(tb->CFR[h], tb->rkey[h]);
if (lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes if (lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes
/* shifting may merge items which might save space */ /* shifting may merge items which might save space */
......
...@@ -153,7 +153,7 @@ static void internal_insert_childs(struct buffer_info *cur_bi, ...@@ -153,7 +153,7 @@ static void internal_insert_childs(struct buffer_info *cur_bi,
memcpy(dc, new_dc, DC_SIZE * count); memcpy(dc, new_dc, DC_SIZE * count);
/* prepare space for count items */ /* prepare space for count items */
ih = B_N_PDELIM_KEY(cur, ((to == -1) ? 0 : to)); ih = internal_key(cur, ((to == -1) ? 0 : to));
memmove(ih + count, ih, memmove(ih + count, ih,
(nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE); (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
...@@ -233,7 +233,7 @@ static void internal_delete_pointers_items(struct buffer_info *cur_bi, ...@@ -233,7 +233,7 @@ static void internal_delete_pointers_items(struct buffer_info *cur_bi,
dc = B_N_CHILD(cur, first_p); dc = B_N_CHILD(cur, first_p);
memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE); 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, memmove(key, key + del_num,
(nr - first_i - del_num) * KEY_SIZE + (nr + 1 - (nr - first_i - del_num) * KEY_SIZE + (nr + 1 -
del_num) * DC_SIZE); del_num) * DC_SIZE);
...@@ -330,13 +330,13 @@ static void internal_copy_pointers_items(struct buffer_info *dest_bi, ...@@ -330,13 +330,13 @@ static void internal_copy_pointers_items(struct buffer_info *dest_bi,
memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num); memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num);
/* prepare space for cpy_num - 1 item headers */ /* 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, memmove(key + cpy_num - 1, key,
KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest + KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest +
cpy_num)); cpy_num));
/* insert headers */ /* 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 */ /* sizes, item number */
set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1)); set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1));
...@@ -429,12 +429,12 @@ static void internal_insert_key(struct buffer_info *dest_bi, int dest_position_b ...@@ -429,12 +429,12 @@ static void internal_insert_key(struct buffer_info *dest_bi, int dest_position_b
nr = blkh_nr_item(blkh); nr = blkh_nr_item(blkh);
/* prepare space for inserting key */ /* 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, memmove(key + 1, key,
(nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE); (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
/* insert key */ /* 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. */ /* Change dirt, free space, item number fields. */
...@@ -717,7 +717,7 @@ static void replace_lkey(struct tree_balance *tb, int h, struct item_head *key) ...@@ -717,7 +717,7 @@ static 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) if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0)
return; 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);
do_balance_mark_internal_dirty(tb, tb->CFL[h], 0); do_balance_mark_internal_dirty(tb, tb->CFL[h], 0);
} }
...@@ -732,7 +732,7 @@ static void replace_rkey(struct tree_balance *tb, int h, struct item_head *key) ...@@ -732,7 +732,7 @@ static void replace_rkey(struct tree_balance *tb, int h, struct item_head *key)
"R[h] can not be empty if it exists (item number=%d)", "R[h] can not be empty if it exists (item number=%d)",
B_NR_ITEMS(tb->R[h])); B_NR_ITEMS(tb->R[h]));
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);
do_balance_mark_internal_dirty(tb, tb->CFR[h], 0); do_balance_mark_internal_dirty(tb, tb->CFR[h], 0);
} }
...@@ -997,7 +997,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure ...@@ -997,7 +997,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* new items don't fall into S_new */ /* new items don't fall into S_new */
/* store the delimiting key for the next level */ /* store the delimiting key for the next level */
/* new_insert_key = (n - snum)'th key in S[h] */ /* 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); KEY_SIZE);
/* last parameter is del_par */ /* last parameter is del_par */
internal_move_pointers_items(&dest_bi, &src_bi, internal_move_pointers_items(&dest_bi, &src_bi,
...@@ -1008,7 +1008,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure ...@@ -1008,7 +1008,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* store the delimiting key for the next level */ /* store the delimiting key for the next level */
/* new_insert_key = (n + insert_item - snum)'th key in S[h] */ /* new_insert_key = (n + insert_item - snum)'th key in S[h] */
memcpy(&new_insert_key, memcpy(&new_insert_key,
B_N_PDELIM_KEY(tbSh, n + insert_num - snum), internal_key(tbSh, n + insert_num - snum),
KEY_SIZE); KEY_SIZE);
/* last parameter is del_par */ /* last parameter is del_par */
internal_move_pointers_items(&dest_bi, &src_bi, internal_move_pointers_items(&dest_bi, &src_bi,
......
...@@ -295,9 +295,9 @@ static int _get_block_create_0(struct inode *inode, sector_t block, ...@@ -295,9 +295,9 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
} }
// //
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
if (is_indirect_le_ih(ih)) { if (is_indirect_le_ih(ih)) {
__le32 *ind_item = (__le32 *) B_I_PITEM(bh, ih); __le32 *ind_item = (__le32 *) ih_item_body(bh, ih);
/* FIXME: here we could cache indirect item or part of it in /* FIXME: here we could cache indirect item or part of it in
the inode to avoid search_by_key in case of subsequent the inode to avoid search_by_key in case of subsequent
...@@ -383,7 +383,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block, ...@@ -383,7 +383,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
} else { } else {
chars = ih_item_len(ih) - path.pos_in_item; chars = ih_item_len(ih) - path.pos_in_item;
} }
memcpy(p, B_I_PITEM(bh, ih) + path.pos_in_item, chars); memcpy(p, ih_item_body(bh, ih) + path.pos_in_item, chars);
if (done) if (done)
break; break;
...@@ -404,7 +404,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block, ...@@ -404,7 +404,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
// i/o error most likely // i/o error most likely
break; break;
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
} while (1); } while (1);
flush_dcache_page(bh_result->b_page); flush_dcache_page(bh_result->b_page);
...@@ -684,8 +684,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block, ...@@ -684,8 +684,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
} }
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
item = get_item(&path); item = tp_item_body(&path);
pos_in_item = path.pos_in_item; pos_in_item = path.pos_in_item;
fs_gen = get_generation(inode->i_sb); fs_gen = get_generation(inode->i_sb);
...@@ -1031,8 +1031,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block, ...@@ -1031,8 +1031,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
goto failure; goto failure;
} }
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
item = get_item(&path); item = tp_item_body(&path);
pos_in_item = path.pos_in_item; pos_in_item = path.pos_in_item;
} while (1); } while (1);
...@@ -1133,7 +1133,7 @@ static void init_inode(struct inode *inode, struct treepath *path) ...@@ -1133,7 +1133,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
//int version = ITEM_VERSION_1; //int version = ITEM_VERSION_1;
bh = PATH_PLAST_BUFFER(path); bh = PATH_PLAST_BUFFER(path);
ih = PATH_PITEM_HEAD(path); ih = tp_item_head(path);
copy_key(INODE_PKEY(inode), &(ih->ih_key)); copy_key(INODE_PKEY(inode), &(ih->ih_key));
...@@ -1147,7 +1147,7 @@ static void init_inode(struct inode *inode, struct treepath *path) ...@@ -1147,7 +1147,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
if (stat_data_v1(ih)) { if (stat_data_v1(ih)) {
struct stat_data_v1 *sd = struct stat_data_v1 *sd =
(struct stat_data_v1 *)B_I_PITEM(bh, ih); (struct stat_data_v1 *)ih_item_body(bh, ih);
unsigned long blocks; unsigned long blocks;
set_inode_item_key_version(inode, KEY_FORMAT_3_5); set_inode_item_key_version(inode, KEY_FORMAT_3_5);
...@@ -1195,7 +1195,7 @@ static void init_inode(struct inode *inode, struct treepath *path) ...@@ -1195,7 +1195,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
} else { } else {
// new stat data found, but object may have old items // new stat data found, but object may have old items
// (directories and symlinks) // (directories and symlinks)
struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih); struct stat_data *sd = (struct stat_data *)ih_item_body(bh, ih);
inode->i_mode = sd_v2_mode(sd); inode->i_mode = sd_v2_mode(sd);
set_nlink(inode, sd_v2_nlink(sd)); set_nlink(inode, sd_v2_nlink(sd));
...@@ -1307,7 +1307,7 @@ static void update_stat_data(struct treepath *path, struct inode *inode, ...@@ -1307,7 +1307,7 @@ static void update_stat_data(struct treepath *path, struct inode *inode,
struct item_head *ih; struct item_head *ih;
bh = PATH_PLAST_BUFFER(path); bh = PATH_PLAST_BUFFER(path);
ih = PATH_PITEM_HEAD(path); ih = tp_item_head(path);
if (!is_statdata_le_ih(ih)) if (!is_statdata_le_ih(ih))
reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h", reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h",
...@@ -1315,9 +1315,9 @@ static void update_stat_data(struct treepath *path, struct inode *inode, ...@@ -1315,9 +1315,9 @@ static void update_stat_data(struct treepath *path, struct inode *inode,
if (stat_data_v1(ih)) { if (stat_data_v1(ih)) {
// path points to old stat data // path points to old stat data
inode2sd_v1(B_I_PITEM(bh, ih), inode, size); inode2sd_v1(ih_item_body(bh, ih), inode, size);
} else { } else {
inode2sd(B_I_PITEM(bh, ih), inode, size); inode2sd(ih_item_body(bh, ih), inode, size);
} }
return; return;
...@@ -1368,7 +1368,7 @@ void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th, ...@@ -1368,7 +1368,7 @@ void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
** search if the stat data item has moved ** search if the stat data item has moved
*/ */
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
copy_item_head(&tmp_ih, ih); copy_item_head(&tmp_ih, ih);
fs_gen = get_generation(inode->i_sb); fs_gen = get_generation(inode->i_sb);
reiserfs_prepare_for_journal(inode->i_sb, bh, 1); reiserfs_prepare_for_journal(inode->i_sb, bh, 1);
...@@ -2232,8 +2232,8 @@ static int map_block_for_writepage(struct inode *inode, ...@@ -2232,8 +2232,8 @@ static int map_block_for_writepage(struct inode *inode,
} }
bh = get_last_bh(&path); bh = get_last_bh(&path);
ih = get_ih(&path); ih = tp_item_head(&path);
item = get_item(&path); item = tp_item_body(&path);
pos_in_item = path.pos_in_item; pos_in_item = path.pos_in_item;
/* we've found an unformatted node */ /* we've found an unformatted node */
...@@ -2281,7 +2281,7 @@ static int map_block_for_writepage(struct inode *inode, ...@@ -2281,7 +2281,7 @@ static int map_block_for_writepage(struct inode *inode,
goto research; goto research;
} }
memcpy(B_I_PITEM(bh, ih) + pos_in_item, p + bytes_copied, memcpy(ih_item_body(bh, ih) + pos_in_item, p + bytes_copied,
copy_size); copy_size);
journal_mark_dirty(&th, inode->i_sb, bh); journal_mark_dirty(&th, inode->i_sb, bh);
......
...@@ -396,7 +396,7 @@ static void direntry_print_item(struct item_head *ih, char *item) ...@@ -396,7 +396,7 @@ static void direntry_print_item(struct item_head *ih, char *item)
deh = (struct reiserfs_de_head *)item; deh = (struct reiserfs_de_head *)item;
for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { for (i = 0; i < ih_entry_count(ih); i++, deh++) {
namelen = namelen =
(i ? (deh_location(deh - 1)) : ih_item_len(ih)) - (i ? (deh_location(deh - 1)) : ih_item_len(ih)) -
deh_location(deh); deh_location(deh);
...@@ -430,7 +430,7 @@ static void direntry_check_item(struct item_head *ih, char *item) ...@@ -430,7 +430,7 @@ static void direntry_check_item(struct item_head *ih, char *item)
// FIXME: type something here! // FIXME: type something here!
deh = (struct reiserfs_de_head *)item; deh = (struct reiserfs_de_head *)item;
for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { for (i = 0; i < ih_entry_count(ih); i++, deh++) {
; ;
} }
} }
......
This diff is collapsed.
...@@ -31,7 +31,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off) ...@@ -31,7 +31,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
int rbound, lbound, j; int rbound, lbound, j;
lbound = 0; lbound = 0;
rbound = I_ENTRY_COUNT(ih) - 1; rbound = ih_entry_count(ih) - 1;
for (j = (rbound + lbound) / 2; lbound <= rbound; for (j = (rbound + lbound) / 2; lbound <= rbound;
j = (rbound + lbound) / 2) { j = (rbound + lbound) / 2) {
...@@ -57,7 +57,7 @@ static inline void set_de_item_location(struct reiserfs_dir_entry *de, ...@@ -57,7 +57,7 @@ static inline void set_de_item_location(struct reiserfs_dir_entry *de,
struct treepath *path) struct treepath *path)
{ {
de->de_bh = get_last_bh(path); de->de_bh = get_last_bh(path);
de->de_ih = get_ih(path); de->de_ih = tp_item_head(path);
de->de_deh = B_I_DEH(de->de_bh, de->de_ih); de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
de->de_item_num = PATH_LAST_POSITION(path); de->de_item_num = PATH_LAST_POSITION(path);
} }
...@@ -71,7 +71,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de) ...@@ -71,7 +71,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num); de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0); de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
de->de_name = B_I_PITEM(de->de_bh, de->de_ih) + deh_location(deh); de->de_name = ih_item_body(de->de_bh, de->de_ih) + deh_location(deh);
if (de->de_name[de->de_namelen - 1] == 0) if (de->de_name[de->de_namelen - 1] == 0)
de->de_namelen = strlen(de->de_name); de->de_namelen = strlen(de->de_name);
} }
...@@ -220,7 +220,7 @@ static int linear_search_in_dir_item(struct cpu_key *key, ...@@ -220,7 +220,7 @@ static int linear_search_in_dir_item(struct cpu_key *key,
i = de->de_entry_num; i = de->de_entry_num;
if (i == I_ENTRY_COUNT(de->de_ih) || if (i == ih_entry_count(de->de_ih) ||
GET_HASH_VALUE(deh_offset(deh + i)) != GET_HASH_VALUE(deh_offset(deh + i)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) { GET_HASH_VALUE(cpu_key_k_offset(key))) {
i--; i--;
...@@ -1331,7 +1331,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1331,7 +1331,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
return -EIO; return -EIO;
} }
copy_item_head(&old_entry_ih, get_ih(&old_entry_path)); copy_item_head(&old_entry_ih, tp_item_head(&old_entry_path));
reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1); reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1);
...@@ -1351,7 +1351,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1351,7 +1351,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
return -EIO; return -EIO;
} }
copy_item_head(&new_entry_ih, get_ih(&new_entry_path)); copy_item_head(&new_entry_ih, tp_item_head(&new_entry_path));
reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1); reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
...@@ -1369,7 +1369,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1369,7 +1369,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
return -EIO; return -EIO;
} }
copy_item_head(&dot_dot_ih, copy_item_head(&dot_dot_ih,
get_ih(&dot_dot_entry_path)); tp_item_head(&dot_dot_entry_path));
// node containing ".." gets into transaction // node containing ".." gets into transaction
reiserfs_prepare_for_journal(old_inode->i_sb, reiserfs_prepare_for_journal(old_inode->i_sb,
dot_dot_de.de_bh, 1); dot_dot_de.de_bh, 1);
......
...@@ -439,7 +439,7 @@ static int print_internal(struct buffer_head *bh, int first, int last) ...@@ -439,7 +439,7 @@ static int print_internal(struct buffer_head *bh, int first, int last)
dc = B_N_CHILD(bh, from); dc = B_N_CHILD(bh, from);
reiserfs_printk("PTR %d: %y ", from, dc); reiserfs_printk("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++) { i++, key++, dc++) {
reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc); reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
if (i && i % 4 == 0) if (i && i % 4 == 0)
...@@ -463,7 +463,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first, ...@@ -463,7 +463,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first,
check_leaf(bh); check_leaf(bh);
blkh = B_BLK_HEAD(bh); blkh = B_BLK_HEAD(bh);
ih = B_N_PITEM_HEAD(bh, 0); ih = item_head(bh, 0);
nr = blkh_nr_item(blkh); nr = blkh_nr_item(blkh);
printk printk
...@@ -496,7 +496,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first, ...@@ -496,7 +496,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first,
("-------------------------------------------------------------------------------\n"); ("-------------------------------------------------------------------------------\n");
reiserfs_printk("|%2d| %h |\n", i, ih); reiserfs_printk("|%2d| %h |\n", i, ih);
if (print_mode & PRINT_LEAF_ITEMS) if (print_mode & PRINT_LEAF_ITEMS)
op_print_item(ih, B_I_PITEM(bh, ih)); op_print_item(ih, ih_item_body(bh, ih));
} }
printk printk
...@@ -744,8 +744,8 @@ void check_leaf(struct buffer_head *bh) ...@@ -744,8 +744,8 @@ void check_leaf(struct buffer_head *bh)
if (!bh) if (!bh)
return; return;
check_leaf_block_head(bh); check_leaf_block_head(bh);
for (i = 0, ih = B_N_PITEM_HEAD(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) for (i = 0, ih = item_head(bh, 0); i < B_NR_ITEMS(bh); i++, ih++)
op_check_item(ih, B_I_PITEM(bh, ih)); op_check_item(ih, ih_item_body(bh, ih));
} }
void check_internal(struct buffer_head *bh) void check_internal(struct buffer_head *bh)
......
...@@ -1277,9 +1277,11 @@ static inline loff_t le_ih_k_offset(const struct item_head *ih) ...@@ -1277,9 +1277,11 @@ static inline loff_t le_ih_k_offset(const struct item_head *ih)
static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key) static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key)
{ {
return (version == KEY_FORMAT_3_5) ? if (version == KEY_FORMAT_3_5) {
uniqueness2type(le32_to_cpu(key->u.k_offset_v1.k_uniqueness)) : loff_t val = le32_to_cpu(key->u.k_offset_v1.k_uniqueness);
offset_v2_k_type(&(key->u.k_offset_v2)); return uniqueness2type(val);
} else
return offset_v2_k_type(&(key->u.k_offset_v2));
} }
static inline loff_t le_ih_k_type(const struct item_head *ih) static inline loff_t le_ih_k_type(const struct item_head *ih)
...@@ -1290,8 +1292,22 @@ static inline loff_t le_ih_k_type(const struct item_head *ih) ...@@ -1290,8 +1292,22 @@ static inline loff_t le_ih_k_type(const struct item_head *ih)
static inline void set_le_key_k_offset(int version, struct reiserfs_key *key, static inline void set_le_key_k_offset(int version, struct reiserfs_key *key,
loff_t offset) loff_t offset)
{ {
(version == KEY_FORMAT_3_5) ? (void)(key->u.k_offset_v1.k_offset = cpu_to_le32(offset)) : /* jdm check */ if (version == KEY_FORMAT_3_5)
(void)(set_offset_v2_k_offset(&(key->u.k_offset_v2), offset)); key->u.k_offset_v1.k_offset = cpu_to_le32(offset);
else
set_offset_v2_k_offset(&key->u.k_offset_v2, offset);
}
static inline void add_le_key_k_offset(int version, struct reiserfs_key *key,
loff_t offset)
{
set_le_key_k_offset(version, key,
le_key_k_offset(version, key) + offset);
}
static inline void add_le_ih_k_offset(struct item_head *ih, loff_t offset)
{
add_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset);
} }
static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset) static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset)
...@@ -1302,10 +1318,11 @@ static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset) ...@@ -1302,10 +1318,11 @@ static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset)
static inline void set_le_key_k_type(int version, struct reiserfs_key *key, static inline void set_le_key_k_type(int version, struct reiserfs_key *key,
int type) int type)
{ {
(version == KEY_FORMAT_3_5) ? if (version == KEY_FORMAT_3_5) {
(void)(key->u.k_offset_v1.k_uniqueness = type = type2uniqueness(type);
cpu_to_le32(type2uniqueness(type))) key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type);
: (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type)); } else
set_offset_v2_k_type(&key->u.k_offset_v2, type);
} }
static inline void set_le_ih_k_type(struct item_head *ih, int type) static inline void set_le_ih_k_type(struct item_head *ih, int type)
...@@ -1723,39 +1740,6 @@ extern void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid, ...@@ -1723,39 +1740,6 @@ extern void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid,
extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid, extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid,
__le32 par_dirid, __le32 par_objid); __le32 par_dirid, __le32 par_objid);
/* array of the entry headers */
/* get item body */