<p dir="ltr"><br>
2016年4月7日 02:34,"Eric Sandeen" <<a href="mailto:sandeen@redhat.com">sandeen@redhat.com</a>>写道:<br>
><br>
> On 4/6/16 12:39 PM, Zorro Lang wrote:<br>
> > When use GETNEXTQUOTA ioctl to report project quota, it always<br>
> > report an unexpected quota:<br>
> ><br>
> > (null) 0 0 0 00 [--------]<br>
> ><br>
> > The ID 0 store the default quota, even if no one set default quota,<br>
> > it still have quota accounting, but not enforced. So GETNEXTQUOTA<br>
> > can find and report this undefined quota.<br>
> ><br>
> > From this problem, I thought if others' quota name miss, (null) will<br>
> > be printed too. e.g.<br>
> ><br>
> > # xfs_quota -xc "limit -u bsoft=300m bhard=400m test" $mnt<br>
> > # xfs_quota -xc "report -u" $mnt<br>
> > User ID Used Soft Hard Warn/Grace<br>
> > ---------- --------------------------------------------------<br>
> > root 0 0 0 00 [--------]<br>
> > test 0 307200 409600 00 [--------]<br>
> > # userdel -r test<br>
> > # xfs_quota -xc "report -u" $mnt<br>
> > User ID Used Soft Hard Warn/Grace<br>
> > ---------- --------------------------------------------------<br>
> > root 0 0 0 00 [--------]<br>
> > (null) 0 307200 409600 00 [--------]<br>
> ><br>
> > So this problem same with above id 0's problem. For deal with this,<br>
> > this patch will print id number if the name can't be found.<br>
> ><br>
> > But if use old GETQUOTA ioctl, it won't print project id 0 quota<br>
> > information(if it's not defined). That's different with GETNEXTQUOTA.<br>
> > For keep consistent, this patch also print project id 0 when use old<br>
> > GETQUOTA.<br>
> ><br>
> > Signed-off-by: Zorro Lang <<a href="mailto:zlang@redhat.com">zlang@redhat.com</a>><br>
><br>
> Thanks, I think this makes sense; so this solves 2 problems.<br>
><br>
> 1) always print the id # if there is no name mapping during quota report, and<br>
> 2) always print default project quota information, even if no PRID 0 in in the projects map.<br>
><br>
> UID & GID always (?) have an ID 0 defined (if the system has no root user or group,<br>
> something is very odd, but it is normal to have no PRID 0 defined)<br>
><br>
> other comments below.</p>
<p dir="ltr">Yes, I should add some comments. And I will add one line in xfs_quota man page about report command too.<br>
><br>
> > ---<br>
> ><br>
> > Hi,<br>
> ><br>
> > This's a problem from GETNEXTQUOTA feature. The original disscussion<br>
> > is as below:<br>
> ><br>
> > <a href="http://thread.gmane.org/gmane.comp.file-systems.fstests/1852/focus=1968">http://thread.gmane.org/gmane.comp.file-systems.fstests/1852/focus=1968</a><br>
> ><br>
> > Then Eryu send a patch to xfstests, try to fix the test failure bring<br>
> > by this bug. The disscussion is as below:<br>
> ><br>
> > <a href="http://oss.sgi.com/archives/xfs/2016-04/msg00002.html">http://oss.sgi.com/archives/xfs/2016-04/msg00002.html</a><br>
> ><br>
> > Finally we decided to fix this problem in xfsprogs. After talked with<br>
> > Eric Sandeen, I wrote this patch. At first, Eric thought we shouldn't<br>
> > print project id 0 quota information, if no one set limit for it.<br>
> ><br>
> > Then he change his mind to always print "root" as project id 0's name,<br>
> > if no one define a name for it. But there's another problem, if we<br>
> > print "root" for project id 0, but we can't run:<br>
> ><br>
> > xfs_quota -xc "limit -p xxx xxx root" $mnt<br>
> ><br>
> > Because the "root" is a fake name. Then I suggest to print id number,<br>
> > if the name can't be found. This method not only used for project id<br>
> > 0, it used for all user/group/project IDs which no name defined.<br>
> ><br>
> > So this patch should be the V3 patch. We can't sure which one is the<br>
> > best idea. If anyone have better idea, please tell me.<br>
> ><br>
> > Thanks,<br>
> > Zorro<br>
> ><br>
> > quota/report.c | 11 ++++++++++-<br>
> > 1 file changed, 10 insertions(+), 1 deletion(-)<br>
> ><br>
> > diff --git a/quota/report.c b/quota/report.c<br>
> > index 48a3f29..557d667 100644<br>
> > --- a/quota/report.c<br>
> > +++ b/quota/report.c<br>
> > @@ -389,7 +389,10 @@ report_mount(<br>
> > name = p->pr_name;<br>
> > }<br>
> > }<br>
> > - fprintf(fp, "%-10s", name);<br>
><br>
> Could use a comment:<br>
><br>
> + /* If no name is found, print the id # instead of (null) */<br>
><br>
> > + if (name != NULL)<br>
> > + fprintf(fp, "%-10s", name);<br>
> > + else<br>
> > + fprintf(fp, "#%-10u", d.d_id);<br>
> > }<br>
> ><br>
> > if (form & XFS_BLOCK_QUOTA) {<br>
> > @@ -571,6 +574,12 @@ report_project_mount(<br>
> > id = oid + 1;<br>
> > }<br>
> > } else {<br>
><br>
> Comment:<br>
><br>
> + /* Print default project quota even if PRID 0 isn't defined */<br>
><br>
> > + if (!getprprid(0)) {<br>
> > + report_mount(fp, 0, "#0", NULL, form, XFS_PROJ_QUOTA,<br>
><br>
> If you pass in NULL instead of "#0" does report_mount do the right thing?<br>
> If so, better to not hard-code "#0" here.</p>
<p dir="ltr">This's a good idea! Better than use hard–code #0 which looks ugly.</p>
<p dir="ltr">I will send V2 patch to fix all above problems.</p>
<p dir="ltr">Thanks,<br>
Zorro<br>
><br>
> -Eric<br>
><br>
> > + mount, flags);<br>
> > + flags |= NO_HEADER_FLAG;<br>
> > + }<br>
> > +<br>
> > setprent();<br>
> > while ((p = getprent()) != NULL) {<br>
> > if (report_mount(fp, p->pr_prid, p->pr_name, NULL,<br>
> ><br>
><br>
> _______________________________________________<br>
> xfs mailing list<br>
> <a href="mailto:xfs@oss.sgi.com">xfs@oss.sgi.com</a><br>
> <a href="http://oss.sgi.com/mailman/listinfo/xfs">http://oss.sgi.com/mailman/listinfo/xfs</a><br>
</p>