xfs_quota: print quota id number if the name can't be found
PATCH 1/1 xfs_quota: print quota id number if the name can't be found
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.
Quoted 1 line
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.
---
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(-)
quota/report.c +10 -1
@@ -389,7 +389,10 @@ report_mount( name = p->pr_name; } } -fprintf (fp,"%-10s" , name); +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 { +if (!getprprid (0 )) { +report_mount (fp,0 ,"#0" ,NULL , form,XFS_PROJ_QUOTA , + mount, flags); + flags |=NO_HEADER_FLAG ; + } +setprent ();while ((p =getprent ()) !=NULL ) { if (report_mount(fp, p->pr_prid, p->pr_name, NULL,
Signature · 6 lines
2.5.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 28 lines · Zorro Lang
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.
Quoted 6 lines
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 <[email protected]>
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.
Quoted 42 lines
---
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" $mntBecause 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,
Zorroquota/report.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)quota/report.c +0
-0
quota/report.c report_mount( · line 392
Quoted 4 lines
quota/report.c +0
-1@@ -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) */
quota/report.c report_project_mount( · line 576
Quoted 11 lines
quota/report.c +4
-0+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 */
quota/report.c report_project_mount( · line 578
Quoted 2 lines
quota/report.c +2
-0+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.
-Eric
quota/report.c report_project_mount( · line 585
Quoted 8 lines
quota/report.c +4
-0+ 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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 35 lines · 2016年4月7日 02:34,"Eric Sandeen" <[email protected]>写道:
Quoted 33 lines · Zorro Lang
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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Zorro Lang <[email protected]>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
Quoted 1 line
2) always print default project quota information, even if no PRID 0 in
in the projects map.
Quoted 2 lines
UID & GID always (?) have an ID 0 defined (if the system has no root user
or group,
Quoted 3 lines
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.
Quoted 50 lines
Quoted 43 lines
---
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" $mntBecause 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,
Zorroquota/report.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)quota/report.c +0
-0quota/report.c report_mount( · line 392
Quoted 4 lines
quota/report.c +0
-1@@ -389,7 +389,10 @@ report_mount( name = p->pr_name; } } -fprintf (fp,"%-10s" , name);Could use a comment:
Quoted 1 line
+ /* If no name is found, print the id # instead of (null)
*/
Quoted 15 lines
quota/report.c report_project_mount( · line 576
Quoted 12 lines
quota/report.c +4
-0+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:
Quoted 1 line
+ /* Print default project quota even if PRID 0 isn't
defined */
Quoted 3 lines
quota/report.c report_project_mount( · line 578
Quoted 3 lines
quota/report.c +2
-0+if (!getprprid (0 )) { + report_mount(fp, 0, "#0", NULL, form,
XFS_PROJ_QUOTA,
Quoted 3 lines
If you pass in NULL instead of "#0" does
report_mountdo 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
Quoted 12 lines
-Eric
quota/report.c report_project_mount( · line 585
Quoted 8 lines
quota/report.c +4
-0+ mount, flags); + flags |=NO_HEADER_FLAG ; + } +setprent ();while ((p =getprent ()) !=NULL ) { if (report_mount(fp, p->pr_prid, p->pr_name, NULL,
Quoted 4 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 97 lines · Eric Sandeen
Quoted 28 lines · Zorro Lang
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.
Quoted 6 lines
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 <[email protected]>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.
Quoted 42 lines
---
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" $mntBecause 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,
Zorroquota/report.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)quota/report.c +0
-0quota/report.c report_mount( · line 392
Quoted 4 lines
quota/report.c +0
-1@@ -389,7 +389,10 @@ report_mount( name = p->pr_name; } } -fprintf (fp,"%-10s" , name);Could use a comment:
(quoted diff) +1
-0+ /* If no name is found, print the id # instead of (null) */
Quoted 4 lines
quota/report.c report_mount( · line 395
Quoted 4 lines
quota/report.c +4
-0+if (name !=NULL ) +fprintf (fp,"%-10s" , name); +else +fprintf (fp,"#%-10u" , d.d_id);
There's one more problem. When we print id number we print #%-10u, but for name we print %-10s. There's one more "#" be printed for number. So if we print name and number both, the output will like this:
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 512000 0 0 00 [--------]
#1000 0 307200 409600 00 [--------]
You can find the line of #1000 is not align at the line of "root". Because the name print 10 characters, but the number print 10 characters + #.
Should we fix this problem?
If fix it, should we make name print %-11s, or make number print #%-9u?
Thanks,
Zorro
Quoted 20 lines
quota/report.c report_project_mount( · line 576
Quoted 7 lines
quota/report.c +0
-0}if (form &XFS_BLOCK_QUOTA ) {@@ -571,6 +574,12 @@ report_project_mount( id = oid +1 ; } }else {Comment:
(quoted diff) +1
-0+ /* Print default project quota even if PRID 0 isn't defined */quota/report.c report_project_mount( · line 578
Quoted 3 lines
quota/report.c +2
-0+if (!getprprid (0 )) { + report_mount(fp, 0, "#0", NULL, form, XFS_PROJ_QUOTA,If you pass in NULL instead of "#0" does
report_mountdo the right thing? If so, better to not hard-code "#0" here.-Eric
Quoted 13 lines
quota/report.c report_project_mount( · line 585
Quoted 8 lines
quota/report.c +4
-0+ 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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 20 lines · Zorro Lang
Quoted 7 lines
quota/report.c report_mount( · line 395
Quoted 7 lines
quota/report.c +4
-0+if (name !=NULL ) +fprintf (fp,"%-10s" , name); +else +fprintf (fp,"#%-10u" , d.d_id);There's one more problem. When we print id number we print #%-10u, but for name we print %-10s. There's one more "#" be printed for number. So if we print name and number both, the output will like this:
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 512000 0 0 00 [--------]
#1000 0 307200 409600 00 [--------]
Quoted 7 lines
You can find the line of #1000 is not align at the line of "root". Because the name print 10 characters, but the number print 10 characters + #.
Should we fix this problem?
If fix it, should we make name print %-11s, or make number print #%-9u?
9u I think. Leave the existing format unchanged.
Thx,
Eric
Quoted 35 lines
Thanks,
ZorroQuoted 32 lines
quota/report.c report_project_mount( · line 576
Quoted 7 lines
} if (form & XFS_BLOCK_QUOTA) {quota/report.c +0
-0@@ -571,6 +574,12 @@ report_project_mount( id = oid +1 ; } }else {Comment:
+ /* Print default project quota even if PRID 0 isn't defined */
quota/report.c report_project_mount( · line 578
Quoted 2 lines
quota/report.c +2
-0+if (!getprprid (0 )) { + report_mount(fp, 0, "#0", NULL, form, XFS_PROJ_QUOTA,If you pass in NULL instead of "#0" does
report_mountdo the right thing? If so, better to not hard-code "#0" here.-Eric
quota/report.c report_project_mount( · line 585
Quoted 7 lines
quota/report.c +4
-0+ 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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs