Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138867
b: refs/heads/master
c: ad31a4f
h: refs/heads/master
i:
  138865: 627b29f
  138863: 1943476
v: v3
  • Loading branch information
Jeff Mahoney authored and Linus Torvalds committed Mar 30, 2009
1 parent 3bec756 commit 570c11b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 100 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9dd364358fbdc68faee5d20c2d648c320dc3cf0
refs/heads/master: ad31a4fc0386e8590c51ca4b8f1ae1d8b8b2ac5e
94 changes: 44 additions & 50 deletions trunk/fs/reiserfs/fix_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ static int check_balance(int mode,
/* Check whether parent at the path is the really parent of the current node.*/
static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
{
struct buffer_head *p_s_bh;
struct buffer_head *bh;
struct treepath *p_s_path = p_s_tb->tb_path;
int n_position,
n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
Expand All @@ -1909,21 +1909,21 @@ static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
}

if (!B_IS_IN_TREE
(p_s_bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
(bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
return REPEAT_SEARCH; /* Parent in the path is not in the tree. */

if ((n_position =
PATH_OFFSET_POSITION(p_s_path,
n_path_offset - 1)) > B_NR_ITEMS(p_s_bh))
n_path_offset - 1)) > B_NR_ITEMS(bh))
return REPEAT_SEARCH;

if (B_N_CHILD_NUM(p_s_bh, n_position) !=
if (B_N_CHILD_NUM(bh, n_position) !=
PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr)
/* Parent in the path is not parent of the current node in the tree. */
return REPEAT_SEARCH;

if (buffer_locked(p_s_bh)) {
__wait_on_buffer(p_s_bh);
if (buffer_locked(bh)) {
__wait_on_buffer(bh);
if (FILESYSTEM_CHANGED_TB(p_s_tb))
return REPEAT_SEARCH;
}
Expand All @@ -1943,78 +1943,78 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h)
n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1);
unsigned long n_son_number;
struct super_block *sb = p_s_tb->tb_sb;
struct buffer_head *p_s_bh;
struct buffer_head *bh;

PROC_INFO_INC(sb, get_neighbors[n_h]);

if (p_s_tb->lnum[n_h]) {
/* We need left neighbor to balance S[n_h]. */
PROC_INFO_INC(sb, need_l_neighbor[n_h]);
p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);

RFALSE(p_s_bh == p_s_tb->FL[n_h] &&
RFALSE(bh == p_s_tb->FL[n_h] &&
!PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
"PAP-8270: invalid position in the parent");

n_child_position =
(p_s_bh ==
(bh ==
p_s_tb->FL[n_h]) ? p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->
FL[n_h]);
n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position);
p_s_bh = sb_bread(sb, n_son_number);
if (!p_s_bh)
bh = sb_bread(sb, n_son_number);
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
brelse(p_s_bh);
brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}

RFALSE(!B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) ||
B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) !=
p_s_bh->b_blocknr, "PAP-8275: invalid parent");
RFALSE(!B_IS_IN_TREE(p_s_bh), "PAP-8280: invalid child");
bh->b_blocknr, "PAP-8275: invalid parent");
RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child");
RFALSE(!n_h &&
B_FREE_SPACE(p_s_bh) !=
MAX_CHILD_SIZE(p_s_bh) -
B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)),
"PAP-8290: invalid child size of left neighbor");

brelse(p_s_tb->L[n_h]);
p_s_tb->L[n_h] = p_s_bh;
p_s_tb->L[n_h] = bh;
}

if (p_s_tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
PROC_INFO_INC(sb, need_r_neighbor[n_h]);
p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);

RFALSE(p_s_bh == p_s_tb->FR[n_h] &&
RFALSE(bh == p_s_tb->FR[n_h] &&
PATH_OFFSET_POSITION(p_s_tb->tb_path,
n_path_offset) >=
B_NR_ITEMS(p_s_bh),
B_NR_ITEMS(bh),
"PAP-8295: invalid position in the parent");

n_child_position =
(p_s_bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
(bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position);
p_s_bh = sb_bread(sb, n_son_number);
if (!p_s_bh)
bh = sb_bread(sb, n_son_number);
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
brelse(p_s_bh);
brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
brelse(p_s_tb->R[n_h]);
p_s_tb->R[n_h] = p_s_bh;
p_s_tb->R[n_h] = bh;

RFALSE(!n_h
&& B_FREE_SPACE(p_s_bh) !=
MAX_CHILD_SIZE(p_s_bh) -
&& B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)),
"PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
B_FREE_SPACE(p_s_bh), MAX_CHILD_SIZE(p_s_bh),
B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh),
dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)));

}
Expand Down Expand Up @@ -2090,51 +2090,45 @@ static int get_mem_for_virtual_node(struct tree_balance *tb)

#ifdef CONFIG_REISERFS_CHECK
static void tb_buffer_sanity_check(struct super_block *sb,
struct buffer_head *p_s_bh,
struct buffer_head *bh,
const char *descr, int level)
{
if (p_s_bh) {
if (atomic_read(&(p_s_bh->b_count)) <= 0) {
if (bh) {
if (atomic_read(&(bh->b_count)) <= 0)

reiserfs_panic(sb, "jmacd-1", "negative or zero "
"reference counter for buffer %s[%d] "
"(%b)", descr, level, p_s_bh);
}
"(%b)", descr, level, bh);

if (!buffer_uptodate(p_s_bh)) {
if (!buffer_uptodate(bh))
reiserfs_panic(sb, "jmacd-2", "buffer is not up "
"to date %s[%d] (%b)",
descr, level, p_s_bh);
}
descr, level, bh);

if (!B_IS_IN_TREE(p_s_bh)) {
if (!B_IS_IN_TREE(bh))
reiserfs_panic(sb, "jmacd-3", "buffer is not "
"in tree %s[%d] (%b)",
descr, level, p_s_bh);
}
descr, level, bh);

if (p_s_bh->b_bdev != sb->s_bdev) {
if (bh->b_bdev != sb->s_bdev)
reiserfs_panic(sb, "jmacd-4", "buffer has wrong "
"device %s[%d] (%b)",
descr, level, p_s_bh);
}
descr, level, bh);

if (p_s_bh->b_size != sb->s_blocksize) {
if (bh->b_size != sb->s_blocksize)
reiserfs_panic(sb, "jmacd-5", "buffer has wrong "
"blocksize %s[%d] (%b)",
descr, level, p_s_bh);
}
descr, level, bh);

if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(sb)) {
if (bh->b_blocknr > SB_BLOCK_COUNT(sb))
reiserfs_panic(sb, "jmacd-6", "buffer block "
"number too high %s[%d] (%b)",
descr, level, p_s_bh);
}
descr, level, bh);
}
}
#else
static void tb_buffer_sanity_check(struct super_block *sb,
struct buffer_head *p_s_bh,
struct buffer_head *bh,
const char *descr, int level)
{;
}
Expand Down
63 changes: 31 additions & 32 deletions trunk/fs/reiserfs/stree.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
#include <linux/quotaops.h>

