Patchwork [2/3] tune2fs: Compute quota usage when turning on the 'quota' feature

login
register
mail settings
Submitter Aditya Kali
Date Nov. 4, 2011, 12:18 a.m.
Message ID <1320365913-25857-2-git-send-email-adityakali@google.com>
Download mbox | patch
Permalink /patch/123533/
State Accepted
Headers show

Comments

Aditya Kali - Nov. 4, 2011, 12:18 a.m.
When turning on the quota feature, tune2fs would create empty quota inodes and
set their inode numbers in superblock. This required e2fsck to be ran before
using the quota feature. This patch adds adds call to compute_quota() and make
sure that we write correct quota information in the quota files at tune2fs time
itself. This gets rid of the necessity for running e2fsck after setting the
quota feature. Also, tune2fs now does not use existing old quota files
(aquota.user and aquota.group) even if they exist.

Signed-off-by: Aditya Kali <adityakali@google.com>
---
 misc/tune2fs.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)
Theodore Ts'o - Nov. 14, 2011, 3:57 p.m.
On Thu, Nov 03, 2011 at 05:18:32PM -0700, Aditya Kali wrote:
> When turning on the quota feature, tune2fs would create empty quota inodes and
> set their inode numbers in superblock. This required e2fsck to be ran before
> using the quota feature. This patch adds adds call to compute_quota() and make
> sure that we write correct quota information in the quota files at tune2fs time
> itself. This gets rid of the necessity for running e2fsck after setting the
> quota feature. Also, tune2fs now does not use existing old quota files
> (aquota.user and aquota.group) even if they exist.
> 
> Signed-off-by: Aditya Kali <adityakali@google.com>

Thanks, applied.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 112b258..8bcf667 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -709,23 +709,18 @@  void handle_quota_options(ext2_filsys fs)
 
 	quota_init_context(&qctx, fs, -1);
 
-	if (usrquota == QOPT_ENABLE && !fs->super->s_usr_quota_inum) {
-		if ((qf_ino = quota_file_exists(fs, USRQUOTA, QFMT_VFS_V1)) > 0)
-			quota_set_sb_inum(fs, qf_ino, USRQUOTA);
-		else
-			quota_write_inode(qctx, USRQUOTA);
-	} else if (usrquota == QOPT_DISABLE) {
+	if (usrquota == QOPT_ENABLE || grpquota == QOPT_ENABLE)
+		quota_compute_usage(qctx);
+
+	if (usrquota == QOPT_ENABLE)
+		quota_write_inode(qctx, USRQUOTA);
+	else if (usrquota == QOPT_DISABLE)
 		quota_remove_inode(fs, USRQUOTA);
-	}
 
-	if (grpquota == QOPT_ENABLE && !fs->super->s_grp_quota_inum) {
-		if ((qf_ino = quota_file_exists(fs, GRPQUOTA, QFMT_VFS_V1)) > 0)
-			quota_set_sb_inum(fs, qf_ino, GRPQUOTA);
-		else
-			quota_write_inode(qctx, GRPQUOTA);
-	} else if (grpquota == QOPT_DISABLE) {
+	if (grpquota == QOPT_ENABLE)
+		quota_write_inode(qctx, GRPQUOTA);
+	else if (grpquota == QOPT_DISABLE)
 		quota_remove_inode(fs, GRPQUOTA);
-	}
 
 	quota_release_context(&qctx);