From: Qian Yingjin Date: Wed, 22 Sep 2021 03:39:19 +0000 (+0800) Subject: EX-3880 pcc: add pcc_async_affinity for async PCC attach X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=72ebb9d975404ccd6bcf80458c9e9b00f18685d2;p=fs%2Flustre-release.git EX-3880 pcc: add pcc_async_affinity for async PCC attach This patch adds a tunable parameter "llite.*.pcc_async_affinity" that enables or disables the CPT selection in PCC-RO asynchronous attach for testing. Signed-off-by: Qian Yingjin Change-Id: I1473a7547555a2d6c615d37182b6cc359194aae0 Reviewed-on: https://review.whamcloud.com/45011 Reviewed-by: Yang Sheng Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 0890a68..fefe5dd 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -651,6 +651,36 @@ static ssize_t pcc_mode_store(struct kobject *kobj, struct attribute *attr, } LUSTRE_RW_ATTR(pcc_mode); +static ssize_t pcc_async_affinity_show(struct kobject *kobj, + struct attribute *attr, char *buffer) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kset.kobj); + struct pcc_super *super = &sbi->ll_pcc_super; + + return sprintf(buffer, "%d\n", super->pccs_async_affinity); +} + +static ssize_t pcc_async_affinity_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, size_t count) +{ + struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, + ll_kset.kobj); + struct pcc_super *super = &sbi->ll_pcc_super; + bool val; + int rc; + + rc = kstrtobool(buffer, &val); + if (rc) + return rc; + + super->pccs_async_affinity = val; + + return count; +} +LUSTRE_RW_ATTR(pcc_async_affinity); + static ssize_t checksums_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -1828,6 +1858,7 @@ static struct attribute *llite_attrs[] = { &lustre_attr_inode_cache.attr, &lustre_attr_pcc_async_threshold.attr, &lustre_attr_pcc_mode.attr, + &lustre_attr_pcc_async_affinity.attr, &lustre_attr_opencache_threshold_count.attr, &lustre_attr_opencache_threshold_ms.attr, &lustre_attr_opencache_max_ms.attr, diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 2febbfc..7fa8b64 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -1790,7 +1790,6 @@ out: static int pcc_readonly_attach_async(struct file *file, struct inode *inode, __u32 roid) { - int node = cfs_cpt_spread_node(cfs_cpt_tab, CFS_CPT_ANY); struct pcc_attach_context *pccx = NULL; struct task_struct *task; int rc; @@ -1805,8 +1804,17 @@ static int pcc_readonly_attach_async(struct file *file, if (!pccx) GOTO(out, rc = -ENOMEM); - task = kthread_create_on_node(pcc_readonly_attach_thread, pccx, node, + if (ll_i2pccs(inode)->pccs_async_affinity) { + /* Create a attach kthread on the current node. */ + task = kthread_create(pcc_readonly_attach_thread, pccx, "ll_pcc_%u", current->pid); + } else { + int node = cfs_cpt_spread_node(cfs_cpt_tab, CFS_CPT_ANY); + + task = kthread_create_on_node(pcc_readonly_attach_thread, pccx, + node, "ll_pcc_%u", current->pid); + } + if (IS_ERR(task)) { rc = PTR_ERR(task); CERROR("%s: can't start ll_pcc thread for "DFID", rc = %d\n", diff --git a/lustre/llite/pcc.h b/lustre/llite/pcc.h index 308b180..8f9a45f 100644 --- a/lustre/llite/pcc.h +++ b/lustre/llite/pcc.h @@ -170,6 +170,7 @@ struct pcc_super { __u64 pccs_generation; /* Size threshold for asynchrous PCC-RO attach in background. */ __u64 pccs_async_threshold; + bool pccs_async_affinity; umode_t pccs_mode; };