diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-06-21 10:11:28 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2014-02-17 10:44:59 -0500 |
commit | eb6bea673f884c037fd5358b5f17bfca18038708 (patch) | |
tree | dbca6a04b1b87a3d3a7778c6d2f7a79857295d7c | |
parent | 9693da2379cfd133a265baad948ec94f1349dece (diff) |
drbd: Move resource options from connection to resource
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 4 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 33 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 8 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_state.c | 2 |
4 files changed, 25 insertions, 22 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 1bca8ec5f65b..c88336c64b6b 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -542,6 +542,7 @@ struct drbd_resource { | |||
542 | struct idr devices; /* volume number to device mapping */ | 542 | struct idr devices; /* volume number to device mapping */ |
543 | struct list_head connections; | 543 | struct list_head connections; |
544 | struct list_head resources; | 544 | struct list_head resources; |
545 | struct res_opts res_opts; | ||
545 | }; | 546 | }; |
546 | 547 | ||
547 | struct drbd_connection { | 548 | struct drbd_connection { |
@@ -560,7 +561,6 @@ struct drbd_connection { | |||
560 | struct net_conf *net_conf; /* content protected by rcu */ | 561 | struct net_conf *net_conf; /* content protected by rcu */ |
561 | struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */ | 562 | struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */ |
562 | wait_queue_head_t ping_wait; /* Woken upon reception of a ping, and a state change */ | 563 | wait_queue_head_t ping_wait; /* Woken upon reception of a ping, and a state change */ |
563 | struct res_opts res_opts; | ||
564 | 564 | ||
565 | struct sockaddr_storage my_addr; | 565 | struct sockaddr_storage my_addr; |
566 | int my_addr_len; | 566 | int my_addr_len; |
@@ -1208,7 +1208,7 @@ extern void drbd_delete_minor(struct drbd_device *mdev); | |||
1208 | extern struct drbd_resource *drbd_create_resource(const char *name); | 1208 | extern struct drbd_resource *drbd_create_resource(const char *name); |
1209 | extern void drbd_free_resource(struct drbd_resource *resource); | 1209 | extern void drbd_free_resource(struct drbd_resource *resource); |
1210 | 1210 | ||
1211 | extern int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts); | 1211 | extern int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts); |
1212 | extern struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts); | 1212 | extern struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts); |
1213 | extern void drbd_destroy_connection(struct kref *kref); | 1213 | extern void drbd_destroy_connection(struct kref *kref); |
1214 | extern struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len, | 1214 | extern struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len, |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 2be5355dede2..e58239cf7ec1 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -2487,8 +2487,9 @@ void conn_free_crypto(struct drbd_connection *connection) | |||
2487 | connection->int_dig_vv = NULL; | 2487 | connection->int_dig_vv = NULL; |
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts) | 2490 | int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts) |
2491 | { | 2491 | { |
2492 | struct drbd_connection *connection; | ||
2492 | cpumask_var_t new_cpu_mask; | 2493 | cpumask_var_t new_cpu_mask; |
2493 | int err; | 2494 | int err; |
2494 | 2495 | ||
@@ -2510,13 +2511,15 @@ int set_resource_options(struct drbd_connection *connection, struct res_opts *re | |||
2510 | goto fail; | 2511 | goto fail; |
2511 | } | 2512 | } |
2512 | } | 2513 | } |
2513 | connection->res_opts = *res_opts; | 2514 | resource->res_opts = *res_opts; |
2514 | if (!cpumask_equal(connection->cpu_mask, new_cpu_mask)) { | 2515 | for_each_connection_rcu(connection, resource) { |
2515 | cpumask_copy(connection->cpu_mask, new_cpu_mask); | 2516 | if (!cpumask_equal(connection->cpu_mask, new_cpu_mask)) { |
2516 | drbd_calc_cpu_mask(connection); | 2517 | cpumask_copy(connection->cpu_mask, new_cpu_mask); |
2517 | connection->receiver.reset_cpu_mask = 1; | 2518 | drbd_calc_cpu_mask(connection); |
2518 | connection->asender.reset_cpu_mask = 1; | 2519 | connection->receiver.reset_cpu_mask = 1; |
2519 | connection->worker.reset_cpu_mask = 1; | 2520 | connection->asender.reset_cpu_mask = 1; |
2521 | connection->worker.reset_cpu_mask = 1; | ||
2522 | } | ||
2520 | } | 2523 | } |
2521 | err = 0; | 2524 | err = 0; |
2522 | 2525 | ||
@@ -2563,9 +2566,6 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) | |||
2563 | if (!zalloc_cpumask_var(&connection->cpu_mask, GFP_KERNEL)) | 2566 | if (!zalloc_cpumask_var(&connection->cpu_mask, GFP_KERNEL)) |
2564 | goto fail; | 2567 | goto fail; |
2565 | 2568 | ||
2566 | if (set_resource_options(connection, res_opts)) | ||
2567 | goto fail; | ||
2568 | |||
2569 | connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL); | 2569 | connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL); |
2570 | if (!connection->current_epoch) | 2570 | if (!connection->current_epoch) |
2571 | goto fail; | 2571 | goto fail; |
@@ -2602,19 +2602,24 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) | |||
2602 | 2602 | ||
2603 | kref_init(&connection->kref); | 2603 | kref_init(&connection->kref); |
2604 | 2604 | ||
2605 | kref_get(&resource->kref); | ||
2606 | connection->resource = resource; | 2605 | connection->resource = resource; |
2607 | list_add_tail_rcu(&connection->connections, &resource->connections); | ||
2608 | 2606 | ||
2607 | if (set_resource_options(resource, res_opts)) | ||
2608 | goto fail_resource; | ||
2609 | |||
2610 | kref_get(&resource->kref); | ||
2611 | list_add_tail_rcu(&connection->connections, &resource->connections); | ||
2609 | return connection; | 2612 | return connection; |
2610 | 2613 | ||
2614 | fail_resource: | ||
2615 | list_del(&resource->resources); | ||
2616 | drbd_free_resource(resource); | ||
2611 | fail: | 2617 | fail: |
2612 | kfree(connection->current_epoch); | 2618 | kfree(connection->current_epoch); |
2613 | free_cpumask_var(connection->cpu_mask); | 2619 | free_cpumask_var(connection->cpu_mask); |
2614 | drbd_free_socket(&connection->meta); | 2620 | drbd_free_socket(&connection->meta); |
2615 | drbd_free_socket(&connection->data); | 2621 | drbd_free_socket(&connection->data); |
2616 | kfree(connection); | 2622 | kfree(connection); |
2617 | |||
2618 | return NULL; | 2623 | return NULL; |
2619 | } | 2624 | } |
2620 | 2625 | ||
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index cb241d1d4668..49a0f2ae6454 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -2520,7 +2520,6 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info) | |||
2520 | int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) | 2520 | int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) |
2521 | { | 2521 | { |
2522 | enum drbd_ret_code retcode; | 2522 | enum drbd_ret_code retcode; |
2523 | struct drbd_connection *connection; | ||
2524 | struct res_opts res_opts; | 2523 | struct res_opts res_opts; |
2525 | int err; | 2524 | int err; |
2526 | 2525 | ||
@@ -2529,9 +2528,8 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) | |||
2529 | return retcode; | 2528 | return retcode; |
2530 | if (retcode != NO_ERROR) | 2529 | if (retcode != NO_ERROR) |
2531 | goto fail; | 2530 | goto fail; |
2532 | connection = adm_ctx.connection; | ||
2533 | 2531 | ||
2534 | res_opts = connection->res_opts; | 2532 | res_opts = adm_ctx.resource->res_opts; |
2535 | if (should_set_defaults(info)) | 2533 | if (should_set_defaults(info)) |
2536 | set_res_opts_defaults(&res_opts); | 2534 | set_res_opts_defaults(&res_opts); |
2537 | 2535 | ||
@@ -2542,7 +2540,7 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) | |||
2542 | goto fail; | 2540 | goto fail; |
2543 | } | 2541 | } |
2544 | 2542 | ||
2545 | err = set_resource_options(connection, &res_opts); | 2543 | err = set_resource_options(adm_ctx.resource, &res_opts); |
2546 | if (err) { | 2544 | if (err) { |
2547 | retcode = ERR_INVALID_REQUEST; | 2545 | retcode = ERR_INVALID_REQUEST; |
2548 | if (err == -ENOMEM) | 2546 | if (err == -ENOMEM) |
@@ -2802,7 +2800,7 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device, | |||
2802 | if (nla_put_drbd_cfg_context(skb, first_peer_device(device)->connection, device->vnr)) | 2800 | if (nla_put_drbd_cfg_context(skb, first_peer_device(device)->connection, device->vnr)) |
2803 | goto nla_put_failure; | 2801 | goto nla_put_failure; |
2804 | 2802 | ||
2805 | if (res_opts_to_skb(skb, &first_peer_device(device)->connection->res_opts, exclude_sensitive)) | 2803 | if (res_opts_to_skb(skb, &device->resource->res_opts, exclude_sensitive)) |
2806 | goto nla_put_failure; | 2804 | goto nla_put_failure; |
2807 | 2805 | ||
2808 | rcu_read_lock(); | 2806 | rcu_read_lock(); |
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index bb3d5947904d..64937536be0f 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c | |||
@@ -871,7 +871,7 @@ static union drbd_state sanitize_state(struct drbd_device *device, union drbd_st | |||
871 | (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED)) | 871 | (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED)) |
872 | ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */ | 872 | ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */ |
873 | 873 | ||
874 | if (first_peer_device(device)->connection->res_opts.on_no_data == OND_SUSPEND_IO && | 874 | if (device->resource->res_opts.on_no_data == OND_SUSPEND_IO && |
875 | (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)) | 875 | (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)) |
876 | ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */ | 876 | ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */ |
877 | 877 | ||