From patchwork Thu Mar 14 21:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10853637 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 1723F1515 for ; Thu, 14 Mar 2019 21:06:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0084A283B2 for ; Thu, 14 Mar 2019 21:06:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2FF329DEC; Thu, 14 Mar 2019 21:06:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 83CD0283B2 for ; Thu, 14 Mar 2019 21:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfCNVGd (ORCPT ); Thu, 14 Mar 2019 17:06:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52372 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfCNVGd (ORCPT ); Thu, 14 Mar 2019 17:06:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2EKwsKk102611; Thu, 14 Mar 2019 21:06:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=mmlJmCHsAlyJE4wwIJEF9kUQrHBhx20IRYv5jhuSajU=; b=ePDdzLk/Mt9UcnoIOhx6pl/yjiTig58yUEC1EOt76hdZCH039e+JEnmY446QTrRCotXR nL9QYzEl7lnRRQWLR2mbU3ysHQPI4lXh1QCODN5uLUmRmxsZNmE8AatgaZbLDn1VCNsF vBp2CaKjb0QaVc+omMhLJVk60Yn1LDj3Od0zItVZrOVV7Psb9UDlANB6DRtTm5LT5+qh B/yRzogpUo+btOLglRywHBrQgN1/BEm5BbIXfzsEbL4IsgW/fpbTqcOjZ+D/rFv7SZ0C JY/CWBNG2SKrnbpjnzxrz7R+i9LARCwuTeFKGrKbcDhbt5ZvvU1bdWJi14VdCR3LrOgs RQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2r464rueny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:06:30 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2EL6UOP010187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 21:06:30 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2EL6UqU007730; Thu, 14 Mar 2019 21:06:30 GMT Received: from localhost (/10.145.178.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Mar 2019 21:06:29 +0000 Subject: [PATCH 26/36] xfs_repair: refactor buffer ops assignments during phase 5 From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 14 Mar 2019 14:06:29 -0700 Message-ID: <155259758961.31886.4826767055567611572.stgit@magnolia> In-Reply-To: <155259742281.31886.17157720770696604377.stgit@magnolia> References: <155259742281.31886.17157720770696604377.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9195 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903140143 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 From: Darrick J. Wong Refactor the buffer ops assignments in phase 5 to use a helper function to determine the correct buf_ops instead of open-coding them. Signed-off-by: Darrick J. Wong --- repair/phase5.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/repair/phase5.c b/repair/phase5.c index 367c3ab9..0c53096f 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -615,6 +615,24 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, return(extra_blocks); } +/* Map btnum to buffer ops for the types that need it. */ +static const struct xfs_buf_ops * +btnum_to_ops( + xfs_btnum_t btnum) +{ + switch (btnum) { + case XFS_BTNUM_BNO: + case XFS_BTNUM_CNT: + return &xfs_allocbt_buf_ops; + case XFS_BTNUM_INO: + case XFS_BTNUM_FINO: + return &xfs_inobt_buf_ops; + default: + ASSERT(0); + return NULL; + } +} + static void prop_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs, xfs_agblock_t startblock, @@ -625,6 +643,7 @@ prop_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_alloc_ptr_t *bt_ptr; xfs_agblock_t agbno; bt_stat_level_t *lptr; + const struct xfs_buf_ops *ops = btnum_to_ops(btnum); ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT); @@ -675,7 +694,7 @@ prop_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, /* * initialize block header */ - lptr->buf_p->b_ops = &xfs_allocbt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, level, @@ -723,6 +742,7 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno, extent_tree_node_t *ext_ptr; bt_stat_level_t *lptr; xfs_extlen_t freeblks; + const struct xfs_buf_ops *ops = btnum_to_ops(btnum); ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT); @@ -754,7 +774,7 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno, /* * initialize block header */ - lptr->buf_p->b_ops = &xfs_allocbt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, i, 0, agno, 0); @@ -781,7 +801,7 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno, /* * block initialization, lay in block header */ - lptr->buf_p->b_ops = &xfs_allocbt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, 0, 0, agno, 0); @@ -990,6 +1010,7 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs, xfs_inobt_ptr_t *bt_ptr; xfs_agblock_t agbno; bt_stat_level_t *lptr; + const struct xfs_buf_ops *ops = btnum_to_ops(btnum); level++; @@ -1038,7 +1059,7 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs, /* * initialize block header */ - lptr->buf_p->b_ops = &xfs_inobt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, @@ -1130,6 +1151,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_inobt_rec_t *bt_rec; ino_tree_node_t *ino_rec; bt_stat_level_t *lptr; + const struct xfs_buf_ops *ops = btnum_to_ops(btnum); xfs_agino_t count = 0; xfs_agino_t freecount = 0; int inocnt; @@ -1160,7 +1182,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno, * initialize block header */ - lptr->buf_p->b_ops = &xfs_inobt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, i, 0, agno, 0); @@ -1188,7 +1210,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno, /* * block initialization, lay in block header */ - lptr->buf_p->b_ops = &xfs_inobt_buf_ops; + lptr->buf_p->b_ops = ops; bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p); memset(bt_hdr, 0, mp->m_sb.sb_blocksize); libxfs_btree_init_block(mp, lptr->buf_p, btnum, 0, 0, agno, 0);