summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2014-04-23 16:00:53 +0200
committerJan Kara <jack@suse.cz>2014-05-07 19:01:39 +0200
commit8c480ea1940ffad74af3bb0db8885e413e6aee0a (patch)
treec96109910139445a26816e438a697964ab167e6b
parentreiserfs: balance_leaf refactor, pull out balance_leaf_new_nodes_paste (diff)
downloadlinux-8c480ea1940ffad74af3bb0db8885e413e6aee0a.tar.xz
linux-8c480ea1940ffad74af3bb0db8885e413e6aee0a.zip
reiserfs: balance_leaf refactor pull out balance_leaf_finish_node_insert
This patch factors out a new balance_leaf_finish_node_insert from the code in balance_leaf responsible for inserting new items into S[0] It has not been reformatted yet. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/reiserfs/do_balan.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
index db189cbfdaba..1c4b45993c79 100644
--- a/fs/reiserfs/do_balan.c
+++ b/fs/reiserfs/do_balan.c
@@ -962,6 +962,26 @@ static void balance_leaf_new_nodes_paste(struct tree_balance *tb,
}
+static void balance_leaf_finish_node_insert(struct tree_balance *tb,
+ struct item_head *ih,
+ const char *body)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct buffer_info bi;
+ buffer_info_init_tbS0(tb, &bi);
+ leaf_insert_into_buf(&bi, tb->item_pos, ih,
+ body, tb->zeroes_num);
+
+ /*
+ * If we insert the first key
+ * change the delimiting key
+ */
+ if (tb->item_pos == 0) {
+ if (tb->CFL[0]) /* can be 0 in reiserfsck */
+ replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
+ }
+}
+
/**
* balance_leaf - reiserfs tree balancing algorithm
* @tb: tree balance state
@@ -1136,15 +1156,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih,
switch (flag) {
case M_INSERT: /* insert item into S[0] */
- buffer_info_init_tbS0(tb, &bi);
- leaf_insert_into_buf(&bi, tb->item_pos, ih,
- body, tb->zeroes_num);
-
- /* If we insert the first key change the delimiting key */
- if (tb->item_pos == 0) {
- if (tb->CFL[0]) /* can be 0 in reiserfsck */
- replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
- }
+ balance_leaf_finish_node_insert(tb, ih, body);
break;
case M_PASTE:{ /* append item in S[0] */