From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 10/11] drbd: Improved logging of state changes
Date: Fri, 9 Sep 2011 13:17:35 +0200 [thread overview]
Message-ID: <1315567056-32314-11-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1315567056-32314-1-git-send-email-philipp.reisner@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_state.c | 44 ++++++++++++++++++++++++++------------
drivers/block/drbd/drbd_state.h | 3 +-
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 441d80f..694bd3f 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -366,6 +366,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
char *pbp;
pbp = pb;
*pbp = 0;
+
if (ns.role != os.role && flags & CS_DC_ROLE)
pbp += sprintf(pbp, "role( %s -> %s ) ",
drbd_role_str(os.role),
@@ -386,10 +387,18 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
pbp += sprintf(pbp, "pdsk( %s -> %s ) ",
drbd_disk_str(os.pdsk),
drbd_disk_str(ns.pdsk));
- if (is_susp(ns) != is_susp(os))
- pbp += sprintf(pbp, "susp( %d -> %d ) ",
- is_susp(os),
- is_susp(ns));
+
+ return 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];
+ char *pbp = pb;
+
+ pbp += print_state_change(pbp, os, ns, flags ^ CS_DC_MASK);
+
if (ns.aftr_isp != os.aftr_isp)
pbp += sprintf(pbp, "aftr_isp( %d -> %d ) ",
os.aftr_isp,
@@ -403,15 +412,7 @@ static long print_state_change(char *pb, union drbd_state os, union drbd_state n
os.user_isp,
ns.user_isp);
- return 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))
+ if (pbp != pb)
dev_info(DEV, "%s\n", pb);
}
@@ -419,8 +420,16 @@ static void conn_pr_state_change(struct drbd_tconn *tconn, union drbd_state os,
enum chg_state_flags flags)
{
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);
}
@@ -858,6 +867,12 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
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
* on the ldev here, to be sure the transition -> D_DISKLESS resp.
* drbd_ldev_destroy() won't happen before our corresponding
@@ -1610,6 +1625,7 @@ _conn_request_state(struct drbd_tconn *tconn, union drbd_state mask, union drbd_
}
conn_old_common_state(tconn, &os, &flags);
+ flags |= CS_DC_SUSP;
conn_set_state(tconn, mask, val, &ns_min, &ns_max, flags);
conn_pr_state_change(tconn, os, ns_max, flags);
diff --git a/drivers/block/drbd/drbd_state.h b/drivers/block/drbd/drbd_state.h
index 72e2053..a49bece 100644
--- a/drivers/block/drbd/drbd_state.h
+++ b/drivers/block/drbd/drbd_state.h
@@ -68,8 +68,9 @@ enum chg_state_flags {
CS_DC_CONN = 1 << 7,
CS_DC_DISK = 1 << 8,
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_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
--
1.7.4.1
next prev parent reply other threads:[~2011-09-09 11:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 11:17 [RFC 00/11] drbd: part 9 of adding multiple volume support to drbd Philipp Reisner
2011-09-09 11:17 ` [PATCH 01/11] drbd: Introduced drbd_read_state() Philipp Reisner
2011-09-09 11:17 ` [PATCH 02/11] drbd: Renamed id_susp(union drbd_state s) to drbd_suspended(struct drbd_conf *) Philipp Reisner
2011-09-09 11:17 ` [PATCH 03/11] drbd: Moved susp, susp_nod and susp_fen to the connection object Philipp Reisner
2011-09-09 11:17 ` [PATCH 04/11] drbd: Introduced a new type union drbd_dev_state Philipp Reisner
2011-09-09 11:17 ` [PATCH 05/11] drbd: Renamed nms to ns_max Philipp Reisner
2011-09-09 11:17 ` [PATCH 06/11] drbd: Calculate and provide ns_min to the w_after_conn_state_ch() work Philipp Reisner
2011-09-09 11:17 ` [PATCH 07/11] drbd: Implemented conn_lowest_conn() Philipp Reisner
2011-09-09 11:17 ` [PATCH 08/11] drbd: Implemented conn_lowest_disk() Philipp Reisner
2011-09-09 11:17 ` [PATCH 09/11] drbd: Implemented IO thawing for multiple volumes Philipp Reisner
2011-09-09 11:17 ` Philipp Reisner [this message]
2011-09-09 11:17 ` [PATCH 11/11] drbd: Use tconn in request_timer_fn() Philipp Reisner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315567056-32314-11-git-send-email-philipp.reisner@linbit.com \
--to=philipp.reisner@linbit.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®