Adjust internal functions in preparation for FUA support; although
at this point, the default plugins.c can_fua implementation
correctly reports python as needing emulation, and we can assert
that we aren't seeing a FUA flag.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
plugins/python/python.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index aa09dce7..1954881c 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -46,6 +46,8 @@
#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
+#define NBDKIT_API_VERSION 2
+
#include <nbdkit-plugin.h>
#include "cleanup.h"
@@ -477,7 +479,7 @@ py_get_size (void *handle)
static int
py_pread (void *handle, void *buf,
- uint32_t count, uint64_t offset)
+ uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -485,6 +487,7 @@ py_pread (void *handle, void *buf,
Py_buffer view = {0};
int ret = -1;
+ assert (!flags);
if (!callback_defined ("pread", &fn)) {
nbdkit_error ("%s: missing callback: %s", script, "pread");
return ret;
@@ -523,12 +526,13 @@ out:
static int
py_pwrite (void *handle, const void *buf,
- uint32_t count, uint64_t offset)
+ uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
@@ -549,12 +553,13 @@ py_pwrite (void *handle, const void *buf,
}
static 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 ();
@@ -573,12 +578,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 ();
@@ -597,14 +603,16 @@ 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)
+py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *args;
PyObject *kwargs;
PyObject *r;
+ int may_trim = (flags & NBDKIT_FLAG_MAY_TRIM) != 0;
+ assert (!(flags & ~NBDKIT_FLAG_MAY_TRIM));
if (callback_defined ("zero", &fn)) {
static int zero_may_trim = -1;
--
2.21.0