Thread (24 messages) 24 messages, 3 authors, 2025-06-16

Re: [PATCH 09/10] block: add FALLOC_FL_WRITE_ZEROES support

From: Christoph Hellwig <hch@lst.de>
Date: 2025-06-11 06:11:04
Also in: dm-devel, linux-block, linux-fsdevel, linux-nvme, linux-scsi, linux-xfs, lkml

On Wed, Jun 04, 2025 at 10:08:49AM +0800, Zhang Yi wrote:
quoted hunk ↗ jump to hunk
@@ -856,6 +856,13 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
 	/* Fail if we don't recognize the flags. */
 	if (mode & ~BLKDEV_FALLOC_FL_SUPPORTED)
 		return -EOPNOTSUPP;
+	/*
+	 * Don't allow writing zeroes if the device does not enable the
+	 * unmap write zeroes operation.
+	 */
+	if (!bdev_write_zeroes_unmap(bdev) &&
+	    (mode & FALLOC_FL_WRITE_ZEROES))
Cosmetic nitpick, but I'd turn the check around to check the mode first
as that's easier to read.  The whole check also fits onto a single line:

	if ((mode & FALLOC_FL_WRITE_ZEROES) && !bdev_write_zeroes_unmap(bdev))

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help