diff options
author | Chao Yu <chao@kernel.org> | 2023-05-28 09:47:12 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-06-12 22:04:09 +0200 |
commit | 20872584b8c0b006c007da9588a272c9e28d2e18 (patch) | |
tree | f8445856fa9f4d6fa628aa440a409d5baef54bd9 /fs/f2fs/super.c | |
parent | f2fs: Detect looped node chain efficiently (diff) | |
download | linux-20872584b8c0b006c007da9588a272c9e28d2e18.tar.xz linux-20872584b8c0b006c007da9588a272c9e28d2e18.zip |
f2fs: fix to drop all dirty meta/node pages during umount()
For cp error case, there will be dirty meta/node pages remained after
f2fs_write_checkpoint() in f2fs_put_super(), drop them explicitly, and
do sanity check on reference count of dirty pages and inflight IOs.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r-- | fs/f2fs/super.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ee390c398e1c..2936bc870f5c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1571,6 +1571,7 @@ static void f2fs_put_super(struct super_block *sb) { struct f2fs_sb_info *sbi = F2FS_SB(sb); int i; + int err = 0; bool done; /* unregister procfs/sysfs entries in advance to avoid race case */ @@ -1597,7 +1598,7 @@ static void f2fs_put_super(struct super_block *sb) struct cp_control cpc = { .reason = CP_UMOUNT, }; - f2fs_write_checkpoint(sbi, &cpc); + err = f2fs_write_checkpoint(sbi, &cpc); } /* be sure to wait for any on-going discard commands */ @@ -1606,7 +1607,7 @@ static void f2fs_put_super(struct super_block *sb) struct cp_control cpc = { .reason = CP_UMOUNT | CP_TRIMMED, }; - f2fs_write_checkpoint(sbi, &cpc); + err = f2fs_write_checkpoint(sbi, &cpc); } /* @@ -1623,6 +1624,19 @@ static void f2fs_put_super(struct super_block *sb) f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA); + if (err) { + truncate_inode_pages_final(NODE_MAPPING(sbi)); + truncate_inode_pages_final(META_MAPPING(sbi)); + } + + for (i = 0; i < NR_COUNT_TYPE; i++) { + if (!get_pages(sbi, i)) + continue; + f2fs_err(sbi, "detect filesystem reference count leak during " + "umount, type: %d, count: %lld", i, get_pages(sbi, i)); + f2fs_bug_on(sbi, 1); + } + f2fs_bug_on(sbi, sbi->fsync_node_num); f2fs_destroy_compress_inode(sbi); |