diff options
author | Alex Elder <elder@inktank.com> | 2013-02-20 18:32:08 -0500 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2013-02-25 16:36:56 -0500 |
commit | 37206ee5bede14d59306fea3af4c0105d4712342 (patch) | |
tree | ca7070823a9e633aeca57dbca8d2c277ad58053d | |
parent | 632b88cadece050ca925d74bda250c4a320c5cc7 (diff) |
rbd: normalize dout() calls
Add dout() calls to facilitate tracing of image and object requests.
Change a few existing calls so they use __func__ rather than the
hard-coded function name. Have calls always add ":" after the name
of the function, and prefix pointer values with a consistent tag
indicating what it represents. (Note that there remain some older
dout() calls that are left untouched by this patch.)
Issue a warning if rbd_osd_write_callback() ever gets a short write.
This resolves:
http://tracker.ceph.com/issues/4235
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | drivers/block/rbd.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index bd6078bf99d3..a9c86ca5889f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -443,7 +443,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) | |||
443 | struct rbd_client *rbdc; | 443 | struct rbd_client *rbdc; |
444 | int ret = -ENOMEM; | 444 | int ret = -ENOMEM; |
445 | 445 | ||
446 | dout("rbd_client_create\n"); | 446 | dout("%s:\n", __func__); |
447 | rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); | 447 | rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); |
448 | if (!rbdc) | 448 | if (!rbdc) |
449 | goto out_opt; | 449 | goto out_opt; |
@@ -467,8 +467,8 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) | |||
467 | spin_unlock(&rbd_client_list_lock); | 467 | spin_unlock(&rbd_client_list_lock); |
468 | 468 | ||
469 | mutex_unlock(&ctl_mutex); | 469 | mutex_unlock(&ctl_mutex); |
470 | dout("%s: rbdc %p\n", __func__, rbdc); | ||
470 | 471 | ||
471 | dout("rbd_client_create created %p\n", rbdc); | ||
472 | return rbdc; | 472 | return rbdc; |
473 | 473 | ||
474 | out_err: | 474 | out_err: |
@@ -479,6 +479,8 @@ out_mutex: | |||
479 | out_opt: | 479 | out_opt: |
480 | if (ceph_opts) | 480 | if (ceph_opts) |
481 | ceph_destroy_options(ceph_opts); | 481 | ceph_destroy_options(ceph_opts); |
482 | dout("%s: error %d\n", __func__, ret); | ||
483 | |||
482 | return ERR_PTR(ret); | 484 | return ERR_PTR(ret); |
483 | } | 485 | } |
484 | 486 | ||
@@ -605,7 +607,7 @@ static void rbd_client_release(struct kref *kref) | |||
605 | { | 607 | { |
606 | struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); | 608 | struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); |
607 | 609 | ||
608 | dout("rbd_release_client %p\n", rbdc); | 610 | dout("%s: rbdc %p\n", __func__, rbdc); |
609 | spin_lock(&rbd_client_list_lock); | 611 | spin_lock(&rbd_client_list_lock); |
610 | list_del(&rbdc->node); | 612 | list_del(&rbdc->node); |
611 | spin_unlock(&rbd_client_list_lock); | 613 | spin_unlock(&rbd_client_list_lock); |
@@ -1064,6 +1066,8 @@ out_err: | |||
1064 | 1066 | ||
1065 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) | 1067 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) |
1066 | { | 1068 | { |
1069 | dout("%s: obj %p (was %d)\n", __func__, obj_request, | ||
1070 | atomic_read(&obj_request->kref.refcount)); | ||
1067 | kref_get(&obj_request->kref); | 1071 | kref_get(&obj_request->kref); |
1068 | } | 1072 | } |
1069 | 1073 | ||
@@ -1071,11 +1075,15 @@ static void rbd_obj_request_destroy(struct kref *kref); | |||
1071 | static void rbd_obj_request_put(struct rbd_obj_request *obj_request) | 1075 | static void rbd_obj_request_put(struct rbd_obj_request *obj_request) |
1072 | { | 1076 | { |
1073 | rbd_assert(obj_request != NULL); | 1077 | rbd_assert(obj_request != NULL); |
1078 | dout("%s: obj %p (was %d)\n", __func__, obj_request, | ||
1079 | atomic_read(&obj_request->kref.refcount)); | ||
1074 | kref_put(&obj_request->kref, rbd_obj_request_destroy); | 1080 | kref_put(&obj_request->kref, rbd_obj_request_destroy); |
1075 | } | 1081 | } |
1076 | 1082 | ||
1077 | static void rbd_img_request_get(struct rbd_img_request *img_request) | 1083 | static void rbd_img_request_get(struct rbd_img_request *img_request) |
1078 | { | 1084 | { |
1085 | dout("%s: img %p (was %d)\n", __func__, img_request, | ||
1086 | atomic_read(&img_request->kref.refcount)); | ||
1079 | kref_get(&img_request->kref); | 1087 | kref_get(&img_request->kref); |
1080 | } | 1088 | } |
1081 | 1089 | ||
@@ -1083,6 +1091,8 @@ static void rbd_img_request_destroy(struct kref *kref); | |||
1083 | static void rbd_img_request_put(struct rbd_img_request *img_request) | 1091 | static void rbd_img_request_put(struct rbd_img_request *img_request) |
1084 | { | 1092 | { |
1085 | rbd_assert(img_request != NULL); | 1093 | rbd_assert(img_request != NULL); |
1094 | dout("%s: img %p (was %d)\n", __func__, img_request, | ||
1095 | atomic_read(&img_request->kref.refcount)); | ||
1086 | kref_put(&img_request->kref, rbd_img_request_destroy); | 1096 | kref_put(&img_request->kref, rbd_img_request_destroy); |
1087 | } | 1097 | } |
1088 | 1098 | ||
@@ -1097,6 +1107,8 @@ static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, | |||
1097 | rbd_assert(obj_request->which != BAD_WHICH); | 1107 | rbd_assert(obj_request->which != BAD_WHICH); |
1098 | img_request->obj_request_count++; | 1108 | img_request->obj_request_count++; |
1099 | list_add_tail(&obj_request->links, &img_request->obj_requests); | 1109 | list_add_tail(&obj_request->links, &img_request->obj_requests); |
1110 | dout("%s: img %p obj %p w=%u\n", __func__, img_request, obj_request, | ||
1111 | obj_request->which); | ||
1100 | } | 1112 | } |
1101 | 1113 | ||
1102 | static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, | 1114 | static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, |
@@ -1104,6 +1116,8 @@ static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, | |||
1104 | { | 1116 | { |
1105 | rbd_assert(obj_request->which != BAD_WHICH); | 1117 | rbd_assert(obj_request->which != BAD_WHICH); |
1106 | 1118 | ||
1119 | dout("%s: img %p obj %p w=%u\n", __func__, img_request, obj_request, | ||
1120 | obj_request->which); | ||
1107 | list_del(&obj_request->links); | 1121 | list_del(&obj_request->links); |
1108 | rbd_assert(img_request->obj_request_count > 0); | 1122 | rbd_assert(img_request->obj_request_count > 0); |
1109 | img_request->obj_request_count--; | 1123 | img_request->obj_request_count--; |
@@ -1200,11 +1214,14 @@ static void rbd_osd_req_op_destroy(struct ceph_osd_req_op *op) | |||
1200 | static int rbd_obj_request_submit(struct ceph_osd_client *osdc, | 1214 | static int rbd_obj_request_submit(struct ceph_osd_client *osdc, |
1201 | struct rbd_obj_request *obj_request) | 1215 | struct rbd_obj_request *obj_request) |
1202 | { | 1216 | { |
1217 | dout("%s: osdc %p obj %p\n", __func__, osdc, obj_request); | ||
1218 | |||
1203 | return ceph_osdc_start_request(osdc, obj_request->osd_req, false); | 1219 | return ceph_osdc_start_request(osdc, obj_request->osd_req, false); |
1204 | } | 1220 | } |
1205 | 1221 | ||
1206 | static void rbd_img_request_complete(struct rbd_img_request *img_request) | 1222 | static void rbd_img_request_complete(struct rbd_img_request *img_request) |
1207 | { | 1223 | { |
1224 | dout("%s: img %p\n", __func__, img_request); | ||
1208 | if (img_request->callback) | 1225 | if (img_request->callback) |
1209 | img_request->callback(img_request); | 1226 | img_request->callback(img_request); |
1210 | else | 1227 | else |
@@ -1215,6 +1232,8 @@ static void rbd_img_request_complete(struct rbd_img_request *img_request) | |||
1215 | 1232 | ||
1216 | static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) | 1233 | static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) |
1217 | { | 1234 | { |
1235 | dout("%s: obj %p\n", __func__, obj_request); | ||
1236 | |||
1218 | return wait_for_completion_interruptible(&obj_request->completion); | 1237 | return wait_for_completion_interruptible(&obj_request->completion); |
1219 | } | 1238 | } |
1220 | 1239 | ||
@@ -1248,11 +1267,14 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request) | |||
1248 | static void rbd_osd_trivial_callback(struct rbd_obj_request *obj_request, | 1267 | static void rbd_osd_trivial_callback(struct rbd_obj_request *obj_request, |
1249 | struct ceph_osd_op *op) | 1268 | struct ceph_osd_op *op) |
1250 | { | 1269 | { |
1270 | dout("%s: obj %p\n", __func__, obj_request); | ||
1251 | obj_request_done_set(obj_request); | 1271 | obj_request_done_set(obj_request); |
1252 | } | 1272 | } |
1253 | 1273 | ||
1254 | static void rbd_obj_request_complete(struct rbd_obj_request *obj_request) | 1274 | static void rbd_obj_request_complete(struct rbd_obj_request *obj_request) |
1255 | { | 1275 | { |
1276 | dout("%s: obj %p cb %p\n", __func__, obj_request, | ||
1277 | obj_request->callback); | ||
1256 | if (obj_request->callback) | 1278 | if (obj_request->callback) |
1257 | obj_request->callback(obj_request); | 1279 | obj_request->callback(obj_request); |
1258 | else | 1280 | else |
@@ -1270,6 +1292,8 @@ static void rbd_osd_read_callback(struct rbd_obj_request *obj_request, | |||
1270 | */ | 1292 | */ |
1271 | xferred = le64_to_cpu(op->extent.length); | 1293 | xferred = le64_to_cpu(op->extent.length); |
1272 | rbd_assert(xferred < (u64) UINT_MAX); | 1294 | rbd_assert(xferred < (u64) UINT_MAX); |
1295 | dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request, | ||
1296 | obj_request->result, xferred, obj_request->length); | ||
1273 | if (obj_request->result == (s32) -ENOENT) { | 1297 | if (obj_request->result == (s32) -ENOENT) { |
1274 | zero_bio_chain(obj_request->bio_list, 0); | 1298 | zero_bio_chain(obj_request->bio_list, 0); |
1275 | obj_request->result = 0; | 1299 | obj_request->result = 0; |
@@ -1284,7 +1308,22 @@ static void rbd_osd_read_callback(struct rbd_obj_request *obj_request, | |||
1284 | static void rbd_osd_write_callback(struct rbd_obj_request *obj_request, | 1308 | static void rbd_osd_write_callback(struct rbd_obj_request *obj_request, |
1285 | struct ceph_osd_op *op) | 1309 | struct ceph_osd_op *op) |
1286 | { | 1310 | { |
1311 | |||
1287 | obj_request->xferred = le64_to_cpu(op->extent.length); | 1312 | obj_request->xferred = le64_to_cpu(op->extent.length); |
1313 | dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request, | ||
1314 | obj_request->result, obj_request->xferred, obj_request->length); | ||
1315 | |||
1316 | /* A short write really shouldn't occur. Warn if we see one */ | ||
1317 | |||
1318 | if (obj_request->xferred != obj_request->length) { | ||
1319 | struct rbd_img_request *img_request = obj_request->img_request; | ||
1320 | struct rbd_device *rbd_dev; | ||
1321 | |||
1322 | rbd_dev = img_request ? img_request->rbd_dev : NULL; | ||
1323 | rbd_warn(rbd_dev, "wrote %llu want %llu\n", | ||
1324 | obj_request->xferred, obj_request->length); | ||
1325 | } | ||
1326 | |||
1288 | obj_request_done_set(obj_request); | 1327 | obj_request_done_set(obj_request); |
1289 | } | 1328 | } |
1290 | 1329 | ||
@@ -1295,6 +1334,7 @@ static void rbd_osd_write_callback(struct rbd_obj_request *obj_request, | |||
1295 | static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request, | 1334 | static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request, |
1296 | struct ceph_osd_op *op) | 1335 | struct ceph_osd_op *op) |
1297 | { | 1336 | { |
1337 | dout("%s: obj %p\n", __func__, obj_request); | ||
1298 | obj_request_done_set(obj_request); | 1338 | obj_request_done_set(obj_request); |
1299 | } | 1339 | } |
1300 | 1340 | ||
@@ -1307,6 +1347,7 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, | |||
1307 | u32 num_ops; | 1347 | u32 num_ops; |
1308 | u16 opcode; | 1348 | u16 opcode; |
1309 | 1349 | ||
1350 | dout("%s: osd_req %p msg %p\n", __func__, osd_req, msg); | ||
1310 | rbd_assert(osd_req == obj_request->osd_req); | 1351 | rbd_assert(osd_req == obj_request->osd_req); |
1311 | rbd_assert(!!obj_request->img_request ^ | 1352 | rbd_assert(!!obj_request->img_request ^ |
1312 | (obj_request->which == BAD_WHICH)); | 1353 | (obj_request->which == BAD_WHICH)); |
@@ -1453,6 +1494,9 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, | |||
1453 | init_completion(&obj_request->completion); | 1494 | init_completion(&obj_request->completion); |
1454 | kref_init(&obj_request->kref); | 1495 | kref_init(&obj_request->kref); |
1455 | 1496 | ||
1497 | dout("%s: \"%s\" %llu/%llu %d -> obj %p\n", __func__, object_name, | ||
1498 | offset, length, (int)type, obj_request); | ||
1499 | |||
1456 | return obj_request; | 1500 | return obj_request; |
1457 | } | 1501 | } |
1458 | 1502 | ||
@@ -1462,6 +1506,8 @@ static void rbd_obj_request_destroy(struct kref *kref) | |||
1462 | 1506 | ||
1463 | obj_request = container_of(kref, struct rbd_obj_request, kref); | 1507 | obj_request = container_of(kref, struct rbd_obj_request, kref); |
1464 | 1508 | ||
1509 | dout("%s: obj %p\n", __func__, obj_request); | ||
1510 | |||
1465 | rbd_assert(obj_request->img_request == NULL); | 1511 | rbd_assert(obj_request->img_request == NULL); |
1466 | rbd_assert(obj_request->which == BAD_WHICH); | 1512 | rbd_assert(obj_request->which == BAD_WHICH); |
1467 | 1513 | ||
@@ -1531,6 +1577,10 @@ struct rbd_img_request *rbd_img_request_create(struct rbd_device *rbd_dev, | |||
1531 | rbd_img_request_get(img_request); /* Avoid a warning */ | 1577 | rbd_img_request_get(img_request); /* Avoid a warning */ |
1532 | rbd_img_request_put(img_request); /* TEMPORARY */ | 1578 | rbd_img_request_put(img_request); /* TEMPORARY */ |
1533 | 1579 | ||
1580 | dout("%s: rbd_dev %p %s %llu/%llu -> img %p\n", __func__, rbd_dev, | ||
1581 | write_request ? "write" : "read", offset, length, | ||
1582 | img_request); | ||
1583 | |||
1534 | return img_request; | 1584 | return img_request; |
1535 | } | 1585 | } |
1536 | 1586 | ||
@@ -1542,6 +1592,8 @@ static void rbd_img_request_destroy(struct kref *kref) | |||
1542 | 1592 | ||
1543 | img_request = container_of(kref, struct rbd_img_request, kref); | 1593 | img_request = container_of(kref, struct rbd_img_request, kref); |
1544 | 1594 | ||
1595 | dout("%s: img %p\n", __func__, img_request); | ||
1596 | |||
1545 | for_each_obj_request_safe(img_request, obj_request, next_obj_request) | 1597 | for_each_obj_request_safe(img_request, obj_request, next_obj_request) |
1546 | rbd_img_obj_request_del(img_request, obj_request); | 1598 | rbd_img_obj_request_del(img_request, obj_request); |
1547 | rbd_assert(img_request->obj_request_count == 0); | 1599 | rbd_assert(img_request->obj_request_count == 0); |
@@ -1563,6 +1615,8 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, | |||
1563 | u64 resid; | 1615 | u64 resid; |
1564 | u16 opcode; | 1616 | u16 opcode; |
1565 | 1617 | ||
1618 | dout("%s: img %p bio %p\n", __func__, img_request, bio_list); | ||
1619 | |||
1566 | opcode = img_request->write_request ? CEPH_OSD_OP_WRITE | 1620 | opcode = img_request->write_request ? CEPH_OSD_OP_WRITE |
1567 | : CEPH_OSD_OP_READ; | 1621 | : CEPH_OSD_OP_READ; |
1568 | bio_offset = 0; | 1622 | bio_offset = 0; |
@@ -1638,6 +1692,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) | |||
1638 | 1692 | ||
1639 | img_request = obj_request->img_request; | 1693 | img_request = obj_request->img_request; |
1640 | 1694 | ||
1695 | dout("%s: img %p obj %p\n", __func__, img_request, obj_request); | ||
1641 | rbd_assert(img_request != NULL); | 1696 | rbd_assert(img_request != NULL); |
1642 | rbd_assert(img_request->rq != NULL); | 1697 | rbd_assert(img_request->rq != NULL); |
1643 | rbd_assert(img_request->obj_request_count > 0); | 1698 | rbd_assert(img_request->obj_request_count > 0); |
@@ -1685,6 +1740,7 @@ static int rbd_img_request_submit(struct rbd_img_request *img_request) | |||
1685 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; | 1740 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; |
1686 | struct rbd_obj_request *obj_request; | 1741 | struct rbd_obj_request *obj_request; |
1687 | 1742 | ||
1743 | dout("%s: img %p\n", __func__, img_request); | ||
1688 | for_each_obj_request(img_request, obj_request) { | 1744 | for_each_obj_request(img_request, obj_request) { |
1689 | int ret; | 1745 | int ret; |
1690 | 1746 | ||
@@ -1745,7 +1801,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | |||
1745 | if (!rbd_dev) | 1801 | if (!rbd_dev) |
1746 | return; | 1802 | return; |
1747 | 1803 | ||
1748 | dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n", | 1804 | dout("%s: \"%s\" notify_id %llu opcode %u\n", __func__, |
1749 | rbd_dev->header_name, (unsigned long long) notify_id, | 1805 | rbd_dev->header_name, (unsigned long long) notify_id, |
1750 | (unsigned int) opcode); | 1806 | (unsigned int) opcode); |
1751 | rc = rbd_dev_refresh(rbd_dev, &hver); | 1807 | rc = rbd_dev_refresh(rbd_dev, &hver); |
@@ -3371,7 +3427,7 @@ static int rbd_dev_snaps_register(struct rbd_device *rbd_dev) | |||
3371 | struct rbd_snap *snap; | 3427 | struct rbd_snap *snap; |
3372 | int ret = 0; | 3428 | int ret = 0; |
3373 | 3429 | ||
3374 | dout("%s called\n", __func__); | 3430 | dout("%s:\n", __func__); |
3375 | if (WARN_ON(!device_is_registered(&rbd_dev->dev))) | 3431 | if (WARN_ON(!device_is_registered(&rbd_dev->dev))) |
3376 | return -EIO; | 3432 | return -EIO; |
3377 | 3433 | ||