aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2014-11-10 11:21:09 -0500
committerJens Axboe <axboe@fb.com>2014-11-10 11:27:30 -0500
commit179e20b8df97e0c7541a1bae30cad53ecc7a5e86 (patch)
tree09ba871446b543f9adf3c7468334053e3a2cab62 /drivers/block
parenta64e6bb4db601b561f2d3a80dfc554ddfe73db74 (diff)
drbd: Minor cleanups
. Update comments . drbd_set_{in,out_of}_sync(): Remove unused parameters . Move common code into adm_del_resource() . Redefine ERR_MINOR_EXISTS -> ERR_MINOR_OR_VOLUME_EXISTS Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_actlog.c3
-rw-r--r--drivers/block/drbd/drbd_int.h9
-rw-r--r--drivers/block/drbd/drbd_main.c6
-rw-r--r--drivers/block/drbd/drbd_nl.c60
4 files changed, 34 insertions, 44 deletions
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index a2dfa169237d..1318e3217cb0 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -827,8 +827,7 @@ static int update_sync_bits(struct drbd_device *device,
827 * 827 *
828 */ 828 */
829int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size, 829int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size,
830 enum update_sync_bits_mode mode, 830 enum update_sync_bits_mode mode)
831 const char *file, const unsigned int line)
832{ 831{
833 /* Is called from worker and receiver context _only_ */ 832 /* Is called from worker and receiver context _only_ */
834 unsigned long sbnr, ebnr, lbnr; 833 unsigned long sbnr, ebnr, lbnr;
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 9b22f8f01b57..c14b718c2fab 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1662,14 +1662,13 @@ extern void drbd_advance_rs_marks(struct drbd_device *device, unsigned long stil
1662 1662
1663enum update_sync_bits_mode { RECORD_RS_FAILED, SET_OUT_OF_SYNC, SET_IN_SYNC }; 1663enum update_sync_bits_mode { RECORD_RS_FAILED, SET_OUT_OF_SYNC, SET_IN_SYNC };
1664extern int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size, 1664extern int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size,
1665 enum update_sync_bits_mode mode, 1665 enum update_sync_bits_mode mode);
1666 const char *file, const unsigned int line);
1667#define drbd_set_in_sync(device, sector, size) \ 1666#define drbd_set_in_sync(device, sector, size) \
1668 __drbd_change_sync(device, sector, size, SET_IN_SYNC, __FILE__, __LINE__) 1667 __drbd_change_sync(device, sector, size, SET_IN_SYNC)
1669#define drbd_set_out_of_sync(device, sector, size) \ 1668#define drbd_set_out_of_sync(device, sector, size) \
1670 __drbd_change_sync(device, sector, size, SET_OUT_OF_SYNC, __FILE__, __LINE__) 1669 __drbd_change_sync(device, sector, size, SET_OUT_OF_SYNC)
1671#define drbd_rs_failed_io(device, sector, size) \ 1670#define drbd_rs_failed_io(device, sector, size) \
1672 __drbd_change_sync(device, sector, size, RECORD_RS_FAILED, __FILE__, __LINE__) 1671 __drbd_change_sync(device, sector, size, RECORD_RS_FAILED)
1673extern void drbd_al_shrink(struct drbd_device *device); 1672extern void drbd_al_shrink(struct drbd_device *device);
1674extern int drbd_initialize_al(struct drbd_device *, void *); 1673extern int drbd_initialize_al(struct drbd_device *, void *);
1675 1674
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 973c185c9cfe..cce25a5eb157 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2731,7 +2731,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
2731 2731
2732 device = minor_to_device(minor); 2732 device = minor_to_device(minor);
2733 if (device) 2733 if (device)
2734 return ERR_MINOR_EXISTS; 2734 return ERR_MINOR_OR_VOLUME_EXISTS;
2735 2735
2736 /* GFP_KERNEL, we are outside of all write-out paths */ 2736 /* GFP_KERNEL, we are outside of all write-out paths */
2737 device = kzalloc(sizeof(struct drbd_device), GFP_KERNEL); 2737 device = kzalloc(sizeof(struct drbd_device), GFP_KERNEL);
@@ -2794,7 +2794,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
2794 id = idr_alloc(&drbd_devices, device, minor, minor + 1, GFP_KERNEL); 2794 id = idr_alloc(&drbd_devices, device, minor, minor + 1, GFP_KERNEL);
2795 if (id < 0) { 2795 if (id < 0) {
2796 if (id == -ENOSPC) { 2796 if (id == -ENOSPC) {
2797 err = ERR_MINOR_EXISTS; 2797 err = ERR_MINOR_OR_VOLUME_EXISTS;
2798 drbd_msg_put_info(adm_ctx->reply_skb, "requested minor exists already"); 2798 drbd_msg_put_info(adm_ctx->reply_skb, "requested minor exists already");
2799 } 2799 }
2800 goto out_no_minor_idr; 2800 goto out_no_minor_idr;
@@ -2804,7 +2804,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
2804 id = idr_alloc(&resource->devices, device, vnr, vnr + 1, GFP_KERNEL); 2804 id = idr_alloc(&resource->devices, device, vnr, vnr + 1, GFP_KERNEL);
2805 if (id < 0) { 2805 if (id < 0) {
2806 if (id == -ENOSPC) { 2806 if (id == -ENOSPC) {
2807 err = ERR_MINOR_EXISTS; 2807 err = ERR_MINOR_OR_VOLUME_EXISTS;
2808 drbd_msg_put_info(adm_ctx->reply_skb, "requested minor exists already"); 2808 drbd_msg_put_info(adm_ctx->reply_skb, "requested minor exists already");
2809 } 2809 }
2810 goto out_idr_remove_minor; 2810 goto out_idr_remove_minor;
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 1cd47df44bda..c145619f1ccb 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -2052,7 +2052,7 @@ check_net_options(struct drbd_connection *connection, struct net_conf *new_net_c
2052 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf); 2052 rv = _check_net_options(connection, rcu_dereference(connection->net_conf), new_net_conf);
2053 rcu_read_unlock(); 2053 rcu_read_unlock();
2054 2054
2055 /* connection->volumes protected by genl_lock() here */ 2055 /* connection->peer_devices protected by genl_lock() here */
2056 idr_for_each_entry(&connection->peer_devices, peer_device, i) { 2056 idr_for_each_entry(&connection->peer_devices, peer_device, i) {
2057 struct drbd_device *device = peer_device->device; 2057 struct drbd_device *device = peer_device->device;
2058 if (!device->bitmap) { 2058 if (!device->bitmap) {
@@ -3483,7 +3483,7 @@ int drbd_adm_new_minor(struct sk_buff *skb, struct genl_info *info)
3483 * that first_peer_device(device)->connection and device->vnr match the request. */ 3483 * that first_peer_device(device)->connection and device->vnr match the request. */
3484 if (adm_ctx.device) { 3484 if (adm_ctx.device) {
3485 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) 3485 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL)
3486 retcode = ERR_MINOR_EXISTS; 3486 retcode = ERR_MINOR_OR_VOLUME_EXISTS;
3487 /* else: still NO_ERROR */ 3487 /* else: still NO_ERROR */
3488 goto out; 3488 goto out;
3489 } 3489 }
@@ -3530,6 +3530,27 @@ out:
3530 return 0; 3530 return 0;
3531} 3531}
3532 3532
3533static int adm_del_resource(struct drbd_resource *resource)
3534{
3535 struct drbd_connection *connection;
3536
3537 for_each_connection(connection, resource) {
3538 if (connection->cstate > C_STANDALONE)
3539 return ERR_NET_CONFIGURED;
3540 }
3541 if (!idr_is_empty(&resource->devices))
3542 return ERR_RES_IN_USE;
3543
3544 list_del_rcu(&resource->resources);
3545 /* Make sure all threads have actually stopped: state handling only
3546 * does drbd_thread_stop_nowait(). */
3547 list_for_each_entry(connection, &resource->connections, connections)
3548 drbd_thread_stop(&connection->worker);
3549 synchronize_rcu();
3550 drbd_free_resource(resource);
3551 return NO_ERROR;
3552}
3553
3533int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) 3554int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3534{ 3555{
3535 struct drbd_config_context adm_ctx; 3556 struct drbd_config_context adm_ctx;
@@ -3575,14 +3596,6 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3575 } 3596 }
3576 } 3597 }
3577 3598
3578 /* If we reach this, all volumes (of this connection) are Secondary,
3579 * Disconnected, Diskless, aka Unconfigured. Make sure all threads have
3580 * actually stopped, state handling only does drbd_thread_stop_nowait(). */
3581 for_each_connection(connection, resource)
3582 drbd_thread_stop(&connection->worker);
3583
3584 /* Now, nothing can fail anymore */
3585
3586 /* delete volumes */ 3599 /* delete volumes */
3587 idr_for_each_entry(&resource->devices, device, i) { 3600 idr_for_each_entry(&resource->devices, device, i) {
3588 retcode = adm_del_minor(device); 3601 retcode = adm_del_minor(device);
@@ -3593,10 +3606,7 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
3593 } 3606 }
3594 } 3607 }
3595 3608
3596 list_del_rcu(&resource->resources); 3609 retcode = adm_del_resource(resource);
3597 synchronize_rcu();
3598 drbd_free_resource(resource);
3599 retcode = NO_ERROR;
3600out: 3610out:
3601 mutex_unlock(&resource->adm_mutex); 3611 mutex_unlock(&resource->adm_mutex);
3602finish: 3612finish:
@@ -3608,7 +3618,6 @@ int drbd_adm_del_resource(struct sk_buff *skb, struct genl_info *info)
3608{ 3618{
3609 struct drbd_config_context adm_ctx; 3619 struct drbd_config_context adm_ctx;
3610 struct drbd_resource *resource; 3620 struct drbd_resource *resource;
3611 struct drbd_connection *connection;
3612 enum drbd_ret_code retcode; 3621 enum drbd_ret_code retcode;
3613 3622
3614 retcode = drbd_adm_prepare(&adm_ctx, skb, info, DRBD_ADM_NEED_RESOURCE); 3623 retcode = drbd_adm_prepare(&adm_ctx, skb, info, DRBD_ADM_NEED_RESOURCE);
@@ -3616,27 +3625,10 @@ int drbd_adm_del_resource(struct sk_buff *skb, struct genl_info *info)
3616 return retcode; 3625 return retcode;
3617 if (retcode != NO_ERROR) 3626 if (retcode != NO_ERROR)
3618 goto finish; 3627 goto finish;
3619
3620 resource = adm_ctx.resource; 3628 resource = adm_ctx.resource;
3621 mutex_lock(&resource->adm_mutex);
3622 for_each_connection(connection, resource) {
3623 if (connection->cstate > C_STANDALONE) {
3624 retcode = ERR_NET_CONFIGURED;
3625 goto out;
3626 }
3627 }
3628 if (!idr_is_empty(&resource->devices)) {
3629 retcode = ERR_RES_IN_USE;
3630 goto out;
3631 }
3632 3629
3633 list_del_rcu(&resource->resources); 3630 mutex_lock(&resource->adm_mutex);
3634 for_each_connection(connection, resource) 3631 retcode = adm_del_resource(resource);
3635 drbd_thread_stop(&connection->worker);
3636 synchronize_rcu();
3637 drbd_free_resource(resource);
3638 retcode = NO_ERROR;
3639out:
3640 mutex_unlock(&resource->adm_mutex); 3632 mutex_unlock(&resource->adm_mutex);
3641finish: 3633finish:
3642 drbd_adm_finish(&adm_ctx, info, retcode); 3634 drbd_adm_finish(&adm_ctx, info, retcode);