All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yunlong Song <yunlong.song@huawei.com>
To: <jaegeuk@kernel.org>, <chao@kernel.org>, <yuchao0@huawei.com>,
	<yunlong.song@icloud.com>, <yunlong.song@huawei.com>
Cc: <miaoxie@huawei.com>, <bintian.wang@huawei.com>,
	<linux-fsdevel@vger.kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v2] f2fs: update dirty status for CURSEG as well
Date: Fri, 13 Oct 2017 21:21:37 +0800	[thread overview]
Message-ID: <1507900897-156286-1-git-send-email-yunlong.song@huawei.com> (raw)
In-Reply-To: <1507728318-113117-1-git-send-email-yunlong.song@huawei.com>

Without this patch, it will cause all the free segments using up in some
corner case. For example, there are 100 segments, and 20 of them are
reserved for ovp. If 79 segments are full of data, segment 80 becomes
CURSEG segment, write 512 blocks and then delete 511 blocks. Since it is
CURSEG segment, the __locate_dirty_segment will not update its dirty
status. Then the dirty_segments(sbi) is 0, f2fs_gc will fail to
get_victim, and f2fs_balance_fs will fail to trigger gc action. After
f2fs_balance_fs returns, f2fs can continue to write data to segment 81.
Again, segment 81 becomes CURSEG segment, write 512 blocks and delete
511 blocks, the dirty_segments(sbi) is 0 and f2fs_gc fail again. This
can finally use up all the free segments and cause panic.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/segment.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index bfbcff8..0fce076 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -687,7 +687,7 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
 	struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 
 	/* need not be added */
-	if (IS_CURSEG(sbi, segno))
+	if (IS_CURSEG(sbi, segno) && dirty_type == PRE)
 		return;
 
 	if (!test_and_set_bit(segno, dirty_i->dirty_segmap[dirty_type]))
@@ -737,7 +737,7 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
 	struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 	unsigned short valid_blocks;
 
-	if (segno == NULL_SEGNO || IS_CURSEG(sbi, segno))
+	if (segno == NULL_SEGNO)
 		return;
 
 	mutex_lock(&dirty_i->seglist_lock);
-- 
1.8.5.2

WARNING: multiple messages have this Message-ID (diff)
From: Yunlong Song <yunlong.song@huawei.com>
To: jaegeuk@kernel.org, chao@kernel.org, yuchao0@huawei.com,
	yunlong.song@icloud.com, yunlong.song@huawei.com
Cc: miaoxie@huawei.com, bintian.wang@huawei.com,
	linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2] f2fs: update dirty status for CURSEG as well
Date: Fri, 13 Oct 2017 21:21:37 +0800	[thread overview]
Message-ID: <1507900897-156286-1-git-send-email-yunlong.song@huawei.com> (raw)
In-Reply-To: <1507728318-113117-1-git-send-email-yunlong.song@huawei.com>

Without this patch, it will cause all the free segments using up in some
corner case. For example, there are 100 segments, and 20 of them are
reserved for ovp. If 79 segments are full of data, segment 80 becomes
CURSEG segment, write 512 blocks and then delete 511 blocks. Since it is
CURSEG segment, the __locate_dirty_segment will not update its dirty
status. Then the dirty_segments(sbi) is 0, f2fs_gc will fail to
get_victim, and f2fs_balance_fs will fail to trigger gc action. After
f2fs_balance_fs returns, f2fs can continue to write data to segment 81.
Again, segment 81 becomes CURSEG segment, write 512 blocks and delete
511 blocks, the dirty_segments(sbi) is 0 and f2fs_gc fail again. This
can finally use up all the free segments and cause panic.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/segment.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index bfbcff8..0fce076 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -687,7 +687,7 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
 	struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 
 	/* need not be added */
-	if (IS_CURSEG(sbi, segno))
+	if (IS_CURSEG(sbi, segno) && dirty_type == PRE)
 		return;
 
 	if (!test_and_set_bit(segno, dirty_i->dirty_segmap[dirty_type]))
@@ -737,7 +737,7 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
 	struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
 	unsigned short valid_blocks;
 
-	if (segno == NULL_SEGNO || IS_CURSEG(sbi, segno))
+	if (segno == NULL_SEGNO)
 		return;
 
 	mutex_lock(&dirty_i->seglist_lock);
-- 
1.8.5.2

  parent reply	other threads:[~2017-10-13 13:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 13:25 [PATCH] f2fs: update dirty status for CURSEG as well Yunlong Song
2017-10-11 13:25 ` Yunlong Song
2017-10-13 11:08 ` [f2fs-dev] " Chao Yu
2017-10-13 11:15   ` Yunlong Song
2017-10-13 11:15     ` Yunlong Song
2017-10-13 13:21 ` Yunlong Song [this message]
2017-10-13 13:21   ` [PATCH v2] " Yunlong Song
2017-10-14  0:14   ` [f2fs-dev] " Chao Yu
2017-10-14  0:14     ` Chao Yu
2017-10-14 12:53     ` [f2fs-dev] " Yunlong Song
2017-10-14 12:53       ` Yunlong Song
2017-10-16  3:43       ` Chao Yu
2017-10-16  3:43         ` Chao Yu
2017-10-28 12:02         ` [f2fs-dev] " Chao Yu
2017-10-28 15:58           ` Yunlong Song
2017-10-28 15:58             ` Yunlong Song
2017-10-29  1:06             ` [f2fs-dev] " Chao Yu
2017-10-29  1:06               ` Chao Yu

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=1507900897-156286-1-git-send-email-yunlong.song@huawei.com \
    --to=yunlong.song@huawei.com \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=yuchao0@huawei.com \
    --cc=yunlong.song@icloud.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.