From 6493661852dfb212ca7320f7de3c9760f502dd83 Mon Sep 17 00:00:00 2001 From: carlosm Date: Wed, 6 Jul 2005 00:40:16 +0000 Subject: [PATCH] Modified Files: client/Buffercache.h client/Buffercache.cc include/config.h config.cc Configuration variables git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@401 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/client/Buffercache.cc | 12 ++++++------ ceph/client/Buffercache.h | 15 ++++++++++----- ceph/config.cc | 3 +++ ceph/config.h | 3 +++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ceph/client/Buffercache.cc b/ceph/client/Buffercache.cc index b56d76bf41ff6..a57b019507eff 100644 --- a/ceph/client/Buffercache.cc +++ b/ceph/client/Buffercache.cc @@ -50,8 +50,8 @@ void Bufferhead::alloc_buffers(size_t size) { dout(10) << "bc: allocating buffers size: " << size << endl; while (size > 0) { - if (size <= BUFC_ALLOC_MAXSIZE) { - size_t k = BUFC_ALLOC_MINSIZE; + if (size <= g_conf.client_bcache_alloc_maxsize) { + size_t k = g_conf.client_bcache_alloc_minsize; size_t asize = size - size % k + (size % k > 0) * k; buffer *b = new buffer(asize); b->set_length(size); @@ -59,11 +59,11 @@ void Bufferhead::alloc_buffers(size_t size) dout(10) << "bc: new buffer(" << asize << "), total: " << bl.length() << endl; break; } - buffer *b = new buffer(BUFC_ALLOC_MAXSIZE); - b->set_length(BUFC_ALLOC_MAXSIZE); + buffer *b = new buffer(g_conf.client_bcache_alloc_maxsize); + b->set_length(g_conf.client_bcache_alloc_maxsize); bl.push_back(b); - dout(10) << "bc: new buffer(" << BUFC_ALLOC_MAXSIZE << "), total: " << bl.length() << endl; - size -= BUFC_ALLOC_MAXSIZE; + dout(10) << "bc: new buffer(" << g_conf.client_bcache_alloc_maxsize << "), total: " << bl.length() << endl; + size -= g_conf.client_bcache_alloc_maxsize; } dout(7) << "bc: allocated " << bl.buffers().size() << " buffers (" << bl.length() << " bytes) " << endl; } diff --git a/ceph/client/Buffercache.h b/ceph/client/Buffercache.h index b574ecab5c280..bb17ba54439e1 100644 --- a/ceph/client/Buffercache.h +++ b/ceph/client/Buffercache.h @@ -7,6 +7,7 @@ #include "include/buffer.h" #include "include/bufferlist.h" #include "include/lru.h" +#include "include/config.h" #include "common/Cond.h" // stl @@ -15,10 +16,6 @@ #include using namespace std; -// FIXME: buffer constants -#define BUFC_ALLOC_MINSIZE 1024 -#define BUFC_ALLOC_MAXSIZE 262144 - // Bufferhead states #define BUFHD_STATE_CLEAN 1 #define BUFHD_STATE_DIRTY 2 @@ -129,6 +126,14 @@ class Filecache { buffer_map.clear(); } + ~Filecache() { + for (map::iterator it = buffer_map.begin(); + it != buffer_map.end(); + it++) { + delete it->second; + } + } + size_t length() { size_t len = 0; for (map::iterator it = buffer_map.begin(); @@ -166,10 +171,10 @@ class Buffercache { // FIXME: constructor & destructor need to mesh with allocator scheme ~Buffercache() { - // FIXME: make sure all buffers are cleaned and then free them for (map::iterator it = bcache_map.begin(); it != bcache_map.end(); it++) { + // FIXME: make sure all buffers are cleaned and then free them delete it->second; } } diff --git a/ceph/config.cc b/ceph/config.cc index 4ab5ffa1c76fa..044fe3c745938 100644 --- a/ceph/config.cc +++ b/ceph/config.cc @@ -58,6 +58,9 @@ md_config_t g_conf = { client_cache_mid: .5, client_cache_stat_ttl: 10, // seconds until cached stat results become invalid client_use_random_mds: false, + client_bcache_alloc_minsize: 1024, + client_bcache_alloc_maxsize: 262144, + client_bcache_ttl: 30, // seconds until dirty buffers are written to disk // --- mds --- mds_cache_size: MDS_CACHE_SIZE, diff --git a/ceph/config.h b/ceph/config.h index b3bf82b746a31..033c4f70ce668 100644 --- a/ceph/config.h +++ b/ceph/config.h @@ -33,6 +33,9 @@ struct md_config_t { float client_cache_mid; int client_cache_stat_ttl; bool client_use_random_mds; // debug flag + int client_bcache_alloc_minsize; + int client_bcache_alloc_maxsize; + int client_bcache_ttl; // mds int mds_cache_size; -- 2.39.5