Commit 906f2770 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Greg Kroah-Hartman

reiserfs: fix corruption introduced by balance_leaf refactor

commit 27d0e5bc upstream.

Commits f1f007c3 (reiserfs: balance_leaf refactor, pull out
balance_leaf_insert_left) and cf22df18 (reiserfs: balance_leaf
refactor, pull out balance_leaf_paste_left) missed that the `body'
pointer was getting repositioned. Subsequent users of the pointer
would expect it to be repositioned, and as a result, parts of the
tree would get overwritten. The most common observed corruption
is indirect block pointers being overwritten.

Since the body value isn't actually used anymore in the called routines,
we can pass back the offset it should be shifted. We constify the body
and ih pointers in the balance_leaf as a mostly-free preventative measure.
Reported-and-tested-by: default avatarJeff Chua <jeff.chua.linux@gmail.com>
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 62de88e8
This diff is collapsed.
...@@ -899,8 +899,9 @@ void leaf_delete_items(struct buffer_info *cur_bi, int last_first, ...@@ -899,8 +899,9 @@ void leaf_delete_items(struct buffer_info *cur_bi, int last_first,
/* insert item into the leaf node in position before */ /* insert item into the leaf node in position before */
void leaf_insert_into_buf(struct buffer_info *bi, int before, void leaf_insert_into_buf(struct buffer_info *bi, int before,
struct item_head *inserted_item_ih, struct item_head * const inserted_item_ih,
const char *inserted_item_body, int zeros_number) const char * const inserted_item_body,
int zeros_number)
{ {
struct buffer_head *bh = bi->bi_bh; struct buffer_head *bh = bi->bi_bh;
int nr, free_space; int nr, free_space;
......
...@@ -3216,11 +3216,12 @@ int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes); ...@@ -3216,11 +3216,12 @@ int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes);
void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first, void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first,
int del_num, int del_bytes); int del_num, int del_bytes);
void leaf_insert_into_buf(struct buffer_info *bi, int before, void leaf_insert_into_buf(struct buffer_info *bi, int before,
struct item_head *inserted_item_ih, struct item_head * const inserted_item_ih,
const char *inserted_item_body, int zeros_number); const char * const inserted_item_body,
void leaf_paste_in_buffer(struct buffer_info *bi, int pasted_item_num,
int pos_in_item, int paste_size, const char *body,
int zeros_number); int zeros_number);
void leaf_paste_in_buffer(struct buffer_info *bi, int pasted_item_num,
int pos_in_item, int paste_size,
const char * const body, int zeros_number);
void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num, void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
int pos_in_item, int cut_size); int pos_in_item, int cut_size);
void leaf_paste_entries(struct buffer_info *bi, int item_num, int before, void leaf_paste_entries(struct buffer_info *bi, int item_num, int before,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment