From f61698d56466a4c79230c24985c4a5285390ed8e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Aug 2013 15:22:41 -0700 Subject: [PATCH] cls_rbd: remove old assign_bid method This method is problematic because it both writes/mutates and returns data, which means that an untimely client disconnect or peering event will result in a success to the client with no payload. It has not been used since v0.52 (18054ba46fe2779d8df8b1a0d69ec93ca6a66c34) which is pre-bobtail; so this change breaks compatibility with pre-bobtail librbd clients (at least for image creation). Signed-off-by: Sage Weil --- PendingReleaseNotes | 7 +++++- src/cls/rbd/cls_rbd.cc | 48 ------------------------------------------ 2 files changed, 6 insertions(+), 49 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 7a41aceb96b7c..67919e541184e 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -1,4 +1,3 @@ - v0.68 ~~~~~ @@ -6,3 +5,9 @@ v0.68 specified location, as that's a job for 'ceph osd crush add'. It will however continue to work just the same as long as the osd already exists in the crush map. + +* The OSD now enforces that class write methods cannot both mutate an + object and return data. The rbd.assign_bid method, the lone + offender, has been removed. This breaks compatibility with + pre-bobtail librbd clients by preventing them from creating new + images. diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index c09f1ee604a71..420de514ee6e4 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -92,7 +92,6 @@ cls_method_handle_t h_dir_rename_image; cls_method_handle_t h_old_snapshots_list; cls_method_handle_t h_old_snapshot_add; cls_method_handle_t h_old_snapshot_remove; -cls_method_handle_t h_assign_bid; #define RBD_MAX_KEYS_READ 64 #define RBD_SNAP_KEY_PREFIX "snapshot_" @@ -1980,48 +1979,6 @@ int old_snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *o } -/* assign block id. This method should be called on the rbd_info object */ -int rbd_assign_bid(cls_method_context_t hctx, bufferlist *in, bufferlist *out) -{ - struct rbd_info info; - int rc; - bufferlist bl; - - rc = cls_cxx_read(hctx, 0, sizeof(info), &bl); - if (rc < 0 && rc != -EEXIST) - return rc; - - if (rc && rc < (int)sizeof(info)) { - CLS_ERR("bad rbd_info object, read %d bytes, expected %d", rc, - (int)sizeof(info)); - return -EIO; - } - - uint64_t max_id; - if (rc) { - memcpy(&info, bl.c_str(), sizeof(info)); - max_id = info.max_id + 1; - info.max_id = max_id; - } else { - memset(&info, 0, sizeof(info)); - max_id = 0; - } - - bufferlist newbl; - bufferptr bp(sizeof(info)); - memcpy(bp.c_str(), &info, sizeof(info)); - newbl.push_back(bp); - rc = cls_cxx_write_full(hctx, &newbl); - if (rc < 0) { - CLS_ERR("error writing rbd_info, got rc=%d", rc); - return rc; - } - - ::encode(max_id, *out); - - return out->length(); -} - void __cls_init() { CLS_LOG(20, "Loaded rbd class!"); @@ -2132,10 +2089,5 @@ void __cls_init() CLS_METHOD_RD | CLS_METHOD_WR, old_snapshot_remove, &h_old_snapshot_remove); - /* assign a unique block id for rbd blocks */ - cls_register_cxx_method(h_class, "assign_bid", - CLS_METHOD_RD | CLS_METHOD_WR, - rbd_assign_bid, &h_assign_bid); - return; }