dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support
@ 2025-08-13  2:40 Zhang Yi
  2025-08-14 16:52 ` Darrick J. Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Yi @ 2025-08-13  2:40 UTC (permalink / raw)
  To: linux-fsdevel, linux-block, dm-devel, linux-nvme, linux-scsi
  Cc: linux-kernel, linux-api, hch, tytso, djwong, bmarzins, chaitanyak,
	shinichiro.kawasaki, brauner, martin.petersen, yi.zhang, yi.zhang,
	chengzhihao1, yukuai3, yangerkun

From: Zhang Yi <yi.zhang@huawei.com>

The Linux kernel (since version 6.17) supports FALLOC_FL_WRITE_ZEROES in
fallocate(2). Add support for FALLOC_FL_WRITE_ZEROES to the fallocate
utility by introducing a new option -w|--write-zeroes.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
v1->v2:
 - Minor description modification to align with the kernel.

 sys-utils/fallocate.1.adoc | 11 +++++++++--
 sys-utils/fallocate.c      | 20 ++++++++++++++++----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/sys-utils/fallocate.1.adoc b/sys-utils/fallocate.1.adoc
index 44ee0ef4c..0ec9ff9a9 100644
--- a/sys-utils/fallocate.1.adoc
+++ b/sys-utils/fallocate.1.adoc
@@ -12,7 +12,7 @@ fallocate - preallocate or deallocate space to a file
 
 == SYNOPSIS
 
-*fallocate* [*-c*|*-p*|*-z*] [*-o* _offset_] *-l* _length_ [*-n*] _filename_
+*fallocate* [*-c*|*-p*|*-z*|*-w*] [*-o* _offset_] *-l* _length_ [*-n*] _filename_
 
 *fallocate* *-d* [*-o* _offset_] [*-l* _length_] _filename_
 
@@ -28,7 +28,7 @@ The exit status returned by *fallocate* is 0 on success and 1 on failure.
 
 The _length_ and _offset_ arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB, and YB.
 
-The options *--collapse-range*, *--dig-holes*, *--punch-hole*, *--zero-range* and *--posix* are mutually exclusive.
+The options *--collapse-range*, *--dig-holes*, *--punch-hole*, *--zero-range*, *--write-zeroes* and *--posix* are mutually exclusive.
 
 *-c*, *--collapse-range*::
 Removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at _offset_ and continues for _length_ bytes. At the completion of the operation, the contents of the file starting at the location __offset__+_length_ will be appended at the location _offset_, and the file will be _length_ bytes smaller. The option *--keep-size* may not be specified for the collapse-range operation.
@@ -76,6 +76,13 @@ Option *--keep-size* can be specified to prevent file length modification.
 +
 Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.
 
+*-w*, *--write-zeroes*::
+Zeroes space in the byte range starting at _offset_ and continuing for _length_ bytes. Within the specified range, blocks are preallocated for the regions that span the holes in the file. After a successful call, subsequent reads from this range will return zeroes, subsequent writes to that range do not require further changes to the file mapping metadata.
++
+Zeroing is done within the filesystem by preferably submitting write zeores commands, the alternative way is submitting actual zeroed data, the specified range will be converted into written extents. The write zeroes command is typically faster than write actual data if the device supports unmap write zeroes, the specified range will not be physically zeroed out on the device.
++
+Options *--keep-size* can not be specified for the write-zeroes operation.
+
 include::man-common/help-version.adoc[]
 
 == AUTHORS
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
index 13bf52915..8d37fdad7 100644
--- a/sys-utils/fallocate.c
+++ b/sys-utils/fallocate.c
@@ -40,7 +40,7 @@
 #if defined(HAVE_LINUX_FALLOC_H) && \
     (!defined(FALLOC_FL_KEEP_SIZE) || !defined(FALLOC_FL_PUNCH_HOLE) || \
      !defined(FALLOC_FL_COLLAPSE_RANGE) || !defined(FALLOC_FL_ZERO_RANGE) || \
-     !defined(FALLOC_FL_INSERT_RANGE))
+     !defined(FALLOC_FL_INSERT_RANGE) || !defined(FALLOC_FL_WRITE_ZEROES))
 # include <linux/falloc.h>	/* non-libc fallback for FALLOC_FL_* flags */
 #endif
 
@@ -65,6 +65,10 @@
 # define FALLOC_FL_INSERT_RANGE		0x20
 #endif
 
+#ifndef FALLOC_FL_WRITE_ZEROES
+# define FALLOC_FL_WRITE_ZEROES		0x80
+#endif
+
 #include "nls.h"
 #include "strutils.h"
 #include "c.h"
@@ -94,6 +98,7 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_(" -o, --offset <num>   offset for range operations, in bytes\n"), out);
 	fputs(_(" -p, --punch-hole     replace a range with a hole (implies -n)\n"), out);
 	fputs(_(" -z, --zero-range     zero and ensure allocation of a range\n"), out);
+	fputs(_(" -w, --write-zeroes   write zeroes and ensure allocation of a range\n"), out);
 #ifdef HAVE_POSIX_FALLOCATE
 	fputs(_(" -x, --posix          use posix_fallocate(3) instead of fallocate(2)\n"), out);
 #endif
@@ -304,6 +309,7 @@ int main(int argc, char **argv)
 	    { "dig-holes",      no_argument,       NULL, 'd' },
 	    { "insert-range",   no_argument,       NULL, 'i' },
 	    { "zero-range",     no_argument,       NULL, 'z' },
+	    { "write-zeroes",   no_argument,       NULL, 'w' },
 	    { "offset",         required_argument, NULL, 'o' },
 	    { "length",         required_argument, NULL, 'l' },
 	    { "posix",          no_argument,       NULL, 'x' },
@@ -312,8 +318,8 @@ int main(int argc, char **argv)
 	};
 
 	static const ul_excl_t excl[] = {	/* rows and cols in ASCII order */
-		{ 'c', 'd', 'i', 'p', 'x', 'z'},
-		{ 'c', 'i', 'n', 'x' },
+		{ 'c', 'd', 'i', 'p', 'w', 'x', 'z'},
+		{ 'c', 'i', 'n', 'w', 'x' },
 		{ 0 }
 	};
 	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
@@ -323,7 +329,7 @@ int main(int argc, char **argv)
 	textdomain(PACKAGE);
 	close_stdout_atexit();
 
-	while ((c = getopt_long(argc, argv, "hvVncpdizxl:o:", longopts, NULL))
+	while ((c = getopt_long(argc, argv, "hvVncpdizwxl:o:", longopts, NULL))
 			!= -1) {
 
 		err_exclusive_options(c, longopts, excl, excl_st);
@@ -353,6 +359,9 @@ int main(int argc, char **argv)
 		case 'z':
 			mode |= FALLOC_FL_ZERO_RANGE;
 			break;
+		case 'w':
+			mode |= FALLOC_FL_WRITE_ZEROES;
+			break;
 		case 'x':
 #ifdef HAVE_POSIX_FALLOCATE
 			posix = 1;
@@ -429,6 +438,9 @@ int main(int argc, char **argv)
 			else if (mode & FALLOC_FL_ZERO_RANGE)
 				fprintf(stdout, _("%s: %s (%ju bytes) zeroed.\n"),
 								filename, str, length);
+			else if (mode & FALLOC_FL_WRITE_ZEROES)
+				fprintf(stdout, _("%s: %s (%ju bytes) write zeroed.\n"),
+								filename, str, length);
 			else
 				fprintf(stdout, _("%s: %s (%ju bytes) allocated.\n"),
 								filename, str, length);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support
  2025-08-13  2:40 [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support Zhang Yi
@ 2025-08-14 16:52 ` Darrick J. Wong
  2025-08-15  9:29   ` Zhang Yi
  0 siblings, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2025-08-14 16:52 UTC (permalink / raw)
  To: Zhang Yi
  Cc: linux-fsdevel, linux-block, dm-devel, linux-nvme, linux-scsi,
	linux-kernel, linux-api, hch, tytso, bmarzins, chaitanyak,
	shinichiro.kawasaki, brauner, martin.petersen, yi.zhang,
	chengzhihao1, yukuai3, yangerkun

On Wed, Aug 13, 2025 at 10:40:15AM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> The Linux kernel (since version 6.17) supports FALLOC_FL_WRITE_ZEROES in
> fallocate(2). Add support for FALLOC_FL_WRITE_ZEROES to the fallocate
> utility by introducing a new option -w|--write-zeroes.
> 
> Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> v1->v2:
>  - Minor description modification to align with the kernel.
> 
>  sys-utils/fallocate.1.adoc | 11 +++++++++--
>  sys-utils/fallocate.c      | 20 ++++++++++++++++----
>  2 files changed, 25 insertions(+), 6 deletions(-)
> 
> diff --git a/sys-utils/fallocate.1.adoc b/sys-utils/fallocate.1.adoc
> index 44ee0ef4c..0ec9ff9a9 100644
> --- a/sys-utils/fallocate.1.adoc
> +++ b/sys-utils/fallocate.1.adoc
> @@ -12,7 +12,7 @@ fallocate - preallocate or deallocate space to a file

<snip all the long lines>

> +*-w*, *--write-zeroes*::
> +Zeroes space in the byte range starting at _offset_ and continuing
> for _length_ bytes. Within the specified range, blocks are
> preallocated for the regions that span the holes in the file. After a
> successful call, subsequent reads from this range will return zeroes,
> subsequent writes to that range do not require further changes to the
> file mapping metadata.

"...will return zeroes and subsequent writes to that range..." ?

> ++
> +Zeroing is done within the filesystem by preferably submitting write

I think we should say less about what the filesystem actually does to
preserve some flexibility:

"Zeroing is done within the filesystem. The filesystem may use a
hardware accelerated zeroing command, or it may submit regular writes.
The behavior depends on the filesystem design and available hardware."

> zeores commands, the alternative way is submitting actual zeroed data,
> the specified range will be converted into written extents. The write
> zeroes command is typically faster than write actual data if the
> device supports unmap write zeroes, the specified range will not be
> physically zeroed out on the device.
> ++
> +Options *--keep-size* can not be specified for the write-zeroes
> operation.
> +
>  include::man-common/help-version.adoc[]
>  
>  == AUTHORS
> diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
> index 13bf52915..8d37fdad7 100644
> --- a/sys-utils/fallocate.c
> +++ b/sys-utils/fallocate.c
> @@ -40,7 +40,7 @@
>  #if defined(HAVE_LINUX_FALLOC_H) && \
>      (!defined(FALLOC_FL_KEEP_SIZE) || !defined(FALLOC_FL_PUNCH_HOLE) || \
>       !defined(FALLOC_FL_COLLAPSE_RANGE) || !defined(FALLOC_FL_ZERO_RANGE) || \
> -     !defined(FALLOC_FL_INSERT_RANGE))
> +     !defined(FALLOC_FL_INSERT_RANGE) || !defined(FALLOC_FL_WRITE_ZEROES))
>  # include <linux/falloc.h>	/* non-libc fallback for FALLOC_FL_* flags */
>  #endif
>  
> @@ -65,6 +65,10 @@
>  # define FALLOC_FL_INSERT_RANGE		0x20
>  #endif
>  
> +#ifndef FALLOC_FL_WRITE_ZEROES
> +# define FALLOC_FL_WRITE_ZEROES		0x80
> +#endif
> +
>  #include "nls.h"
>  #include "strutils.h"
>  #include "c.h"
> @@ -94,6 +98,7 @@ static void __attribute__((__noreturn__)) usage(void)
>  	fputs(_(" -o, --offset <num>   offset for range operations, in bytes\n"), out);
>  	fputs(_(" -p, --punch-hole     replace a range with a hole (implies -n)\n"), out);
>  	fputs(_(" -z, --zero-range     zero and ensure allocation of a range\n"), out);
> +	fputs(_(" -w, --write-zeroes   write zeroes and ensure allocation of a range\n"), out);
>  #ifdef HAVE_POSIX_FALLOCATE
>  	fputs(_(" -x, --posix          use posix_fallocate(3) instead of fallocate(2)\n"), out);
>  #endif
> @@ -304,6 +309,7 @@ int main(int argc, char **argv)
>  	    { "dig-holes",      no_argument,       NULL, 'd' },
>  	    { "insert-range",   no_argument,       NULL, 'i' },
>  	    { "zero-range",     no_argument,       NULL, 'z' },
> +	    { "write-zeroes",   no_argument,       NULL, 'w' },
>  	    { "offset",         required_argument, NULL, 'o' },
>  	    { "length",         required_argument, NULL, 'l' },
>  	    { "posix",          no_argument,       NULL, 'x' },
> @@ -312,8 +318,8 @@ int main(int argc, char **argv)
>  	};
>  
>  	static const ul_excl_t excl[] = {	/* rows and cols in ASCII order */
> -		{ 'c', 'd', 'i', 'p', 'x', 'z'},
> -		{ 'c', 'i', 'n', 'x' },
> +		{ 'c', 'd', 'i', 'p', 'w', 'x', 'z'},
> +		{ 'c', 'i', 'n', 'w', 'x' },
>  		{ 0 }
>  	};
>  	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
> @@ -323,7 +329,7 @@ int main(int argc, char **argv)
>  	textdomain(PACKAGE);
>  	close_stdout_atexit();
>  
> -	while ((c = getopt_long(argc, argv, "hvVncpdizxl:o:", longopts, NULL))
> +	while ((c = getopt_long(argc, argv, "hvVncpdizwxl:o:", longopts, NULL))
>  			!= -1) {
>  
>  		err_exclusive_options(c, longopts, excl, excl_st);
> @@ -353,6 +359,9 @@ int main(int argc, char **argv)
>  		case 'z':
>  			mode |= FALLOC_FL_ZERO_RANGE;
>  			break;
> +		case 'w':
> +			mode |= FALLOC_FL_WRITE_ZEROES;
> +			break;
>  		case 'x':
>  #ifdef HAVE_POSIX_FALLOCATE
>  			posix = 1;
> @@ -429,6 +438,9 @@ int main(int argc, char **argv)
>  			else if (mode & FALLOC_FL_ZERO_RANGE)
>  				fprintf(stdout, _("%s: %s (%ju bytes) zeroed.\n"),
>  								filename, str, length);
> +			else if (mode & FALLOC_FL_WRITE_ZEROES)
> +				fprintf(stdout, _("%s: %s (%ju bytes) write zeroed.\n"),

"write zeroed" is a little strange, but I don't have a better
suggestion. :)

--D

> +								filename, str, length);
>  			else
>  				fprintf(stdout, _("%s: %s (%ju bytes) allocated.\n"),
>  								filename, str, length);
> -- 
> 2.39.2
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support
  2025-08-14 16:52 ` Darrick J. Wong
