aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2011-06-29 04:49:13 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-05-09 04:08:22 -0400
commit77e8fdfc188f0490754f703f80d2853c69052c12 (patch)
treea56b084ec28ab6d376b0da3bcd4684f29f00cacd
parent07667347c89e5d971243a411ca4ed83ad14f9f9e (diff)
drbd: Only print sanitize state's warnings, if the state change happens
The reason for this change is that, with when doing 'drbdadm invalidate' on a disconnected resource caused an "implicitly set pdsk from UpToDate to DUnknown" message, which was missleading. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r--drivers/block/drbd/drbd_main.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 906aca9b6659..8e83a402ed5c 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -509,8 +509,16 @@ static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state);
509static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *, 509static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *,
510 union drbd_state, 510 union drbd_state,
511 union drbd_state); 511 union drbd_state);
512enum sanitize_state_warnings {
513 NO_WARNING,
514 ABORTED_ONLINE_VERIFY,
515 ABORTED_RESYNC,
516 CONNECTION_LOST_NEGOTIATING,
517 IMPLICITLY_UPGRADED_DISK,
518 IMPLICITLY_UPGRADED_PDSK,
519};
512static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, 520static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
513 union drbd_state ns, const char **warn_sync_abort); 521 union drbd_state ns, enum sanitize_state_warnings *warn);
514int drbd_send_state_req(struct drbd_conf *, 522int drbd_send_state_req(struct drbd_conf *,
515 union drbd_state, union drbd_state); 523 union drbd_state, union drbd_state);
516 524
@@ -803,6 +811,21 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
803 return rv; 811 return rv;
804} 812}
805 813
814static void print_sanitize_warnings(struct drbd_conf *mdev, enum sanitize_state_warnings warn)
815{
816 static const char *msg_table[] = {
817 [NO_WARNING] = "",
818 [ABORTED_ONLINE_VERIFY] = "Online-verify aborted.",
819 [ABORTED_RESYNC] = "Resync aborted.",
820 [CONNECTION_LOST_NEGOTIATING] = "Connection lost while negotiating, no data!",
821 [IMPLICITLY_UPGRADED_DISK] = "Implicitly upgraded disk",
822 [IMPLICITLY_UPGRADED_PDSK] = "Implicitly upgraded pdsk",
823 };
824
825 if (warn != NO_WARNING)
826 dev_warn(DEV, "%s\n", msg_table[warn]);
827}
828
806/** 829/**
807 * sanitize_state() - Resolves implicitly necessary additional changes to a state transition 830 * sanitize_state() - Resolves implicitly necessary additional changes to a state transition
808 * @mdev: DRBD device. 831 * @mdev: DRBD device.
@@ -814,11 +837,14 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
814 * to D_UNKNOWN. This rule and many more along those lines are in this function. 837 * to D_UNKNOWN. This rule and many more along those lines are in this function.
815 */ 838 */
816static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, 839static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
817 union drbd_state ns, const char **warn_sync_abort) 840 union drbd_state ns, enum sanitize_state_warnings *warn)
818{ 841{
819 enum drbd_fencing_p fp; 842 enum drbd_fencing_p fp;
820 enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max; 843 enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max;
821 844
845 if (warn)
846 *warn = NO_WARNING;
847
822 fp = FP_DONT_CARE; 848 fp = FP_DONT_CARE;
823 if (get_ldev(mdev)) { 849 if (get_ldev(mdev)) {
824 fp = mdev->ldev->dc.fencing; 850 fp = mdev->ldev->dc.fencing;
@@ -863,10 +889,9 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
863 /* Abort resync if a disk fails/detaches */ 889 /* Abort resync if a disk fails/detaches */
864 if (os.conn > C_CONNECTED && ns.conn > C_CONNECTED && 890 if (os.conn > C_CONNECTED && ns.conn > C_CONNECTED &&
865 (ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) { 891 (ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) {
866 if (warn_sync_abort) 892 if (warn)
867 *warn_sync_abort = 893 *warn = os.conn == C_VERIFY_S || os.conn == C_VERIFY_T ?
868 os.conn == C_VERIFY_S || os.conn == C_VERIFY_T ? 894 ABORTED_ONLINE_VERIFY : ABORTED_RESYNC;
869 "Online-verify" : "Resync";
870 ns.conn = C_CONNECTED; 895 ns.conn = C_CONNECTED;
871 } 896 }
872 897
@@ -877,7 +902,8 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
877 ns.disk = mdev->new_state_tmp.disk; 902 ns.disk = mdev->new_state_tmp.disk;
878 ns.pdsk = mdev->new_state_tmp.pdsk; 903 ns.pdsk = mdev->new_state_tmp.pdsk;
879 } else { 904 } else {
880 dev_alert(DEV, "Connection lost while negotiating, no data!\n"); 905 if (warn)
906 *warn = CONNECTION_LOST_NEGOTIATING;
881 ns.disk = D_DISKLESS; 907 ns.disk = D_DISKLESS;
882 ns.pdsk = D_UNKNOWN; 908 ns.pdsk = D_UNKNOWN;
883 } 909 }
@@ -959,16 +985,16 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
959 ns.disk = disk_max; 985 ns.disk = disk_max;
960 986
961 if (ns.disk < disk_min) { 987 if (ns.disk < disk_min) {
962 dev_warn(DEV, "Implicitly set disk from %s to %s\n", 988 if (warn)
963 drbd_disk_str(ns.disk), drbd_disk_str(disk_min)); 989 *warn = IMPLICITLY_UPGRADED_DISK;
964 ns.disk = disk_min; 990 ns.disk = disk_min;
965 } 991 }
966 if (ns.pdsk > pdsk_max) 992 if (ns.pdsk > pdsk_max)
967 ns.pdsk = pdsk_max; 993 ns.pdsk = pdsk_max;
968 994
969 if (ns.pdsk < pdsk_min) { 995 if (ns.pdsk < pdsk_min) {
970 dev_warn(DEV, "Implicitly set pdsk from %s to %s\n", 996 if (warn)
971 drbd_disk_str(ns.pdsk), drbd_disk_str(pdsk_min)); 997 *warn = IMPLICITLY_UPGRADED_PDSK;
972 ns.pdsk = pdsk_min; 998 ns.pdsk = pdsk_min;
973 } 999 }
974 1000
@@ -1045,12 +1071,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1045{ 1071{
1046 union drbd_state os; 1072 union drbd_state os;
1047 enum drbd_state_rv rv = SS_SUCCESS; 1073 enum drbd_state_rv rv = SS_SUCCESS;
1048 const char *warn_sync_abort = NULL; 1074 enum sanitize_state_warnings ssw;
1049 struct after_state_chg_work *ascw; 1075 struct after_state_chg_work *ascw;
1050 1076
1051 os = mdev->state; 1077 os = mdev->state;
1052 1078
1053 ns = sanitize_state(mdev, os, ns, &warn_sync_abort); 1079 ns = sanitize_state(mdev, os, ns, &ssw);
1054 1080
1055 if (ns.i == os.i) 1081 if (ns.i == os.i)
1056 return SS_NOTHING_TO_DO; 1082 return SS_NOTHING_TO_DO;
@@ -1076,8 +1102,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1076 return rv; 1102 return rv;
1077 } 1103 }
1078 1104
1079 if (warn_sync_abort) 1105 print_sanitize_warnings(mdev, ssw);
1080 dev_warn(DEV, "%s aborted.\n", warn_sync_abort);
1081 1106
1082 { 1107 {
1083 char *pbp, pb[300]; 1108 char *pbp, pb[300];