]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
tune2fs: do not update quota when not needed
authorGwendal Grignou <gwendal@chromium.org>
Fri, 3 Jan 2025 23:50:42 +0000 (15:50 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 21 May 2025 13:44:25 +0000 (09:44 -0400)
commit4ea1d7f202bb4350e8f517e604c6300a521a762c
tree3dd0ce1ea4467c01af074c9a1666a4bd19424d3e
parentea825a53bcb214de7356c2ebd8a10d005613bec3
tune2fs: do not update quota when not needed

Enabling quota is expensive: All inodes in the filesystem are scanned.
Only do it when the requested quota configuration does not match the
existing configuration.

Test:
Add a tiny patch to print out when core of function
handle_quota_options() is triggered.
Issue commands:
truncate -s 1G unused ; mkfs.ext4 unused

| commands                                                | trigger |
comments
+---------------------------------------------------------+---------+---------
| tune2fs -Qusrquota,grpquota -Qprjquota -O quota unused  | Y       |
                  Quota not set at formatting.
| tune2fs -Qusrquota,grpquota -Qprjquota -O quota unused  | N       |
                  Already set just above
| tune2fs -Qusrquota,grpquota -Q^prjquota -O quota unused | Y       |
                  Disabling a quota
| tune2fs -Qusrquota,grpquota -Q^prjquota -O quota unused | N       |
                  No change from previous line.
| tune2fs -Qusrquota,grpquota -O quota unused             | N       |
                  No change from previous line.
| tune2fs -Qusrquota,^grpquota -O quota unused            | Y       |
                  Disabling a quota
| tune2fs -Qusrquota -O quota unused                      | N       |
                  No change from previous line.
| tune2fs -O ^quota unused                                | Y       |
                  Remove quota
| tune2fs -O quota unused                                 | Y       |
                  Re-enable quota, default values
                  (-Qusrquota,grpquota) used.
| tune2fs -O quota -Qusrquota unused                      | N       |
                  Already set just above

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20250103235042.4029197-1-gwendal@chromium.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/tune2fs.c