lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7B432201-71B8-4569-BAD3-805477B4D226@dilger.ca>
Date:   Fri, 18 Nov 2022 07:42:04 -0600
From:   Andreas Dilger <adilger@...ger.ca>
To:     "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Cc:     Theodore Ts'o <tytso@....edu>, linux-ext4@...r.kernel.org,
        Harshad Shirwadkar <harshadshirwadkar@...il.com>,
        Wang Shilong <wshilong@....com>,
        Andreas Dilger <adilger.kernel@...ger.ca>, Li Xi <lixi@....com>
Subject: Re: [RFCv1 11/72] libext2fs: merge quota context after threads finish

On Nov 7, 2022, at 06:23, Ritesh Harjani (IBM) <ritesh.list@...il.com> wrote:
> 
> From: Wang Shilong <wshilong@....com>
> 
> Every threads calculate its own quota accounting,
> merge them after threads finish.
> 
> Signed-off-by: Wang Shilong <wshilong@....com>
> [Note: splitted the patch to seperate libext2fs changes from e2fsck]
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>

Reviewed-by: Andreas Dilger <adilger@...ger.ca>

> ---
> lib/support/mkquota.c | 39 +++++++++++++++++++++++++++++++++++++++
> lib/support/quotaio.h |  3 +++
> 2 files changed, 42 insertions(+)
> 
> diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c
> index 9339c994..ce1ab4cd 100644
> --- a/lib/support/mkquota.c
> +++ b/lib/support/mkquota.c
> @@ -618,6 +618,45 @@ out:
>    return err;
> }
> 
> +static errcode_t merge_usage(dict_t *dest, dict_t *src)
> +{
> +    dnode_t *n;
> +    struct dquot *src_dq, *dest_dq;
> +
> +    for (n = dict_first(src); n; n = dict_next(src, n)) {
> +        src_dq = dnode_get(n);
> +        if (!src_dq)
> +            continue;
> +        dest_dq = get_dq(dest, src_dq->dq_id);
> +        if (dest_dq == NULL)
> +            return -ENOMEM;
> +        dest_dq->dq_dqb.dqb_curspace += src_dq->dq_dqb.dqb_curspace;
> +        dest_dq->dq_dqb.dqb_curinodes += src_dq->dq_dqb.dqb_curinodes;
> +    }
> +
> +    return 0;
> +}
> +
> +
> +errcode_t quota_merge_and_update_usage(quota_ctx_t dest_qctx,
> +                    quota_ctx_t src_qctx)
> +{
> +    dict_t *dict;
> +    enum quota_type    qtype;
> +    errcode_t retval = 0;
> +
> +    for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
> +        dict = src_qctx->quota_dict[qtype];
> +        if (!dict)
> +            continue;
> +        retval = merge_usage(dest_qctx->quota_dict[qtype], dict);
> +        if (retval)
> +            break;
> +    }
> +
> +    return retval;
> +}
> +
> /*
>  * Compares the measured quota in qctx->quota_dict with that in the quota inode
>  * on disk and updates the limits in qctx->quota_dict. 'usage_inconsistent' is
> diff --git a/lib/support/quotaio.h b/lib/support/quotaio.h
> index 84fac35d..240a0762 100644
> --- a/lib/support/quotaio.h
> +++ b/lib/support/quotaio.h
> @@ -40,6 +40,7 @@
> #include "ext2fs/ext2_fs.h"
> #include "ext2fs/ext2fs.h"
> #include "dqblk_v2.h"
> +#include "support/dict.h"
> 
> typedef int64_t qsize_t;    /* Type in which we store size limitations */
> 
> @@ -236,6 +237,8 @@ int quota_file_exists(ext2_filsys fs, enum quota_type qtype);
> void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype);
> errcode_t quota_compare_and_update(quota_ctx_t qctx, enum quota_type qtype,
>                   int *usage_inconsistent);
> +errcode_t quota_merge_and_update_usage(quota_ctx_t dest_qctx,
> +                    quota_ctx_t src_qctx);
> int parse_quota_opts(const char *opts, int (*func)(char *));
> 
> /* parse_qtype.c */
> -- 
> 2.37.3
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