f2fs: fix to tag gcing flag on page during block migration
authorChao Yu <chao@kernel.org>
Sun, 10 Dec 2023 11:35:42 +0000 (19:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:28 +0000 (20:14 +0000)
[ Upstream commit 4961acdd65c956e97c1a000c82d91a8c1cdbe44b ]

It needs to add missing gcing flag on page during block migration,
in order to garantee migrated data be persisted during checkpoint,
otherwise out-of-order persistency between data and node may cause
data corruption after SPOR.

Similar issue was fixed by commit 2d1fe8a86bf5 ("f2fs: fix to tag
gcing flag on page during file defragment").

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/compress.c
fs/f2fs/file.c

index 7514661..372616c 100644 (file)
@@ -1029,8 +1029,10 @@ static void set_cluster_dirty(struct compress_ctx *cc)
        int i;
 
        for (i = 0; i < cc->cluster_size; i++)
-               if (cc->rpages[i])
+               if (cc->rpages[i]) {
                        set_page_dirty(cc->rpages[i]);
+                       set_page_private_gcing(cc->rpages[i]);
+               }
 }
 
 static int prepare_compress_overwrite(struct compress_ctx *cc,
index a631d70..dcf2d92 100644 (file)
@@ -1317,6 +1317,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
                        }
                        memcpy_page(pdst, 0, psrc, 0, PAGE_SIZE);
                        set_page_dirty(pdst);
+                       set_page_private_gcing(pdst);
                        f2fs_put_page(pdst, 1);
                        f2fs_put_page(psrc, 1);
 
@@ -4059,6 +4060,7 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len)
                f2fs_bug_on(F2FS_I_SB(inode), !page);
 
                set_page_dirty(page);
+               set_page_private_gcing(page);
                f2fs_put_page(page, 1);
                f2fs_put_page(page, 0);
        }