From: Junling Zheng <zhengjunling@huawei.com>
To: jaegeuk@kernel.org, yuchao0@huawei.com
Cc: miaoxie@huawei.com, linux-f2fs-devel@lists.sourceforge.net
Subject: [RFC PATCH] f2fs-tools: fix blocks allocation direction inside segment
Date: Tue, 8 May 2018 22:16:59 +0800 [thread overview]
Message-ID: <20180508141659.118390-1-zhengjunling@huawei.com> (raw)
This fixes the block allocation direction from left to right inside
one segment despite of the direction of segment allocation.
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
---
fsck/mount.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fsck/mount.c b/fsck/mount.c
index 1396a2e..38d2aa2 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1921,13 +1921,13 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
if (se->valid_blocks == sbi->blocks_per_seg ||
IS_CUR_SEGNO(sbi, segno, type)) {
- *to = left ? START_BLOCK(sbi, segno) - 1:
+ *to = left ? START_BLOCK(sbi, segno - 1) :
START_BLOCK(sbi, segno + 1);
continue;
}
if (se->valid_blocks == 0 && not_enough) {
- *to = left ? START_BLOCK(sbi, segno) - 1:
+ *to = left ? START_BLOCK(sbi, segno - 1) :
START_BLOCK(sbi, segno + 1);
continue;
}
@@ -1949,7 +1949,10 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
!f2fs_test_bit(offset, (const char *)se->cur_valid_map))
return 0;
- *to = left ? *to - 1: *to + 1;
+ if (!(OFFSET_IN_SEG(sbi, *to + 1)) && left)
+ *to = START_BLOCK(sbi, segno - 1);
+ else
+ *to = *to + 1;
}
return -1;
}
--
2.16.2
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next reply other threads:[~2018-05-08 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 14:16 Junling Zheng [this message]
2018-05-14 8:09 ` [RFC PATCH] f2fs-tools: fix blocks allocation direction inside segment Chao Yu
2018-05-18 0:58 ` Jaegeuk Kim
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=20180508141659.118390-1-zhengjunling@huawei.com \
--to=zhengjunling@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=miaoxie@huawei.com \
--cc=yuchao0@huawei.com \
/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.