Message ID | 20250103235042.4029197-1-gwendal@chromium.org |
---|---|
State | Accepted |
Headers | show |
Series | [v2] tune2fs: do not update quota when not needed | expand |
On Fri 03-01-25 15:50:42, Gwendal Grignou wrote: > 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> Looks good to me. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > > --- > Changes in v2: > Logic has been simplified, based on jack@suse.cz feedback. > > misc/tune2fs.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/misc/tune2fs.c b/misc/tune2fs.c > index 2548a766..3db57632 100644 > --- a/misc/tune2fs.c > +++ b/misc/tune2fs.c > @@ -1799,11 +1799,27 @@ static int handle_quota_options(ext2_filsys fs) > return 1; > } > > + for (qtype = 0; qtype < MAXQUOTAS; qtype++) { > + if (quota_enable[qtype] == QOPT_ENABLE && > + *quota_sb_inump(fs->super, qtype) == 0) { > + /* Some work needed to match the configuration. */ > + break; > + } > + if (quota_enable[qtype] == QOPT_DISABLE && > + *quota_sb_inump(fs->super, qtype)) { > + /* Some work needed to match the configuration. */ > + break; > + } > + } > + if (qtype == MAXQUOTAS) { > + /* Nothing to do. */ > + return 0; > + } > + > for (qtype = 0; qtype < MAXQUOTAS; qtype++) { > if (quota_enable[qtype] == QOPT_ENABLE) > qtype_bits |= 1 << qtype; > } > - > retval = quota_init_context(&qctx, fs, qtype_bits); > if (retval) { > com_err(program_name, retval, > -- > 2.47.1.613.gc27f4b7a9f-goog >
On Fri, 03 Jan 2025 15:50:42 -0800, Gwendal Grignou wrote: > 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 > > [...] Applied, thanks! [1/1] tune2fs: do not update quota when not needed commit: 4ea1d7f202bb4350e8f517e604c6300a521a762c Best regards,
diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 2548a766..3db57632 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -1799,11 +1799,27 @@ static int handle_quota_options(ext2_filsys fs) return 1; } + for (qtype = 0; qtype < MAXQUOTAS; qtype++) { + if (quota_enable[qtype] == QOPT_ENABLE && + *quota_sb_inump(fs->super, qtype) == 0) { + /* Some work needed to match the configuration. */ + break; + } + if (quota_enable[qtype] == QOPT_DISABLE && + *quota_sb_inump(fs->super, qtype)) { + /* Some work needed to match the configuration. */ + break; + } + } + if (qtype == MAXQUOTAS) { + /* Nothing to do. */ + return 0; + } + for (qtype = 0; qtype < MAXQUOTAS; qtype++) { if (quota_enable[qtype] == QOPT_ENABLE) qtype_bits |= 1 << qtype; } - retval = quota_init_context(&qctx, fs, qtype_bits); if (retval) { com_err(program_name, retval,
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> --- Changes in v2: Logic has been simplified, based on jack@suse.cz feedback. misc/tune2fs.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)