From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 7/7] resize.f2fs: fill zeros for expanded ssa area
Date: Wed, 2 Nov 2016 22:28:46 -0700 [thread overview]
Message-ID: <20161103052846.72244-7-jaegeuk@kernel.org> (raw)
In-Reply-To: <20161103052846.72244-1-jaegeuk@kernel.org>
This will avoid wrong behavior after expanding volume.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/resize.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/fsck/resize.c b/fsck/resize.c
index 4813de7..7691524 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -206,24 +206,37 @@ static void migrate_ssa(struct f2fs_sb_info *sbi,
struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
block_t old_sum_blkaddr = get_sb(ssa_blkaddr);
block_t new_sum_blkaddr = get_newsb(ssa_blkaddr);
- unsigned int segno;
+ block_t end_sum_blkaddr = get_newsb(main_blkaddr);
+ block_t blkaddr;
+ void *zero_block = calloc(BLOCK_SZ, 1);
+
+ ASSERT(zero_block);
if (offset && new_sum_blkaddr < old_sum_blkaddr + offset) {
- segno = offset;
- while (segno != TOTAL_SEGS(sbi)) {
- move_ssa(sbi, segno, new_sum_blkaddr + segno - offset);
- segno++;
+ blkaddr = new_sum_blkaddr;
+ while (blkaddr < end_sum_blkaddr) {
+ if (blkaddr - new_sum_blkaddr < TOTAL_SEGS(sbi))
+ move_ssa(sbi, offset, blkaddr);
+ else
+ dev_write_block(zero_block, blkaddr);
+ offset++;
+ blkaddr++;
}
} else {
- segno = TOTAL_SEGS(sbi) - 1;
- while (segno != offset - 1) {
- move_ssa(sbi, segno, new_sum_blkaddr + segno - offset);
- segno--;
+ blkaddr = end_sum_blkaddr - 1;
+ offset = TOTAL_SEGS(sbi) - 1;
+ while (blkaddr >= new_sum_blkaddr) {
+ if (blkaddr >= TOTAL_SEGS(sbi) + new_sum_blkaddr)
+ dev_write_block(zero_block, blkaddr);
+ else
+ move_ssa(sbi, offset--, blkaddr);
+ blkaddr--;
}
}
DBG(0, "Info: Done to migrate SSA blocks: sum_blkaddr = 0x%x -> 0x%x\n",
old_sum_blkaddr, new_sum_blkaddr);
+ free(zero_block);
}
static int shrink_nats(struct f2fs_sb_info *sbi,
--
2.8.3
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
prev parent reply other threads:[~2016-11-03 5:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 5:28 [PATCH 1/7] defrag.f2fs: return error for no space case Jaegeuk Kim
2016-11-03 5:28 ` [PATCH 2/7] resize.f2fs: fix wrong end_blkaddr Jaegeuk Kim
2016-11-03 5:28 ` [PATCH 3/7] f2fs-tools: fix end block addres when finding free block Jaegeuk Kim
2016-11-03 5:28 ` [PATCH 4/7] resize.f2fs: get latest free segments Jaegeuk Kim
2016-11-03 6:53 ` heyunlei
2016-11-03 17:26 ` Jaegeuk Kim
2016-11-03 17:36 ` Jaegeuk Kim
2016-11-03 5:28 ` [PATCH 5/7] sload.f2fs: not support to find or add files in inline_dir directory Jaegeuk Kim
2016-11-03 5:28 ` [PATCH 6/7] f2fs-tools: determine cp_addr by sbi->cur_cp Jaegeuk Kim
2016-11-03 5:28 ` Jaegeuk Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161103052846.72244-7-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.