OPTION(rbd_cache_max_dirty, OPT_LONGLONG, 24<<20) // dirty limit in bytes - set to 0 for write-through caching
OPTION(rbd_cache_target_dirty, OPT_LONGLONG, 16<<20) // target dirty limit in bytes
OPTION(rbd_cache_max_dirty_age, OPT_FLOAT, 1.0) // seconds in cache before writeback starts
+OPTION(rbd_cache_block_writes_upfront, OPT_BOOL, false) // whether to block writes to the cache before the aio_write call completes (true), or block before the aio completion is called (false)
OPTION(nss_db_path, OPT_STR, "") // path to nss db
init_max_dirty,
cct->_conf->rbd_cache_target_dirty,
cct->_conf->rbd_cache_max_dirty_age,
- true);
+ cct->_conf->rbd_cache_block_writes_upfront);
object_set = new ObjectCacher::ObjectSet(NULL, data_ctx.get_id(), 0);
object_set->return_enoent = true;
object_cacher->start();
}
void ImageCtx::write_to_cache(object_t o, bufferlist& bl, size_t len,
- uint64_t off) {
+ uint64_t off, Context *onfinish) {
snap_lock.get_read();
ObjectCacher::OSDWrite *wr = object_cacher->prepare_write(snapc, bl,
utime_t(), 0);
wr->extents.push_back(extent);
{
Mutex::Locker l(cache_lock);
- object_cacher->writex(wr, object_set, cache_lock, NULL);
+ object_cacher->writex(wr, object_set, cache_lock, onfinish);
}
}
uint64_t *overlap) const;
void aio_read_from_cache(object_t o, bufferlist *bl, size_t len,
uint64_t off, Context *onfinish);
- void write_to_cache(object_t o, bufferlist& bl, size_t len, uint64_t off);
+ void write_to_cache(object_t o, bufferlist& bl, size_t len, uint64_t off,
+ Context *onfinish);
int read_from_cache(object_t o, bufferlist *bl, size_t len, uint64_t off);
void user_flushed();
int flush_cache();
bl.append(buf + q->first, q->second);
}
+ C_AioWrite *req_comp = new C_AioWrite(cct, c);
if (ictx->object_cacher) {
- // may block
- ictx->write_to_cache(p->oid, bl, p->length, p->offset);
+ c->add_request();
+ ictx->write_to_cache(p->oid, bl, p->length, p->offset, req_comp);
} else {
// reverse map this object extent onto the parent
vector<pair<uint64_t,uint64_t> > objectx;
objectx);
uint64_t object_overlap = ictx->prune_parent_extents(objectx, overlap);
- C_AioWrite *req_comp = new C_AioWrite(cct, c);
AioWrite *req = new AioWrite(ictx, p->oid.name, p->objectno, p->offset,
objectx, object_overlap,
bl, snapc, snap_id, req_comp);