aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-02-20 00:43:23 -0500
committerSage Weil <sage@newdream.net>2010-02-23 17:26:29 -0500
commit5b3a4db3e4009aff918abb1353eb3f4925393a7b (patch)
tree0f55666c827c3dfe31309209b69121e431366739 /fs/ceph
parentbcd2cbd10ce31c950a40c08d7f601f8ff23537b8 (diff)
ceph: fix up unexpected message handling
Fix skipping of unexpected message types from osd, mon. Clean up pr_info and debug output. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/messenger.c5
-rw-r--r--fs/ceph/mon_client.c14
-rw-r--r--fs/ceph/osd_client.c41
3 files changed, 43 insertions, 17 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
index ca2ad0e5bb28..fdda707aa137 100644
--- a/fs/ceph/messenger.c
+++ b/fs/ceph/messenger.c
@@ -1361,7 +1361,7 @@ static int read_partial_message(struct ceph_connection *con)
1361 con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip); 1361 con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip);
1362 if (skip) { 1362 if (skip) {
1363 /* skip this message */ 1363 /* skip this message */
1364 pr_err("alloc_msg returned NULL, skipping message\n"); 1364 dout("alloc_msg returned NULL, skipping message\n");
1365 con->in_base_pos = -front_len - middle_len - data_len - 1365 con->in_base_pos = -front_len - middle_len - data_len -
1366 sizeof(m->footer); 1366 sizeof(m->footer);
1367 con->in_tag = CEPH_MSGR_TAG_READY; 1367 con->in_tag = CEPH_MSGR_TAG_READY;
@@ -1370,7 +1370,8 @@ static int read_partial_message(struct ceph_connection *con)
1370 if (IS_ERR(con->in_msg)) { 1370 if (IS_ERR(con->in_msg)) {
1371 ret = PTR_ERR(con->in_msg); 1371 ret = PTR_ERR(con->in_msg);
1372 con->in_msg = NULL; 1372 con->in_msg = NULL;
1373 con->error_msg = "error allocating memory for incoming message"; 1373 con->error_msg =
1374 "error allocating memory for incoming message";
1374 return ret; 1375 return ret;
1375 } 1376 }
1376 m = con->in_msg; 1377 m = con->in_msg;
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 40d7d90bbed1..890597c09d43 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -763,7 +763,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
763 struct ceph_mon_client *monc = con->private; 763 struct ceph_mon_client *monc = con->private;
764 int type = le16_to_cpu(hdr->type); 764 int type = le16_to_cpu(hdr->type);
765 int front_len = le32_to_cpu(hdr->front_len); 765 int front_len = le32_to_cpu(hdr->front_len);
766 struct ceph_msg *m; 766 struct ceph_msg *m = NULL;
767 767
768 *skip = 0; 768 *skip = 0;
769 769
@@ -777,13 +777,17 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
777 case CEPH_MSG_AUTH_REPLY: 777 case CEPH_MSG_AUTH_REPLY:
778 m = ceph_msgpool_get(&monc->msgpool_auth_reply, front_len); 778 m = ceph_msgpool_get(&monc->msgpool_auth_reply, front_len);
779 break; 779 break;
780 default: 780 case CEPH_MSG_MON_MAP:
781 return NULL; 781 case CEPH_MSG_MDS_MAP:
782 case CEPH_MSG_OSD_MAP:
783 m = ceph_msg_new(type, front_len, 0, 0, NULL);
784 break;
782 } 785 }
783 786
784 if (!m) 787 if (!m) {
788 pr_info("alloc_msg unknown type %d\n", type);
785 *skip = 1; 789 *skip = 1;
786 790 }
787 return m; 791 return m;
788} 792}
789 793
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index fa0f73703954..ffd819c5a5dd 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -1396,31 +1396,30 @@ static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
1396 ceph_msg_put(msg); 1396 ceph_msg_put(msg);
1397} 1397}
1398 1398
1399static struct ceph_msg *alloc_msg(struct ceph_connection *con, 1399/*
1400 * lookup and return message for incoming reply
1401 */
1402static struct ceph_msg *get_reply(struct ceph_connection *con,
1400 struct ceph_msg_header *hdr, 1403 struct ceph_msg_header *hdr,
1401 int *skip) 1404 int *skip)
1402{ 1405{
1403 struct ceph_osd *osd = con->private; 1406 struct ceph_osd *osd = con->private;
1404 struct ceph_osd_client *osdc = osd->o_osdc; 1407 struct ceph_osd_client *osdc = osd->o_osdc;
1405 int type = le16_to_cpu(hdr->type);
1406 int front = le32_to_cpu(hdr->front_len);
1407 int data_len = le32_to_cpu(hdr->data_len);
1408 struct ceph_msg *m; 1408 struct ceph_msg *m;
1409 struct ceph_osd_request *req; 1409 struct ceph_osd_request *req;
1410 int front = le32_to_cpu(hdr->front_len);
1411 int data_len = le32_to_cpu(hdr->data_len);
1410 u64 tid; 1412 u64 tid;
1411 int err; 1413 int err;
1412 1414
1413 *skip = 0;
1414 if (type != CEPH_MSG_OSD_OPREPLY)
1415 return NULL;
1416
1417 tid = le64_to_cpu(hdr->tid); 1415 tid = le64_to_cpu(hdr->tid);
1418 mutex_lock(&osdc->request_mutex); 1416 mutex_lock(&osdc->request_mutex);
1419 req = __lookup_request(osdc, tid); 1417 req = __lookup_request(osdc, tid);
1420 if (!req) { 1418 if (!req) {
1421 *skip = 1; 1419 *skip = 1;
1422 m = NULL; 1420 m = NULL;
1423 dout("alloc_msg unknown tid %llu\n", tid); 1421 pr_info("alloc_msg unknown tid %llu from osd%d\n", tid,
1422 osd->o_osd);
1424 goto out; 1423 goto out;
1425 } 1424 }
1426 m = __get_next_reply(con, req, front); 1425 m = __get_next_reply(con, req, front);
@@ -1437,11 +1436,33 @@ static struct ceph_msg *alloc_msg(struct ceph_connection *con,
1437 m = ERR_PTR(err); 1436 m = ERR_PTR(err);
1438 } 1437 }
1439 } 1438 }
1439 *skip = 0;
1440 1440
1441out: 1441out:
1442 mutex_unlock(&osdc->request_mutex); 1442 mutex_unlock(&osdc->request_mutex);
1443
1444 return m; 1443 return m;
1444
1445}
1446
1447static struct ceph_msg *alloc_msg(struct ceph_connection *con,
1448 struct ceph_msg_header *hdr,
1449 int *skip)
1450{
1451 struct ceph_osd *osd = con->private;
1452 int type = le16_to_cpu(hdr->type);
1453 int front = le32_to_cpu(hdr->front_len);
1454
1455 switch (type) {
1456 case CEPH_MSG_OSD_MAP:
1457 return ceph_msg_new(type, front, 0, 0, NULL);
1458 case CEPH_MSG_OSD_OPREPLY:
1459 return get_reply(con, hdr, skip);
1460 default:
1461 pr_info("alloc_msg unexpected msg type %d from osd%d\n", type,
1462 osd->o_osd);
1463 *skip = 1;
1464 return NULL;
1465 }
1445} 1466}
1446 1467
1447/* 1468/*