diff mbox series

[5/5] xfs_quota: apply -L/-U range limits in uid/gid/pid loops

Message ID 20220328222503.146496-6-aalbersh@redhat.com (mailing list archive)
State Superseded
Headers show
Series xfsprogs: optimize -L/-U range calls for xfs_quota's dump/report | expand

Commit Message

Andrey Albershteyn March 28, 2022, 10:25 p.m. UTC
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
 quota/report.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

Comments

Christoph Hellwig April 6, 2022, 4:38 p.m. UTC | #1
Please write a commit log that explains why you are doing this and
maybe some higher level context.
diff mbox series

Patch

diff --git a/quota/report.c b/quota/report.c
index 074abbc1..c79e95ab 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -161,8 +161,10 @@  dump_limits_any_type(
 			struct group *g;
 			setgrent();
 			while ((g = getgrent()) != NULL) {
-				get_quota(&d, g->gr_gid, NULL, type, mount->fs_name, 0);
-				dump_file(fp, &d, mount->fs_name);
+				if (get_quota(&d, g->gr_gid, NULL, type, mount->fs_name, 0) &&
+						!(lower && (d.d_id < lower)) &&
+						!(upper && (d.d_id > upper)))
+					dump_file(fp, &d, mount->fs_name);
 			}
 			endgrent();
 			break;
@@ -171,8 +173,10 @@  dump_limits_any_type(
 			struct fs_project *p;
 			setprent();
 			while ((p = getprent()) != NULL) {
-				get_quota(&d, p->pr_prid, NULL, type, mount->fs_name, 0);
-				dump_file(fp, &d, mount->fs_name);
+				if (get_quota(&d, p->pr_prid, NULL, type, mount->fs_name, 0) &&
+						!(lower && (d.d_id < lower)) &&
+						!(upper && (d.d_id > upper)))
+					dump_file(fp, &d, mount->fs_name);
 			}
 			endprent();
 			break;
@@ -181,8 +185,10 @@  dump_limits_any_type(
 			struct passwd *u;
 			setpwent();
 			while ((u = getpwent()) != NULL) {
-				get_quota(&d, u->pw_uid, NULL, type, mount->fs_name, 0);
-				dump_file(fp, &d, mount->fs_name);
+				if (get_quota(&d, u->pw_uid, NULL, type, mount->fs_name, 0) &&
+						!(lower && (d.d_id < lower)) &&
+						!(upper && (d.d_id > upper)))
+					dump_file(fp, &d, mount->fs_name);
 			}
 			endpwent();
 			break;
@@ -474,8 +480,10 @@  report_user_mount(
 	if (!(flags & GETNEXTQUOTA_FLAG)) {
 		setpwent();
 		while ((u = getpwent()) != NULL) {
-			if (get_quota(&d, u->pw_uid, NULL, XFS_USER_QUOTA, mount->fs_name,
-					flags)) {
+			if (get_quota(&d, u->pw_uid, NULL, XFS_USER_QUOTA,
+						mount->fs_name, flags) &&
+					!(lower && (d.d_id < lower)) &&
+					!(upper && (d.d_id > upper))) {
 				report_mount(fp, &d, u->pw_name, form, XFS_USER_QUOTA, mount,
 						flags);
 				flags |= NO_HEADER_FLAG;
@@ -515,7 +523,9 @@  report_group_mount(
 		setgrent();
 		while ((g = getgrent()) != NULL) {
 			if (get_quota(&d, g->gr_gid, NULL, XFS_GROUP_QUOTA,
-						mount->fs_name, flags)) {
+						mount->fs_name, flags) &&
+					!(lower && (d.d_id < lower)) &&
+					!(upper && (d.d_id > upper))) {
 				report_mount(fp, &d, g->gr_name, form,
 						XFS_GROUP_QUOTA, mount, flags);
 				flags |= NO_HEADER_FLAG;
@@ -557,7 +567,9 @@  report_project_mount(
 			 * isn't defined
 			 */
 			if (get_quota(&d, 0, NULL, XFS_PROJ_QUOTA,
-						mount->fs_name, flags)) {
+						mount->fs_name, flags) &&
+					!(lower && (d.d_id < lower)) &&
+					!(upper && (d.d_id > upper))) {
 				report_mount(fp, &d, NULL, form, XFS_PROJ_QUOTA, mount, flags);
 				flags |= NO_HEADER_FLAG;
 			}
@@ -566,7 +578,9 @@  report_project_mount(
 		setprent();
 		while ((p = getprent()) != NULL) {
 			if (get_quota(&d, p->pr_prid, NULL, XFS_PROJ_QUOTA,
-						mount->fs_name, flags)) {
+						mount->fs_name, flags) &&
+					!(lower && (d.d_id < lower)) &&
+					!(upper && (d.d_id > upper))) {
 				report_mount(fp, &d, p->pr_name, form, XFS_PROJ_QUOTA, mount,
 						flags);
 				flags |= NO_HEADER_FLAG;