Skip to content

Commit d662fad

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to set SBI_NEED_FSCK flag for inconsistent inode
If compressed inode has inconsistent fields on i_compress_algorithm, i_compr_blocks and i_log_cluster_size, we missed to set SBI_NEED_FSCK to notice fsck to repair the inode, fix it. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent f6322f3 commit d662fad

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/f2fs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
299299
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
300300
i_log_cluster_size)) {
301301
if (ri->i_compress_algorithm >= COMPRESS_MAX) {
302+
set_sbi_flag(sbi, SBI_NEED_FSCK);
302303
f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
303304
"compress algorithm: %u, run fsck to fix",
304305
__func__, inode->i_ino,
@@ -307,6 +308,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
307308
}
308309
if (le64_to_cpu(ri->i_compr_blocks) >
309310
SECTOR_TO_BLOCK(inode->i_blocks)) {
311+
set_sbi_flag(sbi, SBI_NEED_FSCK);
310312
f2fs_warn(sbi, "%s: inode (ino=%lx) has inconsistent "
311313
"i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix",
312314
__func__, inode->i_ino,
@@ -316,6 +318,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
316318
}
317319
if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
318320
ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) {
321+
set_sbi_flag(sbi, SBI_NEED_FSCK);
319322
f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported "
320323
"log cluster size: %u, run fsck to fix",
321324
__func__, inode->i_ino,

0 commit comments

Comments
 (0)