We document that a plugin callback should return 0 on success, but
other places in the code treat all values other than -1 as success
(perhaps we should treat all negative values as errors, instead of
exactly -1, but that may break binary back-compatibility). However,
when reworking where FUA fallback occurs, we introduced a subtle
change: if a plugin returns a positive value on success, and the
client requested FUA, we ended up reporting success to the client
without performing FUA.
Fixes: 4f37c64ffdd42fab5c5d9c6157db396b60866a7a
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/plugins.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/plugins.c b/src/plugins.c
index 699e9c5..1b0816c 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -412,7 +412,7 @@ plugin_pwrite (struct backend *b, struct connection *conn,
errno = EROFS;
return -1;
}
- if (r == 0 && fua) {
+ if (r != -1 && fua) {
assert (p->plugin.flush);
r = plugin_flush (b, conn, 0);
}
@@ -439,7 +439,7 @@ plugin_trim (struct backend *b, struct connection *conn,
errno = EINVAL;
return -1;
}
- if (r == 0 && fua) {
+ if (r != -1 && fua) {
assert (p->plugin.flush);
r = plugin_flush (b, conn, 0);
}
@@ -503,7 +503,7 @@ plugin_zero (struct backend *b, struct connection *conn,
errno = err;
done:
- if (!result && fua) {
+ if (result != -1 && fua) {
assert (p->plugin.flush);
result = plugin_flush (b, conn, 0);
}
--
2.14.3