]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Allow get_lock_info to fail
authorDan Mick <dan.mick@inktank.com>
Tue, 8 Jan 2013 19:21:22 +0000 (11:21 -0800)
committerSage Weil <sage@inktank.com>
Wed, 9 Jan 2013 02:25:46 +0000 (18:25 -0800)
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 <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/cls/rbd/cls_rbd_client.cc
src/librbd/internal.cc

index 060f8a855db4407c9ea08c32ae4327b5ed454313..ab42591403c807d674dd0367b60e3d1a3cea404d 100644 (file)
@@ -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);
index ee8966cb40e23adf1113a944d906adbde3e99c65..957e843a77d6432bc9aa24eca428dffd2b12f3ed 100644 (file)
@@ -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;