Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp735067imm; Thu, 13 Sep 2018 07:01:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJRpTyhu/jSn3LvOvkVPJNfSUia+d6n25qLcyhdgUh54J8nE6WvaAjiwRyIBRD6+tIn2dA X-Received: by 2002:a65:6110:: with SMTP id z16-v6mr7449287pgu.412.1536847311842; Thu, 13 Sep 2018 07:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847311; cv=none; d=google.com; s=arc-20160816; b=rd2tF1PfsVKnbMXlP510D50+ZSLCGK0NQiF6QCb0ydZ30pIF9T6FVNyf8DGHpSx/Dq GvCKHe9bhaq85aj1h1wYNMUv5w29M3H3R0Hsd7Wg0HzRx04WxI0UKFHX7PtN2HQA3knL yE7r9KUU+di8lc1DXypnGenKxvDD5ve5PMZCH8jVPoqMYPeoz4HehQf3WX+TK8+E1xRp oEzrXuV0GDR1TBsSb1elJ5S8j0aI78jcIMA5fVwoJ8IzAO8gM0DpMCKTZVWCj/K65Pt+ HjOn7ywR26Y+TY+77z6bJFIdDoDkIQfzZuGCx9vFFtxEHFkn7M6ZdhRkvC34L8vk1onc ZEkQ== 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=KFQcdzPsjTI04FnVdu0i1TTXmzVjxi0gyayiSry7RRw=; b=Aiga0hIGhmPRakiEUqeaaDiovaAaoqka7rfmhdN0/XdCt/aGYxdCkoYNEt86Kzm+gG 8ItTIMTeJnyY/MH2S1KLFiBVyyJzNeIa/NoQs6ECQ/Gt2mEqNzug6/OddCjuA0qB1RN5 dGB3KL8l4umb0qr/FaifBV6oy+NeGaWH/EX8uEwDLkJB1bkUI+Las8y0H4SXW8jXGEyQ X7g/ZASY+bFRP2yZaoBnFNGHy1exMj6IsEbVZg83GKQQp9CnyDcSTezf22adE/ATJWSq LBC1aVehdfirlWYxRB/Y0bVm3YKVswvG0QBwtMEa/mXPuwkwgn9ZbHh/lhTBlukQJI6Z lsTA== 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 w61-v6si4071456plb.511.2018.09.13.07.01.34; Thu, 13 Sep 2018 07:01:51 -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 S1731832AbeIMTLH (ORCPT + 99 others); Thu, 13 Sep 2018 15:11:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35044 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730449AbeIMTLG (ORCPT ); Thu, 13 Sep 2018 15:11:06 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EC129D20; Thu, 13 Sep 2018 14:01:28 +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 139/197] btrfs: lift uuid_mutex to callers of btrfs_open_devices Date: Thu, 13 Sep 2018 15:31:28 +0200 Message-Id: <20180913131847.114986271@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 f5194e34cabaddd348a90f950e0a8188dd26cdc0 ] Prepartory work to fix race between mount and device scan. The callers will have to manage the critical section, eg. mount wants to scan and then call btrfs_open_devices without the ioctl scan walking in and modifying the fs devices in the meantime. Reviewed-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 2 ++ fs/btrfs/volumes.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1565,7 +1565,9 @@ static struct dentry *btrfs_mount_root(s goto error_fs_info; } + mutex_lock(&uuid_mutex); error = btrfs_open_devices(fs_devices, mode, fs_type); + mutex_unlock(&uuid_mutex); if (error) goto error_fs_info; --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1146,7 +1146,8 @@ int btrfs_open_devices(struct btrfs_fs_d { int ret; - mutex_lock(&uuid_mutex); + lockdep_assert_held(&uuid_mutex); + mutex_lock(&fs_devices->device_list_mutex); if (fs_devices->opened) { fs_devices->opened++; @@ -1156,7 +1157,6 @@ int btrfs_open_devices(struct btrfs_fs_d ret = open_fs_devices(fs_devices, flags, holder); } mutex_unlock(&fs_devices->device_list_mutex); - mutex_unlock(&uuid_mutex); return ret; }