]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
objectcacher: make *_max_dirty_age tunables; pass to ctor
authorSage Weil <sage@newdream.net>
Tue, 8 May 2012 23:19:51 +0000 (16:19 -0700)
committerSage Weil <sage@newdream.net>
Tue, 8 May 2012 23:19:51 +0000 (16:19 -0700)
This replaces the hard-coded 1 second writeback timer.

Signed-off-by: Sage Weil <sage@newdream.net>
src/client/Client.cc
src/common/config_opts.h
src/include/utime.h
src/librbd.cc
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 86d3c7605b9c64e3c77d6a1dad890817203d8fb7..d245edb055dd4227a71a703b43401878b325d740 100644 (file)
@@ -152,10 +152,11 @@ Client::Client(Messenger *m, MonClient *mc)
   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);
 }
 
index a7c6a462c71145efc057fcf54c1ddc6b0e96c4e8..6a7a3361c55b9f9a048276ac37cd3cf232149d2a 100644 (file)
@@ -153,6 +153,7 @@ OPTION(client_oc, OPT_BOOL, true)
 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)
@@ -378,6 +379,7 @@ OPTION(rbd_cache, OPT_BOOL, false) // whether to enable writeback caching
 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
index 6953a9bcf63544a6a0ad8a38790e22e5ae42345d..3758fe65bb160752f2a1884da93a48baab1c5088 100644 (file)
@@ -54,6 +54,9 @@ public:
   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;
index bd43dd2c132a480801b38866d15df1de99f9172f..05ce5407531c6b7bd239c5f774843be973627c70 100644 (file)
@@ -147,10 +147,11 @@ namespace librbd {
        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();
       }
index ee62de404e45d968142cd3fe2ea8efa465d271b8..b0187906625d7d6bc4682fa4ab57a4f6188c7e88 100644 (file)
@@ -411,10 +411,11 @@ void ObjectCacher::Object::discard(loff_t off, loff_t len)
 
 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)
@@ -1165,7 +1166,7 @@ void ObjectCacher::flusher_entry()
       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) {
index 4e055e298b985478e97ed86d0fe96648c9c4a68a..0728a1f2920eb664e0150d1f6f14fcc86b89ce4d 100644 (file)
@@ -296,6 +296,7 @@ class ObjectCacher {
   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;
@@ -463,7 +464,8 @@ class 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_age);
   ~ObjectCacher();
 
   void start() {
@@ -533,6 +535,9 @@ public:
   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