HomeFreeBSD

Fix zpl_mount() deadlock

Description

Fix zpl_mount() deadlock

Commit 93b43af10 inadvertently introduced the following scenario which
can result in a deadlock. This issue was most easily reproduced by
LXD containers using a ZFS storage backend but should be reproducible
under any workload which is frequently mounting and unmounting.

  • THREAD A --

spa_sync()

  spa_sync_upgrades()
    rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG); <- Waiting on B
  • THREAD B --

mount_fs()

  zpl_mount()
    zpl_mount_impl()
      dmu_objset_hold()
        dmu_objset_hold_flags()
          dsl_pool_hold()
            dsl_pool_config_enter()
              rrw_enter(&dp->dp_config_rwlock, RW_READER, tag);
    sget()
      sget_userns()
        grab_super()
          down_write(&s->s_umount); <- Waiting on C
  • THREAD C --

cleanup_mnt()

  deactivate_super()
    down_write(&s->s_umount);
    deactivate_locked_super()
      zpl_kill_sb()
        kill_anon_super()
          generic_shutdown_super()
            sync_filesystem()
              zpl_sync_fs()
                zfs_sync()
                  zil_commit()
                    txg_wait_synced() <- Waiting on A

Reviewed by: Alek Pinchuk <apinchuk@datto.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7598
Closes #7659
Closes #7691
Closes #7693

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Jul 11 2018, 10:49 PM
GitHub <noreply@github.com>Committed on Jul 11 2018, 10:49 PM
Parents
rG33a19e0fd9b2: Fix kernel unaligned access on sparc64
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGac09630d8b0b: Fix zpl_mount() deadlock (authored by Brian Behlendorf <behlendorf1@llnl.gov>).Jul 11 2018, 10:49 PM