Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp502915yba; Mon, 1 Apr 2019 10:35:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRuJurGEHoy+6h3Bo7yG/FcVWM+1YjtNgrSq2coX/b+iL2MeOqMr1g0rFV6isQ0Kcbxmsa X-Received: by 2002:a62:8c:: with SMTP id 134mr63271459pfa.27.1554140135741; Mon, 01 Apr 2019 10:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140135; cv=none; d=google.com; s=arc-20160816; b=MpuYFHtlm1SgAEx6MFJPveinGSMWLdvSijBu2Klxk1jULjXvmeartr1+gF3ne4r2VS m0jtK5UNduxTZIcNl1d57laxF7vO6s7Vb+OSruvi3LBGBG9mWAxtW33Umsog8IEfTh5X jpHTcCsNAgeYg28jvMFDsbJSPp2q8bIa6r4d35YqALhoSQCKbCHBphVmjwoHmNaEjGS8 jdIzrssYYGHrtV7x4mum1r9icL61o+ad44xfNeBWhKd6l69u20669REZEyPIdfme5Rv3 DjL0zQC34ODepO8iaIyYiDK+u+n0nwSCSIPc2iv7GhroZBZekooMaym43H/mGTg4yCeV bosQ== 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=hTCmOBEbbC0Qh394BCceR/NG5mnaKhsDfOPotlku7Yo=; b=SbfXBzw6bDOBkwXMNU6g02F9ty8zGvAejJ44SAyomnmBANQ7lJ9Qk+s9WVRcsO+Qyt 4g9bkgauBIouJWq0gAwxq+N3IQTeLoUrMgjZbBIQq8x5zbk7xkH+ghL718AGJmxdmt4r 5XEmY3s//BnAdavAHd2jL4ZNv/POul8r81yu3Lut92m5hWIDCHC5iK5MurlfUQEwTUel mphCFlN/tDbtMk5ErpS/Kuusqivo1saJpRTbgi6m4u06VjZPT/z3W3+ztYchdzRUhjIP oTjS8CuS1qoniHxi2WY0cRNYOCzpDyG/AZiwvWB25ILwtPMGapB7ta10xWuIBUAe5qR3 Aq3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="v96/m0hX"; 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 ct1si9500227plb.419.2019.04.01.10.35.20; Mon, 01 Apr 2019 10:35:35 -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="v96/m0hX"; 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 S2387829AbfDARes (ORCPT + 99 others); Mon, 1 Apr 2019 13:34:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733290AbfDARem (ORCPT ); Mon, 1 Apr 2019 13:34:42 -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 0006C2070B; Mon, 1 Apr 2019 17:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140081; bh=5pbCP77xd6o9Sc99DL//hD3+dhbPCPxwszk65TdRd+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v96/m0hXMlrDCw7Vn0OYECcscOaLzMZDaV6YNx5YJ+kE02rW+4+B98Wu+ZS8lWV8k vFx0YjPBrtm8UiQsV9Ez0TDxC5imLhL3yz/ZKxxMKBbZOUky64uES14+ilA5uVVFUw 59qTCLV2VeXDAALIpYHFAgmdrP16yznlL5rOEfjk= 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.4 100/131] btrfs: remove WARN_ON in log_dir_items Date: Mon, 1 Apr 2019 19:02:50 +0200 Message-Id: <20190401170100.277181969@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@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.4-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 @@ -3321,9 +3321,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; /*