From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: qgroup: verify btrfs_qgroup_inherit parameter
Date: Mon, 4 Mar 2024 18:25:05 +0100 [thread overview]
Message-ID: <20240304172505.GL2604@suse.cz> (raw)
In-Reply-To: <19762dc9-2834-46fd-91ce-26a542356adb@gmx.com>
On Sat, Mar 02, 2024 at 06:51:58AM +1030, Qu Wenruo wrote:
> 在 2024/3/1 22:31, David Sterba 写道:
> > On Tue, Feb 27, 2024 at 01:45:35PM +1030, Qu Wenruo wrote:
> >> [BUG]
> >> Currently btrfs can create subvolume with an invalid qgroup inherit
> >> without triggering any error:
> >>
> >> # mkfs.btrfs -O quota -f $dev
> >> # mount $dev $mnt
> >> # btrfs subvolume create -i 2/0 $mnt/subv1
> >> # btrfs qgroup show -prce --sync $mnt
> >> Qgroupid Referenced Exclusive Path
> >> -------- ---------- --------- ----
> >> 0/5 16.00KiB 16.00KiB <toplevel>
> >> 0/256 16.00KiB 16.00KiB subv1
> >>
> >> [CAUSE]
> >> We only do a very basic size check for btrfs_qgroup_inherit structure,
> >> but never really verify if the values are correct.
> >>
> >> Thus in btrfs_qgroup_inherit() function, we have to skip non-existing
> >> qgroups, and never return any error.
> >>
> >> [FIX]
> >> Fix the behavior and introduce extra checks:
> >>
> >> - Introduce early check for btrfs_qgroup_inherit structure
> >> Not only the size, but also all the qgroup ids would be verifyed.
> >>
> >> And the timing is very early, so we can return error early.
> >> This early check is very important for snapshot creation, as snapshot
> >> is delayed to transaction commit.
> >>
> >> - Drop support for btrfs_qgroup_inherit::num_ref_copies and
> >> num_excl_copies
> >> Those two members are used to specify to copy refr/excl numbers from
> >> other qgroups.
> >> This would definitely mark qgroup inconsistent, and btrfs-progs has
> >> dropped the support for them for a long time.
> >> It's time to drop the support for kernel.
> >>
> >> - Verify the supported btrfs_qgroup_inherit::flags
> >> Just in case we want to add extra flags for btrfs_qgroup_inherit.
> >>
> >> Now above subvolume creation would fail with -ENOENT other than silently
> >> ignore the non-existing qgroup.
> >>
> >> CC: stable@vger.kernel.org
> >> Signed-off-by: Qu Wenruo <wqu@suse.com>
> >
> > Reviewed-by: David Sterba <dsterba@suse.com>
> >
> Just one thing to notice, this would cause certain test cases to fail,
> as previously any incorrect qgroup inherit would just be ignored, but
> now it would error out explicitly.
Ok, this is expected if we do fixes like that.
prev parent reply other threads:[~2024-03-04 17:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 3:15 [PATCH] btrfs: qgroup: verify btrfs_qgroup_inherit parameter Qu Wenruo
2024-03-01 12:01 ` David Sterba
2024-03-01 20:21 ` Qu Wenruo
2024-03-04 17:25 ` David Sterba [this message]
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=20240304172505.GL2604@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--cc=stable@vger.kernel.org \
--cc=wqu@suse.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