Commit d894161b authored by antirez's avatar antirez
Browse files

New object field (one of the unused bytes) to hold the type of the swapped out...

New object field (one of the unused bytes) to hold the type of the swapped out value object in key objects
parent 7d30035d
...@@ -231,8 +231,10 @@ typedef struct redisObject { ...@@ -231,8 +231,10 @@ typedef struct redisObject {
void *ptr; void *ptr;
unsigned char type; unsigned char type;
unsigned char encoding; unsigned char encoding;
unsigned char storage; /* where? REDIS_VM_MEMORY, REDIS_VM_SWAPPED, ... */ unsigned char storage; /* If this object is a key, where is the value?
unsigned char notused; * REDIS_VM_MEMORY, REDIS_VM_SWAPPED, ... */
unsigned char vtype; /* If this object is a key, and value is swapped out,
* this is the type of the swapped out object. */
int refcount; int refcount;
/* VM fields, this are only allocated if VM is active, otherwise the /* VM fields, this are only allocated if VM is active, otherwise the
* object allocation function will just allocate * object allocation function will just allocate
...@@ -6791,6 +6793,7 @@ static int vmSwapObject(robj *key, robj *val) { ...@@ -6791,6 +6793,7 @@ static int vmSwapObject(robj *key, robj *val) {
key->vm.page = page; key->vm.page = page;
key->vm.usedpages = pages; key->vm.usedpages = pages;
key->storage = REDIS_VM_SWAPPED; key->storage = REDIS_VM_SWAPPED;
key->vtype = val->type;
decrRefCount(val); /* Deallocate the object from memory. */ decrRefCount(val); /* Deallocate the object from memory. */
vmMarkPagesUsed(page,pages); vmMarkPagesUsed(page,pages);
redisLog(REDIS_DEBUG,"VM: object %s swapped out at %lld (%lld pages)", redisLog(REDIS_DEBUG,"VM: object %s swapped out at %lld (%lld pages)",
...@@ -6811,7 +6814,7 @@ static robj *vmLoadObject(robj *key) { ...@@ -6811,7 +6814,7 @@ static robj *vmLoadObject(robj *key) {
strerror(errno)); strerror(errno));
exit(1); exit(1);
} }
val = rdbLoadObject(key->type,server.vm_fp); val = rdbLoadObject(key->vtype,server.vm_fp);
if (val == NULL) { if (val == NULL) {
redisLog(REDIS_WARNING, "Unrecoverable VM problem in vmLoadObject(): can't load object from swap file: %s", strerror(errno)); redisLog(REDIS_WARNING, "Unrecoverable VM problem in vmLoadObject(): can't load object from swap file: %s", strerror(errno));
exit(1); exit(1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment