[PATCH] f2fs: avoid SSA corruption when replacing block addresses
From: Jaegeuk Kim
Date: Tue Oct 06 2015 - 18:41:58 EST
If block addresses are pointed by the previous checkpoint, we should not update
the SSA when replacing block addresses by f2fs_collapse_range.
This patch allocates a new block address if there is an exising block address.
Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
---
fs/f2fs/segment.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 1d86a35..3c546eb 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1391,8 +1391,20 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
{
struct f2fs_summary sum;
+ /*
+ * we should not use the existing address to avoid SSA
+ * corruption.
+ */
set_summary(&sum, dn->nid, dn->ofs_in_node, version);
+ if (recover_curseg && old_addr != NULL_ADDR && old_addr != NEW_ADDR) {
+ allocate_data_block(sbi, NULL, dn->data_blkaddr,
+ &dn->data_blkaddr, &sum, CURSEG_WARM_DATA);
+ set_data_blkaddr(dn);
+ f2fs_update_extent_cache(dn);
+ old_addr = dn->data_blkaddr;
+ }
+
__f2fs_replace_block(sbi, &sum, old_addr, new_addr, recover_curseg);
dn->data_blkaddr = new_addr;
--
2.1.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/