search for: parse_round_param

Displaying 6 results from an estimated 6 matches for "parse_round_param".

2018 Aug 01
0
[PATCH v2 nbdkit 5/6] Add truncate filter for truncating or extending the size of plugins.
...wn = 0; + +/* The real size of the underlying plugin. */ +static uint64_t real_size; + +/* The calculated size after applying the parameters. */ +static uint64_t size; + +/* This lock protects the real_size and size fields. */ +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +static int +parse_round_param (const char *key, const char *value, unsigned *ret) +{ + int64_t r; + unsigned u; + + /* Parse it as a "size" quantity so we allow round-up=1M and similar. */ + r = nbdkit_parse_size (value); + if (r == -1) + return -1; + + /* Must not be zero or larger than an unsigned int. */ +...
2019 Apr 24
0
[nbdkit PATCH 2/4] truncate: Factor out reading real_size under mutex
...ate/truncate.c @@ -63,6 +63,13 @@ static uint64_t size; /* This lock protects the real_size and size fields. */ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static uint64_t +get_real_size (void) +{ + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock); + return real_size; +} + static int parse_round_param (const char *key, const char *value, unsigned *ret) { @@ -147,7 +154,7 @@ truncate_get_size (struct nbdkit_next_ops *next_ops, void *nxdata, if (r == -1) return -1; - pthread_mutex_lock (&lock); + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock); real_size = size = r; @@ -163,8 +170,...
2019 Apr 27
0
[nbdkit PATCH 2/4] truncate: Fix corruption when plugin changes per-connection size
...own = 0; -/* The real size of the underlying plugin. */ -static uint64_t real_size; - -/* The calculated size after applying the parameters. */ -static uint64_t size; - -/* This lock protects the real_size and size fields. */ -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - static int parse_round_param (const char *key, const char *value, unsigned *ret) { @@ -121,51 +112,90 @@ truncate_config (nbdkit_next_config *next, void *nxdata, "round-up=<N> Round up to next multiple of N.\n" \ "round-down=<N> Round down to multiple of N.&qu...
2018 Aug 01
12
[PATCH v2 nbdkit 0/6] Add truncate filter and other fixes.
I have dropped the map filter from this series for now while I try to get it working. However I think the truncate filter is in a good shape. This incorporates all feedback from Eric's review. Also there are three small fixes to the filter code, all revealed when I was testing using multiple filters which we'd not done much of before. Rich.
2019 Apr 27
8
[nbdkit PATCH 0/4] Fix truncate handling of real_size
While working on adding assertions to pthread_mutex_lock calls, I noticed that the truncate filter's use of mutex didn't really protect us, and isn't really necessary. Cleaning that up also spotted a couple of other potential cleanups. Eric Blake (4): filters: Drop useless .open callbacks truncate: Fix corruption when plugin changes per-connection size truncate: Test for safe
2019 Apr 24
7
[nbdkit PATCH 0/4] More mutex sanity checking
I do have a question about whether patch 2 is right, or whether I've exposed a bigger problem in the truncate (and possibly other) filter, but the rest seem fairly straightforward. Eric Blake (4): server: Check for pthread lock failures truncate: Factor out reading real_size under mutex plugins: Check for mutex failures filters: Check for mutex failures filters/cache/cache.c