* [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled
@ 2024-04-20 7:50 Qu Wenruo
2024-04-22 16:04 ` Filipe Manana
2024-04-23 13:46 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-04-20 7:50 UTC (permalink / raw)
To: linux-btrfs
[BUG]
After kernel commit 86211eea8ae1 ("btrfs: qgroup: validate
btrfs_qgroup_inherit parameter"), user space tool snapper will fail to
create snapshot using its timeline feature.
[CAUSE]
It turns out that, if using timeline snapper would unconditionally pass
btrfs_qgroup_inherit parameter (assigning the new snapshot to qgroup 1/0)
for snapshot creation.
In that case, since qgroup is disabled there would be no qgroup 1/0, and
btrfs_qgroup_check_inherit() would return -ENOENT and fail the whole
snapshot creation.
[FIX]
Just skip the check if qgroup is not enabled.
This is to keep the older behavior for user space tools, as if the
kernel behavior changed for user space, it is a regression of kernel.
Thankfully snapper is also fixing the behavior by detecting if qgroup is
running in the first place, so the effect should not be that huge.
Link: https://github.com/openSUSE/snapper/issues/894
Fixes: 86211eea8ae1 ("btrfs: qgroup: validate btrfs_qgroup_inherit parameter")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/qgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 9aeb740388ab..2f55a89709b3 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3138,6 +3138,9 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
struct btrfs_qgroup_inherit *inherit,
size_t size)
{
+ /* Qgroup not enabled, ignore the inherit parameter. */
+ if (!btrfs_qgroup_enabled(fs_info))
+ return 0;
if (inherit->flags & ~BTRFS_QGROUP_INHERIT_FLAGS_SUPP)
return -EOPNOTSUPP;
if (size < sizeof(*inherit) || size > PAGE_SIZE)
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled
2024-04-20 7:50 [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled Qu Wenruo
@ 2024-04-22 16:04 ` Filipe Manana
2024-04-23 13:46 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2024-04-22 16:04 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Sat, Apr 20, 2024 at 8:52 AM Qu Wenruo <wqu@suse.com> wrote:
>
> [BUG]
> After kernel commit 86211eea8ae1 ("btrfs: qgroup: validate
> btrfs_qgroup_inherit parameter"), user space tool snapper will fail to
> create snapshot using its timeline feature.
>
> [CAUSE]
> It turns out that, if using timeline snapper would unconditionally pass
> btrfs_qgroup_inherit parameter (assigning the new snapshot to qgroup 1/0)
> for snapshot creation.
>
> In that case, since qgroup is disabled there would be no qgroup 1/0, and
> btrfs_qgroup_check_inherit() would return -ENOENT and fail the whole
> snapshot creation.
>
> [FIX]
> Just skip the check if qgroup is not enabled.
> This is to keep the older behavior for user space tools, as if the
> kernel behavior changed for user space, it is a regression of kernel.
>
> Thankfully snapper is also fixing the behavior by detecting if qgroup is
> running in the first place, so the effect should not be that huge.
>
> Link: https://github.com/openSUSE/snapper/issues/894
> Fixes: 86211eea8ae1 ("btrfs: qgroup: validate btrfs_qgroup_inherit parameter")
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/qgroup.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 9aeb740388ab..2f55a89709b3 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3138,6 +3138,9 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
> struct btrfs_qgroup_inherit *inherit,
> size_t size)
> {
> + /* Qgroup not enabled, ignore the inherit parameter. */
> + if (!btrfs_qgroup_enabled(fs_info))
Well, the comment is quite redundant as the expression is
self-explaining... I would leave it out.
Anyway, it looks good, thanks.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
> + return 0;
> if (inherit->flags & ~BTRFS_QGROUP_INHERIT_FLAGS_SUPP)
> return -EOPNOTSUPP;
> if (size < sizeof(*inherit) || size > PAGE_SIZE)
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled
2024-04-20 7:50 [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled Qu Wenruo
2024-04-22 16:04 ` Filipe Manana
@ 2024-04-23 13:46 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2024-04-23 13:46 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Sat, Apr 20, 2024 at 05:20:27PM +0930, Qu Wenruo wrote:
> [BUG]
> After kernel commit 86211eea8ae1 ("btrfs: qgroup: validate
> btrfs_qgroup_inherit parameter"), user space tool snapper will fail to
> create snapshot using its timeline feature.
>
> [CAUSE]
> It turns out that, if using timeline snapper would unconditionally pass
> btrfs_qgroup_inherit parameter (assigning the new snapshot to qgroup 1/0)
> for snapshot creation.
>
> In that case, since qgroup is disabled there would be no qgroup 1/0, and
> btrfs_qgroup_check_inherit() would return -ENOENT and fail the whole
> snapshot creation.
>
> [FIX]
> Just skip the check if qgroup is not enabled.
> This is to keep the older behavior for user space tools, as if the
> kernel behavior changed for user space, it is a regression of kernel.
>
> Thankfully snapper is also fixing the behavior by detecting if qgroup is
> running in the first place, so the effect should not be that huge.
>
> Link: https://github.com/openSUSE/snapper/issues/894
> Fixes: 86211eea8ae1 ("btrfs: qgroup: validate btrfs_qgroup_inherit parameter")
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/qgroup.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 9aeb740388ab..2f55a89709b3 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3138,6 +3138,9 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
> struct btrfs_qgroup_inherit *inherit,
> size_t size)
> {
> + /* Qgroup not enabled, ignore the inherit parameter. */
Agreed with Filipe that the comment is not necessary.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-23 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-20 7:50 [PATCH] btrfs: qgroup: do not check qgroup inherit if qgroup is disabled Qu Wenruo
2024-04-22 16:04 ` Filipe Manana
2024-04-23 13:46 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox