Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3517246imu; Mon, 7 Jan 2019 04:58:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4YfEX70/t3M91ODy6A9Mpqwiiv8UP/NXSrkaLnjQdxQ1WW1fjlUz1lqYjvN4tWdYooz2p5 X-Received: by 2002:a17:902:74cc:: with SMTP id f12mr61673944plt.134.1546865929801; Mon, 07 Jan 2019 04:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546865929; cv=none; d=google.com; s=arc-20160816; b=NFuG9pK1Txf6hSzpmPb1s6dIZDOxBfzx/Ujk2io/lmPDF2U93vSyfrSLUi9dKeuqKv 8OHMAMlfzYJOn6A+zj2mZcEqBtfMWH9ScZHsUQZcsVQzTfeX1ptb1GcALBXbBCegnntB zvy30XOv4TexkB88l4uarLqQWO7PQVPbfxp07mtkbSwM9lB1xDAJ7JIliovZlT0z2cNE B2Tfx6vXCAAFNM9IaisVM3otsbhM/q3fqnQ5CapzK6S4bsbnWwR6itQYxC6da65uiL4q 4UBvJkswzGb9tBm6znZ+SP+GBs0UdInzalMNv55FcfAEyxK+hJ/B+ueWRX1dZGWUWUsP ahiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YiVKq4lncMJ9ctJYeS+rOmAsr6yxAzhiPsSUlp8vEyc=; b=W725bA2iM+v9sRl5WcmGaYRK26ILx8Jgw3RcSvFyj5wHXy/m8Rs470zWehgo4JRGE4 30ylP5JhJh2N9QNA/g2vu95njs2KY5oOpXoFqFCgjxOT5nj1++fAJ9sBgaAr8OxE/yD/ u1wsPacmtoILRhazqpLWemfHM/HpL7B1uD/a5eRmST3+/Sm5ejtKkAYppdY+FktP/nWD gahB1XuQHepWoV5tAcLH0QPB0IIYI2a8P6CVwBoYQd0orzIvWDnBqQENm7zoAn1d8/Af H12KKk9TbpeVtVlHBju47Pw+Np9IXg+6sO5WGRZEsK6FcNPtYZRYw97et3N/YHaZAja9 B00Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wygTaktG; 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 3si30851395plq.138.2019.01.07.04.58.34; Mon, 07 Jan 2019 04:58:49 -0800 (PST) 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=wygTaktG; 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 S1729712AbfAGM4n (ORCPT + 99 others); Mon, 7 Jan 2019 07:56:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:44614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbfAGM4l (ORCPT ); Mon, 7 Jan 2019 07:56:41 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 A108420651; Mon, 7 Jan 2019 12:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865801; bh=OpsOKbOIMR53Wl1YWEhALZjn14H/LTOtPKIClpkilBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wygTaktGWkUJfGRHS/fj06rDFL6kn+f8Bvr1O+cJd8WA2iRc/U3P3oKsxW++GYO8u I4fnuigmlhGVBVgpA2kWZZYzM5IeyQ+wX2Ey7+rVin2YOZ5rc7UkXJTWzeJkRs+Xpu Duqrx2ULgAAq8IpBfzo16zqJaW0fzBLyVuCVvcR8= 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.19 127/170] btrfs: dev-replace: go back to suspend state if another EXCL_OP is running Date: Mon, 7 Jan 2019 13:32:34 +0100 Message-Id: <20190107104507.919477491@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104452.953560660@linuxfoundation.org> References: <20190107104452.953560660@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anand Jain commit 05c49e6bc1e8866ecfd674ebeeb58cdbff9145c2 upstream. In a secnario where balance and replace co-exists as below, - start balance - pause balance - start replace - reboot and when system restarts, balance resumes first. Then the replace is attempted to restart but will fail as the EXCL_OP lock is already held by the balance. If so place the replace state back to BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED state. Fixes: 010a47bde9420 ("btrfs: add proper safety check before resuming dev-replace") CC: stable@vger.kernel.org # 4.18+ Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/dev-replace.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -900,6 +900,10 @@ int btrfs_resume_dev_replace_async(struc * dev-replace to start anyway. */ if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) { + btrfs_dev_replace_write_lock(dev_replace); + dev_replace->replace_state = + BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED; + btrfs_dev_replace_write_unlock(dev_replace); btrfs_info(fs_info, "cannot resume dev-replace, other exclusive operation running"); return 0;