summaryrefslogtreecommitdiff
path: root/slabs.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-09-26 14:43:17 -0700
committerdormando <dormando@rydia.net>2017-11-28 14:18:05 -0800
commitf593a59bce69f917514ef6213cf565c71bddcf8c (patch)
tree4a5dc07433e97b089f46a913b5367aa5d52c059a /slabs.c
parente6239a905d072e837baa8aa425ca0ccee2fc3e01 (diff)
downloadmemcached-f593a59bce69f917514ef6213cf565c71bddcf8c.tar.gz
external storage base commit
been squashing reorganizing, and pulling code off to go upstream ahead of merging the whole branch.
Diffstat (limited to 'slabs.c')
-rw-r--r--slabs.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/slabs.c b/slabs.c
index 0fc3d16..c523a5f 100644
--- a/slabs.c
+++ b/slabs.c
@@ -360,6 +360,9 @@ static void do_slabs_free(void *ptr, const size_t size, unsigned int id) {
it = (item *)ptr;
if ((it->it_flags & ITEM_CHUNKED) == 0) {
+#ifdef EXTSTORE
+ bool is_hdr = it->it_flags & ITEM_HDR;
+#endif
it->it_flags = ITEM_SLABBED;
it->slabs_clsid = 0;
it->prev = 0;
@@ -368,7 +371,15 @@ static void do_slabs_free(void *ptr, const size_t size, unsigned int id) {
p->slots = it;
p->sl_curr++;
+#ifdef EXTSTORE
+ if (!is_hdr) {
+ p->requested -= size;
+ } else {
+ p->requested -= (size - it->nbytes) + sizeof(item_hdr);
+ }
+#else
p->requested -= size;
+#endif
} else {
do_slabs_free_chunked(it, size);
}
@@ -855,6 +866,11 @@ static int slab_rebalance_move(void) {
*/
/* Check if expired or flushed */
ntotal = ITEM_ntotal(it);
+#ifdef EXTSTORE
+ if (it->it_flags & ITEM_HDR) {
+ ntotal = (ntotal - it->nbytes) + sizeof(item_hdr);
+ }
+#endif
/* REQUIRES slabs_lock: CHECK FOR cls->sl_curr > 0 */
if (ch == NULL && (it->it_flags & ITEM_CHUNKED)) {
/* Chunked should be identical to non-chunked, except we need
@@ -928,6 +944,7 @@ static int slab_rebalance_move(void) {
} else {
/* restore ntotal in case we tried saving a head chunk. */
ntotal = ITEM_ntotal(it);
+ // FIXME: need storage instance to call extstore_delete
do_item_unlink(it, hv);
slabs_free(it, ntotal, slab_rebal.s_clsid);
/* Swing around again later to remove it from the freelist. */
@@ -1027,6 +1044,7 @@ static void slab_rebalance_finish(void) {
slab_rebal.d_clsid);
} else if (slab_rebal.d_clsid == SLAB_GLOBAL_PAGE_POOL) {
/* mem_malloc'ed might be higher than mem_limit. */
+ mem_limit_reached = false;
memory_release();
}