Skip to content

Commit

Permalink
cls_rbd: remove old assign_bid method
Browse files Browse the repository at this point in the history
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 (18054ba)
which is pre-bobtail; so this change breaks compatibility with pre-bobtail
librbd clients (at least for image creation).

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Aug 16, 2013
1 parent 93ac92d commit f61698d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 49 deletions.
7 changes: 6 additions & 1 deletion PendingReleaseNotes
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

v0.68
~~~~~

* 'ceph osd crush set <id> <weight> <loc..>' no longer adds the osd to the
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.
48 changes: 0 additions & 48 deletions src/cls/rbd/cls_rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_"
Expand Down Expand Up @@ -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!");
Expand Down Expand Up @@ -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;
}

0 comments on commit f61698d

Please sign in to comment.