mirror_zfs/module/os/linux/zfs
loli10K 2a0d41889e Scrubbing root pools may deadlock on kernels without elevator_change() (#9321)
Originally the zfs_vdev_elevator module option was added as a
convenience so the requested elevator would be automatically set
on the underlying block devices. At the time this was simple
because the kernel provided an API function which did exactly this.

This API was then removed in the Linux 4.12 kernel which prompted
us to add compatibly code to set the elevator via a usermodehelper.

Unfortunately changing the evelator via usermodehelper requires reading
some userland binaries, most notably modprobe(8) or sh(1), from a zfs
dataset on systems with root-on-zfs. This can deadlock the system if
used during the following call path because it may need, if the data
is not already cached in the ARC, reading directly from disk while
holding the spa config lock as a writer:

  zfs_ioc_pool_scan()
    -> spa_scan()
      -> spa_scan()
        -> vdev_reopen()
          -> vdev_elevator_switch()
            -> call_usermodehelper()

While the usermodehelper waits sh(1), modprobe(8) is blocked in the
ZIO pipeline trying to read from disk:

  INFO: task modprobe:2650 blocked for more than 10 seconds.
       Tainted: P           OE     5.2.14
  modprobe        D    0  2650    206 0x00000000
  Call Trace:
   ? __schedule+0x244/0x5f0
   schedule+0x2f/0xa0
   cv_wait_common+0x156/0x290 [spl]
   ? do_wait_intr_irq+0xb0/0xb0
   spa_config_enter+0x13b/0x1e0 [zfs]
   zio_vdev_io_start+0x51d/0x590 [zfs]
   ? tsd_get_by_thread+0x3b/0x80 [spl]
   zio_nowait+0x142/0x2f0 [zfs]
   arc_read+0xb2d/0x19d0 [zfs]
   ...
   zpl_iter_read+0xfa/0x170 [zfs]
   new_sync_read+0x124/0x1b0
   vfs_read+0x91/0x140
   ksys_read+0x59/0xd0
   do_syscall_64+0x4f/0x130
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

This commit changes how we use the usermodehelper functionality from
synchronous (UMH_WAIT_PROC) to asynchronous (UMH_NO_WAIT) which prevents
scrubs, and other vdev_elevator_switch() consumers, from triggering the
aforementioned issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Issue #8664 
Closes #9321
2019-09-13 18:09:59 -07:00
..
abd.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
Makefile.in OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
policy.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
qat_compress.c QAT related bug fixes 2019-09-12 13:33:44 -07:00
qat_crypt.c QAT related bug fixes 2019-09-12 13:33:44 -07:00
qat.c QAT related bug fixes 2019-09-12 13:33:44 -07:00
spa_stats.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
trace.c OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
vdev_disk.c Scrubbing root pools may deadlock on kernels without elevator_change() (#9321) 2019-09-13 18:09:59 -07:00
vdev_file.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_acl.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_ctldir.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_debug.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_dir.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_sysfs.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_vfsops.c Move objnode handling to common code 2019-09-12 13:31:09 -07:00
zfs_vnops.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zfs_znode.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zio_crypt.c Enable SIMD for encryption 2019-09-10 10:45:46 -07:00
zpl_ctldir.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zpl_export.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zpl_file.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zpl_inode.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zpl_super.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00
zpl_xattr.c OpenZFS restructuring - move platform specific sources 2019-09-06 11:26:26 -07:00