Commit 706cb24c authored by Philipp Reisner's avatar Philipp Reisner

drbd: Improved logging of state changes

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent a6d00c8e
...@@ -384,6 +384,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n ...@@ -384,6 +384,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
char *pbp; char *pbp;
pbp = pb; pbp = pb;
*pbp = 0; *pbp = 0;
if (ns.role != os.role && flags & CS_DC_ROLE) if (ns.role != os.role && flags & CS_DC_ROLE)
pbp += sprintf(pbp, "role( %s -> %s ) ", pbp += sprintf(pbp, "role( %s -> %s ) ",
drbd_role_str(os.role), drbd_role_str(os.role),
...@@ -404,10 +405,18 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n ...@@ -404,10 +405,18 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
pbp += sprintf(pbp, "pdsk( %s -> %s ) ", pbp += sprintf(pbp, "pdsk( %s -> %s ) ",
drbd_disk_str(os.pdsk), drbd_disk_str(os.pdsk),
drbd_disk_str(ns.pdsk)); drbd_disk_str(ns.pdsk));
if (is_susp(ns) != is_susp(os))
pbp += sprintf(pbp, "susp( %d -> %d ) ", return pbp - pb;
is_susp(os), }
is_susp(ns));
static void drbd_pr_state_change(struct drbd_conf *mdev, union drbd_state os, union drbd_state ns,
enum chg_state_flags flags)
{
char pb[300];
char *pbp = pb;
pbp += print_state_change(pbp, os, ns, flags ^ CS_DC_MASK);
if (ns.aftr_isp != os.aftr_isp) if (ns.aftr_isp != os.aftr_isp)
pbp += sprintf(pbp, "aftr_isp( %d -> %d ) ", pbp += sprintf(pbp, "aftr_isp( %d -> %d ) ",
os.aftr_isp, os.aftr_isp,
...@@ -421,15 +430,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n ...@@ -421,15 +430,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
os.user_isp, os.user_isp,
ns.user_isp); ns.user_isp);
return pbp - pb; if (pbp != pb)
}
static void drbd_pr_state_change(struct drbd_conf *mdev, union drbd_state os, union drbd_state ns,
enum chg_state_flags flags)
{
char pb[300];
if (print_state_change(pb, os, ns, flags ^ CS_DC_MASK))
dev_info(DEV, "%s\n", pb); dev_info(DEV, "%s\n", pb);
} }
...@@ -437,8 +438,16 @@ static void conn_pr_state_change(struct drbd_tconn *tconn, union drbd_state os, ...@@ -437,8 +438,16 @@ static void conn_pr_state_change(struct drbd_tconn *tconn, union drbd_state os,
enum chg_state_flags flags) enum chg_state_flags flags)
{ {
char pb[300]; char pb[300];
char *pbp = pb;
pbp += print_state_change(pbp, os, ns, flags);
if (print_state_change(pb, os, ns, flags)) if (is_susp(ns) != is_susp(os) && flags & CS_DC_SUSP)
pbp += sprintf(pbp, "susp( %d -> %d ) ",
is_susp(os),
is_susp(ns));
if (pbp != pb)
conn_info(tconn, "%s\n", pb); conn_info(tconn, "%s\n", pb);
} }
...@@ -876,6 +885,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, ...@@ -876,6 +885,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
drbd_pr_state_change(mdev, os, ns, flags); drbd_pr_state_change(mdev, os, ns, flags);
/* Display changes to the susp* flags that where caused by the call to
sanitize_state(). Only display it here if we where not called from
_conn_request_state() */
if (!(flags & CS_DC_SUSP))
conn_pr_state_change(mdev->tconn, os, ns, (flags & ~CS_DC_MASK) | CS_DC_SUSP);
/* if we are going -> D_FAILED or D_DISKLESS, grab one extra reference /* if we are going -> D_FAILED or D_DISKLESS, grab one extra reference
* on the ldev here, to be sure the transition -> D_DISKLESS resp. * on the ldev here, to be sure the transition -> D_DISKLESS resp.
* drbd_ldev_destroy() won't happen before our corresponding * drbd_ldev_destroy() won't happen before our corresponding
...@@ -1628,6 +1643,7 @@ _conn_request_state(struct drbd_tconn *tconn, union drbd_state mask, union drbd_ ...@@ -1628,6 +1643,7 @@ _conn_request_state(struct drbd_tconn *tconn, union drbd_state mask, union drbd_
} }
conn_old_common_state(tconn, &os, &flags); conn_old_common_state(tconn, &os, &flags);
flags |= CS_DC_SUSP;
conn_set_state(tconn, mask, val, &ns_min, &ns_max, flags); conn_set_state(tconn, mask, val, &ns_min, &ns_max, flags);
conn_pr_state_change(tconn, os, ns_max, flags); conn_pr_state_change(tconn, os, ns_max, flags);
......
...@@ -68,8 +68,9 @@ enum chg_state_flags { ...@@ -68,8 +68,9 @@ enum chg_state_flags {
CS_DC_CONN = 1 << 7, CS_DC_CONN = 1 << 7,
CS_DC_DISK = 1 << 8, CS_DC_DISK = 1 << 8,
CS_DC_PDSK = 1 << 9, CS_DC_PDSK = 1 << 9,
CS_DC_SUSP = 1 << 10,
CS_DC_MASK = CS_DC_ROLE + CS_DC_PEER + CS_DC_CONN + CS_DC_DISK + CS_DC_PDSK, CS_DC_MASK = CS_DC_ROLE + CS_DC_PEER + CS_DC_CONN + CS_DC_DISK + CS_DC_PDSK,
CS_IGN_OUTD_FAIL = 1 << 10, CS_IGN_OUTD_FAIL = 1 << 11,
}; };
/* drbd_dev_state and drbd_state are different types. This is to stress the /* drbd_dev_state and drbd_state are different types. This is to stress the
......
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