From: Jan Schmidt <list.btrfs@jan-o-sch.net>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org,
dsterba@suse.cz, Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Subject: Re: [PATCH v3 2/3] Btrfs: rescan for qgroups
Date: Tue, 23 Apr 2013 19:33:32 +0200 [thread overview]
Message-ID: <5176C5EC.5020209@jan-o-sch.net> (raw)
In-Reply-To: <28CF59DE-A74D-4CC4-BBA1-FCD0503EE7BD@gmail.com>
On Tue, April 23, 2013 at 16:54 (+0200), Wang Shilong wrote:
>
> Hello Jan,
>
>>
>> +static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
>> +{
>> + struct qgroup_rescan *qscan = container_of(work, struct qgroup_rescan,
>> + work);
>> + struct btrfs_path *path;
>> + struct btrfs_trans_handle *trans = NULL;
>> + struct btrfs_fs_info *fs_info = qscan->fs_info;
>> + struct ulist *tmp = NULL;
>> + struct extent_buffer *scratch_leaf = NULL;
>> + int err = -ENOMEM;
>> +
>> + path = btrfs_alloc_path();
>> + if (!path)
>> + goto out;
>> + tmp = ulist_alloc(GFP_NOFS);
>> + if (!tmp)
>> + goto out;
>> + scratch_leaf = kmalloc(sizeof(*scratch_leaf), GFP_NOFS);
>> + if (!scratch_leaf)
>> + goto out;
>> +
>> + err = 0;
>> + while (!err) {
>> + trans = btrfs_start_transaction(fs_info->fs_root, 0);
>> + if (IS_ERR(trans)) {
>> + err = PTR_ERR(trans);
>> + break;
>> + }
>> + if (!fs_info->quota_enabled) {
>> + err = EINTR;'
> Why not -EINTR?
Makes sense, will change that.
>> + } else {
>> + err = qgroup_rescan_leaf(qscan, path, trans,
>> + tmp, scratch_leaf);
>> + }
>> + if (err > 0)
>> + btrfs_commit_transaction(trans, fs_info->fs_root);
>> + else
>> + btrfs_end_transaction(trans, fs_info->fs_root);
>> + }
>> +
>> +out:
>> + kfree(scratch_leaf);
>> + ulist_free(tmp);
>> + btrfs_free_path(path);
>> + kfree(qscan);
>> +
>> + mutex_lock(&fs_info->qgroup_rescan_lock);
>> + fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN;
>> +
>> + if (err == 2 &&
>> + fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT) {
>> + fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
>> + } else if (err < 0) {
>
> It -EINTR happens, quota has been disabled, i don't think we should set INCONSISTENT flag…
Debatable. Quota information is in fact inconsistent on disk, and only because
we can conclude that also from the fact that it is currently disabled, it
doesn't hurt to set that flag. In fact, whenever quota is enabled, we're setting
the flag, too:
802 int btrfs_quota_enable(struct btrfs_trans_handle *trans,
803 struct btrfs_fs_info *fs_info)
...
852 fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON |
853 BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
So I don't think it's worth another comparison here.
Thanks,
-Jan
> Thanks,
> Wang
>
>> + fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
>> + }
>> + mutex_unlock(&fs_info->qgroup_rescan_lock);
>> +
>> + if (err >= 0) {
>> + pr_info("btrfs: qgroup scan completed%s\n",
>> + err == 2 ? " (inconsistency flag cleared)" : "");
>> + } else {
>> + pr_err("btrfs: qgroup scan failed with %d\n", err);
>> + }
>> +}
>> +
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-04-23 17:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 11:26 [PATCH v3 0/3] Btrfs: quota rescan for 3.10 Jan Schmidt
2013-04-23 11:26 ` [PATCH v3 1/3] Btrfs: split btrfs_qgroup_account_ref into four functions Jan Schmidt
2013-04-23 11:26 ` [PATCH v3 2/3] Btrfs: rescan for qgroups Jan Schmidt
2013-04-23 11:43 ` Wang Shilong
2013-04-23 12:05 ` Wang Shilong
2013-04-23 13:03 ` Jan Schmidt
2013-04-23 14:54 ` Wang Shilong
2013-04-23 17:33 ` Jan Schmidt [this message]
2013-04-24 11:00 ` Wang Shilong
2013-04-24 15:20 ` Jan Schmidt
2013-04-25 2:16 ` Wang Shilong
2013-04-25 15:04 ` Jan Schmidt
2013-04-23 11:26 ` [PATCH v3 3/3] Btrfs: automatic rescan after "quota enable" command Jan Schmidt
2013-04-23 15:36 ` David Sterba
2013-04-23 15:47 ` David Sterba
2013-04-23 17:28 ` Jan Schmidt
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=5176C5EC.5020209@jan-o-sch.net \
--to=list.btrfs@jan-o-sch.net \
--cc=chris.mason@fusionio.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangshilong1991@gmail.com \
--cc=wangsl-fnst@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.