diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2013-02-25 12:05:16 -0800 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2013-02-25 12:12:04 -0800 |
commit | db5fc2270f91aae220fc3c97b0c62e92e263527b (patch) | |
tree | 2617fe7f7ed97480e4d532dec42ddeedaf086eeb | |
parent | 7f61072ad631096e3657ff94ddfb35ed1b7e8111 (diff) | |
parent | 5806226cf0743bb44eaf7bc815897c6846d43233 (diff) | |
download | ceph-db5fc2270f91aae220fc3c97b0c62e92e263527b.tar.gz |
Merge branch 'wip-4249' into wip-4249-master
Make snap_rollback() only take a read lock on snap_lock, since
it does not modify snapshot-related fields.
Conflicts:
src/librbd/internal.cc
-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); |