diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-06-21 11:23:59 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2014-02-17 10:45:00 -0500 |
commit | c06ece6ba6f1bb2e01616e111303c3ae5f80fdbe (patch) | |
tree | 2044b6aecd791466750863dbda4a544bce31bd19 /drivers/block/drbd/drbd_nl.c | |
parent | eb6bea673f884c037fd5358b5f17bfca18038708 (diff) |
drbd: Turn connection->volumes into connection->peer_devices
Let connection->peer_devices point to peer devices; connection->volumes was
pointing to devices.
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_nl.c')
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 49a0f2ae6454..c352c61f74c3 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -415,14 +415,16 @@ static int conn_khelper(struct drbd_connection *connection, char *cmd) | |||
415 | static enum drbd_fencing_p highest_fencing_policy(struct drbd_connection *connection) | 415 | static enum drbd_fencing_p highest_fencing_policy(struct drbd_connection *connection) |
416 | { | 416 | { |
417 | enum drbd_fencing_p fp = FP_NOT_AVAIL; | 417 | enum drbd_fencing_p fp = FP_NOT_AVAIL; |
418 | struct drbd_device *device; | 418 | struct drbd_peer_device *peer_device; |
419 | int vnr; | 419 | int vnr; |
420 | 420 | ||
421 | rcu_read_lock(); | 421 | rcu_read_lock(); |
422 | idr_for_each_entry(&connection->volumes, device, vnr) { | 422 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
423 | struct drbd_device *device = peer_device->device; | ||
423 | if (get_ldev_if_state(device, D_CONSISTENT)) { | 424 | if (get_ldev_if_state(device, D_CONSISTENT)) { |
424 | fp = max_t(enum drbd_fencing_p, fp, | 425 | struct disk_conf *disk_conf = |
425 | rcu_dereference(device->ldev->disk_conf)->fencing); | 426 | rcu_dereference(peer_device->device->ldev->disk_conf); |
427 | fp = max_t(enum drbd_fencing_p, fp, disk_conf->fencing); | ||
426 | put_ldev(device); | 428 | put_ldev(device); |
427 | } | 429 | } |
428 | } | 430 | } |
@@ -1878,12 +1880,13 @@ out: | |||
1878 | 1880 | ||
1879 | static bool conn_resync_running(struct drbd_connection *connection) | 1881 | static bool conn_resync_running(struct drbd_connection *connection) |
1880 | { | 1882 | { |
1881 | struct drbd_device *device; | 1883 | struct drbd_peer_device *peer_device; |
1882 | bool rv = false; | 1884 | bool rv = false; |
1883 | int vnr; | 1885 | int vnr; |
1884 | 1886 | ||
1885 | rcu_read_lock(); | 1887 | rcu_read_lock(); |
1886 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1888 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1889 | struct drbd_device *device = peer_device->device; | ||
1887 | if (device->state.conn == C_SYNC_SOURCE || | 1890 | if (device->state.conn == C_SYNC_SOURCE || |
1888 | device->state.conn == C_SYNC_TARGET || | 1891 | device->state.conn == C_SYNC_TARGET || |
1889 | device->state.conn == C_PAUSED_SYNC_S || | 1892 | device->state.conn == C_PAUSED_SYNC_S || |
@@ -1899,12 +1902,13 @@ static bool conn_resync_running(struct drbd_connection *connection) | |||
1899 | 1902 | ||
1900 | static bool conn_ov_running(struct drbd_connection *connection) | 1903 | static bool conn_ov_running(struct drbd_connection *connection) |
1901 | { | 1904 | { |
1902 | struct drbd_device *device; | 1905 | struct drbd_peer_device *peer_device; |
1903 | bool rv = false; | 1906 | bool rv = false; |
1904 | int vnr; | 1907 | int vnr; |
1905 | 1908 | ||
1906 | rcu_read_lock(); | 1909 | rcu_read_lock(); |
1907 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1910 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1911 | struct drbd_device *device = peer_device->device; | ||
1908 | if (device->state.conn == C_VERIFY_S || | 1912 | if (device->state.conn == C_VERIFY_S || |
1909 | device->state.conn == C_VERIFY_T) { | 1913 | device->state.conn == C_VERIFY_T) { |
1910 | rv = true; | 1914 | rv = true; |
@@ -1919,7 +1923,7 @@ static bool conn_ov_running(struct drbd_connection *connection) | |||
1919 | static enum drbd_ret_code | 1923 | static enum drbd_ret_code |
1920 | _check_net_options(struct drbd_connection *connection, struct net_conf *old_conf, struct net_conf *new_conf) | 1924 | _check_net_options(struct drbd_connection *connection, struct net_conf *old_conf, struct net_conf *new_conf) |
1921 | { | 1925 | { |
1922 | struct drbd_device *device; | 1926 | struct drbd_peer_device *peer_device; |
1923 | int i; | 1927 | int i; |
1924 | 1928 | ||
1925 | if (old_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) { | 1929 | if (old_conf && connection->cstate == C_WF_REPORT_PARAMS && connection->agreed_pro_version < 100) { |
@@ -1942,7 +1946,8 @@ _check_net_options(struct drbd_connection *connection, struct net_conf *old_conf | |||
1942 | (new_conf->wire_protocol != DRBD_PROT_C)) | 1946 | (new_conf->wire_protocol != DRBD_PROT_C)) |
1943 | return ERR_NOT_PROTO_C; | 1947 | return ERR_NOT_PROTO_C; |
1944 | 1948 | ||
1945 | idr_for_each_entry(&connection->volumes, device, i) { | 1949 | idr_for_each_entry(&connection->peer_devices, peer_device, i) { |
1950 | struct drbd_device *device = peer_device->device; | ||
1946 | if (get_ldev(device)) { | 1951 | if (get_ldev(device)) { |
1947 | enum drbd_fencing_p fp = rcu_dereference(device->ldev->disk_conf)->fencing; | 1952 | enum drbd_fencing_p fp = rcu_dereference(device->ldev->disk_conf)->fencing; |
1948 | put_ldev(device); | 1953 | put_ldev(device); |
@@ -1963,7 +1968,7 @@ static enum drbd_ret_code | |||
1963 | check_net_options(struct drbd_connection *connection, struct net_conf *new_conf) | 1968 | check_net_options(struct drbd_connection *connection, struct net_conf *new_conf) |
1964 | { | 1969 | { |
1965 | static enum drbd_ret_code rv; | 1970 | static enum drbd_ret_code rv; |
1966 | struct drbd_device *device; | 1971 | struct drbd_peer_device *peer_device; |
1967 | int i; | 1972 | int i; |
1968 | 1973 | ||
1969 | rcu_read_lock(); | 1974 | rcu_read_lock(); |
@@ -1971,7 +1976,8 @@ check_net_options(struct drbd_connection *connection, struct net_conf *new_conf) | |||
1971 | rcu_read_unlock(); | 1976 | rcu_read_unlock(); |
1972 | 1977 | ||
1973 | /* connection->volumes protected by genl_lock() here */ | 1978 | /* connection->volumes protected by genl_lock() here */ |
1974 | idr_for_each_entry(&connection->volumes, device, i) { | 1979 | idr_for_each_entry(&connection->peer_devices, peer_device, i) { |
1980 | struct drbd_device *device = peer_device->device; | ||
1975 | if (!device->bitmap) { | 1981 | if (!device->bitmap) { |
1976 | if (drbd_bm_init(device)) | 1982 | if (drbd_bm_init(device)) |
1977 | return ERR_NOMEM; | 1983 | return ERR_NOMEM; |
@@ -2155,7 +2161,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) | |||
2155 | 2161 | ||
2156 | int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) | 2162 | int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) |
2157 | { | 2163 | { |
2158 | struct drbd_device *device; | 2164 | struct drbd_peer_device *peer_device; |
2159 | struct net_conf *old_conf, *new_conf = NULL; | 2165 | struct net_conf *old_conf, *new_conf = NULL; |
2160 | struct crypto crypto = { }; | 2166 | struct crypto crypto = { }; |
2161 | struct drbd_resource *resource; | 2167 | struct drbd_resource *resource; |
@@ -2256,7 +2262,8 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) | |||
2256 | mutex_unlock(&connection->conf_update); | 2262 | mutex_unlock(&connection->conf_update); |
2257 | 2263 | ||
2258 | rcu_read_lock(); | 2264 | rcu_read_lock(); |
2259 | idr_for_each_entry(&connection->volumes, device, i) { | 2265 | idr_for_each_entry(&connection->peer_devices, peer_device, i) { |
2266 | struct drbd_device *device = peer_device->device; | ||
2260 | device->send_cnt = 0; | 2267 | device->send_cnt = 0; |
2261 | device->recv_cnt = 0; | 2268 | device->recv_cnt = 0; |
2262 | } | 2269 | } |
@@ -2915,6 +2922,7 @@ out: | |||
2915 | 2922 | ||
2916 | static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb) | 2923 | static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb) |
2917 | { | 2924 | { |
2925 | struct drbd_peer_device *peer_device; | ||
2918 | struct drbd_device *device; | 2926 | struct drbd_device *device; |
2919 | struct drbd_genlmsghdr *dh; | 2927 | struct drbd_genlmsghdr *dh; |
2920 | struct drbd_resource *pos = (struct drbd_resource *)cb->args[0]; | 2928 | struct drbd_resource *pos = (struct drbd_resource *)cb->args[0]; |
@@ -2926,7 +2934,7 @@ static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb) | |||
2926 | /* Open coded, deferred, iteration: | 2934 | /* Open coded, deferred, iteration: |
2927 | * for_each_resource_safe(resource, tmp, &drbd_resources) { | 2935 | * for_each_resource_safe(resource, tmp, &drbd_resources) { |
2928 | * connection = "first connection of resource"; | 2936 | * connection = "first connection of resource"; |
2929 | * idr_for_each_entry(&connection->volumes, device, i) { | 2937 | * idr_for_each_entry(&connection->peer_devices, peer_device, i) { |
2930 | * ... | 2938 | * ... |
2931 | * } | 2939 | * } |
2932 | * } | 2940 | * } |
@@ -2962,8 +2970,8 @@ static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb) | |||
2962 | if (resource) { | 2970 | if (resource) { |
2963 | next_resource: | 2971 | next_resource: |
2964 | connection = first_connection(resource); | 2972 | connection = first_connection(resource); |
2965 | device = idr_get_next(&connection->volumes, &volume); | 2973 | peer_device = idr_get_next(&connection->peer_devices, &volume); |
2966 | if (!device) { | 2974 | if (!peer_device) { |
2967 | /* No more volumes to dump on this resource. | 2975 | /* No more volumes to dump on this resource. |
2968 | * Advance resource iterator. */ | 2976 | * Advance resource iterator. */ |
2969 | pos = list_entry_rcu(resource->resources.next, | 2977 | pos = list_entry_rcu(resource->resources.next, |
@@ -2987,7 +2995,7 @@ next_resource: | |||
2987 | if (!dh) | 2995 | if (!dh) |
2988 | goto out; | 2996 | goto out; |
2989 | 2997 | ||
2990 | if (!device) { | 2998 | if (!peer_device) { |
2991 | /* This is a connection without a single volume. | 2999 | /* This is a connection without a single volume. |
2992 | * Suprisingly enough, it may have a network | 3000 | * Suprisingly enough, it may have a network |
2993 | * configuration. */ | 3001 | * configuration. */ |
@@ -3002,6 +3010,7 @@ next_resource: | |||
3002 | goto done; | 3010 | goto done; |
3003 | } | 3011 | } |
3004 | 3012 | ||
3013 | device = peer_device->device; | ||
3005 | D_ASSERT(device->vnr == volume); | 3014 | D_ASSERT(device->vnr == volume); |
3006 | D_ASSERT(first_peer_device(device)->connection == connection); | 3015 | D_ASSERT(first_peer_device(device)->connection == connection); |
3007 | 3016 | ||
@@ -3359,7 +3368,7 @@ out: | |||
3359 | int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) | 3368 | int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) |
3360 | { | 3369 | { |
3361 | int retcode; /* enum drbd_ret_code rsp. enum drbd_state_rv */ | 3370 | int retcode; /* enum drbd_ret_code rsp. enum drbd_state_rv */ |
3362 | struct drbd_device *device; | 3371 | struct drbd_peer_device *peer_device; |
3363 | unsigned i; | 3372 | unsigned i; |
3364 | 3373 | ||
3365 | retcode = drbd_adm_prepare(skb, info, DRBD_ADM_NEED_RESOURCE); | 3374 | retcode = drbd_adm_prepare(skb, info, DRBD_ADM_NEED_RESOURCE); |
@@ -3369,8 +3378,8 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) | |||
3369 | goto out; | 3378 | goto out; |
3370 | 3379 | ||
3371 | /* demote */ | 3380 | /* demote */ |
3372 | idr_for_each_entry(&adm_ctx.connection->volumes, device, i) { | 3381 | idr_for_each_entry(&adm_ctx.connection->peer_devices, peer_device, i) { |
3373 | retcode = drbd_set_role(device, R_SECONDARY, 0); | 3382 | retcode = drbd_set_role(peer_device->device, R_SECONDARY, 0); |
3374 | if (retcode < SS_SUCCESS) { | 3383 | if (retcode < SS_SUCCESS) { |
3375 | drbd_msg_put_info("failed to demote"); | 3384 | drbd_msg_put_info("failed to demote"); |
3376 | goto out; | 3385 | goto out; |
@@ -3384,8 +3393,8 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) | |||
3384 | } | 3393 | } |
3385 | 3394 | ||
3386 | /* detach */ | 3395 | /* detach */ |
3387 | idr_for_each_entry(&adm_ctx.connection->volumes, device, i) { | 3396 | idr_for_each_entry(&adm_ctx.connection->peer_devices, peer_device, i) { |
3388 | retcode = adm_detach(device, 0); | 3397 | retcode = adm_detach(peer_device->device, 0); |
3389 | if (retcode < SS_SUCCESS || retcode > NO_ERROR) { | 3398 | if (retcode < SS_SUCCESS || retcode > NO_ERROR) { |
3390 | drbd_msg_put_info("failed to detach"); | 3399 | drbd_msg_put_info("failed to detach"); |
3391 | goto out; | 3400 | goto out; |
@@ -3400,8 +3409,8 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) | |||
3400 | /* Now, nothing can fail anymore */ | 3409 | /* Now, nothing can fail anymore */ |
3401 | 3410 | ||
3402 | /* delete volumes */ | 3411 | /* delete volumes */ |
3403 | idr_for_each_entry(&adm_ctx.connection->volumes, device, i) { | 3412 | idr_for_each_entry(&adm_ctx.connection->peer_devices, peer_device, i) { |
3404 | retcode = adm_del_minor(device); | 3413 | retcode = adm_del_minor(peer_device->device); |
3405 | if (retcode != NO_ERROR) { | 3414 | if (retcode != NO_ERROR) { |
3406 | /* "can not happen" */ | 3415 | /* "can not happen" */ |
3407 | drbd_msg_put_info("failed to delete volume"); | 3416 | drbd_msg_put_info("failed to delete volume"); |