/* Does the buffer contain a disk block which is in the tree. */
inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
inline int B_IS_IN_TREE(const struct buffer_head *bh)
{

RFALSE(B_LEVEL(p_s_bh) > MAX_HEIGHT,
"PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
RFALSE(B_LEVEL(bh) > MAX_HEIGHT,
"PAP-1010: block (%b) has too big level (%z)", bh, bh);

return (B_LEVEL(p_s_bh) != FREE_LEVEL);
return (B_LEVEL(bh) != FREE_LEVEL);
}

//
Expand Down Expand Up @@ -579,7 +579,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key
{
b_blocknr_t n_block_number;
int expected_level;
struct buffer_head *p_s_bh;
struct buffer_head *bh;
struct path_element *p_s_last_element;
int n_node_level, n_retval;
int right_neighbor_of_leaf_node;
Expand Down Expand Up @@ -626,15 +626,14 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key

/* Read the next tree node, and set the last element in the path to
have a pointer to it. */
if ((p_s_bh = p_s_last_element->pe_buffer =
if ((bh = p_s_last_element->pe_buffer =
sb_getblk(sb, n_block_number))) {
if (!buffer_uptodate(p_s_bh) && reada_count > 1) {
if (!buffer_uptodate(bh) && reada_count > 1)
search_by_key_reada(sb, reada_bh,
reada_blocks, reada_count);
}
ll_rw_block(READ, 1, &p_s_bh);
wait_on_buffer(p_s_bh);
if (!buffer_uptodate(p_s_bh))
ll_rw_block(READ, 1, &bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh))
goto io_error;
} else {
io_error:
Expand All @@ -651,8 +650,8 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key
to search is still in the tree rooted from the current buffer. If
not then repeat search from the root. */
if (fs_changed(fs_gen, sb) &&
(!B_IS_IN_TREE(p_s_bh) ||
B_LEVEL(p_s_bh) != expected_level ||
(!B_IS_IN_TREE(bh) ||
B_LEVEL(bh) != expected_level ||
!key_in_buffer(p_s_search_path, p_s_key, sb))) {
PROC_INFO_INC(sb, search_by_key_fs_changed);
PROC_INFO_INC(sb, search_by_key_restarted);
Expand Down Expand Up @@ -686,25 +685,25 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key

// make sure, that the node contents look like a node of
// certain level
if (!is_tree_node(p_s_bh, expected_level)) {
if (!is_tree_node(bh, expected_level)) {
reiserfs_error(sb, "vs-5150",
"invalid format found in block %ld. "
"Fsck?", p_s_bh->b_blocknr);
"Fsck?", bh->b_blocknr);
pathrelse(p_s_search_path);
return IO_ERROR;
}

/* ok, we have acquired next formatted node in the tree */
n_node_level = B_LEVEL(p_s_bh);
n_node_level = B_LEVEL(bh);

PROC_INFO_BH_STAT(sb, p_s_bh, n_node_level - 1);
PROC_INFO_BH_STAT(sb, bh, n_node_level - 1);

RFALSE(n_node_level < n_stop_level,
"vs-5152: tree level (%d) is less than stop level (%d)",
n_node_level, n_stop_level);

n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
B_NR_ITEMS(p_s_bh),
n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(bh, 0),
B_NR_ITEMS(bh),
(n_node_level ==
DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
KEY_SIZE,
Expand All @@ -726,13 +725,13 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key
an internal node. Now we calculate child block number by
position in the node. */
n_block_number =
B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position);
B_N_CHILD_NUM(bh, p_s_last_element->pe_position);

/* if we are going to read leaf nodes, try for read ahead as well */
if ((p_s_search_path->reada & PATH_READA) &&
n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
int pos = p_s_last_element->pe_position;
int limit = B_NR_ITEMS(p_s_bh);
int limit = B_NR_ITEMS(bh);
struct reiserfs_key *le_key;

if (p_s_search_path->reada & PATH_READA_BACK)
Expand All @@ -741,7 +740,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key
if (pos == limit)
break;
reada_blocks[reada_count++] =
B_N_CHILD_NUM(p_s_bh, pos);
B_N_CHILD_NUM(bh, pos);
if (p_s_search_path->reada & PATH_READA_BACK)
pos--;
else
Expand All @@ -750,7 +749,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key
/*
* check to make sure we're in the same object
*/
le_key = B_N_PDELIM_KEY(p_s_bh, pos);
le_key = B_N_PDELIM_KEY(bh, pos);
if (le32_to_cpu(le_key->k_objectid) !=
p_s_key->on_disk_key.k_objectid) {
break;
Expand Down Expand Up @@ -851,15 +850,15 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b
/* Compare given item and item pointed to by the path. */
int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path)
{
struct buffer_head *p_s_bh;
struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path);
struct item_head *ih;

/* Last buffer at the path is not in the tree. */
if (!B_IS_IN_TREE(p_s_bh = PATH_PLAST_BUFFER(p_s_path)))
if (!B_IS_IN_TREE(bh))
return 1;

/* Last path position is invalid. */
if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(p_s_bh))
if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(bh))
return 1;

/* we need only to know, whether it is the same item */
Expand Down Expand Up @@ -959,7 +958,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
{
struct super_block *sb = inode->i_sb;
struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_path);
struct buffer_head *p_s_bh = PATH_PLAST_BUFFER(p_s_path);
struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path);

BUG_ON(!th->t_trans_id);

Expand Down Expand Up @@ -1003,7 +1002,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
do {
need_re_search = 0;
*p_n_cut_size = 0;
p_s_bh = PATH_PLAST_BUFFER(p_s_path);
bh = PATH_PLAST_BUFFER(p_s_path);
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
pos = I_UNFM_NUM(&s_ih);

Expand All @@ -1019,13 +1018,13 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
break;
}

unfm = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1;
block = get_block_num(unfm, 0);

if (block != 0) {
reiserfs_prepare_for_journal(sb, p_s_bh, 1);
reiserfs_prepare_for_journal(sb, bh, 1);
put_block_num(unfm, 0, 0);
journal_mark_dirty (th, sb, p_s_bh);
journal_mark_dirty(th, sb, bh);
reiserfs_free_block(th, inode, block, 1);
}

Expand All @@ -1049,7 +1048,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
/* a trick. If the buffer has been logged, this will do nothing. If
** we've broken the loop without logging it, it will restore the
** buffer */
reiserfs_restore_prepared_buffer(sb, p_s_bh);
reiserfs_restore_prepared_buffer(sb, bh);
} while (need_re_search &&
search_for_position_by_key(sb, p_s_item_key, p_s_path) == POSITION_FOUND);
pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
Expand Down
Loading

0 comments on commit 570c11b

Please sign in to comment.