From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@gmail.com, Wang Yugui <wangyugui@e16-tech.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: 'ls /mnt/scratch/' freeze(deadlock?) when run xfstest(btrfs/232)
Date: Thu, 22 Apr 2021 07:43:42 +0800 [thread overview]
Message-ID: <e8886729-6f82-eca9-d752-0e81145794fe@gmx.com> (raw)
In-Reply-To: <9b4400ca-d0a3-621d-591c-dc377d0bed58@gmx.com>
[-- Attachment #1: Type: text/plain, Size: 2424 bytes --]
On 2021/4/22 上午7:19, Qu Wenruo wrote:
>
>
> On 2021/4/22 上午12:03, Filipe Manana wrote:
>> On Wed, Apr 21, 2021 at 4:57 PM Wang Yugui <wangyugui@e16-tech.com>
>> wrote:
>>>
>>> Hi,
>>>
>>>> That's the problem, qgroup flushing triggers writeback for an inode
>>>> for which we have a page dirtied and locked.
>>>> This should fix it: https://pastebin.com/raw/U9GUZiEf
>>>>
>>>> Try it out and I'll write a changelog later.
>>>> Thanks.
>>>
>>> we run xfstest on two server with this patch.
>>> one passed the tests.
>>> but one got a btrfs/232 error.
>>>
>>> btrfs/232 32s ... _check_btrfs_filesystem: filesystem on
>>> /dev/nvme0n1p1is inconsistent
>>> (see /usr/hpc-bio/xfstests/results//btrfs/232.full for details)
>>> ...
>>> [4/7] checking fs roots
>>> root 5 inode 337 errors 400, nbytes wrong
>>> ERROR: errors found in fs roots
>>
>> Ok, that's a different problem caused by something else.
>> It's possible to be due to the recent refactorings for preparation to
>> subpage block size.
>
> This error looks exactly what I have seen during subpage development.
> The subpage bug is caused by incorrect btrfs_invalidatepage() though,
> and not yet merged into misc-next anyway.
>
> I guess it's some error path not clearing extent states correctly, thus
> leaving the inode nbytes accounting wrong.
>
> BTW, the new @in_reclaim_context parameter for start_delalloc_inodes()
> is already in misc-next:
> commit 3d45f221ce627d13e2e6ef3274f06750c84a6542
> Author: Filipe Manana <fdmanana@suse.com>
> Date: Wed Dec 2 11:55:58 2020 +0000
>
> btrfs: fix deadlock when cloning inline extent and low on free
> metadata space
>
> We only need to make btrfs_start_delalloc_snapshot() to accept the new
> parameter and pass in_reclaim_context = true for qgroup.
Strangely, on my subpage branch, with new @in_reclaim_context parameter
added to btrfs_start_delalloc_snapshot(), I can't reproduce the nbytes
mismatch error in 32 runs loop.
I guess one of the refactor around ordered extents and invalidatepage
may fix the problem by accident.
Mind to test my subpage branch
(https://github.com/adam900710/linux/tree/subpage) with the attached diff?
Thanks,
Qu
>
> Thanks,
> Qu
>>
>> Will try to look into that later.
>>
>> Thanks.
>>
>>> ...
>>>
>>> Best Regards
>>> Wang Yugui (wangyugui@e16-tech.com)
>>> 2021/04/21
>>>
>>
>>
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 3037 bytes --]
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0a66b57f40f1..7fa747f81d5a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3115,7 +3115,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, u64 new_size,
u32 min_type);
-int btrfs_start_delalloc_snapshot(struct btrfs_root *root);
+int btrfs_start_delalloc_snapshot(struct btrfs_root *root,
+ bool in_reclaim_context);
int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
bool in_reclaim_context);
int btrfs_set_extent_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 401820c7e381..91c1162893fb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9730,7 +9730,8 @@ static int start_delalloc_inodes(struct btrfs_root *root,
return ret;
}
-int btrfs_start_delalloc_snapshot(struct btrfs_root *root)
+int btrfs_start_delalloc_snapshot(struct btrfs_root *root,
+ bool in_reclaim_context)
{
struct writeback_control wbc = {
.nr_to_write = LONG_MAX,
@@ -9743,7 +9744,7 @@ int btrfs_start_delalloc_snapshot(struct btrfs_root *root)
if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
return -EROFS;
- return start_delalloc_inodes(root, &wbc, true, false);
+ return start_delalloc_inodes(root, &wbc, true, in_reclaim_context);
}
int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index be174dc9bcd0..9b2b268eb088 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1039,7 +1039,7 @@ static noinline int btrfs_mksnapshot(const struct path *parent,
*/
btrfs_drew_read_lock(&root->snapshot_lock);
- ret = btrfs_start_delalloc_snapshot(root);
+ ret = btrfs_start_delalloc_snapshot(root, false);
if (ret)
goto out;
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 2319c923c9e6..366a6a289796 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3562,7 +3562,7 @@ static int try_flush_qgroup(struct btrfs_root *root)
return 0;
}
- ret = btrfs_start_delalloc_snapshot(root);
+ ret = btrfs_start_delalloc_snapshot(root, true);
if (ret < 0)
goto out;
btrfs_wait_ordered_extents(root, U64_MAX, 0, (u64)-1);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 55741adf9071..bd69db72acc5 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -7170,7 +7170,7 @@ static int flush_delalloc_roots(struct send_ctx *sctx)
int i;
if (root) {
- ret = btrfs_start_delalloc_snapshot(root);
+ ret = btrfs_start_delalloc_snapshot(root, false);
if (ret)
return ret;
btrfs_wait_ordered_extents(root, U64_MAX, 0, U64_MAX);
@@ -7178,7 +7178,7 @@ static int flush_delalloc_roots(struct send_ctx *sctx)
for (i = 0; i < sctx->clone_roots_cnt; i++) {
root = sctx->clone_roots[i].root;
- ret = btrfs_start_delalloc_snapshot(root);
+ ret = btrfs_start_delalloc_snapshot(root, false);
if (ret)
return ret;
btrfs_wait_ordered_extents(root, U64_MAX, 0, U64_MAX);
next prev parent reply other threads:[~2021-04-21 23:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-21 0:31 'ls /mnt/scratch/' freeze(deadlock?) when run xfstest(btrfs/232) Wang Yugui
2021-04-21 12:17 ` Wang Yugui
2021-04-21 13:29 ` Filipe Manana
2021-04-21 15:57 ` Wang Yugui
2021-04-21 16:03 ` Filipe Manana
2021-04-21 23:19 ` Qu Wenruo
2021-04-21 23:43 ` Qu Wenruo [this message]
2021-04-22 0:32 ` Wang Yugui
2021-04-22 0:57 ` Qu Wenruo
2021-04-22 1:25 ` Wang Yugui
2021-04-22 4:16 ` Wang Yugui
2021-04-22 11:06 ` Filipe Manana
2021-04-22 10:59 ` Filipe Manana
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=e8886729-6f82-eca9-d752-0e81145794fe@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=fdmanana@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangyugui@e16-tech.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).