search for: do_falloc

Displaying 20 results from an estimated 47 matches for "do_falloc".

Did you mean: do_alloc
2018 Jul 30
3
[PATCH v2] file: Normalize errno value for ENODEV
...ertions(+), 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 && errno == ENODE...
2018 Aug 13
2
Re: [PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...ting > > - 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); > + if (r== 0) Spacing is o...
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, FALLOC_FL_ZERO_RANGE, offset, count)...
2018 Jul 28
3
[PATCH] file: Normalize errno value for ENODEV
...ertions(+), 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 && errno == ENODEV...
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...ero (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_PUNCH_HOLE - if (may_trim) { + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return r; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return r; } - /* PUNCH_H...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...ero (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_PUNCH_HOLE - if (may_trim) { + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return r; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return r; } - /* PUNCH_H...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...*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 FALLOC_FL_PUNCH_HOLE - if (may_trim) { + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return 0; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return -1; } - /* PUNCH_...
2018 Aug 02
0
[PATCH 1/3] file: Avoid unsupported fallocate() calls
...ero (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_PUNCH_HOLE - if (may_trim) { + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return r; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return r; } - /* PUNCH_H...
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 29
3
[PATCH] file: Zero support for block devices and NFS 4.2
...{ -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE - if (may_trim) { + /* If we can and may trim, punching hole is our best option. */ + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return 0; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return r; } - /* PUNCH...
2018 Aug 02
0
[PATCH] file: Zero support for block devices and NFS 4.2
...{ -#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) struct handle *h = handle; -#endif int r = -1; #ifdef FALLOC_FL_PUNCH_HOLE - if (may_trim) { + /* If we can and may trim, punching hole is our best option. */ + if (h->can_punch_hole && may_trim) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == 0) + return 0; + + if (errno != EOPNOTSUPP) { nbdkit_error ("zero: %m"); + return r; } - /* PUNCH...
2018 Aug 19
1
Re: [PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...e/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); > + if (r== 0) Spacing. Ri...
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 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. -
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...write: %m"); + return -1; + } + buf += r; + count -= r; + offset += r; + } + + if ((flags & NBDKIT_FLAG_FUA) && fileops_flush (handle, 0) == -1) + return -1; + + return 0; +} + +#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 = fallocate (fd, mode, offset, len); + if (r == -1 && errno == ENODEV) { + /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails + with EOPNOTSUPP in this case. Normalize errno to simplify callers. */ +...
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 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
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, offset, count); > > +...
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 (h->fd, FALLOC_FL_ZERO_RANGE, of...
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.