From: Jan Kara <jack@suse.cz>
To: "zhangyi (F)" <yi.zhang@huawei.com>
Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, miaoxie@huawei.com
Subject: Re: [PATCH] quota: correct space limit check
Date: Mon, 7 Aug 2017 16:49:54 +0200 [thread overview]
Message-ID: <20170807144954.GD6470@quack2.suse.cz> (raw)
In-Reply-To: <1502112905-9525-1-git-send-email-yi.zhang@huawei.com>
On Mon 07-08-17 21:35:05, zhangyi (F) wrote:
> Currently we compare total space (curspace + rsvspace)
> with space limit in quota-tools when setting grace time
> and also in check_bdq(), but we missing rsvspace in
> somewhere else, correct them. This patch also fix incorrect
> zero dqb_btime and grace time updating failure when we use
> rsvspace(e.g. ext4 dalloc feature).
>
> Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Thanks for the patch. I'll merge it through my tree.
Honza
> ---
> fs/quota/dquot.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 53a1749..566e6ef 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -1124,6 +1124,10 @@ void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
> WARN_ON_ONCE(1);
> dquot->dq_dqb.dqb_rsvspace = 0;
> }
> + if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
> + dquot->dq_dqb.dqb_bsoftlimit)
> + dquot->dq_dqb.dqb_btime = (time64_t) 0;
> + clear_bit(DQ_BLKS_B, &dquot->dq_flags);
> }
>
> static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
> @@ -1145,7 +1149,8 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number)
> dquot->dq_dqb.dqb_curspace -= number;
> else
> dquot->dq_dqb.dqb_curspace = 0;
> - if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
> + if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
> + dquot->dq_dqb.dqb_bsoftlimit)
> dquot->dq_dqb.dqb_btime = (time64_t) 0;
> clear_bit(DQ_BLKS_B, &dquot->dq_flags);
> }
> @@ -1381,14 +1386,18 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
>
> static int info_bdq_free(struct dquot *dquot, qsize_t space)
> {
> + qsize_t tspace;
> +
> + tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
> +
> if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
> - dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
> + tspace <= dquot->dq_dqb.dqb_bsoftlimit)
> return QUOTA_NL_NOWARN;
>
> - if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
> + if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
> return QUOTA_NL_BSOFTBELOW;
> - if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
> - dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
> + if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
> + tspace - space < dquot->dq_dqb.dqb_bhardlimit)
> return QUOTA_NL_BHARDBELOW;
> return QUOTA_NL_NOWARN;
> }
> @@ -2681,7 +2690,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
>
> if (check_blim) {
> if (!dm->dqb_bsoftlimit ||
> - dm->dqb_curspace < dm->dqb_bsoftlimit) {
> + dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) {
> dm->dqb_btime = 0;
> clear_bit(DQ_BLKS_B, &dquot->dq_flags);
> } else if (!(di->d_fieldmask & QC_SPC_TIMER))
> --
> 2.5.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2017-08-07 14:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 13:35 [PATCH] quota: correct space limit check zhangyi (F)
2017-08-07 14:49 ` Jan Kara [this message]
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=20170807144954.GD6470@quack2.suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=yi.zhang@huawei.com \
/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).