Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2039159imm; Thu, 24 May 2018 04:58:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpno45i5qVg3bVBJoy/T/gbzB1Ss2bE6zfBX4CT2GDqlaBa3KoOrf/g7gKmgLefr8gUR5V5 X-Received: by 2002:a17:902:8494:: with SMTP id c20-v6mr7161963plo.66.1527163095012; Thu, 24 May 2018 04:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163094; cv=none; d=google.com; s=arc-20160816; b=SpKVS/9g3XZ1kaTjIOvhexGPwikMWk0+fM+CassGOgR4UUkcRQuoqRiewI57YDW5fc ZOuQn5SnFbElBV5A1kFR5ozVQOEoa/bse5Jm63hXDc6PMr048wuAmv6l5+KmOxZQoNpg AE8N4tpqB0Rfpe8PRRjxU9N2UobiGnsYGn7e2+SVfBb+hiM2zNL4mmb+1Yem+QpRNS4e ZKIPfuuKLNDRUTOSFlpd9TmQ7Sjfq3oB71cQRT2nRBic1w4fcVR4HjSAsKgPi8NRtaVe mRSSPFtYLDoFE8/vunjKfMd/p8smiDKlGrA38lNaQ7wz0Hjwly6UnceH2wKP9GewErzB vFew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Z4ve07MOQKqKRVoXWIQF7MYVzqrb6OmZd10w/fn+aZU=; b=ShHQnRDiGLEUntiH3VULdXFmhjusL3CV1TEyc2VOR6blvjhy434RGnnWq0kZt56i95 mon5dOh1/4yRrxnZomYRz6N0aXuupzCBVfw3kME/Z6KkVI8JsgjqRbhtMEBdAY1TutyL rSQiaunpWwzSQYemEpeyzuc5xIfx+xkrCzqETyj7Gt3g402PMldYIK1quFJdMhlSI+L6 U2BhTlWqXq1Yu0RXAbrygGz8MdFado5GkTE9Rski8n/5MRmv5E7v60CgwgqBpIhHTUqV WStjOgwEjotMJZsRs95E5MLOfB4ihcmnn3vc7SGgUQloZbQQBTio6rrjv/rnJfT8XT4Q t/Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fl+X892e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63-v6si20919732pfi.162.2018.05.24.04.58.00; Thu, 24 May 2018 04:58:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fl+X892e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969451AbeEXL5V (ORCPT + 99 others); Thu, 24 May 2018 07:57:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:56828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966813AbeEXJpl (ORCPT ); Thu, 24 May 2018 05:45:41 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6C79620897; Thu, 24 May 2018 09:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155139; bh=V+YRfs0noWw4Cnsz+ZBrOnxQ8Dn80K/g81MAZwDQl8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fl+X892eWGvXckK6McArYc0YUmIJv3PuSvtOkLzJMOZa3/6xOJ93Vmzsp1+9NwSI0 LZJ33LtvVzOHOYZx2znxa7x16tyLu2Fr4NpCEUVUVetcm1SKRS9NwFhDN5+Wiqf/zq Mj76Zd9uRLIiJbE7No2ftUua4vXGq3s7W7mrnG6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , David Sterba Subject: [PATCH 4.4 69/92] btrfs: fix crash when trying to resume balance without the resume flag Date: Thu, 24 May 2018 11:38:46 +0200 Message-Id: <20180524093205.984977330@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anand Jain commit 02ee654d3a04563c67bfe658a05384548b9bb105 upstream. We set the BTRFS_BALANCE_RESUME flag in the btrfs_recover_balance() only, which isn't called during the remount. So when resuming from the paused balance we hit the bug: kernel: kernel BUG at fs/btrfs/volumes.c:3890! :: kernel: balance_kthread+0x51/0x60 [btrfs] kernel: kthread+0x111/0x130 :: kernel: RIP: btrfs_balance+0x12e1/0x1570 [btrfs] RSP: ffffba7d0090bde8 Reproducer: On a mounted filesystem: btrfs balance start --full-balance /btrfs btrfs balance pause /btrfs mount -o remount,ro /dev/sdb /btrfs mount -o remount,rw /dev/sdb /btrfs To fix this set the BTRFS_BALANCE_RESUME flag in btrfs_resume_balance_async(). CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3850,6 +3850,15 @@ int btrfs_resume_balance_async(struct bt return 0; } + /* + * A ro->rw remount sequence should continue with the paused balance + * regardless of who pauses it, system or the user as of now, so set + * the resume flag. + */ + spin_lock(&fs_info->balance_lock); + fs_info->balance_ctl->flags |= BTRFS_BALANCE_RESUME; + spin_unlock(&fs_info->balance_lock); + tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); return PTR_ERR_OR_ZERO(tsk); }