From: Mikhail Pershin Date: Mon, 23 Apr 2018 07:48:53 +0000 (+0300) Subject: LU-10413 ldlm: expose dirty age limit for flush-on-glimpse X-Git-Tag: 2.11.52~19 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=69727e45b4c0194f97c74df65b45fbf6a23235c4 LU-10413 ldlm: expose dirty age limit for flush-on-glimpse Glimpse request may cancel old lock and cause data flush. That helps to cache stat results on client locally early. The time limit was hardcoded to 10s and is exposed now as ns_dirty_age_limit namespace value, it can be set/check via /sys/fs/lustre/ldlm/namespaces//dirty_age_limit Signed-off-by: Mikhail Pershin Change-Id: Ie5b74eeb1720d552ab3f667e38af3925855f40ac Reviewed-on: https://review.whamcloud.com/32113 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index c400795..d8ecc3b 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -64,6 +64,9 @@ extern struct kset *ldlm_svc_kset; #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) #define LDLM_DEFAULT_MAX_ALIVE 3900 /* 3900 seconds ~65 min */ #define LDLM_CTIME_AGE_LIMIT (10) +/* if client lock is unused for that time it can be cancelled if any other + * client shows interest in that lock, e.g. glimpse is occured. */ +#define LDLM_DIRTY_AGE_LIMIT (10) #define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024 /** @@ -438,7 +441,13 @@ struct ldlm_namespace { * for a directory and may save an RPC for a later stat. */ time64_t ns_ctime_age_limit; - + /** + * Number of seconds since the lock was last used. The client may + * cancel the lock limited by this age and flush related data if + * any other client shows interest in it doing glimpse request. + * This allows to cache stat data locally for such files early. + */ + time64_t ns_dirty_age_limit; /** * Used to rate-limit ldlm_namespace_dump calls. * \see ldlm_namespace_dump. Increased by 10 seconds every time diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 122c284..e485b30 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1772,7 +1772,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, !lock->l_readers && !lock->l_writers && ktime_after(ktime_get(), ktime_add(lock->l_last_used, - ktime_set(10, 0)))) { + ktime_set(ns->ns_dirty_age_limit, 0)))) { unlock_res_and_lock(lock); if (ldlm_bl_to_thread_lock(ns, NULL, lock)) ldlm_handle_bl_callback(ns, NULL, lock); diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 4c4bc96..0bf6af5 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -490,6 +490,32 @@ static ssize_t early_lock_cancel_store(struct kobject *kobj, } LUSTRE_RW_ATTR(early_lock_cancel); +static ssize_t dirty_age_limit_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + + return sprintf(buf, "%llu\n", ns->ns_dirty_age_limit); +} + +static ssize_t dirty_age_limit_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, size_t count) +{ + struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, + ns_kobj); + unsigned long long tmp; + + if (kstrtoull(buffer, 10, &tmp)) + return -EINVAL; + + ns->ns_dirty_age_limit = tmp; + + return count; +} +LUSTRE_RW_ATTR(dirty_age_limit); + #ifdef HAVE_SERVER_SUPPORT static ssize_t ctime_age_limit_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -647,6 +673,7 @@ static struct attribute *ldlm_ns_attrs[] = { &lustre_attr_lru_size.attr, &lustre_attr_lru_max_age.attr, &lustre_attr_early_lock_cancel.attr, + &lustre_attr_dirty_age_limit.attr, #ifdef HAVE_SERVER_SUPPORT &lustre_attr_ctime_age_limit.attr, &lustre_attr_lock_timeouts.attr, @@ -960,6 +987,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE; ns->ns_max_age = ktime_set(LDLM_DEFAULT_MAX_ALIVE, 0); ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT; + ns->ns_dirty_age_limit = LDLM_DIRTY_AGE_LIMIT; ns->ns_timeouts = 0; ns->ns_orig_connect_flags = 0; ns->ns_connect_flags = 0;