From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: linux-xfs@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 1/5] xfs_quota: separate quota info acquisition into get_dquot()
Date: Mon, 25 Apr 2022 09:22:40 -0700 [thread overview]
Message-ID: <20220425162240.GG17025@magnolia> (raw)
In-Reply-To: <20220420144507.269754-2-aalbersh@redhat.com>
On Wed, Apr 20, 2022 at 04:45:04PM +0200, Andrey Albershteyn wrote:
> Both report_mount() and dump_file() have identical code to get quota
> information. This could be used for further separation of the
> functions.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
> quota/report.c | 49 +++++++++++++++++++++++--------------------------
> 1 file changed, 23 insertions(+), 26 deletions(-)
>
> diff --git a/quota/report.c b/quota/report.c
> index 2eb5b5a9..cccc654e 100644
> --- a/quota/report.c
> +++ b/quota/report.c
> @@ -59,16 +59,15 @@ report_help(void)
> "\n"));
> }
>
> -static int
> -dump_file(
> - FILE *fp,
> +static int
> +get_dquot(
> + struct fs_disk_quota *d,
> uint id,
> uint *oid,
> uint type,
> char *dev,
> int flags)
> {
> - fs_disk_quota_t d;
> int cmd;
>
> if (flags & GETNEXTQUOTA_FLAG)
> @@ -77,7 +76,7 @@ dump_file(
> cmd = XFS_GETQUOTA;
>
> /* Fall back silently if XFS_GETNEXTQUOTA fails, warn on XFS_GETQUOTA */
> - if (xfsquotactl(cmd, dev, type, id, (void *)&d) < 0) {
> + if (xfsquotactl(cmd, dev, type, id, (void *)d) < 0) {
> if (errno != ENOENT && errno != ENOSYS && errno != ESRCH &&
> cmd == XFS_GETQUOTA)
> perror("XFS_GETQUOTA");
> @@ -85,12 +84,29 @@ dump_file(
> }
>
> if (oid) {
> - *oid = d.d_id;
> + *oid = d->d_id;
> /* Did kernelspace wrap? */
> if (*oid < id)
> return 0;
> }
>
> + return 1;
> +}
> +
> +static int
> +dump_file(
> + FILE *fp,
> + uint id,
> + uint *oid,
> + uint type,
> + char *dev,
> + int flags)
> +{
> + fs_disk_quota_t d;
struct fs_disk_quota d;
With that nit fixed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--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)
> @@ -329,31 +345,12 @@ report_mount(
> {
> fs_disk_quota_t d;
> time64_t timer;
> - char *dev = mount->fs_name;
> char c[8], h[8], s[8];
> uint qflags;
> int count;
> - int cmd;
>
> - if (flags & GETNEXTQUOTA_FLAG)
> - cmd = XFS_GETNEXTQUOTA;
> - else
> - cmd = XFS_GETQUOTA;
> -
> - /* Fall back silently if XFS_GETNEXTQUOTA fails, warn on XFS_GETQUOTA*/
> - if (xfsquotactl(cmd, dev, type, id, (void *)&d) < 0) {
> - if (errno != ENOENT && errno != ENOSYS && errno != ESRCH &&
> - cmd == XFS_GETQUOTA)
> - perror("XFS_GETQUOTA");
> + if (!get_dquot(&d, id, oid, type, mount->fs_name, flags))
> return 0;
> - }
> -
> - if (oid) {
> - *oid = d.d_id;
> - /* Did kernelspace wrap? */
> - if (* oid < id)
> - return 0;
> - }
>
> if (flags & TERSE_FLAG) {
> count = 0;
> --
> 2.27.0
>
next prev parent reply other threads:[~2022-04-25 16:22 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 [this message]
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
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=20220425162240.GG17025@magnolia \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=hch@lst.de \
--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