cluster-cache: fix put() not allocating space for a cluster in on-disk storage
This commit is contained in:
@@ -185,6 +185,30 @@ enum ec3_status cluster_cache_get(
|
|||||||
return EC3_SUCCESS;
|
return EC3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum ec3_status alloc_ondisk_cluster(
|
||||||
|
struct cluster_cache *cache,
|
||||||
|
size_t *offset)
|
||||||
|
{
|
||||||
|
char buf[1024] = {0};
|
||||||
|
|
||||||
|
size_t pos;
|
||||||
|
b_file_size(cache->c_storage, &pos);
|
||||||
|
b_file_seek(cache->c_storage, 0, B_SEEK_END);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < cache->c_cluster_size; i += sizeof buf) {
|
||||||
|
size_t nr_written = 0;
|
||||||
|
b_file_write(
|
||||||
|
cache->c_storage,
|
||||||
|
B_OFFSET_CURRENT,
|
||||||
|
sizeof buf,
|
||||||
|
buf,
|
||||||
|
&nr_written);
|
||||||
|
}
|
||||||
|
|
||||||
|
*offset = pos;
|
||||||
|
return EC3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
enum ec3_status cluster_cache_put(
|
enum ec3_status cluster_cache_put(
|
||||||
struct cluster_cache *cache,
|
struct cluster_cache *cache,
|
||||||
size_t cluster_id,
|
size_t cluster_id,
|
||||||
@@ -210,7 +234,7 @@ enum ec3_status cluster_cache_put(
|
|||||||
entry->e_length = len;
|
entry->e_length = len;
|
||||||
|
|
||||||
if (cache->c_storage) {
|
if (cache->c_storage) {
|
||||||
b_file_size(cache->c_storage, &entry->e_storage_offset);
|
alloc_ondisk_cluster(cache, &entry->e_storage_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
put_cluster(&cache->c_entries, entry);
|
put_cluster(&cache->c_entries, entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user