diff options
author | Sage Weil <sage@newdream.net> | 2010-03-04 13:22:59 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:11 -0400 |
commit | 21b667f69b023979410188d7d94c9b219f216626 (patch) | |
tree | 7f6fd28d03fe97e1f4febd3ee5f8522e2f6a86dc /fs | |
parent | 81a6cf2d30eac5d790f53cdff110892f7b18c7fe (diff) |
ceph: simplify page setup for incoming data
Drop largely useless helper __prepare_pages(), and simplify sanity checks.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/osd_client.c | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index 3514f71ff85f..22a33f8c8807 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -1087,45 +1087,6 @@ bad: | |||
1087 | return; | 1087 | return; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | |||
1091 | /* | ||
1092 | * A read request prepares specific pages that data is to be read into. | ||
1093 | * When a message is being read off the wire, we call prepare_pages to | ||
1094 | * find those pages. | ||
1095 | * 0 = success, -1 failure. | ||
1096 | */ | ||
1097 | static int __prepare_pages(struct ceph_connection *con, | ||
1098 | struct ceph_msg_header *hdr, | ||
1099 | struct ceph_osd_request *req, | ||
1100 | u64 tid, | ||
1101 | struct ceph_msg *m) | ||
1102 | { | ||
1103 | struct ceph_osd *osd = con->private; | ||
1104 | struct ceph_osd_client *osdc; | ||
1105 | int ret = -1; | ||
1106 | int data_len = le32_to_cpu(hdr->data_len); | ||
1107 | unsigned data_off = le16_to_cpu(hdr->data_off); | ||
1108 | |||
1109 | int want = calc_pages_for(data_off & ~PAGE_MASK, data_len); | ||
1110 | |||
1111 | if (!osd) | ||
1112 | return -1; | ||
1113 | |||
1114 | osdc = osd->o_osdc; | ||
1115 | |||
1116 | dout("__prepare_pages on msg %p tid %llu, has %d pages, want %d\n", m, | ||
1117 | tid, req->r_num_pages, want); | ||
1118 | if (unlikely(req->r_num_pages < want)) | ||
1119 | goto out; | ||
1120 | m->pages = req->r_pages; | ||
1121 | m->nr_pages = req->r_num_pages; | ||
1122 | ret = 0; /* success */ | ||
1123 | out: | ||
1124 | BUG_ON(ret < 0 || m->nr_pages < want); | ||
1125 | |||
1126 | return ret; | ||
1127 | } | ||
1128 | |||
1129 | /* | 1090 | /* |
1130 | * Register request, send initial attempt. | 1091 | * Register request, send initial attempt. |
1131 | */ | 1092 | */ |
@@ -1394,7 +1355,8 @@ static void dispatch(struct ceph_connection *con, struct ceph_msg *msg) | |||
1394 | } | 1355 | } |
1395 | 1356 | ||
1396 | /* | 1357 | /* |
1397 | * lookup and return message for incoming reply | 1358 | * lookup and return message for incoming reply. set up reply message |
1359 | * pages. | ||
1398 | */ | 1360 | */ |
1399 | static struct ceph_msg *get_reply(struct ceph_connection *con, | 1361 | static struct ceph_msg *get_reply(struct ceph_connection *con, |
1400 | struct ceph_msg_header *hdr, | 1362 | struct ceph_msg_header *hdr, |
@@ -1407,7 +1369,6 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, | |||
1407 | int front = le32_to_cpu(hdr->front_len); | 1369 | int front = le32_to_cpu(hdr->front_len); |
1408 | int data_len = le32_to_cpu(hdr->data_len); | 1370 | int data_len = le32_to_cpu(hdr->data_len); |
1409 | u64 tid; | 1371 | u64 tid; |
1410 | int err; | ||
1411 | 1372 | ||
1412 | tid = le64_to_cpu(hdr->tid); | 1373 | tid = le64_to_cpu(hdr->tid); |
1413 | mutex_lock(&osdc->request_mutex); | 1374 | mutex_lock(&osdc->request_mutex); |
@@ -1439,12 +1400,19 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, | |||
1439 | m = ceph_msg_get(req->r_reply); | 1400 | m = ceph_msg_get(req->r_reply); |
1440 | 1401 | ||
1441 | if (data_len > 0) { | 1402 | if (data_len > 0) { |
1442 | err = __prepare_pages(con, hdr, req, tid, m); | 1403 | unsigned data_off = le16_to_cpu(hdr->data_off); |
1443 | if (err < 0) { | 1404 | int want = calc_pages_for(data_off & ~PAGE_MASK, data_len); |
1405 | |||
1406 | if (unlikely(req->r_num_pages < want)) { | ||
1407 | pr_warning("tid %lld reply %d > expected %d pages\n", | ||
1408 | tid, want, m->nr_pages); | ||
1444 | *skip = 1; | 1409 | *skip = 1; |
1445 | ceph_msg_put(m); | 1410 | ceph_msg_put(m); |
1446 | m = ERR_PTR(err); | 1411 | m = ERR_PTR(-EIO); |
1412 | goto out; | ||
1447 | } | 1413 | } |
1414 | m->pages = req->r_pages; | ||
1415 | m->nr_pages = req->r_num_pages; | ||
1448 | } | 1416 | } |
1449 | *skip = 0; | 1417 | *skip = 0; |
1450 | req->r_con_filling_msg = ceph_con_get(con); | 1418 | req->r_con_filling_msg = ceph_con_get(con); |