@ 2025-08-15  9:29   ` Zhang Yi
  2025-08-15 14:29     ` Darrick J. Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Yi @ 2025-08-15  9:29 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: linux-fsdevel, linux-block, dm-devel, linux-nvme, linux-scsi,
	linux-kernel, linux-api, hch, tytso, bmarzins, chaitanyak,
	shinichiro.kawasaki, brauner, martin.petersen, yi.zhang,
	chengzhihao1, yukuai3, yangerkun

Thank you for your review comments!

On 2025/8/15 0:52, Darrick J. Wong wrote:
> On Wed, Aug 13, 2025 at 10:40:15AM +0800, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> The Linux kernel (since version 6.17) supports FALLOC_FL_WRITE_ZEROES in
>> fallocate(2). Add support for FALLOC_FL_WRITE_ZEROES to the fallocate
>> utility by introducing a new option -w|--write-zeroes.
>>
>> Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
>> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
>> ---
>> v1->v2:
>>  - Minor description modification to align with the kernel.
>>
>>  sys-utils/fallocate.1.adoc | 11 +++++++++--
>>  sys-utils/fallocate.c      | 20 ++++++++++++++++----
>>  2 files changed, 25 insertions(+), 6 deletions(-)
>>
>> diff --git a/sys-utils/fallocate.1.adoc b/sys-utils/fallocate.1.adoc
>> index 44ee0ef4c..0ec9ff9a9 100644
>> --- a/sys-utils/fallocate.1.adoc
>> +++ b/sys-utils/fallocate.1.adoc
>> @@ -12,7 +12,7 @@ fallocate - preallocate or deallocate space to a file
> 
> <snip all the long lines>
> 
>> +*-w*, *--write-zeroes*::
>> +Zeroes space in the byte range starting at _offset_ and continuing
>> for _length_ bytes. Within the specified range, blocks are
>> preallocated for the regions that span the holes in the file. After a
>> successful call, subsequent reads from this range will return zeroes,
>> subsequent writes to that range do not require further changes to the
>> file mapping metadata.
> 
> "...will return zeroes and subsequent writes to that range..." ?
> 

