From: Dan Mick Date: Tue, 8 Jan 2013 19:21:22 +0000 (-0800) Subject: librbd: Allow get_lock_info to fail X-Git-Tag: v0.57~231^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4483285c9fb16f09986e2e48b855cd3db869e33c;p=ceph.git librbd: Allow get_lock_info to fail If the lock class isn't present, EOPNOTSUPP is returned for lock calls on newer OSDs, but sadly EIO on older; we need to treat both as acceptable failures for RBD images. rados lock list will still fail. Fixes #3744. Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index 060f8a855db4..ab42591403c8 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -99,10 +99,14 @@ namespace librbd { ::decode(parent->overlap, iter); // get_lock_info - ClsLockType lock_type; + ClsLockType lock_type = LOCK_NONE; r = rados::cls::lock::get_lock_info_finish(&iter, lockers, &lock_type, lock_tag); - if (r < 0) + + // see comment in ictx_refresh(). Ugly conflation of + // EOPNOTSUPP and EIO. + + if (r < 0 && ((r != -EOPNOTSUPP) && (r != -EIO))) return r; *exclusive_lock = (lock_type == LOCK_EXCLUSIVE); diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index ee8966cb40e2..957e843a77d6 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1609,11 +1609,19 @@ reprotect_and_return_err: << dendl; return r; } - ClsLockType lock_type; + ClsLockType lock_type = LOCK_NONE; r = rados::cls::lock::get_lock_info(&ictx->md_ctx, ictx->header_oid, RBD_LOCK_NAME, &ictx->lockers, &lock_type, &ictx->lock_tag); - if (r < 0) { + + // If EOPNOTSUPP, treat image as if there are no locks (we can't + // query them). + + // Ugly: OSDs prior to eed28daaf8927339c2ecae1b1b06c1b63678ab03 + // return EIO when the class isn't present; should be EOPNOTSUPP. + // Treat EIO or EOPNOTSUPP the same for now, as LOCK_NONE. Blech. + + if (r < 0 && ((r != -EOPNOTSUPP) && (r != -EIO))) { lderr(cct) << "Error getting lock info: " << cpp_strerror(r) << dendl; return r;