From patchwork Thu Jul 12 15:48:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 943106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41RL2546kLz9s1R; Fri, 13 Jul 2018 01:48:29 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fddpO-00032I-JW; Thu, 12 Jul 2018 15:48:22 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fddpM-000320-GH for kernel-team@lists.ubuntu.com; Thu, 12 Jul 2018 15:48:20 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fddpM-0003Yo-7T; Thu, 12 Jul 2018 15:48:20 +0000 From: Colin King To: kernel-team@lists.ubuntu.com Subject: [PATCH][SRU][XENIAL] UBUNTU: SAUCE: (noup) zfs to 0.6.5.6-0ubuntu25 Date: Thu, 12 Jul 2018 16:48:19 +0100 Message-Id: <20180712154819.29950-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Colin Ian King BugLink: http://bugs.launchpad.net/bugs/1781364 This is a sync of zfs 0.6.5.6-0ubuntu25 that fixes a mount/umount deadlock for upstream ZFS commit ac09630d8b0b ("Fix zpl_mount() deadlock") ZFS commit 93b43af 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 Signed-off-by: Brian Behlendorf (backport from ZFS upstream commit ac09630d8b0bf6c92084a30fdaefd03fd0adbdc1) Signed-off-by: Colin Ian King Acked-by: Stefan Bader Acked-by: Kleber Sacilotto de Souza --- zfs/META | 2 +- zfs/include/sys/zfs_vfsops.h | 1 + zfs/module/zfs/zpl_super.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/zfs/META b/zfs/META index 6837592..f34a9d6 100644 --- a/zfs/META +++ b/zfs/META @@ -2,7 +2,7 @@ Meta: 1 Name: zfs Branch: 1.0 Version: 0.6.5.6 -Release: 0ubuntu24 +Release: 0ubuntu25 Release-Tags: relext License: CDDL Author: OpenZFS on Linux diff --git a/zfs/include/sys/zfs_vfsops.h b/zfs/include/sys/zfs_vfsops.h index efaefda..49eefba 100644 --- a/zfs/include/sys/zfs_vfsops.h +++ b/zfs/include/sys/zfs_vfsops.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #ifdef __cplusplus diff --git a/zfs/module/zfs/zpl_super.c b/zfs/module/zfs/zpl_super.c index f75a0d8..fc467ae 100644 --- a/zfs/module/zfs/zpl_super.c +++ b/zfs/module/zfs/zpl_super.c @@ -467,8 +467,17 @@ zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mntopts_t *zmo) if (err) return (ERR_PTR(-err)); + /* + * The dsl pool lock must be released prior to calling sget(). + * It is possible sget() may block on the lock in grab_super() + * while deactivate_super() holds that same lock and waits for + * a txg sync. If the dsl_pool lock is held over over sget() + * this can prevent the pool sync and cause a deadlock. + */ + dsl_pool_rele(dmu_objset_pool(os), FTAG); s = zpl_sget(fs_type, zpl_test_super, set_anon_super, flags, os); - dmu_objset_rele(os, FTAG); + dsl_dataset_rele(dmu_objset_ds(os), FTAG); + if (IS_ERR(s)) return (ERR_CAST(s));