From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01A6B8BEE for ; Mon, 21 Jul 2025 03:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753067298; cv=none; b=tVmirLOBDSWNnoE0yuYlDMdmBfDFwL01ndtcRn8kB9CocfaXRJqsHfohu55O6kGWEBlMGox7/ZtgQsfrlWhG/prUjOFX8ySqseBWXzRqxOABkqH903a3wJ5DvnRXwR8mbXJqtf+umbiW5RGZcWQqj2/ImLA8ZfcSzdLy7iYshPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753067298; c=relaxed/simple; bh=7kjh95nBJiPLAQsE/kUaEUe3O6FLXdQGqny1//I2HF8=; h=Message-ID:Date:MIME-Version:Subject:From:To:CC:References: In-Reply-To:Content-Type; b=c7I5baAULA7xf9ZF5MVjCzB6Poxilen6gnhKNV6iNPazGP51zsfmfzwFFRj+9OZr3S2X2hI9krkuKVuxLcNCj3uugRptjPM/YHjE2ol9Wqz0A5pZ6Ek/c10zJXp3YkAwlGswHiJNu7aNFZIzIlAPmij3mmthp9pNAhebNFMundc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bllbC3bNCzSjbM; Mon, 21 Jul 2025 11:03:35 +0800 (CST) Received: from kwepemo100017.china.huawei.com (unknown [7.202.195.215]) by mail.maildlp.com (Postfix) with ESMTPS id 8C2FE180B57; Mon, 21 Jul 2025 11:08:06 +0800 (CST) Received: from [10.174.187.231] (10.174.187.231) by kwepemo100017.china.huawei.com (7.202.195.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 21 Jul 2025 11:08:05 +0800 Message-ID: <441c158e-8de3-e0f1-60f2-fa10b7bdfffe@huawei.com> Date: Mon, 21 Jul 2025 11:08:05 +0800 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v4] debugfs/logdump.c: Add parameter t to dump sequence commit timestamps From: zhanchengbin To: Theodore Ts'o CC: "Darrick J. Wong" , , , References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemo100017.china.huawei.com (7.202.195.215) Friendly ping, thanks. On 2025/7/3 20:07, zhanchengbin wrote: > When filesystem errors occur, inspect journal sequences with parameter t to > dump commit timestamps. > > Signed-off-by: zhanchengbin > --- > v4: (1) Fix incorrect variable type; (2) Add logging for error branches. > - Link to v3: > https://patchwork.ozlabs.org/project/linux-ext4/patch/32252e29-aba9-df6f-3b97-d3774df375ad@huawei.com/ > > v3: Change from displaying UTC time to local time. > - Link to v2: > https://patchwork.ozlabs.org/project/linux-ext4/patch/5a4b703c-6940-d9da-5686-337e3220d3a4@huawei.com/ > > v2: Correct abnormal formats in the patch. > - Link to v1: > https://patchwork.ozlabs.org/project/linux-ext4/patch/50aeb0c1-9f14-ed04-c3b7-7a50f61c3341@huawei.com/ > > --- >  debugfs/logdump.c | 61 ++++++++++++++++++++++++++++++++++++++++------- >  1 file changed, 52 insertions(+), 9 deletions(-) > > diff --git a/debugfs/logdump.c b/debugfs/logdump.c > index 324ed42..a1256c4 100644 > --- a/debugfs/logdump.c > +++ b/debugfs/logdump.c > @@ -47,7 +47,7 @@ enum journal_location {JOURNAL_IS_INTERNAL, > JOURNAL_IS_EXTERNAL}; > >  #define ANY_BLOCK ((blk64_t) -1) > > -static int        dump_all, dump_super, dump_old, dump_contents, > dump_descriptors; > +static int        dump_all, dump_super, dump_old, dump_contents, > dump_descriptors, dump_time; >  static int64_t        dump_counts; >  static blk64_t        block_to_dump, bitmap_to_dump, inode_block_to_dump; >  static unsigned int    group_to_dump, inode_offset_to_dump; > @@ -67,6 +67,8 @@ static void dump_descriptor_block(FILE *, struct > journal_source *, >                    char *, journal_superblock_t *, >                    unsigned int *, unsigned int, __u32, tid_t); > > +static void dump_commit_time(FILE *out_file, char *buf); > + >  static void dump_revoke_block(FILE *, char *, journal_superblock_t *, >                    unsigned int, unsigned int, tid_t); > > @@ -118,10 +120,11 @@ void do_logdump(int argc, ss_argv_t argv, int > sci_idx EXT2FS_ATTR((unused)), >      inode_block_to_dump = ANY_BLOCK; >      inode_to_dump = -1; >      dump_counts = -1; > +    dump_time = 0; >      wrapped_flag = false; > >      reset_getopt(); > -    while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) { > +    while ((c = getopt (argc, argv, "ab:ci:f:OsSn:t")) != EOF) { >          switch (c) { >          case 'a': >              dump_all++; > @@ -162,6 +165,9 @@ void do_logdump(int argc, ss_argv_t argv, int > sci_idx EXT2FS_ATTR((unused)), >                  return; >              } >              break; > +        case 't': > +            dump_time++; > +            break; >          default: >              goto print_usage; >          } > @@ -521,21 +527,33 @@ static void dump_journal(char *cmdname, FILE > *out_file, >                  break; >          } > > -        if (dump_descriptors) { > -            fprintf (out_file, "Found expected sequence %u, " > -                 "type %u (%s) at block %u\n", > -                 sequence, blocktype, > -                 type_to_name(blocktype), blocknr); > -        } > - >          switch (blocktype) { >          case JBD2_DESCRIPTOR_BLOCK: > +            if (dump_descriptors) { > +                fprintf (out_file, "Found expected sequence %u, " > +                     "type %u (%s) at block %u\n", > +                     sequence, blocktype, > +                     type_to_name(blocktype), blocknr); > +            } > + >              dump_descriptor_block(out_file, source, buf, jsb, >                            &blocknr, blocksize, maxlen, >                            transaction); >              continue; > >          case JBD2_COMMIT_BLOCK: > +            if (dump_descriptors) { > +                fprintf (out_file, "Found expected sequence %u, " > +                     "type %u (%s) at block %u", > +                     sequence, blocktype, > +                     type_to_name(blocktype), blocknr); > +            } > + > +            if (dump_time) > +                dump_commit_time(out_file, buf); > +            else > +                fprintf(out_file, "\n"); > + >              cur_counts++; >              transaction++; >              blocknr++; > @@ -543,6 +561,13 @@ static void dump_journal(char *cmdname, FILE > *out_file, >              continue; > >          case JBD2_REVOKE_BLOCK: > +            if (dump_descriptors) { > +                fprintf (out_file, "Found expected sequence %u, " > +                     "type %u (%s) at block %u\n", > +                     sequence, blocktype, > +                     type_to_name(blocktype), blocknr); > +            } > + >              dump_revoke_block(out_file, buf, jsb, >                        blocknr, blocksize, >                        transaction); > @@ -742,6 +767,24 @@ static void dump_descriptor_block(FILE *out_file, >      *blockp = blocknr; >  } > > +static void dump_commit_time(FILE *out_file, char *buf) > +{ > +    struct commit_header    *header; > +    uint64_t    commit_sec; > +    time_t        timestamp; > +    char        time_buffer[26]; > +    char        *result; > + > +    header = (struct commit_header *)buf; > +    commit_sec = be64_to_cpu(header->h_commit_sec); > + > +    timestamp = commit_sec; > +    result = ctime_r(×tamp, time_buffer); > +    if (result) > +        fprintf(out_file, ", commit at: %s", time_buffer); > +    else > +        fprintf(out_file, ", commit_sec is %llu\n", commit_sec); > +} > >  static void dump_revoke_block(FILE *out_file, char *buf, >                    journal_superblock_t *jsb EXT2FS_ATTR((unused)),