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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 20, 2022 at 04:45:08PM +0200, Andrey Albershteyn wrote:
> In case kernel doesn't support XFS_GETNEXTQUOTA the report/dump
> command will fallback to iterating over all known uid/gid/pid.
> However, currently it won't take -L/-U range limits into account
> (all entities with non-zero qoutas will be outputted). This applies
> those limits for fallback case.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>

--D

> ---
>  quota/report.c | 40 +++++++++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 13 deletions(-)
> 
> diff --git a/quota/report.c b/quota/report.c
> index 65d931f3..8af763e4 100644
> --- a/quota/report.c
> +++ b/quota/report.c
> @@ -161,9 +161,11 @@ dump_limits_any_type(
>  			struct group *g;
>  			setgrent();
>  			while ((g = getgrent()) != NULL) {
> -				get_dquot(&d, g->gr_gid, NULL, type,
> -						mount->fs_name, 0);
> -				dump_file(fp, &d, mount->fs_name);
> +				if (get_dquot(&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;
> @@ -172,9 +174,11 @@ dump_limits_any_type(
>  			struct fs_project *p;
>  			setprent();
>  			while ((p = getprent()) != NULL) {
> -				get_dquot(&d, p->pr_prid, NULL, type,
> -						mount->fs_name, 0);
> -				dump_file(fp, &d, mount->fs_name);
> +				if (get_dquot(&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;
> @@ -183,9 +187,11 @@ dump_limits_any_type(
>  			struct passwd *u;
>  			setpwent();
>  			while ((u = getpwent()) != NULL) {
> -				get_dquot(&d, u->pw_uid, NULL, type,
> -						mount->fs_name, 0);
> -				dump_file(fp, &d, mount->fs_name);
> +				if (get_dquot(&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;
> @@ -478,7 +484,9 @@ report_user_mount(
>  		setpwent();
>  		while ((u = getpwent()) != NULL) {
>  			if (get_dquot(&d, u->pw_uid, NULL, XFS_USER_QUOTA,
> -						mount->fs_name, flags)) {
> +						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;
> @@ -518,7 +526,9 @@ report_group_mount(
>  		setgrent();
>  		while ((g = getgrent()) != NULL) {
>  			if (get_dquot(&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;
> @@ -560,7 +570,9 @@ report_project_mount(
>  			 * isn't defined
>  			 */
>  			if (get_dquot(&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;
> @@ -570,7 +582,9 @@ report_project_mount(
>  		setprent();
>  		while ((p = getprent()) != NULL) {
>  			if (get_dquot(&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;
> -- 
> 2.27.0
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux