From patchwork Wed Sep 12 19:26:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 10598179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FC7314BD for ; Wed, 12 Sep 2018 19:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF17B2AA88 for ; Wed, 12 Sep 2018 19:26:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2F052AA99; Wed, 12 Sep 2018 19:26:51 +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 EBD4F2AA88 for ; Wed, 12 Sep 2018 19:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728198AbeIMAcq (ORCPT ); Wed, 12 Sep 2018 20:32:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728196AbeIMAcq (ORCPT ); Wed, 12 Sep 2018 20:32:46 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12BEE3082A34 for ; Wed, 12 Sep 2018 19:26:49 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF592308BE75 for ; Wed, 12 Sep 2018 19:26:48 +0000 (UTC) To: linux-xfs From: Eric Sandeen Subject: [PATCH] xfs_repair: warn properly about reflink flag with and without -n Message-ID: <700e2326-fd4c-224e-bf9c-cb77756e4a55@redhat.com> Date: Wed, 12 Sep 2018 14:26:48 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 12 Sep 2018 19:26:49 +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 The decision to emit a warning in fix_inode_reflink_flag seems broken; in no-modify mode we'll do_warn that we're setting it (even though we don't), and we'll be silent if it needs to be cleared. Fix this so it's the standard "would" in no-modify, and "will" in regular mode. This also ensures that we return the proper status if flags are found to be incorrect in -n or -e mode. Signed-off-by: Eric Sandeen diff --git a/repair/rmap.c b/repair/rmap.c index bffb5b61..7ef2d0fd 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -1142,16 +1142,27 @@ fix_inode_reflink_flag( struct xfs_dinode *dino; struct xfs_buf *buf; + if (no_modify) { + if (set) + do_warn( +_("would set reflink flag on inode %"PRIu64"\n"), + XFS_AGINO_TO_INO(mp, agno, agino)); + else + do_warn( +_("would clear reflink flag on inode %"PRIu64"\n"), + XFS_AGINO_TO_INO(mp, agno, agino)); + return 0; + } + + /* Modify mode */ if (set) do_warn( _("setting reflink flag on inode %"PRIu64"\n"), XFS_AGINO_TO_INO(mp, agno, agino)); - else if (!no_modify) /* && !set */ + else do_warn( _("clearing reflink flag on inode %"PRIu64"\n"), XFS_AGINO_TO_INO(mp, agno, agino)); - if (no_modify) - return 0; buf = get_agino_buf(mp, agno, agino, &dino); if (!buf)