On 2/21/24 02:11, Keith Busch wrote: > From: Keith Busch <kbusch@xxxxxxxxxx> > > If a user runs something like `blkdiscard -z /dev/sda`, and the device > does not have an efficient write zero offload, the kernel will dispatch > long chains of bio's using the ZERO_PAGE for the entire capacity of the > device. If the capacity is very large, this process could take a long > time in an uninterruptable state, which the user may want to abort. > Check between batches for the user's request to kill the process so they > don't need to wait potentially many hours. > > Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx> > --- > block/blk-lib.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/block/blk-lib.c b/block/blk-lib.c > index e59c3069e8351..d5c334aa98e0d 100644 > --- a/block/blk-lib.c > +++ b/block/blk-lib.c > @@ -190,6 +190,8 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev, > break; > } > cond_resched(); > + if (fatal_signal_pending(current)) > + break; > } > > *biop = bio; I have an NVMe device which supports write offload. The total size of this disk is ~1.5 TB. When I tried zero out the whole NVMe drive it took more than 10 minutes. Please see below: # cat /sys/block/nvme0n1/queue/write_zeroes_max_bytes 8388608 # nvme id-ns /dev/nvme0n1 -H NVME Identify Namespace 1: nsze : 0x1749a956 ncap : 0x1749a956 nuse : 0x1749a956 <snip> nvmcap : 1600321314816 <snip> LBA Format 0 : Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best (in use) <snip> # time blkdiscard -z /dev/nvme0n1 real 10m27.514s user 0m0.000s sys 0m0.369s So shouldn't we need to add the same code (allowing user to kill the process) under __blkdev_issue_write_zeroes()? I think even though a drive supports "write zero offload", if drive has a very large capacity then it would take up a lot of time to zero out the complete drive. Yes the time required may not be in hours in this case but it could be in tens of minutes depending on the drive capacity. Thanks, --Nilay