aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-02-25 19:11:12 -0500
committerSage Weil <sage@inktank.com>2013-02-26 18:02:50 -0500
commit1b83bef24c6746a146d39915a18fb5425f2facb0 (patch)
treea765aeb136f4c7e354c01314e5fdfb776d503fb7 /drivers/block
parent2169aea649c08374bec7d220a3b8f64712275356 (diff)
libceph: update osd request/reply encoding
Use the new version of the encoding for osd requests and replies. In the process, update the way we are tracking request ops and reply lengths and results in the struct ceph_osd_request. Update the rbd and fs/ceph users appropriately. The main changes are: - we keep pointers into the request memory for fields we need to update each time the request is sent out over the wire - we keep information about the result in an array in the request struct where the users can easily get at it. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 22085e86a409..6c81a4c040b9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -196,7 +196,7 @@ struct rbd_obj_request {
196 196
197 u64 xferred; /* bytes transferred */ 197 u64 xferred; /* bytes transferred */
198 u64 version; 198 u64 version;
199 s32 result; 199 int result;
200 atomic_t done; 200 atomic_t done;
201 201
202 rbd_obj_callback_t callback; 202 rbd_obj_callback_t callback;
@@ -1282,12 +1282,19 @@ static void rbd_osd_trivial_callback(struct rbd_obj_request *obj_request)
1282 1282
1283static void rbd_osd_read_callback(struct rbd_obj_request *obj_request) 1283static void rbd_osd_read_callback(struct rbd_obj_request *obj_request)
1284{ 1284{
1285
1286 dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request, 1285 dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request,
1287 obj_request->result, obj_request->xferred, obj_request->length); 1286 obj_request->result, obj_request->xferred, obj_request->length);
1288 if (obj_request->result == (s32) -ENOENT) { 1287 /*
1288 * ENOENT means a hole in the object. We zero-fill the
1289 * entire length of the request. A short read also implies
1290 * zero-fill to the end of the request. Either way we
1291 * update the xferred count to indicate the whole request
1292 * was satisfied.
1293 */
1294 if (obj_request->result == -ENOENT) {
1289 zero_bio_chain(obj_request->bio_list, 0); 1295 zero_bio_chain(obj_request->bio_list, 0);
1290 obj_request->result = 0; 1296 obj_request->result = 0;
1297 obj_request->xferred = obj_request->length;
1291 } else if (obj_request->xferred < obj_request->length && 1298 } else if (obj_request->xferred < obj_request->length &&
1292 !obj_request->result) { 1299 !obj_request->result) {
1293 zero_bio_chain(obj_request->bio_list, obj_request->xferred); 1300 zero_bio_chain(obj_request->bio_list, obj_request->xferred);
@@ -1298,20 +1305,14 @@ static void rbd_osd_read_callback(struct rbd_obj_request *obj_request)
1298 1305
1299static void rbd_osd_write_callback(struct rbd_obj_request *obj_request) 1306static void rbd_osd_write_callback(struct rbd_obj_request *obj_request)
1300{ 1307{
1301 dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request, 1308 dout("%s: obj %p result %d %llu\n", __func__, obj_request,
1302 obj_request->result, obj_request->xferred, obj_request->length); 1309 obj_request->result, obj_request->length);
1303 1310 /*
1304 /* A short write really shouldn't occur. Warn if we see one */ 1311 * There is no such thing as a successful short write.
1305 1312 * Our xferred value is the number of bytes transferred
1306 if (obj_request->xferred != obj_request->length) { 1313 * back. Set it to our originally-requested length.
1307 struct rbd_img_request *img_request = obj_request->img_request; 1314 */
1308 struct rbd_device *rbd_dev; 1315 obj_request->xferred = obj_request->length;
1309
1310 rbd_dev = img_request ? img_request->rbd_dev : NULL;
1311 rbd_warn(rbd_dev, "wrote %llu want %llu\n",
1312 obj_request->xferred, obj_request->length);
1313 }
1314
1315 obj_request_done_set(obj_request); 1316 obj_request_done_set(obj_request);
1316} 1317}
1317 1318
@@ -1329,9 +1330,6 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
1329 struct ceph_msg *msg) 1330 struct ceph_msg *msg)
1330{ 1331{
1331 struct rbd_obj_request *obj_request = osd_req->r_priv; 1332 struct rbd_obj_request *obj_request = osd_req->r_priv;
1332 struct ceph_osd_reply_head *reply_head;
1333 struct ceph_osd_op *op;
1334 u32 num_ops;
1335 u16 opcode; 1333 u16 opcode;
1336 1334
1337 dout("%s: osd_req %p msg %p\n", __func__, osd_req, msg); 1335 dout("%s: osd_req %p msg %p\n", __func__, osd_req, msg);
@@ -1339,22 +1337,19 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
1339 rbd_assert(!!obj_request->img_request ^ 1337 rbd_assert(!!obj_request->img_request ^
1340 (obj_request->which == BAD_WHICH)); 1338 (obj_request->which == BAD_WHICH));
1341 1339
1342 reply_head = msg->front.iov_base; 1340 if (osd_req->r_result < 0)
1343 obj_request->result = (s32) le32_to_cpu(reply_head->result); 1341 obj_request->result = osd_req->r_result;
1344 obj_request->version = le64_to_cpu(osd_req->r_reassert_version.version); 1342 obj_request->version = le64_to_cpu(osd_req->r_reassert_version.version);
1345 1343
1346 num_ops = le32_to_cpu(reply_head->num_ops); 1344 WARN_ON(osd_req->r_num_ops != 1); /* For now */
1347 WARN_ON(num_ops != 1); /* For now */
1348 1345
1349 /* 1346 /*
1350 * We support a 64-bit length, but ultimately it has to be 1347 * We support a 64-bit length, but ultimately it has to be
1351 * passed to blk_end_request(), which takes an unsigned int. 1348 * passed to blk_end_request(), which takes an unsigned int.
1352 */ 1349 */
1353 op = &reply_head->ops[0]; 1350 obj_request->xferred = osd_req->r_reply_op_len[0];
1354 obj_request->xferred = le64_to_cpu(op->extent.length);
1355 rbd_assert(obj_request->xferred < (u64) UINT_MAX); 1351 rbd_assert(obj_request->xferred < (u64) UINT_MAX);
1356 1352 opcode = osd_req->r_request_ops[0].op;
1357 opcode = le16_to_cpu(op->op);
1358 switch (opcode) { 1353 switch (opcode) {
1359 case CEPH_OSD_OP_READ: 1354 case CEPH_OSD_OP_READ:
1360 rbd_osd_read_callback(obj_request); 1355 rbd_osd_read_callback(obj_request);
@@ -1719,6 +1714,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
1719 more = blk_end_request(img_request->rq, result, xferred); 1714 more = blk_end_request(img_request->rq, result, xferred);
1720 which++; 1715 which++;
1721 } 1716 }
1717
1722 rbd_assert(more ^ (which == img_request->obj_request_count)); 1718 rbd_assert(more ^ (which == img_request->obj_request_count));
1723 img_request->next_completion = which; 1719 img_request->next_completion = which;
1724out: 1720out: