Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp525265yba; Mon, 1 Apr 2019 11:03:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqza/TkHK0OE+jigK4e95ou5kzawToT5Iqvia6/Wlmg+7Ou+ArbS6PIaDwYtpnQblbAtQl22 X-Received: by 2002:a63:ed4f:: with SMTP id m15mr40680021pgk.387.1554141833251; Mon, 01 Apr 2019 11:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554141833; cv=none; d=google.com; s=arc-20160816; b=Vt8Vq5gtT2r0Zs4UgUSk9aD+/G2r813gRpdYg+q/G4PYQT8XdDqx7sNEFYSRQt2tWH BbZs1mOlXZ0C6zHls/Dn9ksoXaJDHOQU2+u6jqaws2LeQkXgLcqWPX6O93qY+HMjtO58 hy/VchgF+fBWzdpyTMsQ6wGPtr3jIQh0YytakXtFxFrIT7zUbwWrAkIt7HhL8plu1l2A 0eO9FnP7EvA4Dh8z6gQxImSwH3cUy/vs1QRd6wJiudwF/v+GoDvr8Q+O22FnvuYAF8K0 C512zc8Vttu2lNHp3jhbaM3x/kPlYA6T+9yDLLa8fYbnP9BOWf8T5DOjrMQzbHPRO2Hk c2bg== 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=SfvaRy8KoFjrDuGUYdyzANGUxb3qjYME/T3HTYncL8Q=; b=D038uCxDJsaDc/Ebbrqm1QGBTI++i4wyMi5lXEtZcNzTRC7iUSBke4rFQkgZz3tQDN iJLybra1PzerPmlwSGy90wj0xOivte/AzPH2rcwB7qYLcxETglt7b6KhrXEKgyvp3VH5 OiuEfK5W2bOCeDU5n4Yrq68wZlhn/m4XB6Sk+o3QkcoTAK5Ades/HxSp8ZNthzN8ldpu 85XS8XHuRsrZqGJpvyhZd9ou9eJjbx1S8btiQ49E1Shhd/Ab9Mc0cZKn1FMt7zE7Wp2o +/C7t9fQEMheoXRl7bDniY0dUvXr4x5Ru9cDyB21Q4+Ffprkgg5MW9E2/Ls75nquf/Jr OsSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qpknGuLk; 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 g8si9120881pgq.159.2019.04.01.11.03.37; Mon, 01 Apr 2019 11:03:53 -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=qpknGuLk; 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 S1730760AbfDAROd (ORCPT + 99 others); Mon, 1 Apr 2019 13:14:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:37894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728813AbfDAROc (ORCPT ); Mon, 1 Apr 2019 13:14:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0E3F521473; Mon, 1 Apr 2019 17:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138871; bh=BWZHSDq+fteNM14pWLBv+L9HmWzg6Kx9g7A4YrbVTwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpknGuLkfRChwEDyvNFMPZPhZayG5VrsSWiaUtYjNgv4tncKPZXco+ph1zrJ1Bbv5 oGHJa8y2jkfoDtDSIHVHiKQH/HtSQGhdnkT4jk/6ZuRPIUp7nGis5dSSazvmYJhL3r k9E5H3NhcP/fcsIPIxqcs/XdBw7FCjvhrA+GVJLk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba Subject: [PATCH 4.19 046/134] btrfs: remove WARN_ON in log_dir_items Date: Mon, 1 Apr 2019 19:01:22 +0200 Message-Id: <20190401170048.899722291@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170044.243719205@linuxfoundation.org> References: <20190401170044.243719205@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: Josef Bacik commit 2cc8334270e281815c3850c3adea363c51f21e0d upstream. When Filipe added the recursive directory logging stuff in 2f2ff0ee5e430 ("Btrfs: fix metadata inconsistencies after directory fsync") he specifically didn't take the directory i_mutex for the children directories that we need to log because of lockdep. This is generally fine, but can lead to this WARN_ON() tripping if we happen to run delayed deletion's in between our first search and our second search of dir_item/dir_indexes for this directory. We expect this to happen, so the WARN_ON() isn't necessary. Drop the WARN_ON() and add a comment so we know why this case can happen. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3532,9 +3532,16 @@ static noinline int log_dir_items(struct } btrfs_release_path(path); - /* find the first key from this transaction again */ + /* + * Find the first key from this transaction again. See the note for + * log_new_dir_dentries, if we're logging a directory recursively we + * won't be holding its i_mutex, which means we can modify the directory + * while we're logging it. If we remove an entry between our first + * search and this search we'll not find the key again and can just + * bail. + */ ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); - if (WARN_ON(ret != 0)) + if (ret != 0) goto done; /*