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

+17 -17
View File
@@ -407,7 +407,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
return;
}
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++) {
struct reiserfs_de_head *deh;
/* look for property objectid */
@@ -456,7 +456,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
printf("Wrong format \'%c\'\n", corruption_command[0]);
return;
}
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++) {
struct reiserfs_de_head *deh;
/* look for property objectid */
@@ -482,7 +482,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
set_ih_key_format(ih, format);
set_type(format, &ih->ih_key, type);
@@ -500,7 +500,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
corruption_command[0]);
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
set_key_objectid(&ih->ih_key, objectid);
break;
@@ -516,14 +516,14 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
corruption_command[0]);
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
if (!is_indirect_ih(ih) || pos_in_item >= I_UNFM_NUM(ih)) {
reiserfs_warning(stderr,
"Not an indirect item or there is "
"not so many unfm ptrs in it\n");
return;
}
d32_put((__u32 *) B_I_PITEM(bh, ih), pos_in_item,
d32_put((__u32 *) ih_item_body(bh, ih), pos_in_item,
get_sb_block_count(fs->fs_ondisk_sb) + 100);
break;
@@ -563,7 +563,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
printf("can not destroy order\n");
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
key = &(ih + 1)->ih_key;
set_key_dirid(&ih->ih_key, get_key_dirid(key) + 1);
@@ -586,9 +586,9 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
corruption_command[0]);
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
sd = (struct stat_data_v1 *)B_I_PITEM(bh, ih);
sd = (struct stat_data_v1 *)ih_item_body(bh, ih);
reiserfs_warning(stderr,
"Changing sd_size of %k from %d to %d\n",
&ih->ih_key, sd_v1_size(sd), value);
@@ -613,9 +613,9 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
corruption_command[0]);
return;
}
ih = B_N_PITEM_HEAD(bh, item_num);
ih = item_head(bh, item_num);
sd = (struct stat_data_v1 *)B_I_PITEM(bh, ih);
sd = (struct stat_data_v1 *)ih_item_body(bh, ih);
reiserfs_warning(stderr,
"Changing sd_first_direct_byte of %k from %d to %d\n",
&ih->ih_key,
@@ -640,7 +640,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
for (i = 0; i < item_numbers; i++) {
printf("Do corruptions : %d item header; \n", i);
ih = B_N_PITEM_HEAD(bh, i);
ih = item_head(bh, i);
do_one_ih_corrupt(ih, bytes_to_corrupt);
printf("Ok\n");
}
@@ -954,7 +954,7 @@ void do_ih_random_corrupt(reiserfs_filsys_t *fs, unsigned long nr_leaves_cr)
printf("# block %lu , item header %d\n", bh->b_blocknr,
j);
ih = B_N_PITEM_HEAD(bh, j);
ih = item_head(bh, j);
do_one_ih_random_corrupt(ih);
}
mark_buffer_dirty(bh);
@@ -980,7 +980,7 @@ void do_one_item_random_corrupt(struct buffer_head *bh, struct item_head *ih)
unsigned int count;
char *p;
p = (char *)B_I_PITEM(bh, ih);
p = (char *)ih_item_body(bh, ih);
from = get_rand(0, get_ih_item_len(ih) - 1);
count = get_rand(1, get_ih_item_len(ih));
@@ -1066,7 +1066,7 @@ void do_dir_random_corrupt(reiserfs_filsys_t *fs, unsigned long nr_leaves_cr)
bh->b_blocknr, j);
printf("# block %lu , item %d\n", bh->b_blocknr, j);
ih = B_N_PITEM_HEAD(bh, j);
ih = item_head(bh, j);
if (get_type(&ih->ih_key) != TYPE_DIRENTRY)
continue;
do_one_item_random_corrupt(bh, ih);
@@ -1151,7 +1151,7 @@ void do_sd_random_corrupt(reiserfs_filsys_t *fs, unsigned long nr_leaves_cr)
bh->b_blocknr, j);
printf("# block %lu , item %d\n", bh->b_blocknr, j);
ih = B_N_PITEM_HEAD(bh, j);
ih = item_head(bh, j);
if (get_type(&ih->ih_key) != TYPE_STAT_DATA)
continue;
do_one_item_random_corrupt(bh, ih);
@@ -1230,7 +1230,7 @@ void do_ind_random_corrupt(reiserfs_filsys_t *fs, unsigned long nr_leaves_cr)
if (should_be_corrupted == 0)
continue;
ih = B_N_PITEM_HEAD(bh, j);
ih = item_head(bh, j);
if (get_type(&ih->ih_key) != TYPE_INDIRECT)
continue;
if ((data(fs)->log_file_name) && (data(fs)->log))
+4 -4
View File
@@ -108,11 +108,11 @@ static void print_disk_tree(reiserfs_filsys_t *fs, unsigned long block_nr)
print_block(stdout, fs, bh,
data(fs)->options & PRINT_TREE_DETAILS, -1, -1);
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
count = leaf_item_number_estimate(bh);
for (i = 0; i < count; i++, ih++) {
if (is_indirect_ih(ih)) {
__u32 *ind_item = (__u32 *) B_I_PITEM(bh, ih);
__u32 *ind_item = (__u32 *) ih_item_body(bh, ih);
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
if (d32_get(ind_item, j)) {
@@ -574,8 +574,8 @@ static void callback_badblock_print(reiserfs_filsys_t *fs,
__u32 *ind_item;
__u32 i;
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++)
fprintf(fd, "%u\n", d32_get(ind_item, i));
+7 -7
View File
@@ -100,7 +100,7 @@ static void pack_direct(struct packed_item *pi, struct buffer_head *bh,
if (get_pi_mask(pi) & SAFE_LINK)
set_key_dirid(&ih->ih_key,
d32_get((__u32 *) B_I_PITEM(bh, ih), 0));
d32_get((__u32 *) ih_item_body(bh, ih), 0));
/* send key components which are to be sent */
pack_ih(pi, ih);
@@ -138,7 +138,7 @@ static void pack_indirect(struct packed_item *pi, struct buffer_head *bh,
if (get_ih_entry_count(ih))
set_pi_mask(pi, get_pi_mask(pi) | IH_FREE_SPACE);
ind_item = (__u32 *) B_I_PITEM(bh, ih);
ind_item = (__u32 *) ih_item_body(bh, ih);
if (!should_pack_indirect(ind_item, I_UNFM_NUM(ih)))
set_pi_mask(pi, get_pi_mask(pi) | WHOLE_INDIRECT);
@@ -251,7 +251,7 @@ static void pack_stat_data(struct packed_item *pi, struct buffer_head *bh,
*/
struct stat_data_v1 *sd_v1;
sd_v1 = (struct stat_data_v1 *)B_I_PITEM(bh, ih);
sd_v1 = (struct stat_data_v1 *)ih_item_body(bh, ih);
if (sd_v1->sd_first_direct_byte != 0xffffffff) /* ok if -1 */
set_pi_mask(pi,
get_pi_mask(pi) |
@@ -279,7 +279,7 @@ static void pack_stat_data(struct packed_item *pi, struct buffer_head *bh,
__u32 nlink32, size32;
__u64 size64;
sd = (struct stat_data *)B_I_PITEM(bh, ih);
sd = (struct stat_data *)ih_item_body(bh, ih);
if (sd_v2_nlink(sd) > 0xffff) {
set_pi_mask(pi, get_pi_mask(pi) | NLINK_BITS_32);
nlink32 = sd->sd_nlink;
@@ -356,10 +356,10 @@ static int can_pack_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
int i;
struct item_head *ih;
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 (is_it_bad_item
(fs, ih, B_I_PITEM(bh, ih), 0 /*check_unfm_ptr */ ,
(fs, ih, ih_item_body(bh, ih), 0 /*check_unfm_ptr */ ,
1 /*bad dir */ ))
return 0;
}
@@ -394,7 +394,7 @@ static void pack_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
v16 = get_blkh_nr_items(B_BLK_HEAD(bh));
fwrite_le16(&v16);
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
for (i = 0; i < v16; i++, ih++) {
#if 0
+8 -8
View File
@@ -79,7 +79,7 @@ void do_recover(reiserfs_filsys_t fs)
printf("working with block %lu..\n", block);
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
for (i = 0; i < node_item_number(bh); i++, ih++) {
__u32 *indirect;
struct buffer_head *tmp_bh;
@@ -89,7 +89,7 @@ void do_recover(reiserfs_filsys_t fs)
|| key.k_objectid != ih->ih_key.k_objectid)
continue;
indirect = (__u32 *) B_I_PITEM(bh, ih);
indirect = (__u32 *) ih_item_body(bh, ih);
for (j = 0; j < I_UNFM_NUM(ih); j++) {
block = le32_to_cpu(indirect[j]);
if (!block)
@@ -308,7 +308,7 @@ static void recover_items(FILE * fp, reiserfs_filsys_t *fs, FILE * target_file)
if (i == map_size / sizeof(struct saved_item)) {
if (start != -1) {
reiserfs_print_item(stdout, bh,
B_N_PITEM_HEAD(bh,
item_head(bh,
(cur -
1)->
si_item_num));
@@ -341,7 +341,7 @@ static void recover_items(FILE * fp, reiserfs_filsys_t *fs, FILE * target_file)
printf("Problem item %d:\n", i - start - 1);
reiserfs_print_item(stdout, bh,
B_N_PITEM_HEAD(bh,
item_head(bh,
(cur -
1)->
si_item_num));
@@ -349,7 +349,7 @@ static void recover_items(FILE * fp, reiserfs_filsys_t *fs, FILE * target_file)
/* problem interval finished */
printf("Problem item %d:\n", i - start - 1);
reiserfs_print_item(stdout, bh,
B_N_PITEM_HEAD(bh,
item_head(bh,
(cur -
1)->
si_item_num));
@@ -377,15 +377,15 @@ static void recover_items(FILE * fp, reiserfs_filsys_t *fs, FILE * target_file)
fseek(target_file,
get_offset(&(map + result)->si_ih.ih_key) - 1, SEEK_SET);
ih = B_N_PITEM_HEAD(bh, (map + result)->si_item_num);
ih = item_head(bh, (map + result)->si_item_num);
if (is_direct_ih(ih)) {
fwrite(B_I_PITEM(bh, ih),
fwrite(ih_item_body(bh, ih),
(map + result)->si_ih.ih2_item_len, 1,
target_file);
} else if (is_indirect_ih(ih)) {
for (j = 0; j < I_UNFM_NUM(ih); j++) {
unfm_ptr =
d32_get((__u32 *) B_I_PITEM(bh, ih), j);
d32_get((__u32 *) ih_item_body(bh, ih), j);
if (!unfm_ptr) {
fseek(target_file, fs->fs_blocksize,
SEEK_CUR);
+10 -10
View File
@@ -57,7 +57,7 @@ static void store_item(struct saved_name *name, struct buffer_head *bh,
new = obstack_alloc(&item_store, sizeof(struct saved_item));
new->si_ih = *ih;
new->si_block = bh->b_blocknr;
new->si_item_num = ih - B_N_PITEM_HEAD(bh, 0);
new->si_item_num = ih - item_head(bh, 0);
new->si_next = 0;
new->si_entry_pos = pos;
@@ -174,12 +174,12 @@ static void scan_for_name(struct buffer_head *bh)
int min_entry_size = 1;
int ih_entry_count = 0;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i++, ih++) {
if (!is_direntry_ih(ih))
continue;
if (is_it_bad_item(fs, ih, B_I_PITEM(bh, ih), 0, 1))
if (is_it_bad_item(fs, ih, ih_item_body(bh, ih), 0, 1))
continue;
deh = B_I_DEH(bh, ih);
@@ -340,7 +340,7 @@ static void scan_items(struct buffer_head *bh, struct reiserfs_key *key)
struct saved_name *name_in_store;
void *res;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i++, ih++) {
if (key) {
@@ -567,8 +567,8 @@ static void map_one_item(struct saved_item *item)
return;
}
ih = B_N_PITEM_HEAD(bh, item->si_item_num);
data = B_I_PITEM(bh, ih);
ih = item_head(bh, item->si_item_num);
data = ih_item_body(bh, ih);
if (memcmp(&item->si_ih, ih, sizeof(*ih)))
reiserfs_panic("wrong item");
@@ -731,7 +731,7 @@ static void print_items(FILE * fp, reiserfs_filsys_t *fs)
reiserfs_warning(fp, "bread failed\n");
continue;
}
ih = B_N_PITEM_HEAD(bh, item.si_item_num);
ih = item_head(bh, item.si_item_num);
reiserfs_print_item(stdout, bh, ih);
brelse(bh);
}
@@ -861,7 +861,7 @@ static void locate_file(reiserfs_filsys_t *fs, struct reiserfs_key *key)
si.si_block = get_bh(&path)->b_blocknr;
si.si_item_num = get_item_pos(&path);
si.si_ih = *get_ih(&path);
si.si_ih = *tp_item_head(&path);
map_one_item(&si);
}
@@ -924,7 +924,7 @@ static void look_for_name(reiserfs_filsys_t *fs)
get_item_pos(&path), path.pos_in_item);
deh =
B_I_DEH(get_bh(&path),
get_ih(&path)) + path.pos_in_item;
tp_item_head(&path)) + path.pos_in_item;
set_key_dirid(&fkey, get_deh_dirid(deh));
set_key_objectid(&fkey, get_deh_objectid(deh));
@@ -956,7 +956,7 @@ static void scan_for_key(struct buffer_head *bh, struct reiserfs_key *key)
int min_entry_size = 1;
int ih_entry_count = 0;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i++, ih++) {
if ((get_key_dirid(&ih->ih_key) == get_key_dirid(key) ||
+2 -2
View File
@@ -111,7 +111,7 @@ static void stat1_the_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
struct item_head *ih;
int is_there_unique_item;
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
is_there_unique_item = 0;
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i++, ih++) {
@@ -131,7 +131,7 @@ static void stat1_the_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
fs_stat.blocks_to_skip++;
reiserfs_bitmap_clear_bit(input_bitmap(fs), bh->b_blocknr);
} else {
ih = B_N_PITEM_HEAD(bh, 0);
ih = item_head(bh, 0);
/* node contains at least one unique item. We will put it in, count items of each type */
for (i = 0; i < i_num; i++, ih++) {
fs_stat.items[get_type(&ih->ih_key)]++;
+5 -5
View File
@@ -163,7 +163,7 @@ static void unpack_stat_data(struct packed_item *pi, struct buffer_head *bh,
*/
struct stat_data_v1 *sd;
sd = (struct stat_data_v1 *)B_I_PITEM(bh, ih);
sd = (struct stat_data_v1 *)ih_item_body(bh, ih);
memset(sd, 0, sizeof(sd));
fread16(&sd->sd_mode);
@@ -185,7 +185,7 @@ static void unpack_stat_data(struct packed_item *pi, struct buffer_head *bh,
*/
struct stat_data *sd;
sd = (struct stat_data *)B_I_PITEM(bh, ih);
sd = (struct stat_data *)ih_item_body(bh, ih);
memset(sd, 0, sizeof(sd));
fread16(&sd->sd_mode);
@@ -229,7 +229,7 @@ static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
set_ih_entry_count(ih, 0);
}
ind_item = (__u32 *) B_I_PITEM(bh, ih);
ind_item = (__u32 *) ih_item_body(bh, ih);
if (get_pi_mask(pi) & SAFE_LINK) {
d32_put(ind_item, 0, get_key_dirid(&ih->ih_key));
@@ -263,7 +263,7 @@ static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
static void unpack_direct(struct packed_item *pi, struct buffer_head *bh,
struct item_head *ih)
{
__u32 *d_item = (__u32 *) B_I_PITEM(bh, ih);
__u32 *d_item = (__u32 *) ih_item_body(bh, ih);
if (!(get_pi_mask(pi) & IH_FREE_SPACE))
/* ih_free_space was not packed - set default */
@@ -305,7 +305,7 @@ static void unpack_leaf(int dev, hashf_t hash_func, __u16 blocksize)
set_blkh_level(B_BLK_HEAD(bh), DISK_LEAF_NODE_LEVEL);
set_blkh_free_space(B_BLK_HEAD(bh), MAX_FREE_SPACE(bh->b_size));
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 0
fread32(&v32);