]> git.proxmox.com Git - mirror_zfs.git/commit - module/zfs/zfs_ioctl.c
Allow for lock-free reading zfsdev_state_list.
authorTim Chase <tim@chase2k.com>
Thu, 8 May 2014 14:51:01 +0000 (09:51 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 19 May 2014 18:45:11 +0000 (11:45 -0700)
commit3937ab20f32fc7b79cacfd91c0891f4e1b4ab2de
tree485d588f306837e2d2d271d1b3cc01cd1d67d2e8
parent1cbae971c5ef215d1036b65511a839879e446c4c
Allow for lock-free reading zfsdev_state_list.

Restructure the zfsdev_state_list to allow for lock-free reading by
converting to a simple singly-linked list from which items are never
deleted and over which only forward iterations are performed.  It depends
on, among other things, the atomicity of accessing the zs_minor integer
and zs_next pointer.

This fixes a lock inversion in which the zfsdev_state_lock is used by
both the sync task (txg_sync) and indirectly by any user program which
uses /dev/zfs; the zfsdev_release method uses the same lock and then
blocks on the sync task.

The most typical failure scenerio occurs when the sync task is cleaning
up a user hold while various concurrent "zfs" commands are in progress.

Neither Illumos nor Solaris are affected by this issue because they use
DDI interface which provides lock-free reading of device state via the
ddi_get_soft_state() function.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2301
include/sys/zfs_ioctl.h
module/zfs/zfs_ioctl.c