Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Boris Burkov <boris@bur.io>, David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/5] btrfs: qgroup: warn about inconsistent qgroups when relation update fails
Date: Fri, 21 Jun 2024 08:04:20 +0930	[thread overview]
Message-ID: <61592e4b-62fe-49b4-8ac6-55ff28c3a08b@gmx.com> (raw)
In-Reply-To: <20240620212833.GB3251296@zen.localdomain>



在 2024/6/21 06:58, Boris Burkov 写道:
> On Wed, Jun 19, 2024 at 07:09:20PM +0200, David Sterba wrote:
>> Calling btrfs_handle_fs_error() after btrfs_run_qgroups() fails to
>> update the qgroup status is probably not necessary, this would turn the
>> filesystem to read-only. For the same reason aborting the transaction is
>> also not a good option.
>>
>> The state is left inconsistent and can be fixed by rescan, printing a
>> warning should be sufficient. Return code reflects the status of
>> adding/deleting the relation and if the transaction was ended properly.
>
> A few thoughts/questions about this:
>
> 1. Why do we even need to btrfs_run_qgroups() here? Won't we btrfs_run_qgroups
> in the transaction that actually commits the qgroup relation items? I'm
> guessing some qgroup lookup sees the not-committed items in a way users
> care about? Are we expecting such high-scale `qgroup assign` that we
> can't just commit this txn and make it simpler?

I agree with this.

I'm originally thinking some weird situation that one have called
btrfs_run_qgroups(), then we do relation update without
btrfs_run_qgroups(), in this case it may cause problems.

But since btrfs_run_qgroups() is really only called in committing
transaction and this is the only other location, I do not think it's
going to cause much problem.

So overall we should just remove the btrfs_run_qgroups() call and no
need to handle the error (even no need to commit tranasaction).

Thanks,
Qu

>
> 2. Is this really failing in cases where adding the relation items
> succeeds and then it all gets committed successfully? i.e., do you have
> a reproducer for this case?
>
> 3. If this is a realistic scenario, I'm worried about the squotas case,
> which doesn't have any rescan capability to fallback on. However, I
> don't see why my (1) above doesn't just save us anyway. If we commit the
> relation item, then we also commit the status/info items. And the txn
> commit run_qgroups is not allowed to fail.
>
> 4. Let's say that 1. is not strictly essential, and the txn commit is
> going to fix us. In that case, is it really accurate to say we are
> inconsistent any more than just during a transaction before we run
> qgroups? I suppose compared to the case where this succeeded, we are. I
> just have a weird feeling we are stretching the meaning of inconsistent.
> Though not in an egregious way or anything, as we are reporting a
> non-fatal error?
>
> Sorry for the slightly rambling review..
>
> Thanks,
> Boris
>
>>
>> Signed-off-by: David Sterba <dsterba@suse.com>
>> ---
>>   fs/btrfs/ioctl.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
>> index 31c4aea8b93a..f893a6b711c6 100644
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -3877,8 +3877,9 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
>>   	err = btrfs_run_qgroups(trans);
>>   	mutex_unlock(&fs_info->qgroup_ioctl_lock);
>>   	if (err < 0)
>> -		btrfs_handle_fs_error(fs_info, err,
>> -				      "failed to update qgroup status and info");
>> +		btrfs_warn(fs_info,
>> +			   "qgroup status update failed after %s relation, marked as inconsistent",
>> +			   sa->assign ? "adding" : "deleting");
>>   	err = btrfs_end_transaction(trans);
>>   	if (err && !ret)
>>   		ret = err;
>> --
>> 2.45.0
>>
>

  reply	other threads:[~2024-06-20 22:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 17:08 [PATCH 0/5] Error handling fixes David Sterba
2024-06-19 17:08 ` [PATCH 1/5] btrfs: abort transaction if we don't find extref in btrfs_del_inode_extref() David Sterba
2024-06-19 17:09 ` [PATCH 2/5] btrfs: only print error message when checking item size in print_extent_item() David Sterba
2024-06-19 17:09 ` [PATCH 3/5] btrfs: abort transaction on errors in btrfs_free_chunk() David Sterba
2024-06-19 17:09 ` [PATCH 4/5] btrfs: qgroup: preallocate memory before adding a relation David Sterba
2024-06-20  1:59   ` Qu Wenruo
2024-06-20 17:40     ` David Sterba
2024-06-20 17:46     ` [PATCH v2] " David Sterba
2024-06-20 22:22       ` Qu Wenruo
2024-06-19 17:09 ` [PATCH 5/5] btrfs: qgroup: warn about inconsistent qgroups when relation update fails David Sterba
2024-06-20 21:28   ` Boris Burkov
2024-06-20 22:34     ` Qu Wenruo [this message]
2024-06-19 23:21 ` [PATCH 0/5] Error handling fixes 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=61592e4b-62fe-49b4-8ac6-55ff28c3a08b@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=boris@bur.io \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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