]> git.proxmox.com Git - mirror_zfs.git/commit
Limit the number of blocks to discard at once.
authorEtienne Dechamps <etienne.dechamps@ovh.net>
Tue, 31 Jul 2012 08:45:37 +0000 (10:45 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 31 Jul 2012 16:46:09 +0000 (09:46 -0700)
commit7c0e570888532b3cecf66459e55688df18946be0
tree2f78e22bc0a86c02e9d07f36781b74e699deaf1a
parent330d06f90d143b41b276796526a66a1c1fff046d
Limit the number of blocks to discard at once.

The number of blocks that can be discarded in one BLKDISCARD ioctl on a
zvol is currently unlimited. Some applications, such as mkfs, discard
the whole volume at once and they use the maximum possible discard size
to do that. As a result, several gigabytes discard requests are not
uncommon.

Unfortunately, if a large amount of data is allocated in the zvol, ZFS
can be quite slow to process discard requests. This is especially true
if the volblocksize is low (e.g. the 8K default). As a result, very
large discard requests can take a very long time (seconds to minutes
under heavy load) to complete. This can cause a number of problems, most
notably if the zvol is accessed remotely (e.g. via iSCSI), in which case
the client has a high probability of timing out on the request.

This patch solves the issue by adding a new tunable module parameter:
zvol_max_discard_blocks. This indicates the maximum possible range, in
zvol blocks, of one discard operation. It is set by default to 16384
blocks, which appears to be a good tradeoff. Using the default
volblocksize of 8K this is equivalent to 128 MB. When using the maximum
volblocksize of 128K this is equivalent to 2 GB.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #858
module/zfs/zvol.c