Skip to content

Commit 63584d7

Browse files
committed
hfsplus: fix logic of alloc/free b-tree node
The hfs_bmap_alloc() and hfs_bmap_free() modify the b-tree's counters and nodes' bitmap of b-tree. However, hfs_btree_write() synchronizes the state of in-core b-tree's counters and node's bitmap with b-tree's descriptor in header node. Postponing this synchronization could result in inconsistent state of file system volume. This patch adds calling of hfs_btree_write() in hfs_bmap_alloc() and hfs_bmap_free() methods. cc: John Paul Adrian Glaubitz <[email protected]> cc: Yangtao Li <[email protected]> cc: [email protected] Signed-off-by: Viacheslav Dubeyko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Viacheslav Dubeyko <[email protected]>
1 parent cd3901f commit 63584d7

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/hfsplus/btree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
564564
set_page_dirty(page);
565565
kunmap_local(data);
566566
tree->free_nodes--;
567+
hfs_btree_write(tree);
567568
mark_inode_dirty(tree->inode);
568569
hfs_bnode_put(node);
569570
return hfs_bnode_create(tree,
@@ -585,6 +586,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
585586
if (!nidx) {
586587
hfs_dbg("create new bmap node\n");
587588
next_node = hfs_bmap_new_bmap(node, idx);
589+
hfs_btree_write(tree);
588590
} else
589591
next_node = hfs_bnode_find(tree, nidx);
590592
hfs_bnode_put(node);
@@ -655,6 +657,7 @@ void hfs_bmap_free(struct hfs_bnode *node)
655657
nidx, node->type);
656658
} else {
657659
tree->free_nodes++;
660+
hfs_btree_write(tree);
658661
mark_inode_dirty(tree->inode);
659662
}
660663

0 commit comments

Comments
 (0)