Yeah.

>> ++
>> +Zeroing is done within the filesystem by preferably submitting write
> 
> I think we should say less about what the filesystem actually does to
> preserve some flexibility:
> 
> "Zeroing is done within the filesystem. The filesystem may use a
> hardware accelerated zeroing command, or it may submit regular writes.
> The behavior depends on the filesystem design and available hardware."
> 

Sure.

>> zeores commands, the alternative way is submitting actual zeroed data,
>> the specified range will be converted into written extents. The write
>> zeroes command is typically faster than write actual data if the
>> device supports unmap write zeroes, the specified range will not be
>> physically zeroed out on the device.
>> ++
>> +Options *--keep-size* can not be specified for the write-zeroes
>> operation.
>> +
>>  include::man-common/help-version.adoc[]
>>  
>>  == AUTHORS
[..]
>> @@ -429,6 +438,9 @@ int main(int argc, char **argv)
>>  			else if (mode & FALLOC_FL_ZERO_RANGE)
>>  				fprintf(stdout, _("%s: %s (%ju bytes) zeroed.\n"),
>>  								filename, str, length);
>> +			else if (mode & FALLOC_FL_WRITE_ZEROES)
>> +				fprintf(stdout, _("%s: %s (%ju bytes) write zeroed.\n"),
> 
> "write zeroed" is a little strange, but I don't have a better
> suggestion. :)
> 

