search for: file_flush

Displaying 20 results from an estimated 32 matches for "file_flush".

2019 Jan 05
0
[PATCH nbdkit v2 07/11] file: Implement NBDKIT_API_VERSION 2.
...*/ #endif +#define NBDKIT_API_VERSION 2 + #include <nbdkit-plugin.h> #include "isaligned.h" @@ -263,9 +265,30 @@ file_can_trim (void *handle) #endif } +static int +file_can_fua (void *handle) +{ + return NBDKIT_FUA_NATIVE; +} + +/* Flush the file to disk. */ +static int +file_flush (void *handle, uint32_t flags) +{ + struct handle *h = handle; + + if (fdatasync (h->fd) == -1) { + nbdkit_error ("fdatasync: %m"); + return -1; + } + + return 0; +} + /* Read data from the file. */ static int -file_pread (void *handle, void *buf, uint32_t count, uint64_t o...
2018 Jan 31
1
[nbdkit PATCH] file: Add trim support
...64_t offset) @@ -219,7 +231,7 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) return 0; } -/* Write data to the file. */ +/* Write zeroes to the file. */ static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { @@ -268,6 +280,33 @@ file_flush (void *handle) return 0; } +/* Punch a hole in the file. */ +static int +file_trim (void *handle, uint32_t count, uint64_t offset) +{ + int r = -1; +#ifdef FALLOC_FL_PUNCH_HOLE + struct handle *h = handle; + + /* Trim is advisory; we don't care if it fails for anything other + * than...
2019 Jan 04
10
[PATCH nbdkit 0/7] server: Implement NBD_FLAG_CAN_MULTI_CONN.
First thing to say is that I need to do a *lot* more testing on this, so this is just an early peek. In particular, although it passed ‘make check && make check-valgrind’ I have *not* tested it against a multi-conn-aware client such as the Linux kernel >= 4.9. This implements NBD_FLAG_CAN_MULTI_CONN, described in the protocol doc as: "NBD_FLAG_CAN_MULTI_CONN: Indicates that
2020 Aug 10
1
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...32967 > > This explains the issue: > https://bugzilla.redhat.com/1247135#c29 > > And here you can how unrelated I/O is affected by uncontrolled flushes: > https://bugzilla.redhat.com/1247135#c30 > https://bugzilla.redhat.com/1247135#c36 Thanks for the explanation. Our use of file_flush (ie fdatasync) is less than ideal - we should probably use sync_file_range, which is what Linus suggested. However in this case it won't be a problem because we're only flushing the few pages we have just written. We control the file and there is no chance that the flush will cause an unc...
2019 Jan 05
15
[PATCH nbdkit v2 01/11] server: Implement NBD_FLAG_CAN_MULTI_CONN.
For existing commits, this is almost identical to v1, except that I updated some commit messages and reordered the commits in a somewhat more logical sequence. The main changes are the extra commits: [06/11] plugins: Return NBD_FLAG_CAN_MULTI_CONN from some readonly plugins. - Readonly plugins that can set the flag unconditionally. [09/11] partitioning: Return NBD_FLAG_CAN_MULTI_CONN. [10/11]
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...{ - /* Prefer posix_fadvise(), but letting nbdkit call .pread on our - * behalf also tends to work well for the local file system - * cache. - */ -#if HAVE_POSIX_FADVISE - return NBDKIT_FUA_NATIVE; -#else - return NBDKIT_FUA_EMULATE; -#endif -} - -/* Flush the file to disk. */ -static int -file_flush (void *handle, uint32_t flags) -{ - struct handle *h = handle; - - if (fdatasync (h->fd) == -1) { - nbdkit_error ("fdatasync: %m"); - return -1; - } - - return 0; -} - -/* Read data from the file. */ -static int -file_pread (void *handle, void *buf, uint32_t count, uint64_t o...
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; /*
2018 Aug 02
2
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
..._zero() callback, so that nbdkit won't even waste time calling into .zero() if we know we will just be deferring right back to a full write (either because the macro is not available, or because we encountered a failure trying to use it on a previous connection). > @@ -301,27 +320,30 @@ file_flush (void *handle) > static int > file_trim (void *handle, uint32_t count, uint64_t offset) > { > - int r = -1; > #ifdef FALLOC_FL_PUNCH_HOLE > struct handle *h = handle; > + int r = -1; > + > + if (h->can_punch_hole) { > + r = do_fallocate (h->fd,...
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...UPP) { + nbdkit_error ("zero: %m"); + return r; + } + + h->can_zero_range = false; } -#else - /* Trigger a fall back to writing */ - errno = EOPNOTSUPP; #endif + /* Trigger a fall back to writing */ + errno = EOPNOTSUPP; return r; } @@ -301,27 +324,30 @@ file_flush (void *handle) static int file_trim (void *handle, uint32_t count, uint64_t offset) { - int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE struct handle *h = handle; + int r = -1; + + if (h->can_punch_hole) { + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, +...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...UPP) { + nbdkit_error ("zero: %m"); + return r; + } + + h->can_zero_range = false; } -#else - /* Trigger a fall back to writing */ - errno = EOPNOTSUPP; #endif + /* Trigger a fall back to writing */ + errno = EOPNOTSUPP; return r; } @@ -301,27 +324,30 @@ file_flush (void *handle) static int file_trim (void *handle, uint32_t count, uint64_t offset) { - int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE struct handle *h = handle; + int r = -1; + + if (h->can_punch_hole) { + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, +...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...t;); + return -1; + } + + h->can_zero_range = false; } -#else - /* Trigger a fall back to writing */ - errno = EOPNOTSUPP; #endif - return r; + /* Trigger a fall back to writing */ + errno = EOPNOTSUPP; + return -1; } /* Flush the file to disk. */ @@ -301,27 +324,30 @@ file_flush (void *handle) static int file_trim (void *handle, uint32_t count, uint64_t offset) { - int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE struct handle *h = handle; + int r; + + if (h->can_punch_hole) { + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, +...
2020 Aug 07
3
[PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...== cache_none) flags |= NBDKIT_FLAG_FUA; +#endif + while (count > 0) { ssize_t r = pwrite (h->fd, buf, count, offset); if (r == -1) { @@ -369,6 +453,12 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, if ((flags & NBDKIT_FLAG_FUA) && file_flush (handle, 0) == -1) return -1; +#ifdef HAVE_POSIX_FADVISE + /* On Linux this will evict the pages we just wrote from the page cache. */ + if (cache_mode == cache_none) + posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); +#endif + return 0; } -- 2.27.0
2019 Mar 20
0
[PATCH nbdkit 8/8] file: Implement extents.
...d_mutex_unlock (&lseek_lock); + + return r; +} +#endif /* SEEK_HOLE */ + static struct nbdkit_plugin plugin = { .name = "file", .longname = "nbdkit file plugin", @@ -522,6 +637,10 @@ static struct nbdkit_plugin plugin = { .flush = file_flush, .trim = file_trim, .zero = file_zero, +#ifdef SEEK_HOLE + .can_extents = file_can_extents, + .extents = file_extents, +#endif .errno_is_preserved = 1, }; -- 2.20.1
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.
2017 Jan 20
7
[nbdkit PATCH 0/5] Add WRITE_ZEROES support
The upstream protocol recently promoted NBD_CMD_WRITE_ZEROES from experimental to a documented extension. Exposing support for this allows plugin writers to create sparse files when driven by a client that knows how to use the extension; meanwhile, even if a plugin does not support this extension, the server benefits from less network traffic from the client. Eric Blake (5): protocol: Support
2018 Aug 02
0
[PATCH 1/3] file: Avoid unsupported fallocate() calls
...UPP) { + nbdkit_error ("zero: %m"); + return r; + } + + h->can_zero_range = false; } -#else - /* Trigger a fall back to writing */ - errno = EOPNOTSUPP; #endif + /* Trigger a fall back to writing */ + errno = EOPNOTSUPP; return r; } @@ -301,27 +320,30 @@ file_flush (void *handle) static int file_trim (void *handle, uint32_t count, uint64_t offset) { - int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE struct handle *h = handle; + int r = -1; + + if (h->can_punch_hole) { + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, +...
2018 Aug 02
0
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
...nbdkit > won't even waste time calling into .zero() if we know we will just be > deferring right back to a full write (either because the macro is not > available, or because we encountered a failure trying to use it on a > previous connection). > > > @@ -301,27 +320,30 @@ file_flush (void *handle) > > static int > > file_trim (void *handle, uint32_t count, uint64_t offset) > > { > > - int r = -1; > > #ifdef FALLOC_FL_PUNCH_HOLE > > struct handle *h = handle; > > + int r = -1; > > + > > + if (h->can_punch_h...
2020 Aug 07
3
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...;+ > > while (count > 0) { > > ssize_t r = pwrite (h->fd, buf, count, offset); > > if (r == -1) { > >@@ -369,6 +453,12 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > > if ((flags & NBDKIT_FLAG_FUA) && file_flush (handle, 0) == -1) > > return -1; > >+#ifdef HAVE_POSIX_FADVISE > >+ /* On Linux this will evict the pages we just wrote from the page cache. */ > >+ if (cache_mode == cache_none) > >+ posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); &g...
2020 Aug 07
2
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
On Fri, Aug 07, 2020 at 05:29:24PM +0300, Nir Soffer wrote: > On Fri, Aug 7, 2020 at 5:07 PM Richard W.M. Jones <rjones@redhat.com> wrote: > > These ones? > > https://www.redhat.com/archives/libguestfs/2020-August/msg00078.html > > No, we had a bug when copying image from glance caused sanlock timeouts > because of the unpredictable page cache flushes. > > We
2020 Aug 07
0
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...A; > +#endif > + > while (count > 0) { > ssize_t r = pwrite (h->fd, buf, count, offset); > if (r == -1) { > @@ -369,6 +453,12 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > if ((flags & NBDKIT_FLAG_FUA) && file_flush (handle, 0) == -1) > return -1; > > +#ifdef HAVE_POSIX_FADVISE > + /* On Linux this will evict the pages we just wrote from the page cache. */ > + if (cache_mode == cache_none) > + posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); > +#endif...