From: Niu <niu@whamcloud.com>
To: adityakali@google.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 2/3] tune2fs: preserve old limits when turn on quota feature
Date: Sun, 06 Nov 2011 21:39:04 +0800 [thread overview]
Message-ID: <4EB68DF8.7030608@whamcloud.com> (raw)
When turn on quota by tune2fs, if the old quota file exist, the quota
usage should be recomputed but the old limits should be preserved.
Signed-off-by: Niu Yawei <niu@whamcloud.com>
---
misc/tune2fs.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 8bcf667..74a0489 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -700,7 +700,6 @@ err:
void handle_quota_options(ext2_filsys fs)
{
quota_ctx_t qctx;
- errcode_t retval;
ext2_ino_t qf_ino;
if (!usrquota && !grpquota)
@@ -712,15 +711,33 @@ void handle_quota_options(ext2_filsys fs)
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)
+ if (usrquota == QOPT_ENABLE && !fs->super->s_usr_quota_inum) {
+ if ((qf_ino = quota_file_exists(fs, USRQUOTA,
+ QFMT_VFS_V1)) > 0) {
+ if (quota_update_inode(qctx, qf_ino, USRQUOTA) == 0)
+ quota_set_sb_inum(fs, qf_ino, USRQUOTA);
+ else
+ quota_write_inode(qctx, USRQUOTA);
+ } else {
+ quota_write_inode(qctx, USRQUOTA);
+ }
+ } else if (usrquota == QOPT_DISABLE) {
quota_remove_inode(fs, USRQUOTA);
+ }
- if (grpquota == QOPT_ENABLE)
- quota_write_inode(qctx, GRPQUOTA);
- else if (grpquota == QOPT_DISABLE)
+ if (grpquota == QOPT_ENABLE && !fs->super->s_grp_quota_inum) {
+ if ((qf_ino = quota_file_exists(fs, GRPQUOTA,
+ QFMT_VFS_V1)) > 0) {
+ if (quota_update_inode(qctx, qf_ino, GRPQUOTA) == 0)
+ quota_set_sb_inum(fs, qf_ino, GRPQUOTA);
+ else
+ quota_write_inode(qctx, GRPQUOTA);
+ } else {
+ quota_write_inode(qctx, GRPQUOTA);
+ }
+ } else if (grpquota == QOPT_DISABLE) {
quota_remove_inode(fs, GRPQUOTA);
+ }
quota_release_context(&qctx);
-- 1.7.1
next reply other threads:[~2011-11-06 13:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-06 13:39 Niu [this message]
2011-11-14 15:59 ` [PATCH 2/3] tune2fs: preserve old limits when turn on quota feature Ted Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EB68DF8.7030608@whamcloud.com \
--to=niu@whamcloud.com \
--cc=adityakali@google.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).