Hmm... What about simply using "zeroed", the same to FALLOC_FL_ZERO_RANGE?
Users should be aware of the parameters they have passed to fallocate(),
so they should not use this print for further differentiation.

Thanks,
Yi.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support
  2025-08-15  9:29   ` Zhang Yi
@ 2025-08-15 14:29     ` Darrick J. Wong
  2025-08-18  2:17       ` Zhang Yi
  0 siblings, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2025-08-15 14:29 UTC (permalink / raw)
  To: Zhang Yi
  Cc: linux-fsdevel, linux-block, dm-devel, linux-nvme, linux-scsi,
	linux-kernel, linux-api, hch, tytso, bmarzins, chaitanyak,
	shinichiro.kawasaki, brauner, martin.petersen, yi.zhang,
	chengzhihao1, yukuai3, yangerkun

On Fri, Aug 15, 2025 at 05:29:19PM +0800, Zhang Yi wrote:
> Thank you for your review comments!
> 
> On 2025/8/15 0:52, Darrick J. Wong wrote:
> > On Wed, Aug 13, 2025 at 10:40:15AM +0800, Zhang Yi wrote:
> >> From: Zhang Yi <yi.zhang@huawei.com>
> >>
> >> The Linux kernel (since version 6.17) supports FALLOC_FL_WRITE_ZEROES in
> >> fallocate(2). Add support for FALLOC_FL_WRITE_ZEROES to the fallocate
> >> utility by introducing a new option -w|--write-zeroes.
> >>
> >> Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
> >> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> >> ---
> >> v1->v2:
> >>  - Minor description modification to align with the kernel.
> >>
> >>  sys-utils/fallocate.1.adoc | 11 +++++++++--
> >>  sys-utils/fallocate.c      | 20 ++++++++++++++++----
> >>  2 files changed, 25 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/sys-utils/fallocate.1.adoc b/sys-utils/fallocate.1.adoc
> >> index 44ee0ef4c..0ec9ff9a9 100644
> >> --- a/sys-utils/fallocate.1.adoc
> >> +++ b/sys-utils/fallocate.1.adoc
> >> @@ -12,7 +12,7 @@ fallocate - preallocate or deallocate space to a file
> > 
> > <snip all the long lines>
> > 
> >> +*-w*, *--write-zeroes*::
> >> +Zeroes space in the byte range starting at _offset_ and continuing
> >> for _length_ bytes. Within the specified range, blocks are
> >> preallocated for the regions that span the holes in the file. After a
> >> successful call, subsequent reads from this range will return zeroes,
> >> subsequent writes to that range do not require further changes to the
> >> file mapping metadata.
> > 
> > "...will return zeroes and subsequent writes to that range..." ?
> > 
> 
> Yeah.
> 
> >> ++
> >> +Zeroing is done within the filesystem by preferably submitting write
> > 
> > I think we should say less about what the filesystem actually does to
> > preserve some flexibility:
> > 
> > "Zeroing is done within the filesystem. The filesystem may use a
> > hardware accelerated zeroing command, or it may submit regular writes.
> > The behavior depends on the filesystem design and available hardware."
> > 
> 
> Sure.
> 
> >> zeores commands, the alternative way is submitting actual zeroed data,
> >> the specified range will be converted into written extents. The write
> >> zeroes command is typically faster than write actual data if the
> >> device supports unmap write zeroes, the specified range will not be
> >> physically zeroed out on the device.
> >> ++
> >> +Options *--keep-size* can not be specified for the write-zeroes
> >> operation.
> >> +
> >>  include::man-common/help-version.adoc[]
> >>  
> >>  == AUTHORS
> [..]
> >> @@ -429,6 +438,9 @@ int main(int argc, char **argv)
> >>  			else if (mode & FALLOC_FL_ZERO_RANGE)
> >>  				fprintf(stdout, _("%s: %s (%ju bytes) zeroed.\n"),
> >>  								filename, str, length);
> >> +			else if (mode & FALLOC_FL_WRITE_ZEROES)
> >> +				fprintf(stdout, _("%s: %s (%ju bytes) write zeroed.\n"),
> > 
> > "write zeroed" is a little strange, but I don't have a better
> > suggestion. :)
> > 
> 
> Hmm... What about simply using "zeroed", the same to FALLOC_FL_ZERO_RANGE?
> Users should be aware of the parameters they have passed to fallocate(),
> so they should not use this print for further differentiation.

No thanks, different inputs should produce different outputs. :)

--D

> Thanks,
> Yi.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support
  2025-08-15 14:29     ` Darrick J. Wong
