Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp479133yba; Mon, 1 Apr 2019 10:07:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXExYfYz+jJu9Th9GkQg9P99Z9SJ35SWYyuQBncEMJtmsn2/BqERWp9rIa6wSa4Mqd8LC3 X-Received: by 2002:a17:902:3381:: with SMTP id b1mr55684041plc.5.1554138433220; Mon, 01 Apr 2019 10:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554138433; cv=none; d=google.com; s=arc-20160816; b=oZ/r8w2snVhFSnoBVkLkrAA6XIb9KY4K4++UnGxM9ljO2QzUMnuElBsqjUH04c+UUU bqQigVLOQC6Qe8RhzP5Pic4h0FQwAHDc2YUefR5DmvTj8Aa4gzhKtqtCCHRkj2WiYD9e kzvRspUhosyksnxH3zBcEa/uOwBiE8kRbT62YUZlfX6OcYdvK6KEdCyXG/z5R7XKVM2i 6edzim4WuWS3ByXtBjPPKoG7cygUFkdIxIynGqMl6Ax91bNiV1KLfk5tUv2HWV99l0wo zluz2UvL2e7AqgsJLrKGi5PfRoUDyaK8BYKjGIxj8w2LeCptuFJtr+9ErqorOfCBTiQI EhRQ== 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=Kuc/1UuEvsgRMzCTI5FXBWuSqHbI72plS/6O/L8VRTg=; b=rYV152mjo30zOTWqzR8DbmRsGv5dmKCNPn4adZA76hBb3reV46sRlHOF+Fw0ttHVJH jKZWrDgz5cR00DSdAnpAa5zvw07rb5PS1FUCMAvMDcw7bw6zO70tEE7QKCxFCvj0RgOd k8ycKHGpSHbZl16mfZPhr7DqEOmdV4hkC47D7o1r3RAry4Mq/9e3EQNwYwR58qMvQ4S8 +BvENg7lQeg695S8PaCyrVIiayCfTF/fEwGYL0IK/nx7juvSyazcwegCfLy1xgiZHUfG p+1KaMb/oF22abjpNsIAanI+IPIhdcqV6jUxwI06F9pRiAVBn4UKgraxQyasgz73RB1t xJwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ar8erTu6; 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 t22si9063265plo.74.2019.04.01.10.06.57; Mon, 01 Apr 2019 10:07:13 -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=ar8erTu6; 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 S1729074AbfDARFx (ORCPT + 99 others); Mon, 1 Apr 2019 13:05:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:51136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbfDARFv (ORCPT ); Mon, 1 Apr 2019 13:05:51 -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 B5F7E21924; Mon, 1 Apr 2019 17:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138350; bh=2Hf302KDYpQoH4JmJd6KTh4I0Fb5+jnv/PbmfV5th1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ar8erTu6kDSb3uinEIccq5TJycZ6zrHglAWhcl4UxGbFTVAcMtBcHn5Lj5lJYc7P4 OGjKeGFC//gJ+VueND74u069vPflAnO2V99xmrI6H4H54n+5CLExML5gPD0EebcnDY V3/NSIVob9b7j2RJVH+A/sojoPdvmc9Br8UnMBoA= 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 5.0 039/146] btrfs: remove WARN_ON in log_dir_items Date: Mon, 1 Apr 2019 19:00:51 +0200 Message-Id: <20190401170051.801904900@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170048.449559024@linuxfoundation.org> References: <20190401170048.449559024@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 5.0-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 @@ -3517,9 +3517,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; /*