Received: by 10.213.65.68 with SMTP id h4csp1737718imn; Mon, 19 Mar 2018 11:54:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELtgVRzV5/43+IZ5lfCq3Hmno72uu2+iemczh8SHRjHwmUjvBzGkne32vWHWHSNhYjoR2azw X-Received: by 2002:a17:902:b901:: with SMTP id bf1-v6mr13252625plb.175.1521485657534; Mon, 19 Mar 2018 11:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521485657; cv=none; d=google.com; s=arc-20160816; b=Nm60jzceCvpyuZUD0iH7Fpad1GikJgKp1ayukNb5uncJ/hUY8mNhs797gpEkllngT8 mP3YScyPPVibCRTIYmtSbp0TKnTG80yMhTE3fbdkIGQdACnEjEN/8ylbwZWSc413wMkN 5mlN6k5B3HePBqjoNw2ojj8KLHSFu46pQ4bt0sR96LKEZA4dMs51Avt9ULcehraiUaks YgWH775GvilEQavdjKN1mgvDUk/B8thrpOK48gbWndL3QRG1OUdeEbFV/Wuw67jU8Cae nMxw5xi7Rge5R1DSE3oykpql/P+GqUltzbPFm5FuU71uHToA9Im5lWceljxR+VykaCPr f84w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=M81bpAsIRmhjXPvLA5c9j2XLXnUZrlO340I7H3DRA8g=; b=W+eCRgasXitt99/34dSivDkFJZ0foP+mgSjbYX+LWONHnu25bXQTGDWJBCA43XB1Uk +nGFhc6DO0/u5HEImjpZ+7027s6jv+kd0U6i92EjD/IwKzVNyCOwGtTUIroRKjlXdDAx SFvbVmgYtI5phuj7uFAhbT57M899VNKKbpwXRq/SHHI4u/yFIMw0bQuFbfMo5LIEBpHE /IZtIWLGmM8PeS3pJ/SZ81KwxT5aXwPOxrNIK3G+XCo5FCoUbPfmXLX/ujgq3iaZFTph oqXRcL1LL2xBa4zm0K1HYvpw1nU9gra0FHYQUTlSgmlWLfeD36Z6E42wz/imhxQuaqDA DidQ== 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 w130si373685pfd.280.2018.03.19.11.54.02; Mon, 19 Mar 2018 11:54:17 -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 S970159AbeCSSac (ORCPT + 99 others); Mon, 19 Mar 2018 14:30:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53202 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935692AbeCSSaW (ORCPT ); Mon, 19 Mar 2018 14:30:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DEDA5125D; Mon, 19 Mar 2018 18:30:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zygo Blaxell , Lu Fengqi , David Sterba Subject: [PATCH 4.14 34/41] btrfs: remove spurious WARN_ON(ref->count < 0) in find_parent_nodes Date: Mon, 19 Mar 2018 19:08:34 +0100 Message-Id: <20180319180734.440233720@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180732.195217948@linuxfoundation.org> References: <20180319180732.195217948@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zygo Blaxell commit c8195a7b1ad5648857ce20ba24f384faed8512bc upstream. Until v4.14, this warning was very infrequent: WARNING: CPU: 3 PID: 18172 at fs/btrfs/backref.c:1391 find_parent_nodes+0xc41/0x14e0 Modules linked in: [...] CPU: 3 PID: 18172 Comm: bees Tainted: G D W L 4.11.9-zb64+ #1 Hardware name: System manufacturer System Product Name/M5A78L-M/USB3, BIOS 2101 12/02/2014 Call Trace: dump_stack+0x85/0xc2 __warn+0xd1/0xf0 warn_slowpath_null+0x1d/0x20 find_parent_nodes+0xc41/0x14e0 __btrfs_find_all_roots+0xad/0x120 ? extent_same_check_offsets+0x70/0x70 iterate_extent_inodes+0x168/0x300 iterate_inodes_from_logical+0x87/0xb0 ? iterate_inodes_from_logical+0x87/0xb0 ? extent_same_check_offsets+0x70/0x70 btrfs_ioctl+0x8ac/0x2820 ? lock_acquire+0xc2/0x200 do_vfs_ioctl+0x91/0x700 ? __fget+0x112/0x200 SyS_ioctl+0x79/0x90 entry_SYSCALL_64_fastpath+0x23/0xc6 ? trace_hardirqs_off_caller+0x1f/0x140 Starting with v4.14 (specifically 86d5f9944252 ("btrfs: convert prelimary reference tracking to use rbtrees")) the WARN_ON occurs three orders of magnitude more frequently--almost once per second while running workloads like bees. Replace the WARN_ON() with a comment rationale for its removal. The rationale is paraphrased from an explanation by Edmund Nadolski on the linux-btrfs mailing list. Fixes: 8da6d5815c59 ("Btrfs: added btrfs_find_all_roots()") Signed-off-by: Zygo Blaxell Reviewed-by: Lu Fengqi Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/backref.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1252,7 +1252,16 @@ again: while (node) { ref = rb_entry(node, struct prelim_ref, rbnode); node = rb_next(&ref->rbnode); - WARN_ON(ref->count < 0); + /* + * ref->count < 0 can happen here if there are delayed + * refs with a node->action of BTRFS_DROP_DELAYED_REF. + * prelim_ref_insert() relies on this when merging + * identical refs to keep the overall count correct. + * prelim_ref_insert() will merge only those refs + * which compare identically. Any refs having + * e.g. different offsets would not be merged, + * and would retain their original ref->count < 0. + */ if (roots && ref->count && ref->root_id && ref->parent == 0) { if (sc && sc->root_objectid && ref->root_id != sc->root_objectid) {