aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2010-12-07 18:39:32 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-03-10 05:36:19 -0500
commitbf885f8a6772fb48409dd505a09d974a5e621f22 (patch)
tree28205a11a192a14192bac3f8487b444e6d533955 /drivers/block
parentc8b325632f0e5ffdaeca3d1f3be77c9399316a40 (diff)
drbd: Be more explicit about functions that return an enum drbd_state_rv
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/drbd_int.h32
-rw-r--r--drivers/block/drbd/drbd_main.c59
-rw-r--r--drivers/block/drbd/drbd_nl.c29
-rw-r--r--drivers/block/drbd/drbd_receiver.c2
4 files changed, 67 insertions, 55 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index c81710a42111..749607a494e6 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1174,14 +1174,19 @@ enum dds_flags {
1174}; 1174};
1175 1175
1176extern void drbd_init_set_defaults(struct drbd_conf *mdev); 1176extern void drbd_init_set_defaults(struct drbd_conf *mdev);
1177extern int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, 1177extern enum drbd_state_rv drbd_change_state(struct drbd_conf *mdev,
1178 union drbd_state mask, union drbd_state val); 1178 enum chg_state_flags f,
1179 union drbd_state mask,
1180 union drbd_state val);
1179extern void drbd_force_state(struct drbd_conf *, union drbd_state, 1181extern void drbd_force_state(struct drbd_conf *, union drbd_state,
1180 union drbd_state); 1182 union drbd_state);
1181extern int _drbd_request_state(struct drbd_conf *, union drbd_state, 1183extern enum drbd_state_rv _drbd_request_state(struct drbd_conf *,
1182 union drbd_state, enum chg_state_flags); 1184 union drbd_state,
1183extern int __drbd_set_state(struct drbd_conf *, union drbd_state, 1185 union drbd_state,
1184 enum chg_state_flags, struct completion *done); 1186 enum chg_state_flags);
1187extern enum drbd_state_rv __drbd_set_state(struct drbd_conf *, union drbd_state,
1188 enum chg_state_flags,
1189 struct completion *done);
1185extern void print_st_err(struct drbd_conf *, union drbd_state, 1190extern void print_st_err(struct drbd_conf *, union drbd_state,
1186 union drbd_state, int); 1191 union drbd_state, int);
1187extern int drbd_thread_start(struct drbd_thread *thi); 1192extern int drbd_thread_start(struct drbd_thread *thi);
@@ -1245,7 +1250,7 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size)
1245 1250
1246extern int drbd_send_bitmap(struct drbd_conf *mdev); 1251extern int drbd_send_bitmap(struct drbd_conf *mdev);
1247extern int _drbd_send_bitmap(struct drbd_conf *mdev); 1252extern int _drbd_send_bitmap(struct drbd_conf *mdev);
1248extern int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode); 1253extern int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode);
1249extern void drbd_free_bc(struct drbd_backing_dev *ldev); 1254extern void drbd_free_bc(struct drbd_backing_dev *ldev);
1250extern void drbd_mdev_cleanup(struct drbd_conf *mdev); 1255extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
1251 1256
@@ -1493,8 +1498,9 @@ enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew =
1493extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local); 1498extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local);
1494extern void resync_after_online_grow(struct drbd_conf *); 1499extern void resync_after_online_grow(struct drbd_conf *);
1495extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local); 1500extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local);
1496extern int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, 1501extern enum drbd_state_rv drbd_set_role(struct drbd_conf *mdev,
1497 int force); 1502 enum drbd_role new_role,
1503 int force);
1498extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev); 1504extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev);
1499extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev); 1505extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev);
1500extern int drbd_khelper(struct drbd_conf *mdev, char *cmd); 1506extern int drbd_khelper(struct drbd_conf *mdev, char *cmd);
@@ -1761,11 +1767,11 @@ static inline void drbd_state_unlock(struct drbd_conf *mdev)
1761 wake_up(&mdev->misc_wait); 1767 wake_up(&mdev->misc_wait);
1762} 1768}
1763 1769
1764static inline int _drbd_set_state(struct drbd_conf *mdev, 1770static inline enum drbd_state_rv
1765 union drbd_state ns, enum chg_state_flags flags, 1771_drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1766 struct completion *done) 1772 enum chg_state_flags flags, struct completion *done)
1767{ 1773{
1768 int rv; 1774 enum drbd_state_rv rv;
1769 1775
1770 read_lock(&global_state_lock); 1776 read_lock(&global_state_lock);
1771 rv = __drbd_set_state(mdev, ns, flags, done); 1777 rv = __drbd_set_state(mdev, ns, flags, done);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index cddf311b7429..a101dceb2d49 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -473,12 +473,13 @@ static int cl_wide_st_chg(struct drbd_conf *mdev,
473 (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S); 473 (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S);
474} 474}
475 475
476int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, 476enum drbd_state_rv
477 union drbd_state mask, union drbd_state val) 477drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f,
478 union drbd_state mask, union drbd_state val)
478{ 479{
479 unsigned long flags; 480 unsigned long flags;
480 union drbd_state os, ns; 481 union drbd_state os, ns;
481 int rv; 482 enum drbd_state_rv rv;
482 483
483 spin_lock_irqsave(&mdev->req_lock, flags); 484 spin_lock_irqsave(&mdev->req_lock, flags);
484 os = mdev->state; 485 os = mdev->state;
@@ -502,9 +503,10 @@ void drbd_force_state(struct drbd_conf *mdev,
502 drbd_change_state(mdev, CS_HARD, mask, val); 503 drbd_change_state(mdev, CS_HARD, mask, val);
503} 504}
504 505
505static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns); 506static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state);
506static int is_valid_state_transition(struct drbd_conf *, 507static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *,
507 union drbd_state, union drbd_state); 508 union drbd_state,
509 union drbd_state);
508static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, 510static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
509 union drbd_state ns, const char **warn_sync_abort); 511 union drbd_state ns, const char **warn_sync_abort);
510int drbd_send_state_req(struct drbd_conf *, 512int drbd_send_state_req(struct drbd_conf *,
@@ -516,7 +518,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
516{ 518{
517 union drbd_state os, ns; 519 union drbd_state os, ns;
518 unsigned long flags; 520 unsigned long flags;
519 int rv; 521 enum drbd_state_rv rv;
520 522
521 if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags)) 523 if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags))
522 return SS_CW_SUCCESS; 524 return SS_CW_SUCCESS;
@@ -537,7 +539,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
537 if (rv == SS_SUCCESS) { 539 if (rv == SS_SUCCESS) {
538 rv = is_valid_state_transition(mdev, ns, os); 540 rv = is_valid_state_transition(mdev, ns, os);
539 if (rv == SS_SUCCESS) 541 if (rv == SS_SUCCESS)
540 rv = 0; /* cont waiting, otherwise fail. */ 542 rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */
541 } 543 }
542 } 544 }
543 spin_unlock_irqrestore(&mdev->req_lock, flags); 545 spin_unlock_irqrestore(&mdev->req_lock, flags);
@@ -555,14 +557,14 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
555 * Should not be called directly, use drbd_request_state() or 557 * Should not be called directly, use drbd_request_state() or
556 * _drbd_request_state(). 558 * _drbd_request_state().
557 */ 559 */
558static int drbd_req_state(struct drbd_conf *mdev, 560static enum drbd_state_rv
559 union drbd_state mask, union drbd_state val, 561drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
560 enum chg_state_flags f) 562 union drbd_state val, enum chg_state_flags f)
561{ 563{
562 struct completion done; 564 struct completion done;
563 unsigned long flags; 565 unsigned long flags;
564 union drbd_state os, ns; 566 union drbd_state os, ns;
565 int rv; 567 enum drbd_state_rv rv;
566 568
567 init_completion(&done); 569 init_completion(&done);
568 570
@@ -637,10 +639,11 @@ abort:
637 * Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE 639 * Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE
638 * flag, or when logging of failed state change requests is not desired. 640 * flag, or when logging of failed state change requests is not desired.
639 */ 641 */
640int _drbd_request_state(struct drbd_conf *mdev, union drbd_state mask, 642enum drbd_state_rv
641 union drbd_state val, enum chg_state_flags f) 643_drbd_request_state(struct drbd_conf *mdev, union drbd_state mask,
644 union drbd_state val, enum chg_state_flags f)
642{ 645{
643 int rv; 646 enum drbd_state_rv rv;
644 647
645 wait_event(mdev->state_wait, 648 wait_event(mdev->state_wait,
646 (rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE); 649 (rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE);
@@ -664,8 +667,8 @@ static void print_st(struct drbd_conf *mdev, char *name, union drbd_state ns)
664 ); 667 );
665} 668}
666 669
667void print_st_err(struct drbd_conf *mdev, 670void print_st_err(struct drbd_conf *mdev, union drbd_state os,
668 union drbd_state os, union drbd_state ns, int err) 671 union drbd_state ns, enum drbd_state_rv err)
669{ 672{
670 if (err == SS_IN_TRANSIENT_STATE) 673 if (err == SS_IN_TRANSIENT_STATE)
671 return; 674 return;
@@ -680,12 +683,13 @@ void print_st_err(struct drbd_conf *mdev,
680 * @mdev: DRBD device. 683 * @mdev: DRBD device.
681 * @ns: State to consider. 684 * @ns: State to consider.
682 */ 685 */
683static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns) 686static enum drbd_state_rv
687is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
684{ 688{
685 /* See drbd_state_sw_errors in drbd_strings.c */ 689 /* See drbd_state_sw_errors in drbd_strings.c */
686 690
687 enum drbd_fencing_p fp; 691 enum drbd_fencing_p fp;
688 int rv = SS_SUCCESS; 692 enum drbd_state_rv rv = SS_SUCCESS;
689 693
690 fp = FP_DONT_CARE; 694 fp = FP_DONT_CARE;
691 if (get_ldev(mdev)) { 695 if (get_ldev(mdev)) {
@@ -748,10 +752,11 @@ static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
748 * @ns: new state. 752 * @ns: new state.
749 * @os: old state. 753 * @os: old state.
750 */ 754 */
751static int is_valid_state_transition(struct drbd_conf *mdev, 755static enum drbd_state_rv
752 union drbd_state ns, union drbd_state os) 756is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
757 union drbd_state os)
753{ 758{
754 int rv = SS_SUCCESS; 759 enum drbd_state_rv rv = SS_SUCCESS;
755 760
756 if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) && 761 if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) &&
757 os.conn > C_CONNECTED) 762 os.conn > C_CONNECTED)
@@ -1029,12 +1034,12 @@ static void drbd_resume_al(struct drbd_conf *mdev)
1029 * 1034 *
1030 * Caller needs to hold req_lock, and global_state_lock. Do not call directly. 1035 * Caller needs to hold req_lock, and global_state_lock. Do not call directly.
1031 */ 1036 */
1032int __drbd_set_state(struct drbd_conf *mdev, 1037enum drbd_state_rv
1033 union drbd_state ns, enum chg_state_flags flags, 1038__drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1034 struct completion *done) 1039 enum chg_state_flags flags, struct completion *done)
1035{ 1040{
1036 union drbd_state os; 1041 union drbd_state os;
1037 int rv = SS_SUCCESS; 1042 enum drbd_state_rv rv = SS_SUCCESS;
1038 const char *warn_sync_abort = NULL; 1043 const char *warn_sync_abort = NULL;
1039 struct after_state_chg_work *ascw; 1044 struct after_state_chg_work *ascw;
1040 1045
@@ -2031,7 +2036,7 @@ int drbd_send_state_req(struct drbd_conf *mdev,
2031 (struct p_header80 *)&p, sizeof(p)); 2036 (struct p_header80 *)&p, sizeof(p));
2032} 2037}
2033 2038
2034int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode) 2039int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode)
2035{ 2040{
2036 struct p_req_state_reply p; 2041 struct p_req_state_reply p;
2037 2042
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index fe336592e538..7a2faf6d48e2 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -288,10 +288,11 @@ void drbd_try_outdate_peer_async(struct drbd_conf *mdev)
288 dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n"); 288 dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n");
289} 289}
290 290
291int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) 291enum drbd_state_rv
292drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
292{ 293{
293 const int max_tries = 4; 294 const int max_tries = 4;
294 int r = 0; 295 enum drbd_state_rv rv = SS_UNKNOWN_ERROR;
295 int try = 0; 296 int try = 0;
296 int forced = 0; 297 int forced = 0;
297 union drbd_state mask, val; 298 union drbd_state mask, val;
@@ -306,17 +307,17 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
306 val.i = 0; val.role = new_role; 307 val.i = 0; val.role = new_role;
307 308
308 while (try++ < max_tries) { 309 while (try++ < max_tries) {
309 r = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE); 310 rv = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE);
310 311
311 /* in case we first succeeded to outdate, 312 /* in case we first succeeded to outdate,
312 * but now suddenly could establish a connection */ 313 * but now suddenly could establish a connection */
313 if (r == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) { 314 if (rv == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) {
314 val.pdsk = 0; 315 val.pdsk = 0;
315 mask.pdsk = 0; 316 mask.pdsk = 0;
316 continue; 317 continue;
317 } 318 }
318 319
319 if (r == SS_NO_UP_TO_DATE_DISK && force && 320 if (rv == SS_NO_UP_TO_DATE_DISK && force &&
320 (mdev->state.disk < D_UP_TO_DATE && 321 (mdev->state.disk < D_UP_TO_DATE &&
321 mdev->state.disk >= D_INCONSISTENT)) { 322 mdev->state.disk >= D_INCONSISTENT)) {
322 mask.disk = D_MASK; 323 mask.disk = D_MASK;
@@ -325,7 +326,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
325 continue; 326 continue;
326 } 327 }
327 328
328 if (r == SS_NO_UP_TO_DATE_DISK && 329 if (rv == SS_NO_UP_TO_DATE_DISK &&
329 mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) { 330 mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) {
330 D_ASSERT(mdev->state.pdsk == D_UNKNOWN); 331 D_ASSERT(mdev->state.pdsk == D_UNKNOWN);
331 nps = drbd_try_outdate_peer(mdev); 332 nps = drbd_try_outdate_peer(mdev);
@@ -341,9 +342,9 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
341 continue; 342 continue;
342 } 343 }
343 344
344 if (r == SS_NOTHING_TO_DO) 345 if (rv == SS_NOTHING_TO_DO)
345 goto fail; 346 goto fail;
346 if (r == SS_PRIMARY_NOP && mask.pdsk == 0) { 347 if (rv == SS_PRIMARY_NOP && mask.pdsk == 0) {
347 nps = drbd_try_outdate_peer(mdev); 348 nps = drbd_try_outdate_peer(mdev);
348 349
349 if (force && nps > D_OUTDATED) { 350 if (force && nps > D_OUTDATED) {
@@ -356,7 +357,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
356 357
357 continue; 358 continue;
358 } 359 }
359 if (r == SS_TWO_PRIMARIES) { 360 if (rv == SS_TWO_PRIMARIES) {
360 /* Maybe the peer is detected as dead very soon... 361 /* Maybe the peer is detected as dead very soon...
361 retry at most once more in this case. */ 362 retry at most once more in this case. */
362 __set_current_state(TASK_INTERRUPTIBLE); 363 __set_current_state(TASK_INTERRUPTIBLE);
@@ -365,16 +366,16 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
365 try = max_tries - 1; 366 try = max_tries - 1;
366 continue; 367 continue;
367 } 368 }
368 if (r < SS_SUCCESS) { 369 if (rv < SS_SUCCESS) {
369 r = _drbd_request_state(mdev, mask, val, 370 rv = _drbd_request_state(mdev, mask, val,
370 CS_VERBOSE + CS_WAIT_COMPLETE); 371 CS_VERBOSE + CS_WAIT_COMPLETE);
371 if (r < SS_SUCCESS) 372 if (rv < SS_SUCCESS)
372 goto fail; 373 goto fail;
373 } 374 }
374 break; 375 break;
375 } 376 }
376 377
377 if (r < SS_SUCCESS) 378 if (rv < SS_SUCCESS)
378 goto fail; 379 goto fail;
379 380
380 if (forced) 381 if (forced)
@@ -423,7 +424,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
423 kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE); 424 kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
424 fail: 425 fail:
425 mutex_unlock(&mdev->state_mutex); 426 mutex_unlock(&mdev->state_mutex);
426 return r; 427 return rv;
427} 428}
428 429
429static struct drbd_conf *ensure_mdev(int minor, int create) 430static struct drbd_conf *ensure_mdev(int minor, int create)
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index d34d093278c7..c116cbdc9dca 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3112,7 +3112,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi
3112{ 3112{
3113 struct p_req_state *p = &mdev->data.rbuf.req_state; 3113 struct p_req_state *p = &mdev->data.rbuf.req_state;
3114 union drbd_state mask, val; 3114 union drbd_state mask, val;
3115 int rv; 3115 enum drbd_state_rv rv;
3116 3116
3117 mask.i = be32_to_cpu(p->mask); 3117 mask.i = be32_to_cpu(p->mask);
3118 val.i = be32_to_cpu(p->val); 3118 val.i = be32_to_cpu(p->val);