diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-06-16 11:58:02 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:57:46 -0500 |
commit | afbbfa88bc506bc13b957c3811bce299de1d31d5 (patch) | |
tree | edb0be8cfb2ecc1fcd4c8bd93bce96f852be4b59 /drivers/block/drbd/drbd_main.c | |
parent | 089c075d88ac9407b8d7c5c8fc4b21c0d940bd82 (diff) |
drbd: Allow to pass resource options to the new-resource command
This is equivalent to how the attach and connect commands work.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 79f275dc43a4..933d4767c110 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -2479,8 +2479,47 @@ void conn_free_crypto(struct drbd_tconn *tconn) | |||
2479 | tconn->int_dig_vv = NULL; | 2479 | tconn->int_dig_vv = NULL; |
2480 | } | 2480 | } |
2481 | 2481 | ||
2482 | int set_resource_options(struct drbd_tconn *tconn, struct res_opts *res_opts) | ||
2483 | { | ||
2484 | cpumask_var_t new_cpu_mask; | ||
2485 | int err; | ||
2486 | |||
2487 | if (!zalloc_cpumask_var(&new_cpu_mask, GFP_KERNEL)) | ||
2488 | return -ENOMEM; | ||
2489 | /* | ||
2490 | retcode = ERR_NOMEM; | ||
2491 | drbd_msg_put_info("unable to allocate cpumask"); | ||
2492 | */ | ||
2493 | |||
2494 | /* silently ignore cpu mask on UP kernel */ | ||
2495 | if (nr_cpu_ids > 1 && res_opts->cpu_mask[0] != 0) { | ||
2496 | /* FIXME: Get rid of constant 32 here */ | ||
2497 | err = __bitmap_parse(res_opts->cpu_mask, 32, 0, | ||
2498 | cpumask_bits(new_cpu_mask), nr_cpu_ids); | ||
2499 | if (err) { | ||
2500 | conn_warn(tconn, "__bitmap_parse() failed with %d\n", err); | ||
2501 | /* retcode = ERR_CPU_MASK_PARSE; */ | ||
2502 | goto fail; | ||
2503 | } | ||
2504 | } | ||
2505 | tconn->res_opts = *res_opts; | ||
2506 | if (!cpumask_equal(tconn->cpu_mask, new_cpu_mask)) { | ||
2507 | cpumask_copy(tconn->cpu_mask, new_cpu_mask); | ||
2508 | drbd_calc_cpu_mask(tconn); | ||
2509 | tconn->receiver.reset_cpu_mask = 1; | ||
2510 | tconn->asender.reset_cpu_mask = 1; | ||
2511 | tconn->worker.reset_cpu_mask = 1; | ||
2512 | } | ||
2513 | err = 0; | ||
2514 | |||
2515 | fail: | ||
2516 | free_cpumask_var(new_cpu_mask); | ||
2517 | return err; | ||
2518 | |||
2519 | } | ||
2520 | |||
2482 | /* caller must be under genl_lock() */ | 2521 | /* caller must be under genl_lock() */ |
2483 | struct drbd_tconn *conn_create(const char *name) | 2522 | struct drbd_tconn *conn_create(const char *name, struct res_opts *res_opts) |
2484 | { | 2523 | { |
2485 | struct drbd_tconn *tconn; | 2524 | struct drbd_tconn *tconn; |
2486 | 2525 | ||
@@ -2500,6 +2539,9 @@ struct drbd_tconn *conn_create(const char *name) | |||
2500 | if (!zalloc_cpumask_var(&tconn->cpu_mask, GFP_KERNEL)) | 2539 | if (!zalloc_cpumask_var(&tconn->cpu_mask, GFP_KERNEL)) |
2501 | goto fail; | 2540 | goto fail; |
2502 | 2541 | ||
2542 | if (set_resource_options(tconn, res_opts)) | ||
2543 | goto fail; | ||
2544 | |||
2503 | if (!tl_init(tconn)) | 2545 | if (!tl_init(tconn)) |
2504 | goto fail; | 2546 | goto fail; |
2505 | 2547 | ||
@@ -2520,8 +2562,6 @@ struct drbd_tconn *conn_create(const char *name) | |||
2520 | drbd_thread_init(tconn, &tconn->worker, drbd_worker, "worker"); | 2562 | drbd_thread_init(tconn, &tconn->worker, drbd_worker, "worker"); |
2521 | drbd_thread_init(tconn, &tconn->asender, drbd_asender, "asender"); | 2563 | drbd_thread_init(tconn, &tconn->asender, drbd_asender, "asender"); |
2522 | 2564 | ||
2523 | drbd_set_res_opts_defaults(&tconn->res_opts); | ||
2524 | |||
2525 | kref_init(&tconn->kref); | 2565 | kref_init(&tconn->kref); |
2526 | list_add_tail_rcu(&tconn->all_tconn, &drbd_tconns); | 2566 | list_add_tail_rcu(&tconn->all_tconn, &drbd_tconns); |
2527 | 2567 | ||