fs: ext2: Fix removing indirect blocks
This commit fixes removing indirect blocks (marking them as 0) in the inode structure. Previous version of the code was removing the top-level blocks only when the first removed block was one of the first 12 direct blocks. However, when the first removed block is the first block in the referenced block list, its parent (indirect block) should also be removed. Signed-off-by: Franciszek Pindel <fpindel@antmicro.com>
This commit is contained in:
parent
5e4bbd5c7c
commit
8cc2d90123
|
@ -669,9 +669,11 @@ int64_t ext2_inode_remove_blocks(struct ext2_inode *inode, uint32_t first)
|
||||||
|
|
||||||
max_lvl = get_level_offsets(inode->i_fs, first, offsets);
|
max_lvl = get_level_offsets(inode->i_fs, first, offsets);
|
||||||
|
|
||||||
if (all_zero(offsets, max_lvl)) {
|
if (all_zero(&offsets[1], max_lvl)) {
|
||||||
/* We remove also the first block because all blocks referenced from it will be
|
/* The first block to remove is either:
|
||||||
* deleted.
|
* - one of the first 12 blocks in the indode
|
||||||
|
* - the first referenced block in the indirect block list;
|
||||||
|
* we remove also the indirect block
|
||||||
*/
|
*/
|
||||||
start = offsets[0];
|
start = offsets[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue