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:
1 parent
290bb8c378
commit
c1ff1d5d2d
28 files changed
+354
-355
No files matched your search
+17
-17
@@ -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))
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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) ||
|
||||
|
||||
@@ -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)]++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+23
-23
@@ -362,7 +362,7 @@ static int bad_stat_data(reiserfs_filsys_t *fs,
|
||||
return 0;
|
||||
/* Check this on semantic_check pass.
|
||||
|
||||
sd = (struct stat_data *)B_I_PITEM(bh,ih);
|
||||
sd = (struct stat_data *)ih_item_body(bh,ih);
|
||||
get_sd_nlink (ih, sd, &links);
|
||||
if (S_ISDIR(sd->sd_mode)) {
|
||||
if (links < 2) {
|
||||
@@ -403,7 +403,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
struct item_head *ih)
|
||||
{
|
||||
__u32 i;
|
||||
__u32 *ind = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
if (get_ih_item_len(ih) % 4) {
|
||||
fsck_log("%s: block %lu: item (%H) has bad length\n",
|
||||
@@ -477,7 +477,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
static int bad_indirect_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
struct item_head *ih)
|
||||
{
|
||||
__u32 *ind = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
||||
unsigned int i;
|
||||
|
||||
if (get_ih_item_len(ih) % 4) {
|
||||
@@ -585,7 +585,7 @@ static int bad_directory_item(reiserfs_filsys_t *fs,
|
||||
}
|
||||
|
||||
/* check name hashing */
|
||||
prev_name = B_I_PITEM(bh, ih) + get_ih_item_len(ih);
|
||||
prev_name = ih_item_body(bh, ih) + get_ih_item_len(ih);
|
||||
prev_off = 0;
|
||||
|
||||
for (i = 0; i < count; i++, deh++) {
|
||||
@@ -648,7 +648,7 @@ static int bad_item(reiserfs_filsys_t *fs, struct buffer_head *bh, int num)
|
||||
struct item_head *ih;
|
||||
int format;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, num);
|
||||
ih = item_head(bh, num);
|
||||
|
||||
if ((get_ih_flags(ih)) != 0) {
|
||||
if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
|
||||
@@ -755,7 +755,7 @@ int bad_pair(reiserfs_filsys_t *fs, struct buffer_head *bh, int pos)
|
||||
{
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, pos);
|
||||
ih = item_head(bh, pos);
|
||||
|
||||
if (comp_keys(&((ih - 1)->ih_key), &ih->ih_key) != -1) {
|
||||
if (fsck_mode(fs) != FSCK_REBUILD)
|
||||
@@ -841,15 +841,15 @@ static int bad_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
if (bad_item(fs, bh, i)) {
|
||||
fsck_log
|
||||
("bad_leaf: block %lu, item %d: The corrupted item found "
|
||||
"(%H)\n", bh->b_blocknr, i, B_N_PITEM_HEAD(bh, i));
|
||||
"(%H)\n", bh->b_blocknr, i, item_head(bh, i));
|
||||
}
|
||||
|
||||
if (i && bad_pair(fs, bh, i)) {
|
||||
fsck_log
|
||||
("bad_leaf: block %lu, items %d and %d: The wrong order "
|
||||
"of items: %k, %k\n", bh->b_blocknr, i - 1, i,
|
||||
&B_N_PITEM_HEAD(bh, i - 1)->ih_key,
|
||||
&B_N_PITEM_HEAD(bh, i)->ih_key);
|
||||
&item_head(bh, i - 1)->ih_key,
|
||||
&item_head(bh, i)->ih_key);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -863,13 +863,13 @@ static int bad_internal(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
for (i = 0; i <= B_NR_ITEMS(bh); i++) {
|
||||
if (i != B_NR_ITEMS(bh) && i != B_NR_ITEMS(bh) - 1)
|
||||
/* make sure that keys are in increasing order */
|
||||
if (comp_keys(B_N_PDELIM_KEY(bh, i),
|
||||
B_N_PDELIM_KEY(bh, i + 1)) != -1) {
|
||||
if (comp_keys(internal_key(bh, i),
|
||||
internal_key(bh, i + 1)) != -1) {
|
||||
fsck_log
|
||||
("%s: vpf-10320: block %lu, items %d and %d: The "
|
||||
"wrong order of items: %k, %k\n",
|
||||
__FUNCTION__, bh->b_blocknr, i, i + 1,
|
||||
B_N_PDELIM_KEY(bh, i), B_N_PDELIM_KEY(bh,
|
||||
internal_key(bh, i), internal_key(bh,
|
||||
i +
|
||||
1));
|
||||
|
||||
@@ -931,7 +931,7 @@ int internal_remove(struct buffer_head *bh, int pos)
|
||||
delete = (char *)B_N_CHILD(bh, pos + 2);
|
||||
memmove(delete - DC_SIZE, delete, bh->b_size - (delete - bh->b_data));
|
||||
|
||||
delete = (char *)B_N_PDELIM_KEY(bh, pos + 1);
|
||||
delete = (char *)internal_key(bh, pos + 1);
|
||||
memmove(delete - KEY_SIZE, delete, bh->b_size - (delete - bh->b_data));
|
||||
|
||||
nr = B_NR_ITEMS(bh) - 1;
|
||||
@@ -956,7 +956,7 @@ int leaf_fix_key_oid(struct buffer_head *bh, int pos, __u32 oid)
|
||||
if (B_NR_ITEMS(bh) < pos)
|
||||
return -1;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, pos);
|
||||
ih = item_head(bh, pos);
|
||||
set_key_objectid(&ih->ih_key, oid);
|
||||
|
||||
mark_buffer_dirty(bh);
|
||||
@@ -1027,7 +1027,7 @@ static struct reiserfs_key *lkey(struct buffer_head **path, int h)
|
||||
while (h > 0) {
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
if (pos)
|
||||
return B_N_PDELIM_KEY(path[h - 1], pos - 1);
|
||||
return internal_key(path[h - 1], pos - 1);
|
||||
h--;
|
||||
}
|
||||
return 0;
|
||||
@@ -1041,7 +1041,7 @@ static struct reiserfs_key *rkey(struct buffer_head **path, int h)
|
||||
while (h > 0) {
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
if (pos != B_NR_ITEMS(path[h - 1]))
|
||||
return B_N_PDELIM_KEY(path[h - 1], pos);
|
||||
return internal_key(path[h - 1], pos);
|
||||
h--;
|
||||
}
|
||||
return 0;
|
||||
@@ -1067,19 +1067,19 @@ static int bad_path(reiserfs_filsys_t *fs, struct buffer_head **path, int h1)
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
|
||||
dk = lkey(path, h);
|
||||
if (dk && comp_keys(dk, B_N_PKEY(path[h], 0))) {
|
||||
if (dk && comp_keys(dk, leaf_key(path[h], 0))) {
|
||||
/* left delimiting key must be equal to the key of 0-th item in the
|
||||
node */
|
||||
fsck_log
|
||||
("bad_path: The left delimiting key %k of the node (%lu) must "
|
||||
"be equal to the first element's key %k within the node.\n",
|
||||
dk, path[h]->b_blocknr, B_N_PKEY(path[h], 0));
|
||||
dk, path[h]->b_blocknr, leaf_key(path[h], 0));
|
||||
one_more_corruption(fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dk = rkey(path, h);
|
||||
if (dk && comp_keys(dk, B_N_PKEY(path[h],
|
||||
if (dk && comp_keys(dk, leaf_key(path[h],
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h]))
|
||||
- 1)) != 1) {
|
||||
/* right delimiting key must be gt the key of the last item in the node */
|
||||
@@ -1088,7 +1088,7 @@ static int bad_path(reiserfs_filsys_t *fs, struct buffer_head **path, int h1)
|
||||
"be greater than the last (%d) element's key %k within the node.\n",
|
||||
dk, path[h]->b_blocknr,
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h])) - 1,
|
||||
B_N_PKEY(path[h],
|
||||
leaf_key(path[h],
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h])) - 1));
|
||||
one_more_corruption(fs, FATAL);
|
||||
return 1;
|
||||
@@ -1199,9 +1199,9 @@ static int clean_attributes_handler(reiserfs_filsys_t *fs,
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++) {
|
||||
if (is_stat_data_ih(B_N_PITEM_HEAD(bh, i)) &&
|
||||
get_ih_item_len(B_N_PITEM_HEAD(bh, i)) == SD_SIZE) {
|
||||
set_sd_v2_sd_attrs((struct stat_data *)B_N_PITEM(bh, i),
|
||||
if (is_stat_data_ih(item_head(bh, i)) &&
|
||||
get_ih_item_len(item_head(bh, i)) == SD_SIZE) {
|
||||
set_sd_v2_sd_attrs((struct stat_data *)item_body(bh, i),
|
||||
0);
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
|
||||
+8
-8
@@ -64,7 +64,7 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
if (!fsck_quiet(fs))
|
||||
print_how_fast(leaves++, 0, 50, 0);
|
||||
|
||||
for (ih = get_ih(&path);
|
||||
for (ih = tp_item_head(&path);
|
||||
item_pos < get_blkh_nr_items(B_BLK_HEAD(bh));
|
||||
item_pos++, ih++, PATH_LAST_POSITION(&path)++) {
|
||||
if (is_item_reachable(ih))
|
||||
@@ -100,11 +100,11 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
}
|
||||
|
||||
/* stat data marked "not having name" found */
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
is_it_dir =
|
||||
((not_a_directory(B_I_PITEM(bh, ih))) ? 0 : 1);
|
||||
((not_a_directory(ih_item_body(bh, ih))) ? 0 : 1);
|
||||
|
||||
if (is_it_dir) {
|
||||
struct reiserfs_key tmp_key;
|
||||
@@ -117,7 +117,7 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
0xffffffff, TYPE_DIRENTRY);
|
||||
reiserfs_search_by_key_4(fs, &tmp_key,
|
||||
&tmp_path);
|
||||
tmp_ih = get_ih(&tmp_path);
|
||||
tmp_ih = tp_item_head(&tmp_path);
|
||||
tmp_ih--;
|
||||
if (not_of_one_file(&tmp_key, tmp_ih))
|
||||
reiserfs_panic("not directory found");
|
||||
@@ -227,11 +227,11 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
&obj_key);
|
||||
|
||||
/* check_regular_file does not mark stat data reachable */
|
||||
mark_item_reachable(get_ih(&path),
|
||||
mark_item_reachable(tp_item_head(&path),
|
||||
get_bh(&path));
|
||||
|
||||
rebuild_check_regular_file(&path,
|
||||
get_item
|
||||
tp_item_body
|
||||
(&path),
|
||||
0
|
||||
/*reloc_ih */
|
||||
@@ -399,8 +399,8 @@ void pass_3a_look_for_lost(reiserfs_filsys_t *fs)
|
||||
reiserfs_panic
|
||||
("look_for_lost: The StatData of the 'lost+found' directory %K could not be found",
|
||||
&lost_found_dir_key);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
get_sd_size(ih, sd, &sd_size);
|
||||
size += sd_size;
|
||||
blocks = dir_size2st_blocks(size);
|
||||
|
||||
+18
-18
@@ -245,8 +245,8 @@ static int verify_directory_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
char *direntries;
|
||||
#endif
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, item_num);
|
||||
item = B_I_PITEM(bh, ih);
|
||||
ih = item_head(bh, item_num);
|
||||
item = ih_item_body(bh, ih);
|
||||
deh = (struct reiserfs_de_head *)item;
|
||||
|
||||
if ((get_ih_entry_count(ih) >
|
||||
@@ -690,12 +690,12 @@ static void pass0_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
|
||||
/* Delete all safe links. */
|
||||
for (i = get_blkh_nr_items(B_BLK_HEAD(bh)) - 1; i >= 0; i--) {
|
||||
if (get_key_dirid(&B_N_PITEM_HEAD(bh, i)->ih_key) == ~(__u32) 0) {
|
||||
if (get_key_dirid(&item_head(bh, i)->ih_key) == ~(__u32) 0) {
|
||||
delete_item(fs, bh, i);
|
||||
}
|
||||
if (get_key_dirid(&B_N_PITEM_HEAD(bh, i)->ih_key) ==
|
||||
if (get_key_dirid(&item_head(bh, i)->ih_key) ==
|
||||
BADBLOCK_DIRID
|
||||
&& get_key_objectid(&B_N_PITEM_HEAD(bh, i)->ih_key) ==
|
||||
&& get_key_objectid(&item_head(bh, i)->ih_key) ==
|
||||
BADBLOCK_OBJID) {
|
||||
delete_item(fs, bh, i);
|
||||
}
|
||||
@@ -706,7 +706,7 @@ static void pass0_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
|
||||
start_again:
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < (nr_items = get_blkh_nr_items(B_BLK_HEAD(bh)));
|
||||
i++, ih++) {
|
||||
|
||||
@@ -1484,7 +1484,7 @@ start_again:
|
||||
|
||||
file_format = get_ih_key_format(ih);
|
||||
|
||||
get_sd_mode(ih, B_N_PITEM(bh, i), &mode);
|
||||
get_sd_mode(ih, item_body(bh, i), &mode);
|
||||
symlnk = (S_ISLNK(mode) ? 1 : 0);
|
||||
; /*correct_stat_data (fs, bh, i); */
|
||||
} else if (!is_direntry_ih(ih) &&
|
||||
@@ -1506,8 +1506,8 @@ start_again:
|
||||
&& !not_of_one_file(&ih->ih_key, &(ih - 1)->ih_key)) {
|
||||
__u16 mode;
|
||||
|
||||
get_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1), &mode);
|
||||
if (not_a_directory(B_I_PITEM(bh, ih - 1))
|
||||
get_sd_mode(ih - 1, ih_item_body(bh, ih - 1), &mode);
|
||||
if (not_a_directory(ih_item_body(bh, ih - 1))
|
||||
&& is_direntry_ih(ih)) {
|
||||
/* make SD mode SD of dir */
|
||||
fsck_log
|
||||
@@ -1516,10 +1516,10 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFDIR;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
} else if (!not_a_directory(B_I_PITEM(bh, ih - 1))
|
||||
} else if (!not_a_directory(ih_item_body(bh, ih - 1))
|
||||
&& !is_direntry_ih(ih)) {
|
||||
/* make SD mode SD of regular file */
|
||||
fsck_log
|
||||
@@ -1528,11 +1528,11 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
}
|
||||
if (not_a_regfile(B_I_PITEM(bh, ih - 1))
|
||||
if (not_a_regfile(ih_item_body(bh, ih - 1))
|
||||
&& is_indirect_ih(ih)) {
|
||||
fsck_log
|
||||
("pass0: block %lu, item %d: The file %K has the wrong mode (%M), corrected to ",
|
||||
@@ -1540,7 +1540,7 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
}
|
||||
@@ -1607,7 +1607,7 @@ start_again:
|
||||
}
|
||||
}
|
||||
*/
|
||||
ind_item = (__u32 *) B_I_PITEM(bh, ih);
|
||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
||||
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
||||
unfm_ptr = d32_get(ind_item, j);
|
||||
if (!unfm_ptr)
|
||||
@@ -1645,7 +1645,7 @@ start_again:
|
||||
}
|
||||
|
||||
/* mark all objectids in use */
|
||||
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;
|
||||
|
||||
@@ -1816,8 +1816,8 @@ int is_leaf_bad(struct buffer_head *bh)
|
||||
|
||||
assert(is_leaf_node(bh));
|
||||
|
||||
for (i = 0, ih = B_N_PITEM_HEAD(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
for (i = 0, ih = item_head(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
fsck_log
|
||||
("is_leaf_bad: block %lu, item %d: The corrupted item found (%H)\n",
|
||||
bh->b_blocknr, i, ih);
|
||||
|
||||
+10
-10
@@ -68,7 +68,7 @@ static void stat_data_in_tree(struct buffer_head *bh, struct item_head *ih)
|
||||
}
|
||||
#endif
|
||||
|
||||
zero_nlink(ih, B_I_PITEM(bh, ih));
|
||||
zero_nlink(ih, ih_item_body(bh, ih));
|
||||
}
|
||||
|
||||
static char *still_bad_unfm_ptr_to_string(int val)
|
||||
@@ -97,7 +97,7 @@ static void indirect_in_tree(struct buffer_head *bh, struct item_head *ih)
|
||||
__u32 unfm_ptr;
|
||||
int ret;
|
||||
|
||||
unp = (__u32 *) B_I_PITEM(bh, ih);
|
||||
unp = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||
unfm_ptr = d32_get(unp, i);
|
||||
@@ -168,8 +168,8 @@ int balance_condition_fails(struct buffer_head *left, struct buffer_head *right)
|
||||
{
|
||||
if (B_FREE_SPACE(left) >= B_CHILD_SIZE(right) -
|
||||
(are_items_mergeable
|
||||
(B_N_PITEM_HEAD(left, B_NR_ITEMS(left) - 1),
|
||||
B_N_PITEM_HEAD(right, 0), left->b_size) ? IH_SIZE : 0))
|
||||
(item_head(left, B_NR_ITEMS(left) - 1),
|
||||
item_head(right, 0), left->b_size) ? IH_SIZE : 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ int balance_condition_2_fails(struct buffer_head *new,
|
||||
|
||||
if (B_FREE_SPACE(new) >= used_space -
|
||||
(are_items_mergeable
|
||||
(B_N_PITEM_HEAD(new, B_NR_ITEMS(new) - 1),
|
||||
(item_head(new, B_NR_ITEMS(new) - 1),
|
||||
(struct item_head *)right_dkey, new->b_size) ? IH_SIZE : 0))
|
||||
return 1;
|
||||
|
||||
@@ -230,7 +230,7 @@ static void get_max_buffer_key(struct buffer_head *bh, struct reiserfs_key *key)
|
||||
{
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1);
|
||||
ih = item_head(bh, B_NR_ITEMS(bh) - 1);
|
||||
copy_key(key, &(ih->ih_key));
|
||||
|
||||
if (is_direntry_key(key)) {
|
||||
@@ -276,7 +276,7 @@ static void try_to_insert_pointer_to_leaf(struct buffer_head *new_bh)
|
||||
return;
|
||||
}
|
||||
|
||||
first_bh_key = B_N_PKEY(new_bh, 0);
|
||||
first_bh_key = leaf_key(new_bh, 0);
|
||||
|
||||
/* try to find place in the tree for the first key of the coming node */
|
||||
ret_value = reiserfs_search_by_key_4(fs, first_bh_key, &path);
|
||||
@@ -287,7 +287,7 @@ static void try_to_insert_pointer_to_leaf(struct buffer_head *new_bh)
|
||||
get_max_buffer_key(new_bh, &last_bh_key);
|
||||
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
if (comp_keys(B_N_PKEY(bh, 0), &last_bh_key) ==
|
||||
if (comp_keys(leaf_key(bh, 0), &last_bh_key) ==
|
||||
1 /* first is greater */ ) {
|
||||
/* new buffer falls before the leftmost leaf */
|
||||
if (balance_condition_fails(new_bh, bh))
|
||||
@@ -344,7 +344,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
__u32 unfm_ptr;
|
||||
int dirty = 0;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_direntry_ih(ih)) {
|
||||
struct reiserfs_de_head *deh;
|
||||
@@ -419,7 +419,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
continue;
|
||||
|
||||
/* correct indirect items */
|
||||
ind_item = (__u32 *) B_I_PITEM(bh, ih);
|
||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||
unfm_ptr = d32_get(ind_item, j);
|
||||
|
||||
+19
-19
@@ -157,9 +157,9 @@ void save_item(struct si **head, struct item_head *ih, char *item,
|
||||
struct si *save_and_delete_file_item(struct si *si, struct reiserfs_path *path)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
save_item(&si, ih, B_I_PITEM(bh, ih), bh->b_blocknr);
|
||||
save_item(&si, ih, ih_item_body(bh, ih), bh->b_blocknr);
|
||||
|
||||
/* delete item temporary - do not free unformatted nodes */
|
||||
reiserfsck_delete_item(path, 1 /*temporary */ );
|
||||
@@ -194,7 +194,7 @@ int should_relocate(struct item_head *ih)
|
||||
break;
|
||||
}
|
||||
|
||||
path_ih = get_ih(&path);
|
||||
path_ih = tp_item_head(&path);
|
||||
if (not_of_one_file(&key, &(path_ih->ih_key))) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -219,7 +219,7 @@ int should_relocate(struct item_head *ih)
|
||||
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_ih(path_ih)
|
||||
&& !not_a_directory(get_item(&path)))
|
||||
&& !not_a_directory(tp_item_body(&path)))
|
||||
|| (is_direntry_ih(path_ih))) {
|
||||
/* item of directory found. so, we have to relocate the file */
|
||||
pathrelse(&path);
|
||||
@@ -245,12 +245,12 @@ static void overwrite_stat_data(struct item_head *new_ih,
|
||||
__u16 new_mode, old_mode;
|
||||
|
||||
get_sd_mode(new_ih, new_item, &new_mode);
|
||||
get_sd_mode(get_ih(path), get_item(path), &old_mode);
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &old_mode);
|
||||
|
||||
if (S_ISREG(new_mode) && !S_ISREG(old_mode)) {
|
||||
/* in tree we have not regular file - overwrite its stat data
|
||||
with stat data of regular file */
|
||||
memcpy(get_item(path), new_item, get_ih_item_len(get_ih(path)));
|
||||
memcpy(tp_item_body(path), new_item, get_ih_item_len(tp_item_head(path)));
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
return;
|
||||
}
|
||||
@@ -263,13 +263,13 @@ static void overwrite_stat_data(struct item_head *new_ih,
|
||||
|
||||
/* if coming stat data has newer mtime - use that */
|
||||
if (stat_data_v1(new_ih)) {
|
||||
if (st_mtime_v1(new_item) > st_mtime_v1(get_item(path))) {
|
||||
memcpy(get_item(path), new_item, SD_V1_SIZE);
|
||||
if (st_mtime_v1(new_item) > st_mtime_v1(tp_item_body(path))) {
|
||||
memcpy(tp_item_body(path), new_item, SD_V1_SIZE);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
}
|
||||
} else {
|
||||
if (st_mtime_v2(new_item) > st_mtime_v2(get_item(path))) {
|
||||
memcpy(get_item(path), new_item, SD_SIZE);
|
||||
if (st_mtime_v2(new_item) > st_mtime_v2(tp_item_body(path))) {
|
||||
memcpy(tp_item_body(path), new_item, SD_SIZE);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ static void put_sd_into_tree(struct item_head *new_ih, char *new_item)
|
||||
if (reiserfs_search_by_key_4(fs, &(new_ih->ih_key), &path) ==
|
||||
ITEM_FOUND) {
|
||||
/* this stat data is found */
|
||||
if (get_ih_key_format(get_ih(&path)) !=
|
||||
if (get_ih_key_format(tp_item_head(&path)) !=
|
||||
get_ih_key_format(new_ih)) {
|
||||
/* in tree stat data and a new one are of different
|
||||
formats */
|
||||
@@ -317,13 +317,13 @@ static void put_sd_into_tree(struct item_head *new_ih, char *new_item)
|
||||
is of V2 */
|
||||
fsck_log
|
||||
("found newer in the tree, mode (%M), insersion was skipped.\n",
|
||||
st_mode(get_item(&path)));
|
||||
st_mode(tp_item_body(&path)));
|
||||
pathrelse(&path);
|
||||
} else {
|
||||
/* the stat data in the tree is sd_v1 */
|
||||
fsck_log
|
||||
("older sd, mode (%M), is replaced with it.\n",
|
||||
st_mode(get_item(&path)));
|
||||
st_mode(tp_item_body(&path)));
|
||||
reiserfsck_delete_item(&path,
|
||||
0 /*not temporary */ );
|
||||
|
||||
@@ -402,15 +402,15 @@ static void put_stat_data_items(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 < B_NR_ITEMS(bh); i++, ih++) {
|
||||
|
||||
/* this check instead of saved_items */
|
||||
if (!is_stat_data_ih(ih)
|
||||
|| is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
|| is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
continue;
|
||||
}
|
||||
insert_item_separately(ih, B_I_PITEM(bh, ih),
|
||||
insert_item_separately(ih, ih_item_body(bh, ih),
|
||||
0 /*was in tree */ );
|
||||
}
|
||||
}
|
||||
@@ -420,14 +420,14 @@ static void put_not_stat_data_items(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 < B_NR_ITEMS(bh); i++, ih++) {
|
||||
|
||||
if (is_stat_data_ih(ih)
|
||||
|| is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
|| is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
continue;
|
||||
}
|
||||
insert_item_separately(ih, B_I_PITEM(bh, ih),
|
||||
insert_item_separately(ih, ih_item_body(bh, ih),
|
||||
0 /*was in tree */ );
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ void pass_4_check_unaccessed_items(void)
|
||||
if (!fsck_quiet(fs))
|
||||
print_how_fast(items++, 0, 50, 0);
|
||||
|
||||
for (i = get_item_pos(&path), ih = get_ih(&path);
|
||||
for (i = get_item_pos(&path), ih = tp_item_head(&path);
|
||||
i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (!is_item_reachable(ih)) {
|
||||
PATH_LAST_POSITION(&path) = i;
|
||||
|
||||
+19
-19
@@ -102,7 +102,7 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
int retval = OK;
|
||||
__u32 tmp_position;
|
||||
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
if (new_ih) {
|
||||
/* this objectid is used already */
|
||||
@@ -119,8 +119,8 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
("check_check_regular_file: Could not find a StatData of "
|
||||
"the relocated file %K", &new_ih->ih_key);
|
||||
/* stat data is marked unreachable again due to relocation, fix that */
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
}
|
||||
|
||||
if (get_ih_item_len(ih) == SD_SIZE)
|
||||
@@ -208,8 +208,8 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
}
|
||||
|
||||
bh = get_bh(path);
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
set_sd_size(ih, sd, &real_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
set_sd_mode(ih, sd, &mode);
|
||||
@@ -252,7 +252,7 @@ start_again:
|
||||
/* leaf containing directory item */
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
*pos_in_item = path.pos_in_item;
|
||||
*ih = *get_ih(&path);
|
||||
*ih = *tp_item_head(&path);
|
||||
deh = B_I_DEH(bh, ih);
|
||||
|
||||
/* position was not found for '.' or there is no '..' */
|
||||
@@ -362,7 +362,7 @@ start_again:
|
||||
|
||||
/* copy directory item to the temporary buffer */
|
||||
dir_item = getmem(get_ih_item_len(ih));
|
||||
memcpy(dir_item, B_I_PITEM(bh, ih), get_ih_item_len(ih));
|
||||
memcpy(dir_item, ih_item_body(bh, ih), get_ih_item_len(ih));
|
||||
|
||||
/* next item key */
|
||||
if (PATH_LAST_POSITION(&path) == (B_NR_ITEMS(bh) - 1) &&
|
||||
@@ -374,7 +374,7 @@ start_again:
|
||||
}
|
||||
|
||||
if (fsck_mode(fs) == FSCK_REBUILD)
|
||||
mark_item_reachable(get_ih(&path), bh);
|
||||
mark_item_reachable(tp_item_head(&path), bh);
|
||||
pathrelse(&path);
|
||||
|
||||
return dir_item;
|
||||
@@ -424,8 +424,8 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
}
|
||||
|
||||
/* stat data has been found */
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
get_sd_nlink(ih, sd, &nlink);
|
||||
|
||||
@@ -522,7 +522,7 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
get_sd_mode(ih, sd, &mode);
|
||||
|
||||
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;
|
||||
|
||||
/* release path pointing to stat data */
|
||||
@@ -673,7 +673,7 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
|
||||
tmp_deh =
|
||||
B_I_DEH(get_bh(&path),
|
||||
get_ih(&path)) +
|
||||
tp_item_head(&path)) +
|
||||
path.pos_in_item;
|
||||
fsck_log
|
||||
("The directory %K pointing to %K (\"%.*s\") updated to point "
|
||||
@@ -735,8 +735,8 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
}
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
set_sd_size(ih, sd, &dir_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
@@ -770,7 +770,7 @@ int check_safe_links()
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_ih = get_ih(&safe_link_path);
|
||||
tmp_ih = tp_item_head(&safe_link_path);
|
||||
|
||||
if (get_key_dirid(&tmp_ih->ih_key) != (__u32) - 1 ||
|
||||
get_key_objectid(&tmp_ih->ih_key) == (__u32) - 1) {
|
||||
@@ -784,7 +784,7 @@ int check_safe_links()
|
||||
get_ih_item_len(tmp_ih));
|
||||
|
||||
set_key_dirid(&key,
|
||||
d32_get((__u32 *) get_item(&safe_link_path), 0));
|
||||
d32_get((__u32 *) tp_item_body(&safe_link_path), 0));
|
||||
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
||||
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
||||
set_key_dirid(&safe_link_key, 0);
|
||||
@@ -803,7 +803,7 @@ int check_safe_links()
|
||||
("Invalid safe link %k: cannot find the pointed object (%K) - "
|
||||
"safe link was deleted\n", &tmp_ih->ih_key,
|
||||
&key);
|
||||
d32_put((__u32 *) get_item(&safe_link_path), 0,
|
||||
d32_put((__u32 *) tp_item_body(&safe_link_path), 0,
|
||||
0);
|
||||
pathrelse(&path);
|
||||
reiserfsck_delete_item(&safe_link_path, 0);
|
||||
@@ -811,7 +811,7 @@ int check_safe_links()
|
||||
}
|
||||
} else if (get_offset(&tmp_ih->ih_key) == 0x1) {
|
||||
/* Truncate */
|
||||
if (!not_a_directory(get_item(&path))) {
|
||||
if (!not_a_directory(tp_item_body(&path))) {
|
||||
/*truncate on directory should not happen */
|
||||
/*sware on check, delete on fix-fixable */
|
||||
if (fsck_mode(fs) == FSCK_CHECK) {
|
||||
@@ -826,7 +826,7 @@ int check_safe_links()
|
||||
"a directory (%K) - safe link was deleted\n",
|
||||
&tmp_ih->ih_key, &key);
|
||||
d32_put((__u32 *)
|
||||
get_item(&safe_link_path), 0,
|
||||
tp_item_body(&safe_link_path), 0,
|
||||
0);
|
||||
pathrelse(&path);
|
||||
reiserfsck_delete_item(&safe_link_path,
|
||||
|
||||
+31
-31
@@ -349,10 +349,10 @@ void relocate_dir(struct item_head *ih, int change_ih)
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
path_ih = get_ih(&path);
|
||||
path_ih = tp_item_head(&path);
|
||||
if (not_of_one_file(&key, &(path_ih->ih_key))) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -361,7 +361,7 @@ void relocate_dir(struct item_head *ih, int change_ih)
|
||||
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_ih(path_ih)
|
||||
&& not_a_directory(get_item(&path)))
|
||||
&& not_a_directory(tp_item_body(&path)))
|
||||
|| is_direct_ih(path_ih) || is_indirect_ih(path_ih)) {
|
||||
/* item of not a directory found. Leave it in the
|
||||
tree. FIXME: should not happen */
|
||||
@@ -427,7 +427,7 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
retval = OK;
|
||||
|
||||
/* stat data of a file */
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
bh = get_bh(path);
|
||||
|
||||
if (new_ih) {
|
||||
@@ -444,10 +444,10 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
("%s: Could not find the StatData of the relocated file %k",
|
||||
__FUNCTION__, &(new_ih->ih_key));
|
||||
/* stat data is marked unreachable again due to relocation, fix that */
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
bh = get_bh(path);
|
||||
mark_item_reachable(ih, bh);
|
||||
sd = get_item(path);
|
||||
sd = tp_item_body(path);
|
||||
|
||||
}
|
||||
|
||||
@@ -526,8 +526,8 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
__FUNCTION__, &sd_ih.ih_key);
|
||||
|
||||
bh = get_bh(path);
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
set_sd_size(ih, sd, &real_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
set_sd_mode(ih, sd, &mode);
|
||||
@@ -570,7 +570,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
/* leaf containing directory item */
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
*pos_in_item = path.pos_in_item;
|
||||
*ih = *get_ih(&path);
|
||||
*ih = *tp_item_head(&path);
|
||||
deh = B_I_DEH(bh, ih);
|
||||
|
||||
/* make sure, that ".." exists as well */
|
||||
@@ -634,7 +634,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
|
||||
/* copy directory item to the temporary buffer */
|
||||
dir_item = getmem(get_ih_item_len(ih));
|
||||
memcpy(dir_item, B_I_PITEM(bh, ih), get_ih_item_len(ih));
|
||||
memcpy(dir_item, ih_item_body(bh, ih), get_ih_item_len(ih));
|
||||
|
||||
/* next item key */
|
||||
if (PATH_LAST_POSITION(&path) == (B_NR_ITEMS(bh) - 1) &&
|
||||
@@ -646,7 +646,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
}
|
||||
|
||||
if (fsck_mode(fs) == FSCK_REBUILD)
|
||||
mark_item_reachable(get_ih(&path), bh);
|
||||
mark_item_reachable(tp_item_head(&path), bh);
|
||||
pathrelse(&path);
|
||||
|
||||
return dir_item;
|
||||
@@ -677,38 +677,38 @@ int fix_obviously_wrong_sd_mode(struct reiserfs_path *path)
|
||||
|
||||
next_key = reiserfs_next_key(path);
|
||||
|
||||
if (!next_key || not_of_one_file(next_key, &get_ih(path)->ih_key))
|
||||
if (!next_key || not_of_one_file(next_key, &tp_item_head(path)->ih_key))
|
||||
return 0;
|
||||
|
||||
/* next item exists and of the same file. Fix the SD mode */
|
||||
|
||||
if (not_a_directory(get_item(path)) && is_direntry_key(next_key)) {
|
||||
if (not_a_directory(tp_item_body(path)) && is_direntry_key(next_key)) {
|
||||
/* make SD mode SD of dir */
|
||||
get_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
fsck_log("The directory %K had wrong mode %M",
|
||||
&get_ih(path)->ih_key, mode);
|
||||
&tp_item_head(path)->ih_key, mode);
|
||||
|
||||
if (fsck_mode(fs) != FSCK_CHECK) {
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFDIR;
|
||||
fsck_log(" - corrected to %M\n", mode);
|
||||
set_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
set_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
} else {
|
||||
fsck_log("\n");
|
||||
retval = 1;
|
||||
}
|
||||
} else if (!not_a_directory(get_item(path))
|
||||
} else if (!not_a_directory(tp_item_body(path))
|
||||
&& !is_direntry_key(next_key)) {
|
||||
/* make SD mode SD of regular file */
|
||||
get_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
fsck_log("The file %K had wrong mode %M", &get_ih(path)->ih_key,
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
fsck_log("The file %K had wrong mode %M", &tp_item_head(path)->ih_key,
|
||||
mode);
|
||||
if (fsck_mode(fs) != FSCK_CHECK) {
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log(" - corrected to %M\n", mode);
|
||||
set_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
set_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
} else {
|
||||
fsck_log("\n");
|
||||
@@ -769,8 +769,8 @@ start_again: /* when directory was relocated */
|
||||
|
||||
/* stat data has been found */
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
/* */
|
||||
get_sd_nlink(ih, sd, &nlink);
|
||||
@@ -877,7 +877,7 @@ start_again: /* when directory was relocated */
|
||||
*/
|
||||
|
||||
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;
|
||||
/* save stat data's size and st_blocks */
|
||||
get_sd_size(ih, sd, &saved_size);
|
||||
@@ -1005,7 +1005,7 @@ start_again: /* when directory was relocated */
|
||||
|
||||
tmp_deh =
|
||||
B_I_DEH(get_bh(&path),
|
||||
get_ih(&path)) +
|
||||
tp_item_head(&path)) +
|
||||
path.pos_in_item;
|
||||
fsck_log
|
||||
("The entry %K (\"%.*s\") in directory %K updated to point to ",
|
||||
@@ -1060,8 +1060,8 @@ start_again: /* when directory was relocated */
|
||||
key);
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
set_sd_size(ih, sd, &dir_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
@@ -1164,7 +1164,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
lost_found_dir_format =
|
||||
create_dir_sd(fs, &path, &lost_found_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 lost+found's stat data %k\n",
|
||||
@@ -1172,7 +1172,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
if (not_a_directory(get_item(&path))) {
|
||||
if (not_a_directory(tp_item_body(&path))) {
|
||||
fsck_progress
|
||||
("\"/lost+found\" exists, but it is not a directory, \
|
||||
lost files will not be linked\n");
|
||||
@@ -1182,7 +1182,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
}
|
||||
|
||||
lost_found_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);
|
||||
@@ -1209,8 +1209,8 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
__FUNCTION__);
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
get_sd_size(ih, sd, &sd_size);
|
||||
sd_size += item_len;
|
||||
|
||||
+33
-33
@@ -35,7 +35,7 @@ static unsigned long indirect_to_direct(struct reiserfs_path *path, __u64 len,
|
||||
int symlink)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
__u32 unfm_ptr;
|
||||
struct buffer_head *unfm_bh = 0;
|
||||
struct item_head ins_ih;
|
||||
@@ -57,7 +57,7 @@ static unsigned long indirect_to_direct(struct reiserfs_path *path, __u64 len,
|
||||
TYPE_DIRECT);
|
||||
|
||||
// we do not know what length this item should be
|
||||
unfm_ptr = d32_get((__u32 *) get_item(path), I_UNFM_NUM(ih) - 1);
|
||||
unfm_ptr = d32_get((__u32 *) tp_item_body(path), I_UNFM_NUM(ih) - 1);
|
||||
if (unfm_ptr && (unfm_bh = bread(bh->b_dev, unfm_ptr, bh->b_size))) {
|
||||
/* we can read the block */
|
||||
buf = unfm_bh->b_data;
|
||||
@@ -137,10 +137,10 @@ int delete_N_items_after_key(struct reiserfs_key *start_key,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
rkey = &(get_ih(&path))->ih_key;
|
||||
rkey = &(tp_item_head(&path))->ih_key;
|
||||
if (not_of_one_file(start_key, rkey)) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -150,7 +150,7 @@ int delete_N_items_after_key(struct reiserfs_key *start_key,
|
||||
copy_key(start_key, rkey);
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_key(rkey)
|
||||
&& !not_a_directory(get_item(&path)))
|
||||
&& !not_a_directory(tp_item_body(&path)))
|
||||
|| (is_direntry_key(rkey))) {
|
||||
if (skip_dir_items) {
|
||||
/* item of directory found. Leave it in the tree */
|
||||
@@ -225,7 +225,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
|
||||
switch (retval) {
|
||||
case POSITION_FOUND:
|
||||
/**/ ih = PATH_PITEM_HEAD(&path);
|
||||
/**/ ih = tp_item_head(&path);
|
||||
|
||||
if (ih_was_tail(ih)) {
|
||||
was_tail = 1;
|
||||
@@ -377,7 +377,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
i++) {
|
||||
__u32 *ind =
|
||||
(__u32 *)
|
||||
get_item(&path);
|
||||
tp_item_body(&path);
|
||||
|
||||
if (d32_get(ind, i) !=
|
||||
0)
|
||||
@@ -414,7 +414,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
pathrelse(&path);
|
||||
} else {
|
||||
__u32 *ind =
|
||||
(__u32 *) get_item(&path);
|
||||
(__u32 *) tp_item_body(&path);
|
||||
/* DEBUG message.
|
||||
fsck_log ("are_file_items_correct: The indirect item is converted back to direct %K\n", &ih->ih_key);
|
||||
*/
|
||||
@@ -592,9 +592,9 @@ void rewrite_file(struct item_head *ih, int should_relocate,
|
||||
static int make_file_writeable(struct buffer_head *bh, int pos)
|
||||
/* struct item_head * sd_ih, void * sd */
|
||||
{
|
||||
struct item_head *sd_ih = B_N_PITEM_HEAD(bh, pos);
|
||||
struct item_head *sd_ih = item_head(bh, pos);
|
||||
struct item_head sd_ih_copy;
|
||||
struct stat_data *sd = (struct stat_data *)B_N_PITEM(bh, pos);
|
||||
struct stat_data *sd = (struct stat_data *)item_body(bh, pos);
|
||||
struct stat_data sd_copy;
|
||||
__u64 size;
|
||||
__u32 blocks;
|
||||
@@ -738,12 +738,12 @@ static unsigned long block_to_start(struct reiserfs_path *path)
|
||||
__u32 blk;
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
if (get_offset(&ih->ih_key) == 1 || PATH_LAST_POSITION(path) == 0)
|
||||
return bh->b_blocknr;
|
||||
|
||||
ih--;
|
||||
blk = d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
blk = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
return (blk ? blk : bh->b_blocknr);
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
int copied = 0;
|
||||
int file_format;
|
||||
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
copy_key(&key, &(ih->ih_key));
|
||||
|
||||
file_format = key_format(&key);
|
||||
@@ -777,12 +777,12 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
do {
|
||||
__u64 len;
|
||||
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
len = get_bytes_number(ih, fs->fs_blocksize);
|
||||
|
||||
memcpy(unbh->b_data + copied,
|
||||
B_I_PITEM(PATH_PLAST_BUFFER(path), ih), len);
|
||||
ih_item_body(PATH_PLAST_BUFFER(path), ih), len);
|
||||
|
||||
// save_unfm_overwriting (unbh->b_blocknr, ih);
|
||||
copied += len;
|
||||
@@ -813,7 +813,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
mark_ih_was_tail(&insih);
|
||||
reiserfsck_insert_item(path, &insih, (const char *)&(ni));
|
||||
} else {
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
if (!is_indirect_ih(ih))
|
||||
reiserfs_panic
|
||||
@@ -837,7 +837,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
brelse(unbh);
|
||||
|
||||
if (usearch_by_position(fs, &key, file_format, path) != POSITION_FOUND
|
||||
|| !is_indirect_ih(PATH_PITEM_HEAD(path)))
|
||||
|| !is_indirect_ih(tp_item_head(path)))
|
||||
reiserfs_panic
|
||||
("direct2indirect: The data %k, which are supposed to be converted, are not found",
|
||||
&key);
|
||||
@@ -856,7 +856,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
||||
int zero_number;
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
unfm_ptr = d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
|
||||
/* append to free space of the last unformatted node of indirect item ih */
|
||||
free_space =
|
||||
@@ -896,7 +896,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
||||
/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) { */
|
||||
unbh = reiserfsck_get_new_buffer(bh->b_blocknr);
|
||||
memset(unbh->b_data, 0, unbh->b_size);
|
||||
d32_put((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1,
|
||||
d32_put((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1,
|
||||
unbh->b_blocknr);
|
||||
/*mark_block_unformatted (unbh->b_blocknr); */
|
||||
mark_buffer_dirty(bh);
|
||||
@@ -927,7 +927,7 @@ int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
||||
__u32 *ni;
|
||||
struct buffer_head *unbh;
|
||||
int retval;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
__u32 bytes_number;
|
||||
int i, count = 0;
|
||||
|
||||
@@ -1002,11 +1002,11 @@ int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
||||
long long int must_there_be_a_hole(struct item_head *comingih,
|
||||
struct reiserfs_path *path)
|
||||
{
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (is_direct_ih(ih)) {
|
||||
direct2indirect2(0, path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
}
|
||||
|
||||
path->pos_in_item = I_UNFM_NUM(ih);
|
||||
@@ -1026,7 +1026,7 @@ int reiserfs_append_zero_unfm_ptr(struct reiserfs_path *path,
|
||||
__u32 *ni;
|
||||
long long int count;
|
||||
|
||||
if (is_direct_ih(PATH_PITEM_HEAD(path)))
|
||||
if (is_direct_ih(tp_item_head(path)))
|
||||
/* convert direct item to indirect */
|
||||
direct2indirect2(0, path);
|
||||
|
||||
@@ -1055,9 +1055,9 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
||||
__u64 coming_len = get_bytes_number(comingih, fs->fs_blocksize);
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
unfm_ptr = d32_get((__u32 *) B_I_PITEM(bh, ih), path->pos_in_item);
|
||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), path->pos_in_item);
|
||||
unbh = 0;
|
||||
|
||||
if (unfm_ptr != 0 && unfm_ptr < get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||
@@ -1070,7 +1070,7 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
||||
if (unfm_ptr == 0 || unfm_ptr >= get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||
if ((unbh = reiserfsck_get_new_buffer(bh->b_blocknr)) != NULL) {
|
||||
memset(unbh->b_data, 0, unbh->b_size);
|
||||
d32_put((__u32 *) B_I_PITEM(bh, ih), path->pos_in_item,
|
||||
d32_put((__u32 *) ih_item_body(bh, ih), path->pos_in_item,
|
||||
unbh->b_blocknr);
|
||||
mark_buffer_dirty(bh);
|
||||
} else {
|
||||
@@ -1156,12 +1156,12 @@ static int overwrite_by_indirect_item(struct item_head *comingih,
|
||||
int *pos_in_coming_item)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
int written;
|
||||
__u32 *item_in_tree;
|
||||
int src_unfm_ptrs, dest_unfm_ptrs, to_copy, i, dirty = 0;
|
||||
|
||||
item_in_tree = (__u32 *) B_I_PITEM(bh, ih) + path->pos_in_item;
|
||||
item_in_tree = (__u32 *) ih_item_body(bh, ih) + path->pos_in_item;
|
||||
coming_item += *pos_in_coming_item;
|
||||
|
||||
dest_unfm_ptrs = I_UNFM_NUM(ih) - path->pos_in_item;
|
||||
@@ -1207,7 +1207,7 @@ static int reiserfsck_overwrite_file(struct item_head *comingih, char *item,
|
||||
{
|
||||
__u32 unfm_ptr;
|
||||
int written = 0;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (not_of_one_file(ih, &(comingih->ih_key)))
|
||||
reiserfs_panic
|
||||
@@ -1278,8 +1278,8 @@ check_again:
|
||||
}
|
||||
|
||||
/*SD found */
|
||||
file_format = get_ih_key_format(get_ih(&path));
|
||||
get_sd_mode(get_ih(&path), get_item(&path), &mode);
|
||||
file_format = get_ih_key_format(tp_item_head(&path));
|
||||
get_sd_mode(tp_item_head(&path), tp_item_body(&path), &mode);
|
||||
|
||||
if (file_format != get_ih_key_format(ih)) {
|
||||
/* Not for symlinks and not for items which should be relocted. */
|
||||
@@ -1332,7 +1332,7 @@ check_again:
|
||||
there is no item between wamted offset and SD, insert first item */
|
||||
if (retval == POSITION_NOT_FOUND &&
|
||||
(PATH_LAST_POSITION(&path) >= B_NR_ITEMS(get_bh(&path)) ||
|
||||
get_offset(&get_ih(&path)->ih_key) > get_offset(&key)))
|
||||
get_offset(&tp_item_head(&path)->ih_key) > get_offset(&key)))
|
||||
retval = FILE_NOT_FOUND;
|
||||
|
||||
if (retval == DIRECTORY_FOUND)
|
||||
@@ -1361,7 +1361,7 @@ check_again:
|
||||
if (retval == POSITION_NOT_FOUND) {
|
||||
|
||||
if (is_direct_ih(ih)) {
|
||||
mark_ih_was_tail(get_ih(&path));
|
||||
mark_ih_was_tail(tp_item_head(&path));
|
||||
mark_buffer_dirty(get_bh(&path));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -40,7 +40,7 @@ void reiserfsck_insert_item(struct reiserfs_path *path, struct item_head *ih,
|
||||
|
||||
static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
||||
{
|
||||
__u32 *punfm = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *punfm = (__u32 *) ih_item_body(bh, ih);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||
@@ -64,7 +64,7 @@ static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
||||
void reiserfsck_delete_item(struct reiserfs_path *path, int temporary)
|
||||
{
|
||||
struct tree_balance tb;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (is_indirect_ih(ih) && !temporary)
|
||||
free_unformatted_nodes(ih, PATH_PLAST_BUFFER(path));
|
||||
@@ -87,10 +87,10 @@ void reiserfsck_cut_from_item(struct reiserfs_path *path, int cut_size)
|
||||
if (cut_size >= 0)
|
||||
die("reiserfsck_cut_from_item: cut size == %d", cut_size);
|
||||
|
||||
if (is_indirect_ih(ih = PATH_PITEM_HEAD(path))) {
|
||||
if (is_indirect_ih(ih = tp_item_head(path))) {
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
__u32 unfm_ptr =
|
||||
d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
if (unfm_ptr != 0) {
|
||||
struct buffer_head *to_be_forgotten;
|
||||
|
||||
@@ -143,7 +143,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
|
||||
|
||||
+10
-11
@@ -972,7 +972,7 @@ struct reiserfs_de_head {
|
||||
#define dir_size2st_blocks(size) ((size + 511) / 512)
|
||||
|
||||
/* array of the entry headers */
|
||||
#define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(B_I_PITEM(bh,ih)))
|
||||
#define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(ih_item_body(bh,ih)))
|
||||
|
||||
#define REISERFS_MAX_NAME_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE - DEH_SIZE)
|
||||
/* -SD_SIZE when entry will contain stat data */
|
||||
@@ -1095,7 +1095,7 @@ struct reiserfs_path var = {ILLEGAL_PATH_ELEMENT_OFFSET, }
|
||||
#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
|
||||
#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
|
||||
|
||||
#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
|
||||
#define tp_item_head(p_s_path) item_head(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
|
||||
|
||||
/* in do_balance leaf has h == 0 in contrast with path structure,
|
||||
where root has level == 0. That is why we need these defines */
|
||||
@@ -1107,9 +1107,8 @@ struct reiserfs_path var = {ILLEGAL_PATH_ELEMENT_OFFSET, }
|
||||
#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
|
||||
|
||||
#define get_bh(path) PATH_PLAST_BUFFER(path)
|
||||
#define get_ih(path) PATH_PITEM_HEAD(path)
|
||||
#define get_item_pos(path) PATH_LAST_POSITION(path)
|
||||
#define get_item(path) ((void *)B_N_PITEM(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION (path)))
|
||||
#define tp_item_body(path) ((void *)item_body(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION (path)))
|
||||
#define item_moved(ih,path) comp_items(ih, path)
|
||||
#define path_changed(ih,path) comp_items (ih, path)
|
||||
|
||||
@@ -1403,27 +1402,27 @@ struct buffer_info {
|
||||
|
||||
|
||||
/* get the item header */
|
||||
#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
|
||||
#define item_head(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
|
||||
|
||||
/* get key */
|
||||
#define B_N_PDELIM_KEY(bh,item_num) ( (struct reiserfs_key *)((bh)->b_data + BLKH_SIZE) + (item_num) )
|
||||
#define internal_key(bh,item_num) ( (struct reiserfs_key *)((bh)->b_data + BLKH_SIZE) + (item_num) )
|
||||
|
||||
/* get the key */
|
||||
#define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) )
|
||||
#define leaf_key(bh,item_num) ( &(item_head(bh,item_num)->ih_key) )
|
||||
|
||||
/* get item body */
|
||||
#define B_N_PITEM(bh,item_num) ( (bh)->b_data + get_ih_location (B_N_PITEM_HEAD((bh),(item_num))))
|
||||
#define item_body(bh,item_num) ( (bh)->b_data + get_ih_location (item_head((bh),(item_num))))
|
||||
|
||||
/* get the stat data by the buffer header and the item order */
|
||||
#define B_N_STAT_DATA(bh,nr) \
|
||||
( (struct stat_data *)((bh)->b_data+get_ih_location(B_N_PITEM_HEAD((bh),(nr))) ) )
|
||||
( (struct stat_data *)((bh)->b_data+get_ih_location(item_head((bh),(nr))) ) )
|
||||
|
||||
/* following defines use reiserfs buffer header and item header */
|
||||
/* get item body */
|
||||
#define B_I_PITEM(bh,ih) ( (bh)->b_data + get_ih_location(ih))
|
||||
#define ih_item_body(bh,ih) ( (bh)->b_data + get_ih_location(ih))
|
||||
|
||||
/* get stat-data */
|
||||
#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )B_I_PITEM(bh,ih) )
|
||||
#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )ih_item_body(bh,ih) )
|
||||
|
||||
#define MAX_DIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - 2*IH_SIZE - SD_SIZE - UNFM_P_SIZE)
|
||||
#define MAX_INDIRECT_ITEM_LEN(size) MAX_ITEM_LEN(size)
|
||||
|
||||
+36
-36
@@ -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
@@ -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
@@ -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
@@ -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 */
|
||||
|
||||
@@ -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
@@ -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
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -119,7 +119,7 @@ static unsigned long move_formatted_block(reiserfs_filsys_t *fs,
|
||||
leaf_node_cnt++;
|
||||
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++) {
|
||||
ih = B_N_PITEM_HEAD(bh, i);
|
||||
ih = item_head(bh, i);
|
||||
|
||||
/* skip the bad blocks. */
|
||||
if (get_key_objectid(&ih->ih_key) == BADBLOCK_OBJID &&
|
||||
@@ -129,7 +129,7 @@ static unsigned long move_formatted_block(reiserfs_filsys_t *fs,
|
||||
if (is_indirect_ih(ih)) {
|
||||
__u32 *indirect;
|
||||
|
||||
indirect = (__u32 *) B_I_PITEM(bh, ih);
|
||||
indirect = (__u32 *) ih_item_body(bh, ih);
|
||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||
unsigned long unfm_block;
|
||||
|
||||
|
||||
+4
-4
@@ -294,8 +294,8 @@ static void callback_new_badblocks(reiserfs_filsys_t *fs,
|
||||
struct item_head *tmp_ih;
|
||||
__u32 *ind_item, 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++) {
|
||||
if (reiserfs_bitmap_test_bit(fs->fs_badblocks_bm,
|
||||
@@ -318,8 +318,8 @@ static void callback_clear_badblocks(reiserfs_filsys_t *fs,
|
||||
struct item_head *tmp_ih;
|
||||
__u32 *ind_item, 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++) {
|
||||
reiserfs_bitmap_clear_bit(fs->fs_bitmap2, d32_get(ind_item, i));
|
||||
|
||||
Reference in new issue
Block a user