From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Edward Adam Davis <eadavis@qq.com>,
syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com
Cc: boris@bur.io, clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] btrfs: fix warning in create_pending_snapshot
Date: Sat, 11 Nov 2023 17:24:42 +1030 [thread overview]
Message-ID: <8800d890-e16c-4388-97c6-e55fd3ca7515@gmx.com> (raw)
In-Reply-To: <tencent_DB6BA6C1B369A367C96C83A36457D7735705@qq.com>
On 2023/11/11 15:36, Edward Adam Davis wrote:
> The create_snapshot will use the objectid that already exists in the qgroup_tree
> tree, so when calculating the free_ojectid, it is added to determine whether it
> exists in the qgroup_tree tree.
>
> Reported-and-tested-by: syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com
> Fixes: 6ed05643ddb1 ("btrfs: create qgroup earlier in snapshot creation")
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> fs/btrfs/disk-io.c | 3 ++-
> fs/btrfs/qgroup.c | 2 +-
> fs/btrfs/qgroup.h | 2 ++
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 401ea09ae4b8..97050a3edc32 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -4931,7 +4931,8 @@ int btrfs_get_free_objectid(struct btrfs_root *root, u64 *objectid)
> goto out;
> }
>
> - *objectid = root->free_objectid++;
> + while (find_qgroup_rb(root->fs_info, root->free_objectid++));
I don't think this is correct.
Firstly you didn't take qgroup_ioctl_lock.
Secondly, please explain why you believe the free objectid of a
subvolume is related to the qgroup id?
For any one who really wants to fix the syzbot bug, please explain the
bug clearly before doing any fix.
If you can not explain the bug clearly, then you're doing it wrong.
Thanks,
Qu
> + *objectid = root->free_objectid;
> ret = 0;
> out:
> mutex_unlock(&root->objectid_mutex);
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index edb84cc03237..3705e7d57057 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -171,7 +171,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
> static void qgroup_rescan_zero_tracking(struct btrfs_fs_info *fs_info);
>
> /* must be called with qgroup_ioctl_lock held */
> -static struct btrfs_qgroup *find_qgroup_rb(struct btrfs_fs_info *fs_info,
> +struct btrfs_qgroup *find_qgroup_rb(struct btrfs_fs_info *fs_info,
> u64 qgroupid)
> {
> struct rb_node *n = fs_info->qgroup_tree.rb_node;
> diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
> index 855a4f978761..96c6aa31ca91 100644
> --- a/fs/btrfs/qgroup.h
> +++ b/fs/btrfs/qgroup.h
> @@ -425,4 +425,6 @@ bool btrfs_check_quota_leak(struct btrfs_fs_info *fs_info);
> int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
> struct btrfs_squota_delta *delta);
>
> +struct btrfs_qgroup *find_qgroup_rb(struct btrfs_fs_info *fs_info,
> + u64 qgroupid);
> #endif
next prev parent reply other threads:[~2023-11-11 6:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 17:16 [syzbot] [btrfs?] WARNING in create_pending_snapshot syzbot
2023-11-10 11:48 ` [PATCH] btrfs: fix warning " Lizhi Xu
2023-11-10 20:36 ` Qu Wenruo
2023-11-11 5:06 ` Edward Adam Davis
2023-11-11 6:20 ` Matthew Wilcox
2023-11-11 8:13 ` [PATCH] test 305230142ae0 Edward Adam Davis
2023-11-11 20:48 ` Qu Wenruo
2023-11-11 6:54 ` Qu Wenruo [this message]
2023-11-12 4:48 ` [PATCH V2] btrfs: fix warning in create_pending_snapshot Edward Adam Davis
2023-11-12 7:35 ` Qu Wenruo
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=8800d890-e16c-4388-97c6-e55fd3ca7515@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=boris@bur.io \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=eadavis@qq.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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