With this patch, journal size and object cache size should be set with human friendly value like 200G, 2000M.
This patch breaks compatibility of command line. Signed-off-by: Liu Yuan <[email protected]> --- sheep/journal.c | 2 +- sheep/sheep.c | 39 ++++++++++++++++++++------------------- tests/functional/018 | 2 +- tests/functional/019 | 2 +- tests/functional/020 | 2 +- tests/functional/044 | 2 +- tests/functional/047 | 4 ++-- tests/functional/049 | 4 ++-- tests/functional/058 | 2 +- tests/functional/065 | 4 ++-- tests/functional/066 | 2 +- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/sheep/journal.c b/sheep/journal.c index cd38701..49e2b95 100644 --- a/sheep/journal.c +++ b/sheep/journal.c @@ -266,7 +266,7 @@ int journal_file_init(const char *path, size_t size, bool skip) if (!skip) check_recover_journal_file(path); - jfile_size = (size * 1024 * 1024) / 2; + jfile_size = size / 2; fd = create_journal_file(path, jfile_name[0]); if (fd < 0) diff --git a/sheep/sheep.c b/sheep/sheep.c index e9c7eb5..5856ba2 100644 --- a/sheep/sheep.c +++ b/sheep/sheep.c @@ -40,8 +40,8 @@ static const char journal_help[] = "\tsize=: size of the journal in megabyes\n" "\tdir=: path to the location of the journal (default: $STORE)\n" "\tskip: if specified, skip the recovery at startup\n" -"\nExample:\n\t$ sheep -j dir=/journal,size=1024\n" -"This tries to use /journal as the journal storage of the size 1024M\n"; +"\nExample:\n\t$ sheep -j dir=/journal,size=1G\n" +"This tries to use /journal as the journal storage of the size 1G\n"; static const char loglevel_help[] = "Available log levels:\n" @@ -90,7 +90,7 @@ static const char cache_help[] = "\tdir=: path to the location of the cache (default: $STORE/cache)\n" "\tdirectio: use directio mode for cache IO, " "if not specified use buffered IO\n" -"\nExample:\n\t$ sheep -w size=200000,dir=/my_ssd,directio ...\n" +"\nExample:\n\t$ sheep -w size=200G,dir=/my_ssd,directio ...\n" "This tries to use /my_ssd as the cache storage with 200G allocted to the\n" "cache in directio mode\n"; @@ -260,21 +260,21 @@ struct system_info *sys = &__sys; static int cache_size_parser(char *s) { - const uint32_t max_cache_size = UINT32_MAX; + const uint64_t max_cache_size = ((uint64_t)UINT32_MAX + 1)*1024*1024; uint64_t cache_size; - char *p; - cache_size = strtoull(s, &p, 10); - if (s == p || max_cache_size < cache_size) - goto err; + if (option_parse_size(s, &cache_size) < 0) + return -1; +#define MIN_CACHE_SIZE (10*1024*1024) /* 10M */ + if (cache_size < MIN_CACHE_SIZE || cache_size > max_cache_size) { + sd_err("Invalid cache option '%s': size must be between " + "between %uM and %" PRIu64 "G", s, + MIN_CACHE_SIZE/1024/1024, max_cache_size/1024/1024/1024); + return -1; + } - sys->object_cache_size = cache_size; + sys->object_cache_size = cache_size / 1024 / 1024; return 0; - -err: - sd_err("Invalid object cache option '%s': size must be an integer " - "between 1 and %" PRIu32 " inclusive", s, max_cache_size); - return -1; } static int cache_directio_parser(char *s) @@ -319,8 +319,7 @@ static struct option_parser ionic_parsers[] = { static char jpath[PATH_MAX]; static bool jskip; -static ssize_t jsize; -#define MIN_JOURNAL_SIZE (64) /* 64M */ +static uint64_t jsize; static int journal_dir_parser(char *s) { @@ -330,10 +329,12 @@ static int journal_dir_parser(char *s) static int journal_size_parser(char *s) { - jsize = strtoll(s, NULL, 10); - if (jsize < MIN_JOURNAL_SIZE || jsize == LLONG_MAX) { + if (option_parse_size(s, &jsize) < 0) + return -1; +#define MIN_JOURNAL_SIZE (64*1024*1024) /* 64M */ + if (jsize < MIN_JOURNAL_SIZE) { sd_err("invalid size %s, must be bigger than %u(M)", - s, MIN_JOURNAL_SIZE); + s, MIN_JOURNAL_SIZE/1024/1024); return -1; } return 0; diff --git a/tests/functional/018 b/tests/functional/018 index c0ab9ee..bcec541 100755 --- a/tests/functional/018 +++ b/tests/functional/018 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 2`; do - _start_sheep $i "-w size=100" + _start_sheep $i "-w size=100M" done _wait_for_sheep "3" diff --git a/tests/functional/019 b/tests/functional/019 index efe8cb8..136fb6e 100755 --- a/tests/functional/019 +++ b/tests/functional/019 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 2`; do - _start_sheep $i "-w size=100" + _start_sheep $i "-w size=100M" done _wait_for_sheep "3" diff --git a/tests/functional/020 b/tests/functional/020 index 77066bf..a2a6d04 100755 --- a/tests/functional/020 +++ b/tests/functional/020 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 2`; do - _start_sheep $i "-w size=20" + _start_sheep $i "-w size=20M" done _wait_for_sheep "3" diff --git a/tests/functional/044 b/tests/functional/044 index fc5d8be..0db70f9 100755 --- a/tests/functional/044 +++ b/tests/functional/044 @@ -5,7 +5,7 @@ . ./common for i in 0 1 2; do - _start_sheep $i "-w size=1000" + _start_sheep $i "-w size=1000M" done _wait_for_sheep 3 diff --git a/tests/functional/047 b/tests/functional/047 index 675f74e..df527e5 100755 --- a/tests/functional/047 +++ b/tests/functional/047 @@ -4,7 +4,7 @@ . ./common -_start_sheep 0 "-j size=64" +_start_sheep 0 "-j size=64M" _wait_for_sheep 1 @@ -26,7 +26,7 @@ else fi # do the journal replay -_start_sheep 0 "-j size=64" +_start_sheep 0 "-j size=64M" _wait_for_sheep 1 sleep 3 diff --git a/tests/functional/049 b/tests/functional/049 index d466130..ae3ebc8 100755 --- a/tests/functional/049 +++ b/tests/functional/049 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 2`; do - _start_sheep $i "-w size=30" + _start_sheep $i "-w size=30M" done _wait_for_sheep 3 @@ -20,7 +20,7 @@ _wait_for_sheep_stop #trigger an object reclaim at startup for i in `seq 0 2`; do - _start_sheep $i "-w size=10" + _start_sheep $i "-w size=10M" done _wait_for_sheep 3 diff --git a/tests/functional/058 b/tests/functional/058 index ea584de..ebd61db 100755 --- a/tests/functional/058 +++ b/tests/functional/058 @@ -4,7 +4,7 @@ . ./common for i in 0 1 2; do - _start_sheep $i "-w size=200" + _start_sheep $i "-w size=200M" done _wait_for_sheep 3 _cluster_format diff --git a/tests/functional/065 b/tests/functional/065 index e0ee1ae..7e5e03b 100755 --- a/tests/functional/065 +++ b/tests/functional/065 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 1`; do - _start_sheep $i "-w size=400" + _start_sheep $i "-w size=400M" done _wait_for_sheep 2 @@ -15,7 +15,7 @@ $DOG vdi create t 1G -P # move objects into stale directory _kill_sheep 0 -_start_sheep 0 "-w size=400" +_start_sheep 0 "-w size=400M" _wait_for_sheep 2 dd if=/dev/zero | $DOG vdi write -w t & diff --git a/tests/functional/066 b/tests/functional/066 index 97f0b9f..84dedee 100755 --- a/tests/functional/066 +++ b/tests/functional/066 @@ -5,7 +5,7 @@ . ./common for i in `seq 0 1 2`; do - _start_sheep $i "-w size=200" + _start_sheep $i "-w size=200M" done _wait_for_sheep 3 -- 1.7.9.5 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
