Commit feb2ddbd authored by Philipp Reisner's avatar Philipp Reisner

follow cpumask api change

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent cf7fead8
...@@ -1081,10 +1081,10 @@ extern int drbd_thread_start(struct drbd_thread *thi); ...@@ -1081,10 +1081,10 @@ extern int drbd_thread_start(struct drbd_thread *thi);
extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait); extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
extern void drbd_thread_current_set_cpu(struct drbd_conf *mdev); extern void drbd_thread_current_set_cpu(struct drbd_conf *mdev);
extern cpumask_t drbd_calc_cpu_mask(struct drbd_conf *mdev); extern void drbd_calc_cpu_mask(struct drbd_conf *mdev);
#else #else
#define drbd_thread_current_set_cpu(A) ({}) #define drbd_thread_current_set_cpu(A) ({})
#define drbd_calc_cpu_mask(A) CPU_MASK_ALL #define drbd_calc_cpu_mask(A) ({})
#endif #endif
extern void drbd_free_resources(struct drbd_conf *mdev); extern void drbd_free_resources(struct drbd_conf *mdev);
extern void tl_release(struct drbd_conf *mdev, unsigned int barrier_nr, extern void tl_release(struct drbd_conf *mdev, unsigned int barrier_nr,
......
...@@ -1545,25 +1545,23 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait) ...@@ -1545,25 +1545,23 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
* Forces all threads of a device onto the same CPU. This is benificial for * Forces all threads of a device onto the same CPU. This is benificial for
* DRBD's performance. May be overwritten by user's configuration. * DRBD's performance. May be overwritten by user's configuration.
*/ */
cpumask_t drbd_calc_cpu_mask(struct drbd_conf *mdev) void drbd_calc_cpu_mask(struct drbd_conf *mdev)
{ {
int sv, cpu; int ord, cpu;
cpumask_t av_cpu_m;
if (cpus_weight(mdev->cpu_mask)) /* user override. */
return mdev->cpu_mask; if (cpumask_weight(&mdev->cpu_mask))
return;
av_cpu_m = cpu_online_map;
sv = mdev_to_minor(mdev) % cpus_weight(av_cpu_m);
for_each_cpu_mask(cpu, av_cpu_m) { ord = mdev_to_minor(mdev) % cpumask_weight(cpu_online_mask);
if (sv-- == 0) for_each_online_cpu(cpu) {
return cpumask_of_cpu(cpu); if (ord-- == 0) {
cpumask_set_cpu(cpu, &mdev->cpu_mask);
return;
}
} }
/* should not be reached */
/* some kernel versions "forget" to add the (cpumask_t) typecast cpumask_setall(&mdev->cpu_mask);
* to that macro, which results in "parse error before '{'" ;-> */
return (cpumask_t) CPU_MASK_ALL; /* Never reached. */
} }
/** /**
...@@ -1586,11 +1584,7 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev) ...@@ -1586,11 +1584,7 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev)
if (!thi->reset_cpu_mask) if (!thi->reset_cpu_mask)
return; return;
thi->reset_cpu_mask = 0; thi->reset_cpu_mask = 0;
/* preempt_disable(); set_cpus_allowed_ptr(p, &mdev->cpu_mask);
Thas was a kernel that warned about a call to smp_processor_id() while preemt
was not disabled. It seems that this was fixed in manline. */
set_cpus_allowed(p, mdev->cpu_mask);
/* preempt_enable(); */
} }
#endif #endif
......
...@@ -1524,16 +1524,20 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n ...@@ -1524,16 +1524,20 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n
struct crypto_hash *verify_tfm = NULL; struct crypto_hash *verify_tfm = NULL;
struct crypto_hash *csums_tfm = NULL; struct crypto_hash *csums_tfm = NULL;
struct syncer_conf sc; struct syncer_conf sc;
cpumask_t n_cpu_mask = CPU_MASK_NONE; cpumask_var_t new_cpu_mask;
memcpy(&sc, &mdev->sync_conf, sizeof(struct syncer_conf)); if (!zalloc_cpumask_var(&new_cpu_mask, GFP_KERNEL)) {
retcode = ERR_NOMEM;
goto fail;
}
if (nlp->flags & DRBD_NL_SET_DEFAULTS) { if (nlp->flags & DRBD_NL_SET_DEFAULTS) {
memset(&sc, 0, sizeof(struct syncer_conf)); memset(&sc, 0, sizeof(struct syncer_conf));
sc.rate = DRBD_RATE_DEF; sc.rate = DRBD_RATE_DEF;
sc.after = DRBD_AFTER_DEF; sc.after = DRBD_AFTER_DEF;
sc.al_extents = DRBD_AL_EXTENTS_DEF; sc.al_extents = DRBD_AL_EXTENTS_DEF;
} } else
memcpy(&sc, &mdev->sync_conf, sizeof(struct syncer_conf));
if (!syncer_conf_from_tags(mdev, nlp->tag_list, &sc)) { if (!syncer_conf_from_tags(mdev, nlp->tag_list, &sc)) {
retcode = ERR_MANDATORY_TAG; retcode = ERR_MANDATORY_TAG;
...@@ -1590,8 +1594,9 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n ...@@ -1590,8 +1594,9 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n
} }
/* silently ignore cpu mask on UP kernel */ /* silently ignore cpu mask on UP kernel */
if (NR_CPUS > 1 && sc.cpu_mask[0] != 0) { if (nr_cpu_ids > 1 && sc.cpu_mask[0] != 0) {
err = __bitmap_parse(sc.cpu_mask, 32, 0, (unsigned long *)&n_cpu_mask, NR_CPUS); err = __bitmap_parse(sc.cpu_mask, 32, 0,
cpumask_bits(new_cpu_mask), nr_cpu_ids);
if (err) { if (err) {
dev_warn(DEV, "__bitmap_parse() failed with %d\n", err); dev_warn(DEV, "__bitmap_parse() failed with %d\n", err);
retcode = ERR_CPU_MASK_PARSE; retcode = ERR_CPU_MASK_PARSE;
...@@ -1652,9 +1657,9 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n ...@@ -1652,9 +1657,9 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n
if (mdev->state.conn >= C_CONNECTED) if (mdev->state.conn >= C_CONNECTED)
drbd_send_sync_param(mdev, &sc); drbd_send_sync_param(mdev, &sc);
if (!cpus_equal(mdev->cpu_mask, n_cpu_mask)) { if (!cpumask_equal(&mdev->cpu_mask, new_cpu_mask)) {
mdev->cpu_mask = n_cpu_mask; cpumask_copy(&mdev->cpu_mask, new_cpu_mask);
mdev->cpu_mask = drbd_calc_cpu_mask(mdev); drbd_calc_cpu_mask(mdev);
mdev->receiver.reset_cpu_mask = 1; mdev->receiver.reset_cpu_mask = 1;
mdev->asender.reset_cpu_mask = 1; mdev->asender.reset_cpu_mask = 1;
mdev->worker.reset_cpu_mask = 1; mdev->worker.reset_cpu_mask = 1;
...@@ -1662,6 +1667,7 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n ...@@ -1662,6 +1667,7 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE); kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
fail: fail:
free_cpumask_var(new_cpu_mask);
crypto_free_hash(csums_tfm); crypto_free_hash(csums_tfm);
crypto_free_hash(verify_tfm); crypto_free_hash(verify_tfm);
reply->ret_code = retcode; reply->ret_code = retcode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment