This replaces the hard-coded 1 second writeback timer.
Signed-off-by: Sage Weil <sage@newdream.net>
writeback_handler = new ObjecterWriteback(objecter);
objectcacher = new ObjectCacher(cct, "libcephfs", *writeback_handler, client_lock,
client_flush_set_callback, // all commit callback
- (void*)this);
- objectcacher->set_max_size(cct->_conf->client_oc_size);
- objectcacher->set_max_dirty(cct->_conf->client_oc_max_dirty);
- objectcacher->set_target_dirty(cct->_conf->client_oc_target_dirty);
+ (void*)this,
+ cct->_conf->client_oc_size,
+ cct->_conf->client_oc_max_dirty,
+ cct->_conf->client_oc_target_dirty,
+ cct->_conf->client_oc_max_dirty_age);
filer = new Filer(objecter);
}
OPTION(client_oc_size, OPT_INT, 1024*1024* 200) // MB * n
OPTION(client_oc_max_dirty, OPT_INT, 1024*1024* 100) // MB * n (dirty OR tx.. bigish)
OPTION(client_oc_target_dirty, OPT_INT, 1024*1024* 8) // target dirty (keep this smallish)
+OPTION(client_oc_max_dirty_age, OPT_DOUBLE, 5.0) // max age in cache before writeback
// note: the max amount of "in flight" dirty data is roughly (max - target)
OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent
OPTION(fuse_big_writes, OPT_BOOL, true)
OPTION(rbd_cache_size, OPT_LONGLONG, 32<<20) // cache size
OPTION(rbd_cache_max_dirty, OPT_LONGLONG, 24<<20) // dirty limit
OPTION(rbd_cache_target_dirty, OPT_LONGLONG, 16<<20) // target dirty limit
+OPTION(rbd_cache_max_dirty_age, OPT_FLOAT, 1.0) // age in cache before writeback starts
OPTION(rgw_cache_enabled, OPT_BOOL, true) // rgw cache enabled
OPTION(rgw_cache_lru_size, OPT_INT, 10000) // num of entries in rgw cache
OPTION(rgw_socket_path, OPT_STR, "") // path to unix domain socket, if not specified, rgw will not run as external fcgi
utime_t(const struct timeval *v) {
set_from_timeval(v);
}
+ explicit utime_t(double d) {
+ set_from_double(d);
+ }
void to_timespec(struct timespec *ts) const {
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_nsec;
ldout(cct, 20) << "enabling writback caching..." << dendl;
writeback_handler = new LibrbdWriteback(data_ctx, cache_lock);
object_cacher = new ObjectCacher(cct, pname, *writeback_handler, cache_lock,
- NULL, NULL);
- object_cacher->set_max_size(cct->_conf->rbd_cache_size);
- object_cacher->set_max_dirty(cct->_conf->rbd_cache_max_dirty);
- object_cacher->set_target_dirty(cct->_conf->rbd_cache_target_dirty);
+ NULL, NULL,
+ cct->_conf->rbd_cache_size,
+ cct->_conf->rbd_cache_max_dirty,
+ cct->_conf->rbd_cache_target_dirty,
+ cct->_conf->rbd_cache_max_dirty_age);
object_set = new ObjectCacher::ObjectSet(NULL, data_ctx.get_id(), 0);
object_cacher->start();
}
ObjectCacher::ObjectCacher(CephContext *cct_, string name, WritebackHandler& wb, Mutex& l,
flush_set_callback_t flush_callback,
- void *flush_callback_arg)
+ void *flush_callback_arg,
+ uint64_t max_size, uint64_t max_dirty, uint64_t target_dirty, double max_dirty_age)
: perfcounter(NULL),
cct(cct_), writeback_handler(wb), name(name), lock(l),
- max_dirty(0), target_dirty(0), max_size(0),
+ max_dirty(max_dirty), target_dirty(target_dirty), max_size(max_size), max_dirty_age(max_dirty_age),
flush_set_callback(flush_callback), flush_set_callback_arg(flush_callback_arg),
flusher_stop(false), flusher_thread(this),
stat_clean(0), stat_dirty(0), stat_rx(0), stat_tx(0), stat_missing(0), stat_dirty_waiting(0)
else {
// check tail of lru for old dirty items
utime_t cutoff = ceph_clock_now(cct);
- cutoff.sec_ref()--;
+ cutoff -= max_dirty_age;
BufferHead *bh = 0;
while ((bh = (BufferHead*)lru_dirty.lru_get_next_expire()) != 0 &&
bh->last_write < cutoff) {
Mutex& lock;
int64_t max_dirty, target_dirty, max_size;
+ utime_t max_dirty_age;
flush_set_callback_t flush_set_callback;
void *flush_set_callback_arg;
ObjectCacher(CephContext *cct_, string name, WritebackHandler& wb, Mutex& l,
flush_set_callback_t flush_callback,
- void *flush_callback_arg);
+ void *flush_callback_arg,
+ uint64_t max_size, uint64_t max_dirty, uint64_t target_dirty, double max_age);
~ObjectCacher();
void start() {
void set_max_size(int64_t v) {
max_size = v;
}
+ void set_max_dirty_age(double a) {
+ max_dirty_age.set_from_double(a);
+ }
// file functions