From patchwork Mon Apr 7 07:55:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 3944591 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 304C99F371 for ; Mon, 7 Apr 2014 07:56:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CD5620303 for ; Mon, 7 Apr 2014 07:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A122202DD for ; Mon, 7 Apr 2014 07:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754790AbaDGH4F (ORCPT ); Mon, 7 Apr 2014 03:56:05 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:32887 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbaDGH4E (ORCPT ); Mon, 7 Apr 2014 03:56:04 -0400 Received: from sf.home (unknown [93.84.41.252]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id BDC3D33FD21; Mon, 7 Apr 2014 07:56:02 +0000 (UTC) Received: by sf.home (Postfix, from userid 1000) id 99C70D1A1FC7; Mon, 7 Apr 2014 10:55:55 +0300 (FET) From: Sergei Trofimovich To: Qu Wenruo Cc: Sergei Trofimovich , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: fix crash in remount(thread_pool=) case Date: Mon, 7 Apr 2014 10:55:46 +0300 Message-Id: <1396857346-24877-1-git-send-email-slyich@gmail.com> X-Mailer: git-send-email 1.9.0 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Sergei Trofimovich Reproducer: mount /dev/ubda /mnt mount -oremount,thread_pool=42 /mnt Gives a crash: ? btrfs_workqueue_set_max+0x0/0x70 btrfs_resize_thread_pool+0xe3/0xf0 ? sync_filesystem+0x0/0xc0 ? btrfs_resize_thread_pool+0x0/0xf0 btrfs_remount+0x1d2/0x570 ? kern_path+0x0/0x80 do_remount_sb+0xd9/0x1c0 do_mount+0x26a/0xbf0 ? kfree+0x0/0x1b0 SyS_mount+0xc4/0x110 It's a call btrfs_workqueue_set_max(fs_info->scrub_wr_completion_workers, new_pool_size); with fs_info->scrub_wr_completion_workers = NULL; as scrub wqs get created only on user's demand. Patch skips not-created-yet workqueues. Signed-off-by: Sergei Trofimovich CC: Qu Wenruo CC: Chris Mason CC: Josef Bacik CC: linux-btrfs@vger.kernel.org --- fs/btrfs/async-thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index ecb5832..5a201d8 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -323,6 +323,8 @@ void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max) { + if (!wq) + return; wq->normal->max_active = max; if (wq->high) wq->high->max_active = max;