diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-05-11 11:33:21 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-05-11 11:33:21 -0400 |
commit | 098f59c2512426926722a96f82af127bd91fb5e4 (patch) | |
tree | d4f281ac0c6d61a8ee443b9fe8b49434e82618a2 /fs/btrfs/ctree.c | |
parent | 509659cde578d891445afd67d87121dd13e71596 (diff) |
Btrfs: patch queue: fix corruption when splitting large items
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 990d297a7a13..20e01f95ce6e 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -871,6 +871,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root | |||
871 | btrfs_set_node_blockptr(lower, slot, blocknr); | 871 | btrfs_set_node_blockptr(lower, slot, blocknr); |
872 | btrfs_set_header_nritems(&lower->header, nritems + 1); | 872 | btrfs_set_header_nritems(&lower->header, nritems + 1); |
873 | btrfs_mark_buffer_dirty(path->nodes[level]); | 873 | btrfs_mark_buffer_dirty(path->nodes[level]); |
874 | check_node(root, path, level); | ||
874 | return 0; | 875 | return 0; |
875 | } | 876 | } |
876 | 877 | ||
@@ -1101,6 +1102,8 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1101 | } else { | 1102 | } else { |
1102 | btrfs_block_release(root, right_buf); | 1103 | btrfs_block_release(root, right_buf); |
1103 | } | 1104 | } |
1105 | if (path->nodes[1]) | ||
1106 | check_node(root, path, 1); | ||
1104 | return 0; | 1107 | return 0; |
1105 | } | 1108 | } |
1106 | /* | 1109 | /* |
@@ -1216,6 +1219,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1216 | 1219 | ||
1217 | btrfs_mark_buffer_dirty(t); | 1220 | btrfs_mark_buffer_dirty(t); |
1218 | btrfs_mark_buffer_dirty(right_buf); | 1221 | btrfs_mark_buffer_dirty(right_buf); |
1222 | |||
1219 | wret = fixup_low_keys(trans, root, path, &right->items[0].key, 1); | 1223 | wret = fixup_low_keys(trans, root, path, &right->items[0].key, 1); |
1220 | if (wret) | 1224 | if (wret) |
1221 | ret = wret; | 1225 | ret = wret; |
@@ -1231,6 +1235,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1231 | path->slots[0] -= push_items; | 1235 | path->slots[0] -= push_items; |
1232 | } | 1236 | } |
1233 | BUG_ON(path->slots[0] < 0); | 1237 | BUG_ON(path->slots[0] < 0); |
1238 | if (path->nodes[1]) | ||
1239 | check_node(root, path, 1); | ||
1234 | return ret; | 1240 | return ret; |
1235 | } | 1241 | } |
1236 | 1242 | ||
@@ -1326,13 +1332,12 @@ static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1326 | wret = insert_ptr(trans, root, path, | 1332 | wret = insert_ptr(trans, root, path, |
1327 | &disk_key, | 1333 | &disk_key, |
1328 | bh_blocknr(right_buffer), | 1334 | bh_blocknr(right_buffer), |
1329 | path->slots[1] - 1, 1); | 1335 | path->slots[1], 1); |
1330 | if (wret) | 1336 | if (wret) |
1331 | ret = wret; | 1337 | ret = wret; |
1332 | btrfs_block_release(root, path->nodes[0]); | 1338 | btrfs_block_release(root, path->nodes[0]); |
1333 | path->nodes[0] = right_buffer; | 1339 | path->nodes[0] = right_buffer; |
1334 | path->slots[0] = 0; | 1340 | path->slots[0] = 0; |
1335 | path->slots[1] -= 1; | ||
1336 | if (path->slots[1] == 0) { | 1341 | if (path->slots[1] == 0) { |
1337 | wret = fixup_low_keys(trans, root, | 1342 | wret = fixup_low_keys(trans, root, |
1338 | path, &disk_key, 1); | 1343 | path, &disk_key, 1); |
@@ -1379,6 +1384,7 @@ static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1379 | } else | 1384 | } else |
1380 | btrfs_block_release(root, right_buffer); | 1385 | btrfs_block_release(root, right_buffer); |
1381 | BUG_ON(path->slots[0] < 0); | 1386 | BUG_ON(path->slots[0] < 0); |
1387 | check_node(root, path, 1); | ||
1382 | 1388 | ||
1383 | if (!double_split) | 1389 | if (!double_split) |
1384 | return ret; | 1390 | return ret; |