Commit eb6bea67 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Move resource options from connection to resource

Signed-off-by: default avatarAndreas Gruenbacher <agruen@linbit.com>
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
parent 9693da23
...@@ -542,6 +542,7 @@ struct drbd_resource { ...@@ -542,6 +542,7 @@ struct drbd_resource {
struct idr devices; /* volume number to device mapping */ struct idr devices; /* volume number to device mapping */
struct list_head connections; struct list_head connections;
struct list_head resources; struct list_head resources;
struct res_opts res_opts;
}; };
struct drbd_connection { struct drbd_connection {
...@@ -560,7 +561,6 @@ struct drbd_connection { ...@@ -560,7 +561,6 @@ struct drbd_connection {
struct net_conf *net_conf; /* content protected by rcu */ struct net_conf *net_conf; /* content protected by rcu */
struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */ struct mutex conf_update; /* mutex for ready-copy-update of net_conf and disk_conf */
wait_queue_head_t ping_wait; /* Woken upon reception of a ping, and a state change */ wait_queue_head_t ping_wait; /* Woken upon reception of a ping, and a state change */
struct res_opts res_opts;
struct sockaddr_storage my_addr; struct sockaddr_storage my_addr;
int my_addr_len; int my_addr_len;
...@@ -1208,7 +1208,7 @@ extern void drbd_delete_minor(struct drbd_device *mdev); ...@@ -1208,7 +1208,7 @@ extern void drbd_delete_minor(struct drbd_device *mdev);
extern struct drbd_resource *drbd_create_resource(const char *name); extern struct drbd_resource *drbd_create_resource(const char *name);
extern void drbd_free_resource(struct drbd_resource *resource); extern void drbd_free_resource(struct drbd_resource *resource);
extern int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts); extern int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts);
extern struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts); extern struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts);
extern void drbd_destroy_connection(struct kref *kref); extern void drbd_destroy_connection(struct kref *kref);
extern struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len, extern struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len,
......
...@@ -2487,8 +2487,9 @@ void conn_free_crypto(struct drbd_connection *connection) ...@@ -2487,8 +2487,9 @@ void conn_free_crypto(struct drbd_connection *connection)
connection->int_dig_vv = NULL; connection->int_dig_vv = NULL;
} }
int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts) int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts)
{ {
struct drbd_connection *connection;
cpumask_var_t new_cpu_mask; cpumask_var_t new_cpu_mask;
int err; int err;
...@@ -2510,13 +2511,15 @@ int set_resource_options(struct drbd_connection *connection, struct res_opts *re ...@@ -2510,13 +2511,15 @@ int set_resource_options(struct drbd_connection *connection, struct res_opts *re
goto fail; goto fail;
} }
} }
connection->res_opts = *res_opts; resource->res_opts = *res_opts;
if (!cpumask_equal(connection->cpu_mask, new_cpu_mask)) { for_each_connection_rcu(connection, resource) {
cpumask_copy(connection->cpu_mask, new_cpu_mask); if (!cpumask_equal(connection->cpu_mask, new_cpu_mask)) {
drbd_calc_cpu_mask(connection); cpumask_copy(connection->cpu_mask, new_cpu_mask);
connection->receiver.reset_cpu_mask = 1; drbd_calc_cpu_mask(connection);
connection->asender.reset_cpu_mask = 1; connection->receiver.reset_cpu_mask = 1;
connection->worker.reset_cpu_mask = 1; connection->asender.reset_cpu_mask = 1;
connection->worker.reset_cpu_mask = 1;
}
} }
err = 0; err = 0;
...@@ -2563,9 +2566,6 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) ...@@ -2563,9 +2566,6 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts)
if (!zalloc_cpumask_var(&connection->cpu_mask, GFP_KERNEL)) if (!zalloc_cpumask_var(&connection->cpu_mask, GFP_KERNEL))
goto fail; goto fail;
if (set_resource_options(connection, res_opts))
goto fail;
connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL); connection->current_epoch = kzalloc(sizeof(struct drbd_epoch), GFP_KERNEL);
if (!connection->current_epoch) if (!connection->current_epoch)
goto fail; goto fail;
...@@ -2602,19 +2602,24 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) ...@@ -2602,19 +2602,24 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts)
kref_init(&connection->kref); kref_init(&connection->kref);
kref_get(&resource->kref);
connection->resource = resource; connection->resource = resource;
list_add_tail_rcu(&connection->connections, &resource->connections);
if (set_resource_options(resource, res_opts))
goto fail_resource;
kref_get(&resource->kref);
list_add_tail_rcu(&connection->connections, &resource->connections);
return connection; return connection;
fail_resource:
list_del(&resource->resources);
drbd_free_resource(resource);
fail: fail:
kfree(connection->current_epoch); kfree(connection->current_epoch);
free_cpumask_var(connection->cpu_mask); free_cpumask_var(connection->cpu_mask);
drbd_free_socket(&connection->meta); drbd_free_socket(&connection->meta);
drbd_free_socket(&connection->data); drbd_free_socket(&connection->data);
kfree(connection); kfree(connection);
return NULL; return NULL;
} }
......
...@@ -2520,7 +2520,6 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info) ...@@ -2520,7 +2520,6 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
{ {
enum drbd_ret_code retcode; enum drbd_ret_code retcode;
struct drbd_connection *connection;
struct res_opts res_opts; struct res_opts res_opts;
int err; int err;
...@@ -2529,9 +2528,8 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) ...@@ -2529,9 +2528,8 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
return retcode; return retcode;
if (retcode != NO_ERROR) if (retcode != NO_ERROR)
goto fail; goto fail;
connection = adm_ctx.connection;
res_opts = connection->res_opts; res_opts = adm_ctx.resource->res_opts;
if (should_set_defaults(info)) if (should_set_defaults(info))
set_res_opts_defaults(&res_opts); set_res_opts_defaults(&res_opts);
...@@ -2542,7 +2540,7 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) ...@@ -2542,7 +2540,7 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info)
goto fail; goto fail;
} }
err = set_resource_options(connection, &res_opts); err = set_resource_options(adm_ctx.resource, &res_opts);
if (err) { if (err) {
retcode = ERR_INVALID_REQUEST; retcode = ERR_INVALID_REQUEST;
if (err == -ENOMEM) if (err == -ENOMEM)
...@@ -2802,7 +2800,7 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device, ...@@ -2802,7 +2800,7 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device,
if (nla_put_drbd_cfg_context(skb, first_peer_device(device)->connection, device->vnr)) if (nla_put_drbd_cfg_context(skb, first_peer_device(device)->connection, device->vnr))
goto nla_put_failure; goto nla_put_failure;
if (res_opts_to_skb(skb, &first_peer_device(device)->connection->res_opts, exclude_sensitive)) if (res_opts_to_skb(skb, &device->resource->res_opts, exclude_sensitive))
goto nla_put_failure; goto nla_put_failure;
rcu_read_lock(); rcu_read_lock();
......
...@@ -871,7 +871,7 @@ static union drbd_state sanitize_state(struct drbd_device *device, union drbd_st ...@@ -871,7 +871,7 @@ static union drbd_state sanitize_state(struct drbd_device *device, union drbd_st
(ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED)) (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED))
ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */ ns.susp_fen = 1; /* Suspend IO while fence-peer handler runs (peer lost) */
if (first_peer_device(device)->connection->res_opts.on_no_data == OND_SUSPEND_IO && if (device->resource->res_opts.on_no_data == OND_SUSPEND_IO &&
(ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)) (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE))
ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */ ns.susp_nod = 1; /* Suspend IO while no data available (no accessible data available) */
......
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