From: Di Wang Date: Wed, 8 May 2024 23:20:40 +0000 (+0000) Subject: LU-17833 ptlrpc: Check lru_resize during connection X-Git-Tag: 2.15.65~127 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F55060%2F19;p=fs%2Flustre-release.git LU-17833 ptlrpc: Check lru_resize during connection Since the parameter log processing might finish before connection is established, so it should check if lru size has been disabled by parameters log in ptlrpc_connect_set_flags(). OCI-bug-id: LFS-229 Signed-off-by: Di Wang Change-Id: I246fcbcd17aa201f80b6950d8eff57489dc81645 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55060 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 1201927..2f40d6c 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -575,7 +575,10 @@ struct ldlm_namespace { * Flag to indicate the LRU recalc on RPC reply is in progress. * Used to limit the process by 1 thread only. */ - ns_rpc_recalc:1; + ns_rpc_recalc:1, + + /* lru_size is set even before connection */ + ns_lru_size_set_before_connection:1; /** * Which bucket should we start with the lock reclaim. diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 65cde6f..0f11d25 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -352,6 +352,16 @@ static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, ldlm_ns_name(ns), ns->ns_max_unused, (unsigned int)tmp); + /* This might be done even before connection from param setting + * config log, so it needs to be remembered to make sure + * LRU_SIZE is being set correctly in connection callback. + * See ptlrpc_connect_set_flags(). + */ + spin_lock(&ns->ns_lock); + if (ns->ns_connect_flags == 0) + ns->ns_lru_size_set_before_connection = 1; + spin_unlock(&ns->ns_lock); + /* Make sure that LRU resize was originally supported before * turning it on here. */ diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index edc6791..feb38df 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -938,9 +938,25 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp, CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server flags: %#llx\n", imp->imp_obd->obd_name, ocd->ocd_connect_flags); + + spin_lock(&ns->ns_lock); ns->ns_connect_flags = (ns->ns_connect_flags & changed_flags) | (ocd->ocd_connect_flags & ~changed_flags); ns->ns_orig_connect_flags = ocd->ocd_connect_flags; + /* If lru_size has been set by param set configuration, + * then it should honor param set. + * if ns_max_unused is 0, then it means the param set actually + * set lru_size to 0, i.e. LRU_SIZE should be enabled or set by + * connection result; otherwise it should disable lru_resize. + * see lru_size_store(). + */ + if (ns_connect_lru_resize(ns) && + ns->ns_lru_size_set_before_connection && + ns->ns_max_unused != 0) + ns->ns_connect_flags &= ~OBD_CONNECT_LRU_RESIZE; + + ns->ns_lru_size_set_before_connection = 0; + spin_unlock(&ns->ns_lock); } if (ocd->ocd_connect_flags & OBD_CONNECT_AT) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 8b5c432..76036ce 100755 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -4107,7 +4107,7 @@ test_46a() { } run_test 46a "handle ost additional - wide striped file" -test_47() { #17674 +test_47a() { #17674 reformat setup_noconfig check_mount || error "check_mount failed" @@ -4140,10 +4140,39 @@ test_47() { #17674 fi let count=count+1 done + cleanup || error "cleanup failed with $?" +} +run_test 47a "server restart does not lose lru_resize" + +test_47b() { #17833 + local create_simple_link=false + reformat + setup_noconfig + check_mount || error "check_mount failed" + + [[ -e /usr/sbin/lctl ]] || { + # Unfortunately set_param -P rely on the hardcoded path + # /usr/sbin/lctl + ln -s /usr/sbin/lctl $LCTL || + skip_env "Can not create symlink /usr/sbin/lctl" + stack_trap "rm -f /usr/sbin/lctl" + } + + do_facet mgs $LCTL \ + set_param -P ldlm.namespaces.$FSNAME-*-mdc-*.lru_size=200 + wait_update $HOSTNAME \ + "$LCTL get_param -n ldlm.namespaces.$FSNAME-MDT0000-mdc-*.lru_size" \ + "200" + umount $MOUNT || error "Unable to umount client" + mount_client $MOUNT || error "mount failed" + for ns in $($LCTL get_param ldlm.namespaces.$FSNAME*mdc*.lru_size); do + (( ${ns/*=/} == 200)) || + error "${ns/=*/} is ${ns/*=/}, expect 200" + done cleanup || error "cleanup failed with $?" } -run_test 47 "server restart does not make client loss lru_resize settings" +run_test 47b "client restart does not lose lru_resize" cleanup_48() { trap 0