diff options
author | Niu <niu@whamcloud.com> | 2011-11-14 10:58:28 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-11-14 10:58:28 -0500 |
commit | cdfaa75901a66d02fa23f100e0346934371c3753 (patch) | |
tree | 8bf9b39d74ca8138a290a6c91930641de4431f8a | |
parent | 198d20fc74a6124548b96e4c14c38ff8d5a95ae5 (diff) | |
download | e2fsprogs-cdfaa75901a66d02fa23f100e0346934371c3753.tar.gz |
tune2fs: preserve old limits when turn on quota feature
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | misc/tune2fs.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 8bcf6672..74a04890 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); |