uniontech inclusion category: bugfix bugzilla: NA CVE: NA
----------------------
We should not get the socket num in init_eufs_fs, becuse system usually supports cpu hotplug,so we should get socket num in dep_int.
Socket num is not necessarily the same when file system mount,so it shoule be eufs_sb_info's member.
Signed-off-by: Gou Hao gouhao@uniontech.com --- fs/eulerfs/dep.c | 28 ++++++++++++++++++++++------ fs/eulerfs/euler.h | 2 -- fs/eulerfs/euler_def.h | 1 + fs/eulerfs/super.c | 15 +-------------- 4 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/fs/eulerfs/dep.c b/fs/eulerfs/dep.c index ec014bbf3700..4f8bad75c0c3 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 = num_sockets * persisters_per_socket; + int num_persisters = sbi->socket_num * persisters_per_socket;
eufs_info("sb=%px cpu=%d cpumask=%*pbl period=%d\n", data, smp_processor_id(), cpumask_pr_args(mask), period); @@ -700,6 +700,19 @@ static int persister(void *data) return 0; }
+static inline int get_socket_num(void) +{ + int num = 0; + int cpu, sock; + for_each_possible_cpu(cpu) { + sock = cpu_to_node(cpu); + if (sock > num) + num = sock; + } + num += 1; + return num; +} + int dep_init(struct super_block *sb) { struct eufs_sb_info *sbi = EUFS_SB(sb); @@ -707,6 +720,7 @@ int dep_init(struct super_block *sb) int i, j; char name[BDEVNAME_SIZE]; int err; + int socket_num = get_socket_num();
sbi->persistee_list = alloc_percpu(struct llist_head); if (!sbi->persistee_list) { @@ -714,12 +728,14 @@ int dep_init(struct super_block *sb) goto cleanup; }
+ sbi->socket_num = socket_num; + /* init each llist */ for_each_possible_cpu(cpu) init_llist_head(per_cpu_ptr(sbi->persistee_list, cpu));
sbi->persisters = kmalloc(sizeof(struct task_struct *) * - persisters_per_socket * num_sockets, + persisters_per_socket * socket_num, GFP_KERNEL); if (!sbi->persisters) { err = -ENOMEM; @@ -727,7 +743,7 @@ int dep_init(struct super_block *sb) }
sbi->need_sync = kzalloc( - sizeof(bool) * persisters_per_socket * num_sockets, GFP_KERNEL); + sizeof(bool) * persisters_per_socket * socket_num, GFP_KERNEL); if (!sbi->need_sync) { err = -ENOMEM; goto cleanup; @@ -736,7 +752,7 @@ int dep_init(struct super_block *sb) init_waitqueue_head(&sbi->sync_wq);
bdevname(sb->s_bdev, name); - for (i = 0; i < num_sockets; ++i) { + for (i = 0; i < socket_num; ++i) { for (j = 0; j < persisters_per_socket; ++j) { int idx = i * persisters_per_socket + j;
@@ -768,11 +784,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; if (sbi->persisters) { int i;
- for (i = 0; i < persisters_per_socket * num_sockets; ++i) { + for (i = 0; i < persisters_per_socket * socket_num; ++i) { if (sbi->persisters[i]) { kthread_stop(sbi->persisters[i]); sbi->persisters[i] = NULL; diff --git a/fs/eulerfs/euler.h b/fs/eulerfs/euler.h index 0abb7602bb63..71201f9a61b2 100644 --- a/fs/eulerfs/euler.h +++ b/fs/eulerfs/euler.h @@ -57,8 +57,6 @@ #include "inode.h" #include "nvalloc.h"
-extern int num_sockets; - /* Function Prototypes */ extern __printf(2, 3) void eufs_error_mng(struct super_block *sb, const char *fmt, ...); diff --git a/fs/eulerfs/euler_def.h b/fs/eulerfs/euler_def.h index 727f1c4cf181..cca190c43439 100644 --- a/fs/eulerfs/euler_def.h +++ b/fs/eulerfs/euler_def.h @@ -179,6 +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; /* 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 43fc717002d7..db6ad3497e1b 100644 --- a/fs/eulerfs/super.c +++ b/fs/eulerfs/super.c @@ -72,8 +72,6 @@ module_param(wear_alloc_threshold, int, 0444); MODULE_PARM_DESC(wear_alloc_threshold, "Wear leveling threshold for allocation");
-int num_sockets; - static struct super_operations eufs_sops;
void eufs_error_mng(struct super_block *sb, const char *fmt, ...) @@ -688,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 = num_sockets * persisters_per_socket; + int num_persisters = sbi->socket_num * persisters_per_socket; int wait_flag;
if (!sync) @@ -752,7 +750,6 @@ static struct file_system_type eufs_fs_type = { static int __init init_eufs_fs(void) { int rc = 0; - int cpu;
BUILD_BUG_ON(sizeof(struct eufs_renamej) != 2 * CACHELINE_SIZE);
@@ -772,16 +769,6 @@ static int __init init_eufs_fs(void) if (rc) goto out4;
- num_sockets = 0; - for_each_possible_cpu(cpu) { - int sock = cpu_to_node(cpu); - - if (sock > num_sockets) - num_sockets = sock; - } - num_sockets += 1; - eufs_info("Num socket: %d\n", num_sockets); - eufs_show_params();
return 0;