Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
To: Qu Wenruo <wqu@suse.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: qgroup: Auto kick in rescan if qgroup tree is initialized without rescan initialized
Date: Thu, 26 Jul 2018 16:21:49 +0900	[thread overview]
Message-ID: <feefe6a2-c1ac-fa8e-85d0-e8c039eb6ebd@jp.fujitsu.com> (raw)
In-Reply-To: <20180726065900.8469-1-wqu@suse.com>

On 2018/07/26 15:59, Qu Wenruo wrote:
> Under certain case, btrfs/166 could cause power loss just after quota
> tree initialized but rescan not kicked in.
> 
> In this case, since flags of qgroup status item is just ON |
> INCONSISTENT, without RESCAN flag, rescan won't be kicked in in next
> mount.
> 
> Now kick in rescan automatically for such situation, so user won't need
> to do rescan manually.

How about setting all of BTRFS_QGROUP_STATUS_FLAG_ON/INCONSISTENT/RESCAN
at first place and calling qgroup_rescan_init(fs_info, 0, 0) 
(currently it is (fs_info, 0, 1)) in btrfs_quota_enable()?

I think with this approach, current btrfs-progs can work as expected too.

> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/qgroup.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index c25dc47210a3..e62598fc354f 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -392,6 +392,17 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
>  			fs_info->qgroup_flags = btrfs_qgroup_status_flags(l,
>  									  ptr);
>  			rescan_progress = btrfs_qgroup_status_rescan(l, ptr);
> +
> +			/*
> +			 * Qgroup is enabled but rescan hans't kicked in and
> +			 * power loss happened, kick rescan in
> +			 */
> +			if (rescan_progress == 0 &&
> +			    (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT |
> +			     BTRFS_QGROUP_STATUS_FLAG_ON) ==
> +			    fs_info->qgroup_flags)
> +				fs_info->qgroup_flags |=
> +					BTRFS_QGROUP_STATUS_FLAG_RESCAN;
>  			goto next1;
>  		}
>  
> 


  reply	other threads:[~2018-07-26  8:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26  6:59 [PATCH] btrfs: qgroup: Auto kick in rescan if qgroup tree is initialized without rescan initialized Qu Wenruo
2018-07-26  7:21 ` Misono Tomohiro [this message]
2018-07-26  7:45   ` Qu Wenruo
2018-07-26 12:31 ` 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=feefe6a2-c1ac-fa8e-85d0-e8c039eb6ebd@jp.fujitsu.com \
    --to=misono.tomohiro@jp.fujitsu.com \
    --cc=linux-btrfs@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