Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: stop using discards for zeroing

Now that we have REQ_OP_WRITE_ZEROES implemented for all devices that
support efficient zeroing, we can remove the call to blkdev_issue_discard.
This means we only have two ways of zeroing left and can simplify the
code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Christoph Hellwig and committed by
Jens Axboe
71027e97 5d1429fe

+6 -6
+6 -6
block/blk-lib.c
··· 279 279 * Zero-fill a block range, either using hardware offload or by explicitly 280 280 * writing zeroes to the device. 281 281 * 282 + * Note that this function may fail with -EOPNOTSUPP if the driver signals 283 + * zeroing offload support, but the device fails to process the command (for 284 + * some devices there is no non-destructive way to verify whether this 285 + * operation is actually supported). In this case the caller should call 286 + * retry the call to blkdev_issue_zeroout() and the fallback path will be used. 287 + * 282 288 * If a device is using logical block provisioning, the underlying space will 283 289 * not be released if %flags contains BLKDEV_ZERO_NOUNMAP. 284 290 * ··· 354 348 int ret; 355 349 struct bio *bio = NULL; 356 350 struct blk_plug plug; 357 - 358 - if (!(flags & BLKDEV_ZERO_NOUNMAP)) { 359 - if (!blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 360 - BLKDEV_DISCARD_ZERO)) 361 - return 0; 362 - } 363 351 364 352 blk_start_plug(&plug); 365 353 ret = __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask,