search for: file_trim

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

2018 Jul 30
3
[PATCH v2] file: Normalize errno value for ENODEV
Fix issues Eric found in the original patch: https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html - When handling ENODEV, the caller is expecting EOPNOTSUPP to trigger fallback. - ENODEV should be ignored in file_trim. Tested only on Fedora 28 and RHEL 7.5. --- plugins/file/file.c | 33 ++++++++++++++++++++++++--------- 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...
2018 Jul 28
3
[PATCH] file: Normalize errno value for ENODEV
Fix issues Eric found in the original patch: https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html - When handling ENODEV, the caller is expecting ENOTSUPP to trigger fallback. - ENODEV should be ignored in file_trim. Tested only on Fedora 28. --- plugins/file/file.c | 33 ++++++++++++++++++++++++--------- 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 @@...
2018 Jan 31
1
[nbdkit PATCH] file: Add trim support
...nt, 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 EIO or EPERM. */ + r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,...
2019 Jan 05
0
[PATCH nbdkit v2 07/11] file: Implement NBDKIT_API_VERSION 2.
...*handle) -{ - struct handle *h = handle; - - if (fdatasync (h->fd) == -1) { - nbdkit_error ("fdatasync: %m"); + out: + if ((flags & NBDKIT_FLAG_FUA) && file_flush (handle, 0) == -1) return -1; - } - return 0; } /* Punch a hole in the file. */ static int -file_trim (void *handle, uint32_t count, uint64_t offset) +file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { #ifdef FALLOC_FL_PUNCH_HOLE struct handle *h = handle; @@ -470,6 +488,9 @@ file_trim (void *handle, uint32_t count, uint64_t offset) } #endif + if ((flags & N...
2018 Jul 27
4
[PATCH] file: Fix zero/trim with block device
...) #ifdef FALLOC_FL_ZERO_RANGE r = fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); - if (r == -1 && errno != EOPNOTSUPP) { + if (r == -1 && errno != EOPNOTSUPP && errno != ENODEV) { nbdkit_error ("zero: %m"); } #else @@ -288,11 +288,11 @@ file_trim (void *handle, uint32_t count, uint64_t offset) struct handle *h = handle; /* Trim is advisory; we don't care if it fails for anything other - * than EIO or EPERM. */ + * than EIO, EPERM, or ENODEV (kernel 3.10) */ r = fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SI...
2019 Mar 20
0
[PATCH nbdkit 8/8] file: Implement extents.
...("lseek (to find device size): %m"); - return -1; - } + int64_t size; + pthread_mutex_lock (&lseek_lock); + size = block_device_size (h->fd); + pthread_mutex_unlock (&lseek_lock); return size; } else { /* Regular file. */ @@ -501,6 +519,103 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) return 0; } +#ifdef SEEK_HOLE +/* 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 f...
2018 Jul 28
1
Re: [PATCH] file: Fix zero/trim with block device
...t_error ("zero: %m"); > > } > > #else > > Are we sure that the caller still sees the correct EOPNOTSUPP errno > value that it uses in deciding whether to attempt the manual > fallbacks? You may need to explicitly set errno. > > >@@ -288,11 +288,11 @@ file_trim (void *handle, uint32_t count, uint64_t offset) > > struct handle *h = handle; > > /* Trim is advisory; we don't care if it fails for anything other > >- * than EIO or EPERM. */ > >+ * than EIO, EPERM, or ENODEV (kernel 3.10) */ > > r = fallocate (h-&g...
2019 Mar 28
0
[PATCH nbdkit v5 FINAL 15/19] file: Implement extents.
...("lseek (to find device size): %m"); - return -1; - } + int64_t size; + pthread_mutex_lock (&lseek_lock); + size = block_device_size (h->fd); + pthread_mutex_unlock (&lseek_lock); return size; } else { /* Regular file. */ @@ -501,6 +521,103 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) return 0; } +#ifdef SEEK_HOLE +/* 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 f...
2018 Jul 30
0
Re: [PATCH] file: Normalize errno value for ENODEV
On 07/28/2018 06:42 AM, Nir Soffer wrote: > Fix issues Eric found in the original patch: > https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html > > - When handling ENODEV, the caller is expecting ENOTSUPP to trigger > fallback. > - ENODEV should be ignored in file_trim. > > Tested only on Fedora 28. > --- > plugins/file/file.c | 33 ++++++++++++++++++++++++--------- > 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....
2018 Jul 30
0
Re: [PATCH v2] file: Normalize errno value for ENODEV
On 07/30/2018 12:02 PM, Nir Soffer wrote: > Fix issues Eric found in the original patch: > https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html > > - When handling ENODEV, the caller is expecting EOPNOTSUPP to trigger > fallback. > - ENODEV should be ignored in file_trim. > > Tested only on Fedora 28 and RHEL 7.5. > --- > plugins/file/file.c | 33 ++++++++++++++++++++++++--------- > 1 file changed, 24 insertions(+), 9 deletions(-) > > +#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) > +static int > +do_fallocate(i...
2018 Jul 30
1
Re: [PATCH v2] file: Normalize errno value for ENODEV
...Soffer wrote: > > Fix issues Eric found in the original patch: > > https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html > > > > - When handling ENODEV, the caller is expecting EOPNOTSUPP to trigger > > fallback. > > - ENODEV should be ignored in file_trim. > > > > Tested only on Fedora 28 and RHEL 7.5. > > --- > > plugins/file/file.c | 33 ++++++++++++++++++++++++--------- > > 1 file changed, 24 insertions(+), 9 deletions(-) > > > > > +#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE)...
2018 Aug 02
2
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
...ste 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, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > +...
2018 Jul 27
0
Re: [PATCH] file: Fix zero/trim with block device
...errno != ENODEV) { > nbdkit_error ("zero: %m"); > } > #else Are we sure that the caller still sees the correct EOPNOTSUPP errno value that it uses in deciding whether to attempt the manual fallbacks? You may need to explicitly set errno. > @@ -288,11 +288,11 @@ file_trim (void *handle, uint32_t count, uint64_t offset) > struct handle *h = handle; > > /* Trim is advisory; we don't care if it fails for anything other > - * than EIO or EPERM. */ > + * than EIO, EPERM, or ENODEV (kernel 3.10) */ > r = fallocate (h->fd, FALLOC...
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...%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, + offset, count); + if (r...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...%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, + offset, count); + if (r...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...>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, + offset, count); + if (r == -...
2018 Aug 02
0
[PATCH 1/3] file: Avoid unsupported fallocate() calls
...%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, + offset, count); + if (r...
2018 Aug 03
10
[PATCH v2 0/4] file: Zero for block devices and older file systems
...set and count are aligned to device sector size. - initialize h->can_* properly. Before they were uninitialized if FALLOC_FL_* macros were not defined. - Use new h->can_punch_hole in file_can_trim, so now we report the actual capability once we detected it. - Use h->can_punch_hole in file_trim, so we try only once if the operation is not supported. v1 was here: https://www.redhat.com/archives/libguestfs/2018-July/msg00084.html Nir Soffer (4): file: Avoid unsupported fallocate() calls file: Support zero without ZERO_RANGE common: Add isaligned helper module file: Zero for bloc...
2018 Aug 02
0
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
...f 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, FALLOC_FL_...
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