Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp739089imm; Thu, 13 Sep 2018 07:04:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdajm+WLzaXrKj7oJFI3veS7NBHaVw5JkI3GVlzHk+gqFNMYUo9s7Sq8W90Bd4ZHrWoU+4E+ X-Received: by 2002:a63:b914:: with SMTP id z20-v6mr7363604pge.396.1536847480319; Thu, 13 Sep 2018 07:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847480; cv=none; d=google.com; s=arc-20160816; b=szfl3vKjjdMx1BcQlD6MTujp+PP40eUlgeh9RWTnZ9OX+pfz3RQtQVeX0zUH9VTugw yD5W/BC2aYPiZqhtqq0NN5wx0WPn+F+EDqXYii7dVAwCA8AUTDRLzFi4yUGzAWsz3GIV X3T151bZ+5x4hevMo3hB35aVp7azscDU/HTvB5SDoK9ussBKmKQNKoB6deMbUJgojZDF J5KUo1nhfrInqIkQHaDj+odeBNgpRxDA3Xg9qZ/ldwh7Xq46xnZqktNb5OCtPHWf/6se tELCG2Qqyiy6wIV4mOJlkzPv9jiBWWLU/YjpeoX12/5wQ9AcyKKEXMlZBuRjxDZJdGRK a1RQ== 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; bh=fOLX7X6CF3NznFFkBibONpaRwtiJ3esafCLgXRRAFoo=; b=R0LLgGaJ09Vhc+pWvYkANTM9kCt7kwwNmpwHy8q6vuVs9ery1EIkKY6f23/FTm4FY7 vkkSQolnc+2J+CTKZmOQvYdYZXZWvkPBfnGgChevevB9RWXib70CZouvwoINNCfnmdxi n0ydevWvyI9bs8u8rbKaE74GAX/envRxFR+eA6ZCoQpsIq378WTZB875DZnE2wFvTCm2 fwDF1OndT1VTzozFY6l/7Kri0yLQk5ufqPuycNxUwvL3rIQcwnQoFyUJ35RDfINvw2P+ TQLguwgF7PjBy8rZiY5ua7DXfJoz3oCe3yOFT0GAC+rf6Fnoo17U/QBO8j1cVBhvK8pB vrxg== ARC-Authentication-Results: i=1; mx.google.com; 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 72-v6si4156147pfq.6.2018.09.13.07.04.23; Thu, 13 Sep 2018 07:04:40 -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; 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 S1732055AbeIMTN2 (ORCPT + 99 others); Thu, 13 Sep 2018 15:13:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35334 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728556AbeIMTN1 (ORCPT ); Thu, 13 Sep 2018 15:13:27 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6DDD2D2E; Thu, 13 Sep 2018 14:03:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , David Sterba , Sasha Levin Subject: [PATCH 4.18 149/197] btrfs: lift uuid_mutex to callers of btrfs_parse_early_options Date: Thu, 13 Sep 2018 15:31:38 +0200 Message-Id: <20180913131847.511999376@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Sterba [ Upstream commit 5139cff598d42b1e531f40c84691a7e945f04553 ] Prepartory work to fix race between mount and device scan. btrfs_parse_early_options calls the device scan from mount and we'll need to let mount completely manage the critical section. Reviewed-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -892,6 +892,8 @@ static int btrfs_parse_early_options(con char *device_name, *opts, *orig, *p; int error = 0; + lockdep_assert_held(&uuid_mutex); + if (!options) return 0; @@ -917,10 +919,8 @@ static int btrfs_parse_early_options(con error = -ENOMEM; goto out; } - mutex_lock(&uuid_mutex); error = btrfs_scan_one_device(device_name, flags, holder, fs_devices); - mutex_unlock(&uuid_mutex); kfree(device_name); if (error) goto out; @@ -1528,8 +1528,10 @@ static struct dentry *btrfs_mount_root(s if (!(flags & SB_RDONLY)) mode |= FMODE_WRITE; + mutex_lock(&uuid_mutex); error = btrfs_parse_early_options(data, mode, fs_type, &fs_devices); + mutex_unlock(&uuid_mutex); if (error) { return ERR_PTR(error); }