Displaying 5 results from an estimated 5 matches for "subtract_offset".
2019 Mar 19
0
[PATCH nbdkit 5/9] offset: Implement mapping of extents.
...de <stdint.h>
#include <string.h>
+#include <assert.h>
#include <nbdkit-filter.h>
@@ -132,6 +133,47 @@ offset_zero (struct nbdkit_next_ops *next_ops, void *nxdata,
return next_ops->zero (nxdata, count, offs + offset, flags, err);
}
+/* Extents. */
+static int
+subtract_offset (uint64_t offs, uint64_t length, uint32_t type,
+ void *vp)
+{
+ struct nbdkit_extents_map *extents_map = vp;
+
+ assert (offs >= offset);
+ offs -= offset;
+ return nbdkit_extent_add (extents_map, offs, length, type);
+}
+
+static int
+offset_extents (struct nbdkit_next_ops...
2019 Mar 20
2
New extents structure proposal
I think the extents map is just too complicated and is unnecessarily
so. How about instead we define the plugin interface to be:
int can_extents (void *handle); // as before
int extents (void *handle, uint32_t count, uint64_t offset, uint32_t flags,
struct nbdkit_extents_list *list);
and have the extents_list be a simple list. The first extent you add
must start at offset.
2019 Mar 20
0
Re: New extents structure proposal
...ap2 == NULL)
+ return -1;
+ if (next_ops->extents (nxdata, count, offs + offset,
+ flags, map2, err) == -1) {
+ nbdkit_extents_free (map2);
+ return -1;
+ }
+
+ /* Transform offsets in map2, return result in extents_map. */
+ if (nbdkit_extents_foreach (map2, subtract_offset, extents_map,
+ NBDKIT_EXTENTS_FOREACH_FLAG_RANGE,
+ offset, range) == -1) {
+ nbdkit_extents_free (map2);
+ return -1;
+ }
+ nbdkit_extents_free (map2);
because the plugin was calling:
+ if (nbdkit_extent_add (extents_map, offs...
2019 Mar 20
2
Re: New extents structure proposal
...(next_ops->extents (nxdata, count, offs + offset,
> + flags, map2, err) == -1) {
> + nbdkit_extents_free (map2);
> + return -1;
> + }
> +
> + /* Transform offsets in map2, return result in extents_map. */
> + if (nbdkit_extents_foreach (map2, subtract_offset, extents_map,
> + NBDKIT_EXTENTS_FOREACH_FLAG_RANGE,
> + offset, range) == -1) {
> + nbdkit_extents_free (map2);
> + return -1;
> + }
> + nbdkit_extents_free (map2);
>
> because the plugin was calling:
>...
2019 Mar 19
15
[PATCH nbdkit 0/9] [mainly for discussion and early review] Implement extents.
I want to post this but mainly for discussion and early review. It's
not safe for these patches to all go upstream yet (because not all
filters have been checked/adjusted), but if any patches were to go
upstream then probably 1 & 2 only are safe.
File, VDDK, memory and data plugins all work, although I have only
done minimal testing on them.
The current tests, such as they are, all