diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2010-12-07 18:39:32 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-03-10 05:36:19 -0500 |
commit | bf885f8a6772fb48409dd505a09d974a5e621f22 (patch) | |
tree | 28205a11a192a14192bac3f8487b444e6d533955 /drivers/block/drbd/drbd_main.c | |
parent | c8b325632f0e5ffdaeca3d1f3be77c9399316a40 (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/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 59 |
1 files changed, 32 insertions, 27 deletions
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 | ||
476 | int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, | 476 | enum drbd_state_rv |
477 | union drbd_state mask, union drbd_state val) | 477 | drbd_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 | ||
505 | static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns); | 506 | static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state); |
506 | static int is_valid_state_transition(struct drbd_conf *, | 507 | static 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); | ||
508 | static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, | 510 | static 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); |
510 | int drbd_send_state_req(struct drbd_conf *, | 512 | int 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 | */ |
558 | static int drbd_req_state(struct drbd_conf *mdev, | 560 | static enum drbd_state_rv |
559 | union drbd_state mask, union drbd_state val, | 561 | drbd_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 | */ |
640 | int _drbd_request_state(struct drbd_conf *mdev, union drbd_state mask, | 642 | enum 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 | ||
667 | void print_st_err(struct drbd_conf *mdev, | 670 | void 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 | */ |
683 | static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns) | 686 | static enum drbd_state_rv |
687 | is_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 | */ |
751 | static int is_valid_state_transition(struct drbd_conf *mdev, | 755 | static enum drbd_state_rv |
752 | union drbd_state ns, union drbd_state os) | 756 | is_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 | */ |
1032 | int __drbd_set_state(struct drbd_conf *mdev, | 1037 | enum 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 | ||
2034 | int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode) | 2039 | int 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 | ||