Re: [PATCH 02/16] tmpfs: keep the quota soft limits of an unused id
From: Jan Kara
Date: Mon Oct 26 2026 - 07:04:09 EST
On Mon 26-10-26 10:40:35, David Hildenbrand (Arm) wrote:
> From: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
> When the last reference to a dquot goes away, shmem_release_dquot()
> stores its limits in the rb tree of the mount, unless
> shmem_is_empty_dquot() says that there is nothing worth storing. That
> function looks at the usage and at the two hard limits only.
>
> So if the administrator sets nothing but soft limits for an id that owns
> no file yet, the entry is thrown away as soon as the dquot that
> Q_SETQUOTA used is released, and the id never gets to see a limit.
>
> To fix it, compare the soft limits as well: an entry can be empty only if
> both soft limits are zero as well, which is exactly what
> shmem_acquire_dquot() sets for a new entry.
>
> Fix generated by an LLM and sent by Josef Bacik in private.
>
> Fixes: de4c0e7ca8b5 ("shmem: Add default quota limit mount options")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> [ david: slightly adjusted description ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Good spotting although I consider this pretty minor (unlikely setup proven
by the fact nobody complained so far). Feel free to add:
Reviewed-by: Jan Kara <jack@xxxxxxx>
Honza
> ---
> mm/shmem_quota.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/shmem_quota.c b/mm/shmem_quota.c
> index a3fa4bd93e753..43d3b4fd6cb1b 100644
> --- a/mm/shmem_quota.c
> +++ b/mm/shmem_quota.c
> @@ -256,6 +256,8 @@ static bool shmem_is_empty_dquot(struct dquot *dquot)
> if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
> (dquot->dq_dqb.dqb_curspace == 0 &&
> dquot->dq_dqb.dqb_curinodes == 0 &&
> + dquot->dq_dqb.dqb_bsoftlimit == 0 &&
> + dquot->dq_dqb.dqb_isoftlimit == 0 &&
> dquot->dq_dqb.dqb_bhardlimit == bhardlimit &&
> dquot->dq_dqb.dqb_ihardlimit == ihardlimit))
> return true;
>
> --
> 2.43.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR