Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

RFC: Refine sdsmvtonvm(...) function to return more information when nvm_malloc failed. #13

@BrytonLee

Description

@BrytonLee

sds sdsmvtonvm(const sds s)

 106 sds sdsmvtonvm(const sds s)
 107 {
 108     if(server.nvm_base && !is_nvm_addr(s))
 109     {
 110         size_t header_size = sdsheadersize(s);
 111         size_t total_size = header_size + sdsalloc(s) + 1;
 112         if(total_size >= server.sdsmv_threshold)
 113         {
 114             void* new_sh = nvm_malloc(total_size);
 115             if(!new_sh)
 116             {
 117                 //serverLog(LL_WARNING, "Can't allocate on NVM. Keep data in memory.");
 118                 return s;
 119             }
 120             void* sh = s - header_size;
 121             size_t used_size = header_size + sdslen(s) + 1;
 122             pmem_memcpy_persist(new_sh, sh, used_size);
 123             zfree(sh);
 124             return (char*)new_sh + header_size;
 125         }
 126     }
 127     return s;
 128 }

I would like to change the sdsmvtonvm() signature to return an error message when nvm_malloc failed. Otherwise, users who calls sdsmvtonvm() have no chance to check if it succeed or not.

Would you like to shed a light on that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions