Displaying 20 results from an estimated 32 matches for "py_trim".
Did you mean:
may_trim
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...atic int
-py_flush (void *handle)
+py_flush (void *handle, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (callback_defined ("flush", &fn)) {
PyErr_Clear ();
@@ -519,12 +523,13 @@ py_flush (void *handle)
}
static int
-py_trim (void *handle, uint32_t count, uint64_t offset)
+py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (callback_defined ("trim", &fn)) {
PyErr_Clear ();
@@ -543,14 +548,1...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...Err_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
Py_DECREF (fn);
if (check_python_failure ("flush") == -1)
return -1;
@@ -584,7 +599,7 @@ py_flush (void *handle, uint32_t flags)
static int
py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *args;
PyObject *kwargs;
@@ -596,7 +611,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
if (callback_defined (&quo...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...break;
+ case 2:
+ r = PyObject_CallFunction (fn, "OI", obj, flags, NULL);
+ break;
+ default: abort ();
+ }
Py_DECREF (fn);
if (check_python_failure ("flush") == -1)
return -1;
@@ -556,7 +605,7 @@ py_flush (void *handle)
}
static int
-py_trim (void *handle, uint32_t count, uint64_t offset)
+py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -565,7 +614,15 @@ py_trim (void *handle, uint32_t count, uint64_t offset)
if (callback_defined ("trim", &fn)) {...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...break;
+ case 2:
+ r = PyObject_CallFunction (fn, "OI", obj, flags, NULL);
+ break;
+ default: abort ();
+ }
Py_DECREF (fn);
if (check_python_failure ("flush") == -1)
return -1;
@@ -566,7 +629,7 @@ py_flush (void *handle)
}
static int
-py_trim (void *handle, uint32_t count, uint64_t offset)
+py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -575,7 +638,15 @@ py_trim (void *handle, uint32_t count, uint64_t offset)
if (callback_defined ("trim", &fn)) {...
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for
reference, I added 'zero' support for python, perl, and ruby
back in 1.1.13, then Rich had to add it for ocaml in 1.1.20).
I tested this heavily under python 2, but for now only compile
tested under python 3; I plan to do further testing there and
make any tweaks if necessary.
I wrote patch 5 early on, but then realized I
2017 Jan 26
0
[nbdkit PATCH v2 6/6] python: Support zero callback
...or;
+
static PyObject *
set_error (PyObject *self, PyObject *args)
{
@@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &err))
return NULL;
nbdkit_set_error (err);
+ last_error = err;
Py_RETURN_NONE;
}
@@ -441,6 +444,48 @@ py_trim (void *handle, uint32_t count, uint64_t offset)
}
static int
+py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
+{
+ PyObject *obj = handle;
+ PyObject *fn;
+ PyObject *args;
+ PyObject *r;
+
+ if (callback_defined ("zero", &fn)) {
+ PyErr_Clear ();
+
+...
2017 Jan 27
0
[nbdkit PATCH v3 4/4] python: Support zero callback
...or;
+
static PyObject *
set_error (PyObject *self, PyObject *args)
{
@@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &err))
return NULL;
nbdkit_set_error (err);
+ last_error = err;
Py_RETURN_NONE;
}
@@ -441,6 +444,48 @@ py_trim (void *handle, uint32_t count, uint64_t offset)
}
static int
+py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
+{
+ PyObject *obj = handle;
+ PyObject *fn;
+ PyObject *args;
+ PyObject *r;
+
+ if (callback_defined ("zero", &fn)) {
+ PyErr_Clear ();
+
+...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...llFunctionObjArgs (fn, obj, NULL);
> + r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
> Py_DECREF (fn);
> if (check_python_failure ("flush") == -1)
> return -1;
> @@ -584,7 +599,7 @@ py_flush (void *handle, uint32_t flags)
> static int
> py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *args;
> PyObject *kwargs;
> @@ -596,7 +611,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t f...
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 25
6
[nbdkit PATCH 0/5] Counterproposal for python v2 interfaces
As mentioned in my reviews, I wonder if we should make our python
callbacks look a bit more Pythonic by having kwargs added for each
new flag that we want to expose. The idea was first floated here:
https://www.redhat.com/archives/libguestfs/2018-April/msg00108.html
Note that with my proposal, there is no need for a python script to
expose a global API_VERSION variable; new flags are added
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...y_can_zero,
+ .can_fast_zero = py_can_fast_zero,
+ .can_fua = py_can_fua,
+ .can_cache = py_can_cache,
+ .can_extents = py_can_extents,
- .pread = py_pread,
- .pwrite = py_pwrite,
- .flush = py_flush,
- .trim = py_trim,
- .zero = py_zero,
- .cache = py_cache,
- .extents = py_extents,
+ .pread = py_pread,
+ .pwrite = py_pwrite,
+ .flush = py_flush,
+ .trim = py_trim,
+ .zero = py_zero,
+ .cache...
2019 Nov 22
0
[PATCH nbdkit v2 06/10] python: Implement cache.
..."%s not implemented", "cache");
+ return -1;
+ }
+
+ return 0;
+}
+
static int
boolean_callback (void *handle, const char *can_fn, const char *plain_fn)
{
@@ -768,6 +801,7 @@ static struct nbdkit_plugin plugin = {
.flush = py_flush,
.trim = py_trim,
.zero = py_zero,
+ .cache = py_cache,
};
NBDKIT_REGISTER_PLUGIN (plugin)
--
2.23.0
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 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...t_plugin plugin = {
.can_write = py_can_write,
.can_flush = py_can_flush,
.can_trim = py_can_trim,
+ .can_cache = py_can_cache,
.pread = py_pread,
.pwrite = py_pwrite,
.flush = py_flush,
.trim = py_trim,
.zero = py_zero,
+ .cache = py_cache,
};
NBDKIT_REGISTER_PLUGIN (plugin)
--
2.23.0
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
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...Py_DECREF (kwargs);
if (check_python_failure ("pwrite") == -1)
return -1;
Py_DECREF (r);
@@ -494,7 +553,7 @@ py_pwrite (void *handle, const void *buf,
return -1;
}
- return 0;
+ return need_flush ? py_flush (handle, 0) : 0;
}
static int
@@ -527,14 +586,42 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
+ PyObject *args;
+ PyObject *kwargs;
PyObject *r;
+ int fua = (flags & NBDKIT_FLAG_FUA) != 0;
+ int need_flush = fua && !trim_has_fua;
- assert (!flags);
+ assert (!...
2017 Jan 26
10
[nbdkit PATCH v2 0/6] bind .zero to Python
Fix some things I noticed while reviewing v1, and follow Rich's
idea to add a new nbdkit_set_error() utility function with a
binding for Python users to request a particular error (rather
than being forced to live with whatever stale value is in errno
after all the intermediate binding glue code).
I could not easily find out how to register a C function callable
from perl bindings, and have
2017 Jan 24
4
[nbdkit PATCH 0/2] bind .zero to more languages
Begin the language binding followups to my new .zero callback, since
Rich was indeed correct that we want them.
I'm more familiar with python and perl (at least to the point that
I was able to modify the appropriate example files and prove to
myself that the bindings worked), so I've started with those.
I'm less familiar with ruby and ocaml, so I've left those for
tomorrow (it
2020 Aug 05
5
[PATCH nbdkit 3/4] python: Allow thread model to be set from Python plugins.
This is working for me now, although possibly only on Python 3.9.
Dan suggested PyEval_InitThreads but that was deprecated in
Python 3.7.
Rich.
2020 Mar 19
5
[nbdkit PATCH 0/2] More caching of initial setup
When I added .can_FOO caching in 1.16, I missed the case that the sh
plugin itself was calling .can_flush twice in some situations (in
order to default .can_fua). Then right after, I regressed it to call
.can_zero twice (in order to default .can_fast_zero). I also missed
that .thread_model could use better caching, because at the time, I
did not add testsuite coverage. Fix that now.
Eric Blake