From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] Revert "f2fs: fix quota_sync failure due to f2fs_lock_op"
Date: Fri, 29 May 2020 15:34:26 -0700 [thread overview]
Message-ID: <20200529223426.GA249109@google.com> (raw)
In-Reply-To: <20200529092947.7890-1-yuchao0@huawei.com>
On 05/29, Chao Yu wrote:
> Under heavy fsstress, we may triggle panic while issuing discard,
> because __check_sit_bitmap() detects that discard command may earse
> valid data blocks, the root cause is as below race stack described,
> since we removed lock when flushing quota data, quota data writeback
> may race with write_checkpoint(), so that it causes inconsistency in
> between cached discard entry and segment bitmap.
>
> - f2fs_write_checkpoint
> - block_operations
> - set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH)
> - f2fs_flush_sit_entries
> - add_discard_addrs
> - __set_bit_le(i, (void *)de->discard_map);
> - f2fs_write_data_pages
> - f2fs_write_single_data_page
> : inode is quota one, cp_rwsem won't be locked
> - f2fs_do_write_data_page
> - f2fs_allocate_data_block
> - f2fs_wait_discard_bio
> : discard entry has not been added yet.
> - update_sit_entry
> - f2fs_clear_prefree_segments
> - f2fs_issue_discard
> : add discard entry
>
> This patch fixes this issue by reverting 435cbab95e39 ("f2fs: fix quota_sync
> failure due to f2fs_lock_op").
>
> Fixes: 435cbab95e39 ("f2fs: fix quota_sync failure due to f2fs_lock_op")
The previous patch fixes quota_sync gets EAGAIN all the time.
How about this? It seems this works for fsstress test.
---
fs/f2fs/segment.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index ebbadde6cbced..f67cffc38975e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3095,6 +3095,14 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
struct curseg_info *curseg = CURSEG_I(sbi, type);
bool put_pin_sem = false;
+ /*
+ * We need to wait for node_write to avoid block allocation during
+ * checkpoint. This can only happen to quota writes which can cause
+ * the below discard race condition.
+ */
+ if (IS_DATASEG(type))
+ down_write(&sbi->node_write);
+
if (type == CURSEG_COLD_DATA) {
/* GC during CURSEG_COLD_DATA_PINNED allocation */
if (down_read_trylock(&sbi->pin_sem)) {
@@ -3174,6 +3182,9 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
if (put_pin_sem)
up_read(&sbi->pin_sem);
+
+ if (IS_DATASEG(type))
+ up_write(&sbi->node_write);
}
static void update_device_state(struct f2fs_io_info *fio)
--
2.27.0.rc0.183.gde8f92d652-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2020-05-29 22:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 9:29 [f2fs-dev] [PATCH] Revert "f2fs: fix quota_sync failure due to f2fs_lock_op" Chao Yu
2020-05-29 22:34 ` Jaegeuk Kim [this message]
2020-05-30 1:30 ` Chao Yu
2020-05-30 1:49 ` Jaegeuk Kim
2020-05-30 2:02 ` Chao Yu
2020-05-30 15:18 ` 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=20200529223426.GA249109@google.com \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).