Commit 17aaa4ae authored by Rusty Russell's avatar Rusty Russell Committed by Philipp Reisner

drdb: use cpumask_var_t in struct drdb_conf

Any code which can be compiled on x86 should try to avoid cpumask_t
(or even struct cpumask) declarations; we are heading towards struct
cpumask being undefined if CONFIG_CPUMASK_OFFSTACK.

The code is the same for CONFIG_CPUMASK_OFFSTACK=n.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 0efb1839
......@@ -1006,7 +1006,7 @@ struct drbd_conf {
spinlock_t peer_seq_lock;
unsigned int minor;
unsigned long comm_bm_set; /* communicated number of set bits. */
cpumask_t cpu_mask;
cpumask_var_t cpu_mask;
struct bm_io_work bm_io_work;
u64 ed_uuid; /* UUID of the exposed data */
struct mutex state_mutex;
......
......@@ -1550,18 +1550,18 @@ void drbd_calc_cpu_mask(struct drbd_conf *mdev)
int ord, cpu;
/* user override. */
if (cpumask_weight(&mdev->cpu_mask))
if (cpumask_weight(mdev->cpu_mask))
return;
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);
cpumask_set_cpu(cpu, mdev->cpu_mask);
return;
}
}
/* should not be reached */
cpumask_setall(&mdev->cpu_mask);
cpumask_setall(mdev->cpu_mask);
}
/**
......@@ -1584,7 +1584,7 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev)
if (!thi->reset_cpu_mask)
return;
thi->reset_cpu_mask = 0;
set_cpus_allowed_ptr(p, &mdev->cpu_mask);
set_cpus_allowed_ptr(p, mdev->cpu_mask);
}
#endif
......@@ -3001,6 +3001,8 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL);
if (!mdev)
return NULL;
if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL))
goto out_no_cpumask;
mdev->minor = minor;
......@@ -3079,6 +3081,8 @@ out_no_io_page:
out_no_disk:
blk_cleanup_queue(q);
out_no_q:
free_cpumask_var(mdev->cpu_mask);
out_no_cpumask:
kfree(mdev);
return NULL;
}
......@@ -3095,6 +3099,7 @@ void drbd_free_mdev(struct drbd_conf *mdev)
__free_page(mdev->md_io_page);
put_disk(mdev->vdisk);
blk_cleanup_queue(mdev->rq_queue);
free_cpumask_var(mdev->cpu_mask);
kfree(mdev);
}
......
......@@ -1657,8 +1657,8 @@ 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 (!cpumask_equal(&mdev->cpu_mask, new_cpu_mask)) {
cpumask_copy(&mdev->cpu_mask, new_cpu_mask);
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;
......
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