Skip to contentSkip to conversation

fallocate.2: Document FALLOC_FL_ZERO_RANGE

PATCH In review Lukas Czerner 3 participants 10 messages Apr 17, 2014 – May 5, 2014 9 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fallocate.2: Document FALLOC_FL_ZERO_RANGE

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
 man2/fallocate.2 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
man2/fallocate.2 +41 -0
index b31bbde..df31782 100644
@@ -124,6 +124,45 @@ Btrfs (since Linux 3.7)
 .IP *
 tmpfs (since Linux 3.5)
 .\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued.
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -193,6 +232,8 @@ Or:
 .I mode
 specifies
 .BR FALLOC_FL_PUNCH_HOLE
+or
+.BR FALLOC_FL_ZERO_RANGE
 and
 the file referred to by
 .I fd
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): 1397741451-19161-1-git-send-email-lczerner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

Lukas,

Thanks for the patch.

Two general comments:
* The text does not explain what zeroing file space is about and why one would do it. For example, I'm a little unclear after reading it whether FALLOC_FL_ZERO_RANGE will create a hole in a file.
* Some entries should probably be added to ERRORS.

Could you fix both of those and resubmit?

Note that I've just pushed some changes to the page for FALLOC_FL_COLLAPSE_RANGE, so you may want to pull the latest version to ensure there are no conflicts.

Cheers,

Michael

Quoted 68 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
 man2/fallocate.2 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
man2/fallocate.2 +41 -0
index b31bbde..df31782 100644
@@ -124,6 +124,45 @@ Btrfs (since Linux 3.7)
 .IP *
 tmpfs (since Linux 3.5)
 .\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued.
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -193,6 +232,8 @@ Or:
 .I mode
 specifies
 .BR FALLOC_FL_PUNCH_HOLE
+or
+.BR FALLOC_FL_ZERO_RANGE
 and
 the file referred to by
 .I fd
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 7 lines · Michael Kerrisk (man-pages)

Date: Fri, 18 Apr 2014 17:49:48 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Subject: Re: [PATCH] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Quoted 8 lines

Lukas,

Thanks for the patch.

Two general comments:
* The text does not explain what zeroing file space is about and why one would do it. For example, I'm a little unclear after reading it whether FALLOC_FL_ZERO_RANGE will create a hole in a file.

It is saying that blocks are preallocated for the regions that span holes in the file. And there isn't anything saying about punching a hole into the file. But I guess I can be more clear about it.

Quoted 3 lines

* Some entries should probably be added to ERRORS.

Could you fix both of those and resubmit?

Sure I'll do that next week.

Quoted 71 lines

Note that I've just pushed some changes to the page for FALLOC_FL_COLLAPSE_RANGE, so you may want to pull the latest version to ensure there are no conflicts.

Cheers,

Michael

Quoted 60 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
 man2/fallocate.2 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
man2/fallocate.2 +39 -0
index b31bbde..df31782 100644
@@ -124,6 +124,45 @@ Btrfs (since Linux 3.7)
 .IP *
 tmpfs (since Linux 3.5)
 .\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued.
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -193,6 +232,8 @@ Or:
 .I mode
Quoted 11 lines

man2/fallocate.2 Or: · line 239

Quoted 8 lines
man2/fallocate.2 +2 -0
 specifies
 .BR FALLOC_FL_PUNCH_HOLE
+or
+.BR FALLOC_FL_ZERO_RANGE
 and
 the file referred to by
 .I fd

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): alpine.LFD.2.00.1404181819470.2128-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#6 lore raw

Ping, Lukáš!

Quoted 110 lines · Lukáš Czerner
Quoted 7 lines · Michael Kerrisk (man-pages)

Date: Fri, 18 Apr 2014 17:49:48 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Subject: Re: [PATCH] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Quoted 8 lines

Lukas,

Thanks for the patch.

Two general comments:
* The text does not explain what zeroing file space is about and why one would do it. For example, I'm a little unclear after reading it whether FALLOC_FL_ZERO_RANGE will create a hole in a file.

It is saying that blocks are preallocated for the regions that span holes in the file. And there isn't anything saying about punching a hole into the file. But I guess I can be more clear about it.

