History

nilfs2: fix missing block address termination in btree node shrinking

nilfs_btree_delete function does not terminate part of virtual block addresses when shrinking the last remaining child node into the root node. The missing address termination causes that dead btree node blocks persist and chip away free disk space. This fixes the leak bug on the btree node deletion.

Ryusuke Konishi committed 15 years ago

Commit d4099051 parent fe744fd1 file · +14 −7Browse files

Unified · Split

fs/nilfs2/btree.c+14−7
@@ -1346,6 +1346,11 @@ static void nilfs_btree_shrink(struct nilfs_bmap *btree, · 1345 unmodified lines
13461346 path[level].bp_bh = NULL;
13471347 }
13481348
1349+static void nilfs_btree_nop(struct nilfs_bmap *btree,
1350+ struct nilfs_btree_path *path,
1351+ int level, __u64 *keyp, __u64 *ptrp)
1352+{
1353+}
13491354
13501355 static int nilfs_btree_prepare_delete(struct nilfs_bmap *btree,
13511356 struct nilfs_btree_path *path,
@@ -1439,16 +1444,22 @@ static int nilfs_btree_prepare_delete(struct nilfs_bmap *btree, · 87 unmodified lines
14391444 NILFS_BTREE_ROOT_NCHILDREN_MAX) {
14401445 path[level].bp_op = nilfs_btree_shrink;
14411446 stats->bs_nblocks += 2;
1447+ level++;
1448+ path[level].bp_op = nilfs_btree_nop;
1449+ goto shrink_root_child;
14421450 } else {
14431451 path[level].bp_op = nilfs_btree_do_delete;
14441452 stats->bs_nblocks++;
1453+ goto out;
14451454 }
1446−
1447− goto out;
1448−
14491455 }
14501456 }
14511457
1458+ /* child of the root node is deleted */
1459+ path[level].bp_op = nilfs_btree_do_delete;
1460+ stats->bs_nblocks++;
1461+
1462+shrink_root_child:
14521463 node = nilfs_btree_get_root(btree);
14531464 path[level].bp_oldreq.bpr_ptr =
14541465 nilfs_btree_node_get_ptr(node, dindex,
@@ -1458,10 +1469,6 @@ static int nilfs_btree_prepare_delete(struct nilfs_bmap *btree, · 3 unmodified lines
14581469 if (ret < 0)
14591470 goto err_out_child_node;
14601471
1461− /* child of the root node is deleted */
1462− path[level].bp_op = nilfs_btree_do_delete;
1463− stats->bs_nblocks++;
1464−
14651472 /* success */
14661473 out:
14671474 *levelp = level;