if (r < 0)
return r;
- Mutex::Locker l(ictx->md_lock);
+ 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
- Mutex::Locker l2(ictx->snap_lock);
++ 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 -