From patchwork Thu Jun 14 22:16:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Benatto X-Patchwork-Id: 10465397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A45CC6020F for ; Thu, 14 Jun 2018 22:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 875B528C2C for ; Thu, 14 Jun 2018 22:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BFAE28C49; Thu, 14 Jun 2018 22:16:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29C6728C2C for ; Thu, 14 Jun 2018 22:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936073AbeFNWQw (ORCPT ); Thu, 14 Jun 2018 18:16:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37678 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936045AbeFNWQv (ORCPT ); Thu, 14 Jun 2018 18:16:51 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D45A4BDD1 for ; Thu, 14 Jun 2018 22:16:51 +0000 (UTC) Received: from barchetta.redhat.com (ovpn-116-44.gru2.redhat.com [10.97.116.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A0B520078AF; Thu, 14 Jun 2018 22:16:48 +0000 (UTC) From: Marco Benatto To: linux-xfs@vger.kernel.org Cc: mbenatto@redhat.com, sandeen@redhat.com Subject: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf directory Date: Thu, 14 Jun 2018 19:16:46 -0300 Message-Id: <20180614221646.20017-1-mbenatto@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 14 Jun 2018 22:16:51 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently when root inode is in short-form and its parent ino has an invalid value, process_sf_dir2() ends up not fixing it, because if verify_inum() fails we never get to the next case which would fix the root inode's parent pointer. This behavior triggers the following assert on process_dir2(): ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) || (ino == mp->m_sb.sb_rootino && (ino == *parent || need_root_dotdot == 1))); This patch fixes this behavior by making sure we always properly handle rootino parent pointer in process_sf_dir2() Signed-off-by: Marco Benatto Signed-off-by: Eric Sandeen --- repair/dir2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/repair/dir2.c b/repair/dir2.c index e162d2b..225f926 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -495,8 +495,10 @@ _("corrected entry offsets in directory %" PRIu64 "\n"), /* * if parent entry is bogus, null it out. we'll fix it later . + * If the validation fails for the root inode we fix it in + * the next else case. */ - if (verify_inum(mp, *parent)) { + if (verify_inum(mp, *parent) && ino != mp->m_sb.sb_rootino) { do_warn( _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),