From 925b31e36c3046b5de6b9eacc1f6a8d052690328 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Tue, 22 Apr 2025 13:51:15 +0300 Subject: [PATCH] LU-18944 target: shrink grant depending on free space Shrink grant at targets when it uses more than 25% of left space. Signed-off-by: Sergey Cheremencev Change-Id: I7f2fe97a05e04cce0ac9db82abe4c4bd20f194a0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58926 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Patrick Farrell --- lustre/target/tgt_grant.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lustre/target/tgt_grant.c b/lustre/target/tgt_grant.c index c4e6587..8b436e9 100644 --- a/lustre/target/tgt_grant.c +++ b/lustre/target/tgt_grant.c @@ -62,9 +62,6 @@ static int lbug_on_grant_miscount; module_param(lbug_on_grant_miscount, int, 0644); MODULE_PARM_DESC(lbug_on_grant_miscount, "LBUG on grant miscount"); -/* Clients typically hold 2x their max_rpcs_in_flight of grant space */ -#define TGT_GRANT_SHRINK_LIMIT(exp) (2ULL * 8 * exp_max_brw_size(exp)) - /* Helpers to inflate/deflate grants for clients that do not support the grant * parameters */ static inline u64 tgt_grant_inflate(struct tg_grants_data *tgd, u64 val) @@ -588,8 +585,9 @@ static void tgt_grant_shrink(struct obd_export *exp, struct obdo *oa, assert_spin_locked(&tgd->tgd_grant_lock); LASSERT(exp); - if (left_space >= tgd->tgd_tot_granted_clients * - TGT_GRANT_SHRINK_LIMIT(exp)) + + /* don't need to shrink grant if it uses less than 25% of left space */ + if (tgd->tgd_tot_granted * 4 < left_space) return; grant_shrink = oa->o_grant; -- 1.8.3.1