search for: falloc_fl_zero_rang

Displaying 20 results from an estimated 61 matches for "falloc_fl_zero_rang".

Did you mean: falloc_fl_zero_range
2018 Aug 13
2
Re: [PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...gt; 3. Fall back to manual writing > > - trim changed to: > 1. If we can punch hole, try PUNCH_HOLE > 2. Succeed > --- > plugins/file/file.c | 80 ++++++++++++++++++++++++++++++--------------- > 1 file changed, 53 insertions(+), 27 deletions(-) > > #ifdef FALLOC_FL_ZERO_RANGE > - r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); > - if (r == -1 && errno != EOPNOTSUPP) { > - nbdkit_error ("zero: %m"); > + if (h->can_zero_range) { > + r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); > + i...
2018 Aug 18
2
Re: [PATCH v2 1/4] file: Avoid unsupported fallocate() calls
On Mon, Aug 13, 2018 at 11:58 PM Nir Soffer <nsoffer@redhat.com> wrote: > On Mon, Aug 13, 2018 at 8:44 PM Eric Blake <eblake@redhat.com> wrote: > >> > #ifdef FALLOC_FL_ZERO_RANGE >> > - r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); >> > - if (r == -1 && errno != EOPNOTSUPP) { >> > - nbdkit_error ("zero: %m"); >> > + if (h->can_zero_range) { >> > + r = do_fallocate (h->fd, FALL...
2018 Jul 27
4
[PATCH] file: Fix zero/trim with block device
When using block device on RHEL 7.5, file plugin fails to zero with this error (copied from strace): [pid 39551] fallocate(8, FALLOC_FL_ZERO_RANGE, 1536, 64000) = -1 ENODEV (No such device) This is expected error according to the manual: ENODEV fd does not refer to a regular file or a directory. (If fd is a pipe or FIFO, a different error results.) Treat this error as EOPNOSUPP. Tested only on Fedora 28; I don't know how to build nb...
2018 Jul 28
1
Re: [PATCH] file: Fix zero/trim with block device
On Fri, Jul 27, 2018 at 04:23:10PM -0500, Eric Blake wrote: > On 07/27/2018 04:03 PM, Nir Soffer wrote: > >When using block device on RHEL 7.5, file plugin fails to zero with this > >error (copied from strace): > > > >[pid 39551] fallocate(8, FALLOC_FL_ZERO_RANGE, 1536, 64000) = -1 ENODEV (No such device) > > > >This is expected error according to the manual: > > > >ENODEV fd does not refer to a regular file or a directory. (If fd is a > >pipe or FIFO, a different error results.) > > The man page is out-of-date; newer...
2018 Jul 30
3
[PATCH v2] file: Normalize errno value for ENODEV
...++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/file/file.c b/plugins/file/file.c index a7c07fb..a8a6253 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -50,6 +50,21 @@ static char *filename = NULL; +#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) +static int +do_fallocate(int fd, int mode, off_t offset, off_t len) +{ + int r = -1; + r = fallocate (fd, mode, offset, len); + /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails + with EOPNOTSUPP in this case. Normalize errno to simplify callers. */ + if (r == -1...
2018 Jul 28
3
[PATCH] file: Normalize errno value for ENODEV
...++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/file/file.c b/plugins/file/file.c index a7c07fb..4210adb 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -50,6 +50,21 @@ static char *filename = NULL; +#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) +static int +do_fallocate(int fd, int mode, off_t offset, off_t len) +{ + int r = -1; + r = fallocate (fd, mode, offset, len); + /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails + with EOPNOTSUPP in this case. Normlize errno to simplify callers. */ + if (r == -1 &...
2018 Aug 19
1
Re: [PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...ile/file.c > +++ b/plugins/file/file.c > @@ -33,6 +33,7 @@ > > #include <config.h> > > +#include <stdbool.h> > #include <stdio.h> > #include <stdlib.h> Can you put stdbook after stdlib for consistency with the other source files. > #ifdef FALLOC_FL_ZERO_RANGE > - r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); > - if (r == -1 && errno != EOPNOTSUPP) { > - nbdkit_error ("zero: %m"); > + if (h->can_zero_range) { > + r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); > + i...
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
2018 Jul 27
0
Re: [PATCH] file: Fix zero/trim with block device
On 07/27/2018 04:03 PM, Nir Soffer wrote: > When using block device on RHEL 7.5, file plugin fails to zero with this > error (copied from strace): > > [pid 39551] fallocate(8, FALLOC_FL_ZERO_RANGE, 1536, 64000) = -1 ENODEV (No such device) > > This is expected error according to the manual: > > ENODEV fd does not refer to a regular file or a directory. (If fd is a > pipe or FIFO, a different error results.) The man page is out-of-date; newer kernels support FALLOC_FL_ZERO...
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...e { int fd; + bool can_punch_hole; + bool can_zero_range; }; /* Create the per-connection handle. */ @@ -146,6 +149,18 @@ file_open (int 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 define...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...e { int fd; + bool can_punch_hole; + bool can_zero_range; }; /* Create the per-connection handle. */ @@ -146,6 +149,18 @@ file_open (int 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 define...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...e { int fd; + bool can_punch_hole; + bool can_zero_range; }; /* Create the per-connection handle. */ @@ -146,6 +149,18 @@ file_open (int 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 define...
2018 Aug 02
0
[PATCH 1/3] file: Avoid unsupported fallocate() calls
...e { int fd; + bool can_punch_hole; + bool can_zero_range; }; /* Create the per-connection handle. */ @@ -146,6 +149,18 @@ file_open (int 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; } @@ -189,19 +204,15 @@ file_get_size (void *handle) return statbuf.st_size; } +/* Trim is advisory, but we prefer to advertise it only when we can actually + * (attempt to) punch holes. Before...
2018 Aug 02
0
[PATCH] file: Zero support for block devices and NFS 4.2
...{ + nbdkit_error ("fstat: %s: %m", filename); + free (h); + return NULL; + } + + h->is_block_device = S_ISBLK(statbuf.st_mode); + + /* These flags will disabled if an operation is not supported. */ +#ifdef FALLOC_FL_PUNCH_HOLE + h->can_punch_hole = true; +#endif +#ifdef FALLOC_FL_ZERO_RANGE + h->can_zero_range = true; +#endif + h->can_fallocate = true; + return h; } @@ -164,27 +189,29 @@ static int64_t file_get_size (void *handle) { struct handle *h = handle; - struct stat statbuf; - if (fstat (h->fd, &statbuf) == -1) { - nbdkit_error ("stat: %m&...
2018 Aug 03
10
[PATCH v2 0/4] file: Zero for block devices and older file systems
This is the third 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 v2: - Revert file_can_trim change, since it is too late to change the value after negotiation. Changing the capability dinamically may be useful internally, but it should be done via other means. -
2018 Aug 18
7
[PATCH v3 0/4] file: Zero for block devices and older file systems
This version addresses some of the comments on v2. Changes since v2: - file_zero: Add missing space in function call - is_aligned: Assert that align is indeed a power of 2 - Spelling in commit message Not changed: - Eric commented that spacing was off: https://www.redhat.com/archives/libguestfs/2018-August/msg00113.html but I could not find anything wrong. - Eric asked if ioctl.h will cause
2018 Aug 13
0
Re: [PATCH v2 1/4] file: Avoid unsupported fallocate() calls
On Mon, Aug 13, 2018 at 8:44 PM Eric Blake <eblake@redhat.com> wrote: > > #ifdef FALLOC_FL_ZERO_RANGE > > - r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); > > - if (r == -1 && errno != EOPNOTSUPP) { > > - nbdkit_error ("zero: %m"); > > + if (h->can_zero_range) { > > + r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, of...
2018 Aug 18
0
Re: [PATCH v2 1/4] file: Avoid unsupported fallocate() calls
On 08/18/2018 03:09 PM, Nir Soffer wrote: > On Mon, Aug 13, 2018 at 11:58 PM Nir Soffer <nsoffer@redhat.com> wrote: > >> On Mon, Aug 13, 2018 at 8:44 PM Eric Blake <eblake@redhat.com> wrote: >> >>>> #ifdef FALLOC_FL_ZERO_RANGE >>>> - r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); >>>> - if (r == -1 && errno != EOPNOTSUPP) { >>>> - nbdkit_error ("zero: %m"); >>>> + if (h->can_zero_range) { >>>> + r = do_fallocate...
2018 Aug 19
9
[PATCH v3 0/4] file: Zero for block devices and older file systems
This version addresses comments on v3. Changes since v3: - Finally got spacing right (Eric) - Reorder includes (Richard) - Return 0 or -1 instead of r (Richard) - Add common/include/isaligned.h to Makefile.am (Richard) v3 was here: https://www.redhat.com/archives/libguestfs/2018-August/msg00177.html Nir Soffer (4): file: Avoid unsupported fallocate() calls file: Support zero without
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...s compiled. */ +void +fileops_dump_plugin (void) +{ +#ifdef BLKSSZGET + printf ("file_blksszget=yes\n"); +#endif +#ifdef BLKZEROOUT + printf ("file_blkzeroout=yes\n"); +#endif +#ifdef FALLOC_FL_PUNCH_HOLE + printf ("file_falloc_fl_punch_hole=yes\n"); +#endif +#ifdef FALLOC_FL_ZERO_RANGE + printf ("file_falloc_fl_zero_range=yes\n"); +#endif +} + +int +init_fileops (int fd, struct fileops *fops) +{ + struct stat statbuf; + + if (fstat (fd, &statbuf) == -1) { + nbdkit_error ("fstat: %m"); + return -1; + } + + fops->fd = fd; + fops->is_block_...