In reply to:
If we call it with n_caches > what is in the file, we should flush the old cache and the re-initalize the cache for more files. This is a likely scenario when we add a new store engine that also wants to use the append_cache in which case n_caches can increase for the same server instance
In reply to:
Note that as the above is uint, it can never be < 0, so it's easier to just test == 0
/* Wait for preceding concurrent writes completion */
while ((uint64_t) my_atomic_load64_explicit((int64*) &cache->cached_eof, MY_MEMORY_ORDER_RELAXED) <
start) LF_BACKOFF();
Why wait. Can't we start writing to the beginning of the cache buffer up to the last flushed byte?
Isn't the cache a round-buffer? From the code it looks like we write to the end always, then flush and then start from the beginning.
hm.. It's probably right that we test for <= 0 above, but we need to cast the full expression to int or just make avail an int64_t
In reply to:
ssize_t written; is sent to my_pwrite which takes size_t. Isn't it better to use size_t to not get warnings about conversions on windows ?
In reply to:
Why is n_caches uint64? When reading the code, I would assume that this means it's very big. Why not just uint ?
I can understand you want the header structure aligned, but that is independent of the user interface that is using 'n'
alos, please replace 'n' as a parameter to cache_slot or something more readable
Another thing to think about is to replace argument checking to use assert instead of return...
if (n >= dir->header->n_caches)
return -1;
In reply to:
In create_directory, shouldn't you start with setting dir->header to 0 to make it easy to check if the structure is unitialized or not?
Better to use header than 'dummy' which doesn't tell the user what it's all about.
In reply to:
+/* PMAC0\0\0\0 */
+static const uint64_t pmem_append_cache_magic= 0x0000003043414d50;
In allmost all mariadb code, we usually have a magic prefix of:
255,255,id,version
The current max id is 12, so you could use 13.
sorry, should be 254,254
For example:
uchar maria_file_magic[]=
{ (uchar) 254, (uchar) 254, (uchar) 9, '\003', };
uchar maria_pack_file_magic[]=
{ (uchar) 254, (uchar) 254, (uchar) 10, '\001', };
most system have updated 'file' to support mariadb files...