Pre-allocate vdev I/O buffers
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 20 Aug 2012 00:17:02 +0000 (17:17 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 27 Aug 2012 19:01:37 +0000 (12:01 -0700)
commit86dd0fd9222b6103c6533036c47b908ece944460
tree4dc2e9bcfcca485ccbc6dc11e255748b8023faad
parent44f21da41c441bfceec7b825991b6e68321d78a2
Pre-allocate vdev I/O buffers

The vdev queue layer may require a small number of buffers
when attempting to create aggregate I/O requests.  Rather than
attempting to allocate them from the global zio buffers, which
is slow under memory pressure, it makes sense to pre-allocate
them because...

1) These buffers are short lived.  They are only required for
the life of a single I/O at which point they can be used by
the next I/O.

2) The maximum number of concurrent buffers needed by a vdev is
small.  It's roughly limited by the zfs_vdev_max_pending tunable
which defaults to 10.

By keeping a small list of these buffer per-vdev we can ensure
one is always available when we need it.  This significantly
reduces contention on the vq->vq_lock, because we no longer
need to perform a slow allocation under this lock.  This is
particularly important when memory is already low on the system.

It would probably be wise to extend the use of these buffers beyond
aggregate I/O and in to the raidz implementation.  The inability
to quickly allocate buffer for the parity stripes could result in
similiar problems.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
include/sys/vdev_impl.h
include/sys/zio.h
module/zfs/vdev_queue.c
module/zfs/zio.c