uniontech inclusion category: bugfix bugzilla: NA CVE: NA
------------------
We record the socket_num for calculate persister num, why don't we direct record persister num?
Signed-off-by: Gou Hao gouhao@uniontech.com --- fs/eulerfs/dep.c | 24 +++++++++++------------- fs/eulerfs/euler_def.h | 2 +- fs/eulerfs/super.c | 8 ++++---- 3 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/fs/eulerfs/dep.c b/fs/eulerfs/dep.c index e85130f7eddc..da826a18fa31 100644 --- a/fs/eulerfs/dep.c +++ b/fs/eulerfs/dep.c @@ -677,7 +677,7 @@ static int persister(void *data) /* more than a second */ (HZ * persist_period)); int idx = 0; - int num_persisters = sbi->socket_num * persisters_per_socket; + int num_persisters = sbi->persister_num;
eufs_info("sb=%px cpu=%d cpumask=%*pbl period=%d\n", data, smp_processor_id(), cpumask_pr_args(mask), period); @@ -707,7 +707,7 @@ int dep_init(struct super_block *sb) int cpu, j; char name[BDEVNAME_SIZE]; int err; - int socket_num, node; + int node_num, node; unsigned long node_mask;
sbi->persistee_list = alloc_percpu(struct llist_head); @@ -716,29 +716,27 @@ int dep_init(struct super_block *sb) goto cleanup; }
- socket_num = node_mask = 0; + node_num = node_mask = 0; for_each_online_cpu(cpu) { /* init each llist */ init_llist_head(per_cpu_ptr(sbi->persistee_list, cpu)); node = cpu_to_node(cpu); node_mask |= 1 << node; - if (node > socket_num) - socket_num++; + if (node > node_num) + node_num++; } - socket_num++; + node_num++;
- sbi->socket_num = socket_num; + sbi->persister_num = node_num * persisters_per_socket;
sbi->persisters = kmalloc(sizeof(struct task_struct *) * - persisters_per_socket * socket_num, - GFP_KERNEL); + sbi->persister_num, GFP_KERNEL); if (!sbi->persisters) { err = -ENOMEM; goto cleanup; }
- sbi->need_sync = kzalloc( - sizeof(bool) * persisters_per_socket * socket_num, GFP_KERNEL); + sbi->need_sync = kzalloc(sizeof(bool) * sbi->persister_num, GFP_KERNEL); if (!sbi->need_sync) { err = -ENOMEM; goto cleanup; @@ -784,11 +782,11 @@ int dep_init(struct super_block *sb) void dep_fini(struct super_block *sb) { struct eufs_sb_info *sbi = EUFS_SB(sb); - int socket_num = sbi->socket_num; + int persister_num = sbi->persister_num; if (sbi->persisters) { int i;
- for (i = 0; i < persisters_per_socket * socket_num; ++i) { + for (i = 0; i < persister_num; ++i) { if (sbi->persisters[i]) { kthread_stop(sbi->persisters[i]); sbi->persisters[i] = NULL; diff --git a/fs/eulerfs/euler_def.h b/fs/eulerfs/euler_def.h index cca190c43439..4513ff1d3887 100644 --- a/fs/eulerfs/euler_def.h +++ b/fs/eulerfs/euler_def.h @@ -179,7 +179,7 @@ struct eufs_sb_info { bool *need_sync; /* for fssync */ wait_queue_head_t sync_wq; /* for fssync's thread */ struct mutex sync_mutex; /* serialize fssync request */ - int socket_num; + int persister_num; /* End of Persister */
/* The word `draining` is reserved for volatility quota limitation */ diff --git a/fs/eulerfs/super.c b/fs/eulerfs/super.c index db6ad3497e1b..6f888debbb46 100644 --- a/fs/eulerfs/super.c +++ b/fs/eulerfs/super.c @@ -686,7 +686,7 @@ static int eufs_sync_fs(struct super_block *sb, int sync) { struct eufs_sb_info *sbi = EUFS_SB(sb); int i; - int num_persisters = sbi->socket_num * persisters_per_socket; + int persister_num = sbi->persister_num; int wait_flag;
if (!sync) @@ -694,16 +694,16 @@ static int eufs_sync_fs(struct super_block *sb, int sync)
mutex_lock(&sbi->sync_mutex);
- for (i = 0; i < num_persisters; i++) + for (i = 0; i < persister_num; i++) sbi->need_sync[i] = true;
/* FIXME: Persisters may miss the wake-up message. */ - for (i = 0; i < num_persisters; ++i) + for (i = 0; i < persister_num; ++i) wake_up_process(sbi->persisters[i]);
do { wait_flag = false; - for (i = 0; i < num_persisters; i++) { + for (i = 0; i < persister_num; i++) { if (sbi->need_sync[i] == false) continue; wait_flag = true;