Skip to content

Commit

Permalink
extstore: fail to start if given no disk space
Browse files Browse the repository at this point in the history
should avoid accidentally starting up with extstore enabled but no atual
disk space assigned.
  • Loading branch information
dormando committed Jun 13, 2023
1 parent e3052dc commit 4269308
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ struct extstore_conf_file *storage_conf_parse(char *arg, unsigned int page_size)
// page_count is nearest-but-not-larger-than pages * psize
cf->page_count = multiplier / page_size;
assert(page_size * cf->page_count <= multiplier);
if (cf->page_count == 0) {
fprintf(stderr, "supplied ext_path has zero size, cannot use\n");
goto error;
}

// final token would be a default free bucket
p = strtok_r(NULL, ",", &b);
Expand Down
10 changes: 10 additions & 0 deletions t/extstore.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ if (!supports_extstore()) {

$ext_path = "/tmp/extstore.$$";

eval {
my $server = new_memcached("-o ext_path=$ext_path:0m");
};
ok($@, "failed to start server with zero pages assigned");

eval {
my $server = new_memcached("-o ext_path=$ext_path:1GB");
};
ok($@, "failed to start server with invalid path size");

my $server = new_memcached("-m 64 -U 0 -o ext_page_size=8,ext_wbuf_size=2,ext_threads=1,ext_io_depth=2,ext_item_size=512,ext_item_age=2,ext_recache_rate=10000,ext_max_frag=0.9,ext_path=$ext_path:64m,slab_automove=0,ext_compact_under=1,ext_max_sleep=100000");
my $sock = $server->sock;

Expand Down

0 comments on commit 4269308

Please sign in to comment.