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[]
* 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>
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 */
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"),