Skip to content

Commit 9ec7cab

Browse files
committed
ceph: hex dump corrupt server data to KERN_DEBUG
Also, print fsid using standard format, NOT hex dump. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent 93c20d9 commit 9ec7cab

10 files changed

Lines changed: 41 additions & 7 deletions

File tree

‎fs/ceph/caps.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
26812681

26822682
bad:
26832683
pr_err("ceph_handle_caps: corrupt message\n");
2684+
ceph_msg_dump(msg);
26842685
return;
26852686
}
26862687

‎fs/ceph/mds_client.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
16501650
return;
16511651
if (msg->front.iov_len < sizeof(*head)) {
16521652
pr_err("mdsc_handle_reply got corrupt (short) reply\n");
1653+
ceph_msg_dump(msg);
16531654
return;
16541655
}
16551656

@@ -1740,6 +1741,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
17401741
mutex_lock(&session->s_mutex);
17411742
if (err < 0) {
17421743
pr_err("mdsc_handle_reply got corrupt reply mds%d\n", mds);
1744+
ceph_msg_dump(msg);
17431745
goto out_err;
17441746
}
17451747

@@ -1929,6 +1931,7 @@ static void handle_session(struct ceph_mds_session *session,
19291931
bad:
19301932
pr_err("mdsc_handle_session corrupt message mds%d len %d\n", mds,
19311933
(int)msg->front.iov_len);
1934+
ceph_msg_dump(msg);
19321935
return;
19331936
}
19341937

@@ -2394,6 +2397,7 @@ static void handle_lease(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
23942397

23952398
bad:
23962399
pr_err("corrupt lease message\n");
2400+
ceph_msg_dump(msg);
23972401
}
23982402

23992403
void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,

‎fs/ceph/mdsmap.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
4949
struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
5050
{
5151
struct ceph_mdsmap *m;
52+
const void *start = *p;
5253
int i, j, n;
5354
int err = -EINVAL;
5455
u16 version;
@@ -154,6 +155,9 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
154155
err = -ENOMEM;
155156
bad:
156157
pr_err("corrupt mdsmap\n");
158+
print_hex_dump(KERN_DEBUG, "mdsmap: ",
159+
DUMP_PREFIX_OFFSET, 16, 1,
160+
start, end - start, true);
157161
ceph_mdsmap_destroy(m);
158162
return ERR_PTR(-EINVAL);
159163
}

‎fs/ceph/messenger.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,3 +2115,23 @@ void ceph_msg_last_put(struct kref *kref)
21152115
else
21162116
ceph_msg_kfree(m);
21172117
}
2118+
2119+
void ceph_msg_dump(struct ceph_msg *msg)
2120+
{
2121+
pr_debug("msg_dump %p (front_max %d nr_pages %d)\n", msg,
2122+
msg->front_max, msg->nr_pages);
2123+
print_hex_dump(KERN_DEBUG, "header: ",
2124+
DUMP_PREFIX_OFFSET, 16, 1,
2125+
&msg->hdr, sizeof(msg->hdr), true);
2126+
print_hex_dump(KERN_DEBUG, " front: ",
2127+
DUMP_PREFIX_OFFSET, 16, 1,
2128+
msg->front.iov_base, msg->front.iov_len, true);
2129+
if (msg->middle)
2130+
print_hex_dump(KERN_DEBUG, "middle: ",
2131+
DUMP_PREFIX_OFFSET, 16, 1,
2132+
msg->middle->vec.iov_base,
2133+
msg->middle->vec.iov_len, true);
2134+
print_hex_dump(KERN_DEBUG, "footer: ",
2135+
DUMP_PREFIX_OFFSET, 16, 1,
2136+
&msg->footer, sizeof(msg->footer), true);
2137+
}

‎fs/ceph/messenger.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,6 @@ static inline void ceph_msg_put(struct ceph_msg *msg)
254254
kref_put(&msg->kref, ceph_msg_last_put);
255255
}
256256

257+
extern void ceph_msg_dump(struct ceph_msg *msg);
258+
257259
#endif

‎fs/ceph/mon_client.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ static void handle_subscribe_ack(struct ceph_mon_client *monc,
242242
return;
243243
bad:
244244
pr_err("got corrupt subscribe-ack msg\n");
245+
ceph_msg_dump(msg);
245246
}
246247

247248
/*
@@ -364,6 +365,7 @@ static void handle_statfs_reply(struct ceph_mon_client *monc,
364365

365366
bad:
366367
pr_err("corrupt statfs reply, no tid\n");
368+
ceph_msg_dump(msg);
367369
}
368370

369371
/*

‎fs/ceph/osd_client.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
773773
pr_err("corrupt osd_op_reply got %d %d expected %d\n",
774774
(int)msg->front.iov_len, le32_to_cpu(msg->hdr.front_len),
775775
(int)sizeof(*rhead));
776+
ceph_msg_dump(msg);
776777
}
777778

778779

@@ -964,6 +965,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
964965

965966
bad:
966967
pr_err("osdc handle_map corrupt msg\n");
968+
ceph_msg_dump(msg);
967969
up_write(&osdc->map_sem);
968970
return;
969971
}

‎fs/ceph/osdmap.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
726726
bad:
727727
pr_err("corrupt inc osdmap epoch %d off %d (%p of %p-%p)\n",
728728
epoch, (int)(*p - start), *p, start, end);
729+
print_hex_dump(KERN_DEBUG, "osdmap: ",
730+
DUMP_PREFIX_OFFSET, 16, 1,
731+
start, end - start, true);
729732
if (newcrush)
730733
crush_destroy(newcrush);
731734
return ERR_PTR(err);

‎fs/ceph/snap.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
877877

878878
bad:
879879
pr_err("corrupt snap message from mds%d\n", mds);
880+
ceph_msg_dump(msg);
880881
out:
881882
if (locked_rwsem)
882883
up_write(&mdsc->snap_rwsem);

‎fs/ceph/super.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,8 @@ int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid)
602602
{
603603
if (client->have_fsid) {
604604
if (ceph_fsid_compare(&client->fsid, fsid)) {
605-
print_hex_dump(KERN_ERR, "this fsid: ",
606-
DUMP_PREFIX_NONE, 16, 1,
607-
(void *)fsid, 16, 0);
608-
print_hex_dump(KERN_ERR, " old fsid: ",
609-
DUMP_PREFIX_NONE, 16, 1,
610-
(void *)&client->fsid, 16, 0);
611-
pr_err("fsid mismatch\n");
605+
pr_err("bad fsid, had " FSID_FORMAT " got " FSID_FORMAT,
606+
PR_FSID(&client->fsid), PR_FSID(fsid));
612607
return -1;
613608
}
614609
} else {

0 commit comments

Comments
 (0)