Commit aedbcc28 authored by Philipp Reisner's avatar Philipp Reisner

drbd-8.3: drbd_strings: symblol clashes, drbd_bitmap: assert

 drbd_strings: Renamed the functions to the drbd_ namespace; export them from drbd.ko to drbd_trace.ko
 drbd_bitmap: set bits: do not trigger assert for aligned very last bit.
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent e19ad91c
......@@ -2,7 +2,7 @@ drbd-y := drbd_bitmap.o drbd_proc.o
drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o
drbd-y += drbd_main.o drbd_strings.o drbd_nl.o
drbd_trace-y := drbd_tracing.o drbd_strings.o
drbd_trace-y := drbd_tracing.o
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o
obj-$(CONFIG_DRBD_TRACE) += drbd_trace.o
......@@ -1096,8 +1096,9 @@ static inline void bm_set_full_words_within_one_page(struct drbd_bitmap *b,
kunmap_atomic(paddr, KM_USER0);
}
/* same thing as drbd_bm_set_bits, but without taking the spin_lock_irqsave.
* you must first drbd_bm_lock().
/* Same thing as drbd_bm_set_bits, but without taking the spin_lock_irqsave.
* You must first drbd_bm_lock().
* Can be called to set the whole bitmap in one go.
* Sets bits from s to e _inclusive_. */
void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsigned long e)
{
......@@ -1106,7 +1107,7 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi
* then assign full words up to the last long boundary (el),
* then set_bit up to and including the last bit (e).
*
* Do not use memset, because we have need to account for changes,
* Do not use memset, because we must account for changes,
* so we need to loop over the words with hweight() anyways.
*/
unsigned long sl = ALIGN(s,BITS_PER_LONG);
......@@ -1148,8 +1149,13 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi
last_word = MLPP(el >> LN2_BPL);
bm_set_full_words_within_one_page(mdev->bitmap, last_page, first_word, last_word);
/* possibly trailing bits */
__bm_change_bits_to(mdev, el, e, 1, KM_USER0);
/* possibly trailing bits.
* example: (e & 63) == 63, el will be e+1.
* if that even was the very last bit,
* it would trigger an assert in __bm_change_bits_to()
*/
if (el <= e)
__bm_change_bits_to(mdev, el, e, 1, KM_USER0);
}
/* returns bit state
......
......@@ -1486,8 +1486,8 @@ void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo);
/* drbd_proc.c */
extern struct proc_dir_entry *drbd_proc;
extern struct file_operations drbd_proc_fops;
extern const char *conns_to_name(enum drbd_conns s);
extern const char *roles_to_name(enum drbd_role s);
extern const char *drbd_conn_str(enum drbd_conns s);
extern const char *drbd_role_str(enum drbd_role s);
/* drbd_actlog.c */
extern void drbd_al_begin_io(struct drbd_conf *mdev, sector_t sector);
......@@ -2002,7 +2002,7 @@ static inline void drbd_get_syncer_progress(struct drbd_conf *mdev,
*/
smp_rmb();
dev_warn(DEV, "cs:%s rs_left=%lu > rs_total=%lu (rs_failed %lu)\n",
conns_to_name(mdev->state.conn),
drbd_conn_str(mdev->state.conn),
*bits_left, mdev->rs_total, mdev->rs_failed);
*per_mil_done = 0;
} else {
......
......@@ -664,11 +664,11 @@ static void print_st(struct drbd_conf *mdev, char *name, union drbd_state ns)
{
dev_err(DEV, " %s = { cs:%s ro:%s/%s ds:%s/%s %c%c%c%c }\n",
name,
conns_to_name(ns.conn),
roles_to_name(ns.role),
roles_to_name(ns.peer),
disks_to_name(ns.disk),
disks_to_name(ns.pdsk),
drbd_conn_str(ns.conn),
drbd_role_str(ns.role),
drbd_role_str(ns.peer),
drbd_disk_str(ns.disk),
drbd_disk_str(ns.pdsk),
ns.susp ? 's' : 'r',
ns.aftr_isp ? 'a' : '-',
ns.peer_isp ? 'p' : '-',
......@@ -681,25 +681,25 @@ void print_st_err(struct drbd_conf *mdev,
{
if (err == SS_IN_TRANSIENT_STATE)
return;
dev_err(DEV, "State change failed: %s\n", set_st_err_name(err));
dev_err(DEV, "State change failed: %s\n", drbd_set_st_err_str(err));
print_st(mdev, " state", os);
print_st(mdev, "wanted", ns);
}
#define peers_to_name roles_to_name
#define pdsks_to_name disks_to_name
#define drbd_peer_str drbd_role_str
#define drbd_pdsk_str drbd_disk_str
#define susps_to_name(A) ((A) ? "1" : "0")
#define aftr_isps_to_name(A) ((A) ? "1" : "0")
#define peer_isps_to_name(A) ((A) ? "1" : "0")
#define user_isps_to_name(A) ((A) ? "1" : "0")
#define drbd_susp_str(A) ((A) ? "1" : "0")
#define drbd_aftr_isp_str(A) ((A) ? "1" : "0")
#define drbd_peer_isp_str(A) ((A) ? "1" : "0")
#define drbd_user_isp_str(A) ((A) ? "1" : "0")
#define PSC(A) \
({ if (ns.A != os.A) { \
pbp += sprintf(pbp, #A "( %s -> %s ) ", \
A##s_to_name(os.A), \
A##s_to_name(ns.A)); \
drbd_##A##_str(os.A), \
drbd_##A##_str(ns.A)); \
} })
/**
......@@ -1006,7 +1006,7 @@ int __drbd_set_state(struct drbd_conf *mdev,
if (is_valid_state(mdev, os) == rv) {
dev_err(DEV, "Considering state change from bad state. "
"Error would be: '%s'\n",
set_st_err_name(rv));
drbd_set_st_err_str(rv));
print_st(mdev, "old", os);
print_st(mdev, "new", ns);
rv = is_valid_state_transition(mdev, ns, os);
......@@ -3745,3 +3745,9 @@ const char *drbd_buildtag(void)
module_init(drbd_init)
module_exit(drbd_cleanup)
/* For drbd_tracing: */
EXPORT_SYMBOL(drbd_conn_str);
EXPORT_SYMBOL(drbd_role_str);
EXPORT_SYMBOL(drbd_disk_str);
EXPORT_SYMBOL(drbd_set_st_err_str);
......@@ -190,7 +190,7 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "\n");
}
sn = conns_to_name(mdev->state.conn);
sn = drbd_conn_str(mdev->state.conn);
if (mdev->state.conn == C_STANDALONE &&
mdev->state.disk == D_DISKLESS &&
......@@ -202,10 +202,10 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
" ns:%u nr:%u dw:%u dr:%u al:%u bm:%u "
"lo:%d pe:%d ua:%d ap:%d ep:%d wo:%c",
i, sn,
roles_to_name(mdev->state.role),
roles_to_name(mdev->state.peer),
disks_to_name(mdev->state.disk),
disks_to_name(mdev->state.pdsk),
drbd_role_str(mdev->state.role),
drbd_role_str(mdev->state.peer),
drbd_disk_str(mdev->state.disk),
drbd_disk_str(mdev->state.pdsk),
(mdev->net_conf == NULL ? ' ' :
(mdev->net_conf->wire_protocol - DRBD_PROT_A+'A')),
mdev->state.susp ? 's' : 'r',
......
......@@ -2043,7 +2043,7 @@ static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h)
if (mdev->state.conn >= C_CONNECTED &&
mdev->state.conn != C_VERIFY_T)
dev_warn(DEV, "ASSERT FAILED: got P_OV_REQUEST while being %s\n",
conns_to_name(mdev->state.conn));
drbd_conn_str(mdev->state.conn));
if (mdev->ov_start_sector == ~(sector_t)0 &&
mdev->agreed_pro_version >= 90) {
mdev->ov_start_sector = sector;
......@@ -3014,7 +3014,7 @@ static int receive_state(struct drbd_conf *mdev, struct p_header *h)
real_peer_disk = peer_state.disk;
if (peer_state.disk == D_NEGOTIATING) {
real_peer_disk = mdev->p_uuid[UI_FLAGS] & 4 ? D_INCONSISTENT : D_CONSISTENT;
dev_info(DEV, "real peer disk state = %s\n", disks_to_name(real_peer_disk));
dev_info(DEV, "real peer disk state = %s\n", drbd_disk_str(real_peer_disk));
}
spin_lock_irq(&mdev->req_lock);
......@@ -3354,7 +3354,7 @@ static int receive_bitmap(struct drbd_conf *mdev, struct p_header *h)
/* admin may have requested C_DISCONNECTING,
* other threads may have noticed network errors */
dev_info(DEV, "unexpected cstate (%s) in receive_bitmap\n",
conns_to_name(mdev->state.conn));
drbd_conn_str(mdev->state.conn));
}
ok = TRUE;
......@@ -3511,7 +3511,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
return;
if (mdev->state.conn >= C_WF_CONNECTION)
dev_err(DEV, "ASSERT FAILED cstate = %s, expected < WFConnection\n",
conns_to_name(mdev->state.conn));
drbd_conn_str(mdev->state.conn));
/* asender does not clean up anything. it must not interfere, either */
drbd_thread_stop(&mdev->asender);
......@@ -3948,7 +3948,7 @@ static int got_RqSReply(struct drbd_conf *mdev, struct p_header *h)
} else {
set_bit(CL_ST_CHG_FAIL, &mdev->flags);
dev_err(DEV, "Requested state change failed by peer: %s (%d)\n",
set_st_err_name(retcode), retcode);
drbd_set_st_err_str(retcode), retcode);
}
wake_up(&mdev->state_wait);
......
......@@ -89,23 +89,23 @@ static const char *drbd_state_sw_errors[] = {
[-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted",
};
const char *conns_to_name(enum drbd_conns s)
const char *drbd_conn_str(enum drbd_conns s)
{
/* enums are unsigned... */
return s > C_PAUSED_SYNC_T ? "TOO_LARGE" : drbd_conn_s_names[s];
}
const char *roles_to_name(enum drbd_role s)
const char *drbd_role_str(enum drbd_role s)
{
return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s];
}
const char *disks_to_name(enum drbd_disk_state s)
const char *drbd_disk_str(enum drbd_disk_state s)
{
return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s];
}
const char *set_st_err_name(enum drbd_state_ret_codes err)
const char *drbd_set_st_err_str(enum drbd_state_ret_codes err)
{
return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" :
err > SS_TWO_PRIMARIES ? "TOO_LARGE"
......
......@@ -484,19 +484,19 @@ static void probe_drbd_req(struct drbd_request *req, enum drbd_req_event what, c
req->epoch,
(unsigned long long)req->sector,
req->size,
conns_to_name(mdev->state.conn));
drbd_conn_str(mdev->state.conn));
}
}
#define peers_to_name roles_to_name
#define pdsks_to_name disks_to_name
#define drbd_peer_str drbd_role_str
#define drbd_pdsk_str drbd_disk_str
#define PSM(A) \
do { \
if (mask.A) { \
int i = snprintf(p, len, " " #A "( %s )", \
A##s_to_name(val.A)); \
drbd_##A##_str(val.A)); \
if (i >= len) \
return op; \
p += i; \
......
......@@ -433,7 +433,7 @@ int w_make_resync_request(struct drbd_conf *mdev,
if (mdev->state.conn != C_SYNC_TARGET)
dev_err(DEV, "%s in w_make_resync_request\n",
conns_to_name(mdev->state.conn));
drbd_conn_str(mdev->state.conn));
if (!get_ldev(mdev)) {
/* Since we only need to access mdev->rsync a
......@@ -1397,7 +1397,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
if (r == SS_SUCCESS) {
dev_info(DEV, "Began resync as %s (will sync %lu KB [%lu bits set]).\n",
conns_to_name(ns.conn),
drbd_conn_str(ns.conn),
(unsigned long) mdev->rs_total << (BM_BLOCK_SHIFT-10),
(unsigned long) mdev->rs_total);
......
......@@ -275,10 +275,10 @@ enum drbd_state_ret_codes {
};
/* from drbd_strings.c */
extern const char *conns_to_name(enum drbd_conns);
extern const char *roles_to_name(enum drbd_role);
extern const char *disks_to_name(enum drbd_disk_state);
extern const char *set_st_err_name(enum drbd_state_ret_codes);
extern const char *drbd_conn_str(enum drbd_conns);
extern const char *drbd_role_str(enum drbd_role);
extern const char *drbd_disk_str(enum drbd_disk_state);
extern const char *drbd_set_st_err_str(enum drbd_state_ret_codes);
#define SHARED_SECRET_MAX 64
......
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