Whamcloud - gitweb
quota: Rename quota_update_limits() to quota_read_all_dquots()
authorJan Kara <jack@suse.cz>
Mon, 23 Aug 2021 15:41:23 +0000 (17:41 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 3 Sep 2021 18:34:58 +0000 (14:34 -0400)
quota_update_limits() is a misnomer because what it actually does is
that it updates 'usage' counters and leaves 'limit' counters intact.
Rename quota_update_limits() to quota_read_all_dquots() and while
changing prototype also add a flags argument so that callers can control
which quota information is actually updated from the disk.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/super.c
lib/support/mkquota.c
lib/support/quotaio.h
misc/tune2fs.c

index 31e2ffb..4342613 100644 (file)
@@ -281,7 +281,8 @@ static errcode_t e2fsck_read_all_quotas(e2fsck_t ctx)
                if (qf_ino == 0)
                        continue;
 
-               retval = quota_update_limits(ctx->qctx, qf_ino, qtype);
+               retval = quota_read_all_dquots(ctx->qctx, qf_ino, qtype,
+                                              QREAD_USAGE);
                if (retval)
                        break;
        }
index 7500cb2..f1f2e35 100644 (file)
@@ -592,10 +592,11 @@ static errcode_t quota_write_all_dquots(struct quota_handle *qh,
 #endif
 
 /*
- * Updates the in-memory quota limits from the given quota inode.
+ * Read quotas from disk and updates the in-memory information determined by
+ * 'flags' from the on-disk data.
  */
-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino,
-                             enum quota_type qtype)
+errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino,
+                               enum quota_type qtype, unsigned int flags)
 {
        struct scan_dquots_data scan_data;
        struct quota_handle *qh;
@@ -618,8 +619,8 @@ errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino,
 
        scan_data.quota_dict = qctx->quota_dict[qh->qh_type];
        scan_data.check_consistency = 0;
-       scan_data.update_limits = 0;
-       scan_data.update_usage = 1;
+       scan_data.update_limits = !!(flags & QREAD_LIMITS);
+       scan_data.update_usage = !!(flags & QREAD_USAGE);
        qh->qh_ops->scan_dquots(qh, scan_dquots_callback, &scan_data);
 
        err = quota_file_close(qctx, qh);
index 6068970..84fac35 100644 (file)
@@ -224,8 +224,11 @@ void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode,
 void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode,
                    ext2_ino_t ino, qsize_t space);
 errcode_t quota_write_inode(quota_ctx_t qctx, enum quota_type qtype);
-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino,
-                             enum quota_type type);
+/* Flags for quota_read_all_dquots() */
+#define QREAD_USAGE  0x01
+#define QREAD_LIMITS 0x02
+errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino,
+                               enum quota_type type, unsigned int flags);
 errcode_t quota_compute_usage(quota_ctx_t qctx);
 void quota_release_context(quota_ctx_t *qctx);
 errcode_t quota_remove_inode(ext2_filsys fs, enum quota_type qtype);
index 4200104..f459d5d 100644 (file)
@@ -1677,8 +1677,9 @@ static int handle_quota_options(ext2_filsys fs)
                if (quota_enable[qtype] == QOPT_ENABLE &&
                    *quota_sb_inump(fs->super, qtype) == 0) {
                        if ((qf_ino = quota_file_exists(fs, qtype)) > 0) {
-                               retval = quota_update_limits(qctx, qf_ino,
-                                                            qtype);
+                               retval = quota_read_all_dquots(qctx, qf_ino,
+                                                              qtype,
+                                                              QREAD_USAGE);
                                if (retval) {
                                        com_err(program_name, retval,
                                                _("while updating quota limits (%d)"),