From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/4] btrfs-progs: cmds/qgroup: sync the fs before doing qgroup search
Date: Thu, 9 May 2024 18:42:30 +0930 [thread overview]
Message-ID: <50d13a90a4dd1146fe6d755ec3a7e69ff9fba325.1715245781.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1715245781.git.wqu@suse.com>
Since qgroup numbers are only updated at transaction commit time, it's
better to do the a sync before reading the quota tree, to reduce the
chance of uncommitted qgroup changes.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds/qgroup.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/cmds/qgroup.c b/cmds/qgroup.c
index 6e88db5803a5..09eac0d2b36e 100644
--- a/cmds/qgroup.c
+++ b/cmds/qgroup.c
@@ -2135,6 +2135,7 @@ static const char * const cmd_qgroup_clear_stale_usage[] = {
static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char **argv)
{
+ enum btrfs_util_error err;
int ret = 0;
int fd;
char *path = NULL;
@@ -2151,6 +2152,11 @@ static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char *
if (fd < 0)
return 1;
+ /* Sync the fs so that the qgroup numbers are uptodate. */
+ err = btrfs_util_sync_fd(fd);
+ if (err)
+ warning("sync ioctl failed on '%s': %m", path);
+
ret = qgroups_search_all(fd, &qgroup_lookup);
if (ret == -ENOTTY) {
error("can't list qgroups: quotas not enabled");
--
2.45.0
next prev parent reply other threads:[~2024-05-09 9:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-09 9:12 [PATCH 0/4] btrfs-progs: cmds/qgroup: enhance stale qgroups handling Qu Wenruo
2024-05-09 9:12 ` Qu Wenruo [this message]
2024-05-09 9:12 ` [PATCH 2/4] btrfs-progs: cmds/qgroup: add qgroup_lookup::flags member Qu Wenruo
2024-05-09 9:12 ` [PATCH 3/4] btrfs-progs: cmds/qgroup: handle stale qgroup deleteion more accurately Qu Wenruo
2024-05-09 9:12 ` [PATCH 4/4] btrfs-progs: cmds/qgroup: add more special status for qgroups Qu Wenruo
2024-05-17 16:15 ` [PATCH 0/4] btrfs-progs: cmds/qgroup: enhance stale qgroups handling David Sterba
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=50d13a90a4dd1146fe6d755ec3a7e69ff9fba325.1715245781.git.wqu@suse.com \
--to=wqu@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;
as well as URLs for NNTP newsgroup(s).