From patchwork Wed May 30 15:51:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 10439307 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 B8AFD60327 for ; Wed, 30 May 2018 15:52:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6D58290B0 for ; Wed, 30 May 2018 15:52:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B094290B8; Wed, 30 May 2018 15:52:19 +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 45DB429227 for ; Wed, 30 May 2018 15:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753627AbeE3Pvq (ORCPT ); Wed, 30 May 2018 11:51:46 -0400 Received: from sandeen.net ([63.231.237.45]:50842 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753483AbeE3Pvq (ORCPT ); Wed, 30 May 2018 11:51:46 -0400 Received: from [10.0.0.4] (liberator [10.0.0.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id A280917DFC; Wed, 30 May 2018 10:51:42 -0500 (CDT) Subject: [PATCH 2/2] xfs_repair: notify user if free inodes contain errors To: Eric Sandeen , linux-xfs References: <4f70c5e0-8093-38b3-256d-ee16460aa4ad@redhat.com> From: Eric Sandeen Message-ID: <8a7acb77-f0ce-0b6d-cb2c-2dabcc2bab63@sandeen.net> Date: Wed, 30 May 2018 10:51:45 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <4f70c5e0-8093-38b3-256d-ee16460aa4ad@redhat.com> Content-Language: en-US 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 xfs_repair checks allocated but unused (free) inodes in on-disk clusters, and up until now silently repairs any errors, and as a result does not alter exit status if errors are found. The in-kernel verifiers will be noisy about these errors and instruct the user to run repair, so it's best if repair is explicit about any fixes it makes. This shamelessly re-uses xfs_dinode_verify for this purpose. Signed-off-by: Eric Sandeen --- -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 63bf27e..0f68e58 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -134,6 +134,7 @@ #define xfs_symlink_hdr_ok libxfs_symlink_hdr_ok #define xfs_verify_cksum libxfs_verify_cksum +#define xfs_dinode_verify libxfs_dinode_verify #define xfs_alloc_ag_max_usable libxfs_alloc_ag_max_usable #define xfs_allocbt_maxrecs libxfs_allocbt_maxrecs diff --git a/repair/dinode.c b/repair/dinode.c index 92130db..a4e3c51 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2448,9 +2448,15 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), * it just in case to ensure that format, etc. are * set correctly */ - if (!no_modify) { - clear_dinode(mp, dino, lino); - *dirty += 1; + if (libxfs_dinode_verify(mp, lino, dino) != NULL) { + do_warn( + _("free inode %" PRIu64 " contains errors, "), lino); + if (!no_modify) { + clear_dinode(mp, dino, lino); + do_warn(_("corrected\n")); + *dirty += 1; + } else + do_warn(_("would correct\n")); } *used = is_free; return 0;