Displaying 20 results from an estimated 244 matches for "can_write".
2019 Aug 30
3
[nbdkit PATCH v2 0/2] caching .can_write
...od exercise, because I really like how it forced me to spend
a good hour on the commit message of patch 1 explaining things, and
how patch 2 then fell out in 10 minutes of hacking to fix the problem
identified in passing in the patch 1 commit message.
Eric Blake (2):
server: Cache per-connection can_write
server: Remember .open(readonly) status
server/internal.h | 5 ++-
server/backend.c | 43 ++++++++++++++++++++-
server/connections.c | 5 ++-
server/filters.c | 6 +--
server/plugins.c | 4 +-
server/protocol-handshake.c | 74 +++++++++++++++...
2019 Jan 30
3
[PATCH nbdkit] xz: Do not pass can_write through to the plugin.
...t.
An alternate way I can think to fix this would be for the core server
to maintain a readonly flag for each layer (instead of just per-
server).
You could also argue that our readonly test in
server/connections.c:compute_eflags is wrong and/or that the
implementations of server/plugins.c:plugin_can_write and
server/filters.c:filter_can_write have the wrong default - they should
consult the readonly flag which was passed to that layer's open call.
However the fix only affects one filter, and we're not maintaining an
API for filters, so maybe we can defer the problem.
Rich.
2018 Dec 14
0
[PATCH nbdkit 3/3] tests: Test export flags (eflags).
...((0 + $(od --endian=big -An -N2 -d < eflags.out)))
+ printf "eflags 0x%04x" $eflags
+ for f in $all_flags; do
+ [ $(( eflags & ${!f} )) -ne 0 ] && echo -n " $f"
+ done
+ echo
+}
+
+fail ()
+{
+ echo "$@"
+ exit 1
+}
+
+# no -r
+# can_write=false
+
+do_nbdkit <<'EOF'
+case "$1" in
+ get_size) echo 1M ;;
+ *) exit 2 ;;
+esac
+EOF
+
+[ $eflags -eq $(( HAS_FLAGS|READ_ONLY )) ] ||
+ fail "expected HAS_FLAGS|READ_ONLY"
+
+# -r
+# can_write=false
+
+do_nbdkit -r <<'EOF'
+case "...
2019 Jan 30
0
[PATCH nbdkit] xz: Do not pass can_write through to the plugin.
...this error:
nbdkit: file[1]: debug: xz: pwrite count=4096 offset=1048576 flags=0x0
nbdkit: file[1]: debug: pwrite count=4096 offset=1048576 fua=0
nbdkit: file[1]: error: pwrite: Bad file descriptor
nbdkit: file[1]: debug: sending error reply: Bad file descriptor
Since the filter did not intercept can_write, it was passed through to
the layer below (the file plugin). The filter opens the file plugin
passing readonly=1, but in the case where there are no filters, nbdkit
core would never call can_write() (assuming that because we opened the
server readonly, it would return false). However with the fil...
2019 Aug 30
0
[nbdkit PATCH v2 2/2] server: Remember .open(readonly) status
The previous patch argued that globally affecting .can_write based on
'-r' (the global 'readonly') prevents the ability for a filter to call
next_open(nxdata, true) to purposefully write to the plugin, even
while advertising .can_write=0 to the client. But it also
demonstrated that when a filter passes false to next_open, we were
still makin...
2019 Nov 22
0
[PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
...plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index 51e0f57..0fd4dcb 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/python/nbdkit-python-plugin.pod
@@ -184,25 +184,25 @@ contents will be garbage collected.
def get_size(h):
# return the size of the disk
-=item C<can_write>
+=item C<is_rotational>
(Optional)
- def can_write(h):
+ def is_rotational(h):
# return a boolean
-=item C<can_flush>
+=item C<can_write>
(Optional)
- def can_flush(h):
+ def can_write(h):
# return a boolean
-=item C<is_rotational>
+=item C<can_f...
2019 Nov 22
1
Re: [PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
...lugin.pod
> index 51e0f57..0fd4dcb 100644
> --- a/plugins/python/nbdkit-python-plugin.pod
> +++ b/plugins/python/nbdkit-python-plugin.pod
> @@ -184,25 +184,25 @@ contents will be garbage collected.
> def get_size(h):
> # return the size of the disk
>
> -=item C<can_write>
> +=item C<is_rotational>
>
> (Optional)
>
> - def can_write(h):
> + def is_rotational(h):
> # return a boolean
>
> -=item C<can_flush>
> +=item C<can_write>
>
> (Optional)
>
> - def can_flush(h):
> + def can...
2011 Feb 28
0
[LLVMdev] [PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix
Hi - the attached patch provides implementations and tests for sys::fs::can_read() and sys::fs::can_write() for Unix. These were adapted from the previous implementations in lib/Support/Unix/Path.inc. can_execute() could be implemented quite similarly, but I wasn't sure where the best place to add a test for it would be, so left it out for now.
Thanks,
Liam
-------------- next part --------------...
2018 Dec 15
5
[PATCH nbdkit v2 0/4] tests: Test export flags (eflags).
v1 was here:
https://www.redhat.com/archives/libguestfs/2018-December/thread.html#00123
v2:
- Document "-" instead of "script=-" and use it in the test; and
verify this also works on FreeBSD; and verify that it doesn't
depend on the particular behaviour of our wrapper script and should
work with installed nbdkit too.
- Fix handling of zero flags parameter.
-
2020 Sep 21
0
[nbdkit PATCH v3 06/14] api: Add .export_description
...const char *export_description (struct nbdkit_next_ops *next_ops,
+ void *nxdata, void *handle);
+
+This intercepts the plugin C<.export_description> method and can be
+used to read or modify the export description that the NBD client
+will see.
+
=head2 C<.can_write>
=head2 C<.can_flush>
diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod
index f1476032..62feae47 100644
--- a/docs/nbdkit-plugin.pod
+++ b/docs/nbdkit-plugin.pod
@@ -825,6 +825,26 @@ to get the size (in bytes) of the block device being exported.
The returned size must be E<...
2018 Dec 14
6
[PATCH nbdkit 0/3] tests: Test export flags (eflags).
Some feature additions to the shell script plugin allow us to test the
export flags field reasonably easily.
Rich.
2018 Sep 10
1
question on nbdkit sh plugin
In the just-added nbdkit-sh-plugin.pod, you documented that unlike other
plugins (where introspection or struct member population) can be used to
determine which functionalities are supported, the shell plugin has to
implement can_write and friends to return a special status 2 to document
not supported, and 3 to indicate false, in part because you can't detect
if a pwrite function is present without running it.
But since pwrite normally takes additional parameters, could we instead
document that nbdkit calling '/path/t...
2019 Oct 07
6
[nbdkit PATCH 0/5] More retry fixes
I think this is my last round of patches for issues I identified with
the retry filter. With this in place, it should be safe to interject
another filter in between retry and the plugin.
Eric Blake (5):
retry: Don't call into closed plugin
tests: Refactor test-retry-reopen-fail.sh
tests: Enhance retry test to cover failed reopen
server: Move prepare/finalize/close recursion to
2019 Oct 07
0
[nbdkit PATCH 5/5] server: Ensure .finalize and .close are called as needed
...ssed, so .close is needed */
+ HANDLE_CONNECTED = 2, /* Set if .prepare passed, so .finalize is needed */
+ HANDLE_FAILED = 4, /* Set if .finalize failed */
+};
+
struct b_conn_handle {
void *handle;
+ unsigned char state; /* Bitmask of HANDLE_* values */
+
uint64_t exportsize;
int can_write;
int can_flush;
@@ -173,6 +181,7 @@ static inline void
reset_b_conn_handle (struct b_conn_handle *h)
{
h->handle = NULL;
+ h->state = 0;
h->exportsize = -1;
h->can_write = -1;
h->can_flush = -1;
diff --git a/server/backend.c b/server/backend.c
index 702c9b96..bdc5bb...
2019 Sep 19
1
Re: [PATCH nbdkit 2/2] Add new retry filter.
...ckend_reopen (struct backend *b, struct connection *conn, int readonly)
> {
> + struct b_conn_handle *h = &conn->handles[b->i];
> +
> debug ("%s: reopen", b->name);
>
> b->close (b, conn);
> +
> + /* This forces .open to recalculate h->can_write, which might have
> + * changed since we may have a new readonly value.
> + */
> + h->can_write = -1;
> +
> return backend_open (b, conn, readonly);
> }
Obviously this hunk should be in the first patch ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat http:...
2019 Aug 30
0
[nbdkit PATCH 6/9] server: Cache per-connection can_FOO flags
...to the plugin more than once per connection on any of the
flag determination callbacks.
The following script demonstrates the speedup, where we avoid repeated
calls into a slow can_fua. Pre-patch:
$ cat script
case "$1" in
get_size) echo 1m;;
can_fua) sleep 1; echo native;;
can_write | can_zero | pwrite | zero) ;;
*) exit 2 ;;
esac
$ /bin/time -f %e ./nbdkit --filter=blocksize sh script maxlen=4k \
--run 'qemu-io -f raw -c "w -z -f 0 16k" $nbd'
wrote 16384/16384 bytes at offset 0
16 KiB, 1 ops; 0:00:05.07 (3.157 KiB/sec and 0.1973 ops/sec)
6.14
there ar...
2020 Mar 17
1
Re: [nbdkit PATCH 1/4] server: Normalize plugin can_* values
On Mon, Mar 16, 2020 at 10:36:14PM -0500, Eric Blake wrote:
> The documentation for .can_write and friends mentioned merely that the
> callback must return a boolean value, or -1 on failure. Historically,
> we have treated any non-zero value other than -1 as true, and some
> plugins have sloppily relied on this behavior, including the
> standalone nbd plugin prior to the use of...
2018 Jan 19
1
Re: [nbdkit PATCH] Update filters to support FUA flags.
On Fri, Jan 19, 2018 at 10:45:51AM -0600, Eric Blake wrote:
> I'm wondering if we're missing documentation here (and/or in the plugins
> document) that if .can_write returns true, the plugin must supply a
> .pwrite; likewise for .can_trim implying a .trim, and .can_flush
> implying a .flush.
It's a strange one.
For example if a plugin returns .can_pwrite == 1 but doesn't implement
.pwrite then the NBD connection will appear to be writable, but a...
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 Aug 23
2
[nbdkit PATCH 3/3] plugins: Add .can_fast_zero hook
...&buf, &len);
+
+ if (flags & NBDKIT_FLAG_FAST_ZERO)
+ flag_append("fast", &comma, &buf, &len);
}
static void
@@ -536,7 +539,7 @@ sh_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
/* Common code for handling all boolean methods like can_write etc. */
static int
-boolean_method (void *handle, const char *method_name)
+boolean_method (void *handle, const char *method_name, int def)
{
char *h = handle;
const char *args[] = { script, method_name, h, NULL };
@@ -546,8 +549,8 @@ boolean_method (void *handle, const char *method_name)...