From patchwork Thu Aug 25 23:52:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9300565 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 9CF3860757 for ; Thu, 25 Aug 2016 23:53:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D06D20453 for ; Thu, 25 Aug 2016 23:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81AFD29414; Thu, 25 Aug 2016 23:53:30 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C8AE020453 for ; Thu, 25 Aug 2016 23:53:29 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 3EA82825E; Thu, 25 Aug 2016 18:52:39 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay2.corp.sgi.com [137.38.102.29]) by oss.sgi.com (Postfix) with ESMTP id 535A7825A for ; Thu, 25 Aug 2016 18:52:38 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay2.corp.sgi.com (Postfix) with ESMTP id 2425830404E for ; Thu, 25 Aug 2016 16:52:38 -0700 (PDT) X-ASG-Debug-ID: 1472169155-0bf57b5314209bd0001-NocioJ Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by cuda.sgi.com with ESMTP id Qzrd0H5oey5eDHDe (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Aug 2016 16:52:36 -0700 (PDT) X-Barracuda-Envelope-From: darrick.wong@oracle.com X-Barracuda-Effective-Source-IP: userp1040.oracle.com[156.151.31.81] X-Barracuda-Apparent-Source-IP: 156.151.31.81 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PNqYN3032620 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 23:52:34 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u7PNqXqi012701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 23:52:34 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7PNqXeu023704; Thu, 25 Aug 2016 23:52:33 GMT Received: from localhost (/10.145.178.207) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Aug 2016 16:52:32 -0700 Subject: [PATCH 55/71] xfs_logprint: support refcount redo items From: "Darrick J. Wong" X-ASG-Orig-Subj: [PATCH 55/71] xfs_logprint: support refcount redo items To: david@fromorbit.com, darrick.wong@oracle.com Date: Thu, 25 Aug 2016 16:52:31 -0700 Message-ID: <147216915147.4420.13686802045570738569.stgit@birch.djwong.org> In-Reply-To: <147216879156.4420.2446767701729565218.stgit@birch.djwong.org> References: <147216879156.4420.2446767701729565218.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-Barracuda-Connect: userp1040.oracle.com[156.151.31.81] X-Barracuda-Start-Time: 1472169156 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.25:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 6151 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.7 tests=BSF_SC0_MISMATCH_TO, UNPARSEABLE_RELAY X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32328 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.00 UNPARSEABLE_RELAY Informational: message has unparseable relay lines Cc: linux-xfs@vger.kernel.org, xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Print reference count update redo items. Signed-off-by: Darrick J. Wong --- logprint/log_misc.c | 11 +++ logprint/log_print_all.c | 12 ++++ logprint/log_redo.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++ logprint/logprint.h | 5 ++ 4 files changed, 178 insertions(+) diff --git a/logprint/log_misc.c b/logprint/log_misc.c index f6488d9..5389b72 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -1008,6 +1008,17 @@ xlog_print_record( be32_to_cpu(op_head->oh_len)); break; } + case XFS_LI_CUI: { + skip = xlog_print_trans_cui(&ptr, + be32_to_cpu(op_head->oh_len), + continued); + break; + } + case XFS_LI_CUD: { + skip = xlog_print_trans_cud(&ptr, + be32_to_cpu(op_head->oh_len)); + break; + } case XFS_LI_QUOTAOFF: { skip = xlog_print_trans_qoff(&ptr, be32_to_cpu(op_head->oh_len)); diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index 46952c4..eb3e326 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -418,6 +418,12 @@ xlog_recover_print_logitem( case XFS_LI_RUI: xlog_recover_print_rui(item); break; + case XFS_LI_CUD: + xlog_recover_print_cud(item); + break; + case XFS_LI_CUI: + xlog_recover_print_cui(item); + break; case XFS_LI_DQUOT: xlog_recover_print_dquot(item); break; @@ -458,6 +464,12 @@ xlog_recover_print_item( case XFS_LI_RUI: printf("RUI"); break; + case XFS_LI_CUD: + printf("CUD"); + break; + case XFS_LI_CUI: + printf("CUI"); + break; case XFS_LI_DQUOT: printf("DQ "); break; diff --git a/logprint/log_redo.c b/logprint/log_redo.c index add0764..6a2e30a 100644 --- a/logprint/log_redo.c +++ b/logprint/log_redo.c @@ -380,3 +380,153 @@ xlog_recover_print_rud( f = item->ri_buf[0].i_addr; xlog_print_trans_rud(&f, sizeof(struct xfs_rud_log_format)); } + +/* Reference Count Update Items */ + +static int +xfs_cui_copy_format( + char *buf, + uint len, + struct xfs_cui_log_format *dst_fmt, + int continued) +{ + uint nextents = ((struct xfs_cui_log_format *)buf)->cui_nextents; + uint dst_len = sizeof(struct xfs_cui_log_format) + + (nextents - 1) * sizeof(struct xfs_phys_extent); + + if (len == dst_len || continued) { + memcpy((char *)dst_fmt, buf, len); + return 0; + } + fprintf(stderr, _("%s: bad size of CUI format: %u; expected %u; nextents = %u\n"), + progname, len, dst_len, nextents); + return 1; +} + +int +xlog_print_trans_cui( + char **ptr, + uint src_len, + int continued) +{ + struct xfs_cui_log_format *src_f, *f = NULL; + uint dst_len; + uint nextents; + struct xfs_phys_extent *ex; + int i; + int error = 0; + int core_size; + + core_size = offsetof(struct xfs_cui_log_format, cui_extents); + + /* + * memmove to ensure 8-byte alignment for the long longs in + * struct xfs_cui_log_format structure + */ + src_f = malloc(src_len); + if (src_f == NULL) { + fprintf(stderr, _("%s: %s: malloc failed\n"), + progname, __func__); + exit(1); + } + memmove((char*)src_f, *ptr, src_len); + *ptr += src_len; + + /* convert to native format */ + nextents = src_f->cui_nextents; + dst_len = sizeof(struct xfs_cui_log_format) + + (nextents - 1) * sizeof(struct xfs_phys_extent); + + if (continued && src_len < core_size) { + printf(_("CUI: Not enough data to decode further\n")); + error = 1; + goto error; + } + + f = malloc(dst_len); + if (f == NULL) { + fprintf(stderr, _("%s: %s: malloc failed\n"), + progname, __func__); + exit(1); + } + if (xfs_cui_copy_format((char *)src_f, src_len, f, continued)) { + error = 1; + goto error; + } + + printf(_("CUI: #regs: %d num_extents: %d id: 0x%llx\n"), + f->cui_size, f->cui_nextents, (unsigned long long)f->cui_id); + + if (continued) { + printf(_("CUI extent data skipped (CONTINUE set, no space)\n")); + goto error; + } + + ex = f->cui_extents; + for (i=0; i < f->cui_nextents; i++) { + printf("(s: 0x%llx, l: %d, f: 0x%x) ", + (unsigned long long)ex->pe_startblock, ex->pe_len, + ex->pe_flags); + printf("\n"); + ex++; + } +error: + free(src_f); + free(f); + return error; +} + +void +xlog_recover_print_cui( + struct xlog_recover_item *item) +{ + char *src_f; + uint src_len; + + src_f = item->ri_buf[0].i_addr; + src_len = item->ri_buf[0].i_len; + + xlog_print_trans_cui(&src_f, src_len, 0); +} + +int +xlog_print_trans_cud( + char **ptr, + uint len) +{ + struct xfs_cud_log_format *f; + struct xfs_cud_log_format lbuf; + + /* size without extents at end */ + uint core_size = sizeof(struct xfs_cud_log_format); + + /* + * memmove to ensure 8-byte alignment for the long longs in + * xfs_efd_log_format_t structure + */ + memmove(&lbuf, *ptr, MIN(core_size, len)); + f = &lbuf; + *ptr += len; + if (len >= core_size) { + printf(_("CUD: #regs: %d id: 0x%llx\n"), + f->cud_size, + (unsigned long long)f->cud_cui_id); + + /* don't print extents as they are not used */ + + return 0; + } else { + printf(_("CUD: Not enough data to decode further\n")); + return 1; + } +} + +void +xlog_recover_print_cud( + struct xlog_recover_item *item) +{ + char *f; + + f = item->ri_buf[0].i_addr; + xlog_print_trans_cud(&f, sizeof(struct xfs_cud_log_format)); +} diff --git a/logprint/logprint.h b/logprint/logprint.h index 0c03c08..a1115e2 100644 --- a/logprint/logprint.h +++ b/logprint/logprint.h @@ -56,4 +56,9 @@ extern void xlog_recover_print_rui(struct xlog_recover_item *item); extern int xlog_print_trans_rud(char **ptr, uint len); extern void xlog_recover_print_rud(struct xlog_recover_item *item); +extern int xlog_print_trans_cui(char **ptr, uint src_len, int continued); +extern void xlog_recover_print_cui(struct xlog_recover_item *item); +extern int xlog_print_trans_cud(char **ptr, uint len); +extern void xlog_recover_print_cud(struct xlog_recover_item *item); + #endif /* LOGPRINT_H */