diff options
-rw-r--r-- | src/librbd/internal.cc | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index d913b314edd..9c8276fd4fd 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1736,17 +1736,23 @@ reprotect_and_return_err: return r; RWLock::WLocker l(ictx->md_lock); - RWLock::WLocker l2(ictx->snap_lock); - if (!ictx->snap_exists) - return -ENOENT; + snap_t snap_id; + uint64_t new_size; + { + // need to drop snap_lock before invalidating cache + RWLock::RLocker l2(ictx->snap_lock); + if (!ictx->snap_exists) + return -ENOENT; - if (ictx->snap_id != CEPH_NOSNAP || ictx->read_only) - return -EROFS; + if (ictx->snap_id != CEPH_NOSNAP || ictx->read_only) + return -EROFS; - snap_t snap_id = ictx->get_snap_id(snap_name); - if (snap_id == CEPH_NOSNAP) { - lderr(cct) << "No such snapshot found." << dendl; - return -ENOENT; + snap_id = ictx->get_snap_id(snap_name); + if (snap_id == CEPH_NOSNAP) { + lderr(cct) << "No such snapshot found." << dendl; + return -ENOENT; + } + new_size = ictx->get_image_size(ictx->snap_id); } // need to flush any pending writes before resizing and rolling back - @@ -1754,9 +1760,6 @@ reprotect_and_return_err: // the current version, so we have to invalidate that too. ictx->invalidate_cache(); - uint64_t new_size = ictx->get_image_size(ictx->snap_id); - ictx->get_snap_size(snap_name, &new_size); - ldout(cct, 2) << "resizing to snapshot size..." << dendl; NoOpProgressContext no_op; r = resize_helper(ictx, new_size, no_op); @@ -1772,10 +1775,6 @@ reprotect_and_return_err: return r; } - snap_t new_snap_id = ictx->get_snap_id(snap_name); - ldout(cct, 20) << "snap_id is " << ictx->snap_id << " new snap_id is " - << new_snap_id << dendl; - notify_change(ictx->md_ctx, ictx->header_oid, NULL, ictx); ictx->perfcounter->inc(l_librbd_snap_rollback); |