Skip to contentSkip to conversation

xfs_quota: print quota id number if the name can't be found

PATCH In review Zorro Lang 5 participants 5 messages Apr 7, 2016 – May 11, 2016

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v3 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 V3 patch fix some man page problems. Thanks for Eric specified my English syntax problems.

Thanks,
Zorro

 man/man8/xfs_quota.8 |  4 +++-
 quota/report.c       | 16 +++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
man/man8/xfs_quota.8 +3 -1
index 951252b..a14568b 100644
@@ -357,7 +357,9 @@ option outputs the report to
 .I file
 instead of stdout. The
 .B \-a
-option reports on all filesystems. The
+option reports on all filesystems. By default, outputs the name of
+the user/group/project. If no name is defined for a given ID, outputs
+the numeric ID instead. The
 .B \-n
 option outputs the numeric ID instead of the name. The
 .B \-L
quota/report.c +15 -1
index 48a3f29..cc422d1 100644
@@ -389,7 +389,11 @@ report_mount(
 					name = p->pr_name;
 			}
 		}
-		fprintf(fp, "%-10s", name);
+		/* If no name is found, print the id #num instead of (null) */
+		if (name != NULL)
+			fprintf(fp, "%-10s", name);
+		else
+			fprintf(fp, "#%-9u", d.d_id);
 	}
 
 	if (form & XFS_BLOCK_QUOTA) {
@@ -571,6 +575,16 @@ report_project_mount(
 			id = oid + 1;
 		}
 	} else {
+		if (!getprprid(0)) {
+			/*
+			 * Print default project quota, even if projid 0
+			 * isn't defined
+			 */
+			report_mount(fp, 0, NULL, 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
Reviewed-by on v3 1/1
#1 lore raw
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.

Looks good to me, thanks Zorro!

Quoted 54 lines

---

Hi,

This V3 patch fix some man page problems. Thanks for Eric specified my English syntax problems.

Thanks,
Zorro

 man/man8/xfs_quota.8 |  4 +++-
 quota/report.c       | 16 +++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
man/man8/xfs_quota.8 +3 -1
index 951252b..a14568b 100644
@@ -357,7 +357,9 @@ option outputs the report to
 .I file
 instead of stdout. The
 .B \-a
-option reports on all filesystems. The
+option reports on all filesystems. By default, outputs the name of
+the user/group/project. If no name is defined for a given ID, outputs
+the numeric ID instead. The
 .B \-n
 option outputs the numeric ID instead of the name. The
 .B \-L
quota/report.c +8 -1
index 48a3f29..cc422d1 100644
@@ -389,7 +389,11 @@ report_mount(
 					name = p->pr_name;
 			}
 		}
-		fprintf(fp, "%-10s", name);
+		/* If no name is found, print the id #num instead of (null) */
+		if (name != NULL)
+			fprintf(fp, "%-10s", name);
+		else
+			fprintf(fp, "#%-9u", d.d_id);
 	}
 
 	if (form & XFS_BLOCK_QUOTA) {
@@ -571,6 +575,16 @@ report_project_mount(
 			id = oid + 1;
 		}
 	} else {
+		if (!getprprid(0)) {
+			/*
+			 * Print default project quota, even if projid 0

quota/report.c report_project_mount( · line 590

Quoted 10 lines
quota/report.c +7 -0
+			 * isn't defined
+			 */
+			report_mount(fp, 0, NULL, 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,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
In reply to Zorro Lang
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.

OK, so with this applied xfs/133 and xfs/134 both now fail with this extra output:

+#0 0 0 0 00 [--------]

Can you send patches for these tests to filter out these lines so that the tests pass again for both old and new xfsprogs?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw
Quoted 37 lines · 2016年5月11日 08:10,"Dave Chinner" <[email protected]>写道:
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.

Quoted 7 lines

OK, so with this applied xfs/133 and xfs/134 both now fail with this extra output:

+#0 0 0 0 00 [--------]

Can you send patches for these tests to filter out these lines so that the tests pass again for both old and new xfsprogs?

Hi Dave,

Sure, I'm doing on this. I remember that a patch from Eryu maybe suit for this xfsprogs change(maybe need some modify). I'll check it and send a suitable patch as soon as possible.

Thanks,
Zorro

Quoted 8 lines

Cheers,

Dave.
--
Dave Chinner
[email protected]

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