Displaying 18 results from an estimated 18 matches for "block_device_size".
2019 Mar 20
0
[PATCH nbdkit 8/8] file: Implement extents.
...READ_MUTEX_INITIALIZER;
+
+/* to enable: -D file.zero=1 */
+int file_debug_zero;
static void
file_unload (void)
@@ -220,6 +227,21 @@ file_close (void *handle)
#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
+/* For block devices, stat->st_size is not the true size. */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek (to find device size): %m");
+ return -1;
+ }
+
+ return size;
+}
+
/* Get the file size. */
static int64_t
file_get_size (void *handle)
@@ -227,15 +249,11 @@ file_get_si...
2019 Mar 23
1
Re: [PATCH nbdkit 8/8] file: Implement extents.
...*/
> +int file_debug_zero;
>
> static void
> file_unload (void)
> @@ -220,6 +227,21 @@ file_close (void *handle)
>
> #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
>
> +/* For block devices, stat->st_size is not the true size. */
> +static int64_t
> +block_device_size (int fd)
> +{
> + off_t size;
> +
> + size = lseek (fd, 0, SEEK_END);
Calling lseek without the lock? I'm not sure if you can guarantee that
.size won't be called in parallel with some other .extents.
/me reads ahead
Oh, the caller has the lock. I might add a comment to this...
2020 Apr 08
2
[PATCH nbdkit v3] tmpdisk: Generalize the tmpdisk plugin.
v2 was here:
https://www.redhat.com/archives/libguestfs/2020-April/msg00075.html
In v3:
- Add [VAR=VALUE ...] to manual.
- Various minor improvements to the manual.
- Work (at least, in theory - not tested) with block devices or
symlinks. I didn't document this because it's hard to ensure these
files or block devices would be cleaned up, so here be dragons.
- Remove O_NOCTTY.
-
2019 Mar 28
0
[PATCH nbdkit v5 FINAL 15/19] file: Implement extents.
...-D file.zero=1 */
+int file_debug_zero;
static void
file_unload (void)
@@ -220,6 +227,23 @@ file_close (void *handle)
#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
+/* For block devices, stat->st_size is not the true size. The caller
+ * grabs the lseek_lock.
+ */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek (to find device size): %m");
+ return -1;
+ }
+
+ return size;
+}
+
/* Get the file size. */
static int64_t
file_get_size (void *handle)
@@ -227,15 +251,11 @@ file_get_si...
2020 Apr 09
0
[PATCH nbdkit v2 3/3] tmpdisk: Implement this plugin using fileops.
...return h->size;
-}
-
/* This creates and runs the full "mkfs" (or whatever) command. */
static int
run_command (const char *disk)
@@ -263,37 +230,18 @@ run_command (const char *disk)
return 0;
}
-/* For block devices, stat->st_size is not the true size. */
-static int64_t
-block_device_size (int fd)
-{
- off_t size;
-
- size = lseek (fd, 0, SEEK_END);
- if (size == -1) {
- nbdkit_error ("lseek: %m");
- return -1;
- }
-
- return size;
-}
-
static void *
tmpdisk_open (int readonly)
{
- struct handle *h;
+ struct fileops *fops;
CLEANUP_FREE char *dir = NULL,...
2019 Apr 23
0
[nbdkit PATCH 4/4] plugins: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE
...<nbdkit-plugin.h>
+#include "cleanup.h"
#include "isaligned.h"
#ifndef O_CLOEXEC
@@ -250,12 +251,8 @@ file_get_size (void *handle)
struct handle *h = handle;
if (h->is_block_device) {
- int64_t size;
-
- pthread_mutex_lock (&lseek_lock);
- size = block_device_size (h->fd);
- pthread_mutex_unlock (&lseek_lock);
- return size;
+ ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lseek_lock);
+ return block_device_size (h->fd);
} else {
/* Regular file. */
struct stat statbuf;
@@ -607,13 +604,8 @@ static int
file_extents (void *handle, uin...
2020 Apr 09
6
[PATCH nbdkit v2 0/3] Implement fileops.
Needs some work still, see in particular the commit message
for patch 3.
Rich.
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...ops->can_fallocate = true;
+ fops->can_zeroout = fops->is_block_device;
+
+ return 0;
+}
+
+void
+close_fileops (struct fileops *fops)
+{
+ close (fops->fd);
+}
+
+/* For block devices, stat->st_size is not the true size. The caller
+ * grabs the lseek_lock.
+ */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek (to find device size): %m");
+ return -1;
+ }
+
+ return size;
+}
+
+/* Get the file size. */
+int64_t
+fileops_get_size (void *handle)
+{
+ struct fileops *fops = handle;...
2020 Apr 09
1
[PATCH nbdkit PRELIMINARY] file: Move file operators to a new fileops mini-library
There's a lot of code in nbdkit-file-plugin which it would be nice to
reuse elsewhere. One possible approach (as outlined here) is simply
to move the file callbacks (like file.pread, file.pwrite, file.zero
etc) to a new mini-library. They can then be consumed by other
plugins fairly easily by doing:
static void *
foo_open (int readonly)
{
struct fileops *fops;
int fd, flags;
/*
2020 Aug 07
0
[nbdkit PATCH 2/4] file: Add .list_exports support
...+ free (h->file);
close (h->fd);
free (h);
}
@@ -239,7 +323,7 @@ file_close (void *handle)
#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
/* For block devices, stat->st_size is not the true size. The caller
- * grabs the lseek_lock.
+ * grabs the lock.
*/
static int64_t
block_device_size (int fd)
@@ -262,7 +346,7 @@ file_get_size (void *handle)
struct handle *h = handle;
if (h->is_block_device) {
- ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lseek_lock);
+ ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock);
return block_device_size (h->fd);
} else {
/* Regular file...
2020 Apr 08
0
[PATCH nbdkit v3] tmpdisk: Pass any parameters as shell variables to the command.
...c ('\n', fp);
- putc ('\n', fp);
+ /* The command. */
fprintf (fp, "%s", command);
if (fclose (fp) == EOF) {
@@ -216,11 +263,28 @@ run_command (const char *disk)
return 0;
}
+/* For block devices, stat->st_size is not the true size. */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek: %m");
+ return -1;
+ }
+
+ return size;
+}
+
static void *
tmpdisk_open (int readonly)
{
struct handle *h;
- CLEANUP_FREE char *disk = NULL;
+ CLEANUP_FREE char *di...
2019 Apr 23
8
[nbdkit PATCH 0/4] Start using cleanup macros in filters/plugins
There's more that can be done (in particular, use of CLEANUP_FREE),
but this is enough to at least see if I'm on the right track.
I couldn't figure out an obvious difference between common/include and
common/utils, but it looks like the former is for things that are
inlineable via .h only, while the latter is when you need to link in
a convenience library, so this landed in the
2020 Aug 14
2
[PATCH nbdkit] New ondemand plugin.
...command killed by signal %d", WTERMSIG (r));
+ return -1;
+ }
+ else if (WIFSTOPPED (r)) {
+ nbdkit_error ("command stopped by signal %d", WSTOPSIG (r));
+ return -1;
+ }
+
+ return 0;
+}
+
+/* For block devices, stat->st_size is not the true size. */
+static int64_t
+block_device_size (int fd)
+{
+ off_t size;
+
+ size = lseek (fd, 0, SEEK_END);
+ if (size == -1) {
+ nbdkit_error ("lseek: %m");
+ return -1;
+ }
+
+ return size;
+}
+
+static void *
+ondemand_open (int readonly)
+{
+ struct handle *h;
+ CLEANUP_FREE char *disk = NULL;
+ int flags, err;
+ s...
2019 Mar 20
15
[PATCH nbdkit 0/8] Implement extents using a simpler array.
Not sure what version we're up to, but this reimplements extents using
the new simpler structure described in this thread:
https://www.redhat.com/archives/libguestfs/2019-March/msg00077.html
I also fixed most of the things that Eric pointed out in the previous
review, although I need to go back over his replies and check I've got
everything.
This needs a bit more testing. However the
2020 Aug 07
8
[nbdkit PATCH 0/4] More .list_exports uses
Here's changes to the file plugin (which I'm happy with) and a new
exportname filter (which is still at RFC stage; I need to finish
implementing strict mode in .open, and add tests).
I also discovered that we really want .list_exports and .open to know
when they are used on plaintext vs. tls clients for --tls=on, and we
may want to split out a new .default_export callback rather than
2019 Mar 26
21
[PATCH nbdkit v4 00/15] Implement Block Status.
I'm not sure exactly which version we're up to, but let's say it's
version 4.
I'm a lot happier with this version:
- all filters have been reviewed and changed where I think that's necessary
- can_extents is properly defined and implemented now
- NBD protocol is followed
- I believe it addresses all previous review points where possible
The "only" thing
2019 Mar 19
15
[PATCH nbdkit 0/9] [mainly for discussion and early review] Implement extents.
I want to post this but mainly for discussion and early review. It's
not safe for these patches to all go upstream yet (because not all
filters have been checked/adjusted), but if any patches were to go
upstream then probably 1 & 2 only are safe.
File, VDDK, memory and data plugins all work, although I have only
done minimal testing on them.
The current tests, such as they are, all
2019 Mar 28
32
[PATCH nbdkit v5 FINAL 00/19] Implement extents.
This has already been pushed upstream. I am simply posting these here
so we have a reference in the mailing list in case we find bugs later
(as I'm sure we will - it's a complex patch series).
Great thanks to Eric Blake for tireless review on this one. It also
seems to have identified a few minor bugs in qemu along the way.
Rich.