search for: nbdkit_add_ext

Displaying 20 results from an estimated 120 matches for "nbdkit_add_ext".

2019 Apr 24
4
[PATCH nbdkit 2/2] filters: Be careful to set *err if nbdkit_add_extent or nbdkit_extents_new fail.
This fix isn't exhaustive but it fixes some obvious problems in the filters. Rich.
2019 Apr 24
0
[PATCH nbdkit 2/2] filters: Be careful to set *err if nbdkit_add_extent or nbdkit_extents_new fail.
.....633a1c7 100644 --- a/filters/offset/offset.c +++ b/filters/offset/offset.c @@ -156,8 +156,10 @@ offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, for (i = 0; i < nbdkit_extents_count (extents2); ++i) { e = nbdkit_get_extent (extents2, i); e.offset -= offset; - if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { + *err = errno; return -1; + } } return 0; } diff --git a/filters/partition/partition.c b/filters/partition/partition.c index a89dbec..a635df8 100644 --- a...
2019 Apr 24
0
[PATCH nbdkit 1/2] server: extents: Set errno on error from nbdkit_add_extent.
errno is currently set to a suitable value if nbdkit_extents_new returns an error, but this was not documented so I added that documentation. Set errno to a suitable value if nbdkit_add_extent returns an error, and also document that. Thanks: Eric Blake for spotting the problem. --- docs/nbdkit-filter.pod | 3 ++- docs/nbdkit-plugin.pod | 2 +- server/extents.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/nbdkit-filter.pod b/docs/nbdkit-filter.po...
2019 Apr 24
1
Re: [PATCH nbdkit 2/2] filters: Be careful to set *err if nbdkit_add_extent or nbdkit_extents_new fail.
.../offset/offset.c > +++ b/filters/offset/offset.c > @@ -156,8 +156,10 @@ offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata, > for (i = 0; i < nbdkit_extents_count (extents2); ++i) { > e = nbdkit_get_extent (extents2, i); > e.offset -= offset; > - if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > + *err = errno; > return -1; > + } > } I'll see if I can spot other places that also need the cleanup, but this patch is incrementally...
2019 Mar 23
2
Re: [PATCH nbdkit 7/8] vddk: Implement extents.
...et * VIXDISKLIB_SECTOR_SIZE; > + length = block_list->blocks[i].length * VIXDISKLIB_SECTOR_SIZE; > + > + /* The query returns blocks. We must insert holes between the > + * blocks as necessary. > + */ > + if (position < offset) { > + if (nbdkit_add_extent (extents, > + offset, length, > + NBDKIT_EXTENT_HOLE | NBDKIT_EXTENT_ZERO) == -1) > + goto error_in_add; > + } > + > + if (nbdkit_add_extent (extents, > + offset, lengt...
2019 Apr 23
1
Re: [nbdkit PATCH 2/4] filters: Utilize CLEANUP_EXTENTS_FREE
..._extents_free (extents2); > + if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1) > return -1; > - } > > for (i = 0; i < nbdkit_extents_count (extents2); ++i) { > struct nbdkit_extent e = nbdkit_get_extent (extents2, i); > > - if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { > - nbdkit_extents_free (extents2); > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) > return -1; > - } Of course, we have to re-add the {} if we fix nbdkit_add_extent() to set reasonable errno so...
2020 Apr 15
0
[PATCH nbdkit 3/9] server: Use new vector library when building the list of extents.
...nt *new_extents; - - new_allocated = exts->allocated; - if (new_allocated == 0) - new_allocated = 1; - new_allocated *= 2; - new_extents = - realloc (exts->extents, new_allocated * sizeof (struct nbdkit_extent)); - if (new_extents == NULL) { - nbdkit_error ("nbdkit_add_extent: realloc: %m"); - return -1; - } - exts->allocated = new_allocated; - exts->extents = new_extents; + if (extents_append (&exts->extents, *e) == -1) { + nbdkit_error ("nbdkit_add_extent: realloc: %m"); + return -1; } - exts->extents[exts-&...
2019 Apr 23
2
Re: [PATCH nbdkit v5 FINAL 14/19] data, memory: Implement extents.
...DKIT_EXTENT_ZERO; > + else { > + if (is_zero (p, n)) > + /* A backing page and it's all zero, it's a zero extent. */ > + type = NBDKIT_EXTENT_ZERO; > + else > + /* Normal allocated data. */ > + type = 0; > + } > + if (nbdkit_add_extent (extents, offset, n, type) == -1) > + return -1; > + ...to here, after the final nbdkit_add_extent, so that we can return a larger extent than the client's request. I remember when I originally asked, you declined due to odd interactions with REQ_ONE semantics, but since then, we...
2019 Mar 27
2
Re: [PATCH nbdkit v4 01/15] server: Implement extents/can_extents calls for plugins and filters.
...virtual > +disk as if it was allocated. > + > +The callback should detect and return the list of extents overlapping > +the range C<[offset...offset+count-1]>. The C<extents> parameter > +points to an opaque object which the callback should fill in by > +calling C<nbdkit_add_extent>. See L</Extents list> below. [1] > + > +If there is an error, C<.extents> should call C<nbdkit_error> with an > +error message, and C<nbdkit_set_error> to record an appropriate error > +(unless C<errno> is sufficient), then return C<-1>. &gt...
2019 Apr 23
1
Re: [PATCH nbdkit v5 FINAL 10/19] offset: Implement mapping of extents.
...t;extents (nxdata, count, offs + offset, > + flags, extents2, err) == -1) > + goto error; And here. > + > + for (i = 0; i < nbdkit_extents_count (extents2); ++i) { > + e = nbdkit_get_extent (extents2, i); > + e.offset -= offset; > + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) > + goto error; But here, *err remains unchanged. Is this a problem? Should nbdkit_add_extent() guarantee that errno is sane on failure (right now, it does not)? Affects several filters. -- Eric Blake, Principal Software Engineer Red Hat,...
2019 Apr 24
2
Re: [PATCH nbdkit v5 FINAL 14/19] data, memory: Implement extents.
On 4/23/19 4:49 PM, Richard W.M. Jones wrote: >> >> ...to here, after the final nbdkit_add_extent, so that we can return a >> larger extent than the client's request. I remember when I originally >> asked, you declined due to odd interactions with REQ_ONE semantics, but >> since then, we changed how add_extent() works. Does it work now to defer >> the clamping? &g...
2019 Mar 20
0
[PATCH nbdkit 1/8] server: Implement extents/can_extents calls for plugins and filters.
...; + struct nbdkit_extent e; + + extents2 = nbdkit_extents_new (offset); + next_ops->extents (nxdata, count, offset, flags, extents2, err); + for (i = 0; i < nbdkit_extents_size (extents2); ++i) { + e = nbdkit_get_extent (extents2, i); + e.offset = /* transform offset */; + nbdkit_add_extent (extents, e.offset, e.length, e.type); + } + nbdkit_extents_free (extents2); + } + +More complicated transformations may require the filter to allocate a +new extents list using C<nbdkit_extents_new> and free the old one +using C<nbdkit_extents_free>. + +If there is an error, C&l...
2019 Mar 27
2
Re: [PATCH nbdkit 7/8] vddk: Implement extents.
...->blocks[i].length * VIXDISKLIB_SECTOR_SIZE; > > > + > > > + /* The query returns blocks. We must insert holes between the > > > + * blocks as necessary. > > > + */ > > > + if (position < offset) { > > > + if (nbdkit_add_extent (extents, > > > + offset, length, > > > + NBDKIT_EXTENT_HOLE | NBDKIT_EXTENT_ZERO) == -1) > > > + goto error_in_add; > > > + } > > > + > > > + if (nbdkit_add_exten...
2019 Apr 23
0
[nbdkit PATCH 2/4] filters: Utilize CLEANUP_EXTENTS_FREE
...*nxdata, } if (next_ops->extents (nxdata, count, offs + offset, flags, extents2, err) == -1) - goto error; + return -1; for (i = 0; i < nbdkit_extents_count (extents2); ++i) { e = nbdkit_get_extent (extents2, i); e.offset -= offset; if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) - goto error; + return -1; } - nbdkit_extents_free (extents2); return 0; - - error: - nbdkit_extents_free (extents2); - return -1; } static struct nbdkit_filter filter = { diff --git a/filters/partition/partition.c b/filters/part...
2020 Aug 10
2
[PATCH nbdkit] python: Allow extents to return any iterable (which includes lists).
...nt32_t count, uint64_t offset, extent_length = PyLong_AsUnsignedLongLong (py_length); extent_type = PyLong_AsUnsignedLong (py_type); if (check_python_failure ("PyLong") == -1) { + Py_DECREF (iter); Py_DECREF (r); return -1; } if (nbdkit_add_extent (extents, extent_offset, extent_length, extent_type) == -1) { + Py_DECREF (iter); Py_DECREF (r); return -1; } } + if (size < 1) { + nbdkit_error ("extents method cannot return an empty list"); + Py_DEC...
2019 Mar 25
0
Re: [PATCH nbdkit 7/8] vddk: Implement extents.
...gt; + length = block_list->blocks[i].length * VIXDISKLIB_SECTOR_SIZE; > > + > > + /* The query returns blocks. We must insert holes between the > > + * blocks as necessary. > > + */ > > + if (position < offset) { > > + if (nbdkit_add_extent (extents, > > + offset, length, > > + NBDKIT_EXTENT_HOLE | NBDKIT_EXTENT_ZERO) == -1) > > + goto error_in_add; > > + } > > + > > + if (nbdkit_add_extent (extents, > > +...
2019 May 15
2
[nbdkit PATCH] extents: Do not shorten overlaps by 0
...out. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- server/extents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/extents.c b/server/extents.c index d3d1a15ab97c..c422491601f0 100644 --- a/server/extents.c +++ b/server/extents.c @@ -168,7 +168,7 @@ nbdkit_add_extent (struct nbdkit_extents *exts, return 0; /* Shorten extents that overlap the end of the range. */ - if (offset + length >= exts->end) { + if (offset + length > exts->end) { overlap = offset + length - exts->end; length -= overlap; } -- 2.21.0
2019 Mar 26
0
[PATCH nbdkit v4 01/15] server: Implement extents/can_extents calls for plugins and filters.
...+ struct nbdkit_extent e; + + extents2 = nbdkit_extents_new (offset + shift); + next_ops->extents (nxdata, count, offset + shift, flags, extents2, err); + for (i = 0; i < nbdkit_extents_count (extents2); ++i) { + e = nbdkit_get_extent (extents2, i); + e.offset -= shift; + nbdkit_add_extent (extents, e.offset, e.length, e.type); + } + nbdkit_extents_free (extents2); + } + +If there is an error, C<.extents> should call C<nbdkit_error> with an +error message B<and> return -1 with C<err> set to the positive errno +value to return to the client. + +=head3 Al...
2019 Mar 28
0
[PATCH nbdkit v5 FINAL 01/19] server: Implement extents/can_extents calls for plugins and filters.
...t_size (nxdata); + extents2 = nbdkit_extents_new (offset + shift, size - shift); + next_ops->extents (nxdata, count, offset + shift, flags, extents2, err); + for (i = 0; i < nbdkit_extents_count (extents2); ++i) { + e = nbdkit_get_extent (extents2, i); + e.offset -= shift; + nbdkit_add_extent (extents, e.offset, e.length, e.type); + } + nbdkit_extents_free (extents2); + } + +If there is an error, C<.extents> should call C<nbdkit_error> with an +error message B<and> return -1 with C<err> set to the positive errno +value to return to the client. + +=head3 Al...
2019 Mar 27
0
Re: [PATCH nbdkit v4 01/15] server: Implement extents/can_extents calls for plugins and filters.
...it was allocated. > > + > > +The callback should detect and return the list of extents overlapping > > +the range C<[offset...offset+count-1]>. The C<extents> parameter > > +points to an opaque object which the callback should fill in by > > +calling C<nbdkit_add_extent>. See L</Extents list> below. > > [1] > > > + > > +If there is an error, C<.extents> should call C<nbdkit_error> with an > > +error message, and C<nbdkit_set_error> to record an appropriate error > > +(unless C<errno> is suffic...