Displaying 15 results from an estimated 15 matches for "flag_may_trim".
2019 Nov 22
2
Re: [PATCH nbdkit v2 02/10] python: Add various constants to the API.
On Fri, Nov 22, 2019 at 9:54 PM Richard W.M. Jones <rjones@redhat.com> wrote:
>
> These are accessible from the plugin by:
>
> import nbdkit
>
> if flags & nbdkit.FLAG_MAY_TRIM:
> &c.
Nice way to expose the flags!
> Many (all?) of these are not yet useful for plugins, some will never
> be useful, but they only consume a tiny bit of memory and it's nice to
> have the complete set available for future use.
> ---
> plugins/python/python.c | 27...
2019 Nov 22
1
Re: [PATCH nbdkit v2 02/10] python: Add various constants to the API.
...0:05:15PM +0200, Nir Soffer wrote:
> > On Fri, Nov 22, 2019 at 9:54 PM Richard W.M. Jones <rjones@redhat.com> wrote:
> > >
> > > These are accessible from the plugin by:
> > >
> > > import nbdkit
> > >
> > > if flags & nbdkit.FLAG_MAY_TRIM:
> > > &c.
> >
> > Nice way to expose the flags!
> >
> > > Many (all?) of these are not yet useful for plugins, some will never
> > > be useful, but they only consume a tiny bit of memory and it's nice to
> > > have the complete set av...
2019 Nov 22
0
[PATCH nbdkit v2 02/10] python: Add various constants to the API.
These are accessible from the plugin by:
import nbdkit
if flags & nbdkit.FLAG_MAY_TRIM:
&c.
Many (all?) of these are not yet useful for plugins, some will never
be useful, but they only consume a tiny bit of memory and it's nice to
have the complete set available for future use.
---
plugins/python/python.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)...
2019 Nov 22
0
Re: [PATCH nbdkit v2 02/10] python: Add various constants to the API.
On Fri, Nov 22, 2019 at 10:05:15PM +0200, Nir Soffer wrote:
> On Fri, Nov 22, 2019 at 9:54 PM Richard W.M. Jones <rjones@redhat.com> wrote:
> >
> > These are accessible from the plugin by:
> >
> > import nbdkit
> >
> > if flags & nbdkit.FLAG_MAY_TRIM:
> > &c.
>
> Nice way to expose the flags!
>
> > Many (all?) of these are not yet useful for plugins, some will never
> > be useful, but they only consume a tiny bit of memory and it's nice to
> > have the complete set available for future use.
> >...
2019 Nov 21
10
[PATCH nbdkit 0/8] Implement nbdkit API v2 for Python plugins.
And fill out most of the missing bits of the API.
Rich.
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...t:offset+count]
-def pwrite(h, buf, offset):
+def pwrite(h, buf, offset, flags):
global disk
end = offset + len(buf)
disk[offset:end] = buf
-def zero(h, count, offset, may_trim):
+def zero(h, count, offset, flags):
global disk
- if may_trim:
+ if flags & nbdkit.FLAG_MAY_TRIM:
disk[offset:offset+count] = bytearray(count)
else:
nbdkit.set_error(errno.EOPNOTSUPP)
diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index 6453474..882c0d8 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/pyth...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...t:offset+count]
-def pwrite(h, buf, offset):
+def pwrite(h, buf, offset, flags):
global disk
end = offset + len(buf)
disk[offset:end] = buf
-def zero(h, count, offset, may_trim):
+def zero(h, count, offset, flags):
global disk
- if may_trim:
+ if flags & nbdkit.FLAG_MAY_TRIM:
disk[offset:offset+count] = bytearray(count)
else:
nbdkit.set_error(errno.EOPNOTSUPP)
diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index e089bc9..f393e8f 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/pyth...
2019 Nov 25
7
[PATCH nbdkit v2 0/7] Implement nbdkit API v2 for Python plugins.
v3 was here:
https://www.redhat.com/archives/libguestfs/2019-November/msg00209.html
In v4:
- Rebase on top of current master. Includes various fixes and
updates required because of Nir's patches that went into master.
- Fix api_version() -> API_VERSION in patch 2 noted previously on the
mailing list.
Rich.
2019 Nov 23
8
[PATCH nbdkit v3 0/7] Implement nbdkit API v2 for Python plugins.
v2 was here:
https://www.redhat.com/archives/libguestfs/2019-November/msg00163.html
I pushed patch 1 (with spelling fix), patch 4 and patch 5 since those
were previously ACKed on the list.
Differences in v3:
- Add error checking to PyModule_AddIntConstant.
- Use API_VERSION constant instead of function.
- Add max API version supported to --dump-plugin output.
- Print API_VERSION selected by
2019 Nov 22
18
[PATCH nbdkit v2 00/10] Implement nbdkit API v2 for Python plugins.
v1:
https://www.redhat.com/archives/libguestfs/2019-November/msg00153.html
v2:
- Fix implementation of can_cache.
- Add implementation of can_fua.
- Add a very thorough test suite which tests every command + flag
combination.
2019 Nov 22
0
[PATCH nbdkit v2 06/10] python: Implement cache.
...it a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index 0fd4dcb..ee58cd7 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/python/nbdkit-python-plugin.pod
@@ -293,6 +293,19 @@ because there is nothing to optimize if
S<C<flags & nbdkit.FLAG_MAY_TRIM>> is false), use
S<C<nbdkit.set_error (errno.EOPNOTSUPP)>>.
+=item C<cache>
+
+(Optional)
+
+ def cache(h, count, offset, flags):
+ # no return value
+
+The body of your C<cache> function should prefetch data in the
+indicated range.
+
+If the cache operation fail...
2019 Nov 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...13 @@ contents will be garbage collected.
def can_trim(h):
# return a boolean
+=item C<can_cache>
+
+(Optional)
+
+ def can_cache(h):
+ # return a boolean
+
=item C<pread>
(Required)
@@ -293,6 +300,19 @@ because there is nothing to optimize if
S<C<flags & nbdkit.FLAG_MAY_TRIM>> is false), use
S<C<nbdkit.set_error (errno.EOPNOTSUPP)>>.
+=item C<cache>
+
+(Optional)
+
+ def cache(h, count, offset, flags):
+ # no return value
+
+The body of your C<cache> function should prefetch data in the
+indicated range.
+
+If the cache operation fail...
2019 Nov 22
0
[PATCH nbdkit v2 10/10] tests: Test the Python plugin thoroughly.
...ero(h, count, offset, flags):
+ expect_fua = cfg.get ('zero_expect_fua', False)
+ actual_fua = bool (flags & nbdkit.FLAG_FUA)
+ assert expect_fua == actual_fua
+ expect_may_trim = cfg.get ('zero_expect_may_trim', False)
+ actual_may_trim = bool (flags & nbdkit.FLAG_MAY_TRIM)
+ assert expect_may_trim == actual_may_trim
+ expect_fast_zero = cfg.get ('zero_expect_fast_zero', False)
+ actual_fast_zero = bool (flags & nbdkit.FLAG_FAST_ZERO)
+ assert expect_fast_zero == actual_fast_zero
+ h['disk'][offset:offset+count] = bytearray(count)
+...
2019 Nov 22
3
Re: [PATCH nbdkit v2 10/10] tests: Test the Python plugin thoroughly.
...gs):
> + expect_fua = cfg.get ('zero_expect_fua', False)
> + actual_fua = bool (flags & nbdkit.FLAG_FUA)
> + assert expect_fua == actual_fua
> + expect_may_trim = cfg.get ('zero_expect_may_trim', False)
> + actual_may_trim = bool (flags & nbdkit.FLAG_MAY_TRIM)
> + assert expect_may_trim == actual_may_trim
> + expect_fast_zero = cfg.get ('zero_expect_fast_zero', False)
> + actual_fast_zero = bool (flags & nbdkit.FLAG_FAST_ZERO)
> + assert expect_fast_zero == actual_fast_zero
> + h['disk'][offset:offset+co...
2019 Nov 22
8
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...ion may be optimized as a trim as long
> -as subsequent reads see zeroes.
> +The body of your C<zero> function should ensure that C<count> bytes of
> +the disk, starting at C<offset>, will read back as zero. C<flags> is
> +a bitmask which may include C<nbdkit.FLAG_MAY_TRIM>,
> +C<nbdkit.FLAG_FUA>, C<nbdkit.FLAG_FAST_ZERO>.
Well, technically FAST_ZERO can't be set until later in the series when
you plumb in the can_fast_zero callback... :)
> static int
> -py_pwrite (void *handle, const void *buf,
> - uint32_t count, uint6...