From 0356990876308f811cc6c61c22946a1cd73e5c23 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Tue, 19 May 2015 00:08:35 -0400 Subject: [PATCH 1/1] LU-6529 ldlm: cancel aged locks for LRUR It doesn't make sense to keep the very aged lock even with the LRUR policy. This patch decreased the default ns_max_age from 10 hours to 65 minutes and changed LRUR policy to cancel very aged locks. Signed-off-by: Niu Yawei Change-Id: Iabf6f50a7837821afcf2a75b6c17c7484b34667f Reviewed-on: http://review.whamcloud.com/14856 Tested-by: Jenkins Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lustre_dlm.h | 2 +- lustre/ldlm/ldlm_request.c | 6 ++++++ lustre/tests/sanity.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 1935e2f..192bb84 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -63,7 +63,7 @@ struct obd_device; #define OBD_LDLM_DEVICENAME "ldlm" #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) -#define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(36000)) +#define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(3900)) /* 65 min */ #define LDLM_CTIME_AGE_LIMIT (10) #define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024 diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 54ecbdd..684062f 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -1480,6 +1480,12 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, if (count && added >= count) return LDLM_POLICY_KEEP_LOCK; + /* Despite of the LV, It doesn't make sense to keep the lock which + * is unused for ns_max_age time. */ + if (cfs_time_after(cfs_time_current(), + cfs_time_add(lock->l_last_used, ns->ns_max_age))) + return LDLM_POLICY_CANCEL_LOCK; + slv = ldlm_pool_get_slv(pl); lvf = ldlm_pool_get_lvf(pl); la = cfs_duration_sec(cfs_time_sub(cur, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7bb9c3a..e7747e5 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8395,6 +8395,38 @@ test_124b() { } run_test 124b "lru resize (performance test) =======================" +test_124c() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] && + skip "no lru resize on server" && return 0 + + # cache ununsed locks on client + local nr=100 + cancel_lru_locks mdc + test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir" + createmany -o $DIR/$tdir/f $nr || + error "failed to create $nr files in $DIR/$tdir" + ls -l $DIR/$tdir > /dev/null + + local nsdir="ldlm.namespaces.*-MDT0000-mdc-*" + local unused=$($LCTL get_param -n $nsdir.lock_unused_count) + local max_age=$($LCTL get_param -n $nsdir.lru_max_age) + local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period) + echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p" + + # set lru_max_age to 1 sec + $LCTL set_param $nsdir.lru_max_age=1000 # jiffies + echo "sleep $((recalc_p * 2)) seconds..." + sleep $((recalc_p * 2)) + + local remaining=$($LCTL get_param -n $nsdir.lock_unused_count) + # restore lru_max_age + $LCTL set_param -n $nsdir.lru_max_age $max_age + [ $remaining -eq 0 ] || error "$remaining locks are not canceled" + unlinkmany $DIR/$tdir/f $nr +} +run_test 124c "LRUR cancel very aged locks" + test_125() { # 13358 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return -- 1.8.3.1