Commit 77e8fdfc authored by Philipp Reisner's avatar Philipp Reisner

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: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 07667347
...@@ -509,8 +509,16 @@ static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state); ...@@ -509,8 +509,16 @@ static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state);
static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *, static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *,
union drbd_state, union drbd_state,
union drbd_state); union drbd_state);
enum sanitize_state_warnings {
NO_WARNING,
ABORTED_ONLINE_VERIFY,
ABORTED_RESYNC,
CONNECTION_LOST_NEGOTIATING,
IMPLICITLY_UPGRADED_DISK,
IMPLICITLY_UPGRADED_PDSK,
};
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
union drbd_state ns, const char **warn_sync_abort); union drbd_state ns, enum sanitize_state_warnings *warn);
int drbd_send_state_req(struct drbd_conf *, int drbd_send_state_req(struct drbd_conf *,
union drbd_state, union drbd_state); union drbd_state, union drbd_state);
...@@ -803,6 +811,21 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns, ...@@ -803,6 +811,21 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
return rv; return rv;
} }
static void print_sanitize_warnings(struct drbd_conf *mdev, enum sanitize_state_warnings warn)
{
static const char *msg_table[] = {
[NO_WARNING] = "",
[ABORTED_ONLINE_VERIFY] = "Online-verify aborted.",
[ABORTED_RESYNC] = "Resync aborted.",
[CONNECTION_LOST_NEGOTIATING] = "Connection lost while negotiating, no data!",
[IMPLICITLY_UPGRADED_DISK] = "Implicitly upgraded disk",
[IMPLICITLY_UPGRADED_PDSK] = "Implicitly upgraded pdsk",
};
if (warn != NO_WARNING)
dev_warn(DEV, "%s\n", msg_table[warn]);
}
/** /**
* sanitize_state() - Resolves implicitly necessary additional changes to a state transition * sanitize_state() - Resolves implicitly necessary additional changes to a state transition
* @mdev: DRBD device. * @mdev: DRBD device.
...@@ -814,11 +837,14 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns, ...@@ -814,11 +837,14 @@ is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
* to D_UNKNOWN. This rule and many more along those lines are in this function. * to D_UNKNOWN. This rule and many more along those lines are in this function.
*/ */
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
union drbd_state ns, const char **warn_sync_abort) union drbd_state ns, enum sanitize_state_warnings *warn)
{ {
enum drbd_fencing_p fp; enum drbd_fencing_p fp;
enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max; enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max;
if (warn)
*warn = NO_WARNING;
fp = FP_DONT_CARE; fp = FP_DONT_CARE;
if (get_ldev(mdev)) { if (get_ldev(mdev)) {
fp = mdev->ldev->dc.fencing; fp = mdev->ldev->dc.fencing;
...@@ -863,10 +889,9 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -863,10 +889,9 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
/* Abort resync if a disk fails/detaches */ /* Abort resync if a disk fails/detaches */
if (os.conn > C_CONNECTED && ns.conn > C_CONNECTED && if (os.conn > C_CONNECTED && ns.conn > C_CONNECTED &&
(ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) { (ns.disk <= D_FAILED || ns.pdsk <= D_FAILED)) {
if (warn_sync_abort) if (warn)
*warn_sync_abort = *warn = os.conn == C_VERIFY_S || os.conn == C_VERIFY_T ?
os.conn == C_VERIFY_S || os.conn == C_VERIFY_T ? ABORTED_ONLINE_VERIFY : ABORTED_RESYNC;
"Online-verify" : "Resync";
ns.conn = C_CONNECTED; ns.conn = C_CONNECTED;
} }
...@@ -877,7 +902,8 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -877,7 +902,8 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
ns.disk = mdev->new_state_tmp.disk; ns.disk = mdev->new_state_tmp.disk;
ns.pdsk = mdev->new_state_tmp.pdsk; ns.pdsk = mdev->new_state_tmp.pdsk;
} else { } else {
dev_alert(DEV, "Connection lost while negotiating, no data!\n"); if (warn)
*warn = CONNECTION_LOST_NEGOTIATING;
ns.disk = D_DISKLESS; ns.disk = D_DISKLESS;
ns.pdsk = D_UNKNOWN; ns.pdsk = D_UNKNOWN;
} }
...@@ -959,16 +985,16 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state ...@@ -959,16 +985,16 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state
ns.disk = disk_max; ns.disk = disk_max;
if (ns.disk < disk_min) { if (ns.disk < disk_min) {
dev_warn(DEV, "Implicitly set disk from %s to %s\n", if (warn)
drbd_disk_str(ns.disk), drbd_disk_str(disk_min)); *warn = IMPLICITLY_UPGRADED_DISK;
ns.disk = disk_min; ns.disk = disk_min;
} }
if (ns.pdsk > pdsk_max) if (ns.pdsk > pdsk_max)
ns.pdsk = pdsk_max; ns.pdsk = pdsk_max;
if (ns.pdsk < pdsk_min) { if (ns.pdsk < pdsk_min) {
dev_warn(DEV, "Implicitly set pdsk from %s to %s\n", if (warn)
drbd_disk_str(ns.pdsk), drbd_disk_str(pdsk_min)); *warn = IMPLICITLY_UPGRADED_PDSK;
ns.pdsk = pdsk_min; ns.pdsk = pdsk_min;
} }
...@@ -1045,12 +1071,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, ...@@ -1045,12 +1071,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
{ {
union drbd_state os; union drbd_state os;
enum drbd_state_rv rv = SS_SUCCESS; enum drbd_state_rv rv = SS_SUCCESS;
const char *warn_sync_abort = NULL; enum sanitize_state_warnings ssw;
struct after_state_chg_work *ascw; struct after_state_chg_work *ascw;
os = mdev->state; os = mdev->state;
ns = sanitize_state(mdev, os, ns, &warn_sync_abort); ns = sanitize_state(mdev, os, ns, &ssw);
if (ns.i == os.i) if (ns.i == os.i)
return SS_NOTHING_TO_DO; return SS_NOTHING_TO_DO;
...@@ -1076,8 +1102,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, ...@@ -1076,8 +1102,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
return rv; return rv;
} }
if (warn_sync_abort) print_sanitize_warnings(mdev, ssw);
dev_warn(DEV, "%s aborted.\n", warn_sync_abort);
{ {
char *pbp, pb[300]; char *pbp, pb[300];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment