search for: file_pwrit

Displaying 20 results from an estimated 33 matches for "file_pwrit".

Did you mean: file_pwrite
2019 Jan 05
0
[PATCH nbdkit v2 07/11] file: Implement NBDKIT_API_VERSION 2.
...32_t count, uint64_t offset) +file_pread (void *handle, void *buf, uint32_t count, uint64_t offset, + uint32_t flags) { struct handle *h = handle; @@ -289,7 +312,8 @@ file_pread (void *handle, void *buf, uint32_t count, uint64_t offset) /* Write data to the file. */ static int -file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) +file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, + uint32_t flags) { struct handle *h = handle; @@ -304,6 +328,9 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t o...
2018 Jan 31
1
[nbdkit PATCH] file: Add trim support
...t we prefer to advertise it only when we can + * actually (attempt to) punch holes. */ +#ifdef FALLOC_FL_PUNCH_HOLE + return 1; +#else + return 0; +#endif +} + /* Read data from the file. */ static int file_pread (void *handle, void *buf, uint32_t count, uint64_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; }...
2020 Aug 07
2
[PATCH nbdkit] plugins: file: More standard cache mode names
...t offset, #ifdef HAVE_POSIX_FADVISE /* On Linux this will evict the pages we just read from the page cache. */ - if (cache_mode == cache_none) + if (cache_mode == cache_writethrough) posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); #endif @@ -441,11 +441,11 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, uint32_t orig_count = count; uint64_t orig_offset = offset; - /* If cache=none we want to force pages we have just written to the - * file to be flushed to disk so we can immediately evict them from - * the page cache. +...
2020 Aug 07
3
[PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
..._t offset, offset += r; } +#ifdef HAVE_POSIX_FADVISE + /* On Linux this will evict the pages we just read from the page cache. */ + if (cache_mode == cache_none) + posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); +#endif + return 0; } @@ -355,6 +428,17 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, { struct handle *h = handle; +#if defined (HAVE_POSIX_FADVISE) && defined (POSIX_FADV_DONTNEED) + uint32_t orig_count = count; + uint64_t orig_offset = offset; + + /* If cache=none we want to force pages we have just...
2020 Aug 07
3
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...O_DIRECT implementation, but my idea was that it might be an alternate implementation of cache=none. But if we thought we might use O_DIRECT as a separate mode, then maybe we should rename cache=none. cache=advise? cache=dontneed? I can't think of a good name! > >@@ -355,6 +428,17 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > > { > > struct handle *h = handle; > >+#if defined (HAVE_POSIX_FADVISE) && defined (POSIX_FADV_DONTNEED) > >+ uint32_t orig_count = count; > >+ uint64_t orig_offset = offset; > >+ &...
2020 Aug 08
0
Re: [PATCH nbdkit] plugins: file: More standard cache mode names
...ISE > /* On Linux this will evict the pages we just read from the page cache. */ > - if (cache_mode == cache_none) > + if (cache_mode == cache_writethrough) > posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); > #endif > > @@ -441,11 +441,11 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > uint32_t orig_count = count; > uint64_t orig_offset = offset; > > - /* If cache=none we want to force pages we have just written to the > - * file to be flushed to disk so we can immediately evict them fro...
2020 Aug 07
0
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...also possible to avoid polluting the page cache by using O_DIRECT, but that comes with harder guarantees (aligned access through aligned buffers), so we may add it as another mode later on. But in the meantime, cache=none is fairly nice while still avoiding O_DIRECT. > @@ -355,6 +428,17 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > { > struct handle *h = handle; > > +#if defined (HAVE_POSIX_FADVISE) && defined (POSIX_FADV_DONTNEED) > + uint32_t orig_count = count; > + uint64_t orig_offset = offset; > + > + /* If cac...
2020 Aug 07
0
Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
...CT > as a separate mode, then maybe we should rename cache=none. > cache=advise? cache=dontneed? I can't think of a good name! > Yes, don't call it none if you use the cache. How about advise=? I would keep cache semantics similar to qemu. > > >@@ -355,6 +428,17 @@ file_pwrite (void *handle, const void *buf, > uint32_t count, uint64_t offset, > > > { > > > struct handle *h = handle; > > >+#if defined (HAVE_POSIX_FADVISE) && defined (POSIX_FADV_DONTNEED) > > >+ uint32_t orig_count = count; > > >+ uint64_t orig...
2020 Aug 08
1
Re: [PATCH nbdkit] plugins: file: More standard cache mode names
...will evict the pages we just read from the page cache. */ > > - if (cache_mode == cache_none) > > + if (cache_mode == cache_writethrough) > > posix_fadvise (h->fd, orig_offset, orig_count, POSIX_FADV_DONTNEED); > > #endif > > > > @@ -441,11 +441,11 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, > > uint32_t orig_count = count; > > uint64_t orig_offset = offset; > > > > - /* If cache=none we want to force pages we have just written to the > > - * file to be flushed to disk so we can imm...
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
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...nt readonly) return NULL; } +#ifdef FALLOC_FL_PUNCH_HOLE + h->can_punch_hole = true; +#else + h->can_punch_hole = false; +#endif + +#ifdef FALLOC_FL_ZERO_RANGE + h->can_zero_range = true; +#else + h->can_zero_range = false; +#endif + return h; } @@ -252,34 +267,42 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNC...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...nt readonly) return NULL; } +#ifdef FALLOC_FL_PUNCH_HOLE + h->can_punch_hole = true; +#else + h->can_punch_hole = false; +#endif + +#ifdef FALLOC_FL_ZERO_RANGE + h->can_zero_range = true; +#else + h->can_zero_range = false; +#endif + return h; } @@ -252,34 +267,42 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNC...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...nt readonly) return NULL; } +#ifdef FALLOC_FL_PUNCH_HOLE + h->can_punch_hole = true; +#else + h->can_punch_hole = false; +#endif + +#ifdef FALLOC_FL_ZERO_RANGE + h->can_zero_range = true; +#else + h->can_zero_range = false; +#endif + return h; } @@ -252,35 +267,43 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif - int r = -1; + int r; #ifdef FALL...
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]
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
...fpathconf() to definitively learn what will work on a given - * fd for a more precise answer; oh well. */ -#ifdef FALLOC_FL_PUNCH_HOLE - return 1; -#else - return 0; -#endif + struct handle *h = handle; + return h->can_punch_hole; } /* Read data from the file. */ @@ -252,34 +263,42 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNC...
2018 Aug 02
0
[PATCH] file: Zero support for block devices and NFS 4.2
.../* Regular file. */ + struct stat statbuf; + + if (fstat (h->fd, &statbuf) == -1) { + nbdkit_error ("fstat: %m"); + return -1; + } - /* Else regular file. */ - return statbuf.st_size; + return statbuf.st_size; + } } static int @@ -250,33 +277,86 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset) static int file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNC...
2018 Aug 02
10
[PATCH 0/3] file: Zero for block devices and older file systems
This is the second version to support efficient zero for block devices on older kernels (e.g. RHEL 7.5), and file systems that do not support yet FALLOC_FS_ZERO_RANGE (e.g. NFS 4.2). Changes since v1: - Split to smaller patches - Skip linux only includes on other systems - Skip code using BLKZEROOUT if the macro is not defined - Try BLKZEROOUT only if the offset and count are aligned to device
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...{ - nbdkit_error ("pread: %m"); - return -1; - } - if (r == 0) { - nbdkit_error ("pread: unexpected end of file"); - return -1; - } - buf += r; - count -= r; - offset += r; - } - - return 0; -} - -/* Write data to the file. */ -static int -file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, - uint32_t flags) -{ - struct handle *h = handle; - - while (count > 0) { - ssize_t r = pwrite (h->fd, buf, count, offset); - if (r == -1) { - nbdkit_error ("pwrite: %m"); - return -1; -...
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; /*