diff options
author | Alex Elder <elder@inktank.com> | 2012-07-03 17:01:18 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 12:30:05 -0400 |
commit | 0ce1a7941341cc63c8352b7df50020e5485bc43a (patch) | |
tree | 13ab8af0ed5f4e7a7625e1d9e9e4795f5d6628c5 /drivers/block | |
parent | 820a5f3e94b9f8ea8c0c6125ce34b237ed67b1dc (diff) |
rbd: use rbd_dev consistently
Most variables that represent a struct rbd_device are named
"rbd_dev", but in some cases "dev" is used instead. Change all the
"dev" references so they use "rbd_dev" consistently, to make it
clear from the name that we're working with an RBD device (as
opposed to, for example, a struct device). Similarly, change the
name of the "dev" field in struct rbd_notify_info to be "rbd_dev".
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 125 |
1 files changed, 64 insertions, 61 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 5c0f0445982c..03439565c738 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -582,35 +582,36 @@ static int snap_by_name(struct rbd_image_header *header, const char *snap_name, | |||
582 | return -ENOENT; | 582 | return -ENOENT; |
583 | } | 583 | } |
584 | 584 | ||
585 | static int rbd_header_set_snap(struct rbd_device *dev, u64 *size) | 585 | static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size) |
586 | { | 586 | { |
587 | struct rbd_image_header *header = &dev->header; | 587 | struct rbd_image_header *header = &rbd_dev->header; |
588 | struct ceph_snap_context *snapc = header->snapc; | 588 | struct ceph_snap_context *snapc = header->snapc; |
589 | int ret = -ENOENT; | 589 | int ret = -ENOENT; |
590 | 590 | ||
591 | down_write(&dev->header_rwsem); | 591 | down_write(&rbd_dev->header_rwsem); |
592 | 592 | ||
593 | if (!memcmp(dev->snap_name, RBD_SNAP_HEAD_NAME, | 593 | if (!memcmp(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME, |
594 | sizeof (RBD_SNAP_HEAD_NAME))) { | 594 | sizeof (RBD_SNAP_HEAD_NAME))) { |
595 | if (header->total_snaps) | 595 | if (header->total_snaps) |
596 | snapc->seq = header->snap_seq; | 596 | snapc->seq = header->snap_seq; |
597 | else | 597 | else |
598 | snapc->seq = 0; | 598 | snapc->seq = 0; |
599 | dev->snap_id = CEPH_NOSNAP; | 599 | rbd_dev->snap_id = CEPH_NOSNAP; |
600 | dev->read_only = 0; | 600 | rbd_dev->read_only = 0; |
601 | if (size) | 601 | if (size) |
602 | *size = header->image_size; | 602 | *size = header->image_size; |
603 | } else { | 603 | } else { |
604 | ret = snap_by_name(header, dev->snap_name, &snapc->seq, size); | 604 | ret = snap_by_name(header, rbd_dev->snap_name, |
605 | &snapc->seq, size); | ||
605 | if (ret < 0) | 606 | if (ret < 0) |
606 | goto done; | 607 | goto done; |
607 | dev->snap_id = snapc->seq; | 608 | rbd_dev->snap_id = snapc->seq; |
608 | dev->read_only = 1; | 609 | rbd_dev->read_only = 1; |
609 | } | 610 | } |
610 | 611 | ||
611 | ret = 0; | 612 | ret = 0; |
612 | done: | 613 | done: |
613 | up_write(&dev->header_rwsem); | 614 | up_write(&rbd_dev->header_rwsem); |
614 | return ret; | 615 | return ret; |
615 | } | 616 | } |
616 | 617 | ||
@@ -854,7 +855,7 @@ static void rbd_coll_end_req(struct rbd_request *req, | |||
854 | * Send ceph osd request | 855 | * Send ceph osd request |
855 | */ | 856 | */ |
856 | static int rbd_do_request(struct request *rq, | 857 | static int rbd_do_request(struct request *rq, |
857 | struct rbd_device *dev, | 858 | struct rbd_device *rbd_dev, |
858 | struct ceph_snap_context *snapc, | 859 | struct ceph_snap_context *snapc, |
859 | u64 snapid, | 860 | u64 snapid, |
860 | const char *obj, u64 ofs, u64 len, | 861 | const char *obj, u64 ofs, u64 len, |
@@ -895,13 +896,13 @@ static int rbd_do_request(struct request *rq, | |||
895 | 896 | ||
896 | dout("rbd_do_request obj=%s ofs=%lld len=%lld\n", obj, len, ofs); | 897 | dout("rbd_do_request obj=%s ofs=%lld len=%lld\n", obj, len, ofs); |
897 | 898 | ||
898 | down_read(&dev->header_rwsem); | 899 | down_read(&rbd_dev->header_rwsem); |
899 | 900 | ||
900 | osdc = &dev->rbd_client->client->osdc; | 901 | osdc = &rbd_dev->rbd_client->client->osdc; |
901 | req = ceph_osdc_alloc_request(osdc, flags, snapc, ops, | 902 | req = ceph_osdc_alloc_request(osdc, flags, snapc, ops, |
902 | false, GFP_NOIO, pages, bio); | 903 | false, GFP_NOIO, pages, bio); |
903 | if (!req) { | 904 | if (!req) { |
904 | up_read(&dev->header_rwsem); | 905 | up_read(&rbd_dev->header_rwsem); |
905 | ret = -ENOMEM; | 906 | ret = -ENOMEM; |
906 | goto done_pages; | 907 | goto done_pages; |
907 | } | 908 | } |
@@ -926,7 +927,7 @@ static int rbd_do_request(struct request *rq, | |||
926 | layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | 927 | layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); |
927 | layout->fl_stripe_count = cpu_to_le32(1); | 928 | layout->fl_stripe_count = cpu_to_le32(1); |
928 | layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | 929 | layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); |
929 | layout->fl_pg_pool = cpu_to_le32(dev->pool_id); | 930 | layout->fl_pg_pool = cpu_to_le32(rbd_dev->pool_id); |
930 | ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno, | 931 | ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno, |
931 | req, ops); | 932 | req, ops); |
932 | 933 | ||
@@ -935,7 +936,7 @@ static int rbd_do_request(struct request *rq, | |||
935 | snapc, | 936 | snapc, |
936 | &mtime, | 937 | &mtime, |
937 | req->r_oid, req->r_oid_len); | 938 | req->r_oid, req->r_oid_len); |
938 | up_read(&dev->header_rwsem); | 939 | up_read(&rbd_dev->header_rwsem); |
939 | 940 | ||
940 | if (linger_req) { | 941 | if (linger_req) { |
941 | ceph_osdc_set_request_linger(osdc, req); | 942 | ceph_osdc_set_request_linger(osdc, req); |
@@ -1012,7 +1013,7 @@ static void rbd_simple_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg | |||
1012 | /* | 1013 | /* |
1013 | * Do a synchronous ceph osd operation | 1014 | * Do a synchronous ceph osd operation |
1014 | */ | 1015 | */ |
1015 | static int rbd_req_sync_op(struct rbd_device *dev, | 1016 | static int rbd_req_sync_op(struct rbd_device *rbd_dev, |
1016 | struct ceph_snap_context *snapc, | 1017 | struct ceph_snap_context *snapc, |
1017 | u64 snapid, | 1018 | u64 snapid, |
1018 | int opcode, | 1019 | int opcode, |
@@ -1049,7 +1050,7 @@ static int rbd_req_sync_op(struct rbd_device *dev, | |||
1049 | } | 1050 | } |
1050 | } | 1051 | } |
1051 | 1052 | ||
1052 | ret = rbd_do_request(NULL, dev, snapc, snapid, | 1053 | ret = rbd_do_request(NULL, rbd_dev, snapc, snapid, |
1053 | obj, ofs, len, NULL, | 1054 | obj, ofs, len, NULL, |
1054 | pages, num_pages, | 1055 | pages, num_pages, |
1055 | flags, | 1056 | flags, |
@@ -1076,7 +1077,7 @@ done: | |||
1076 | * Do an asynchronous ceph osd operation | 1077 | * Do an asynchronous ceph osd operation |
1077 | */ | 1078 | */ |
1078 | static int rbd_do_op(struct request *rq, | 1079 | static int rbd_do_op(struct request *rq, |
1079 | struct rbd_device *rbd_dev , | 1080 | struct rbd_device *rbd_dev, |
1080 | struct ceph_snap_context *snapc, | 1081 | struct ceph_snap_context *snapc, |
1081 | u64 snapid, | 1082 | u64 snapid, |
1082 | int opcode, int flags, int num_reply, | 1083 | int opcode, int flags, int num_reply, |
@@ -1168,7 +1169,7 @@ static int rbd_req_read(struct request *rq, | |||
1168 | /* | 1169 | /* |
1169 | * Request sync osd read | 1170 | * Request sync osd read |
1170 | */ | 1171 | */ |
1171 | static int rbd_req_sync_read(struct rbd_device *dev, | 1172 | static int rbd_req_sync_read(struct rbd_device *rbd_dev, |
1172 | struct ceph_snap_context *snapc, | 1173 | struct ceph_snap_context *snapc, |
1173 | u64 snapid, | 1174 | u64 snapid, |
1174 | const char *obj, | 1175 | const char *obj, |
@@ -1176,7 +1177,7 @@ static int rbd_req_sync_read(struct rbd_device *dev, | |||
1176 | char *buf, | 1177 | char *buf, |
1177 | u64 *ver) | 1178 | u64 *ver) |
1178 | { | 1179 | { |
1179 | return rbd_req_sync_op(dev, NULL, | 1180 | return rbd_req_sync_op(rbd_dev, NULL, |
1180 | snapid, | 1181 | snapid, |
1181 | CEPH_OSD_OP_READ, | 1182 | CEPH_OSD_OP_READ, |
1182 | CEPH_OSD_FLAG_READ, | 1183 | CEPH_OSD_FLAG_READ, |
@@ -1187,7 +1188,7 @@ static int rbd_req_sync_read(struct rbd_device *dev, | |||
1187 | /* | 1188 | /* |
1188 | * Request sync osd watch | 1189 | * Request sync osd watch |
1189 | */ | 1190 | */ |
1190 | static int rbd_req_sync_notify_ack(struct rbd_device *dev, | 1191 | static int rbd_req_sync_notify_ack(struct rbd_device *rbd_dev, |
1191 | u64 ver, | 1192 | u64 ver, |
1192 | u64 notify_id, | 1193 | u64 notify_id, |
1193 | const char *obj) | 1194 | const char *obj) |
@@ -1199,11 +1200,11 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev, | |||
1199 | if (ret < 0) | 1200 | if (ret < 0) |
1200 | return ret; | 1201 | return ret; |
1201 | 1202 | ||
1202 | ops[0].watch.ver = cpu_to_le64(dev->header.obj_version); | 1203 | ops[0].watch.ver = cpu_to_le64(rbd_dev->header.obj_version); |
1203 | ops[0].watch.cookie = notify_id; | 1204 | ops[0].watch.cookie = notify_id; |
1204 | ops[0].watch.flag = 0; | 1205 | ops[0].watch.flag = 0; |
1205 | 1206 | ||
1206 | ret = rbd_do_request(NULL, dev, NULL, CEPH_NOSNAP, | 1207 | ret = rbd_do_request(NULL, rbd_dev, NULL, CEPH_NOSNAP, |
1207 | obj, 0, 0, NULL, | 1208 | obj, 0, 0, NULL, |
1208 | NULL, 0, | 1209 | NULL, 0, |
1209 | CEPH_OSD_FLAG_READ, | 1210 | CEPH_OSD_FLAG_READ, |
@@ -1218,54 +1219,54 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev, | |||
1218 | 1219 | ||
1219 | static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | 1220 | static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) |
1220 | { | 1221 | { |
1221 | struct rbd_device *dev = (struct rbd_device *)data; | 1222 | struct rbd_device *rbd_dev = (struct rbd_device *)data; |
1222 | int rc; | 1223 | int rc; |
1223 | 1224 | ||
1224 | if (!dev) | 1225 | if (!rbd_dev) |
1225 | return; | 1226 | return; |
1226 | 1227 | ||
1227 | dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n", dev->obj_md_name, | 1228 | dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n", rbd_dev->obj_md_name, |
1228 | notify_id, (int)opcode); | 1229 | notify_id, (int)opcode); |
1229 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | 1230 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); |
1230 | rc = __rbd_refresh_header(dev); | 1231 | rc = __rbd_refresh_header(rbd_dev); |
1231 | mutex_unlock(&ctl_mutex); | 1232 | mutex_unlock(&ctl_mutex); |
1232 | if (rc) | 1233 | if (rc) |
1233 | pr_warning(RBD_DRV_NAME "%d got notification but failed to " | 1234 | pr_warning(RBD_DRV_NAME "%d got notification but failed to " |
1234 | " update snaps: %d\n", dev->major, rc); | 1235 | " update snaps: %d\n", rbd_dev->major, rc); |
1235 | 1236 | ||
1236 | rbd_req_sync_notify_ack(dev, ver, notify_id, dev->obj_md_name); | 1237 | rbd_req_sync_notify_ack(rbd_dev, ver, notify_id, rbd_dev->obj_md_name); |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | /* | 1240 | /* |
1240 | * Request sync osd watch | 1241 | * Request sync osd watch |
1241 | */ | 1242 | */ |
1242 | static int rbd_req_sync_watch(struct rbd_device *dev, | 1243 | static int rbd_req_sync_watch(struct rbd_device *rbd_dev, |
1243 | const char *obj, | 1244 | const char *obj, |
1244 | u64 ver) | 1245 | u64 ver) |
1245 | { | 1246 | { |
1246 | struct ceph_osd_req_op *ops; | 1247 | struct ceph_osd_req_op *ops; |
1247 | struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc; | 1248 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; |
1248 | 1249 | ||
1249 | int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_WATCH, 0); | 1250 | int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_WATCH, 0); |
1250 | if (ret < 0) | 1251 | if (ret < 0) |
1251 | return ret; | 1252 | return ret; |
1252 | 1253 | ||
1253 | ret = ceph_osdc_create_event(osdc, rbd_watch_cb, 0, | 1254 | ret = ceph_osdc_create_event(osdc, rbd_watch_cb, 0, |
1254 | (void *)dev, &dev->watch_event); | 1255 | (void *)rbd_dev, &rbd_dev->watch_event); |
1255 | if (ret < 0) | 1256 | if (ret < 0) |
1256 | goto fail; | 1257 | goto fail; |
1257 | 1258 | ||
1258 | ops[0].watch.ver = cpu_to_le64(ver); | 1259 | ops[0].watch.ver = cpu_to_le64(ver); |
1259 | ops[0].watch.cookie = cpu_to_le64(dev->watch_event->cookie); | 1260 | ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie); |
1260 | ops[0].watch.flag = 1; | 1261 | ops[0].watch.flag = 1; |
1261 | 1262 | ||
1262 | ret = rbd_req_sync_op(dev, NULL, | 1263 | ret = rbd_req_sync_op(rbd_dev, NULL, |
1263 | CEPH_NOSNAP, | 1264 | CEPH_NOSNAP, |
1264 | 0, | 1265 | 0, |
1265 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | 1266 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, |
1266 | ops, | 1267 | ops, |
1267 | 1, obj, 0, 0, NULL, | 1268 | 1, obj, 0, 0, NULL, |
1268 | &dev->watch_request, NULL); | 1269 | &rbd_dev->watch_request, NULL); |
1269 | 1270 | ||
1270 | if (ret < 0) | 1271 | if (ret < 0) |
1271 | goto fail_event; | 1272 | goto fail_event; |
@@ -1274,8 +1275,8 @@ static int rbd_req_sync_watch(struct rbd_device *dev, | |||
1274 | return 0; | 1275 | return 0; |
1275 | 1276 | ||
1276 | fail_event: | 1277 | fail_event: |
1277 | ceph_osdc_cancel_event(dev->watch_event); | 1278 | ceph_osdc_cancel_event(rbd_dev->watch_event); |
1278 | dev->watch_event = NULL; | 1279 | rbd_dev->watch_event = NULL; |
1279 | fail: | 1280 | fail: |
1280 | rbd_destroy_ops(ops); | 1281 | rbd_destroy_ops(ops); |
1281 | return ret; | 1282 | return ret; |
@@ -1284,7 +1285,7 @@ fail: | |||
1284 | /* | 1285 | /* |
1285 | * Request sync osd unwatch | 1286 | * Request sync osd unwatch |
1286 | */ | 1287 | */ |
1287 | static int rbd_req_sync_unwatch(struct rbd_device *dev, | 1288 | static int rbd_req_sync_unwatch(struct rbd_device *rbd_dev, |
1288 | const char *obj) | 1289 | const char *obj) |
1289 | { | 1290 | { |
1290 | struct ceph_osd_req_op *ops; | 1291 | struct ceph_osd_req_op *ops; |
@@ -1294,10 +1295,10 @@ static int rbd_req_sync_unwatch(struct rbd_device *dev, | |||
1294 | return ret; | 1295 | return ret; |
1295 | 1296 | ||
1296 | ops[0].watch.ver = 0; | 1297 | ops[0].watch.ver = 0; |
1297 | ops[0].watch.cookie = cpu_to_le64(dev->watch_event->cookie); | 1298 | ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie); |
1298 | ops[0].watch.flag = 0; | 1299 | ops[0].watch.flag = 0; |
1299 | 1300 | ||
1300 | ret = rbd_req_sync_op(dev, NULL, | 1301 | ret = rbd_req_sync_op(rbd_dev, NULL, |
1301 | CEPH_NOSNAP, | 1302 | CEPH_NOSNAP, |
1302 | 0, | 1303 | 0, |
1303 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | 1304 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, |
@@ -1305,33 +1306,34 @@ static int rbd_req_sync_unwatch(struct rbd_device *dev, | |||
1305 | 1, obj, 0, 0, NULL, NULL, NULL); | 1306 | 1, obj, 0, 0, NULL, NULL, NULL); |
1306 | 1307 | ||
1307 | rbd_destroy_ops(ops); | 1308 | rbd_destroy_ops(ops); |
1308 | ceph_osdc_cancel_event(dev->watch_event); | 1309 | ceph_osdc_cancel_event(rbd_dev->watch_event); |
1309 | dev->watch_event = NULL; | 1310 | rbd_dev->watch_event = NULL; |
1310 | return ret; | 1311 | return ret; |
1311 | } | 1312 | } |
1312 | 1313 | ||
1313 | struct rbd_notify_info { | 1314 | struct rbd_notify_info { |
1314 | struct rbd_device *dev; | 1315 | struct rbd_device *rbd_dev; |
1315 | }; | 1316 | }; |
1316 | 1317 | ||
1317 | static void rbd_notify_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | 1318 | static void rbd_notify_cb(u64 ver, u64 notify_id, u8 opcode, void *data) |
1318 | { | 1319 | { |
1319 | struct rbd_device *dev = (struct rbd_device *)data; | 1320 | struct rbd_device *rbd_dev = (struct rbd_device *)data; |
1320 | if (!dev) | 1321 | if (!rbd_dev) |
1321 | return; | 1322 | return; |
1322 | 1323 | ||
1323 | dout("rbd_notify_cb %s notify_id=%lld opcode=%d\n", dev->obj_md_name, | 1324 | dout("rbd_notify_cb %s notify_id=%lld opcode=%d\n", |
1325 | rbd_dev->obj_md_name, | ||
1324 | notify_id, (int)opcode); | 1326 | notify_id, (int)opcode); |
1325 | } | 1327 | } |
1326 | 1328 | ||
1327 | /* | 1329 | /* |
1328 | * Request sync osd notify | 1330 | * Request sync osd notify |
1329 | */ | 1331 | */ |
1330 | static int rbd_req_sync_notify(struct rbd_device *dev, | 1332 | static int rbd_req_sync_notify(struct rbd_device *rbd_dev, |
1331 | const char *obj) | 1333 | const char *obj) |
1332 | { | 1334 | { |
1333 | struct ceph_osd_req_op *ops; | 1335 | struct ceph_osd_req_op *ops; |
1334 | struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc; | 1336 | struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; |
1335 | struct ceph_osd_event *event; | 1337 | struct ceph_osd_event *event; |
1336 | struct rbd_notify_info info; | 1338 | struct rbd_notify_info info; |
1337 | int payload_len = sizeof(u32) + sizeof(u32); | 1339 | int payload_len = sizeof(u32) + sizeof(u32); |
@@ -1341,7 +1343,7 @@ static int rbd_req_sync_notify(struct rbd_device *dev, | |||
1341 | if (ret < 0) | 1343 | if (ret < 0) |
1342 | return ret; | 1344 | return ret; |
1343 | 1345 | ||
1344 | info.dev = dev; | 1346 | info.rbd_dev = rbd_dev; |
1345 | 1347 | ||
1346 | ret = ceph_osdc_create_event(osdc, rbd_notify_cb, 1, | 1348 | ret = ceph_osdc_create_event(osdc, rbd_notify_cb, 1, |
1347 | (void *)&info, &event); | 1349 | (void *)&info, &event); |
@@ -1354,7 +1356,7 @@ static int rbd_req_sync_notify(struct rbd_device *dev, | |||
1354 | ops[0].watch.prot_ver = RADOS_NOTIFY_VER; | 1356 | ops[0].watch.prot_ver = RADOS_NOTIFY_VER; |
1355 | ops[0].watch.timeout = 12; | 1357 | ops[0].watch.timeout = 12; |
1356 | 1358 | ||
1357 | ret = rbd_req_sync_op(dev, NULL, | 1359 | ret = rbd_req_sync_op(rbd_dev, NULL, |
1358 | CEPH_NOSNAP, | 1360 | CEPH_NOSNAP, |
1359 | 0, | 1361 | 0, |
1360 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | 1362 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, |
@@ -1378,7 +1380,7 @@ fail: | |||
1378 | /* | 1380 | /* |
1379 | * Request sync osd read | 1381 | * Request sync osd read |
1380 | */ | 1382 | */ |
1381 | static int rbd_req_sync_exec(struct rbd_device *dev, | 1383 | static int rbd_req_sync_exec(struct rbd_device *rbd_dev, |
1382 | const char *obj, | 1384 | const char *obj, |
1383 | const char *cls, | 1385 | const char *cls, |
1384 | const char *method, | 1386 | const char *method, |
@@ -1402,7 +1404,7 @@ static int rbd_req_sync_exec(struct rbd_device *dev, | |||
1402 | ops[0].cls.indata = data; | 1404 | ops[0].cls.indata = data; |
1403 | ops[0].cls.indata_len = len; | 1405 | ops[0].cls.indata_len = len; |
1404 | 1406 | ||
1405 | ret = rbd_req_sync_op(dev, NULL, | 1407 | ret = rbd_req_sync_op(rbd_dev, NULL, |
1406 | CEPH_NOSNAP, | 1408 | CEPH_NOSNAP, |
1407 | 0, | 1409 | 0, |
1408 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, | 1410 | CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, |
@@ -1633,7 +1635,7 @@ out_dh: | |||
1633 | /* | 1635 | /* |
1634 | * create a snapshot | 1636 | * create a snapshot |
1635 | */ | 1637 | */ |
1636 | static int rbd_header_add_snap(struct rbd_device *dev, | 1638 | static int rbd_header_add_snap(struct rbd_device *rbd_dev, |
1637 | const char *snap_name, | 1639 | const char *snap_name, |
1638 | gfp_t gfp_flags) | 1640 | gfp_t gfp_flags) |
1639 | { | 1641 | { |
@@ -1645,11 +1647,11 @@ static int rbd_header_add_snap(struct rbd_device *dev, | |||
1645 | struct ceph_mon_client *monc; | 1647 | struct ceph_mon_client *monc; |
1646 | 1648 | ||
1647 | /* we should create a snapshot only if we're pointing at the head */ | 1649 | /* we should create a snapshot only if we're pointing at the head */ |
1648 | if (dev->snap_id != CEPH_NOSNAP) | 1650 | if (rbd_dev->snap_id != CEPH_NOSNAP) |
1649 | return -EINVAL; | 1651 | return -EINVAL; |
1650 | 1652 | ||
1651 | monc = &dev->rbd_client->client->monc; | 1653 | monc = &rbd_dev->rbd_client->client->monc; |
1652 | ret = ceph_monc_create_snapid(monc, dev->pool_id, &new_snapid); | 1654 | ret = ceph_monc_create_snapid(monc, rbd_dev->pool_id, &new_snapid); |
1653 | dout("created snapid=%lld\n", new_snapid); | 1655 | dout("created snapid=%lld\n", new_snapid); |
1654 | if (ret < 0) | 1656 | if (ret < 0) |
1655 | return ret; | 1657 | return ret; |
@@ -1664,7 +1666,8 @@ static int rbd_header_add_snap(struct rbd_device *dev, | |||
1664 | ceph_encode_string_safe(&p, e, snap_name, name_len, bad); | 1666 | ceph_encode_string_safe(&p, e, snap_name, name_len, bad); |
1665 | ceph_encode_64_safe(&p, e, new_snapid, bad); | 1667 | ceph_encode_64_safe(&p, e, new_snapid, bad); |
1666 | 1668 | ||
1667 | ret = rbd_req_sync_exec(dev, dev->obj_md_name, "rbd", "snap_add", | 1669 | ret = rbd_req_sync_exec(rbd_dev, rbd_dev->obj_md_name, |
1670 | "rbd", "snap_add", | ||
1668 | data, p - data, &ver); | 1671 | data, p - data, &ver); |
1669 | 1672 | ||
1670 | kfree(data); | 1673 | kfree(data); |
@@ -1672,9 +1675,9 @@ static int rbd_header_add_snap(struct rbd_device *dev, | |||
1672 | if (ret < 0) | 1675 | if (ret < 0) |
1673 | return ret; | 1676 | return ret; |
1674 | 1677 | ||
1675 | down_write(&dev->header_rwsem); | 1678 | down_write(&rbd_dev->header_rwsem); |
1676 | dev->header.snapc->seq = new_snapid; | 1679 | rbd_dev->header.snapc->seq = new_snapid; |
1677 | up_write(&dev->header_rwsem); | 1680 | up_write(&rbd_dev->header_rwsem); |
1678 | 1681 | ||
1679 | return 0; | 1682 | return 0; |
1680 | bad: | 1683 | bad: |