]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: update FALLOC_FL_WRITE_ZEROES
authorKarel Zak <kzak@redhat.com>
Mon, 1 Sep 2025 12:10:17 +0000 (14:10 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 1 Sep 2025 12:10:17 +0000 (14:10 +0200)
Update to Zhang Yi's latest version of the patch.

Unfortunately, I missed that he was still working on it (it was sent
to the kernel mailing lists rather than the util-linux mailing list).

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fallocate.1.adoc
sys-utils/fallocate.c

index 0ec9ff9a9e58d5fdcd65eac04656a68733a3868c..69602f01c550fb282debd409f2f9f670c39b6509 100644 (file)
@@ -77,11 +77,11 @@ 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.
+Zeroes space in the byte range starting at _offset_ and continuing for _length_ bytes. Within the specified range, written 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 and 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.
+Zeroing is done within the filesystem. The filesystem may use a hardware-accelerated zeroing command or may submit regular writes. The behavior depends on the filesystem design and the available hardware.
 +
-Options *--keep-size* can not be specified for the write-zeroes operation.
+Options *--keep-size* cannot be specified for the write-zeroes operation because allocating written blocks beyond the inode size is not permitted.
 
 include::man-common/help-version.adoc[]
 
index 8d37fdad74fb4ae212cb67857fd8d328ae253ff1..30c391406e7b93768b50854879c47571d120f657 100644 (file)
@@ -17,8 +17,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <https://gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -395,16 +396,16 @@ int main(int argc, char **argv)
                if (length == -2LL)
                        length = 0;
                if (length < 0)
-                       errx(EXIT_FAILURE, _("invalid length"));
+                       errx(EXIT_FAILURE, _("invalid length value specified"));
        } else {
                /* it's safer to require the range specification (--length --offset) */
                if (length == -2LL)
                        errx(EXIT_FAILURE, _("no length argument specified"));
                if (length <= 0)
-                       errx(EXIT_FAILURE, _("invalid length"));
+                       errx(EXIT_FAILURE, _("invalid length value specified"));
        }
        if (offset < 0)
-               errx(EXIT_FAILURE, _("invalid offset"));
+               errx(EXIT_FAILURE, _("invalid offset value specified"));
 
        /* O_CREAT makes sense only for the default fallocate(2) behavior
         * when mode is no specified and new space is allocated */
@@ -439,7 +440,7 @@ int main(int argc, char **argv)
                                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"),
+                               fprintf(stdout, _("%s: %s (%ju bytes) written as zeroes.\n"),
                                                                filename, str, length);
                        else
                                fprintf(stdout, _("%s: %s (%ju bytes) allocated.\n"),