From patchwork Fri Oct 10 20:57:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 5067351 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B59A9F295 for ; Fri, 10 Oct 2014 20:57:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56EB62018E for ; Fri, 10 Oct 2014 20:57:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46D262020E for ; Fri, 10 Oct 2014 20:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755146AbaJJU5p (ORCPT ); Fri, 10 Oct 2014 16:57:45 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57173 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888AbaJJU5o (ORCPT ); Fri, 10 Oct 2014 16:57:44 -0400 Received: from pps.filterd (m0044008 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s9AKuGjv009731 for ; Fri, 10 Oct 2014 13:57:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=0qhR36iwb2YW1MqGfcxjAPooI+Zn7jVf7NCgTKf7nnY=; b=ZK8qQi6ywKa5h07eLqJjuHGTT+vCL1g8SgwfquWK586ozPeFbD56vVnzY6UrdrxX/eqd 0WHToh9U1nr0ZY2jFkJBdWXx4kOzDOr6l0d5qygGDeccX7no8Vz9jLorisCLE1Xav72e UU9iH2FGx2NW8etw6okVuDcgq3syexwigME= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0a-00082601.pphosted.com with ESMTP id 1pxnkg85gx-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Fri, 10 Oct 2014 13:57:43 -0700 Received: from localhost (192.168.57.29) by mail.thefacebook.com (192.168.16.15) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 10 Oct 2014 13:57:43 -0700 From: Josef Bacik To: Subject: [PATCH 10/12] Btrfs-progs: deal with mismatch index between dir index and inode ref Date: Fri, 10 Oct 2014 16:57:15 -0400 Message-ID: <1412974637-31334-11-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1412974637-31334-1-git-send-email-jbacik@fb.com> References: <1412974637-31334-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [192.168.57.29] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.28, 0.0.0000 definitions=2014-10-10_08:2014-10-10, 2014-10-10, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=3.2261198479322e-07 kscore.compositescore=0 circleOfTrustscore=502.112 compositescore=0.999776574422466 urlsuspect_oldscore=0.999776574422466 suspectscore=1 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=62764 rbsscore=0.999776574422466 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1410100175 X-FB-Internal: deliver Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes we have a dir index and an inode ref that don't agree on the index. In this case just assume that the inode ref is the ultimate authority on the subject and delete the dir index. This means we have to not reset index if we find a mismatched inode ref to make sure we delete the right dir index. Thanks, Signed-off-by: Josef Bacik --- cmds-check.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index ca890cc..80fa244 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -608,9 +608,10 @@ static int add_inode_backref(struct cache_tree *inode_cache, backref->errors |= REF_ERR_DUP_INODE_REF; if (backref->found_dir_index && backref->index != index) backref->errors |= REF_ERR_INDEX_UNMATCH; + else + backref->index = index; backref->ref_type = itemtype; - backref->index = index; backref->found_inode_ref = 1; } else { BUG_ON(1); @@ -1654,8 +1655,10 @@ static int repair_inode_backrefs(struct btrfs_root *root, if (rec->ino == root_dirid && backref->index == 0) continue; - if (delete && backref->found_dir_index && - !backref->found_inode_ref) { + if (delete && + ((backref->found_dir_index && !backref->found_inode_ref) || + (backref->found_dir_index && backref->found_inode_ref && + backref->errors & REF_ERR_INDEX_UNMATCH))) { ret = delete_dir_index(root, inode_cache, rec, backref); if (ret) break;