From patchwork Thu Sep 3 01:05:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 7114321 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EE8229F372 for ; Thu, 3 Sep 2015 01:05:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CCB6206EC for ; Thu, 3 Sep 2015 01:05:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2557C206E6 for ; Thu, 3 Sep 2015 01:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbbICBF2 (ORCPT ); Wed, 2 Sep 2015 21:05:28 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35961 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754839AbbICBFZ (ORCPT ); Wed, 2 Sep 2015 21:05:25 -0400 Received: by pacwi10 with SMTP id wi10so28061785pac.3 for ; Wed, 02 Sep 2015 18:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=g6M+yjS3zv1Ke8Swb0v2gom1wpv8xsEHVy7LUvBp8oU=; b=wLsuob8NsLJ3G0h6yl/NTq7SziYCMy5dMI54t+Q/rdpUf2lOrGRFWNKs1F6w3W9t0Z aQm7LzxuCfGn7TBflJAStNUC5EVfp38ATynx83Z3uVuJ12KFxWOw7pkZc4A9chHJ+M4l oc7aW9MJqTm8ASDOMvs0FnzoaQ444MPH5p1Q5sSU5jarDcaNyxJ8kmmVGwAj7FtRAb9f zEpN+1dj/sdQ9CfQ7qKCUGiBYC3qne9Vckpjstb5xX0nRSlRLH667eZ/VDGLbfsFJAbE bIU+jO/M61LQu+zZjXUYb8qzoUgKQomubDX8zReJ7q0vJXNKsilBBrUmXTH4c4MG5cdq 7h4g== X-Received: by 10.66.136.237 with SMTP id qd13mr62664417pab.84.1441242325123; Wed, 02 Sep 2015 18:05:25 -0700 (PDT) Received: from jmaggard-ThinkPad-W520.infrant-6.com ([209.249.181.1]) by smtp.gmail.com with ESMTPSA id y9sm11560954pdp.17.2015.09.02.18.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Sep 2015 18:05:24 -0700 (PDT) From: Justin Maggard X-Google-Original-From: Justin Maggard To: linux-btrfs@vger.kernel.org Cc: Justin Maggard Subject: [PATCH v2] btrfs: qgroup: exit the rescan worker during umount Date: Wed, 2 Sep 2015 18:05:17 -0700 Message-Id: <1441242317-16547-1-git-send-email-jmaggard@netgear.com> X-Mailer: git-send-email 2.5.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP v2: Fix stupid error while making formatting changes... I was hitting a consistent NULL pointer dereference during shutdown that showed the trace running through end_workqueue_bio(). I traced it back to the endio_meta_workers workqueue being poked after it had already been destroyed. Eventually I found that the root cause was a qgroup rescan that was still in progress while we were stopping all the btrfs workers. Currently we explicitly pause balance and scrub operations in close_ctree(), but we do nothing to stop the qgroup rescan. We should probably be doing the same for qgroup rescan, but that's a much larger change. This small change is good enough to allow me to unmount without crashing. Signed-off-by: Justin Maggard Reviewed-by: David Sterba --- fs/btrfs/qgroup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index d904ee1..5bfcee9 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2278,7 +2278,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) goto out; err = 0; - while (!err) { + while (!err && !btrfs_fs_closing(fs_info)) { trans = btrfs_start_transaction(fs_info->fs_root, 0); if (IS_ERR(trans)) { err = PTR_ERR(trans); @@ -2301,7 +2301,8 @@ out: btrfs_free_path(path); mutex_lock(&fs_info->qgroup_rescan_lock); - fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN; + if (!btrfs_fs_closing(fs_info)) + fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN; if (err > 0 && fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT) { @@ -2330,7 +2331,9 @@ out: } btrfs_end_transaction(trans, fs_info->quota_root); - if (err >= 0) { + if (btrfs_fs_closing(fs_info)) { + btrfs_info(fs_info, "qgroup scan paused"); + } else if (err >= 0) { btrfs_info(fs_info, "qgroup scan completed%s", err > 0 ? " (inconsistency flag cleared)" : ""); } else {