IoCtx data_ctx, md_ctx;
WatchCtx *wctx;
bool needs_refresh;
+ int refresh_seq;
Mutex refresh_lock;
Mutex lock; // protects access to snapshot and header information
Mutex cache_lock; // used as client_lock for the ObjectCacher
snap_exists(true),
name(imgname),
needs_refresh(true),
+ refresh_seq(0),
refresh_lock("librbd::ImageCtx::refresh_lock"),
lock("librbd::ImageCtx::lock"),
cache_lock("librbd::ImageCtx::cache_lock"),
if (valid) {
Mutex::Locker lictx(ictx->refresh_lock);
ictx->needs_refresh = true;
+ ++ictx->refresh_seq;
ictx->perfcounter->inc(l_librbd_notify);
}
}
assert(ictx->lock.is_locked());
ictx->refresh_lock.Lock();
ictx->needs_refresh = true;
+ ++ictx->refresh_seq;
ictx->refresh_lock.Unlock();
}
ldout(cct, 20) << "ictx_refresh " << ictx << dendl;
ictx->refresh_lock.Lock();
- ictx->needs_refresh = false;
+ int refresh_seq = ictx->refresh_seq;
ictx->refresh_lock.Unlock();
int r;
if (!ictx->snapc.is_valid()) {
lderr(cct) << "image snap context is invalid!" << dendl;
- ictx->refresh_lock.Lock();
- ictx->needs_refresh = true;
- ictx->refresh_lock.Unlock();
return -EIO;
}
ictx->data_ctx.selfmanaged_snap_set_write_ctx(ictx->snapc.seq, ictx->snaps);
+ ictx->refresh_lock.Lock();
+ if (refresh_seq == ictx->refresh_seq) {
+ ictx->needs_refresh = false;
+ }
+ ictx->refresh_lock.Unlock();
+
return 0;
}