xfs
[Top] [All Lists]

Re: [PATCH] xfs_quota: print quota id number if the name can't be found

To: Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: Re: [PATCH] xfs_quota: print quota id number if the name can't be found
From: Zorro Lang <zorro.lang@xxxxxxxxx>
Date: Thu, 7 Apr 2016 09:41:47 +0800
Cc: xfs@xxxxxxxxxxx, zlang@xxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=GvnUGhf9CErd7DtUSx7H6x63ZIlk+EP8C5sTOmyLwnY=; b=LzSsmebsF8eTi/VAvPS6N0Yxeagl73jiSnOQ+KZsIj/nWC01V4Rfj5HuRg6SUINv1W gX3R7kbukUoD6cde58qwYMc6QKKDj+mlHAP/3y4xBTNSwQDV8p1G6shWXOc1nO1s/FoR t4sXSKbqEcooSirOuyvZoa7js31MnhMas2VEdqmn/d02DmiITCLZT4c3mz2DWOezTqRp kUkNJPpoU4bOLrGS6kpFSld889lIUcapDYhaNahR4v+vWDNnHt7s9dCQldtbHdnJa2G8 UGRaPHD5wKHuBT3AnSi1zHTAQGNPeiFOK5YoWWZcygLU94rQp7vQQOCrrvv6STp+v5T2 nGUA==
In-reply-to: <570556AE.7080306@xxxxxxxxxx>
References: <1459964353-25151-1-git-send-email-zlang@xxxxxxxxxx> <570556AE.7080306@xxxxxxxxxx>


2016å4æ7æ 02:34ï"Eric Sandeen" <sandeen@xxxxxxxxxx>åéï
>
> On 4/6/16 12:39 PM, Zorro Lang wrote:
> > When use GETNEXTQUOTA ioctl to report project quota, it always
> > report an unexpected quota:
> >
> >Â Â(null) 0 0 0 00 [--------]
> >
> > The ID 0 store the default quota, even if no one set default quota,
> > it still have quota accounting, but not enforced. So GETNEXTQUOTA
> > can find and report this undefined quota.
> >
> > From this problem, I thought if others' quota name miss, (null) will
> > be printed too. e.g.
> >
> >Â Â# xfs_quota -xc "limit -u bsoft=300m bhard=400m test" $mnt
> >Â Â# xfs_quota -xc "report -u" $mnt
> > ÂUser ID     Used   ÂSoft   ÂHard  Warn/Grace
> >Â Â---------- --------------------------------------------------
> > Âroot        0     0     0  Â00 [--------]
> > Âtest        0  Â307200  Â409600  Â00 [--------]
> >Â Â# userdel -r test
> >Â Â# xfs_quota -xc "report -u" $mnt
> > ÂUser ID     Used   ÂSoft   ÂHard  Warn/Grace
> >Â Â---------- --------------------------------------------------
> > Âroot        0     0     0  Â00 [--------]
> >Â Â(null)Â Â Â Â Â Â Â 0Â Â Â307200Â Â Â409600Â Â Â00 [--------]
> >
> > So this problem same with above id 0's problem. For deal with this,
> > this patch will print id number if the name can't be found.
> >
> > But if use old GETQUOTA ioctl, it won't print project id 0 quota
> > information(if it's not defined). That's different with GETNEXTQUOTA.
> > For keep consistent, this patch also print project id 0 when use old
> > GETQUOTA.
> >
> > Signed-off-by: Zorro Lang <zlang@xxxxxxxxxx>
>
> Thanks, I think this makes sense; so this solves 2 problems.
>
> 1) always print the id # if there is no name mapping during quota report, and
> 2) always print default project quota information, even if no PRID 0 in in the projects map.
>
> UID & GID always (?) have an ID 0 defined (if the system has no root user or group,
> something is very odd, but it is normal to have no PRID 0 defined)
>
> other comments below.

Yes, I should add some comments. And I will add one line in xfs_quota man page about report command too.
>
> > ---
> >
> > Hi,
> >
> > This's a problem from GETNEXTQUOTA feature. The original disscussion
> > is as below:
> >
> > http://thread.gmane.org/gmane.comp.file-systems.fstests/1852/focus=1968
> >
> > Then Eryu send a patch to xfstests, try to fix the test failure bring
> > by this bug. The disscussion is as below:
> >
> > http://oss.sgi.com/archives/xfs/2016-04/msg00002.html
> >
> > Finally we decided to fix this problem in xfsprogs. After talked with
> > Eric Sandeen, I wrote this patch. At first, Eric thought we shouldn't
> > print project id 0 quota information, if no one set limit for it.
> >
> > Then he change his mind to always print "root" as project id 0's name,
> > if no one define a name for it. But there's another problem, if we
> > print "root" for project id 0, but we can't run:
> >
> >Â Âxfs_quota -xc "limit -p xxx xxx root" $mnt
> >
> > Because the "root" is a fake name. Then I suggest to print id number,
> > if the name can't be found. This method not only used for project id
> > 0, it used for all user/group/project IDs which no name defined.
> >
> > So this patch should be the V3 patch. We can't sure which one is the
> > best idea. If anyone have better idea, please tell me.
> >
> > Thanks,
> > Zorro
> >
> >Â quota/report.c | 11 ++++++++++-
> >Â 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/quota/report.c b/quota/report.c
> > index 48a3f29..557d667 100644
> > --- a/quota/report.c
> > +++ b/quota/report.c
> > @@ -389,7 +389,10 @@ report_mount(
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âname = p->pr_name;
> >Â Â Â Â Â Â Â Â Â Â Â Â}
> >Â Â Â Â Â Â Â Â}
> > -Â Â Â Â Â Â Âfprintf(fp, "%-10s", name);
>
> Could use a comment:
>
> +Â Â Â Â Â Â Â Â/* If no name is found, print the id # instead of (null) */
>
> > +Â Â Â Â Â Â Âif (name != NULL)
> > +Â Â Â Â Â Â Â Â Â Â Âfprintf(fp, "%-10s", name);
> > +Â Â Â Â Â Â Âelse
> > +Â Â Â Â Â Â Â Â Â Â Âfprintf(fp, "#%-10u", d.d_id);
> >Â Â Â Â}
> >
> >Â Â Â Âif (form & XFS_BLOCK_QUOTA) {
> > @@ -571,6 +574,12 @@ report_project_mount(
> >Â Â Â Â Â Â Â Â Â Â Â Âid = oid + 1;
> >Â Â Â Â Â Â Â Â}
> >Â Â Â Â} else {
>
> Comment:
>
> +Â Â Â Â Â Â Â Â/* Print default project quota even if PRID 0 isn't defined */
>
> > +Â Â Â Â Â Â Âif (!getprprid(0)) {
> > +Â Â Â Â Â Â Â Â Â Â Âreport_mount(fp, 0, "#0", NULL, form, XFS_PROJ_QUOTA,
>
> If you pass in NULL instead of "#0" does report_mount do the right thing?
> If so, better to not hard-code "#0" here.

This's a good idea! Better than use hardâcode #0 which looks ugly.

I will send V2 patch to fix all above problems.

Thanks,
Zorro
>
> -Eric
>
> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mount, flags);
> > +Â Â Â Â Â Â Â Â Â Â Âflags |= NO_HEADER_FLAG;
> > +Â Â Â Â Â Â Â}
> > +
> >Â Â Â Â Â Â Â Âsetprent();
> >Â Â Â Â Â Â Â Âwhile ((p = getprent()) != NULL) {
> >Â Â Â Â Â Â Â Â Â Â Â Âif (report_mount(fp, p->pr_prid, p->pr_name, NULL,
> >
>
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

<Prev in Thread] Current Thread [Next in Thread>