@ 2025-08-18  2:17       ` Zhang Yi
  0 siblings, 0 replies; 5+ messages in thread
From: Zhang Yi @ 2025-08-18  2:17 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: linux-fsdevel, linux-block, dm-devel, linux-nvme, linux-scsi,
	linux-kernel, linux-api, hch, tytso, bmarzins, chaitanyak,
	shinichiro.kawasaki, brauner, martin.petersen, yi.zhang,
	chengzhihao1, yukuai3, yangerkun

On 8/15/2025 10:29 PM, Darrick J. Wong wrote:
> On Fri, Aug 15, 2025 at 05:29:19PM +0800, Zhang Yi wrote:
>> Thank you for your review comments!
>>
>> On 2025/8/15 0:52, Darrick J. Wong wrote:
>>> On Wed, Aug 13, 2025 at 10:40:15AM +0800, Zhang Yi wrote:
>>>> From: Zhang Yi <yi.zhang@huawei.com>
>>>>
>>>> The Linux kernel (since version 6.17) supports FALLOC_FL_WRITE_ZEROES in
>>>> fallocate(2). Add support for FALLOC_FL_WRITE_ZEROES to the fallocate
>>>> utility by introducing a new option -w|--write-zeroes.
>>>>
>>>> Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
>>>> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
>>>> ---
>>>> v1->v2:
>>>>  - Minor description modification to align with the kernel.
>>>>
>>>>  sys-utils/fallocate.1.adoc | 11 +++++++++--
>>>>  sys-utils/fallocate.c      | 20 ++++++++++++++++----
>>>>  2 files changed, 25 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/sys-utils/fallocate.1.adoc b/sys-utils/fallocate.1.adoc
>>>> index 44ee0ef4c..0ec9ff9a9 100644
>>>> --- a/sys-utils/fallocate.1.adoc
>>>> +++ b/sys-utils/fallocate.1.adoc
>>>> @@ -12,7 +12,7 @@ fallocate - preallocate or deallocate space to a file
>>>
>>> <snip all the long lines>
>>>
>>>> +*-w*, *--write-zeroes*::
>>>> +Zeroes space in the byte range starting at _offset_ and continuing
>>>> for _length_ bytes. Within the specified range, blocks are
>>>> preallocated for the regions that span the holes in the file. After a
>>>> successful call, subsequent reads from this range will return zeroes,
>>>> subsequent writes to that range do not require further changes to the
>>>> file mapping metadata.
>>>
>>> "...will return zeroes and subsequent writes to that range..." ?
>>>
>>
>> Yeah.
>>
>>>> ++
>>>> +Zeroing is done within the filesystem by preferably submitting write
>>>
>>> I think we should say less about what the filesystem actually does to
>>> preserve some flexibility:
>>>
>>> "Zeroing is done within the filesystem. The filesystem may use a
>>> hardware accelerated zeroing command, or it may submit regular writes.
>>> The behavior depends on the filesystem design and available hardware."
>>>
>>
>> Sure.
>>
>>>> zeores commands, the alternative way is submitting actual zeroed data,
>>>> the specified range will be converted into written extents. The write
>>>> zeroes command is typically faster than write actual data if the
>>>> device supports unmap write zeroes, the specified range will not be
>>>> physically zeroed out on the device.
>>>> ++
>>>> +Options *--keep-size* can not be specified for the write-zeroes
>>>> operation.
>>>> +
>>>>  include::man-common/help-version.adoc[]
>>>>  
>>>>  == AUTHORS
>> [..]
>>>> @@ -429,6 +438,9 @@ int main(int argc, char **argv)
>>>>  			else if (mode & FALLOC_FL_ZERO_RANGE)
>>>>  				fprintf(stdout, _("%s: %s (%ju bytes) zeroed.\n"),
>>>>  								filename, str, length);
>>>> +			else if (mode & FALLOC_FL_WRITE_ZEROES)
>>>> +				fprintf(stdout, _("%s: %s (%ju bytes) write zeroed.\n"),
>>>
>>> "write zeroed" is a little strange, but I don't have a better
>>> suggestion. :)
>>>
>>
>> Hmm... What about simply using "zeroed", the same to FALLOC_FL_ZERO_RANGE?
>> Users should be aware of the parameters they have passed to fallocate(),
>> so they should not use this print for further differentiation.
> 
> No thanks, different inputs should produce different outputs. :)
> 

OK. perhaps "written as zeros." ? Sounds OK?

Thanks,
Yi.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-18  2:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13  2:40 [PATCH util-linux v2] fallocate: add FALLOC_FL_WRITE_ZEROES support Zhang Yi
2025-08-14 16:52 ` Darrick J. Wong
2025-08-15  9:29   ` Zhang Yi
2025-08-15 14:29     ` Darrick J. Wong
2025-08-18  2:17       ` Zhang Yi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).