search for: cleanup_extents_free

Displaying 20 results from an estimated 34 matches for "cleanup_extents_free".

2019 Mar 19
0
[PATCH nbdkit 2/9] server: Add CLEANUP_EXTENTS_FREE macro.
.../server/internal.h b/server/internal.h index d0da213..825dd3e 100644 --- a/server/internal.h +++ b/server/internal.h @@ -139,6 +139,8 @@ extern void change_user (void); /* cleanup.c */ extern void cleanup_free (void *ptr); #define CLEANUP_FREE __attribute__((cleanup (cleanup_free))) +extern void cleanup_extents_free (void *ptr); +#define CLEANUP_EXTENTS_FREE __attribute__((cleanup (cleanup_extents_free))) extern void cleanup_unlock (pthread_mutex_t **ptr); #define CLEANUP_UNLOCK __attribute__((cleanup (cleanup_unlock))) #define ACQUIRE_LOCK_FOR_CURRENT_SCOPE(mutex) \ diff --git a/server/cleanup.c b/server/c...
2019 Apr 23
0
[nbdkit PATCH 2/4] filters: Utilize CLEANUP_EXTENTS_FREE
...h" + #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL static int64_t offset = 0, range = -1; @@ -138,7 +140,7 @@ offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, struct nbdkit_extents *extents, int *err) { size_t i; - struct nbdkit_extents *extents2; + CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; struct nbdkit_extent e; int64_t real_size = next_ops->get_size (nxdata); @@ -149,20 +151,15 @@ offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, } if (next_ops->extents (nxdata, count, offs + offset,...
2019 Apr 23
0
[nbdkit PATCH 1/4] cleanup: Move cleanup.c to common
...AY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef NBDKIT_CLEANUP_H +#define NBDKIT_CLEANUP_H + +#include <pthread.h> + +extern void cleanup_free (void *ptr); +#define CLEANUP_FREE __attribute__((cleanup (cleanup_free))) +extern void cleanup_extents_free (void *ptr); +#define CLEANUP_EXTENTS_FREE __attribute__((cleanup (cleanup_extents_free))) +extern void cleanup_unlock (pthread_mutex_t **ptr); +#define CLEANUP_UNLOCK __attribute__((cleanup (cleanup_unlock))) +#define ACQUIRE_LOCK_FOR_CURRENT_SCOPE(mutex) \ + CLEANUP_UNLOCK pthread_mutex_t *_lock...
2019 Apr 23
1
Re: [nbdkit PATCH 2/4] filters: Utilize CLEANUP_EXTENTS_FREE
On 4/23/19 2:06 PM, Eric Blake wrote: > Now that cleanup.h is in common code, we can use it in our > filters. The first round focuses just on places that called > nbdkit_extents_free(), as all three callers had multiple exit paths > that definitely benefit from the macro. > > Signed-off-by: Eric Blake <eblake@redhat.com> > --- > filters/offset/offset.c | 13
2019 Apr 23
8
[nbdkit PATCH 0/4] Start using cleanup macros in filters/plugins
...s difference between common/include and common/utils, but it looks like the former is for things that are inlineable via .h only, while the latter is when you need to link in a convenience library, so this landed in the latter. Eric Blake (4): cleanup: Move cleanup.c to common filters: Utilize CLEANUP_EXTENTS_FREE filters: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE plugins: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE common/utils/cleanup.h | 48 ++++++++++++++++++++++++++++++ server/internal.h | 12 +------- {server => common/utils}/cleanup.c | 5 ++-- filters/log/log.c...
2019 Mar 29
2
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
...ct nbdkit_extent e = nbdkit_get_extent (extents2, i); > + > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > + nbdkit_extents_free (extents2); > + return -1; > + } > + } > + nbdkit_extents_free (extents2); > + Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
2019 Aug 28
1
[nbdkit PATCH] offset, partition: Fix .extents with non-zero offset
...{ e = nbdkit_get_extent (extents2, i); diff --git a/filters/offset/offset.c b/filters/offset/offset.c index efe5c6d1..00122770 100644 --- a/filters/offset/offset.c +++ b/filters/offset/offset.c @@ -140,9 +140,9 @@ offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, size_t i; CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; struct nbdkit_extent e; - int64_t real_size = next_ops->get_size (nxdata); + int64_t real_size = range >= 0 ? offset + range : next_ops->get_size (nxdata); - extents2 = nbdkit_extents_new (offs + offset, real_size - offset); + extents2 = nbdk...
2019 Mar 29
1
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
On 3/29/19 3:40 AM, Richard W.M. Jones wrote: >>> + nbdkit_extents_free (extents2); >>> + >> >> Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? > > At the moment the CLEANUP_* macros are only available to server code, > not to plugins or filters. They would certainly make plugins and > filters easier to write. I would really like attribute((cleanup)) to > turn up in ISO C one day :-) Just...
2019 Apr 23
1
[RFC: nbdkit PATCH] cleanup: Assert mutex sanity
...ck (_lock) + do { \ + int _r = pthread_mutex_lock (_lock); \ + assert (!_r); \ + } while (0) #endif /* NBDKIT_CLEANUP_H */ diff --git a/common/utils/cleanup.c b/common/utils/cleanup.c index 196d910..995f46c 100644 --- a/common/utils/cleanup.c +++ b/common/utils/cleanup.c @@ -53,5 +53,6 @@ cleanup_extents_free (void *ptr) void cleanup_unlock (pthread_mutex_t **ptr) { - pthread_mutex_unlock (*ptr); + int r = pthread_mutex_unlock (*ptr); + assert (!r); } -- 2.20.1
2019 Mar 29
0
Re: [PATCH nbdkit v5 FINAL 12/19] truncate: Implement extents for beyond end of truncated region.
...i); > > + > > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > > + nbdkit_extents_free (extents2); > > + return -1; > > + } > > + } > > + nbdkit_extents_free (extents2); > > + > > Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters? At the moment the CLEANUP_* macros are only available to server code, not to plugins or filters. They would certainly make plugins and filters easier to write. I would really like attribute((cleanup)) to turn up in ISO C one day :-) Rich. -- Richard Jones, Vir...
2019 Apr 24
1
[PATCH nbdkit] server: Initialize ‘buf’ to avoid GCC 9.0.1 warning.
...l.c b/server/protocol.c index 6fd3b62..5033fd7 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -611,7 +611,7 @@ protocol_recv_request_send_reply (struct connection *conn) uint16_t cmd, flags; uint32_t magic, count, error = 0; uint64_t offset; - char *buf; + char *buf = NULL; CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents = NULL; /* Read the request packet. */ -- 2.20.1
2019 Apr 24
0
[nbdkit PATCH 2/4] truncate: Factor out reading real_size under mutex
...(offset + count <= real_size_copy) @@ -292,14 +281,10 @@ truncate_extents (struct nbdkit_next_ops *next_ops, void *nxdata, uint32_t flags, struct nbdkit_extents *extents, int *err) { uint32_t n; - uint64_t real_size_copy; + uint64_t real_size_copy = get_real_size (); CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; size_t i; - pthread_mutex_lock (&lock); - real_size_copy = real_size; - pthread_mutex_unlock (&lock); - /* If the entire request is beyond the end of the underlying plugin * then this is the easy case: return a hole up to the end of the...
2020 Jul 31
6
[RFC nbdkit PATCH 0/4] Progress towards .list_exports
This takes Rich's API proposal and starts fleshing it out with enough meat that I was able to test 'nbdkit eval' advertising multiple exports with descriptions paired with 'qemu-nbd --list'. Eric Blake (3): server: Add exports list functions server: Prepare to use export list from plugin sh, eval: Add .list_exports support Richard W.M. Jones (1): server: Implement
2020 Jul 08
1
Re: [nbdkit PATCH 2/3] extents: Add nbdkit_extents_aligned()
...extents_remove (&exts->extents, 1); > + } > + else { > + /* The plugin needs a fresh extents object each time, but > + * with care, we can merge it into the callers' extents. > + */ > + extents tmp; > + CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; > + > + extents2 = nbdkit_extents_new (e.offset + e.length, offset + align); > + if (next_ops->extents (nxdata, offset + align - e.length, > + e.offset + e.length, > +...
2019 Apr 23
0
[PATCH nbdkit v2 2/2] server: Use a thread-local pread/pwrite buffer to avoid leaking heap data.
...protocol.c index 3f89f6d..9e8eea5 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -611,7 +611,7 @@ protocol_recv_request_send_reply (struct connection *conn) uint16_t cmd, flags; uint32_t magic, count, error = 0; uint64_t offset; - CLEANUP_FREE char *buf = NULL; + char *buf; CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents = NULL; /* Read the request packet. */ @@ -656,12 +656,12 @@ protocol_recv_request_send_reply (struct connection *conn) goto send_reply; } - /* Allocate the data buffer used for either read or write requests. */ + /* Get the data buffer used f...
2020 Jul 07
0
[nbdkit PATCH 2/3] extents: Add nbdkit_extents_aligned()
...ts->extents.ptr[1].type; + extents_remove (&exts->extents, 1); + } + else { + /* The plugin needs a fresh extents object each time, but + * with care, we can merge it into the callers' extents. + */ + extents tmp; + CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; + + extents2 = nbdkit_extents_new (e.offset + e.length, offset + align); + if (next_ops->extents (nxdata, offset + align - e.length, + e.offset + e.length, + flags & ~NBD...
2020 Jul 07
6
[RFC nbdkit PATCH 0/3] aligned .extents
Ultimately, both the blocksize and swab filters want to return aligned extents to the client. I'm posting this as a snapshot of my work in progress on how I plan to get there (it's not quite working yet, but I'm done for today and wanted to at least document my ideas). I might also add a convenience function for nbdkit_extents_offset, since we have a number of filters that repeat the
2020 Aug 06
6
[nbdkit PATCH v2 0/5] .list_exports
Since v1: - patch 1: check size limits - patch 2: better handling of default export name canonicalization - patch 3: support filters as well as plugins - patch 4: new - patch 5: rewrite sh parser, fix testsuite to actually work and cover more cases (now that libnbd.git is fixed) Eric Blake (4): server: Add exports list functions server: Prepare to use export list from plugin log: Add
2020 Jul 09
0
[nbdkit PATCH] blocksize: Fix .extents when plugin changes type within minblock
...* fine to return less than the full count as long as we're making + * progress. */ - return next_ops->extents (nxdata, - MIN (count, maxlen), - ROUND_DOWN (offset, minblock), - flags, extents, err); + CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; + size_t i; + struct nbdkit_extent e; + + extents2 = nbdkit_extents_new (ROUND_DOWN (offset, minblock), + ROUND_UP (offset + count, minblock)); + if (extents2 == NULL) { + *err = errno; + return -1; + } + + if (nbdk...
2019 Apr 27
0
[nbdkit PATCH 2/4] truncate: Fix corruption when plugin changes per-connection size
...zero (nxdata, n, offset, flags, err); } return 0; @@ -292,21 +306,17 @@ truncate_extents (struct nbdkit_next_ops *next_ops, void *nxdata, uint32_t flags, struct nbdkit_extents *extents, int *err) { uint32_t n; - uint64_t real_size_copy; + struct handle *h = handle; CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL; size_t i; - pthread_mutex_lock (&lock); - real_size_copy = real_size; - pthread_mutex_unlock (&lock); - /* If the entire request is beyond the end of the underlying plugin * then this is the easy case: return a hole up to the end of the...