From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 2/5] xfs_quota: separate get_dquot() and dump_file()
Date: Mon, 25 Apr 2022 09:28:36 -0700 [thread overview]
Message-ID: <20220425162836.GH17025@magnolia> (raw)
In-Reply-To: <20220420144507.269754-3-aalbersh@redhat.com>
On Wed, Apr 20, 2022 at 04:45:05PM +0200, Andrey Albershteyn wrote:
> Separate quota info acquisition from outputting it to file. This
> allows upper functions to filter obtained info (e.g. within specific
> ID range).
>
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> ---
> quota/report.c | 86 ++++++++++++++++++++++++++------------------------
> 1 file changed, 45 insertions(+), 41 deletions(-)
>
> diff --git a/quota/report.c b/quota/report.c
> index cccc654e..d5c6f84f 100644
> --- a/quota/report.c
> +++ b/quota/report.c
> @@ -96,39 +96,31 @@ get_dquot(
> static int
> dump_file(
I kinda wonder if this ought to be named 'dump_dquot' since it's not
really dumping a file or even the dquots of a specifc file. OTOH, the
rest of the utility seems to have similar naming conventions for "report
something to a FILE* stream" so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> FILE *fp,
> - uint id,
> - uint *oid,
> - uint type,
> - char *dev,
> - int flags)
> + struct fs_disk_quota *d,
> + char *dev)
> {
> - fs_disk_quota_t d;
> -
> - if (!get_dquot(&d, id, oid, type, dev, flags))
> - return 0;
> -
> - if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
> - !d.d_ino_softlimit && !d.d_ino_hardlimit &&
> - !d.d_rtb_softlimit && !d.d_rtb_hardlimit)
> + if (!d->d_blk_softlimit && !d->d_blk_hardlimit &&
> + !d->d_ino_softlimit && !d->d_ino_hardlimit &&
> + !d->d_rtb_softlimit && !d->d_rtb_hardlimit)
> return 1;
> fprintf(fp, "fs = %s\n", dev);
> /* this branch is for backward compatibility reasons */
> - if (d.d_rtb_softlimit || d.d_rtb_hardlimit)
> + if (d->d_rtb_softlimit || d->d_rtb_hardlimit)
> fprintf(fp, "%-10d %7llu %7llu %7llu %7llu %7llu %7llu\n",
> - d.d_id,
> - (unsigned long long)d.d_blk_softlimit,
> - (unsigned long long)d.d_blk_hardlimit,
> - (unsigned long long)d.d_ino_softlimit,
> - (unsigned long long)d.d_ino_hardlimit,
> - (unsigned long long)d.d_rtb_softlimit,
> - (unsigned long long)d.d_rtb_hardlimit);
> + d->d_id,
> + (unsigned long long)d->d_blk_softlimit,
> + (unsigned long long)d->d_blk_hardlimit,
> + (unsigned long long)d->d_ino_softlimit,
> + (unsigned long long)d->d_ino_hardlimit,
> + (unsigned long long)d->d_rtb_softlimit,
> + (unsigned long long)d->d_rtb_hardlimit);
> else
> fprintf(fp, "%-10d %7llu %7llu %7llu %7llu\n",
> - d.d_id,
> - (unsigned long long)d.d_blk_softlimit,
> - (unsigned long long)d.d_blk_hardlimit,
> - (unsigned long long)d.d_ino_softlimit,
> - (unsigned long long)d.d_ino_hardlimit);
> + d->d_id,
> + (unsigned long long)d->d_blk_softlimit,
> + (unsigned long long)d->d_blk_hardlimit,
> + (unsigned long long)d->d_ino_softlimit,
> + (unsigned long long)d->d_ino_hardlimit);
>
> return 1;
> }
> @@ -142,6 +134,7 @@ dump_limits_any_type(
> uint upper)
> {
> fs_path_t *mount;
> + struct fs_disk_quota d;
> uint id = 0, oid;
>
> if ((mount = fs_table_lookup(dir, FS_MOUNT_POINT)) == NULL) {
> @@ -153,46 +146,57 @@ dump_limits_any_type(
>
> /* Range was specified; query everything in it */
> if (upper) {
> - for (id = lower; id <= upper; id++)
> - dump_file(fp, id, NULL, type, mount->fs_name, 0);
> + for (id = lower; id <= upper; id++) {
> + get_dquot(&d, id, &oid, type, mount->fs_name, 0);
> + dump_file(fp, &d, mount->fs_name);
> + }
> return;
> }
>
> /* Use GETNEXTQUOTA if it's available */
> - if (dump_file(fp, id, &oid, type, mount->fs_name, GETNEXTQUOTA_FLAG)) {
> + if (get_dquot(&d, id, &oid, type, mount->fs_name, GETNEXTQUOTA_FLAG)) {
> + dump_file(fp, &d, mount->fs_name);
> id = oid + 1;
> - while (dump_file(fp, id, &oid, type, mount->fs_name,
> - GETNEXTQUOTA_FLAG))
> + while (get_dquot(&d, id, &oid, type, mount->fs_name,
> + GETNEXTQUOTA_FLAG)) {
> + dump_file(fp, &d, mount->fs_name);
> id = oid + 1;
> + }
> return;
> - }
> + }
>
> /* Otherwise fall back to iterating over each uid/gid/prjid */
> switch (type) {
> case XFS_GROUP_QUOTA: {
> struct group *g;
> setgrent();
> - while ((g = getgrent()) != NULL)
> - dump_file(fp, g->gr_gid, NULL, type,
> - mount->fs_name, 0);
> + while ((g = getgrent()) != NULL) {
> + get_dquot(&d, g->gr_gid, NULL, type,
> + mount->fs_name, 0);
> + dump_file(fp, &d, mount->fs_name);
> + }
> endgrent();
> break;
> }
> case XFS_PROJ_QUOTA: {
> struct fs_project *p;
> setprent();
> - while ((p = getprent()) != NULL)
> - dump_file(fp, p->pr_prid, NULL, type,
> - mount->fs_name, 0);
> + while ((p = getprent()) != NULL) {
> + get_dquot(&d, p->pr_prid, NULL, type,
> + mount->fs_name, 0);
> + dump_file(fp, &d, mount->fs_name);
> + }
> endprent();
> break;
> }
> case XFS_USER_QUOTA: {
> struct passwd *u;
> setpwent();
> - while ((u = getpwent()) != NULL)
> - dump_file(fp, u->pw_uid, NULL, type,
> - mount->fs_name, 0);
> + while ((u = getpwent()) != NULL) {
> + get_dquot(&d, u->pw_uid, NULL, type,
> + mount->fs_name, 0);
> + dump_file(fp, &d, mount->fs_name);
> + }
> endpwent();
> break;
> }
> --
> 2.27.0
>
next prev parent reply other threads:[~2022-04-25 16:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 14:45 [PATCH v2 0/5] xfsprogs: optimize -L/-U range calls for xfs_quota's dump/report Andrey Albershteyn
2022-04-20 14:45 ` [PATCH v2 1/5] xfs_quota: separate quota info acquisition into get_dquot() Andrey Albershteyn
2022-04-25 16:22 ` Darrick J. Wong
2022-04-20 14:45 ` [PATCH v2 2/5] xfs_quota: separate get_dquot() and dump_file() Andrey Albershteyn
2022-04-24 5:29 ` Christoph Hellwig
2022-04-25 16:28 ` Darrick J. Wong [this message]
2022-04-28 12:43 ` Andrey Albershteyn
2022-04-20 14:45 ` [PATCH v2 3/5] xfs_quota: separate get_dquot() and report_mount() Andrey Albershteyn
2022-04-24 5:29 ` Christoph Hellwig
2022-04-25 16:29 ` Darrick J. Wong
2022-04-20 14:45 ` [PATCH v2 4/5] xfs_quota: utilize XFS_GETNEXTQUOTA for ranged calls in report/dump Andrey Albershteyn
2022-04-25 16:33 ` Darrick J. Wong
2022-04-28 8:39 ` Andrey Albershteyn
2022-04-20 14:45 ` [PATCH v2 5/5] xfs_quota: apply -L/-U range limits in uid/gid/pid loops Andrey Albershteyn
2022-04-24 5:29 ` Christoph Hellwig
2022-04-25 16:33 ` Darrick J. Wong
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=20220425162836.GH17025@magnolia \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=linux-xfs@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