Whamcloud - gitweb
LU-17833 ptlrpc: Check lru_resize during connection 60/55060/19
authorDi Wang <di.d.wang@oracle.com>
Wed, 8 May 2024 23:20:40 +0000 (23:20 +0000)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Jul 2024 20:10:53 +0000 (20:10 +0000)
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 <di.d.wang@oracle.com>
Change-Id: I246fcbcd17aa201f80b6950d8eff57489dc81645
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55060
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Patrick Farrell <patrick.farrell@oracle.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_resource.c
lustre/ptlrpc/import.c
lustre/tests/conf-sanity.sh

index 1201927..2f40d6c 100644 (file)
@@ -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.
index 65cde6f..0f11d25 100644 (file)
@@ -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.
                 */
index edc6791..feb38df 100644 (file)
@@ -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)
index 8b5c432..76036ce 100755 (executable)
@@ -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