Quoted 3 lines

* Some entries should probably be added to ERRORS.

Could you fix both of those and resubmit?

Sure I'll do that next week.

Quoted 82 lines

Note that I've just pushed some changes to the page for FALLOC_FL_COLLAPSE_RANGE, so you may want to pull the latest version to ensure there are no conflicts.

Cheers,

Michael

Quoted 68 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
 man2/fallocate.2 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
man2/fallocate.2 +41 -0
index b31bbde..df31782 100644
@@ -124,6 +124,45 @@ Btrfs (since Linux 3.7)
 .IP *
 tmpfs (since Linux 3.5)
 .\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued.
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -193,6 +232,8 @@ Or:
 .I mode
 specifies
 .BR FALLOC_FL_PUNCH_HOLE
+or
+.BR FALLOC_FL_ZERO_RANGE
 and
 the file referred to by
 .I fd
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAKgNAkibmSZBD4ThhuGg7sJuGBVR+pfMe30b-HXQ0BhYr1Uy2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

PATCH v2 1/1 fallocate.2: Document FALLOC_FL_ZERO_RANGE

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +45 -1
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1398866967-26887-1-git-send-email-lczerner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#10 lore raw

Hi Lukas

Quoted 26 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +8 -0
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for

man2/fallocate.2 ext4 (only for extent-based files) · line 200

Quoted 10 lines
man2/fallocate.2 +10 -0
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.

I just want to confirm my understanding of what's going on here. FALLOC_FL_ZERO_RANGE is serving at least two purposes:
1. Future reads from the specified range will return zero.
2. Blocks (in the form of extents) will be preallocated for the holes in the range, thus ensuring that the necessary storage space is allocated for the file. However, those allocated blocks won't actually be written to. (Metadata trickery will ensure that reads from that region won't actually touch the blocks; the kernel will simply deliver back zeroes.)

Right?

And a question: does FALLOC_FL_ZERO_RANGE work for non-extent-based filesystems? If yes, how is FALLOC_FL_ZERO_RANGE implemented? Are the blocks corresponding to a hole actually allocated and explicitly written with zeroes?

Cheers,

Michael

Quoted 39 lines
man2/fallocate.2 +27 -1
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 56 lines · Michael Kerrisk (man-pages)

Date: Wed, 30 Apr 2014 16:48:42 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Hi Lukas

Quoted 26 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +8 -0
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for

man2/fallocate.2 ext4 (only for extent-based files) · line 200

Quoted 10 lines
man2/fallocate.2 +10 -0
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.

I just want to confirm my understanding of what's going on here. FALLOC_FL_ZERO_RANGE is serving at least two purposes:
1. Future reads from the specified range will return zero.
2. Blocks (in the form of extents) will be preallocated for the holes in the range, thus ensuring that the necessary storage space is allocated for the file. However, those allocated blocks won't actually be written to. (Metadata trickery will ensure that reads from that region won't actually touch the blocks; the kernel will simply deliver back zeroes.)

Quoted 1 line

Right?

Yes, that's exactly right.

Quoted 5 lines

And a question: does FALLOC_FL_ZERO_RANGE work for non-extent-based filesystems? If yes, how is FALLOC_FL_ZERO_RANGE implemented? Are the blocks corresponding to a hole actually allocated and explicitly written with zeroes?

As it is now, FALLOC_FL_ZERO_RANGE does not work on non-extent based files. This is also the case for collapse range and the regular preallocation at least in ext4 case.

Thanks!
-Lukas

Quoted 37 lines

Cheers,

Michael

Quoted 31 lines
man2/fallocate.2 +24 -0
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
Quoted 11 lines

man2/fallocate.2 no other flags are permitted with · line 293

Quoted 8 lines
man2/fallocate.2 +3 -1
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): alpine.LFD.2.00.1404301651060.2100-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#14 lore raw

Lukáš,

Quoted 58 lines · Lukáš Czerner
Quoted 56 lines · Michael Kerrisk (man-pages)

Date: Wed, 30 Apr 2014 16:48:42 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Hi Lukas

Quoted 26 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +8 -0
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for

man2/fallocate.2 ext4 (only for extent-based files) · line 200

Quoted 10 lines
man2/fallocate.2 +10 -0
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.

I just want to confirm my understanding of what's going on here. FALLOC_FL_ZERO_RANGE is serving at least two purposes:
1. Future reads from the specified range will return zero.
2. Blocks (in the form of extents) will be preallocated for the holes in the range, thus ensuring that the necessary storage space is allocated for the file. However, those allocated blocks won't actually be written to. (Metadata trickery will ensure that reads from that region won't actually touch the blocks; the kernel will simply deliver back zeroes.)

Quoted 3 lines
Quoted 1 line

Right?

Yes, that's exactly right.

Thanks.

Quoted 8 lines
Quoted 4 lines

And a question: does FALLOC_FL_ZERO_RANGE work for non-extent-based filesystems? If yes, how is FALLOC_FL_ZERO_RANGE implemented? Are the blocks corresponding to a hole actually allocated and explicitly written with zeroes?

As it is now, FALLOC_FL_ZERO_RANGE does not work on non-extent based files. This is also the case for collapse range and the regular preallocation at least in ext4 case.

Okay -- see my comment below..

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
man2/fallocate.2 +16 -0
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
Quoted 8 lines
Quoted 8 lines

man2/fallocate.2 ext4 (only for extent-based files) · line 224

Quoted 8 lines
man2/fallocate.2 +8 -0
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+

So for these two cases, XFS and ext4, should we perhaps better say

XFS, for extent based files (since Linux 3.14) ext4, for extent based files (since Linux 3.14)
?

Cheers,

Michael

Quoted 19 lines
Quoted 18 lines
Quoted 15 lines
man2/fallocate.2 +3 -1
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

Hi Lukáš

Ping on the question below...

Cheers,

Michael

Quoted 135 lines · Michael Kerrisk (man-pages)

Lukáš,

Quoted 58 lines · Lukáš Czerner
Quoted 56 lines · Michael Kerrisk (man-pages)

Date: Wed, 30 Apr 2014 16:48:42 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Hi Lukas

Quoted 26 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +8 -0
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for

man2/fallocate.2 ext4 (only for extent-based files) · line 200

Quoted 10 lines
man2/fallocate.2 +10 -0
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.

I just want to confirm my understanding of what's going on here. FALLOC_FL_ZERO_RANGE is serving at least two purposes:
1. Future reads from the specified range will return zero.
2. Blocks (in the form of extents) will be preallocated for the holes in the range, thus ensuring that the necessary storage space is allocated for the file. However, those allocated blocks won't actually be written to. (Metadata trickery will ensure that reads from that region won't actually touch the blocks; the kernel will simply deliver back zeroes.)

Quoted 3 lines
Quoted 1 line

Right?

Yes, that's exactly right.

Thanks.

Quoted 8 lines
Quoted 4 lines

And a question: does FALLOC_FL_ZERO_RANGE work for non-extent-based filesystems? If yes, how is FALLOC_FL_ZERO_RANGE implemented? Are the blocks corresponding to a hole actually allocated and explicitly written with zeroes?

As it is now, FALLOC_FL_ZERO_RANGE does not work on non-extent based files. This is also the case for collapse range and the regular preallocation at least in ext4 case.

Okay -- see my comment below..

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
man2/fallocate.2 +16 -0
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
Quoted 8 lines
Quoted 8 lines

man2/fallocate.2 ext4 (only for extent-based files) · line 224

Quoted 8 lines
man2/fallocate.2 +8 -0
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+

So for these two cases, XFS and ext4, should we perhaps better say

XFS, for extent based files (since Linux 3.14) ext4, for extent based files (since Linux 3.14)
?

Cheers,

Michael

Quoted 19 lines
Quoted 18 lines
Quoted 15 lines
man2/fallocate.2 +3 -1
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw
Quoted 8 lines · Michael Kerrisk (man-pages)

Date: Sat, 03 May 2014 05:07:40 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukáš Czerner <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH v2] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Hi Lukáš

Quoted 114 lines

Ping on the question below...

Cheers,

Michael

Quoted 106 lines · Michael Kerrisk (man-pages)

Lukáš,

Quoted 58 lines · Lukáš Czerner
Quoted 56 lines · Michael Kerrisk (man-pages)

Date: Wed, 30 Apr 2014 16:48:42 +0200
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Lukas Czerner <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2] fallocate.2: Document FALLOC_FL_ZERO_RANGE

Hi Lukas

Quoted 26 lines · Lukas Czerner

FALLOC_FL_ZERO_RANGE was added in Linux 3.14, for zeroing ranges in the allocated space in a file.

---
v2: Rebase and update the description

 man2/fallocate.2 | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
man2/fallocate.2 +8 -0
index 73c4f12..30f27c3 100644
@@ -180,6 +180,48 @@ ext4 (only for extent-based files)
 .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e
 and XFS.
 .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d
+.SS Zeroing file space
+Specifying
+.BR FALLOC_FL_ZERO_RANGE
+flag (available since Linux 3.14) in
+.I mode
+zeroes space in the byte range starting at
+.I offset
+and continuing for

man2/fallocate.2 ext4 (only for extent-based files) · line 200

Quoted 10 lines
man2/fallocate.2 +10 -0
+.I len
+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.
+
+Zeroing is done within the file system preferably by converting range into
+unwritten extents which requires very little IO to be issued mostly for
+metadata. This means that the range will not be physically zeroed out
+on the device.

I just want to confirm my understanding of what's going on here. FALLOC_FL_ZERO_RANGE is serving at least two purposes:
1. Future reads from the specified range will return zero.
2. Blocks (in the form of extents) will be preallocated for the holes in the range, thus ensuring that the necessary storage space is allocated for the file. However, those allocated blocks won't actually be written to. (Metadata trickery will ensure that reads from that region won't actually touch the blocks; the kernel will simply deliver back zeroes.)

Quoted 3 lines
Quoted 1 line

Right?

Yes, that's exactly right.

Thanks.

Quoted 8 lines
Quoted 4 lines

And a question: does FALLOC_FL_ZERO_RANGE work for non-extent-based filesystems? If yes, how is FALLOC_FL_ZERO_RANGE implemented? Are the blocks corresponding to a hole actually allocated and explicitly written with zeroes?

As it is now, FALLOC_FL_ZERO_RANGE does not work on non-extent based files. This is also the case for collapse range and the regular preallocation at least in ext4 case.

Okay -- see my comment below..

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
man2/fallocate.2 +16 -0
+
+If the
+.B FALLOC_FL_KEEP_SIZE
+flag is specified in
+.IR mode ,
+the behavior of the call is similar,
+but the file size will not be changed even if
+.IR offset + len
+is greater than the file size. This behaviour is the same as when
+preallocating space with
+.B FALLOC_FL_KEEP_SIZE
+specified.
+
+Not all filesystems support
+.BR FALLOC_FL_ZERO_RANGE ;
+if a filesystem doesn't support the operation, an error is returned.
Quoted 8 lines
Quoted 8 lines

man2/fallocate.2 ext4 (only for extent-based files) · line 224

Quoted 8 lines
man2/fallocate.2 +8 -0
+The operation is supported on at least the following filesystems
+.IP * 3
+XFS (since Linux 2.14)
+.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa
+.IP *
+ext4 (since Linux 3.14)
+.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0
+

So for these two cases, XFS and ext4, should we perhaps better say

XFS, for extent based files (since Linux 3.14)

XFS does not have non-extent based files. I'll resend.

Thanks!
-Lukas

Quoted 32 lines
Quoted 29 lines

ext4, for extent based files (since Linux 3.14)
?

Cheers,

Michael

Quoted 19 lines
Quoted 18 lines
Quoted 15 lines
man2/fallocate.2 +3 -1
 .SH RETURN VALUE
 On success,
 .BR fallocate ()
@@ -243,7 +285,9 @@ no other flags are permitted with
 .B EINVAL
 .I mode
 is
-.BR FALLOC_FL_COLLAPSE_RANGE ,
+.BR FALLOC_FL_COLLAPSE_RANGE
+or
+.BR FALLOC_FL_ZERO_RANGE,
 but the file referred to by
 .I fd
 is not a regular file.