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 | |
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>
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 7 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 27 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 59 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 44 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_state.c | 86 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 5 |
6 files changed, 136 insertions, 92 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index c88336c64b6b..41dced195653 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -549,7 +549,7 @@ struct drbd_connection { | |||
549 | struct list_head connections; | 549 | struct list_head connections; |
550 | struct drbd_resource *resource; | 550 | struct drbd_resource *resource; |
551 | struct kref kref; | 551 | struct kref kref; |
552 | struct idr volumes; /* <connection, vnr> to device mapping */ | 552 | struct idr peer_devices; /* volume number to peer device mapping */ |
553 | enum drbd_conns cstate; /* Only C_STANDALONE to C_WF_REPORT_PARAMS */ | 553 | enum drbd_conns cstate; /* Only C_STANDALONE to C_WF_REPORT_PARAMS */ |
554 | unsigned susp:1; /* IO suspended by user */ | 554 | unsigned susp:1; /* IO suspended by user */ |
555 | unsigned susp_nod:1; /* IO suspended because no data */ | 555 | unsigned susp_nod:1; /* IO suspended because no data */ |
@@ -822,7 +822,10 @@ static inline unsigned int device_to_minor(struct drbd_device *device) | |||
822 | 822 | ||
823 | static inline struct drbd_device *vnr_to_device(struct drbd_connection *connection, int vnr) | 823 | static inline struct drbd_device *vnr_to_device(struct drbd_connection *connection, int vnr) |
824 | { | 824 | { |
825 | return (struct drbd_device *)idr_find(&connection->volumes, vnr); | 825 | struct drbd_peer_device *peer_device; |
826 | |||
827 | peer_device = idr_find(&connection->peer_devices, vnr); | ||
828 | return peer_device ? peer_device->device : NULL; | ||
826 | } | 829 | } |
827 | 830 | ||
828 | /* | 831 | /* |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index e58239cf7ec1..3a67f2421077 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -496,15 +496,16 @@ char *drbd_task_to_thread_name(struct drbd_connection *connection, struct task_s | |||
496 | 496 | ||
497 | int conn_lowest_minor(struct drbd_connection *connection) | 497 | int conn_lowest_minor(struct drbd_connection *connection) |
498 | { | 498 | { |
499 | struct drbd_device *device; | 499 | struct drbd_peer_device *peer_device; |
500 | int vnr = 0, m; | 500 | int vnr = 0, minor = -1; |
501 | 501 | ||
502 | rcu_read_lock(); | 502 | rcu_read_lock(); |
503 | device = idr_get_next(&connection->volumes, &vnr); | 503 | peer_device = idr_get_next(&connection->peer_devices, &vnr); |
504 | m = device ? device_to_minor(device) : -1; | 504 | if (peer_device) |
505 | minor = device_to_minor(peer_device->device); | ||
505 | rcu_read_unlock(); | 506 | rcu_read_unlock(); |
506 | 507 | ||
507 | return m; | 508 | return minor; |
508 | } | 509 | } |
509 | 510 | ||
510 | #ifdef CONFIG_SMP | 511 | #ifdef CONFIG_SMP |
@@ -2590,7 +2591,7 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) | |||
2590 | spin_lock_init(&connection->req_lock); | 2591 | spin_lock_init(&connection->req_lock); |
2591 | mutex_init(&connection->conf_update); | 2592 | mutex_init(&connection->conf_update); |
2592 | init_waitqueue_head(&connection->ping_wait); | 2593 | init_waitqueue_head(&connection->ping_wait); |
2593 | idr_init(&connection->volumes); | 2594 | idr_init(&connection->peer_devices); |
2594 | 2595 | ||
2595 | drbd_init_workqueue(&connection->sender_work); | 2596 | drbd_init_workqueue(&connection->sender_work); |
2596 | mutex_init(&connection->data.mutex); | 2597 | mutex_init(&connection->data.mutex); |
@@ -2632,7 +2633,7 @@ void drbd_destroy_connection(struct kref *kref) | |||
2632 | conn_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size)); | 2633 | conn_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size)); |
2633 | kfree(connection->current_epoch); | 2634 | kfree(connection->current_epoch); |
2634 | 2635 | ||
2635 | idr_destroy(&connection->volumes); | 2636 | idr_destroy(&connection->peer_devices); |
2636 | 2637 | ||
2637 | free_cpumask_var(connection->cpu_mask); | 2638 | free_cpumask_var(connection->cpu_mask); |
2638 | drbd_free_socket(&connection->meta); | 2639 | drbd_free_socket(&connection->meta); |
@@ -2760,7 +2761,7 @@ enum drbd_ret_code drbd_create_minor(struct drbd_connection *connection, unsigne | |||
2760 | } | 2761 | } |
2761 | kref_get(&device->kref); | 2762 | kref_get(&device->kref); |
2762 | 2763 | ||
2763 | id = idr_alloc(&connection->volumes, device, vnr, vnr + 1, GFP_KERNEL); | 2764 | id = idr_alloc(&connection->peer_devices, peer_device, vnr, vnr + 1, GFP_KERNEL); |
2764 | if (id < 0) { | 2765 | if (id < 0) { |
2765 | if (id == -ENOSPC) { | 2766 | if (id == -ENOSPC) { |
2766 | err = ERR_INVALID_REQUEST; | 2767 | err = ERR_INVALID_REQUEST; |
@@ -2786,7 +2787,7 @@ enum drbd_ret_code drbd_create_minor(struct drbd_connection *connection, unsigne | |||
2786 | return NO_ERROR; | 2787 | return NO_ERROR; |
2787 | 2788 | ||
2788 | out_idr_remove_vol: | 2789 | out_idr_remove_vol: |
2789 | idr_remove(&connection->volumes, vnr); | 2790 | idr_remove(&connection->peer_devices, vnr); |
2790 | out_idr_remove_from_resource: | 2791 | out_idr_remove_from_resource: |
2791 | idr_remove(&resource->devices, vnr); | 2792 | idr_remove(&resource->devices, vnr); |
2792 | out_idr_remove_minor: | 2793 | out_idr_remove_minor: |
@@ -2815,7 +2816,7 @@ void drbd_delete_minor(struct drbd_device *device) | |||
2815 | int refs = 3; | 2816 | int refs = 3; |
2816 | 2817 | ||
2817 | for_each_connection(connection, resource) { | 2818 | for_each_connection(connection, resource) { |
2818 | idr_remove(&connection->volumes, device->vnr); | 2819 | idr_remove(&connection->peer_devices, device->vnr); |
2819 | refs++; | 2820 | refs++; |
2820 | } | 2821 | } |
2821 | idr_remove(&resource->devices, device->vnr); | 2822 | idr_remove(&resource->devices, device->vnr); |
@@ -2938,11 +2939,13 @@ void drbd_free_sock(struct drbd_connection *connection) | |||
2938 | 2939 | ||
2939 | void conn_md_sync(struct drbd_connection *connection) | 2940 | void conn_md_sync(struct drbd_connection *connection) |
2940 | { | 2941 | { |
2941 | struct drbd_device *device; | 2942 | struct drbd_peer_device *peer_device; |
2942 | int vnr; | 2943 | int vnr; |
2943 | 2944 | ||
2944 | rcu_read_lock(); | 2945 | rcu_read_lock(); |
2945 | idr_for_each_entry(&connection->volumes, device, vnr) { | 2946 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
2947 | struct drbd_device *device = peer_device->device; | ||
2948 | |||
2946 | kref_get(&device->kref); | 2949 | kref_get(&device->kref); |
2947 | rcu_read_unlock(); | 2950 | rcu_read_unlock(); |
2948 | drbd_md_sync(device); | 2951 | drbd_md_sync(device); |
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"); |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 791005e163db..24907877cae4 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -867,7 +867,7 @@ int drbd_connected(struct drbd_device *device) | |||
867 | static int conn_connect(struct drbd_connection *connection) | 867 | static int conn_connect(struct drbd_connection *connection) |
868 | { | 868 | { |
869 | struct drbd_socket sock, msock; | 869 | struct drbd_socket sock, msock; |
870 | struct drbd_device *device; | 870 | struct drbd_peer_device *peer_device; |
871 | struct net_conf *nc; | 871 | struct net_conf *nc; |
872 | int vnr, timeout, h, ok; | 872 | int vnr, timeout, h, ok; |
873 | bool discard_my_data; | 873 | bool discard_my_data; |
@@ -1038,7 +1038,8 @@ randomize: | |||
1038 | set_bit(STATE_SENT, &connection->flags); | 1038 | set_bit(STATE_SENT, &connection->flags); |
1039 | 1039 | ||
1040 | rcu_read_lock(); | 1040 | rcu_read_lock(); |
1041 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1041 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1042 | struct drbd_device *device = peer_device->device; | ||
1042 | kref_get(&device->kref); | 1043 | kref_get(&device->kref); |
1043 | rcu_read_unlock(); | 1044 | rcu_read_unlock(); |
1044 | 1045 | ||
@@ -1145,12 +1146,14 @@ static int drbd_recv_header(struct drbd_connection *connection, struct packet_in | |||
1145 | static void drbd_flush(struct drbd_connection *connection) | 1146 | static void drbd_flush(struct drbd_connection *connection) |
1146 | { | 1147 | { |
1147 | int rv; | 1148 | int rv; |
1148 | struct drbd_device *device; | 1149 | struct drbd_peer_device *peer_device; |
1149 | int vnr; | 1150 | int vnr; |
1150 | 1151 | ||
1151 | if (connection->write_ordering >= WO_bdev_flush) { | 1152 | if (connection->write_ordering >= WO_bdev_flush) { |
1152 | rcu_read_lock(); | 1153 | rcu_read_lock(); |
1153 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1154 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1155 | struct drbd_device *device = peer_device->device; | ||
1156 | |||
1154 | if (!get_ldev(device)) | 1157 | if (!get_ldev(device)) |
1155 | continue; | 1158 | continue; |
1156 | kref_get(&device->kref); | 1159 | kref_get(&device->kref); |
@@ -1260,7 +1263,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio | |||
1260 | void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo) | 1263 | void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo) |
1261 | { | 1264 | { |
1262 | struct disk_conf *dc; | 1265 | struct disk_conf *dc; |
1263 | struct drbd_device *device; | 1266 | struct drbd_peer_device *peer_device; |
1264 | enum write_ordering_e pwo; | 1267 | enum write_ordering_e pwo; |
1265 | int vnr; | 1268 | int vnr; |
1266 | static char *write_ordering_str[] = { | 1269 | static char *write_ordering_str[] = { |
@@ -1272,7 +1275,9 @@ void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ord | |||
1272 | pwo = connection->write_ordering; | 1275 | pwo = connection->write_ordering; |
1273 | wo = min(pwo, wo); | 1276 | wo = min(pwo, wo); |
1274 | rcu_read_lock(); | 1277 | rcu_read_lock(); |
1275 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1278 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1279 | struct drbd_device *device = peer_device->device; | ||
1280 | |||
1276 | if (!get_ldev_if_state(device, D_ATTACHING)) | 1281 | if (!get_ldev_if_state(device, D_ATTACHING)) |
1277 | continue; | 1282 | continue; |
1278 | dc = rcu_dereference(device->ldev->disk_conf); | 1283 | dc = rcu_dereference(device->ldev->disk_conf); |
@@ -1401,11 +1406,13 @@ static void drbd_remove_epoch_entry_interval(struct drbd_device *device, | |||
1401 | 1406 | ||
1402 | static void conn_wait_active_ee_empty(struct drbd_connection *connection) | 1407 | static void conn_wait_active_ee_empty(struct drbd_connection *connection) |
1403 | { | 1408 | { |
1404 | struct drbd_device *device; | 1409 | struct drbd_peer_device *peer_device; |
1405 | int vnr; | 1410 | int vnr; |
1406 | 1411 | ||
1407 | rcu_read_lock(); | 1412 | rcu_read_lock(); |
1408 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1413 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1414 | struct drbd_device *device = peer_device->device; | ||
1415 | |||
1409 | kref_get(&device->kref); | 1416 | kref_get(&device->kref); |
1410 | rcu_read_unlock(); | 1417 | rcu_read_unlock(); |
1411 | drbd_wait_ee_list_empty(device, &device->active_ee); | 1418 | drbd_wait_ee_list_empty(device, &device->active_ee); |
@@ -4436,7 +4443,7 @@ void conn_flush_workqueue(struct drbd_connection *connection) | |||
4436 | 4443 | ||
4437 | static void conn_disconnect(struct drbd_connection *connection) | 4444 | static void conn_disconnect(struct drbd_connection *connection) |
4438 | { | 4445 | { |
4439 | struct drbd_device *device; | 4446 | struct drbd_peer_device *peer_device; |
4440 | enum drbd_conns oc; | 4447 | enum drbd_conns oc; |
4441 | int vnr; | 4448 | int vnr; |
4442 | 4449 | ||
@@ -4455,11 +4462,12 @@ static void conn_disconnect(struct drbd_connection *connection) | |||
4455 | drbd_free_sock(connection); | 4462 | drbd_free_sock(connection); |
4456 | 4463 | ||
4457 | rcu_read_lock(); | 4464 | rcu_read_lock(); |
4458 | idr_for_each_entry(&connection->volumes, device, vnr) { | 4465 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
4466 | struct drbd_device *device = peer_device->device; | ||
4459 | kref_get(&device->kref); | 4467 | kref_get(&device->kref); |
4460 | rcu_read_unlock(); | 4468 | rcu_read_unlock(); |
4461 | drbd_disconnected(device); | 4469 | drbd_disconnected(device); |
4462 | kref_put(&device->kref, &drbd_destroy_device); | 4470 | kref_put(&device->kref, drbd_destroy_device); |
4463 | rcu_read_lock(); | 4471 | rcu_read_lock(); |
4464 | } | 4472 | } |
4465 | rcu_read_unlock(); | 4473 | rcu_read_unlock(); |
@@ -5111,13 +5119,15 @@ static int got_NegRSDReply(struct drbd_connection *connection, struct packet_inf | |||
5111 | static int got_BarrierAck(struct drbd_connection *connection, struct packet_info *pi) | 5119 | static int got_BarrierAck(struct drbd_connection *connection, struct packet_info *pi) |
5112 | { | 5120 | { |
5113 | struct p_barrier_ack *p = pi->data; | 5121 | struct p_barrier_ack *p = pi->data; |
5114 | struct drbd_device *device; | 5122 | struct drbd_peer_device *peer_device; |
5115 | int vnr; | 5123 | int vnr; |
5116 | 5124 | ||
5117 | tl_release(connection, p->barrier, be32_to_cpu(p->set_size)); | 5125 | tl_release(connection, p->barrier, be32_to_cpu(p->set_size)); |
5118 | 5126 | ||
5119 | rcu_read_lock(); | 5127 | rcu_read_lock(); |
5120 | idr_for_each_entry(&connection->volumes, device, vnr) { | 5128 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
5129 | struct drbd_device *device = peer_device->device; | ||
5130 | |||
5121 | if (device->state.conn == C_AHEAD && | 5131 | if (device->state.conn == C_AHEAD && |
5122 | atomic_read(&device->ap_in_flight) == 0 && | 5132 | atomic_read(&device->ap_in_flight) == 0 && |
5123 | !test_and_set_bit(AHEAD_TO_SYNC_SOURCE, &device->flags)) { | 5133 | !test_and_set_bit(AHEAD_TO_SYNC_SOURCE, &device->flags)) { |
@@ -5187,7 +5197,7 @@ static int got_skip(struct drbd_connection *connection, struct packet_info *pi) | |||
5187 | 5197 | ||
5188 | static int connection_finish_peer_reqs(struct drbd_connection *connection) | 5198 | static int connection_finish_peer_reqs(struct drbd_connection *connection) |
5189 | { | 5199 | { |
5190 | struct drbd_device *device; | 5200 | struct drbd_peer_device *peer_device; |
5191 | int vnr, not_empty = 0; | 5201 | int vnr, not_empty = 0; |
5192 | 5202 | ||
5193 | do { | 5203 | do { |
@@ -5195,7 +5205,8 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection) | |||
5195 | flush_signals(current); | 5205 | flush_signals(current); |
5196 | 5206 | ||
5197 | rcu_read_lock(); | 5207 | rcu_read_lock(); |
5198 | idr_for_each_entry(&connection->volumes, device, vnr) { | 5208 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
5209 | struct drbd_device *device = peer_device->device; | ||
5199 | kref_get(&device->kref); | 5210 | kref_get(&device->kref); |
5200 | rcu_read_unlock(); | 5211 | rcu_read_unlock(); |
5201 | if (drbd_finish_peer_reqs(device)) { | 5212 | if (drbd_finish_peer_reqs(device)) { |
@@ -5208,7 +5219,8 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection) | |||
5208 | set_bit(SIGNAL_ASENDER, &connection->flags); | 5219 | set_bit(SIGNAL_ASENDER, &connection->flags); |
5209 | 5220 | ||
5210 | spin_lock_irq(&connection->req_lock); | 5221 | spin_lock_irq(&connection->req_lock); |
5211 | idr_for_each_entry(&connection->volumes, device, vnr) { | 5222 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
5223 | struct drbd_device *device = peer_device->device; | ||
5212 | not_empty = !list_empty(&device->done_ee); | 5224 | not_empty = !list_empty(&device->done_ee); |
5213 | if (not_empty) | 5225 | if (not_empty) |
5214 | break; | 5226 | break; |
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index 64937536be0f..6435797903b1 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c | |||
@@ -63,12 +63,13 @@ static inline bool is_susp(union drbd_state s) | |||
63 | 63 | ||
64 | bool conn_all_vols_unconf(struct drbd_connection *connection) | 64 | bool conn_all_vols_unconf(struct drbd_connection *connection) |
65 | { | 65 | { |
66 | struct drbd_device *device; | 66 | struct drbd_peer_device *peer_device; |
67 | bool rv = true; | 67 | bool rv = true; |
68 | int vnr; | 68 | int vnr; |
69 | 69 | ||
70 | rcu_read_lock(); | 70 | rcu_read_lock(); |
71 | idr_for_each_entry(&connection->volumes, device, vnr) { | 71 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
72 | struct drbd_device *device = peer_device->device; | ||
72 | if (device->state.disk != D_DISKLESS || | 73 | if (device->state.disk != D_DISKLESS || |
73 | device->state.conn != C_STANDALONE || | 74 | device->state.conn != C_STANDALONE || |
74 | device->state.role != R_SECONDARY) { | 75 | device->state.role != R_SECONDARY) { |
@@ -103,12 +104,14 @@ static enum drbd_role min_role(enum drbd_role role1, enum drbd_role role2) | |||
103 | enum drbd_role conn_highest_role(struct drbd_connection *connection) | 104 | enum drbd_role conn_highest_role(struct drbd_connection *connection) |
104 | { | 105 | { |
105 | enum drbd_role role = R_UNKNOWN; | 106 | enum drbd_role role = R_UNKNOWN; |
106 | struct drbd_device *device; | 107 | struct drbd_peer_device *peer_device; |
107 | int vnr; | 108 | int vnr; |
108 | 109 | ||
109 | rcu_read_lock(); | 110 | rcu_read_lock(); |
110 | idr_for_each_entry(&connection->volumes, device, vnr) | 111 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
112 | struct drbd_device *device = peer_device->device; | ||
111 | role = max_role(role, device->state.role); | 113 | role = max_role(role, device->state.role); |
114 | } | ||
112 | rcu_read_unlock(); | 115 | rcu_read_unlock(); |
113 | 116 | ||
114 | return role; | 117 | return role; |
@@ -117,12 +120,14 @@ enum drbd_role conn_highest_role(struct drbd_connection *connection) | |||
117 | enum drbd_role conn_highest_peer(struct drbd_connection *connection) | 120 | enum drbd_role conn_highest_peer(struct drbd_connection *connection) |
118 | { | 121 | { |
119 | enum drbd_role peer = R_UNKNOWN; | 122 | enum drbd_role peer = R_UNKNOWN; |
120 | struct drbd_device *device; | 123 | struct drbd_peer_device *peer_device; |
121 | int vnr; | 124 | int vnr; |
122 | 125 | ||
123 | rcu_read_lock(); | 126 | rcu_read_lock(); |
124 | idr_for_each_entry(&connection->volumes, device, vnr) | 127 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
128 | struct drbd_device *device = peer_device->device; | ||
125 | peer = max_role(peer, device->state.peer); | 129 | peer = max_role(peer, device->state.peer); |
130 | } | ||
126 | rcu_read_unlock(); | 131 | rcu_read_unlock(); |
127 | 132 | ||
128 | return peer; | 133 | return peer; |
@@ -131,12 +136,14 @@ enum drbd_role conn_highest_peer(struct drbd_connection *connection) | |||
131 | enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection) | 136 | enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection) |
132 | { | 137 | { |
133 | enum drbd_disk_state ds = D_DISKLESS; | 138 | enum drbd_disk_state ds = D_DISKLESS; |
134 | struct drbd_device *device; | 139 | struct drbd_peer_device *peer_device; |
135 | int vnr; | 140 | int vnr; |
136 | 141 | ||
137 | rcu_read_lock(); | 142 | rcu_read_lock(); |
138 | idr_for_each_entry(&connection->volumes, device, vnr) | 143 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
144 | struct drbd_device *device = peer_device->device; | ||
139 | ds = max_t(enum drbd_disk_state, ds, device->state.disk); | 145 | ds = max_t(enum drbd_disk_state, ds, device->state.disk); |
146 | } | ||
140 | rcu_read_unlock(); | 147 | rcu_read_unlock(); |
141 | 148 | ||
142 | return ds; | 149 | return ds; |
@@ -145,12 +152,14 @@ enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection) | |||
145 | enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection) | 152 | enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection) |
146 | { | 153 | { |
147 | enum drbd_disk_state ds = D_MASK; | 154 | enum drbd_disk_state ds = D_MASK; |
148 | struct drbd_device *device; | 155 | struct drbd_peer_device *peer_device; |
149 | int vnr; | 156 | int vnr; |
150 | 157 | ||
151 | rcu_read_lock(); | 158 | rcu_read_lock(); |
152 | idr_for_each_entry(&connection->volumes, device, vnr) | 159 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
160 | struct drbd_device *device = peer_device->device; | ||
153 | ds = min_t(enum drbd_disk_state, ds, device->state.disk); | 161 | ds = min_t(enum drbd_disk_state, ds, device->state.disk); |
162 | } | ||
154 | rcu_read_unlock(); | 163 | rcu_read_unlock(); |
155 | 164 | ||
156 | return ds; | 165 | return ds; |
@@ -159,12 +168,14 @@ enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection) | |||
159 | enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection) | 168 | enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection) |
160 | { | 169 | { |
161 | enum drbd_disk_state ds = D_DISKLESS; | 170 | enum drbd_disk_state ds = D_DISKLESS; |
162 | struct drbd_device *device; | 171 | struct drbd_peer_device *peer_device; |
163 | int vnr; | 172 | int vnr; |
164 | 173 | ||
165 | rcu_read_lock(); | 174 | rcu_read_lock(); |
166 | idr_for_each_entry(&connection->volumes, device, vnr) | 175 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
176 | struct drbd_device *device = peer_device->device; | ||
167 | ds = max_t(enum drbd_disk_state, ds, device->state.pdsk); | 177 | ds = max_t(enum drbd_disk_state, ds, device->state.pdsk); |
178 | } | ||
168 | rcu_read_unlock(); | 179 | rcu_read_unlock(); |
169 | 180 | ||
170 | return ds; | 181 | return ds; |
@@ -173,12 +184,14 @@ enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection) | |||
173 | enum drbd_conns conn_lowest_conn(struct drbd_connection *connection) | 184 | enum drbd_conns conn_lowest_conn(struct drbd_connection *connection) |
174 | { | 185 | { |
175 | enum drbd_conns conn = C_MASK; | 186 | enum drbd_conns conn = C_MASK; |
176 | struct drbd_device *device; | 187 | struct drbd_peer_device *peer_device; |
177 | int vnr; | 188 | int vnr; |
178 | 189 | ||
179 | rcu_read_lock(); | 190 | rcu_read_lock(); |
180 | idr_for_each_entry(&connection->volumes, device, vnr) | 191 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
192 | struct drbd_device *device = peer_device->device; | ||
181 | conn = min_t(enum drbd_conns, conn, device->state.conn); | 193 | conn = min_t(enum drbd_conns, conn, device->state.conn); |
194 | } | ||
182 | rcu_read_unlock(); | 195 | rcu_read_unlock(); |
183 | 196 | ||
184 | return conn; | 197 | return conn; |
@@ -186,13 +199,13 @@ enum drbd_conns conn_lowest_conn(struct drbd_connection *connection) | |||
186 | 199 | ||
187 | static bool no_peer_wf_report_params(struct drbd_connection *connection) | 200 | static bool no_peer_wf_report_params(struct drbd_connection *connection) |
188 | { | 201 | { |
189 | struct drbd_device *device; | 202 | struct drbd_peer_device *peer_device; |
190 | int vnr; | 203 | int vnr; |
191 | bool rv = true; | 204 | bool rv = true; |
192 | 205 | ||
193 | rcu_read_lock(); | 206 | rcu_read_lock(); |
194 | idr_for_each_entry(&connection->volumes, device, vnr) | 207 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) |
195 | if (device->state.conn == C_WF_REPORT_PARAMS) { | 208 | if (peer_device->device->state.conn == C_WF_REPORT_PARAMS) { |
196 | rv = false; | 209 | rv = false; |
197 | break; | 210 | break; |
198 | } | 211 | } |
@@ -1256,12 +1269,12 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, | |||
1256 | spin_lock_irq(&connection->req_lock); | 1269 | spin_lock_irq(&connection->req_lock); |
1257 | if (connection->susp_fen && conn_lowest_conn(connection) >= C_CONNECTED) { | 1270 | if (connection->susp_fen && conn_lowest_conn(connection) >= C_CONNECTED) { |
1258 | /* case2: The connection was established again: */ | 1271 | /* case2: The connection was established again: */ |
1259 | struct drbd_device *odev; | 1272 | struct drbd_peer_device *peer_device; |
1260 | int vnr; | 1273 | int vnr; |
1261 | 1274 | ||
1262 | rcu_read_lock(); | 1275 | rcu_read_lock(); |
1263 | idr_for_each_entry(&connection->volumes, odev, vnr) | 1276 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) |
1264 | clear_bit(NEW_CUR_UUID, &odev->flags); | 1277 | clear_bit(NEW_CUR_UUID, &peer_device->device->flags); |
1265 | rcu_read_unlock(); | 1278 | rcu_read_unlock(); |
1266 | _tl_restart(connection, RESEND); | 1279 | _tl_restart(connection, RESEND); |
1267 | _conn_request_state(connection, | 1280 | _conn_request_state(connection, |
@@ -1530,7 +1543,7 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused) | |||
1530 | struct drbd_connection *connection = w->connection; | 1543 | struct drbd_connection *connection = w->connection; |
1531 | enum drbd_conns oc = acscw->oc; | 1544 | enum drbd_conns oc = acscw->oc; |
1532 | union drbd_state ns_max = acscw->ns_max; | 1545 | union drbd_state ns_max = acscw->ns_max; |
1533 | struct drbd_device *device; | 1546 | struct drbd_peer_device *peer_device; |
1534 | int vnr; | 1547 | int vnr; |
1535 | 1548 | ||
1536 | kfree(acscw); | 1549 | kfree(acscw); |
@@ -1558,7 +1571,8 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused) | |||
1558 | /* case1: The outdate peer handler is successful: */ | 1571 | /* case1: The outdate peer handler is successful: */ |
1559 | if (ns_max.pdsk <= D_OUTDATED) { | 1572 | if (ns_max.pdsk <= D_OUTDATED) { |
1560 | rcu_read_lock(); | 1573 | rcu_read_lock(); |
1561 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1574 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1575 | struct drbd_device *device = peer_device->device; | ||
1562 | if (test_bit(NEW_CUR_UUID, &device->flags)) { | 1576 | if (test_bit(NEW_CUR_UUID, &device->flags)) { |
1563 | drbd_uuid_new_current(device); | 1577 | drbd_uuid_new_current(device); |
1564 | clear_bit(NEW_CUR_UUID, &device->flags); | 1578 | clear_bit(NEW_CUR_UUID, &device->flags); |
@@ -1584,7 +1598,7 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused) | |||
1584 | void conn_old_common_state(struct drbd_connection *connection, union drbd_state *pcs, enum chg_state_flags *pf) | 1598 | void conn_old_common_state(struct drbd_connection *connection, union drbd_state *pcs, enum chg_state_flags *pf) |
1585 | { | 1599 | { |
1586 | enum chg_state_flags flags = ~0; | 1600 | enum chg_state_flags flags = ~0; |
1587 | struct drbd_device *device; | 1601 | struct drbd_peer_device *peer_device; |
1588 | int vnr, first_vol = 1; | 1602 | int vnr, first_vol = 1; |
1589 | union drbd_dev_state os, cs = { | 1603 | union drbd_dev_state os, cs = { |
1590 | { .role = R_SECONDARY, | 1604 | { .role = R_SECONDARY, |
@@ -1595,7 +1609,8 @@ void conn_old_common_state(struct drbd_connection *connection, union drbd_state | |||
1595 | } }; | 1609 | } }; |
1596 | 1610 | ||
1597 | rcu_read_lock(); | 1611 | rcu_read_lock(); |
1598 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1612 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1613 | struct drbd_device *device = peer_device->device; | ||
1599 | os = device->state; | 1614 | os = device->state; |
1600 | 1615 | ||
1601 | if (first_vol) { | 1616 | if (first_vol) { |
@@ -1632,11 +1647,12 @@ conn_is_valid_transition(struct drbd_connection *connection, union drbd_state ma | |||
1632 | { | 1647 | { |
1633 | enum drbd_state_rv rv = SS_SUCCESS; | 1648 | enum drbd_state_rv rv = SS_SUCCESS; |
1634 | union drbd_state ns, os; | 1649 | union drbd_state ns, os; |
1635 | struct drbd_device *device; | 1650 | struct drbd_peer_device *peer_device; |
1636 | int vnr; | 1651 | int vnr; |
1637 | 1652 | ||
1638 | rcu_read_lock(); | 1653 | rcu_read_lock(); |
1639 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1654 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1655 | struct drbd_device *device = peer_device->device; | ||
1640 | os = drbd_read_state(device); | 1656 | os = drbd_read_state(device); |
1641 | ns = sanitize_state(device, apply_mask_val(os, mask, val), NULL); | 1657 | ns = sanitize_state(device, apply_mask_val(os, mask, val), NULL); |
1642 | 1658 | ||
@@ -1647,10 +1663,8 @@ conn_is_valid_transition(struct drbd_connection *connection, union drbd_state ma | |||
1647 | continue; | 1663 | continue; |
1648 | 1664 | ||
1649 | rv = is_valid_transition(os, ns); | 1665 | rv = is_valid_transition(os, ns); |
1650 | if (rv < SS_SUCCESS) | ||
1651 | break; | ||
1652 | 1666 | ||
1653 | if (!(flags & CS_HARD)) { | 1667 | if (rv >= SS_SUCCESS && !(flags & CS_HARD)) { |
1654 | rv = is_valid_state(device, ns); | 1668 | rv = is_valid_state(device, ns); |
1655 | if (rv < SS_SUCCESS) { | 1669 | if (rv < SS_SUCCESS) { |
1656 | if (is_valid_state(device, os) == rv) | 1670 | if (is_valid_state(device, os) == rv) |
@@ -1658,14 +1672,15 @@ conn_is_valid_transition(struct drbd_connection *connection, union drbd_state ma | |||
1658 | } else | 1672 | } else |
1659 | rv = is_valid_soft_transition(os, ns, connection); | 1673 | rv = is_valid_soft_transition(os, ns, connection); |
1660 | } | 1674 | } |
1661 | if (rv < SS_SUCCESS) | 1675 | |
1676 | if (rv < SS_SUCCESS) { | ||
1677 | if (flags & CS_VERBOSE) | ||
1678 | print_st_err(device, os, ns, rv); | ||
1662 | break; | 1679 | break; |
1680 | } | ||
1663 | } | 1681 | } |
1664 | rcu_read_unlock(); | 1682 | rcu_read_unlock(); |
1665 | 1683 | ||
1666 | if (rv < SS_SUCCESS && flags & CS_VERBOSE) | ||
1667 | print_st_err(device, os, ns, rv); | ||
1668 | |||
1669 | return rv; | 1684 | return rv; |
1670 | } | 1685 | } |
1671 | 1686 | ||
@@ -1681,7 +1696,7 @@ conn_set_state(struct drbd_connection *connection, union drbd_state mask, union | |||
1681 | .disk = D_MASK, | 1696 | .disk = D_MASK, |
1682 | .pdsk = D_MASK | 1697 | .pdsk = D_MASK |
1683 | } }; | 1698 | } }; |
1684 | struct drbd_device *device; | 1699 | struct drbd_peer_device *peer_device; |
1685 | enum drbd_state_rv rv; | 1700 | enum drbd_state_rv rv; |
1686 | int vnr, number_of_volumes = 0; | 1701 | int vnr, number_of_volumes = 0; |
1687 | 1702 | ||
@@ -1696,7 +1711,8 @@ conn_set_state(struct drbd_connection *connection, union drbd_state mask, union | |||
1696 | } | 1711 | } |
1697 | 1712 | ||
1698 | rcu_read_lock(); | 1713 | rcu_read_lock(); |
1699 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1714 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1715 | struct drbd_device *device = peer_device->device; | ||
1700 | number_of_volumes++; | 1716 | number_of_volumes++; |
1701 | os = drbd_read_state(device); | 1717 | os = drbd_read_state(device); |
1702 | ns = apply_mask_val(os, mask, val); | 1718 | ns = apply_mask_val(os, mask, val); |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 378e48c983b3..7aa10568ac59 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -1890,7 +1890,7 @@ int drbd_worker(struct drbd_thread *thi) | |||
1890 | { | 1890 | { |
1891 | struct drbd_connection *connection = thi->connection; | 1891 | struct drbd_connection *connection = thi->connection; |
1892 | struct drbd_work *w = NULL; | 1892 | struct drbd_work *w = NULL; |
1893 | struct drbd_device *device; | 1893 | struct drbd_peer_device *peer_device; |
1894 | LIST_HEAD(work_list); | 1894 | LIST_HEAD(work_list); |
1895 | int vnr; | 1895 | int vnr; |
1896 | 1896 | ||
@@ -1934,7 +1934,8 @@ int drbd_worker(struct drbd_thread *thi) | |||
1934 | } while (!list_empty(&work_list)); | 1934 | } while (!list_empty(&work_list)); |
1935 | 1935 | ||
1936 | rcu_read_lock(); | 1936 | rcu_read_lock(); |
1937 | idr_for_each_entry(&connection->volumes, device, vnr) { | 1937 | idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { |
1938 | struct drbd_device *device = peer_device->device; | ||
1938 | D_ASSERT(device->state.disk == D_DISKLESS && device->state.conn == C_STANDALONE); | 1939 | D_ASSERT(device->state.disk == D_DISKLESS && device->state.conn == C_STANDALONE); |
1939 | kref_get(&device->kref); | 1940 | kref_get(&device->kref); |
1940 | rcu_read_unlock(); | 1941 | rcu_read_unlock(); |