search for: can_punch_hole

Displaying 20 results from an estimated 37 matches for "can_punch_hole".

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 Aug 02
0
[PATCH 1/3] file: Avoid unsupported fallocate() calls
...++ b/plugins/file/file.c @@ -33,6 +33,7 @@ #include <config.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -118,6 +119,8 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { 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_zer...
2018 Aug 03
0
[PATCH v2 1/4] file: Avoid unsupported fallocate() calls
...++ b/plugins/file/file.c @@ -33,6 +33,7 @@ #include <config.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -118,6 +119,8 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { 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_zer...
2018 Aug 18
0
[PATCH v3 1/4] file: Avoid unsupported fallocate() calls
...++ b/plugins/file/file.c @@ -33,6 +33,7 @@ #include <config.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -118,6 +119,8 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { 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_zer...
2018 Aug 19
0
[PATCH v4 1/4] file: Avoid unsupported fallocate() calls
...@@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <fcntl.h> #include <unistd.h> @@ -118,6 +119,8 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { 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_zer...
2018 Aug 02
2
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
...manual writing > > - trim changed to: > 1. If we can punch hole, try PUNCH_HOLE > 2. Succeed Seems reasonable from the description. > @@ -118,6 +119,8 @@ file_config_complete (void) > /* The per-connection handle. */ > struct handle { > int fd; > + bool can_punch_hole; > + bool can_zero_range; Would it be better to make these tri-state rather than merely bool? (Indeterminate, supported, known to fail) > }; > > /* Create the per-connection handle. */ > @@ -146,6 +149,18 @@ file_open (int readonly) > return NULL; > } >...
2018 Aug 03
10
[PATCH v2 0/4] file: Zero for block devices and older file systems
...inux 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 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 unsupport...
2020 Apr 09
0
[PATCH nbdkit v2 1/3] file: Move file operators to a new common/fileops mini-library.
...+#include <sys/types.h> + +/* Either use this as the per-connection handle, or it must appear as + * the first member of the per-connection handle. Don’t access these + * fields directly from your plugin. + */ +struct fileops { + int fd; + int sector_size; + bool is_block_device; + bool can_punch_hole; + bool can_zero_range; + bool can_fallocate; + bool can_zeroout; +}; + +/* Initialize the fileops struct. ‘fd’ is a file descriptor opened on + * the local file or block device that you want to serve. Call this + * from your .open callback after allocating the handle and setting up + * the fi...
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
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
0
[PATCH] file: Zero support for block devices and NFS 4.2
...loc.h> /* For FALLOC_FL_* on RHEL, glibc < 2.18 */ +#include <sys/ioctl.h> +#include <linux/fs.h> #include <nbdkit-plugin.h> @@ -116,6 +119,10 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { int fd; + bool is_block_device; + bool can_punch_hole; + bool can_zero_range; + bool can_fallocate; }; /* Create the per-connection handle. */ @@ -123,6 +130,7 @@ static void * file_open (int readonly) { struct handle *h; + struct stat statbuf; int flags; h = malloc (sizeof *h); @@ -144,6 +152,23 @@ file_open (int readonly) re...
2018 Jul 29
3
[PATCH] file: Zero support for block devices and NFS 4.2
...loc.h> /* For FALLOC_FL_* on RHEL, glibc < 2.18 */ +#include <sys/ioctl.h> +#include <linux/fs.h> #include <nbdkit-plugin.h> @@ -116,6 +119,10 @@ file_config_complete (void) /* The per-connection handle. */ struct handle { int fd; + bool is_block_device; + bool can_punch_hole; + bool can_zero_range; + bool can_fallocate; }; /* Create the per-connection handle. */ @@ -123,6 +130,7 @@ static void * file_open (int readonly) { struct handle *h; + struct stat statbuf; int flags; h = malloc (sizeof *h); @@ -144,6 +152,23 @@ file_open (int readonly) re...
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 02
0
Re: [PATCH 1/3] file: Avoid unsupported fallocate() calls
...t; > 1. If we can punch hole, try PUNCH_HOLE > > 2. Succeed > > Seems reasonable from the description. > > > @@ -118,6 +119,8 @@ file_config_complete (void) > > /* The per-connection handle. */ > > struct handle { > > int fd; > > + bool can_punch_hole; > > + bool can_zero_range; > > Would it be better to make these tri-state rather than merely bool? > (Indeterminate, supported, known to fail) > What is the advantage of having tri-state? > > }; > > > > /* Create the per-connection handle. */ > > @...
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.
2019 Jan 05
0
[PATCH nbdkit v2 07/11] file: Implement NBDKIT_API_VERSION 2.
...ffset, off_t len) /* Write zeroes to the file. */ static int -file_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { struct handle *h = handle; int r; #ifdef FALLOC_FL_PUNCH_HOLE - if (h->can_punch_hole && may_trim) { + if (h->can_punch_hole && (flags & NBDKIT_FLAG_MAY_TRIM)) { r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, count); if (r == 0) { if (file_debug_zero) nbdkit_debug ("h->c...
2018 Aug 02
0
[PATCH 2/3] file: Support zero without ZERO_RANGE
...qemu-img. --- plugins/file/file.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/plugins/file/file.c b/plugins/file/file.c index 8bb9a2d..aa05492 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -121,6 +121,7 @@ struct handle { int fd; bool can_punch_hole; bool can_zero_range; + bool can_fallocate; }; /* Create the per-connection handle. */ @@ -161,6 +162,8 @@ file_open (int readonly) h->can_zero_range = false; #endif + h->can_fallocate = true; + return h; } @@ -297,6 +300,35 @@ file_zero (void *handle, uint32_t count, uin...
2018 Aug 03
0
[PATCH v2 2/4] file: Support zero without ZERO_RANGE
...qemu-img. --- plugins/file/file.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/plugins/file/file.c b/plugins/file/file.c index 5daab63..a2cea4a 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -121,6 +121,7 @@ struct handle { int fd; bool can_punch_hole; bool can_zero_range; + bool can_fallocate; }; /* Create the per-connection handle. */ @@ -161,6 +162,8 @@ file_open (int readonly) h->can_zero_range = false; #endif + h->can_fallocate = true; + return h; } @@ -301,6 +304,35 @@ file_zero (void *handle, uint32_t count, uin...
2020 Apr 09
0
[PATCH nbdkit v2 3/3] tmpdisk: Implement this plugin using fileops.
...nst char *tmpdir = "/var/tmp"; @@ -153,12 +153,6 @@ tmpdisk_config_complete (void) "type=ext4|... The filesystem type.\n" \ "command=<COMMAND> Alternate command instead of mkfs." -struct handle { - int fd; - int64_t size; - bool can_punch_hole; -}; - /* Multi-conn is absolutely unsafe! In this callback it is simply * returning the default value (no multi-conn), that's to make it * clear for future authors. @@ -169,33 +163,6 @@ tmpdisk_can_multi_conn (void *handle) return 0; } -static int -tmpdisk_can_trim (void *handle) -...
2018 Jul 30
0
Re: [PATCH] file: Zero support for block devices and NFS 4.2
...fallocate to zero a range. This is much more efficient than writing zeros > + manually. */ s/is/can be/ (it's two syscalls instead of one, and may not be as efficient as we'd like - but does indeed stand a chance of being more efficient than manual efforts) > + if (h->can_punch_hole && h->can_fallocate) { > + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > + offset, count); > + if (r == 0) { > + r = do_fallocate(h->fd, 0, offset, count); > + if (r == 0) > + return 0; > + &g...