From patchwork Tue May 19 01:29:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11556729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67816618 for ; Tue, 19 May 2020 01:29:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35EC4207D3 for ; Tue, 19 May 2020 01:29:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MakHPpxN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbgESB3r (ORCPT ); Mon, 18 May 2020 21:29:47 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:41003 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726276AbgESB3r (ORCPT ); Mon, 18 May 2020 21:29:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589851784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=KIvla5Oy65fDRs5AtMYYjopEMRBiFOvpZOLayh7OShU=; b=MakHPpxNCHsQWU9IsRBE7Cr7pYPbSnJ+CHMgNoKiwnGhx71x3d8XsqthVRS43i7hmDrZiy mBLOtocpQSBJP7inHsoI4pasTHoDyi/+1ZQJHZgyr9qMinh1N4KnoY/Rt6yPxQeMYa8bBA 4gA34PzE8dn3VyWTVUelNkW1hm8/A6k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-Om5yJxcPNECLZ37CU0fgoQ-1; Mon, 18 May 2020 21:29:42 -0400 X-MC-Unique: Om5yJxcPNECLZ37CU0fgoQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D79C7107ACF8; Tue, 19 May 2020 01:29:41 +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 7FEEB261A1; Tue, 19 May 2020 01:29:41 +0000 (UTC) Subject: [PATCH V2] xfs_repair: fix progress reporting From: Eric Sandeen To: linux-xfs Cc: Leonardo Vaz , "Darrick J. Wong" References: Autocrypt: addr=sandeen@redhat.com; prefer-encrypt=mutual; keydata= mQINBE6x99QBEADMR+yNFBc1Y5avoUhzI/sdR9ANwznsNpiCtZlaO4pIWvqQJCjBzp96cpCs nQZV32nqJBYnDpBDITBqTa/EF+IrHx8gKq8TaSBLHUq2ju2gJJLfBoL7V3807PQcI18YzkF+ WL05ODFQ2cemDhx5uLghHEeOxuGj+1AI+kh/FCzMedHc6k87Yu2ZuaWF+Gh1W2ix6hikRJmQ vj5BEeAx7xKkyBhzdbNIbbjV/iGi9b26B/dNcyd5w2My2gxMtxaiP7q5b6GM2rsQklHP8FtW ZiYO7jsg/qIppR1C6Zr5jK1GQlMUIclYFeBbKggJ9mSwXJH7MIftilGQ8KDvNuV5AbkronGC sEEHj2khs7GfVv4pmUUHf1MRIvV0x3WJkpmhuZaYg8AdJlyGKgp+TQ7B+wCjNTdVqMI1vDk2 BS6Rg851ay7AypbCPx2w4d8jIkQEgNjACHVDU89PNKAjScK1aTnW+HNUqg9BliCvuX5g4z2j gJBs57loTWAGe2Ve3cMy3VoQ40Wt3yKK0Eno8jfgzgb48wyycINZgnseMRhxc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0jUDKcviOOfhbQxKJelYNTD5+wE4+TpqH XQLj5HUlzt3JSwqSwx+++FFfWFMheG2HzkfXrvTpud5NrJkGGVn+ErXy6pNf6zSicb+bUXe9 i92UTina2zWaaLEwXspqM338TlFC2JICu8pNt+wHpPCjgy2Ei4u5/4zSYjiA+X1I+V99YJhU +FpT2jzfLUoVsP/6WHWmM/tsS79i50G/PsXYzKOHj/0ZQCKOsJM14NMMCC8gkONe4tek Message-ID: Date: Mon, 18 May 2020 20:29:40 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The Fixes: commit tried to avoid a segfault in case the progress timer went off before the first message type had been set up, but this had the net effect of short-circuiting the pthread start routine, and so the timer didn't get set up at all and we lost all fine-grained progress reporting. The initial problem occurred when log zeroing took more time than the timer interval. So, make a new log zeroing progress item and initialize it when we first set up the timer thread, to be sure that if the timer goes off while we are still zeroing the log, it will be initialized and correct. (We can't offer fine-grained status on log zeroing, so it'll go from zero to $LOGBLOCKS with nothing in between, but it's unlikely that log zeroing will take so long that this really matters.) Reported-by: Leonardo Vaz Fixes: 7f2d6b811755 ("xfs_repair: avoid segfault if reporting progre...") Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong Reviewed-by: Donald Douwsma diff --git a/repair/phase2.c b/repair/phase2.c index 40ea2f84..952ac4a5 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -120,6 +120,9 @@ zero_log( do_error(_("failed to clear log")); } + /* And we are now magically complete! */ + PROG_RPT_INC(prog_rpt_done[0], mp->m_sb.sb_logblocks); + /* * Finally, seed the max LSN from the current state of the log if this * is a v5 filesystem. @@ -160,7 +163,10 @@ phase2( /* Zero log if applicable */ do_log(_(" - zero log...\n")); + + set_progress_msg(PROG_FMT_ZERO_LOG, (uint64_t)mp->m_sb.sb_logblocks); zero_log(mp); + print_final_rpt(); do_log(_(" - scan filesystem freespace and inode maps...\n")); diff --git a/repair/progress.c b/repair/progress.c index 5ee08229..e5a9c1ef 100644 --- a/repair/progress.c +++ b/repair/progress.c @@ -49,35 +49,37 @@ typedef struct progress_rpt_s { static progress_rpt_t progress_rpt_reports[] = { -{FMT1, N_("scanning filesystem freespace"), /* 0 */ +{FMT1, N_("zeroing log"), /* 0 */ + &rpt_fmts[FMT1], &rpt_types[TYPE_BLOCK]}, +{FMT1, N_("scanning filesystem freespace"), /* 1 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("scanning agi unlinked lists"), /* 1 */ +{FMT1, N_("scanning agi unlinked lists"), /* 2 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT2, N_("check uncertain AG inodes"), /* 2 */ +{FMT2, N_("check uncertain AG inodes"), /* 3 */ &rpt_fmts[FMT2], &rpt_types[TYPE_AGI_BUCKET]}, -{FMT1, N_("process known inodes and inode discovery"), /* 3 */ +{FMT1, N_("process known inodes and inode discovery"), /* 4 */ &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]}, -{FMT1, N_("process newly discovered inodes"), /* 4 */ +{FMT1, N_("process newly discovered inodes"), /* 5 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("setting up duplicate extent list"), /* 5 */ +{FMT1, N_("setting up duplicate extent list"), /* 6 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("initialize realtime bitmap"), /* 6 */ +{FMT1, N_("initialize realtime bitmap"), /* 7 */ &rpt_fmts[FMT1], &rpt_types[TYPE_BLOCK]}, -{FMT1, N_("reset realtime bitmaps"), /* 7 */ +{FMT1, N_("reset realtime bitmaps"), /* 8 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("check for inodes claiming duplicate blocks"), /* 8 */ +{FMT1, N_("check for inodes claiming duplicate blocks"), /* 9 */ &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]}, -{FMT1, N_("rebuild AG headers and trees"), /* 9 */ +{FMT1, N_("rebuild AG headers and trees"), /* 10 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("traversing filesystem"), /* 10 */ +{FMT1, N_("traversing filesystem"), /* 12 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT2, N_("traversing all unattached subtrees"), /* 11 */ +{FMT2, N_("traversing all unattached subtrees"), /* 12 */ &rpt_fmts[FMT2], &rpt_types[TYPE_DIR]}, -{FMT2, N_("moving disconnected inodes to lost+found"), /* 12 */ +{FMT2, N_("moving disconnected inodes to lost+found"), /* 13 */ &rpt_fmts[FMT2], &rpt_types[TYPE_INODE]}, -{FMT1, N_("verify and correct link counts"), /* 13 */ +{FMT1, N_("verify and correct link counts"), /* 14 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}, -{FMT1, N_("verify link counts"), /* 14 */ +{FMT1, N_("verify link counts"), /* 15 */ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]} }; @@ -125,7 +127,8 @@ init_progress_rpt (void) */ pthread_mutex_init(&global_msgs.mutex, NULL); - global_msgs.format = NULL; + /* Make sure the format is set to the first phase and not NULL */ + global_msgs.format = &progress_rpt_reports[PROG_FMT_ZERO_LOG]; global_msgs.count = glob_agcount; global_msgs.interval = report_interval; global_msgs.done = prog_rpt_done; diff --git a/repair/progress.h b/repair/progress.h index 9de9eb72..2c1690db 100644 --- a/repair/progress.h +++ b/repair/progress.h @@ -8,26 +8,27 @@ #define PHASE_END 1 -#define PROG_FMT_SCAN_AG 0 /* Phase 2 */ +#define PROG_FMT_ZERO_LOG 0 /* Phase 2 */ +#define PROG_FMT_SCAN_AG 1 -#define PROG_FMT_AGI_UNLINKED 1 /* Phase 3 */ -#define PROG_FMT_UNCERTAIN 2 -#define PROG_FMT_PROCESS_INO 3 -#define PROG_FMT_NEW_INODES 4 +#define PROG_FMT_AGI_UNLINKED 2 /* Phase 3 */ +#define PROG_FMT_UNCERTAIN 3 +#define PROG_FMT_PROCESS_INO 4 +#define PROG_FMT_NEW_INODES 5 -#define PROG_FMT_DUP_EXTENT 5 /* Phase 4 */ -#define PROG_FMT_INIT_RTEXT 6 -#define PROG_FMT_RESET_RTBM 7 -#define PROG_FMT_DUP_BLOCKS 8 +#define PROG_FMT_DUP_EXTENT 6 /* Phase 4 */ +#define PROG_FMT_INIT_RTEXT 7 +#define PROG_FMT_RESET_RTBM 8 +#define PROG_FMT_DUP_BLOCKS 9 -#define PROG_FMT_REBUILD_AG 9 /* Phase 5 */ +#define PROG_FMT_REBUILD_AG 10 /* Phase 5 */ -#define PROG_FMT_TRAVERSAL 10 /* Phase 6 */ -#define PROG_FMT_TRAVERSSUB 11 -#define PROG_FMT_DISCONINODE 12 +#define PROG_FMT_TRAVERSAL 11 /* Phase 6 */ +#define PROG_FMT_TRAVERSSUB 12 +#define PROG_FMT_DISCONINODE 13 -#define PROGRESS_FMT_CORR_LINK 13 /* Phase 7 */ -#define PROGRESS_FMT_VRFY_LINK 14 +#define PROGRESS_FMT_CORR_LINK 14 /* Phase 7 */ +#define PROGRESS_FMT_VRFY_LINK 15 #define DURATION_BUF_SIZE 512