Received: by 10.213.65.68 with SMTP id h4csp36750imn; Mon, 19 Mar 2018 18:44:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELuhwAer7vUCHpx2o4bqBP/TgJ5gd2uwV3ETlSUWSWKriWg9Gyu6N5uWFUiOxf1Utrfvf33m X-Received: by 10.167.129.195 with SMTP id c3mr12039059pfn.14.1521510262462; Mon, 19 Mar 2018 18:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510262; cv=none; d=google.com; s=arc-20160816; b=iL5clEoF+51Y+rf5w5IDDtw7buuNjaRUi6R0n+yeuZFUIcAPb3hWdCRZp4NJnb5PfL 5OepzogmUVKzHzN4n59fSc6DbO6neAsYBaIOh/HxdaN5yrhzOf+qeAkq+VAM4quvoPCS JzDo59eeVI+fA9RDyPidyMnrESXYqpQ5+c1LM3sAue9DOej0uYuq49enl9JAW2szB23u TVgqHbrXwRnMxhdtwosswSLcirTeFwPKeHxlxValnbv+UXqdB+qSGDsB/i8JAGVicRxL z3mzenTOqBFCnBQ6mL3N+kxspBD1Yyc9b3DXLN3bxTFXV/66PupIwIx1Wo3g0gP6lcmB ezbg== 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=Z+ks4/w5faSNQ2c9W9iBxOr1OdKF9qxsGrIK25mImFk=; b=apyn87G2Ugz6MgkdxiEpZNRQzV+jO/9EkVQjZQOrAP8Ela98ZW84KwHesXAexxqdek kRgRH62jJVaHOL5tce7aLG2p1SOXr8Dbh0NDon/Mmsbrj3J6hRFcbOu0zzp28x3ddLqc k26Z/3AWBTZZdsOtwmZj/jYkFRrvRD9LdBnP7BX9oE9sEcxIPMUC1XJDs39yUnmwdBIF 80TAHIr8S7EUYrWqF0l/lMen3ifYVHJ2eR3lxjo+eVZt1sSac45immYqF57aG8JBo7hx QMYJ31szMJAR1gus+vliA7RST/ALt3B9HIRwiUzbl0ubosg2/KxSoSqGLXOJXgjSJnO3 7ADg== 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 o188si396853pga.132.2018.03.19.18.44.08; Mon, 19 Mar 2018 18:44:22 -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 S970428AbeCSSoC (ORCPT + 99 others); Mon, 19 Mar 2018 14:44:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970283AbeCSScW (ORCPT ); Mon, 19 Mar 2018 14:32: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 7988B12A8; Mon, 19 Mar 2018 18:32: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.15 36/52] btrfs: remove spurious WARN_ON(ref->count < 0) in find_parent_nodes Date: Mon, 19 Mar 2018 19:08:34 +0100 Message-Id: <20180319180737.023707478@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180734.976730813@linuxfoundation.org> References: <20180319180734.976730813@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.15-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 @@ -1263,7 +1263,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) {