readahead(),
total_bytes_read(0), copyup_finisher(NULL),
object_map(*this), aio_work_queue(NULL), op_work_queue(NULL),
- asok_hook(new LibrbdAdminSocketHook(this))
+ refresh_in_progress(false), asok_hook(new LibrbdAdminSocketHook(this))
{
md_ctx.dup(p);
data_ctx.dup(p);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "ictx_check " << ictx << dendl;
- ictx->refresh_lock.Lock();
- bool needs_refresh = ictx->last_refresh != ictx->refresh_seq;
- ictx->refresh_lock.Unlock();
+ bool needs_refresh = false;
+ int refresh_seq;
+ {
+ Mutex::Locker refresh_locker(ictx->refresh_lock);
+ while (ictx->refresh_in_progress) {
+ ictx->refresh_cond.Wait(ictx->refresh_lock);
+ }
+
+ if (ictx->last_refresh != ictx->refresh_seq) {
+ ictx->refresh_in_progress = true;
+ needs_refresh = true;
+ refresh_seq = ictx->refresh_seq;
+ }
+ }
if (needs_refresh) {
int r = ictx_refresh(ictx);
+
+ Mutex::Locker refresh_locker(ictx->refresh_lock);
+ ictx->refresh_in_progress = false;
+ ictx->refresh_cond.Signal();
+
if (r < 0) {
lderr(cct) << "Error re-reading rbd header: " << cpp_strerror(-r)
<< dendl;
return r;
}
+ ictx->last_refresh = refresh_seq;
}
return 0;
}
ldout(cct, 20) << "ictx_refresh " << ictx << dendl;
- ictx->refresh_lock.Lock();
- int refresh_seq = ictx->refresh_seq;
- ictx->refresh_lock.Unlock();
-
::SnapContext new_snapc;
bool new_snap = false;
vector<string> snap_names;
if (new_snap) {
_flush(ictx);
}
-
- ictx->refresh_lock.Lock();
- ictx->last_refresh = refresh_seq;
- ictx->refresh_lock.Unlock();
-
return 0;
}