search for: lseek_lock

Displaying 20 results from an estimated 29 matches for "lseek_lock".

2019 Mar 20
0
[PATCH nbdkit 8/8] file: Implement extents.
...NCH_HOLE) #include <linux/falloc.h> /* For FALLOC_FL_*, glibc < 2.18 */ #endif @@ -68,7 +71,11 @@ static char *filename = NULL; -int file_debug_zero; /* to enable: -D file.zero=1 */ +/* Any callbacks using lseek must be protected by this lock. */ +static pthread_mutex_t lseek_lock = PTHREAD_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 int...
2019 Mar 23
1
Re: [PATCH nbdkit 8/8] file: Implement extents.
...ins/file/file.c | 139 ++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 129 insertions(+), 10 deletions(-) > > -int file_debug_zero; /* to enable: -D file.zero=1 */ > +/* Any callbacks using lseek must be protected by this lock. */ > +static pthread_mutex_t lseek_lock = PTHREAD_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...
2019 Mar 28
0
[PATCH nbdkit v5 FINAL 15/19] file: Implement extents.
...NCH_HOLE) #include <linux/falloc.h> /* For FALLOC_FL_*, glibc < 2.18 */ #endif @@ -68,7 +71,11 @@ static char *filename = NULL; -int file_debug_zero; /* to enable: -D file.zero=1 */ +/* Any callbacks using lseek must be protected by this lock. */ +static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; + +/* to enable: -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 +...
2019 Apr 23
0
[nbdkit PATCH 4/4] plugins: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE
...58,6 +58,7 @@ #include <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...
2019 Apr 24
2
Re: [PATCH nbdkit v5 FINAL 15/19] file: Implement extents.
...+/* Extents. */ > + > +static int > +file_can_extents (void *handle) > +{ > + struct handle *h = handle; > + off_t r; > + > + /* A simple test to see whether SEEK_HOLE etc is likely to work on > + * the current filesystem. > + */ > + pthread_mutex_lock (&lseek_lock); > + r = lseek (h->fd, 0, SEEK_HOLE); > + pthread_mutex_unlock (&lseek_lock); > + if (r == -1) { > + nbdkit_debug ("extents disabled: lseek: SEEK_HOLE: %m"); > + return 0; > + } > + return 1; > +} Should we also return 0 if the lseek() returned...
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...T_API_VERSION 2 +#include <nbdkit-plugin.h> + +#include "cleanup.h" +#include "fileops.h" +#include "isaligned.h" + +#ifndef HAVE_FDATASYNC +#define fdatasync fsync +#endif + +/* Any callbacks using lseek must be protected by this lock. */ +static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; + +/* To enable: -D file.zero=1 */ +int file_debug_zero; + +static bool +is_enotsup (int err) +{ + return err == ENOTSUP || err == EOPNOTSUPP; +} + +/* Print some extra information about how the plugin was compiled. */ +void +fileops_dump_plugin (void) +{ +#ifdef BLKSS...
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
...t;sys/ioctl.h> #include <errno.h> +#include <dirent.h> #include <pthread.h> @@ -66,9 +67,11 @@ #endif static char *filename = NULL; +static char *directory = NULL; +DIR *dir = NULL; -/* Any callbacks using lseek must be protected by this lock. */ -static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; +/* Any callbacks using readdir or lseek must be protected by this lock. */ +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; /* to enable: -D file.zero=1 */ int file_debug_zero; @@ -83,10 +86,14 @@ static void file_unload (void) { free (filename); + fr...
2020 Feb 10
2
[nbdkit PATCH 05/10] plugins: Wire up file-based plugin support for NBD_INFO_INIT_STATE
...+ h->init_zero = false; +#ifdef SEEK_HOLE + if (!h->is_block_device) { + off_t r; + + /* A simple test to see whether SEEK_DATA/SEEK_HOLE are likely to work on + * the current filesystem, and to see if the image is sparse or zero. + */ + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lseek_lock); + r = lseek (h->fd, 0, SEEK_DATA); + if (r == -1) { + if (errno == ENXIO) { + nbdkit_debug ("extents enabled, entire image is hole"); + h->can_extents = true; + h->init_sparse = true; + h->init_zero = true; + } else { + nbdk...
2019 Apr 25
0
Re: [PATCH nbdkit v5 FINAL 15/19] file: Implement extents.
...> +file_can_extents (void *handle) > > +{ > > + struct handle *h = handle; > > + off_t r; > > + > > + /* A simple test to see whether SEEK_HOLE etc is likely to work on > > + * the current filesystem. > > + */ > > + pthread_mutex_lock (&lseek_lock); > > + r = lseek (h->fd, 0, SEEK_HOLE); > > + pthread_mutex_unlock (&lseek_lock); > > + if (r == -1) { > > + nbdkit_debug ("extents disabled: lseek: SEEK_HOLE: %m"); > > + return 0; > > + } > > + return 1; > > +} > &gt...
2020 Feb 10
1
[nbdkit PATCH] split: Add support for .extents
...t; #include <sys/stat.h> +#include <stdbool.h> #include <nbdkit-plugin.h> +#include "cleanup.h" + /* The files. */ static char **filenames = NULL; static size_t nr_files = 0; +/* Any callbacks using lseek must be protected by this lock. */ +static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; + static void split_unload (void) { @@ -96,6 +102,7 @@ struct handle { struct file { uint64_t offset, size; int fd; + bool can_extents; }; /* Create the per-connection handle. */ @@ -107,6 +114,7 @@ split_open (int readonly) size_t i; uint64_t offset...
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.
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 Apr 15
0
[PATCH nbdkit 2/9] floppy, iso, split, ssh: Use new vector type to store lists of strings.
...ot; +#include "vector.h" /* The files. */ -static char **filenames = NULL; -static size_t nr_files = 0; +DEFINE_VECTOR_TYPE(string_vector, char *); +static string_vector filenames = empty_vector; /* Any callbacks using lseek must be protected by this lock. */ static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; @@ -58,29 +59,23 @@ static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; static void split_unload (void) { - size_t i; - - for (i = 0; i < nr_files; ++i) - free (filenames[i]); - free (filenames); + string_vector_iter (&filenames, (void *) fre...
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
2
[PATCH nbdkit] plugins: file: More standard cache mode names
...@@ static int fadvise_mode = ; /* cache mode */ -static enum { cache_default, cache_none } cache_mode = cache_default; +static enum { cache_writeback, cache_writethrough } cache_mode = cache_writeback; /* Any callbacks using lseek must be protected by this lock. */ static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; @@ -140,10 +140,10 @@ file_config (const char *key, const char *value) } } else if (strcmp (key, "cache") == 0) { - if (strcmp (value, "default") == 0) - cache_mode = cache_default; - else if (strcmp (value, "none") ==...
2019 Aug 13
3
[nbdkit PATCH 0/2] errno cleanup patches
I ran into these while trying to prepare patches to add NBD_CMD_FLAG_FAST_ZERO, which will expose a new NBD_ENOTSUP wire value. Eric Blake (2): plugins: Don't lose original error when emulating FUA plugins: Permit ENOTSUP as synonym for EOPNOTSUPP docs/nbdkit-filter.pod | 11 ++++++----- docs/nbdkit-plugin.pod | 12 +++++++----- plugins/file/file.c | 16 +++++++++++-----
2019 Apr 24
7
[nbdkit PATCH 0/4] More mutex sanity checking
I do have a question about whether patch 2 is right, or whether I've exposed a bigger problem in the truncate (and possibly other) filter, but the rest seem fairly straightforward. Eric Blake (4): server: Check for pthread lock failures truncate: Factor out reading real_size under mutex plugins: Check for mutex failures filters: Check for mutex failures filters/cache/cache.c
2020 Feb 11
0
Re: [nbdkit PATCH 05/10] plugins: Wire up file-based plugin support for NBD_INFO_INIT_STATE
...SEEK_HOLE > + if (!h->is_block_device) { > + off_t r; > + > + /* A simple test to see whether SEEK_DATA/SEEK_HOLE are likely to work on > + * the current filesystem, and to see if the image is sparse or zero. > + */ > + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lseek_lock); > + r = lseek (h->fd, 0, SEEK_DATA); > + if (r == -1) { > + if (errno == ENXIO) { > + nbdkit_debug ("extents enabled, entire image is hole"); > + h->can_extents = true; > + h->init_sparse = true; > + h->init_zero =...
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