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);
extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait);
#ifdef CONFIG_SMP
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
#define drbd_thread_current_set_cpu(A) ({})
#define drbd_calc_cpu_mask(A) CPU_MASK_ALL
#define drbd_calc_cpu_mask(A) ({})
#endif
extern void drbd_free_resources(struct drbd_conf *mdev);
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)
* Forces all threads of a device onto the same CPU. This is benificial for
* 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;
cpumask_t av_cpu_m;
int ord, cpu;
if (cpus_weight(mdev->cpu_mask))
return mdev->cpu_mask;
av_cpu_m = cpu_online_map;
sv = mdev_to_minor(mdev) % cpus_weight(av_cpu_m);
/* user override. */
if (cpumask_weight(&mdev->cpu_mask))
return;
for_each_cpu_mask(cpu, av_cpu_m) {
if (sv-- == 0)
return cpumask_of_cpu(cpu);
ord = mdev_to_minor(mdev) % cpumask_weight(cpu_online_mask);
for_each_online_cpu(cpu) {
if (ord-- == 0) {
cpumask_set_cpu(cpu, &mdev->cpu_mask);
return;
}
}
/* some kernel versions "forget" to add the (cpumask_t) typecast
* to that macro, which results in "parse error before '{'" ;-> */
return (cpumask_t) CPU_MASK_ALL; /* Never reached. */
/* should not be reached */
cpumask_setall(&mdev->cpu_mask);
}
/**
......@@ -1586,11 +1584,7 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev)
if (!thi->reset_cpu_mask)
return;
thi->reset_cpu_mask = 0;
/* preempt_disable();
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(); */
set_cpus_allowed_ptr(p, &mdev->cpu_mask);
}
#endif
......
......@@ -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 *csums_tfm = NULL;
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) {
memset(&sc, 0, sizeof(struct syncer_conf));
sc.rate = DRBD_RATE_DEF;
sc.after = DRBD_AFTER_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)) {
retcode = ERR_MANDATORY_TAG;
......@@ -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 */
if (NR_CPUS > 1 && sc.cpu_mask[0] != 0) {
err = __bitmap_parse(sc.cpu_mask, 32, 0, (unsigned long *)&n_cpu_mask, NR_CPUS);
if (nr_cpu_ids > 1 && sc.cpu_mask[0] != 0) {
err = __bitmap_parse(sc.cpu_mask, 32, 0,
cpumask_bits(new_cpu_mask), nr_cpu_ids);
if (err) {
dev_warn(DEV, "__bitmap_parse() failed with %d\n", err);
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
if (mdev->state.conn >= C_CONNECTED)
drbd_send_sync_param(mdev, &sc);
if (!cpus_equal(mdev->cpu_mask, n_cpu_mask)) {
mdev->cpu_mask = n_cpu_mask;
mdev->cpu_mask = drbd_calc_cpu_mask(mdev);
if (!cpumask_equal(&mdev->cpu_mask, new_cpu_mask)) {
cpumask_copy(&mdev->cpu_mask, new_cpu_mask);
drbd_calc_cpu_mask(mdev);
mdev->receiver.reset_cpu_mask = 1;
mdev->asender.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
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
fail:
free_cpumask_var(new_cpu_mask);
crypto_free_hash(csums_tfm);
crypto_free_hash(verify_tfm);
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