Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2310230pxb; Fri, 5 Feb 2021 14:40:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJysvHE8XuigmoSLC2JDPf2rWmyfUJwOvNPKYpxa2ANNqbHvF/xkfldEpqHRXYgYIB5k6xtx X-Received: by 2002:a17:907:3e04:: with SMTP id hp4mr6298488ejc.188.1612564809615; Fri, 05 Feb 2021 14:40:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612564809; cv=none; d=google.com; s=arc-20160816; b=w6ucf61KlIJgClj0e7iFYr3IBA3IGCK1+XxUHqt+HDzRY1FQs1kGf12wS1TfoP+IdZ JxtLhM1ymOVgLfznJopE5WPjewElRhNzScC3UdWmVbDWKoWTGcaUKnap6S1c6Smdu05F MzWlJoJJVcVyLo6XwRdOmaG3pT6O5RvPFSe/Y1Qv3mUG11l4Me5Z8j1jzsj7Bh9o04iJ u2tc4f883kYKBcG8OGBbmgfApU9Ttdd0Ik94Uk9PelT16Eq7vfIoQC0T3bpBTUv5es9X wqSojoAOyXfarItqISBE5kLnBnE/17AMjDUN4IBKNp3FCG393eD/YLaCwcg705NIyTVw XRmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lONgPVbbaywsATLx7ca/R9Z6Q8KRDfDggCZF0flKrOc=; b=QCwBjkKLqytRGb6TVacFG4lqlIFM0pAdns6sNRvFe3CpHRQliVF+Y2Re9oNCTbtx/z r2O/LLfciDfzc5cb1hxvpqF14nHm+fvBDTyQgWrspjOCofADfGby+wySghtC0zLFhk5X uCzq7EKZNA6jvPye5Wmi58p6xmyB9dBIkRx+OifZ1rNM96SQ99Iha9TL0Oj+FMacTJ+g PltpbqM+0141ObVbFTkvQUyWBbqvZvRs65uxdrFYKUOnqQrGT0W1P2M3dt27oJI9mNjE IQjrQzDe8nxUBJrzVNbbnCkUlWUBriUMeZ4X8mNdFk86khN3geOAWD+O6mgwI+ce+KQ0 9i0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtwdZiV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si6117377eds.179.2021.02.05.14.39.45; Fri, 05 Feb 2021 14:40:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtwdZiV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232599AbhBEWfz (ORCPT + 99 others); Fri, 5 Feb 2021 17:35:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:44682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232840AbhBEOyd (ORCPT ); Fri, 5 Feb 2021 09:54:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 139BF65048; Fri, 5 Feb 2021 14:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534324; bh=LL5abwxLlE5Zl9tvTdkf45Ng75eLP9spXen9DvmimIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtwdZiV8Ki4w3CtUneIam5Xb/ffdy8Z3Fy9/huDQfC0vakgqmb+SfuD24Vm8RA6c7 /1xipsY8hKE+H7hf4a1JCV5YNcX5Y4aVjGPcEwfbOQrbPT2L81I9H0XPlFRQWSHZLz 0lbeXH086gBsrET+uJL4j+M8s4mQUr5pn/erb0/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Johannes Thumshirn , ethanwu , David Sterba Subject: [PATCH 5.4 11/32] btrfs: backref, only search backref entries from leaves of the same root Date: Fri, 5 Feb 2021 15:07:26 +0100 Message-Id: <20210205140652.826044858@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140652.348864025@linuxfoundation.org> References: <20210205140652.348864025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: ethanwu commit cfc0eed0ec89db7c4a8d461174cabfaa4a0912c7 upstream. We could have some nodes/leaves in subvolume whose owner are not the that subvolume. In this way, when we resolve normal backrefs of that subvolume, we should avoid collecting those references from these blocks. Reviewed-by: Josef Bacik Reviewed-by: Johannes Thumshirn Signed-off-by: ethanwu Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/backref.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -443,11 +443,14 @@ static int add_all_parents(struct btrfs_ * slot == nritems. * 2. We are searching for normal backref but bytenr of this leaf * matches shared data backref + * 3. The leaf owner is not equal to the root we are searching + * * For these cases, go to the next leaf before we continue. */ eb = path->nodes[0]; if (path->slots[0] >= btrfs_header_nritems(eb) || - is_shared_data_backref(preftrees, eb->start)) { + is_shared_data_backref(preftrees, eb->start) || + ref->root_id != btrfs_header_owner(eb)) { if (time_seq == SEQ_LAST) ret = btrfs_next_leaf(root, path); else @@ -466,9 +469,12 @@ static int add_all_parents(struct btrfs_ /* * We are searching for normal backref but bytenr of this leaf - * matches shared data backref. + * matches shared data backref, OR + * the leaf owner is not equal to the root we are searching for */ - if (slot == 0 && is_shared_data_backref(preftrees, eb->start)) { + if (slot == 0 && + (is_shared_data_backref(preftrees, eb->start) || + ref->root_id != btrfs_header_owner(eb))) { if (time_seq == SEQ_LAST) ret = btrfs_next_leaf(root, path); else