From patchwork Tue Sep 14 02:40:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 437E1C433F5 for ; Tue, 14 Sep 2021 02:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 217DE610CC for ; Tue, 14 Sep 2021 02:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237467AbhINCl1 (ORCPT ); Mon, 13 Sep 2021 22:41:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:52926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINClW (ORCPT ); Mon, 13 Sep 2021 22:41:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B9526610F9; Tue, 14 Sep 2021 02:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587205; bh=u9y2wPlxu19w3/BqbAGhJbcAGeL2XisX9FfrLXI6Pkg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=F9GtDCWDbpQd+DPnlxo3kafhdxmt0kWfHVwFZFIRTIFzHnoKGs2vZzs06BDoScdAa 3+UoetPnPBkvnLnrmOxE8c2OGYjLW21s8e3jpsBVDWpikFhoKrTzSZ99unMwOOpgcp toBcIV1inpFQUmPL25UiGF586ac/I4f82HFaB3kIs5URMaMNPOzv7JxRJYyqJQ0am2 ypFtpHSwND56DQILl5ETaL7eSjsawrRnmBlTy0/XluAqOp9iR59kLqv+QcgYzGs9Hy kHNd/UsI+FajqBD6taB1l/N/FIwcqfqDptJqbjhvvmxWfpGpMqajfH5dbaRaEfLrGF I9ZTarbuWziTw== Subject: [PATCH 01/43] xfs_{copy,db,logprint,repair}: pass xfs_mount pointers instead of xfs_sb pointers From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:05 -0700 Message-ID: <163158720548.1604118.4802855306324389235.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Where possible, convert these four programs to pass a pointer to a struct xfs_mount instead of the struct xfs_sb inside the mount. This will make it easier to convert some of the code to the new xfs_has_FEATURE predicates later on. Signed-off-by: Darrick J. Wong --- copy/xfs_copy.c | 21 +++++++------ db/sb.c | 66 ++++++++++++++++++++-------------------- libxfs/init.c | 14 ++++----- logprint/logprint.c | 2 + repair/versions.c | 84 +++++++++++++++++++++++++-------------------------- repair/versions.h | 4 +- repair/xfs_repair.c | 2 + 7 files changed, 95 insertions(+), 98 deletions(-) diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index fc7d225f..5c4f65b4 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -512,9 +512,9 @@ write_wbuf(void) static void sb_update_uuid( - xfs_sb_t *sb, /* Original fs superblock */ - ag_header_t *ag_hdr, /* AG hdr to update for this copy */ - thread_args *tcarg) /* Args for this thread, with UUID */ + struct xfs_mount *mp, + ag_header_t *ag_hdr, /* AG hdr to update for this copy */ + thread_args *tcarg) /* Args for this thread, with UUID */ { /* * If this filesystem has CRCs, the original UUID is stamped into @@ -523,24 +523,25 @@ sb_update_uuid( * we must copy the original sb_uuid to the sb_meta_uuid slot and set * the incompat flag for the feature on this copy. */ - if (xfs_sb_version_hascrc(sb) && !xfs_sb_version_hasmetauuid(sb) && - !uuid_equal(&tcarg->uuid, &sb->sb_uuid)) { + if (xfs_sb_version_hascrc(&mp->m_sb) && + !xfs_sb_version_hasmetauuid(&mp->m_sb) && + !uuid_equal(&tcarg->uuid, &mp->m_sb.sb_uuid)) { uint32_t feat; feat = be32_to_cpu(ag_hdr->xfs_sb->sb_features_incompat); feat |= XFS_SB_FEAT_INCOMPAT_META_UUID; ag_hdr->xfs_sb->sb_features_incompat = cpu_to_be32(feat); platform_uuid_copy(&ag_hdr->xfs_sb->sb_meta_uuid, - &sb->sb_uuid); + &mp->m_sb.sb_uuid); } /* Copy the (possibly new) fs-identifier UUID into sb_uuid */ platform_uuid_copy(&ag_hdr->xfs_sb->sb_uuid, &tcarg->uuid); /* We may have changed the UUID, so update the superblock CRC */ - if (xfs_sb_version_hascrc(sb)) - xfs_update_cksum((char *)ag_hdr->xfs_sb, sb->sb_sectsize, - XFS_SB_CRC_OFF); + if (xfs_sb_version_hascrc(&mp->m_sb)) + xfs_update_cksum((char *)ag_hdr->xfs_sb, mp->m_sb.sb_sectsize, + XFS_SB_CRC_OFF); } int @@ -1221,7 +1222,7 @@ main(int argc, char **argv) /* do each thread in turn, each has its own UUID */ for (j = 0, tcarg = targ; j < num_targets; j++) { - sb_update_uuid(sb, &ag_hdr, tcarg); + sb_update_uuid(mp, &ag_hdr, tcarg); do_write(tcarg, NULL); tcarg++; } diff --git a/db/sb.c b/db/sb.c index cec7dce9..b4c14276 100644 --- a/db/sb.c +++ b/db/sb.c @@ -633,76 +633,76 @@ do_version(xfs_agnumber_t agno, uint16_t version, uint32_t features) static char * version_string( - xfs_sb_t *sbp) + struct xfs_mount *mp) { - static char s[1024]; + static char s[1024]; - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_1) + if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_1) strcpy(s, "V1"); - else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_2) + else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_2) strcpy(s, "V2"); - else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_3) + else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_3) strcpy(s, "V3"); - else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) + else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_4) strcpy(s, "V4"); - else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) + else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) strcpy(s, "V5"); /* * We assume the state of these features now, so macros don't exist for * them any more. */ - if (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT) + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT) strcat(s, ",NLINK"); - if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_SHAREDBIT) strcat(s, ",SHARED"); - if (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT) + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT) strcat(s, ",DIRV2"); - if (xfs_sb_version_hasattr(sbp)) + if (xfs_sb_version_hasattr(&mp->m_sb)) strcat(s, ",ATTR"); - if (xfs_sb_version_hasquota(sbp)) + if (xfs_sb_version_hasquota(&mp->m_sb)) strcat(s, ",QUOTA"); - if (xfs_sb_version_hasalign(sbp)) + if (xfs_sb_version_hasalign(&mp->m_sb)) strcat(s, ",ALIGN"); - if (xfs_sb_version_hasdalign(sbp)) + if (xfs_sb_version_hasdalign(&mp->m_sb)) strcat(s, ",DALIGN"); - if (xfs_sb_version_haslogv2(sbp)) + if (xfs_sb_version_haslogv2(&mp->m_sb)) strcat(s, ",LOGV2"); /* This feature is required now as well */ - if (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT) + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_EXTFLGBIT) strcat(s, ",EXTFLG"); - if (xfs_sb_version_hassector(sbp)) + if (xfs_sb_version_hassector(&mp->m_sb)) strcat(s, ",SECTOR"); - if (xfs_sb_version_hasasciici(sbp)) + if (xfs_sb_version_hasasciici(&mp->m_sb)) strcat(s, ",ASCII_CI"); - if (xfs_sb_version_hasmorebits(sbp)) + if (xfs_sb_version_hasmorebits(&mp->m_sb)) strcat(s, ",MOREBITS"); - if (xfs_sb_version_hasattr2(sbp)) + if (xfs_sb_version_hasattr2(&mp->m_sb)) strcat(s, ",ATTR2"); - if (xfs_sb_version_haslazysbcount(sbp)) + if (xfs_sb_version_haslazysbcount(&mp->m_sb)) strcat(s, ",LAZYSBCOUNT"); - if (xfs_sb_version_hasprojid32bit(sbp)) + if (xfs_sb_version_hasprojid32bit(&mp->m_sb)) strcat(s, ",PROJID32BIT"); - if (xfs_sb_version_hascrc(sbp)) + if (xfs_sb_version_hascrc(&mp->m_sb)) strcat(s, ",CRC"); - if (xfs_sb_version_hasftype(sbp)) + if (xfs_sb_version_hasftype(&mp->m_sb)) strcat(s, ",FTYPE"); - if (xfs_sb_version_hasfinobt(sbp)) + if (xfs_sb_version_hasfinobt(&mp->m_sb)) strcat(s, ",FINOBT"); - if (xfs_sb_version_hassparseinodes(sbp)) + if (xfs_sb_version_hassparseinodes(&mp->m_sb)) strcat(s, ",SPARSE_INODES"); - if (xfs_sb_version_hasmetauuid(sbp)) + if (xfs_sb_version_hasmetauuid(&mp->m_sb)) strcat(s, ",META_UUID"); - if (xfs_sb_version_hasrmapbt(sbp)) + if (xfs_sb_version_hasrmapbt(&mp->m_sb)) strcat(s, ",RMAPBT"); - if (xfs_sb_version_hasreflink(sbp)) + if (xfs_sb_version_hasreflink(&mp->m_sb)) strcat(s, ",REFLINK"); - if (xfs_sb_version_hasinobtcounts(sbp)) + if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) strcat(s, ",INOBTCNT"); - if (xfs_sb_version_hasbigtime(sbp)) + if (xfs_sb_version_hasbigtime(&mp->m_sb)) strcat(s, ",BIGTIME"); - if (xfs_sb_version_needsrepair(sbp)) + if (xfs_sb_version_needsrepair(&mp->m_sb)) strcat(s, ",NEEDSREPAIR"); return s; } @@ -834,7 +834,7 @@ version_f( } dbprintf(_("versionnum [0x%x+0x%x] = %s\n"), mp->m_sb.sb_versionnum, - mp->m_sb.sb_features2, version_string(&mp->m_sb)); + mp->m_sb.sb_features2, version_string(mp)); if (argc == 3) { /* now reset... */ mp->m_sb.sb_versionnum = version; diff --git a/libxfs/init.c b/libxfs/init.c index c3e6a899..735c7851 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -421,22 +421,20 @@ rtmount_init( int flags) { struct xfs_buf *bp; /* buffer for last block of subvolume */ - struct xfs_sb *sbp; /* filesystem superblock copy in mount */ xfs_daddr_t d; /* address of last block of subvolume */ int error; - sbp = &mp->m_sb; - if (sbp->sb_rblocks == 0) + if (mp->m_sb.sb_rblocks == 0) return 0; - if (xfs_sb_version_hasreflink(sbp)) { + if (xfs_sb_version_hasreflink(&mp->m_sb)) { fprintf(stderr, _("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"), progname); return -1; } - if (xfs_sb_version_hasrmapbt(sbp)) { + if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { fprintf(stderr, _("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"), progname); @@ -448,11 +446,11 @@ rtmount_init( progname); return -1; } - mp->m_rsumlevels = sbp->sb_rextslog + 1; + mp->m_rsumlevels = mp->m_sb.sb_rextslog + 1; mp->m_rsumsize = (uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels * - sbp->sb_rbmblocks; - mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize); + mp->m_sb.sb_rbmblocks; + mp->m_rsumsize = roundup(mp->m_rsumsize, mp->m_sb.sb_blocksize); mp->m_rbmip = mp->m_rsumip = NULL; /* diff --git a/logprint/logprint.c b/logprint/logprint.c index e882c5d4..18adf102 100644 --- a/logprint/logprint.c +++ b/logprint/logprint.c @@ -85,7 +85,7 @@ logstat(xfs_mount_t *mp) x.logBBsize = XFS_FSB_TO_BB(mp, sb->sb_logblocks); x.logBBstart = XFS_FSB_TO_DADDR(mp, sb->sb_logstart); x.lbsize = BBSIZE; - if (xfs_sb_version_hassector(sb)) + if (xfs_sb_version_hassector(&mp->m_sb)) x.lbsize <<= (sb->sb_logsectlog - BBSHIFT); if (!x.logname && sb->sb_logstart == 0) { diff --git a/repair/versions.c b/repair/versions.c index 4c44b4e7..7f268f61 100644 --- a/repair/versions.c +++ b/repair/versions.c @@ -30,21 +30,18 @@ int fs_has_extflgbit; xfs_extlen_t fs_ino_alignment; void -update_sb_version(xfs_mount_t *mp) +update_sb_version( + struct xfs_mount *mp) { - xfs_sb_t *sb; + if (fs_attributes && !xfs_sb_version_hasattr(&mp->m_sb)) + xfs_sb_version_addattr(&mp->m_sb); - sb = &mp->m_sb; - - if (fs_attributes && !xfs_sb_version_hasattr(sb)) - xfs_sb_version_addattr(sb); - - if (fs_attributes2 && !xfs_sb_version_hasattr2(sb)) - xfs_sb_version_addattr2(sb); + if (fs_attributes2 && !xfs_sb_version_hasattr2(&mp->m_sb)) + xfs_sb_version_addattr2(&mp->m_sb); /* V2 inode conversion is now always going to happen */ - if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) - sb->sb_versionnum |= XFS_SB_VERSION_NLINKBIT; + if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) + mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT; /* * fix up the superblock version number and feature bits, @@ -52,22 +49,22 @@ update_sb_version(xfs_mount_t *mp) * have quotas. */ if (fs_quotas) { - if (!xfs_sb_version_hasquota(sb)) - xfs_sb_version_addquota(sb); + if (!xfs_sb_version_hasquota(&mp->m_sb)) + xfs_sb_version_addquota(&mp->m_sb); /* * protect against stray bits in the quota flag field */ - if (sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL) { + if (mp->m_sb.sb_qflags & ~XFS_MOUNT_QUOTA_ALL) { /* * update the incore superblock, if we're in * no_modify mode, it'll never get flushed out * so this is ok. */ do_warn(_("bogus quota flags 0x%x set in superblock"), - sb->sb_qflags & ~XFS_MOUNT_QUOTA_ALL); + mp->m_sb.sb_qflags & ~XFS_MOUNT_QUOTA_ALL); - sb->sb_qflags &= XFS_MOUNT_QUOTA_ALL; + mp->m_sb.sb_qflags &= XFS_MOUNT_QUOTA_ALL; if (!no_modify) do_warn(_(", bogus flags will be cleared\n")); @@ -75,16 +72,16 @@ update_sb_version(xfs_mount_t *mp) do_warn(_(", bogus flags would be cleared\n")); } } else { - sb->sb_qflags = 0; + mp->m_sb.sb_qflags = 0; - if (xfs_sb_version_hasquota(sb)) { + if (xfs_sb_version_hasquota(&mp->m_sb)) { lost_quotas = 1; - sb->sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT; + mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT; } } - if (!fs_aligned_inodes && xfs_sb_version_hasalign(sb)) - sb->sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; + if (!fs_aligned_inodes && xfs_sb_version_hasalign(&mp->m_sb)) + mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; } /* @@ -93,7 +90,8 @@ update_sb_version(xfs_mount_t *mp) * global variables. */ int -parse_sb_version(xfs_sb_t *sb) +parse_sb_version( + struct xfs_mount *mp) { fs_attributes = 0; fs_attributes2 = 0; @@ -107,7 +105,7 @@ parse_sb_version(xfs_sb_t *sb) have_gquotino = 0; have_pquotino = 0; - if (sb->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) { + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_SHAREDBIT) { do_warn(_("Shared Version bit set. Not supported. Ever.\n")); return 1; } @@ -116,38 +114,38 @@ parse_sb_version(xfs_sb_t *sb) * ok, check to make sure that the sb isn't newer * than we are */ - if (!xfs_sb_good_version(sb)) { + if (!xfs_sb_good_version(&mp->m_sb)) { do_warn(_("WARNING: unknown superblock version %d\n"), - XFS_SB_VERSION_NUM(sb)); + XFS_SB_VERSION_NUM(&mp->m_sb)); do_warn( _("This filesystem contains features not understood by this program.\n")); return(1); } - if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_4) + if (XFS_SB_VERSION_NUM(&mp->m_sb) >= XFS_SB_VERSION_4) fs_sb_feature_bits = 1; /* Look for V5 feature flags we don't know about */ - if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_5 && - (xfs_sb_has_compat_feature(sb, XFS_SB_FEAT_COMPAT_UNKNOWN) || - xfs_sb_has_ro_compat_feature(sb, XFS_SB_FEAT_RO_COMPAT_UNKNOWN) || - xfs_sb_has_incompat_feature(sb, XFS_SB_FEAT_INCOMPAT_UNKNOWN))) { + if (XFS_SB_VERSION_NUM(&mp->m_sb) >= XFS_SB_VERSION_5 && + (xfs_sb_has_compat_feature(&mp->m_sb, XFS_SB_FEAT_COMPAT_UNKNOWN) || + xfs_sb_has_ro_compat_feature(&mp->m_sb, XFS_SB_FEAT_RO_COMPAT_UNKNOWN) || + xfs_sb_has_incompat_feature(&mp->m_sb, XFS_SB_FEAT_INCOMPAT_UNKNOWN))) { do_warn( _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n" "Using a more recent xfs_repair is recommended.\n"), - sb->sb_features_compat & XFS_SB_FEAT_COMPAT_UNKNOWN, - sb->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN, - sb->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_UNKNOWN); + mp->m_sb.sb_features_compat & XFS_SB_FEAT_COMPAT_UNKNOWN, + mp->m_sb.sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN, + mp->m_sb.sb_features_incompat & XFS_SB_FEAT_INCOMPAT_UNKNOWN); return 1; } - if (xfs_sb_version_hasattr(sb)) + if (xfs_sb_version_hasattr(&mp->m_sb)) fs_attributes = 1; - if (xfs_sb_version_hasattr2(sb)) + if (xfs_sb_version_hasattr2(&mp->m_sb)) fs_attributes2 = 1; - if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { + if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { if (!no_modify) { do_warn( _("WARNING: you have a V1 inode filesystem. It will be converted to a\n" @@ -161,28 +159,28 @@ _("WARNING: you have a V1 inode filesystem. It would be converted to a\n" } } - if (xfs_sb_version_hasquota(sb)) { + if (xfs_sb_version_hasquota(&mp->m_sb)) { fs_quotas = 1; - if (sb->sb_uquotino != 0 && sb->sb_uquotino != NULLFSINO) + if (mp->m_sb.sb_uquotino != 0 && mp->m_sb.sb_uquotino != NULLFSINO) have_uquotino = 1; - if (sb->sb_gquotino != 0 && sb->sb_gquotino != NULLFSINO) + if (mp->m_sb.sb_gquotino != 0 && mp->m_sb.sb_gquotino != NULLFSINO) have_gquotino = 1; - if (sb->sb_pquotino != 0 && sb->sb_pquotino != NULLFSINO) + if (mp->m_sb.sb_pquotino != 0 && mp->m_sb.sb_pquotino != NULLFSINO) have_pquotino = 1; } - if (xfs_sb_version_hasalign(sb)) { + if (xfs_sb_version_hasalign(&mp->m_sb)) { fs_aligned_inodes = 1; - fs_ino_alignment = sb->sb_inoalignmt; + fs_ino_alignment = mp->m_sb.sb_inoalignmt; } /* * calculate maximum file offset for this geometry */ - fs_max_file_offset = 0x7fffffffffffffffLL >> sb->sb_blocklog; + fs_max_file_offset = 0x7fffffffffffffffLL >> mp->m_sb.sb_blocklog; return(0); } diff --git a/repair/versions.h b/repair/versions.h index e1e2521c..c40a8681 100644 --- a/repair/versions.h +++ b/repair/versions.h @@ -34,11 +34,11 @@ extern xfs_extlen_t fs_ino_alignment; * modify superblock to reflect current state of global fs * feature vars above */ -void update_sb_version(xfs_mount_t *mp); +void update_sb_version(struct xfs_mount *mp); /* * parse current sb to set above feature vars */ -int parse_sb_version(xfs_sb_t *sb); +int parse_sb_version(struct xfs_mount *mp); #endif /* _XR_VERSIONS_H */ diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 38406eea..7a142ceb 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -1155,7 +1155,7 @@ main(int argc, char **argv) /* initialize random globals now that we know the fs geometry */ inodes_per_block = mp->m_sb.sb_inopblock; - if (parse_sb_version(&mp->m_sb)) { + if (parse_sb_version(mp)) { do_warn( _("Found unsupported filesystem features. Exiting now.\n")); return(1); From patchwork Tue Sep 14 02:40:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3895C433EF for ; Tue, 14 Sep 2021 02:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDD6D610FB for ; Tue, 14 Sep 2021 02:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234374AbhINCl2 (ORCPT ); Mon, 13 Sep 2021 22:41:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:52956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCl1 (ORCPT ); Mon, 13 Sep 2021 22:41:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39D05610D1; Tue, 14 Sep 2021 02:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587211; bh=qtx4K6+rnWMjKDGdEjLxy78d7q2/++H/a6DV8Tkibco=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=SqJynLqmiH1BtiqPRfbzJJpdkyuzBE98iKHq/AevS69kscx/pLwBjnwPHQE8rsazl +S9dhOsBhCuDym/RkQeghCCo97d8o00ghFIVP+k3NFBZbjcRAL6LNGU3pUtOEm39YB QXZcyRG4/ytAwT7rv20iJ/G0bK0vI07YujaPC/JlhsJlRa1bXpMW6kAz1RJWHY5BkL mdV2AHcKFyLrf0vVQj4Nzrcr239M++347TjHTdd71jg7z6e3djnLDAMK9CAuUFxquT t9mT3s6orsIIZ9+HO95tqk4RtwArm79k9SCBdSqSMdXwwTeCWgR1/YtQDJrBnmtcZT FJ03ddC2CX46A== Subject: [PATCH 02/43] xfs: remove support for disabling quota accounting on a mounted file system From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , Carlos Maiolino , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:10 -0700 Message-ID: <163158721096.1604118.17353772572397459905.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig Source kernel commit: 40b52225e58cd3adf9358146b4b39dccfbfe5892 Disabling quota accounting is hairy, racy code with all kinds of pitfalls. And it has a very strange mind set, as quota accounting (unlike enforcement) really is a propery of the on-disk format. There is no good use case for supporting this. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_trans_resv.c | 30 ------------------------------ libxfs/xfs_trans_resv.h | 2 -- 2 files changed, 32 deletions(-) diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c index 9ce7d8f9..fa5edb87 100644 --- a/libxfs/xfs_trans_resv.c +++ b/libxfs/xfs_trans_resv.c @@ -797,29 +797,6 @@ xfs_calc_qm_dqalloc_reservation( XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1); } -/* - * Turning off quotas. - * the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2 - * the superblock for the quota flags: sector size - */ -STATIC uint -xfs_calc_qm_quotaoff_reservation( - struct xfs_mount *mp) -{ - return sizeof(struct xfs_qoff_logitem) * 2 + - xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); -} - -/* - * End of turning off quotas. - * the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2 - */ -STATIC uint -xfs_calc_qm_quotaoff_end_reservation(void) -{ - return sizeof(struct xfs_qoff_logitem) * 2; -} - /* * Syncing the incore super block changes to disk. * the super block to reflect the changes: sector size @@ -922,13 +899,6 @@ xfs_trans_resv_calc( resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(); resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; - resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp); - resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT; - - resp->tr_qm_equotaoff.tr_logres = - xfs_calc_qm_quotaoff_end_reservation(); - resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT; - resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp); resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT; diff --git a/libxfs/xfs_trans_resv.h b/libxfs/xfs_trans_resv.h index 7241ab28..fc4e9b36 100644 --- a/libxfs/xfs_trans_resv.h +++ b/libxfs/xfs_trans_resv.h @@ -46,8 +46,6 @@ struct xfs_trans_resv { struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ - struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ - struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */ struct xfs_trans_res tr_sb; /* modify superblock */ struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ }; From patchwork Tue Sep 14 02:40:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE46C433EF for ; Tue, 14 Sep 2021 02:40:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D5F0610F9 for ; Tue, 14 Sep 2021 02:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237737AbhINCld (ORCPT ); Mon, 13 Sep 2021 22:41:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:52990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCld (ORCPT ); Mon, 13 Sep 2021 22:41:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD536610D1; Tue, 14 Sep 2021 02:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587216; bh=o18SNfpxKXEHRwHWCvQ1qgCmdrG4xUlE29/n49hnEKU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=brflDvSkOSFUTor6a1a5+zbOUO+Oy/ZvW2ZhLSEheImCMWdREZ+bwxlEyUO2YfLDk vrTBD98kF1DqwXtZ6LFpgqitD+COIwys6fsj9rkVpKNWLFn/feVOUPEy6BxF2Mu5di 6JITZ42KTeKxsGjYPwvousX/rZuldhkcONRxIf4pPTjzrenPxR68TMxv4XQL+rx4lx oFlO5GK+6VOV7JzdOF236NLcOlE+9xDB16QlEzHVNc+nK0LCze7vK4SbPkZqqtfnr5 SyGimu2FP5Ekce1W36efmxxXaVYsxVYn2aWlnmKpZCpclgRvJxR8hfjyILM9zBFaJN X74RVlPMuGQ6w== Subject: [PATCH 03/43] xfs: remove the active vs running quota differentiation From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , Carlos Maiolino , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:16 -0700 Message-ID: <163158721644.1604118.9350600009342205792.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig Source kernel commit: 149e53afc851713a70b6a06ebfaf2ebf25975454 These only made a difference when quotaoff supported disabling quota accounting on a mounted file system, so we can switch everyone to use a single set of flags and helpers now. Note that the *QUOTA_ON naming for the helpers is kept as it was the much more commonly used one. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_quota_defs.h | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h index 0f0af4e3..a02c5062 100644 --- a/libxfs/xfs_quota_defs.h +++ b/libxfs/xfs_quota_defs.h @@ -60,36 +60,14 @@ typedef uint8_t xfs_dqtype_t; #define XFS_DQUOT_LOGRES(mp) \ ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) -#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) -#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) -#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) -#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) +#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) +#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) +#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) +#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) #define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD) #define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) -/* - * Incore only flags for quotaoff - these bits get cleared when quota(s) - * are in the process of getting turned off. These flags are in m_qflags but - * never in sb_qflags. - */ -#define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */ -#define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */ -#define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */ -#define XFS_ALL_QUOTA_ACTIVE \ - (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) - -/* - * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees - * quota will be not be switched off as long as that inode lock is held. - */ -#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ - XFS_GQUOTA_ACTIVE | \ - XFS_PQUOTA_ACTIVE)) -#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) -#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) -#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) - /* * Flags to tell various functions what to do. Not all of these are meaningful * to a single function. None of these XFS_QMOPT_* flags are meant to have From patchwork Tue Sep 14 02:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E466C433EF for ; Tue, 14 Sep 2021 02:40:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74DD1610F9 for ; Tue, 14 Sep 2021 02:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhINClj (ORCPT ); Mon, 13 Sep 2021 22:41:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:53018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCli (ORCPT ); Mon, 13 Sep 2021 22:41:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 261AB610D1; Tue, 14 Sep 2021 02:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587222; bh=TC0+bI10sRzI7q/WJAxRZEUzqUbRPCLWai4qeq1S6gE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DOAC6rgEuwtDLbyHiGUIc5daUv8JdZThwBLBIxDS+Q3VpNs7J0efUdUzrGuSst4IV XQfUc0Ldcntb42jVc678SX8xtxnUlZLbdSPSoOUmzfMbQ9eDm/yfWU7YJG1sbc8sa+ 9/LWGNiIlBVxlLmK3C2U8gcuwW0NZgMWWvIJAsM5NC0CEojZhqsiF2F15NQye5kOiB ySvIXkdRmeAiAeElJZATmsk/654U43E5dtjsfBiqtEqWiTx7yXDK7NGbv4QmORDgsF uMxpUm+o8Vgel0sZe2+iFEjrcCyixjXHwodjRBfuf/JC7aIj/tlSurqX6iO3urLC/p FdftM9xV9vkmA== Subject: [PATCH 04/43] xfs: replace kmem_alloc_large() with kvmalloc() From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:21 -0700 Message-ID: <163158722190.1604118.5769611604065307959.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: d634525db63e9e946c3229fb93c8d9b763afbaf3 There is no reason for this wrapper existing anymore. All the places that use KM_NOFS allocation are within transaction contexts and hence covered by memalloc_nofs_save/restore contexts. Hence we don't need any special handling of vmalloc for large IOs anymore and so special casing this code isn't necessary. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/kmem.h | 3 ++- libxfs/kmem.c | 6 ++++-- libxfs/xfs_attr_leaf.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/kmem.h b/include/kmem.h index 383284ea..6d317256 100644 --- a/include/kmem.h +++ b/include/kmem.h @@ -22,6 +22,7 @@ typedef unsigned int __bitwise gfp_t; #define GFP_KERNEL ((__force gfp_t)0) #define GFP_NOFS ((__force gfp_t)0) #define __GFP_NOFAIL ((__force gfp_t)0) +#define __GFP_NOLOCKDEP ((__force gfp_t)0) #define __GFP_ZERO (__force gfp_t)1 @@ -38,7 +39,7 @@ kmem_cache_free(kmem_zone_t *zone, void *ptr) } extern void *kmem_alloc(size_t, int); -extern void *kmem_alloc_large(size_t, int); +extern void *kvmalloc(size_t, gfp_t); extern void *kmem_zalloc(size_t, int); static inline void diff --git a/libxfs/kmem.c b/libxfs/kmem.c index ee50ab66..3d72ac94 100644 --- a/libxfs/kmem.c +++ b/libxfs/kmem.c @@ -76,9 +76,11 @@ kmem_alloc(size_t size, int flags) } void * -kmem_alloc_large(size_t size, int flags) +kvmalloc(size_t size, gfp_t flags) { - return kmem_alloc(size, flags); + if (flags & __GFP_ZERO) + return kmem_zalloc(size, 0); + return kmem_alloc(size, 0); } void * diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index cfb6bf17..6499f16f 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -486,7 +486,7 @@ xfs_attr_copy_value( } if (!args->value) { - args->value = kmem_alloc_large(valuelen, KM_NOLOCKDEP); + args->value = kvmalloc(valuelen, GFP_KERNEL | __GFP_NOLOCKDEP); if (!args->value) return -ENOMEM; } From patchwork Tue Sep 14 02:40:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91CEDC433EF for ; Tue, 14 Sep 2021 02:40:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69C26610CC for ; Tue, 14 Sep 2021 02:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237812AbhINClo (ORCPT ); Mon, 13 Sep 2021 22:41:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:53042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237763AbhINClo (ORCPT ); Mon, 13 Sep 2021 22:41:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98549610D1; Tue, 14 Sep 2021 02:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587227; bh=X5ogbnVjcveGrsscnUsS9u6ZVa/diJ/mSITaysyn854=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XZQM0/g9Qv65wTaKF7CjQ0Zz8tD+4jqAwtt2uNdp/4chP6Ere0ZuTwaHIB//mcoad TXxpJDK9zrh/mOWx9OJtUUQHy/C/+CsOIhKEd3hptvdnRpD2t+K0paF7GECzzvPZo/ JRt2Eu/kHQmc2HB4HeEDeSWd5TOZfI+18fmWdO4p6zrq+YByWLAL3kIOusZdlLw+m/ ZkViwKO+CmMzJ97mbzaH+WMqymLI2KSXDR0kokDaTwgpIBf6ZVZW0YBoCDIl4+3CiA 6KcIqQTU+jgG0ozVOq97kwq89pBSSavJF4BzLahJxCLDMRGp/5X+kqZnGHdrI2hYP/ WSby5oc5ShwyA== Subject: [PATCH 05/43] xfs: allow setting and clearing of log incompat feature flags From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Allison Henderson , Chandan Babu R , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:27 -0700 Message-ID: <163158722735.1604118.6286172271568225071.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 908ce71e54f8265fa909200410d6c50ab9a2d302 Log incompat feature flags in the superblock exist for one purpose: to protect the contents of a dirty log from replay on a kernel that isn't prepared to handle those dirty contents. This means that they can be cleared if (a) we know the log is clean and (b) we know that there aren't any other threads in the system that might be setting or relying upon a log incompat flag. Therefore, clear the log incompat flags when we've finished recovering the log, when we're unmounting cleanly, remounting read-only, or freezing; and provide a function so that subsequent patches can start using this. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Chandan Babu R Signed-off-by: Darrick J. Wong --- libxfs/xfs_format.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 37570cf0..5d8a1291 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -495,6 +495,21 @@ xfs_sb_has_incompat_log_feature( return (sbp->sb_features_log_incompat & feature) != 0; } +static inline void +xfs_sb_remove_incompat_log_features( + struct xfs_sb *sbp) +{ + sbp->sb_features_log_incompat &= ~XFS_SB_FEAT_INCOMPAT_LOG_ALL; +} + +static inline void +xfs_sb_add_incompat_log_features( + struct xfs_sb *sbp, + unsigned int features) +{ + sbp->sb_features_log_incompat |= features; +} + /* * V5 superblock specific feature checks */ From patchwork Tue Sep 14 02:40:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B760FC433F5 for ; Tue, 14 Sep 2021 02:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A9DA610CC for ; Tue, 14 Sep 2021 02:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237763AbhINClu (ORCPT ); Mon, 13 Sep 2021 22:41:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:53072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINClt (ORCPT ); Mon, 13 Sep 2021 22:41:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18C20610D1; Tue, 14 Sep 2021 02:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587233; bh=0tAKvZgHXFfs93He7cgI2CRL2rJiGZW+TWATXGPX7zY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DrDgmOO4obbkiPG8x740POxSnzGiKfQ6677n9Szch8Tvwo43ZvpSYzdqS2tWkrsVz CGgawGwobVfjuDRFRcm3iLxP4UTjgcZhMxSKRS5AwJ4Qob8uokmBa+7h+o9kCvJtAJ 3OwdXndlgoPEHdWgPMioH7mSBqhniTvLtZr8Wp4xVE/wblPJRoVaWi+QoYZNfeVDR2 CwFeUGk8glHth22qW+VGffUwNuqeu1ykjFTghfHoZPw6yQr5inNLN+5LzR2bCybOXm SiqTINVE9Y8Z/CliFL6hujqlW9TwMVwUodIlrsU+T/oy+BoZkr7r4rS2fLksr0N+pU DhUmkDrg/S4mw== Subject: [PATCH 06/43] xfs: add attr state machine tracepoints From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Allison Henderson , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:32 -0700 Message-ID: <163158723281.1604118.9407732943126699887.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Source kernel commit: df0826312a23e495faa91eee0d6ac31bca35dc09 This is a quick patch to add a new xfs_attr_*_return tracepoints. We use these to track when ever a new state is set or -EAGAIN is returned Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_trace.h | 6 ++++++ libxfs/xfs_attr.c | 31 +++++++++++++++++++++++++++++-- libxfs/xfs_attr_remote.c | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index a1002638..79743f04 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -39,6 +39,12 @@ #define trace_xfs_alloc_vextent_loopfailed(a) ((void) 0) #define trace_xfs_alloc_vextent_allfailed(a) ((void) 0) +#define trace_xfs_attr_sf_addname_return(...) ((void) 0) +#define trace_xfs_attr_set_iter_return(...) ((void) 0) +#define trace_xfs_attr_node_addname_return(...) ((void) 0) +#define trace_xfs_attr_remove_iter_return(...) ((void) 0) +#define trace_xfs_attr_rmtval_remove_return(...) ((void) 0) + #define trace_xfs_log_recover_item_add_cont(a,b,c,d) ((void) 0) #define trace_xfs_log_recover_item_add(a,b,c,d) ((void) 0) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 80a6a96f..354c7c3f 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -335,6 +335,7 @@ xfs_attr_sf_addname( * the attr fork to leaf format and will restart with the leaf * add. */ + trace_xfs_attr_sf_addname_return(XFS_DAS_UNINIT, args->dp); dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -394,6 +395,8 @@ xfs_attr_set_iter( * handling code below */ dac->flags |= XFS_DAC_DEFER_FINISH; + trace_xfs_attr_set_iter_return( + dac->dela_state, args->dp); return -EAGAIN; } else if (error) { return error; @@ -411,6 +414,7 @@ xfs_attr_set_iter( dac->dela_state = XFS_DAS_FOUND_NBLK; } + trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); return -EAGAIN; case XFS_DAS_FOUND_LBLK: /* @@ -438,6 +442,8 @@ xfs_attr_set_iter( error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + trace_xfs_attr_set_iter_return(dac->dela_state, + args->dp); return -EAGAIN; } @@ -472,6 +478,7 @@ xfs_attr_set_iter( * series. */ dac->dela_state = XFS_DAS_FLIP_LFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); return -EAGAIN; case XFS_DAS_FLIP_LFLAG: /* @@ -489,10 +496,14 @@ xfs_attr_set_iter( dac->dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + trace_xfs_attr_set_iter_return( + dac->dela_state, args->dp); if (error) return error; dac->dela_state = XFS_DAS_RD_LEAF; + trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -542,6 +553,8 @@ xfs_attr_set_iter( error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + trace_xfs_attr_set_iter_return( + dac->dela_state, args->dp); return -EAGAIN; } @@ -577,6 +590,7 @@ xfs_attr_set_iter( * series */ dac->dela_state = XFS_DAS_FLIP_NFLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); return -EAGAIN; case XFS_DAS_FLIP_NFLAG: @@ -596,10 +610,15 @@ xfs_attr_set_iter( dac->dela_state = XFS_DAS_RM_NBLK; if (args->rmtblkno) { error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + trace_xfs_attr_set_iter_return( + dac->dela_state, args->dp); + if (error) return error; dac->dela_state = XFS_DAS_CLR_FLAG; + trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -1176,6 +1195,8 @@ xfs_attr_node_addname( * this point. */ dac->flags |= XFS_DAC_DEFER_FINISH; + trace_xfs_attr_node_addname_return( + dac->dela_state, args->dp); return -EAGAIN; } @@ -1422,10 +1443,13 @@ xfs_attr_remove_iter( * blocks are removed. */ error = __xfs_attr_rmtval_remove(dac); - if (error == -EAGAIN) + if (error == -EAGAIN) { + trace_xfs_attr_remove_iter_return( + dac->dela_state, args->dp); return error; - else if (error) + } else if (error) { goto out; + } /* * Refill the state structure with buffers (the prior @@ -1438,6 +1462,7 @@ xfs_attr_remove_iter( goto out; dac->dela_state = XFS_DAS_RM_NAME; dac->flags |= XFS_DAC_DEFER_FINISH; + trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); return -EAGAIN; } @@ -1466,6 +1491,8 @@ xfs_attr_remove_iter( dac->flags |= XFS_DAC_DEFER_FINISH; dac->dela_state = XFS_DAS_RM_SHRINK; + trace_xfs_attr_remove_iter_return( + dac->dela_state, args->dp); return -EAGAIN; } diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index d474ad7d..137e5698 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -695,6 +695,7 @@ __xfs_attr_rmtval_remove( */ if (!done) { dac->flags |= XFS_DAC_DEFER_FINISH; + trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); return -EAGAIN; } From patchwork Tue Sep 14 02:40:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E629CC433EF for ; Tue, 14 Sep 2021 02:40:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C79AA610CC for ; Tue, 14 Sep 2021 02:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237777AbhINClz (ORCPT ); Mon, 13 Sep 2021 22:41:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:53098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINClz (ORCPT ); Mon, 13 Sep 2021 22:41:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87579610D1; Tue, 14 Sep 2021 02:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587238; bh=ZaYYULPjmwab+R/nNJzPcvlqMlyapJwovAT+tyTRBwQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=shBS1/I/eP4KS3W+w5p358ypMa0XJy189coOixesyWTlvJEzX4sAqK8ehcsAqR2RM bTG/1ZyE8olbpx2IrvRjAtTRCQUlfdyOvyGh70qivKE4Ce8kwM0loAcFvBfh5yYqHD z/JUFtQcDL06skC8oHGt/QnYTXf8Xsd/A0iMQiFpy9sfugKAF+qH9lF2XY1kubNQ78 byq4I1Ax7cAV2gJkZCA19RJI1j88yDA+vJAoBwVka3xKdIPX+p/zIp9tNneKtgWSpD zRGwjoNjA23NUkQ1x7P9SoZ32jmFOu/ebjrMUcjfbC3HAM6eX4e7RvnFoOcFGEjDWc 7a/O6gOIIcE4g== Subject: [PATCH 07/43] xfs: Rename __xfs_attr_rmtval_remove From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Allison Henderson , "Darrick J. Wong" , Chandan Babu R , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:38 -0700 Message-ID: <163158723829.1604118.8749493319103931694.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Allison Henderson Source kernel commit: 5e68b4c7fb6414c4a48b6d2988312e3b1f31978e Now that xfs_attr_rmtval_remove is gone, rename __xfs_attr_rmtval_remove to xfs_attr_rmtval_remove Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 6 +++--- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 354c7c3f..2957fd03 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -495,7 +495,7 @@ xfs_attr_set_iter( /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ dac->dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(dac); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( dac->dela_state, args->dp); @@ -609,7 +609,7 @@ xfs_attr_set_iter( /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ dac->dela_state = XFS_DAS_RM_NBLK; if (args->rmtblkno) { - error = __xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(dac); if (error == -EAGAIN) trace_xfs_attr_set_iter_return( dac->dela_state, args->dp); @@ -1442,7 +1442,7 @@ xfs_attr_remove_iter( * May return -EAGAIN. Roll and repeat until all remote * blocks are removed. */ - error = __xfs_attr_rmtval_remove(dac); + error = xfs_attr_rmtval_remove(dac); if (error == -EAGAIN) { trace_xfs_attr_remove_iter_return( dac->dela_state, args->dp); diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 137e5698..b781e44d 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -671,7 +671,7 @@ xfs_attr_rmtval_invalidate( * routine until it returns something other than -EAGAIN. */ int -__xfs_attr_rmtval_remove( +xfs_attr_rmtval_remove( struct xfs_delattr_context *dac) { struct xfs_da_args *args = dac->da_args; diff --git a/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 61b85b91..d72eff30 100644 --- a/libxfs/xfs_attr_remote.h +++ b/libxfs/xfs_attr_remote.h @@ -12,7 +12,7 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); From patchwork Tue Sep 14 02:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6492DC433EF for ; Tue, 14 Sep 2021 02:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4999F610F9 for ; Tue, 14 Sep 2021 02:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237467AbhINCmA (ORCPT ); Mon, 13 Sep 2021 22:42:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235956AbhINCmA (ORCPT ); Mon, 13 Sep 2021 22:42:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04294610D1; Tue, 14 Sep 2021 02:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587244; bh=jpfcyie9bkmFuskhDBl3ijD3CdsjM40haGnXRYw95Bk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=FeUlCnkS6uCf43A41+tXjZHVBN5EEW+GrM8/Jaa8G6FhpryRulwdLyJbBca/goKky HE/IwBKbsE4HF0gad8aadCIzWINyo/pleykuJ3rFiNo4x1RKQ5Tez1nfj0fNh5l/t+ pLea0ZDKndsy61suZPCFysWJHU0gJGC5CEDJ7oc0W+eHMUxT6Os94/3PjjMuhOp9/j 8Qfjh7KUK0nif0rEFZF7KzmI+6ibXPl5rMtyEwaqMSJIqLc68Wxpmpuzyd42wrk21i l5AvWkYV1yqp+i5Mqr/ET30NM8Zf1oCYHIovBmz311gZV1EaRSFHk8iKIDR9XXqepC ofku1jF3PbLdQ== Subject: [PATCH 08/43] xfs: make xfs_rtalloc_query_range input parameters const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , Chandan Babu R , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:43 -0700 Message-ID: <163158724376.1604118.15383914226937184991.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: c02f6529864a4f5f91d216d324bac4ba75415d19 In commit 8ad560d2565e, we changed xfs_rtalloc_query_range to constrain the range of bits in the realtime bitmap file that would actually be searched. In commit a3a374bf1889, we changed the range again (incorrectly), leading to the fix in commit d88850bd5516, which finally corrected the range check code. Unfortunately, the author never noticed that the function modifies its input parameters, which is a totaly no-no since none of the other range query functions change their input parameters. So, fix this function yet again to stash the upper end of the query range (i.e. the high key) in a local variable and hope this is the last time I have to fix my own function. While we're at it, mark the key inputs const so nobody makes this mistake again. :( Fixes: 8ad560d2565e ("xfs: strengthen rtalloc query range checks") Not-fixed-by: a3a374bf1889 ("xfs: fix off-by-one error in xfs_rtalloc_query_range") Not-fixed-by: d88850bd5516 ("xfs: fix high key handling in the rt allocator's query_range function") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Chandan Babu R Signed-off-by: Darrick J. Wong --- libxfs/libxfs_priv.h | 10 +++++----- libxfs/xfs_rtbitmap.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index b9cb302a..07fc2942 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -603,9 +603,9 @@ struct xfs_rtalloc_rec { }; typedef int (*xfs_rtalloc_query_range_fn)( - struct xfs_trans *tp, - struct xfs_rtalloc_rec *rec, - void *priv); + struct xfs_trans *tp, + const struct xfs_rtalloc_rec *rec, + void *priv); int libxfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb, xfs_off_t count_fsb); @@ -699,8 +699,8 @@ int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_extlen_t len, struct xfs_buf **rbpp, xfs_fsblock_t *rsb); int xfs_rtalloc_query_range(struct xfs_trans *tp, - struct xfs_rtalloc_rec *low_rec, - struct xfs_rtalloc_rec *high_rec, + const struct xfs_rtalloc_rec *low_rec, + const struct xfs_rtalloc_rec *high_rec, xfs_rtalloc_query_range_fn fn, void *priv); int xfs_rtalloc_query_all(struct xfs_trans *tp, diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index f08efb7c..15da0496 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1007,8 +1007,8 @@ xfs_rtfree_extent( int xfs_rtalloc_query_range( struct xfs_trans *tp, - struct xfs_rtalloc_rec *low_rec, - struct xfs_rtalloc_rec *high_rec, + const struct xfs_rtalloc_rec *low_rec, + const struct xfs_rtalloc_rec *high_rec, xfs_rtalloc_query_range_fn fn, void *priv) { @@ -1016,6 +1016,7 @@ xfs_rtalloc_query_range( struct xfs_mount *mp = tp->t_mountp; xfs_rtblock_t rtstart; xfs_rtblock_t rtend; + xfs_rtblock_t high_key; int is_free; int error = 0; @@ -1024,12 +1025,12 @@ xfs_rtalloc_query_range( if (low_rec->ar_startext >= mp->m_sb.sb_rextents || low_rec->ar_startext == high_rec->ar_startext) return 0; - high_rec->ar_startext = min(high_rec->ar_startext, - mp->m_sb.sb_rextents - 1); + + high_key = min(high_rec->ar_startext, mp->m_sb.sb_rextents - 1); /* Iterate the bitmap, looking for discrepancies. */ rtstart = low_rec->ar_startext; - while (rtstart <= high_rec->ar_startext) { + while (rtstart <= high_key) { /* Is the first block free? */ error = xfs_rtcheck_range(mp, tp, rtstart, 1, 1, &rtend, &is_free); @@ -1037,8 +1038,7 @@ xfs_rtalloc_query_range( break; /* How long does the extent go for? */ - error = xfs_rtfind_forw(mp, tp, rtstart, - high_rec->ar_startext, &rtend); + error = xfs_rtfind_forw(mp, tp, rtstart, high_key, &rtend); if (error) break; From patchwork Tue Sep 14 02:40:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35557C433EF for ; Tue, 14 Sep 2021 02:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B579610FB for ; Tue, 14 Sep 2021 02:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237737AbhINCmG (ORCPT ); Mon, 13 Sep 2021 22:42:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCmG (ORCPT ); Mon, 13 Sep 2021 22:42:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71EB0610CC; Tue, 14 Sep 2021 02:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587249; bh=SizmMugLVY2cj3HTuglXYhmsZY/qvJ28YpJIFNNO4AE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=N3Ej3DqFkmjlZup7txBOnk1ChXE9iKMwhMoQ7dpq/sQCCVWwqYLtxIN3cGb+Wkg1W 84BXp1QPUMX53SQz35VfGa9xztO8Gjg6Zi03WJi1/ziDK0cOZkqRd1E6uFLu5IlmTL c4hIhL/gn3vLdAl+y6fBrnizA0qdeltakmgccJU/gUvAapwJqcVsWJ5ui4A2WjmLIs Xrgf55qCrqscOvPQXRYrDnmxUgTSVXxwmvR2lGG1q8CyJdLVtkBhpoPDQoxQDJ1916 lat8u5ZMmEBX0TDSXCcYLldaBupv0pzQlzs1A1njMeTb81IJFbxIXttzeKXYW3Q97k peRjH6f4mpCSQ== Subject: [PATCH 09/43] xfs: make the key parameters to all btree key comparison functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:49 -0700 Message-ID: <163158724921.1604118.1028184573661338154.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: d29d5577774d7d032da1343dba80be7423e307f9 The btree key comparison functions are not allowed to change the keys that are passed in, so mark them const. We'll need this for the next patch, which adds const to the btree range query functions. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 32 ++++++++++++++++---------------- libxfs/xfs_bmap_btree.c | 14 +++++++------- libxfs/xfs_btree.h | 6 +++--- libxfs/xfs_ialloc_btree.c | 10 +++++----- libxfs/xfs_refcount_btree.c | 12 ++++++------ libxfs/xfs_rmap_btree.c | 26 +++++++++++++------------- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 3847f7cb..67553183 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -227,23 +227,23 @@ xfs_allocbt_init_ptr_from_cur( STATIC int64_t xfs_bnobt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { - xfs_alloc_rec_incore_t *rec = &cur->bc_rec.a; - xfs_alloc_key_t *kp = &key->alloc; + struct xfs_alloc_rec_incore *rec = &cur->bc_rec.a; + const struct xfs_alloc_rec *kp = &key->alloc; return (int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; } STATIC int64_t xfs_cntbt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { - xfs_alloc_rec_incore_t *rec = &cur->bc_rec.a; - xfs_alloc_key_t *kp = &key->alloc; - int64_t diff; + struct xfs_alloc_rec_incore *rec = &cur->bc_rec.a; + const struct xfs_alloc_rec *kp = &key->alloc; + int64_t diff; diff = (int64_t)be32_to_cpu(kp->ar_blockcount) - rec->ar_blockcount; if (diff) @@ -254,9 +254,9 @@ xfs_cntbt_key_diff( STATIC int64_t xfs_bnobt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return (int64_t)be32_to_cpu(k1->alloc.ar_startblock) - be32_to_cpu(k2->alloc.ar_startblock); @@ -264,11 +264,11 @@ xfs_bnobt_diff_two_keys( STATIC int64_t xfs_cntbt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { - int64_t diff; + int64_t diff; diff = be32_to_cpu(k1->alloc.ar_blockcount) - be32_to_cpu(k2->alloc.ar_blockcount); diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 4c456df9..d72e1e7b 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -385,8 +385,8 @@ xfs_bmbt_init_ptr_from_cur( STATIC int64_t xfs_bmbt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { return (int64_t)be64_to_cpu(key->bmbt.br_startoff) - cur->bc_rec.b.br_startoff; @@ -394,12 +394,12 @@ xfs_bmbt_key_diff( STATIC int64_t xfs_bmbt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { - uint64_t a = be64_to_cpu(k1->bmbt.br_startoff); - uint64_t b = be64_to_cpu(k2->bmbt.br_startoff); + uint64_t a = be64_to_cpu(k1->bmbt.br_startoff); + uint64_t b = be64_to_cpu(k2->bmbt.br_startoff); /* * Note: This routine previously casted a and b to int64 and subtracted diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 4dbdc659..7154ad86 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -140,15 +140,15 @@ struct xfs_btree_ops { /* difference between key value and cursor value */ int64_t (*key_diff)(struct xfs_btree_cur *cur, - union xfs_btree_key *key); + const union xfs_btree_key *key); /* * Difference between key2 and key1 -- positive if key1 > key2, * negative if key1 < key2, and zero if equal. */ int64_t (*diff_two_keys)(struct xfs_btree_cur *cur, - union xfs_btree_key *key1, - union xfs_btree_key *key2); + const union xfs_btree_key *key1, + const union xfs_btree_key *key2); const struct xfs_buf_ops *buf_ops; diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 3e8afe76..fd13ec53 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -252,8 +252,8 @@ xfs_finobt_init_ptr_from_cur( STATIC int64_t xfs_inobt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { return (int64_t)be32_to_cpu(key->inobt.ir_startino) - cur->bc_rec.i.ir_startino; @@ -261,9 +261,9 @@ xfs_inobt_key_diff( STATIC int64_t xfs_inobt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return (int64_t)be32_to_cpu(k1->inobt.ir_startino) - be32_to_cpu(k2->inobt.ir_startino); diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 26fef861..277c7669 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -176,20 +176,20 @@ xfs_refcountbt_init_ptr_from_cur( STATIC int64_t xfs_refcountbt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { struct xfs_refcount_irec *rec = &cur->bc_rec.rc; - struct xfs_refcount_key *kp = &key->refc; + const struct xfs_refcount_key *kp = &key->refc; return (int64_t)be32_to_cpu(kp->rc_startblock) - rec->rc_startblock; } STATIC int64_t xfs_refcountbt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return (int64_t)be32_to_cpu(k1->refc.rc_startblock) - be32_to_cpu(k2->refc.rc_startblock); diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 47e32d20..d27e83b9 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -217,13 +217,13 @@ xfs_rmapbt_init_ptr_from_cur( STATIC int64_t xfs_rmapbt_key_diff( - struct xfs_btree_cur *cur, - union xfs_btree_key *key) + struct xfs_btree_cur *cur, + const union xfs_btree_key *key) { - struct xfs_rmap_irec *rec = &cur->bc_rec.r; - struct xfs_rmap_key *kp = &key->rmap; - __u64 x, y; - int64_t d; + struct xfs_rmap_irec *rec = &cur->bc_rec.r; + const struct xfs_rmap_key *kp = &key->rmap; + __u64 x, y; + int64_t d; d = (int64_t)be32_to_cpu(kp->rm_startblock) - rec->rm_startblock; if (d) @@ -247,14 +247,14 @@ xfs_rmapbt_key_diff( STATIC int64_t xfs_rmapbt_diff_two_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { - struct xfs_rmap_key *kp1 = &k1->rmap; - struct xfs_rmap_key *kp2 = &k2->rmap; - int64_t d; - __u64 x, y; + const struct xfs_rmap_key *kp1 = &k1->rmap; + const struct xfs_rmap_key *kp2 = &k2->rmap; + int64_t d; + __u64 x, y; d = (int64_t)be32_to_cpu(kp1->rm_startblock) - be32_to_cpu(kp2->rm_startblock); From patchwork Tue Sep 14 02:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA44CC433F5 for ; Tue, 14 Sep 2021 02:40:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD24E610D1 for ; Tue, 14 Sep 2021 02:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbhINCmM (ORCPT ); Mon, 13 Sep 2021 22:42:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:53184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhINCmL (ORCPT ); Mon, 13 Sep 2021 22:42:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5BC8610CC; Tue, 14 Sep 2021 02:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587255; bh=3+BNyhJDzKOUq/BS3Bb2GnIg9R8LKoLdbI5L6tcX1YE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=nFKzDOByftBoCsJ/TrkQZcTGkTYWCeev5tU1gLHGfYwYStKkk/tyjW9OfbMFjKGpR E8pnMbmmW0td83eJe00zMcDvn5PNyICiQoi+2v8YzG755ZBFYXWV5VpuW9sbPsj2Ua /q6uTbFh/UUjre2311G/EUaLWVg350WuKGB8oENadCUAEFXJL/2sOlVSFk2RJ7Gwjf nHjqmVBbvMa1JEg2+9/e2jfmDix2zVijOXqMO1Mu7QQYE7zzjTvp8TvSs3wYDB1U1F z9qk/w2ll7rVEn9c1c8VWl8gxS9OQGzEuDqTGzBpcrLRib8p6ncpP5DHqf02fNfeHx 0jBZn8TlvyhqQ== Subject: [PATCH 10/43] xfs: make the key parameters to all btree query range functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:40:54 -0700 Message-ID: <163158725466.1604118.7676809163968280784.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 04dcb47482a9d9e27feba48ca92613edced42ef9 Range query functions are not supposed to modify the query keys that are being passed in, so mark them all const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc.c | 4 ++-- libxfs/xfs_alloc.h | 4 ++-- libxfs/xfs_btree.c | 12 ++++++------ libxfs/xfs_btree.h | 3 ++- libxfs/xfs_rmap.c | 4 ++-- libxfs/xfs_rmap.h | 3 ++- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 5f455342..105c90b0 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3403,8 +3403,8 @@ xfs_alloc_query_range_helper( int xfs_alloc_query_range( struct xfs_btree_cur *cur, - struct xfs_alloc_rec_incore *low_rec, - struct xfs_alloc_rec_incore *high_rec, + const struct xfs_alloc_rec_incore *low_rec, + const struct xfs_alloc_rec_incore *high_rec, xfs_alloc_query_range_fn fn, void *priv) { diff --git a/libxfs/xfs_alloc.h b/libxfs/xfs_alloc.h index e30900b6..3554b7d4 100644 --- a/libxfs/xfs_alloc.h +++ b/libxfs/xfs_alloc.h @@ -225,8 +225,8 @@ typedef int (*xfs_alloc_query_range_fn)( void *priv); int xfs_alloc_query_range(struct xfs_btree_cur *cur, - struct xfs_alloc_rec_incore *low_rec, - struct xfs_alloc_rec_incore *high_rec, + const struct xfs_alloc_rec_incore *low_rec, + const struct xfs_alloc_rec_incore *high_rec, xfs_alloc_query_range_fn fn, void *priv); int xfs_alloc_query_all(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn, void *priv); diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 9caff949..16347ff5 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -4537,8 +4537,8 @@ xfs_btree_compute_maxlevels( STATIC int xfs_btree_simple_query_range( struct xfs_btree_cur *cur, - union xfs_btree_key *low_key, - union xfs_btree_key *high_key, + const union xfs_btree_key *low_key, + const union xfs_btree_key *high_key, xfs_btree_query_range_fn fn, void *priv) { @@ -4628,8 +4628,8 @@ xfs_btree_simple_query_range( STATIC int xfs_btree_overlapped_query_range( struct xfs_btree_cur *cur, - union xfs_btree_key *low_key, - union xfs_btree_key *high_key, + const union xfs_btree_key *low_key, + const union xfs_btree_key *high_key, xfs_btree_query_range_fn fn, void *priv) { @@ -4770,8 +4770,8 @@ xfs_btree_overlapped_query_range( int xfs_btree_query_range( struct xfs_btree_cur *cur, - union xfs_btree_irec *low_rec, - union xfs_btree_irec *high_rec, + const union xfs_btree_irec *low_rec, + const union xfs_btree_irec *high_rec, xfs_btree_query_range_fn fn, void *priv) { diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 7154ad86..462c2585 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -474,7 +474,8 @@ typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur, union xfs_btree_rec *rec, void *priv); int xfs_btree_query_range(struct xfs_btree_cur *cur, - union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec, + const union xfs_btree_irec *low_rec, + const union xfs_btree_irec *high_rec, xfs_btree_query_range_fn fn, void *priv); int xfs_btree_query_all(struct xfs_btree_cur *cur, xfs_btree_query_range_fn fn, void *priv); diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index b95421ef..100e904d 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2295,8 +2295,8 @@ xfs_rmap_query_range_helper( int xfs_rmap_query_range( struct xfs_btree_cur *cur, - struct xfs_rmap_irec *low_rec, - struct xfs_rmap_irec *high_rec, + const struct xfs_rmap_irec *low_rec, + const struct xfs_rmap_irec *high_rec, xfs_rmap_query_range_fn fn, void *priv) { diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index f2423cf7..1354efc4 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -139,7 +139,8 @@ typedef int (*xfs_rmap_query_range_fn)( void *priv); int xfs_rmap_query_range(struct xfs_btree_cur *cur, - struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *high_rec, + const struct xfs_rmap_irec *low_rec, + const struct xfs_rmap_irec *high_rec, xfs_rmap_query_range_fn fn, void *priv); int xfs_rmap_query_all(struct xfs_btree_cur *cur, xfs_rmap_query_range_fn fn, void *priv); From patchwork Tue Sep 14 02:41:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2785EC433F5 for ; Tue, 14 Sep 2021 02:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03D3E610D1 for ; Tue, 14 Sep 2021 02:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237802AbhINCmR (ORCPT ); Mon, 13 Sep 2021 22:42:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhINCmR (ORCPT ); Mon, 13 Sep 2021 22:42:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64B57610FB; Tue, 14 Sep 2021 02:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587260; bh=ZRhwPzvhKHsEztN6T4pz+LDqEhLn78iJQRbshI7/beo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MsVEwU0ij5ASwQe2/z1gDt2RJx61xAjrXu8N/IMXBJqVwcuBahor3yIg2azEHGoNW 3UXibczwfAaY6JgR03CAyBeIqAH3ZADt+YfYM4hDjFWUvqX0U04BocrHDLZj5lZLGu 8sH7SoGm2eK+TJnfUIgra59MSuxvcNlV3VwWmnUoa/e5uumF9tZuummB8evU5SaZJ/ 8rH1GYFFKn/VccrrnAvoDDaqXBmktQu5VTFd9NqDR/V39NpFB5chYqWfbwSZUbCflk 3NwlOxLgEAcGTvTVIxCNFj3WHNqyIqc7BN3sdTtPNfi+SxkZIc0cuiBcGXzgKoV8cs L1D20Sahm3Anw== Subject: [PATCH 11/43] xfs: make the record pointer passed to query_range functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:00 -0700 Message-ID: <163158726014.1604118.12939351209058354006.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 159eb69dba8baf6d5b58b69936920fb311324c82 The query_range functions are supposed to call a caller-supplied function on each record found in the dataset. These functions don't own the memory storing the record, so don't let them change the record. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- db/fsmap.c | 8 ++++---- libxfs/xfs_alloc.c | 2 +- libxfs/xfs_alloc.h | 6 +++--- libxfs/xfs_btree.c | 2 +- libxfs/xfs_btree.h | 2 +- libxfs/xfs_ialloc.c | 4 ++-- libxfs/xfs_ialloc.h | 3 ++- libxfs/xfs_refcount.c | 4 ++-- libxfs/xfs_refcount.h | 2 +- libxfs/xfs_rmap.c | 24 ++++++++++++------------ libxfs/xfs_rmap.h | 8 ++++---- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/db/fsmap.c b/db/fsmap.c index 65e9f1ba..d30b832c 100644 --- a/db/fsmap.c +++ b/db/fsmap.c @@ -16,11 +16,11 @@ struct fsmap_info { static int fsmap_fn( - struct xfs_btree_cur *cur, - struct xfs_rmap_irec *rec, - void *priv) + struct xfs_btree_cur *cur, + const struct xfs_rmap_irec *rec, + void *priv) { - struct fsmap_info *info = priv; + struct fsmap_info *info = priv; dbprintf(_("%llu: %u/%u len %u owner %lld offset %llu bmbt %d attrfork %d extflag %d\n"), info->nr, info->agno, rec->rm_startblock, diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 105c90b0..a7c3b079 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3388,7 +3388,7 @@ struct xfs_alloc_query_range_info { STATIC int xfs_alloc_query_range_helper( struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, void *priv) { struct xfs_alloc_query_range_info *query = priv; diff --git a/libxfs/xfs_alloc.h b/libxfs/xfs_alloc.h index 3554b7d4..e14c5693 100644 --- a/libxfs/xfs_alloc.h +++ b/libxfs/xfs_alloc.h @@ -220,9 +220,9 @@ int xfs_free_extent_fix_freelist(struct xfs_trans *tp, struct xfs_perag *pag, xfs_extlen_t xfs_prealloc_blocks(struct xfs_mount *mp); typedef int (*xfs_alloc_query_range_fn)( - struct xfs_btree_cur *cur, - struct xfs_alloc_rec_incore *rec, - void *priv); + struct xfs_btree_cur *cur, + const struct xfs_alloc_rec_incore *rec, + void *priv); int xfs_alloc_query_range(struct xfs_btree_cur *cur, const struct xfs_alloc_rec_incore *low_rec, diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 16347ff5..fa3ba314 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -4878,7 +4878,7 @@ xfs_btree_diff_two_ptrs( STATIC int xfs_btree_has_record_helper( struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, void *priv) { return -ECANCELED; diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 462c2585..e83836a9 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -471,7 +471,7 @@ unsigned long long xfs_btree_calc_size(uint *limits, unsigned long long len); * code on its own. */ typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, void *priv); + const union xfs_btree_rec *rec, void *priv); int xfs_btree_query_range(struct xfs_btree_cur *cur, const union xfs_btree_irec *low_rec, diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 570349b8..c1f3d28a 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -69,7 +69,7 @@ xfs_inobt_update( void xfs_inobt_btrec_to_irec( struct xfs_mount *mp, - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, struct xfs_inobt_rec_incore *irec) { irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino); @@ -2711,7 +2711,7 @@ struct xfs_ialloc_count_inodes { STATIC int xfs_ialloc_count_inodes_rec( struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, void *priv) { struct xfs_inobt_rec_incore irec; diff --git a/libxfs/xfs_ialloc.h b/libxfs/xfs_ialloc.h index 9a2112b4..8b5c2b70 100644 --- a/libxfs/xfs_ialloc.h +++ b/libxfs/xfs_ialloc.h @@ -106,7 +106,8 @@ int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); union xfs_btree_rec; -void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec, +void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, + const union xfs_btree_rec *rec, struct xfs_inobt_rec_incore *irec); int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len, bool *exists); diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 2ef00c64..1c9e7722 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -90,7 +90,7 @@ xfs_refcount_lookup_eq( /* Convert on-disk record to in-core format. */ void xfs_refcount_btrec_to_irec( - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, struct xfs_refcount_irec *irec) { irec->rc_startblock = be32_to_cpu(rec->refc.rc_startblock); @@ -1653,7 +1653,7 @@ struct xfs_refcount_recovery { STATIC int xfs_refcount_recover_extent( struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, + const union xfs_btree_rec *rec, void *priv) { struct list_head *debris = priv; diff --git a/libxfs/xfs_refcount.h b/libxfs/xfs_refcount.h index 9f6e9aae..02cb3aa4 100644 --- a/libxfs/xfs_refcount.h +++ b/libxfs/xfs_refcount.h @@ -78,7 +78,7 @@ static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res) extern int xfs_refcount_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len, bool *exists); union xfs_btree_rec; -extern void xfs_refcount_btrec_to_irec(union xfs_btree_rec *rec, +extern void xfs_refcount_btrec_to_irec(const union xfs_btree_rec *rec, struct xfs_refcount_irec *irec); extern int xfs_refcount_insert(struct xfs_btree_cur *cur, struct xfs_refcount_irec *irec, int *stat); diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 100e904d..ed7db353 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -178,8 +178,8 @@ xfs_rmap_delete( /* Convert an internal btree record to an rmap record. */ int xfs_rmap_btrec_to_irec( - union xfs_btree_rec *rec, - struct xfs_rmap_irec *irec) + const union xfs_btree_rec *rec, + struct xfs_rmap_irec *irec) { irec->rm_startblock = be32_to_cpu(rec->rmap.rm_startblock); irec->rm_blockcount = be32_to_cpu(rec->rmap.rm_blockcount); @@ -254,9 +254,9 @@ struct xfs_find_left_neighbor_info { /* For each rmap given, figure out if it matches the key we want. */ STATIC int xfs_rmap_find_left_neighbor_helper( - struct xfs_btree_cur *cur, - struct xfs_rmap_irec *rec, - void *priv) + struct xfs_btree_cur *cur, + const struct xfs_rmap_irec *rec, + void *priv) { struct xfs_find_left_neighbor_info *info = priv; @@ -330,9 +330,9 @@ xfs_rmap_find_left_neighbor( /* For each rmap given, figure out if it matches the key we want. */ STATIC int xfs_rmap_lookup_le_range_helper( - struct xfs_btree_cur *cur, - struct xfs_rmap_irec *rec, - void *priv) + struct xfs_btree_cur *cur, + const struct xfs_rmap_irec *rec, + void *priv) { struct xfs_find_left_neighbor_info *info = priv; @@ -2277,9 +2277,9 @@ struct xfs_rmap_query_range_info { /* Format btree record and pass to our callback. */ STATIC int xfs_rmap_query_range_helper( - struct xfs_btree_cur *cur, - union xfs_btree_rec *rec, - void *priv) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *rec, + void *priv) { struct xfs_rmap_query_range_info *query = priv; struct xfs_rmap_irec irec; @@ -2706,7 +2706,7 @@ struct xfs_rmap_key_state { STATIC int xfs_rmap_has_other_keys_helper( struct xfs_btree_cur *cur, - struct xfs_rmap_irec *rec, + const struct xfs_rmap_irec *rec, void *priv) { struct xfs_rmap_key_state *rks = priv; diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 1354efc4..fd67904e 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -134,9 +134,9 @@ int xfs_rmap_get_rec(struct xfs_btree_cur *cur, struct xfs_rmap_irec *irec, int *stat); typedef int (*xfs_rmap_query_range_fn)( - struct xfs_btree_cur *cur, - struct xfs_rmap_irec *rec, - void *priv); + struct xfs_btree_cur *cur, + const struct xfs_rmap_irec *rec, + void *priv); int xfs_rmap_query_range(struct xfs_btree_cur *cur, const struct xfs_rmap_irec *low_rec, @@ -193,7 +193,7 @@ int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno, int xfs_rmap_compare(const struct xfs_rmap_irec *a, const struct xfs_rmap_irec *b); union xfs_btree_rec; -int xfs_rmap_btrec_to_irec(union xfs_btree_rec *rec, +int xfs_rmap_btrec_to_irec(const union xfs_btree_rec *rec, struct xfs_rmap_irec *irec); int xfs_rmap_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len, bool *exists); From patchwork Tue Sep 14 02:41:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0A79C433F5 for ; Tue, 14 Sep 2021 02:41:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 942B3610D1 for ; Tue, 14 Sep 2021 02:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhINCmX (ORCPT ); Mon, 13 Sep 2021 22:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:53246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCmW (ORCPT ); Mon, 13 Sep 2021 22:42:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D467A610CC; Tue, 14 Sep 2021 02:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587265; bh=gAHVfB2veFS1p8GprhXVSL+rrV/CqpMjU3fARRzswlw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=FC7HhN/bfKxKgc44UIs49Zq+DyfudDWSdmuKxopglOsGmkvZk8jFGV7PlHWUQSMwW WZlqeKhlUkacWrq3V6CL0MPW6y0OhTQJCMHdIVEM8lA5z9xB5RGICJ0a/fkPHQprKS uvpj57hbwLUHZ0Li+MlEdzkF460PJmN+7R/KkX/sKbBRJxiwUzdIbVN63eQT06zQ2S m4qePg+JYKvCsI1+tR7vWw/JACceLZBMglZPLFJnFnW4oQi2UAzdQJ5oIod25wgHju KSahQFAwZ0RjT0FRGzUWFVh+2oHFyW1uMHOS9KivvXPdXSQELclat8IjBbo1IsouyG gPNZh3XPllowA== Subject: [PATCH 12/43] xfs: mark the record passed into btree init_key functions as const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:05 -0700 Message-ID: <163158726560.1604118.7312671544600928461.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 23825cd148764ce133ee92375da395140d6ccb15 These functions initialize a key from a record, but they aren't supposed to modify the record. Mark it const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 14 +++++++------- libxfs/xfs_bmap_btree.c | 12 ++++++------ libxfs/xfs_bmap_btree.h | 4 ++-- libxfs/xfs_btree.h | 4 ++-- libxfs/xfs_ialloc_btree.c | 10 +++++----- libxfs/xfs_refcount_btree.c | 10 +++++----- libxfs/xfs_rmap_btree.c | 12 ++++++------ 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 67553183..fb2fdb4a 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -175,8 +175,8 @@ xfs_allocbt_get_maxrecs( STATIC void xfs_allocbt_init_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->alloc.ar_startblock = rec->alloc.ar_startblock; key->alloc.ar_blockcount = rec->alloc.ar_blockcount; @@ -184,10 +184,10 @@ xfs_allocbt_init_key_from_rec( STATIC void xfs_bnobt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { - __u32 x; + __u32 x; x = be32_to_cpu(rec->alloc.ar_startblock); x += be32_to_cpu(rec->alloc.ar_blockcount) - 1; @@ -197,8 +197,8 @@ xfs_bnobt_init_high_key_from_rec( STATIC void xfs_cntbt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->alloc.ar_blockcount = rec->alloc.ar_blockcount; key->alloc.ar_startblock = 0; diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index d72e1e7b..73e387f5 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -76,7 +76,7 @@ xfs_bmbt_disk_get_all( */ xfs_filblks_t xfs_bmbt_disk_get_blockcount( - xfs_bmbt_rec_t *r) + const struct xfs_bmbt_rec *r) { return (xfs_filblks_t)(be64_to_cpu(r->l1) & xfs_mask64lo(21)); } @@ -86,7 +86,7 @@ xfs_bmbt_disk_get_blockcount( */ xfs_fileoff_t xfs_bmbt_disk_get_startoff( - xfs_bmbt_rec_t *r) + const struct xfs_bmbt_rec *r) { return ((xfs_fileoff_t)be64_to_cpu(r->l0) & xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; @@ -350,8 +350,8 @@ xfs_bmbt_get_dmaxrecs( STATIC void xfs_bmbt_init_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->bmbt.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(&rec->bmbt)); @@ -359,8 +359,8 @@ xfs_bmbt_init_key_from_rec( STATIC void xfs_bmbt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->bmbt.br_startoff = cpu_to_be64( xfs_bmbt_disk_get_startoff(&rec->bmbt) + diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h index 72bf74c7..209ded1e 100644 --- a/libxfs/xfs_bmap_btree.h +++ b/libxfs/xfs_bmap_btree.h @@ -88,8 +88,8 @@ extern void xfs_bmdr_to_bmbt(struct xfs_inode *, xfs_bmdr_block_t *, int, struct xfs_btree_block *, int); void xfs_bmbt_disk_set_all(struct xfs_bmbt_rec *r, struct xfs_bmbt_irec *s); -extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r); -extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r); +extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(const struct xfs_bmbt_rec *r); +extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(const struct xfs_bmbt_rec *r); extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int, diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index e83836a9..c4c701fd 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -130,13 +130,13 @@ struct xfs_btree_ops { /* init values of btree structures */ void (*init_key_from_rec)(union xfs_btree_key *key, - union xfs_btree_rec *rec); + const union xfs_btree_rec *rec); void (*init_rec_from_cur)(struct xfs_btree_cur *cur, union xfs_btree_rec *rec); void (*init_ptr_from_cur)(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr); void (*init_high_key_from_rec)(union xfs_btree_key *key, - union xfs_btree_rec *rec); + const union xfs_btree_rec *rec); /* difference between key value and cursor value */ int64_t (*key_diff)(struct xfs_btree_cur *cur, diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index fd13ec53..e7b19d2a 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -187,18 +187,18 @@ xfs_inobt_get_maxrecs( STATIC void xfs_inobt_init_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->inobt.ir_startino = rec->inobt.ir_startino; } STATIC void xfs_inobt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { - __u32 x; + __u32 x; x = be32_to_cpu(rec->inobt.ir_startino); x += XFS_INODES_PER_CHUNK - 1; diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 277c7669..04bc5816 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -134,18 +134,18 @@ xfs_refcountbt_get_maxrecs( STATIC void xfs_refcountbt_init_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->refc.rc_startblock = rec->refc.rc_startblock; } STATIC void xfs_refcountbt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { - __u32 x; + __u32 x; x = be32_to_cpu(rec->refc.rc_startblock); x += be32_to_cpu(rec->refc.rc_blockcount) - 1; diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index d27e83b9..294d4a41 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -154,8 +154,8 @@ xfs_rmapbt_get_maxrecs( STATIC void xfs_rmapbt_init_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { key->rmap.rm_startblock = rec->rmap.rm_startblock; key->rmap.rm_owner = rec->rmap.rm_owner; @@ -171,11 +171,11 @@ xfs_rmapbt_init_key_from_rec( */ STATIC void xfs_rmapbt_init_high_key_from_rec( - union xfs_btree_key *key, - union xfs_btree_rec *rec) + union xfs_btree_key *key, + const union xfs_btree_rec *rec) { - uint64_t off; - int adj; + uint64_t off; + int adj; adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1; From patchwork Tue Sep 14 02:41:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B797C433EF for ; Tue, 14 Sep 2021 02:41:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73412610F9 for ; Tue, 14 Sep 2021 02:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237763AbhINCm2 (ORCPT ); Mon, 13 Sep 2021 22:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCm1 (ORCPT ); Mon, 13 Sep 2021 22:42:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4EE5C610CC; Tue, 14 Sep 2021 02:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587271; bh=flvviJq7izhwh0sWKoxrLVzR1rvB9KAUe1BDsuEAa34=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=dktQuFt5pReTN4Go0doC2jIm+/4H1G6IRFPNC130PH4sVmvUen7C5+yPhWp/pnpqL a7UmegGHOx5req5fF2nVtH5j/JTM3w0fa/AhncQFvGu20Lke0knfo1kI/sSxI2+e5h DL+zARXJxd4WAgikFUQiZqPDyVA529UB6vw4ggLyBXx/HKci9Ov5oWnxOphlpT8JQ5 VsZhvIz0YtNtlw1VIED1zbZ7wA1qrCnYGh4gBBAtv8owXOHH0WWO5ReYbtN8DNPVGM TteFGq3HsBWAx81x8js5zzDXL9/usLzh0FOaAxDpQnJhLswlyj9fLNZ73urOPpZcd4 lrsD+xi36p0jQ== Subject: [PATCH 13/43] xfs: make the keys and records passed to btree inorder functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:11 -0700 Message-ID: <163158727106.1604118.11458136500130772855.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 8e38dc88a67b3c7475cbe8a132d03542717c1e27 The inorder functions are simple predicates, which means that they don't modify the parameters. Mark them all const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 24 ++++++++++++------------ libxfs/xfs_bmap_btree.c | 12 ++++++------ libxfs/xfs_btree.h | 8 ++++---- libxfs/xfs_ialloc_btree.c | 12 ++++++------ libxfs/xfs_refcount_btree.c | 12 ++++++------ libxfs/xfs_rmap_btree.c | 12 ++++++------ 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index fb2fdb4a..79130125 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -374,9 +374,9 @@ const struct xfs_buf_ops xfs_cntbt_buf_ops = { STATIC int xfs_bnobt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return be32_to_cpu(k1->alloc.ar_startblock) < be32_to_cpu(k2->alloc.ar_startblock); @@ -384,9 +384,9 @@ xfs_bnobt_keys_inorder( STATIC int xfs_bnobt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { return be32_to_cpu(r1->alloc.ar_startblock) + be32_to_cpu(r1->alloc.ar_blockcount) <= @@ -395,9 +395,9 @@ xfs_bnobt_recs_inorder( STATIC int xfs_cntbt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return be32_to_cpu(k1->alloc.ar_blockcount) < be32_to_cpu(k2->alloc.ar_blockcount) || @@ -408,9 +408,9 @@ xfs_cntbt_keys_inorder( STATIC int xfs_cntbt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { return be32_to_cpu(r1->alloc.ar_blockcount) < be32_to_cpu(r2->alloc.ar_blockcount) || diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 73e387f5..acaf2941 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -495,9 +495,9 @@ const struct xfs_buf_ops xfs_bmbt_buf_ops = { STATIC int xfs_bmbt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return be64_to_cpu(k1->bmbt.br_startoff) < be64_to_cpu(k2->bmbt.br_startoff); @@ -505,9 +505,9 @@ xfs_bmbt_keys_inorder( STATIC int xfs_bmbt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { return xfs_bmbt_disk_get_startoff(&r1->bmbt) + xfs_bmbt_disk_get_blockcount(&r1->bmbt) <= diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index c4c701fd..4b95373c 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -154,13 +154,13 @@ struct xfs_btree_ops { /* check that k1 is lower than k2 */ int (*keys_inorder)(struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2); + const union xfs_btree_key *k1, + const union xfs_btree_key *k2); /* check that r1 is lower than r2 */ int (*recs_inorder)(struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2); + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2); }; /* diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index e7b19d2a..14b54f13 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -359,9 +359,9 @@ const struct xfs_buf_ops xfs_finobt_buf_ops = { STATIC int xfs_inobt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return be32_to_cpu(k1->inobt.ir_startino) < be32_to_cpu(k2->inobt.ir_startino); @@ -369,9 +369,9 @@ xfs_inobt_keys_inorder( STATIC int xfs_inobt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <= be32_to_cpu(r2->inobt.ir_startino); diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 04bc5816..b088c4a0 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -268,9 +268,9 @@ const struct xfs_buf_ops xfs_refcountbt_buf_ops = { STATIC int xfs_refcountbt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { return be32_to_cpu(k1->refc.rc_startblock) < be32_to_cpu(k2->refc.rc_startblock); @@ -278,9 +278,9 @@ xfs_refcountbt_keys_inorder( STATIC int xfs_refcountbt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { return be32_to_cpu(r1->refc.rc_startblock) + be32_to_cpu(r1->refc.rc_blockcount) <= diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 294d4a41..6d28a469 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -362,9 +362,9 @@ const struct xfs_buf_ops xfs_rmapbt_buf_ops = { STATIC int xfs_rmapbt_keys_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_key *k1, - union xfs_btree_key *k2) + struct xfs_btree_cur *cur, + const union xfs_btree_key *k1, + const union xfs_btree_key *k2) { uint32_t x; uint32_t y; @@ -392,9 +392,9 @@ xfs_rmapbt_keys_inorder( STATIC int xfs_rmapbt_recs_inorder( - struct xfs_btree_cur *cur, - union xfs_btree_rec *r1, - union xfs_btree_rec *r2) + struct xfs_btree_cur *cur, + const union xfs_btree_rec *r1, + const union xfs_btree_rec *r2) { uint32_t x; uint32_t y; From patchwork Tue Sep 14 02:41:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC01FC433EF for ; Tue, 14 Sep 2021 02:41:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7D2B610D1 for ; Tue, 14 Sep 2021 02:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236074AbhINCmd (ORCPT ); Mon, 13 Sep 2021 22:42:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:53292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCmd (ORCPT ); Mon, 13 Sep 2021 22:42:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0A7B610F9; Tue, 14 Sep 2021 02:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587276; bh=V9KED14WUY/JT8WgSJwuQfvFxK/DgkFv/Kstl4Y4NW4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mPoeWS+cy/OEzeiwh6tejktOo9teLmcUaiVoqc4zdGlX3D8QOEv8HGSnuCbmhp4AK 8mFZhpyag9mZKesIuh5p0TVXT0LmCLDVDaCSXhMFHxl6EKN4Sf2JKEu6STCYKCc/Bt bEKvhXglAEph4jtM9dqeB62kNXwVoYHgOeH9/OJ6X4Cz/sQI9X/jZDvpNvXkYe+4dH a4BSkUrd3XNqKOJS1GjDg1mGbr9Y5fMVQnPYITwv9V1f3RQQQQaH4PHjbDr3OsFGf5 u+jr5KOvLPWdBI7Qfnft/mOywDko28LHp1buS24YgCC8dgD1RFEMmWJhjx0TZq/73t WZAPZwStzNiWQ== Subject: [PATCH 14/43] xfs: mark the record passed into xchk_btree functions as const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:16 -0700 Message-ID: <163158727652.1604118.5594733928761021916.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 22ece4e836beff1df528ee09cf21ca5fab7235f5 xchk_btree calls a user-supplied function to validate each btree record that it finds. Those functions are not supposed to change the record data, so mark the parameter const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- include/xfs_arch.h | 10 +++++----- libxfs/xfs_bmap_btree.c | 2 +- libxfs/xfs_bmap_btree.h | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/xfs_arch.h b/include/xfs_arch.h index 7f973249..d46ae470 100644 --- a/include/xfs_arch.h +++ b/include/xfs_arch.h @@ -232,19 +232,19 @@ static inline void be64_add_cpu(__be64 *a, __s64 b) *a = cpu_to_be64(be64_to_cpu(*a) + b); } -static inline uint16_t get_unaligned_be16(void *p) +static inline uint16_t get_unaligned_be16(const void *p) { - uint8_t *__p = p; + const uint8_t *__p = p; return __p[0] << 8 | __p[1]; } -static inline uint32_t get_unaligned_be32(void *p) +static inline uint32_t get_unaligned_be32(const void *p) { - uint8_t *__p = p; + const uint8_t *__p = p; return (uint32_t)__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3]; } -static inline uint64_t get_unaligned_be64(void *p) +static inline uint64_t get_unaligned_be64(const void *p) { return (uint64_t)get_unaligned_be32(p) << 32 | get_unaligned_be32(p + 4); diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index acaf2941..9e2e9926 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -56,7 +56,7 @@ xfs_bmdr_to_bmbt( void xfs_bmbt_disk_get_all( - struct xfs_bmbt_rec *rec, + const struct xfs_bmbt_rec *rec, struct xfs_bmbt_irec *irec) { uint64_t l0 = get_unaligned_be64(&rec->l0); diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h index 209ded1e..eda85512 100644 --- a/libxfs/xfs_bmap_btree.h +++ b/libxfs/xfs_bmap_btree.h @@ -90,7 +90,8 @@ extern void xfs_bmdr_to_bmbt(struct xfs_inode *, xfs_bmdr_block_t *, int, void xfs_bmbt_disk_set_all(struct xfs_bmbt_rec *r, struct xfs_bmbt_irec *s); extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(const struct xfs_bmbt_rec *r); extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(const struct xfs_bmbt_rec *r); -extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); +void xfs_bmbt_disk_get_all(const struct xfs_bmbt_rec *r, + struct xfs_bmbt_irec *s); extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int, xfs_bmdr_block_t *, int); From patchwork Tue Sep 14 02:41:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90648C433EF for ; Tue, 14 Sep 2021 02:41:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78541610D1 for ; Tue, 14 Sep 2021 02:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhINCmj (ORCPT ); Mon, 13 Sep 2021 22:42:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:53316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCmi (ORCPT ); Mon, 13 Sep 2021 22:42:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C9E6610FB; Tue, 14 Sep 2021 02:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587282; bh=653Y42PGC3qIZsMbFcFSRvsJ8b02uOLCx9qxZCfAkho=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=G2K7KyhcXk/IDlp1eXSeJNBEKvf9TVZOZuTRakCiDKY3i6HTHWlduZUM+LRxSWbx4 HRe6wq/Non25PdlC36mhADdB+9SJduOHs4DUnAJ8//0eJOUmyoEPyGtauKJA0+SiV1 MSe+bapO1w+GnT/O/PvyFWu/QRdSVgWiOeu9jB7/eHKpELI1zatBs8ahVyFisK/yWe op3fnf1ob3S2tI4JBmFEUmtnhYCoU8QkMMo3GzZLcBWNeRwK+dmNUJN04jmh7KGNtP HmPFpN3PMPYFPzS6R5U4vuwju921v1yvbla3LbHtL6J3ScB45FZ0ValhyFHLPOAPQi o19av8fITdOmg== Subject: [PATCH 15/43] xfs: make the pointer passed to btree set_root functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:22 -0700 Message-ID: <163158728198.1604118.6785493093865692097.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: b5a6e5fe0e6840bc90e51cf522d6c5a880cde567 The pointer passed to each per-AG btree type's ->set_root function isn't supposed to be modified (that function sets an external pointer to the root block) so mark them const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 6 +++--- libxfs/xfs_btree.h | 2 +- libxfs/xfs_btree_staging.c | 6 +++--- libxfs/xfs_ialloc_btree.c | 12 ++++++------ libxfs/xfs_refcount_btree.c | 6 +++--- libxfs/xfs_rmap_btree.c | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 79130125..c10f20d6 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -29,9 +29,9 @@ xfs_allocbt_dup_cursor( STATIC void xfs_allocbt_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int inc) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int inc) { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 4b95373c..504032d9 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -106,7 +106,7 @@ struct xfs_btree_ops { /* update btree root pointer */ void (*set_root)(struct xfs_btree_cur *cur, - union xfs_btree_ptr *nptr, int level_change); + const union xfs_btree_ptr *nptr, int level_change); /* block allocation / freeing */ int (*alloc_block)(struct xfs_btree_cur *cur, diff --git a/libxfs/xfs_btree_staging.c b/libxfs/xfs_btree_staging.c index ace2eb7c..d808f0fc 100644 --- a/libxfs/xfs_btree_staging.c +++ b/libxfs/xfs_btree_staging.c @@ -112,9 +112,9 @@ xfs_btree_fakeroot_init_ptr_from_cur( /* Update the btree root information for a per-AG fake root. */ STATIC void xfs_btree_afakeroot_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int inc) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int inc) { struct xbtree_afakeroot *afake = cur->bc_ag.afake; diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 14b54f13..f644882b 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -39,9 +39,9 @@ xfs_inobt_dup_cursor( STATIC void xfs_inobt_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *nptr, - int inc) /* level change */ + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *nptr, + int inc) /* level change */ { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agi *agi = agbp->b_addr; @@ -53,9 +53,9 @@ xfs_inobt_set_root( STATIC void xfs_finobt_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *nptr, - int inc) /* level change */ + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *nptr, + int inc) /* level change */ { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agi *agi = agbp->b_addr; diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index b088c4a0..291098a9 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -30,9 +30,9 @@ xfs_refcountbt_dup_cursor( STATIC void xfs_refcountbt_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int inc) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int inc) { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 6d28a469..755246c6 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -55,9 +55,9 @@ xfs_rmapbt_dup_cursor( STATIC void xfs_rmapbt_set_root( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int inc) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int inc) { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; From patchwork Tue Sep 14 02:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71986C433EF for ; Tue, 14 Sep 2021 02:41:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55033610FB for ; Tue, 14 Sep 2021 02:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbhINCmp (ORCPT ); Mon, 13 Sep 2021 22:42:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCmo (ORCPT ); Mon, 13 Sep 2021 22:42:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ABA55610D1; Tue, 14 Sep 2021 02:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587287; bh=joraU5cxcw8coys0KRcVKDs7IpKpW2AMauNb/BOMqJE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=EEPd2RjZH5m7mBzi/ZNGzlLyh+Z5qnHPVlUyTqBIhV3KkMZvzJAEJj0tt4uZccYRm eF7HyOc5pl4nnFh9fncfbNUiT2ZUBUohGvy7nFP/evSkynC5lFOupwz16I3Iv145iv jCXa1EQmR+NSumIYEvDwqGYsSYIixM8HW64FPFoLgOmC5iQfe9E+eDX4EVhYNBPiyS 27NOBuBVHm5Ip+BGivskUUFCc1wPjVKJO/gWWgPZLgVyKhXwJ9jnCg4z3ymakFZudf 503kMPTY2Al/LrGEfL0qwcF9VAw2W9rYLq5P5SvPvh2W9WyW3ZmlwdlQ1M1IJu5e/l e14nXEVA/CWqg== Subject: [PATCH 16/43] xfs: make the start pointer passed to btree alloc_block functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:27 -0700 Message-ID: <163158728744.1604118.7373675138987652673.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: deb06b9ab6dfa167c280a68d5acb2f12e007073f The @start pointer passed to each per-AG btree type's ->alloc_block function isn't supposed to be modified, since it's a hint about the location of the btree block being split that is to be fed to the allocator, so mark the parameter const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 8 ++++---- libxfs/xfs_bmap_btree.c | 8 ++++---- libxfs/xfs_btree.h | 2 +- libxfs/xfs_btree_staging.c | 8 ++++---- libxfs/xfs_ialloc_btree.c | 26 +++++++++++++------------- libxfs/xfs_refcount_btree.c | 8 ++++---- libxfs/xfs_rmap_btree.c | 8 ++++---- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index c10f20d6..33b43c7c 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -48,10 +48,10 @@ xfs_allocbt_set_root( STATIC int xfs_allocbt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { int error; xfs_agblock_t bno; diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 9e2e9926..0552157a 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -191,10 +191,10 @@ xfs_bmbt_update_cursor( STATIC int xfs_bmbt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { xfs_alloc_arg_t args; /* block allocation args */ int error; /* error return value */ diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 504032d9..8a36012a 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -110,7 +110,7 @@ struct xfs_btree_ops { /* block allocation / freeing */ int (*alloc_block)(struct xfs_btree_cur *cur, - union xfs_btree_ptr *start_bno, + const union xfs_btree_ptr *start_bno, union xfs_btree_ptr *new_bno, int *stat); int (*free_block)(struct xfs_btree_cur *cur, struct xfs_buf *bp); diff --git a/libxfs/xfs_btree_staging.c b/libxfs/xfs_btree_staging.c index d808f0fc..146d2475 100644 --- a/libxfs/xfs_btree_staging.c +++ b/libxfs/xfs_btree_staging.c @@ -59,10 +59,10 @@ xfs_btree_fakeroot_dup_cursor( */ STATIC int xfs_btree_fakeroot_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start_bno, - union xfs_btree_ptr *new_bno, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start_bno, + union xfs_btree_ptr *new_bno, + int *stat) { ASSERT(0); return -EFSCORRUPTED; diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index f644882b..5053c4a5 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -87,11 +87,11 @@ xfs_inobt_mod_blockcount( STATIC int __xfs_inobt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat, - enum xfs_ag_resv_type resv) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat, + enum xfs_ag_resv_type resv) { xfs_alloc_arg_t args; /* block allocation args */ int error; /* error return value */ @@ -126,20 +126,20 @@ __xfs_inobt_alloc_block( STATIC int xfs_inobt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { return __xfs_inobt_alloc_block(cur, start, new, stat, XFS_AG_RESV_NONE); } STATIC int xfs_finobt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { if (cur->bc_mp->m_finobt_nores) return xfs_inobt_alloc_block(cur, start, new, stat); diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 291098a9..7a5a1a8d 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -50,10 +50,10 @@ xfs_refcountbt_set_root( STATIC int xfs_refcountbt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 755246c6..7a441f64 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -74,10 +74,10 @@ xfs_rmapbt_set_root( STATIC int xfs_rmapbt_alloc_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *start, - union xfs_btree_ptr *new, - int *stat) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *start, + union xfs_btree_ptr *new, + int *stat) { struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; From patchwork Tue Sep 14 02:41:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E2CC433EF for ; Tue, 14 Sep 2021 02:41:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CB1560C51 for ; Tue, 14 Sep 2021 02:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237777AbhINCmv (ORCPT ); Mon, 13 Sep 2021 22:42:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:53376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237737AbhINCmu (ORCPT ); Mon, 13 Sep 2021 22:42:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25976606A5; Tue, 14 Sep 2021 02:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587293; bh=mYGCy3bXaV6eVDRMzyoIpqVsYtrrqk3RBBQjhWfyfXw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=p6Wysehfm7DNozy+xKiPjsBdxdlMKzK4tG/eFChdKGN5gfEqpGfWQeHX83pqpFRFP SZizViB91y1iCySBhNsreD5sIztwQ6ha46qMt8j7S5BChLROQoGd2H5s83AsQdbFrO hdY+8mG7u/kenFjQWMrLCnnvOu2Sd1ZzDQ9yu9QHsgtOwelZq3BHhFRg2GOFGEhbME MQOIxA10o1APJ8hiKhFy8sGyz61XzzwTVnoTCxkjeG7W68KLI8fzDriGe9+XIrhtAD s1Br27bTROjcpXUBEc/Uk//gc/IyA7RxbuFn1GjP9T8WPol3qTwU1fifWiksEnJYhg CRHy2FI8frAIQ== Subject: [PATCH 17/43] xfs: make the start pointer passed to btree update_lastrec functions const From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:32 -0700 Message-ID: <163158729289.1604118.1441354765552916486.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 60e265f7f85a3d91c368f9284dc6501fa1f41e50 This btree function is called when updating a record in the rightmost block of a btree so that we can update the AGF's longest free extent length field. Neither parameter is supposed to be updated, so mark them both const. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_alloc_btree.c | 10 +++++----- libxfs/xfs_btree.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 33b43c7c..34a514c6 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -101,11 +101,11 @@ xfs_allocbt_free_block( */ STATIC void xfs_allocbt_update_lastrec( - struct xfs_btree_cur *cur, - struct xfs_btree_block *block, - union xfs_btree_rec *rec, - int ptr, - int reason) + struct xfs_btree_cur *cur, + const struct xfs_btree_block *block, + const union xfs_btree_rec *rec, + int ptr, + int reason) { struct xfs_agf *agf = cur->bc_ag.agbp->b_addr; struct xfs_perag *pag; diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 8a36012a..830702bd 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -117,8 +117,8 @@ struct xfs_btree_ops { /* update last record information */ void (*update_lastrec)(struct xfs_btree_cur *cur, - struct xfs_btree_block *block, - union xfs_btree_rec *rec, + const struct xfs_btree_block *block, + const union xfs_btree_rec *rec, int ptr, int reason); /* records in block/level */ @@ -423,7 +423,7 @@ void xfs_btree_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, int); /* * Helpers. */ -static inline int xfs_btree_get_numrecs(struct xfs_btree_block *block) +static inline int xfs_btree_get_numrecs(const struct xfs_btree_block *block) { return be16_to_cpu(block->bb_numrecs); } @@ -434,7 +434,7 @@ static inline void xfs_btree_set_numrecs(struct xfs_btree_block *block, block->bb_numrecs = cpu_to_be16(numrecs); } -static inline int xfs_btree_get_level(struct xfs_btree_block *block) +static inline int xfs_btree_get_level(const struct xfs_btree_block *block) { return be16_to_cpu(block->bb_level); } From patchwork Tue Sep 14 02:41:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF54BC433EF for ; Tue, 14 Sep 2021 02:41:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF8A861108 for ; Tue, 14 Sep 2021 02:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhINCmz (ORCPT ); Mon, 13 Sep 2021 22:42:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:53426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbhINCmz (ORCPT ); Mon, 13 Sep 2021 22:42:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 933D9610D1; Tue, 14 Sep 2021 02:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587298; bh=PaUMx2sjrZfxt+NE1vXH1nIfbT/9eOniQEOhn1MQyok=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=BCIDnXvJiPmks3hNUPLo0+GC6n4a8CEAxjGZ29JLN887Q92S0BRY4XrlUDRXxwTr9 bmKo78bYNpj3fG9yaiXt3vefHnDqT/YeHT5y3XMtOSSbr7kqNIvBre0nzNLN/apAYb rt6np7s0fYplg2G0Uvow1e3QMi3/LZrI9CAuDqXi0juK0M0VLOief1/X0ZzVQVJfzu NOn4GrFWEY3DzNzNHsh2P0X8cCfgbGtsCdVWDW/6/10qyn8UVAIe46rHwiE/hSJVMp tvJAXwnYyNvqlQSDcIBDVYmbjnZUezF/2UM50s4f+Xzv4OdSdx1afelsdZez+W2U7t Sj+V4LZj9VRbg== Subject: [PATCH 18/43] xfs: constify btree function parameters that are not modified From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:38 -0700 Message-ID: <163158729834.1604118.5825865157562723641.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: 32816fd7920b32c24e1720ce387482fb430959fc Constify the rest of the btree functions that take structure and union pointers and are not supposed to modify them. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_btree.c | 70 ++++++++++++++++++++++++++-------------------------- libxfs/xfs_btree.h | 21 +++++++++------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index fa3ba314..be4b8fa3 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -222,10 +222,10 @@ xfs_btree_check_sptr( */ static int xfs_btree_check_ptr( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int index, - int level) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int index, + int level) { if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { if (xfs_btree_check_lptr(cur, be64_to_cpu((&ptr->l)[index]), @@ -932,9 +932,9 @@ xfs_btree_readahead( STATIC int xfs_btree_ptr_to_daddr( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - xfs_daddr_t *daddr) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + xfs_daddr_t *daddr) { xfs_fsblock_t fsbno; xfs_agblock_t agbno; @@ -1009,8 +1009,8 @@ xfs_btree_setbuf( bool xfs_btree_ptr_is_null( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr) { if (cur->bc_flags & XFS_BTREE_LONG_PTRS) return ptr->l == cpu_to_be64(NULLFSBLOCK); @@ -1056,10 +1056,10 @@ xfs_btree_get_sibling( void xfs_btree_set_sibling( - struct xfs_btree_cur *cur, - struct xfs_btree_block *block, - union xfs_btree_ptr *ptr, - int lr) + struct xfs_btree_cur *cur, + struct xfs_btree_block *block, + const union xfs_btree_ptr *ptr, + int lr) { ASSERT(lr == XFS_BB_LEFTSIB || lr == XFS_BB_RIGHTSIB); @@ -1226,10 +1226,10 @@ xfs_btree_set_refs( int xfs_btree_get_buf_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - struct xfs_btree_block **block, - struct xfs_buf **bpp) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + struct xfs_btree_block **block, + struct xfs_buf **bpp) { struct xfs_mount *mp = cur->bc_mp; xfs_daddr_t d; @@ -1254,11 +1254,11 @@ xfs_btree_get_buf_block( */ STATIC int xfs_btree_read_buf_block( - struct xfs_btree_cur *cur, - union xfs_btree_ptr *ptr, - int flags, - struct xfs_btree_block **block, - struct xfs_buf **bpp) + struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, + int flags, + struct xfs_btree_block **block, + struct xfs_buf **bpp) { struct xfs_mount *mp = cur->bc_mp; xfs_daddr_t d; @@ -1286,10 +1286,10 @@ xfs_btree_read_buf_block( */ void xfs_btree_copy_keys( - struct xfs_btree_cur *cur, - union xfs_btree_key *dst_key, - union xfs_btree_key *src_key, - int numkeys) + struct xfs_btree_cur *cur, + union xfs_btree_key *dst_key, + const union xfs_btree_key *src_key, + int numkeys) { ASSERT(numkeys >= 0); memcpy(dst_key, src_key, numkeys * cur->bc_ops->key_len); @@ -1710,10 +1710,10 @@ xfs_btree_decrement( int xfs_btree_lookup_get_block( - struct xfs_btree_cur *cur, /* btree cursor */ - int level, /* level in the btree */ - union xfs_btree_ptr *pp, /* ptr to btree block */ - struct xfs_btree_block **blkp) /* return btree block */ + struct xfs_btree_cur *cur, /* btree cursor */ + int level, /* level in the btree */ + const union xfs_btree_ptr *pp, /* ptr to btree block */ + struct xfs_btree_block **blkp) /* return btree block */ { struct xfs_buf *bp; /* buffer pointer for btree block */ xfs_daddr_t daddr; @@ -4887,12 +4887,12 @@ xfs_btree_has_record_helper( /* Is there a record covering a given range of keys? */ int xfs_btree_has_record( - struct xfs_btree_cur *cur, - union xfs_btree_irec *low, - union xfs_btree_irec *high, - bool *exists) + struct xfs_btree_cur *cur, + const union xfs_btree_irec *low, + const union xfs_btree_irec *high, + bool *exists) { - int error; + int error; error = xfs_btree_query_range(cur, low, high, &xfs_btree_has_record_helper, NULL); diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index 830702bd..4eaf8517 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -503,10 +503,11 @@ union xfs_btree_key *xfs_btree_high_key_addr(struct xfs_btree_cur *cur, int n, union xfs_btree_ptr *xfs_btree_ptr_addr(struct xfs_btree_cur *cur, int n, struct xfs_btree_block *block); int xfs_btree_lookup_get_block(struct xfs_btree_cur *cur, int level, - union xfs_btree_ptr *pp, struct xfs_btree_block **blkp); + const union xfs_btree_ptr *pp, struct xfs_btree_block **blkp); struct xfs_btree_block *xfs_btree_get_block(struct xfs_btree_cur *cur, int level, struct xfs_buf **bpp); -bool xfs_btree_ptr_is_null(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr); +bool xfs_btree_ptr_is_null(struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr); int64_t xfs_btree_diff_two_ptrs(struct xfs_btree_cur *cur, const union xfs_btree_ptr *a, const union xfs_btree_ptr *b); @@ -517,8 +518,9 @@ void xfs_btree_get_keys(struct xfs_btree_cur *cur, struct xfs_btree_block *block, union xfs_btree_key *key); union xfs_btree_key *xfs_btree_high_key_from_key(struct xfs_btree_cur *cur, union xfs_btree_key *key); -int xfs_btree_has_record(struct xfs_btree_cur *cur, union xfs_btree_irec *low, - union xfs_btree_irec *high, bool *exists); +int xfs_btree_has_record(struct xfs_btree_cur *cur, + const union xfs_btree_irec *low, + const union xfs_btree_irec *high, bool *exists); bool xfs_btree_has_more_records(struct xfs_btree_cur *cur); struct xfs_ifork *xfs_btree_ifork_ptr(struct xfs_btree_cur *cur); @@ -541,10 +543,11 @@ xfs_btree_islastblock( void xfs_btree_set_ptr_null(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr); -int xfs_btree_get_buf_block(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, - struct xfs_btree_block **block, struct xfs_buf **bpp); +int xfs_btree_get_buf_block(struct xfs_btree_cur *cur, + const union xfs_btree_ptr *ptr, struct xfs_btree_block **block, + struct xfs_buf **bpp); void xfs_btree_set_sibling(struct xfs_btree_cur *cur, - struct xfs_btree_block *block, union xfs_btree_ptr *ptr, + struct xfs_btree_block *block, const union xfs_btree_ptr *ptr, int lr); void xfs_btree_init_block_cur(struct xfs_btree_cur *cur, struct xfs_buf *bp, int level, int numrecs); @@ -552,7 +555,7 @@ void xfs_btree_copy_ptrs(struct xfs_btree_cur *cur, union xfs_btree_ptr *dst_ptr, const union xfs_btree_ptr *src_ptr, int numptrs); void xfs_btree_copy_keys(struct xfs_btree_cur *cur, - union xfs_btree_key *dst_key, union xfs_btree_key *src_key, - int numkeys); + union xfs_btree_key *dst_key, + const union xfs_btree_key *src_key, int numkeys); #endif /* __XFS_BTREE_H__ */ From patchwork Tue Sep 14 02:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74515C433EF for ; Tue, 14 Sep 2021 02:41:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D237610CC for ; Tue, 14 Sep 2021 02:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236205AbhINCnB (ORCPT ); Mon, 13 Sep 2021 22:43:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCnA (ORCPT ); Mon, 13 Sep 2021 22:43:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F6D6610F9; Tue, 14 Sep 2021 02:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587304; bh=TWOw9M4Kcvvpw2DQ+GNR1cnlFYnJX1WF5J3B2SGkXpg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=RFlofdo1K3oUIg4t0f5vNfzB8PwL0nYDh6jd9UO9G4+pW8Ca3EpWtYoPqLFZuyC0h p6NRtfMtLIbXO6a70d5QEEmdzKjvg3ut3i3FqdOjqPztM0f7mTYEEzZmydISDqvKHG L+AlsmEVGLAgKFPChafyRz182Cc1jcoTiBZ9i1fAkXAbOVEbPrhZULiHTnyRwbQqSx +n5yCUM5GHcirmbeUJYCvhMOSlVwI5qd7XbPbOqU11MU9a6wSHGi26zNNBz6MZbYHJ spIORx/K5mOXkW8XHy8FhVr/mXOfp6LwLAz05dR/65pqHFIHluTSajDBmlY/kYKMJt o/vfIFPDkkaoA== Subject: [PATCH 19/43] xfs: resolve fork names in trace output From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Carlos Maiolino , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:43 -0700 Message-ID: <163158730380.1604118.14813924693730762538.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Source kernel commit: f93f85f77aa80f3e4d5bada01248c98da32933c5 Emit whichfork values as text strings in the ftrace output. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Carlos Maiolino Signed-off-by: Darrick J. Wong --- libxfs/xfs_types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 0870ef6f..b6da06b4 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -87,6 +87,11 @@ typedef void * xfs_failaddr_t; #define XFS_ATTR_FORK 1 #define XFS_COW_FORK 2 +#define XFS_WHICHFORK_STRINGS \ + { XFS_DATA_FORK, "data" }, \ + { XFS_ATTR_FORK, "attr" }, \ + { XFS_COW_FORK, "cow" } + /* * Min numbers of data/attr fork btree root pointers. */ From patchwork Tue Sep 14 02:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8922C433F5 for ; Tue, 14 Sep 2021 02:41:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A22CC610F9 for ; Tue, 14 Sep 2021 02:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236074AbhINCnG (ORCPT ); Mon, 13 Sep 2021 22:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCnG (ORCPT ); Mon, 13 Sep 2021 22:43:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80443610CC; Tue, 14 Sep 2021 02:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587309; bh=TcFCeBPnxLvqlpWygdscfZwtNWXM7c3b54HUHS2AP+g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CZSWoQd+6gmkZt/Ndd5HdCA4q/d4ioyHz5tYREDztsdsBCj4UUvujxLNxMS1Z2KfB jUtbPvWekkFA1AXPHymH28F48C/R0YYyY0FLx7T7pAVkgjyb3D4ftjgHPr+W2NuxbW y4q3n5C+wOiAJ55UPUpBNx+AZyFui5chUVcAQJ/kJYBDHlHZs6gldAqOFYXVtKAi1m oE/I13uk4fGoAZITJ+hXgPCCreY4CvWGeTotN95+KiJ+1N0jJqcncg/jNu4IDabL3L QTTpGkodgmvinBr+UnvT4N5uAHEhBYexS6rSPNNzZNoCLGi0Rv9vQYNq9PFG8KRSXT GUVfFXUqwx2MQ== Subject: [PATCH 20/43] xfs: sb verifier doesn't handle uncached sb buffer From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:49 -0700 Message-ID: <163158730925.1604118.17231730849319617732.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 8cf07f3dd56195316be97758cb8b4e1d7183ea84 The verifier checks explicitly for bp->b_bn == XFS_SB_DADDR to match the primary superblock buffer, but the primary superblock is an uncached buffer and so bp->b_bn is always -1ULL. Hence this never matches and the CRC error reporting is wholly dependent on the mount superblock already being populated so CRC feature checks pass and allow CRC errors to be reported. Fix this so that the primary superblock CRC error reporting is not dependent on already having read the superblock into memory. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/xfs_sb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index b2e214ee..f29a59ae 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -634,7 +634,7 @@ xfs_sb_read_verify( if (!xfs_buf_verify_cksum(bp, XFS_SB_CRC_OFF)) { /* Only fail bad secondaries on a known V5 filesystem */ - if (bp->b_bn == XFS_SB_DADDR || + if (bp->b_maps[0].bm_bn == XFS_SB_DADDR || xfs_sb_version_hascrc(&mp->m_sb)) { error = -EFSBADCRC; goto out_error; From patchwork Tue Sep 14 02:41:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53F46C433F5 for ; Tue, 14 Sep 2021 02:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 308DC61108 for ; Tue, 14 Sep 2021 02:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhINCnL (ORCPT ); Mon, 13 Sep 2021 22:43:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:53506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCnL (ORCPT ); Mon, 13 Sep 2021 22:43:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F04CC610CC; Tue, 14 Sep 2021 02:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587315; bh=KlnbJlF9e8iNH4QQKPKmX92PVOKJqFA0JHLGC3Zbt50=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Xya67BbbDxp1jmIBlU/6tGDKndHMif5nCz9E3uBKru9joxKcVCOv+AE6N6eC0REkd oEjxQUMucgM7Dp/epRV9FgzEQ2Rrw0UzEQK1ewR51fnP34cvKoFET2vtIGxaJK+luw jFclHadQXWmUe2fP+tEIWtBhhawv6M5hJGynHgumiKik2OoXsXL8KpXRJQgJEnm4Z5 TmoD/2jyIkD0rXN0OTb4X2D6DqxHAs8ilsFc+Hp2ivFRsJR7jWOIb3Y1ls38ecv3VV CF0JbBI0G7YnJY9oyur4WKUr7HvQZ6NhtYPIoK4jIGNmtTbE6sz61qcmqRW5wWm+wB 5ZQvr+hMqo19w== Subject: [PATCH 21/43] xfs: rename xfs_has_attr() From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:41:54 -0700 Message-ID: <163158731471.1604118.2196733648224977803.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 51b495eba84dee8c1df4abfc26fc134ea190e28f xfs_has_attr() is poorly named. It has global scope as it is defined in a header file, but it has no namespace scope that tells us what it is checking has attributes. It's not even clear what "has_attr" means, because what it is actually doing is an attribute fork lookup to see if the attribute exists. Upcoming patches use this "xfs_has_" namespace for global filesystem features, which conflicts with this function. Rename xfs_has_attr() to xfs_attr_lookup() and make it a static function, freeing up the "xfs_has_" namespace for global scope usage. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_attr.c | 7 +++---- libxfs/xfs_attr.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 2957fd03..07b19652 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -642,8 +642,8 @@ xfs_attr_set_iter( /* * Return EEXIST if attr is found, or ENOATTR if not */ -int -xfs_has_attr( +static int +xfs_attr_lookup( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; @@ -780,8 +780,8 @@ xfs_attr_set( goto out_trans_cancel; } + error = xfs_attr_lookup(args); if (args->value) { - error = xfs_has_attr(args); if (error == -EEXIST && (args->attr_flags & XATTR_CREATE)) goto out_trans_cancel; if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) @@ -796,7 +796,6 @@ xfs_attr_set( if (!args->trans) goto out_unlock; } else { - error = xfs_has_attr(args); if (error != -EEXIST) goto out_trans_cancel; diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 8de5d1d2..5e71f719 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -490,7 +490,6 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); -int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); From patchwork Tue Sep 14 02:42:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A645C433F5 for ; Tue, 14 Sep 2021 02:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37FD9610D1 for ; Tue, 14 Sep 2021 02:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237467AbhINCnR (ORCPT ); Mon, 13 Sep 2021 22:43:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237098AbhINCnR (ORCPT ); Mon, 13 Sep 2021 22:43:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68BD9610D1; Tue, 14 Sep 2021 02:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587320; bh=87rFHsW5ysEHoN9qLTfflJIMTUC4ESrfLPfJjo/5NZk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=FmmvBKzoFYpcSjKOrg0xOhTw0DAmcWK2M0u+L5ISRehtiK41JTUgYmEf8HVZ0R+/V wdzCF0pBjGgSs8n/HscUJOQc75mQt+lt761FmRZxihA4yvoARY2QFwZ/vbN1Pgm+V1 vw8QTcu4/RFtHofd/Be09CD8EkoWIio/EY1h2DKVy7kuKBFlP26yT/1RdgXk4dSZDH X0ctmUxj6ikuRmalDunNr+hx9UKbGMdTZ7DOK2Poo1lat413/zySZDfU7u50uFlxCX ZlbxgVLdU4RZisEg/BaPcHlsvyBoSXjsqsT0vcoqmrG0q5BjdzRFQPWM+cGqO8SBwh 5w3kLwdOr+FTA== Subject: [PATCH 22/43] xfs: rework attr2 feature and mount options From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:00 -0700 Message-ID: <163158732017.1604118.6704125945588625133.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: e23b55d537c9be60ae918fa6c3be0d699986f346 The attr2 feature is somewhat unique in that it has both a superblock feature bit to enable it and mount options to enable and disable it. Back when it was first introduced in 2005, attr2 was disabled unless either the attr2 superblock feature bit was set, or the attr2 mount option was set. If the superblock feature bit was not set but the mount option was set, then when the first attr2 format inode fork was created, it would set the superblock feature bit. This is as it should be - the superblock feature bit indicated the presence of the attr2 on disk format. The noattr2 mount option, however, did not affect the superblock feature bit. If noattr2 was specified, the on-disk superblock feature bit was ignored and the code always just created attr1 format inode forks. If neither of the attr2 or noattr2 mounts option were specified, then the behaviour was determined by the superblock feature bit. This was all pretty sane. Fast foward 3 years, and we are dealing with fallout from the botched sb_features2 addition and having to deal with feature mismatches between the sb_features2 and sb_bad_features2 fields. The attr2 feature bit was one of these flags. The reconciliation was done well after mount option parsing and, unfortunately, the feature reconciliation had a bug where it ignored the noattr2 mount option. For reasons lost to the mists of time, it was decided that resolving this issue in commit 7c12f296500e ("[XFS] Fix up noattr2 so that it will properly update the versionnum and features2 fields.") required noattr2 to clear the superblock attr2 feature bit. This greatly complicated the attr2 behaviour and broke rules about feature bits needing to be set when those specific features are present in the filesystem. By complicated, I mean that it introduced problems due to feature bit interactions with log recovery. All of the superblock feature bit checks are done prior to log recovery, but if we crash after removing a feature bit, then on the next mount we see the feature bit in the unrecovered superblock, only to have it go away after the log has been replayed. This means our mount time feature processing could be all wrong. Hence you can mount with noattr2, crash shortly afterwards, and mount again without attr2 or noattr2 and still have attr2 enabled because the second mount sees attr2 still enabled in the superblock before recovery runs and removes the feature bit. It's just a mess. Further, this is all legacy code as the v5 format requires attr2 to be enabled at all times and it cannot be disabled. i.e. the noattr2 mount option returns an error when used on v5 format filesystems. To straighten this all out, this patch reverts the attr2/noattr2 mount option behaviour back to the original behaviour. There is no reason for disabling attr2 these days, so we will only do this when the noattr2 mount option is set. This will not remove the superblock feature bit. The superblock bit will provide the default behaviour and only track whether attr2 is present on disk or not. The attr2 mount option will enable the creation of attr2 format inode forks, and if the superblock feature bit is not set it will be added when the first attr2 inode fork is created. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_format.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 5d8a1291..ac739e6a 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -398,13 +398,6 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; } -static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) -{ - sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; - if (!sbp->sb_features2) - sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; -} - static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) { return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || From patchwork Tue Sep 14 02:42:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DAFEC433EF for ; Tue, 14 Sep 2021 02:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 245FD606A5 for ; Tue, 14 Sep 2021 02:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbhINCnW (ORCPT ); Mon, 13 Sep 2021 22:43:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:53564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCnW (ORCPT ); Mon, 13 Sep 2021 22:43:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA8EF610D1; Tue, 14 Sep 2021 02:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587325; bh=a4yJ7rWJ0SpUf5rANrsQvLZjshRCtQQ43GIQxqfkzeE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ntfP4LB8YBwayr+VJL1cxfkohGXkmoQ7yzH1FsoK2W1dKbAdAaLQFOCvNzv5QkktD RTsFp4bceE0xGNG38vAa+0Z0D6Q+DboWaTpRWDtNm7jyN1dq+p2XrRmlO5inr0jbNd 5gyukMe1zqUkxgzMZAjhmFhmxqKkHGjohiyeoBV5Igm1ZsJh1EBYwILGawmWsR9CoE +GMWg2CVACHQK4XYgUtV1cA5nTPwRFiJl1g9nHXlIKSjeVaiv8Zo5GxbakukfUVZmh 8z8CuVW4qE/nHkQEIcTPGPL9k7cSSCqNqdmxOytlGMXFtfhKxczg90OeoODabRRHwU PFJr6VOO9vhug== Subject: [PATCH 23/43] xfs: reflect sb features in xfs_mount From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:05 -0700 Message-ID: <163158732562.1604118.11206667342956091163.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: a1d86e8dec8c1325d301c9d5594bb794bc428fc3 Currently on-disk feature checks require decoding the superblock fileds and so can be non-trivial. We have almost 400 hundred individual feature checks in the XFS code, so this is a significant amount of code. To reduce runtime check overhead, pre-process all the version flags into a features field in the xfs_mount at mount time so we can convert all the feature checks to a simple flag check. There is also a need to convert the dynamic feature flags to update the m_features field. This is required for attr, attr2 and quota features. New xfs_mount based wrappers are added for this. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/sb.c | 8 ++++- include/xfs_mount.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++ libxfs/init.c | 1 + libxfs/libxfs_api_defs.h | 1 + libxfs/xfs_format.h | 2 + libxfs/xfs_sb.c | 66 +++++++++++++++++++++++++++++++++++++++ libxfs/xfs_sb.h | 1 + logprint/logprint.c | 1 + mkfs/xfs_mkfs.c | 2 + repair/phase2.c | 1 + repair/versions.c | 3 ++ 11 files changed, 161 insertions(+), 2 deletions(-) diff --git a/db/sb.c b/db/sb.c index b4c14276..7909acae 100644 --- a/db/sb.c +++ b/db/sb.c @@ -720,6 +720,7 @@ version_f( { uint16_t version = 0; uint32_t features = 0; + unsigned long old_mfeatures = 0; xfs_agnumber_t ag; if (argc == 2) { /* WRITE VERSION */ @@ -802,7 +803,7 @@ version_f( version = mp->m_sb.sb_versionnum; features = mp->m_sb.sb_features2; } else if (!strcasecmp(argv[1], "projid32bit")) { - xfs_sb_version_addprojid32bit(&mp->m_sb); + xfs_sb_version_addprojid32(&mp->m_sb); version = mp->m_sb.sb_versionnum; features = mp->m_sb.sb_features2; } else { @@ -821,6 +822,8 @@ version_f( } mp->m_sb.sb_versionnum = version; mp->m_sb.sb_features2 = features; + mp->m_features &= ~XFS_FEAT_ATTR2; + mp->m_features |= libxfs_sb_version_to_features(&mp->m_sb); } } @@ -831,6 +834,8 @@ version_f( features = mp->m_sb.sb_features2; mp->m_sb.sb_versionnum = strtoul(argv[1], &sp, 0); mp->m_sb.sb_features2 = strtoul(argv[2], &sp, 0); + old_mfeatures = mp->m_features; + mp->m_features = libxfs_sb_version_to_features(&mp->m_sb); } dbprintf(_("versionnum [0x%x+0x%x] = %s\n"), mp->m_sb.sb_versionnum, @@ -839,6 +844,7 @@ version_f( if (argc == 3) { /* now reset... */ mp->m_sb.sb_versionnum = version; mp->m_sb.sb_features2 = features; + mp->m_features = old_mfeatures; return 0; } diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 763122e0..351ceaef 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -78,6 +78,7 @@ typedef struct xfs_mount { uint m_ag_max_usable; /* max space per AG */ struct radix_tree_root m_perag_tree; uint m_flags; /* global mount flags */ + uint64_t m_features; /* active filesystem features */ bool m_finobt_nores; /* no per-AG finobt resv. */ uint m_qflags; /* quota status flags */ uint m_attroffset; /* inode attribute offset */ @@ -117,6 +118,82 @@ typedef struct xfs_mount { #define M_IGEO(mp) (&(mp)->m_ino_geo) +/* + * Flags for m_features. + * + * These are all the active features in the filesystem, regardless of how + * they are configured. + */ +#define XFS_FEAT_ATTR (1ULL << 0) /* xattrs present in fs */ +#define XFS_FEAT_NLINK (1ULL << 1) /* 32 bit link counts */ +#define XFS_FEAT_QUOTA (1ULL << 2) /* quota active */ +#define XFS_FEAT_ALIGN (1ULL << 3) /* inode alignment */ +#define XFS_FEAT_DALIGN (1ULL << 4) /* data alignment */ +#define XFS_FEAT_LOGV2 (1ULL << 5) /* version 2 logs */ +#define XFS_FEAT_SECTOR (1ULL << 6) /* sector size > 512 bytes */ +#define XFS_FEAT_EXTFLG (1ULL << 7) /* unwritten extents */ +#define XFS_FEAT_ASCIICI (1ULL << 8) /* ASCII only case-insens. */ +#define XFS_FEAT_LAZYSBCOUNT (1ULL << 9) /* Superblk counters */ +#define XFS_FEAT_ATTR2 (1ULL << 10) /* dynamic attr fork */ +#define XFS_FEAT_PARENT (1ULL << 11) /* parent pointers */ +#define XFS_FEAT_PROJID32 (1ULL << 12) /* 32 bit project id */ +#define XFS_FEAT_CRC (1ULL << 13) /* metadata CRCs */ +#define XFS_FEAT_V3INODES (1ULL << 14) /* Version 3 inodes */ +#define XFS_FEAT_PQUOTINO (1ULL << 15) /* non-shared proj/grp quotas */ +#define XFS_FEAT_FTYPE (1ULL << 16) /* inode type in dir */ +#define XFS_FEAT_FINOBT (1ULL << 17) /* free inode btree */ +#define XFS_FEAT_RMAPBT (1ULL << 18) /* reverse map btree */ +#define XFS_FEAT_REFLINK (1ULL << 19) /* reflinked files */ +#define XFS_FEAT_SPINODES (1ULL << 20) /* sparse inode chunks */ +#define XFS_FEAT_META_UUID (1ULL << 21) /* metadata UUID */ +#define XFS_FEAT_REALTIME (1ULL << 22) /* realtime device present */ +#define XFS_FEAT_INOBTCNT (1ULL << 23) /* inobt block counts */ +#define XFS_FEAT_BIGTIME (1ULL << 24) /* large timestamps */ +#define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ + +#define __XFS_HAS_FEAT(name, NAME) \ +static inline bool xfs_has_ ## name (struct xfs_mount *mp) \ +{ \ + return mp->m_features & XFS_FEAT_ ## NAME; \ +} + +/* Some features can be added dynamically so they need a set wrapper, too. */ +#define __XFS_ADD_FEAT(name, NAME) \ + __XFS_HAS_FEAT(name, NAME); \ +static inline void xfs_add_ ## name (struct xfs_mount *mp) \ +{ \ + mp->m_features |= XFS_FEAT_ ## NAME; \ + xfs_sb_version_add ## name(&mp->m_sb); \ +} + +/* Superblock features */ +__XFS_ADD_FEAT(attr, ATTR) +__XFS_HAS_FEAT(nlink, NLINK) +__XFS_ADD_FEAT(quota, QUOTA) +__XFS_HAS_FEAT(align, ALIGN) +__XFS_HAS_FEAT(dalign, DALIGN) +__XFS_HAS_FEAT(logv2, LOGV2) +__XFS_HAS_FEAT(sector, SECTOR) +__XFS_HAS_FEAT(extflg, EXTFLG) +__XFS_HAS_FEAT(asciici, ASCIICI) +__XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT) +__XFS_ADD_FEAT(attr2, ATTR2) +__XFS_HAS_FEAT(parent, PARENT) +__XFS_ADD_FEAT(projid32, PROJID32) +__XFS_HAS_FEAT(crc, CRC) +__XFS_HAS_FEAT(v3inodes, V3INODES) +__XFS_HAS_FEAT(pquotino, PQUOTINO) +__XFS_HAS_FEAT(ftype, FTYPE) +__XFS_HAS_FEAT(finobt, FINOBT) +__XFS_HAS_FEAT(rmapbt, RMAPBT) +__XFS_HAS_FEAT(reflink, REFLINK) +__XFS_HAS_FEAT(sparseinodes, SPINODES) +__XFS_HAS_FEAT(metauuid, META_UUID) +__XFS_HAS_FEAT(realtime, REALTIME) +__XFS_HAS_FEAT(inobtcounts, INOBTCNT) +__XFS_HAS_FEAT(bigtime, BIGTIME) +__XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) + #define LIBXFS_MOUNT_DEBUGGER 0x0001 #define LIBXFS_MOUNT_32BITINODES 0x0002 #define LIBXFS_MOUNT_32BITINOOPT 0x0004 diff --git a/libxfs/init.c b/libxfs/init.c index 735c7851..b0a6d1fc 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -715,6 +715,7 @@ libxfs_mount( bool debugger = (flags & LIBXFS_MOUNT_DEBUGGER); int error; + mp->m_features = xfs_sb_version_to_features(sb); libxfs_buftarg_init(mp, dev, logdev, rtdev); mp->m_finobt_nores = true; diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index b76e6380..a086fca2 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -161,6 +161,7 @@ #define xfs_sb_quota_from_disk libxfs_sb_quota_from_disk #define xfs_sb_read_secondary libxfs_sb_read_secondary #define xfs_sb_to_disk libxfs_sb_to_disk +#define xfs_sb_version_to_features libxfs_sb_version_to_features #define xfs_symlink_blocks libxfs_symlink_blocks #define xfs_symlink_hdr_ok libxfs_symlink_hdr_ok diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index ac739e6a..fdd35202 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -405,7 +405,7 @@ static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); } -static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) +static inline void xfs_sb_version_addprojid32(struct xfs_sb *sbp) { sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index f29a59ae..100dd87d 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -28,6 +28,72 @@ * Physical superblock buffer manipulations. Shared with libxfs in userspace. */ +uint64_t +xfs_sb_version_to_features( + struct xfs_sb *sbp) +{ + uint64_t features = 0; + + /* optional V4 features */ + if (sbp->sb_rblocks > 0) + features |= XFS_FEAT_REALTIME; + if (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT) + features |= XFS_FEAT_ATTR; + if (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT) + features |= XFS_FEAT_QUOTA; + if (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT) + features |= XFS_FEAT_ALIGN; + if (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT) + features |= XFS_FEAT_LOGV2; + if (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT) + features |= XFS_FEAT_DALIGN; + if (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT) + features |= XFS_FEAT_EXTFLG; + if (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT) + features |= XFS_FEAT_SECTOR; + if (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT) + features |= XFS_FEAT_ASCIICI; + if (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) { + if (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT) + features |= XFS_FEAT_LAZYSBCOUNT; + if (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT) + features |= XFS_FEAT_ATTR2; + if (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT) + features |= XFS_FEAT_PROJID32; + if (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE) + features |= XFS_FEAT_FTYPE; + } + + if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5) + return features; + + /* Always on V5 features */ + features |= XFS_FEAT_ALIGN | XFS_FEAT_LOGV2 | XFS_FEAT_EXTFLG | + XFS_FEAT_LAZYSBCOUNT | XFS_FEAT_ATTR2 | XFS_FEAT_PROJID32 | + XFS_FEAT_V3INODES | XFS_FEAT_CRC | XFS_FEAT_PQUOTINO; + + /* Optional V5 features */ + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT) + features |= XFS_FEAT_FINOBT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_RMAPBT) + features |= XFS_FEAT_RMAPBT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK) + features |= XFS_FEAT_REFLINK; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) + features |= XFS_FEAT_FTYPE; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) + features |= XFS_FEAT_SPINODES; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) + features |= XFS_FEAT_META_UUID; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_BIGTIME) + features |= XFS_FEAT_BIGTIME; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) + features |= XFS_FEAT_NEEDSREPAIR; + return features; +} + /* Check all the superblock fields we care about when reading one in. */ STATIC int xfs_validate_sb_read( diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index 0c1602d9..d2dd99cb 100644 --- a/libxfs/xfs_sb.h +++ b/libxfs/xfs_sb.h @@ -20,6 +20,7 @@ extern void xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp); extern void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from); extern void xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from); extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); +extern uint64_t xfs_sb_version_to_features(struct xfs_sb *sbp); extern int xfs_update_secondary_sbs(struct xfs_mount *mp); diff --git a/logprint/logprint.c b/logprint/logprint.c index 18adf102..430961ff 100644 --- a/logprint/logprint.c +++ b/logprint/logprint.c @@ -80,6 +80,7 @@ logstat(xfs_mount_t *mp) */ sb = &mp->m_sb; libxfs_sb_from_disk(sb, (xfs_dsb_t *)buf); + mp->m_features |= libxfs_sb_version_to_features(&mp->m_sb); mp->m_blkbb_log = sb->sb_blocklog - BBSHIFT; x.logBBsize = XFS_FSB_TO_BB(mp, sb->sb_logblocks); diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index b8c11ce9..2340b7b1 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3425,6 +3425,7 @@ start_superblock_setup( /* log reservation calculations depend on rt geometry */ sbp->sb_rblocks = cfg->rtblocks; sbp->sb_rextsize = cfg->rtextblocks; + mp->m_features |= libxfs_sb_version_to_features(sbp); } static void @@ -3484,6 +3485,7 @@ finish_superblock_setup( sbp->sb_qflags = 0; sbp->sb_unit = cfg->dsunit; sbp->sb_width = cfg->dswidth; + mp->m_features |= libxfs_sb_version_to_features(sbp); } diff --git a/repair/phase2.c b/repair/phase2.c index cb9adf1d..81c01526 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -213,6 +213,7 @@ upgrade_filesystem( do_error( _("filesystem feature upgrade failed, err=%d\n"), error); + mp->m_features |= libxfs_sb_version_to_features(&mp->m_sb); } if (bp) libxfs_buf_relse(bp); diff --git a/repair/versions.c b/repair/versions.c index 7f268f61..0b5376d7 100644 --- a/repair/versions.c +++ b/repair/versions.c @@ -82,6 +82,9 @@ update_sb_version( if (!fs_aligned_inodes && xfs_sb_version_hasalign(&mp->m_sb)) mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; + + mp->m_features &= ~(XFS_FEAT_QUOTA | XFS_FEAT_ALIGN); + mp->m_features |= libxfs_sb_version_to_features(&mp->m_sb); } /* From patchwork Tue Sep 14 02:42:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40DC8C433F5 for ; Tue, 14 Sep 2021 02:42:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2395E610F9 for ; Tue, 14 Sep 2021 02:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhINCn2 (ORCPT ); Mon, 13 Sep 2021 22:43:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234374AbhINCn2 (ORCPT ); Mon, 13 Sep 2021 22:43:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C82F606A5; Tue, 14 Sep 2021 02:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587331; bh=2VXykYF1NpHP6SQ+p/icx2jUHdFl6wCBFB8HfzNvIBg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=TS+d34UpoOxiUZUZTTEs8iFzzxNGUx+jcZ2LsGSfQJN825kfotxkS8LvD4QTbcyqF rRMLw2MAN23Alp7sB/wsJWgH94bcG8iKyzwCNiom4rMDd45T84fBYWEciiDvunJ9AD fM2/hYwUO1iyX20iOrwQz2S1pSfhHYPChQpSmaMzJ4hN6JNKxWI03j8PNwL2K66pXt HzQSn/0mw0as4JQs244tq7JiVCL2S9iOBb0dMdT42zUV3Ato+ckOwTECsk229WtpUD C+eRkPmFj9C6wQl8cyf5FlgcTKmZMaSJYx5ebM88FS/qqO6rbrSmoCEYCoeT0lDRBh wqDZk6/zjwkSA== Subject: [PATCH 24/43] xfs: replace xfs_sb_version checks with feature flag checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:11 -0700 Message-ID: <163158733109.1604118.2378745638711836230.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 38c26bfd90e1999650d5ef40f90d721f05916643 Convert the xfs_sb_version_hasfoo() to checks against mp->m_features. Checks of the superblock itself during disk operations (e.g. in the read/write verifiers and the to/from disk formatters) are not converted - they operate purely on the superblock state. Everything else should use the mount features. Large parts of this conversion were done with sed with commands like this: for f in `git grep -l xfs_sb_version_has fs/xfs/*.c`; do sed -i -e 's/xfs_sb_version_has\(.*\)(&\(.*\)->m_sb)/xfs_has_\1(\2)/' $f done With manual cleanups for things like "xfs_has_extflgbit" and other little inconsistencies in naming. The result is ia lot less typing to check features and an XFS binary size reduced by a bit over 3kB: $ size -t fs/xfs/built-in.a text data bss dec hex filenam before 1130866 311352 484 1442702 16038e (TOTALS) after 1127727 311352 484 1439563 15f74b (TOTALS) Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/sb.c | 2 +- libxfs/xfs_ag.c | 20 ++++++++++---------- libxfs/xfs_alloc.c | 34 +++++++++++++++++----------------- libxfs/xfs_alloc_btree.c | 2 +- libxfs/xfs_alloc_btree.h | 2 +- libxfs/xfs_attr_leaf.c | 14 +++++++------- libxfs/xfs_attr_remote.c | 10 +++++----- libxfs/xfs_bmap.c | 12 ++++++------ libxfs/xfs_bmap_btree.c | 4 ++-- libxfs/xfs_bmap_btree.h | 2 +- libxfs/xfs_btree.c | 14 +++++++------- libxfs/xfs_da_btree.c | 4 ++-- libxfs/xfs_da_format.h | 2 +- libxfs/xfs_dir2_block.c | 6 +++--- libxfs/xfs_dir2_data.c | 6 +++--- libxfs/xfs_dir2_leaf.c | 6 +++--- libxfs/xfs_dir2_node.c | 10 +++++----- libxfs/xfs_dir2_sf.c | 2 +- libxfs/xfs_dquot_buf.c | 6 +++--- libxfs/xfs_format.h | 10 +++++----- libxfs/xfs_ialloc.c | 14 +++++++------- libxfs/xfs_ialloc_btree.c | 6 +++--- libxfs/xfs_ialloc_btree.h | 2 +- libxfs/xfs_inode_buf.c | 6 +++--- libxfs/xfs_log_format.h | 4 ++-- libxfs/xfs_log_rlimit.c | 2 +- libxfs/xfs_refcount_btree.c | 4 ++-- libxfs/xfs_rmap.c | 6 +++--- libxfs/xfs_rmap_btree.c | 6 +++--- libxfs/xfs_sb.c | 12 ++++++------ libxfs/xfs_symlink_remote.c | 10 +++++----- libxfs/xfs_trans_resv.c | 12 ++++++------ libxfs/xfs_types.c | 2 +- repair/agheader.c | 2 +- 34 files changed, 128 insertions(+), 128 deletions(-) diff --git a/db/sb.c b/db/sb.c index 7909acae..94001943 100644 --- a/db/sb.c +++ b/db/sb.c @@ -682,7 +682,7 @@ version_string( strcat(s, ",ATTR2"); if (xfs_sb_version_haslazysbcount(&mp->m_sb)) strcat(s, ",LAZYSBCOUNT"); - if (xfs_sb_version_hasprojid32bit(&mp->m_sb)) + if (xfs_sb_version_hasprojid32(&mp->m_sb)) strcat(s, ",PROJID32BIT"); if (xfs_sb_version_hascrc(&mp->m_sb)) strcat(s, ",CRC"); diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 9eda6eba..8051759a 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -467,7 +467,7 @@ xfs_rmaproot_init( rrec->rm_offset = 0; /* account for refc btree root */ - if (xfs_sb_version_hasreflink(&mp->m_sb)) { + if (xfs_has_reflink(mp)) { rrec = XFS_RMAP_REC_ADDR(block, 5); rrec->rm_startblock = cpu_to_be32(xfs_refc_block(mp)); rrec->rm_blockcount = cpu_to_be32(1); @@ -526,7 +526,7 @@ xfs_agfblock_init( agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp)); agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1); agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (xfs_has_rmapbt(mp)) { agf->agf_roots[XFS_BTNUM_RMAPi] = cpu_to_be32(XFS_RMAP_BLOCK(mp)); agf->agf_levels[XFS_BTNUM_RMAPi] = cpu_to_be32(1); @@ -539,9 +539,9 @@ xfs_agfblock_init( tmpsize = id->agsize - mp->m_ag_prealloc_blocks; agf->agf_freeblks = cpu_to_be32(tmpsize); agf->agf_longest = cpu_to_be32(tmpsize); - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) uuid_copy(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid); - if (xfs_sb_version_hasreflink(&mp->m_sb)) { + if (xfs_has_reflink(mp)) { agf->agf_refcount_root = cpu_to_be32( xfs_refc_block(mp)); agf->agf_refcount_level = cpu_to_be32(1); @@ -567,7 +567,7 @@ xfs_agflblock_init( __be32 *agfl_bno; int bucket; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC); agfl->agfl_seqno = cpu_to_be32(id->agno); uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid); @@ -597,9 +597,9 @@ xfs_agiblock_init( agi->agi_freecount = 0; agi->agi_newino = cpu_to_be32(NULLAGINO); agi->agi_dirino = cpu_to_be32(NULLAGINO); - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) uuid_copy(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid); - if (xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (xfs_has_finobt(mp)) { agi->agi_free_root = cpu_to_be32(XFS_FIBT_BLOCK(mp)); agi->agi_free_level = cpu_to_be32(1); } @@ -717,14 +717,14 @@ xfs_ag_init_headers( .ops = &xfs_finobt_buf_ops, .work = &xfs_btroot_init, .type = XFS_BTNUM_FINO, - .need_init = xfs_sb_version_hasfinobt(&mp->m_sb) + .need_init = xfs_has_finobt(mp) }, { /* RMAP root block */ .daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_RMAP_BLOCK(mp)), .numblks = BTOBB(mp->m_sb.sb_blocksize), .ops = &xfs_rmapbt_buf_ops, .work = &xfs_rmaproot_init, - .need_init = xfs_sb_version_hasrmapbt(&mp->m_sb) + .need_init = xfs_has_rmapbt(mp) }, { /* REFC root block */ .daddr = XFS_AGB_TO_DADDR(mp, id->agno, xfs_refc_block(mp)), @@ -732,7 +732,7 @@ xfs_ag_init_headers( .ops = &xfs_refcountbt_buf_ops, .work = &xfs_btroot_init, .type = XFS_BTNUM_REFC, - .need_init = xfs_sb_version_hasreflink(&mp->m_sb) + .need_init = xfs_has_reflink(mp) }, { /* NULL terminating block */ .daddr = XFS_BUF_DADDR_NULL, diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index a7c3b079..b8725339 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -47,7 +47,7 @@ xfs_agfl_size( { unsigned int size = mp->m_sb.sb_sectsize; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) size -= sizeof(struct xfs_agfl); return size / sizeof(xfs_agblock_t); @@ -57,9 +57,9 @@ unsigned int xfs_refc_block( struct xfs_mount *mp) { - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) return XFS_RMAP_BLOCK(mp) + 1; - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) return XFS_FIBT_BLOCK(mp) + 1; return XFS_IBT_BLOCK(mp) + 1; } @@ -68,11 +68,11 @@ xfs_extlen_t xfs_prealloc_blocks( struct xfs_mount *mp) { - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) return xfs_refc_block(mp) + 1; - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) return XFS_RMAP_BLOCK(mp) + 1; - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) return XFS_FIBT_BLOCK(mp) + 1; return XFS_IBT_BLOCK(mp) + 1; } @@ -122,11 +122,11 @@ xfs_alloc_ag_max_usable( blocks = XFS_BB_TO_FSB(mp, XFS_FSS_TO_BB(mp, 4)); /* ag headers */ blocks += XFS_ALLOC_AGFL_RESERVE; blocks += 3; /* AGF, AGI btree root blocks */ - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) blocks++; /* finobt root block */ - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) blocks++; /* rmap root block */ - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) blocks++; /* refcount root block */ return mp->m_sb.sb_agblocks - blocks; @@ -594,7 +594,7 @@ xfs_agfl_verify( * AGFL is what the AGF says is active. We can't get to the AGF, so we * can't verify just those entries are valid. */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return NULL; if (!xfs_verify_magic(bp, agfl->agfl_magicnum)) @@ -634,7 +634,7 @@ xfs_agfl_read_verify( * AGFL is what the AGF says is active. We can't get to the AGF, so we * can't verify just those entries are valid. */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF)) @@ -655,7 +655,7 @@ xfs_agfl_write_verify( xfs_failaddr_t fa; /* no verification of non-crc AGFLs */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; fa = xfs_agfl_verify(bp); @@ -2369,7 +2369,7 @@ xfs_agfl_needs_reset( int active; /* no agfl header on v4 supers */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return false; /* @@ -2873,7 +2873,7 @@ xfs_agf_verify( struct xfs_mount *mp = bp->b_mount; struct xfs_agf *agf = bp->b_addr; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(agf->agf_lsn))) @@ -2903,7 +2903,7 @@ xfs_agf_verify( be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > mp->m_ag_maxlevels) return __this_address; - if (xfs_sb_version_hasrmapbt(&mp->m_sb) && + if (xfs_has_rmapbt(mp) && (be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) < 1 || be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > mp->m_rmap_maxlevels)) return __this_address; @@ -2946,7 +2946,7 @@ xfs_agf_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -2971,7 +2971,7 @@ xfs_agf_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 34a514c6..a8a24fa4 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -496,7 +496,7 @@ xfs_allocbt_init_common( atomic_inc(&pag->pag_ref); cur->bc_ag.pag = pag; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; return cur; diff --git a/libxfs/xfs_alloc_btree.h b/libxfs/xfs_alloc_btree.h index 9eb4c667..2f6b816a 100644 --- a/libxfs/xfs_alloc_btree.h +++ b/libxfs/xfs_alloc_btree.h @@ -20,7 +20,7 @@ struct xbtree_afakeroot; * Btree block header size depends on a superblock flag. */ #define XFS_ALLOC_BLOCK_LEN(mp) \ - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + (xfs_has_crc(((mp))) ? \ XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN) /* diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 6499f16f..3fff838e 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -381,7 +381,7 @@ xfs_attr3_leaf_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -403,7 +403,7 @@ xfs_attr3_leaf_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -624,10 +624,10 @@ STATIC void xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) { if ((mp->m_flags & XFS_MOUNT_ATTR2) && - !(xfs_sb_version_hasattr2(&mp->m_sb))) { + !(xfs_has_attr2(mp))) { spin_lock(&mp->m_sb_lock); - if (!xfs_sb_version_hasattr2(&mp->m_sb)) { - xfs_sb_version_addattr2(&mp->m_sb); + if (!xfs_has_attr2(mp)) { + xfs_add_attr2(mp); spin_unlock(&mp->m_sb_lock); xfs_log_sb(tp); } else @@ -1196,7 +1196,7 @@ xfs_attr3_leaf_to_node( xfs_trans_buf_set_type(args->trans, bp2, XFS_BLFT_ATTR_LEAF_BUF); bp2->b_ops = bp1->b_ops; memcpy(bp2->b_addr, bp1->b_addr, args->geo->blksize); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; hdr3->blkno = cpu_to_be64(bp2->b_bn); } @@ -1261,7 +1261,7 @@ xfs_attr3_leaf_create( memset(&ichdr, 0, sizeof(ichdr)); ichdr.firstused = args->geo->blksize; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_da3_blkinfo *hdr3 = bp->b_addr; ichdr.magic = XFS_ATTR3_LEAF_MAGIC; diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index b781e44d..73eb256e 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -50,7 +50,7 @@ xfs_attr3_rmt_blocks( struct xfs_mount *mp, int attrlen) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { int buflen = XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize); return (attrlen + buflen - 1) / buflen; } @@ -125,7 +125,7 @@ __xfs_attr3_rmt_read_verify( int blksize = mp->m_attr_geo->blksize; /* no verification of non-crc buffers */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return 0; ptr = bp->b_addr; @@ -190,7 +190,7 @@ xfs_attr3_rmt_write_verify( xfs_daddr_t bno; /* no verification of non-crc buffers */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; ptr = bp->b_addr; @@ -245,7 +245,7 @@ xfs_attr3_rmt_hdr_set( { struct xfs_attr3_rmt_hdr *rmt = ptr; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return 0; rmt->rm_magic = cpu_to_be32(XFS_ATTR3_RMT_MAGIC); @@ -295,7 +295,7 @@ xfs_attr_rmtval_copyout( byte_cnt = min(*valuelen, byte_cnt); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (xfs_attr3_rmt_hdr_ok(src, ino, *offset, byte_cnt, bno)) { xfs_alert(mp, diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index a548507c..db9e8566 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1108,17 +1108,17 @@ xfs_bmap_add_attrfork( xfs_trans_log_inode(tp, ip, logflags); if (error) goto trans_cancel; - if (!xfs_sb_version_hasattr(&mp->m_sb) || - (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { + if (!xfs_has_attr(mp) || + (!xfs_has_attr2(mp) && version == 2)) { bool log_sb = false; spin_lock(&mp->m_sb_lock); - if (!xfs_sb_version_hasattr(&mp->m_sb)) { - xfs_sb_version_addattr(&mp->m_sb); + if (!xfs_has_attr(mp)) { + xfs_add_attr(mp); log_sb = true; } - if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { - xfs_sb_version_addattr2(&mp->m_sb); + if (!xfs_has_attr2(mp) && version == 2) { + xfs_add_attr2(mp); log_sb = true; } spin_unlock(&mp->m_sb_lock); diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 0552157a..f5f228bc 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -134,7 +134,7 @@ xfs_bmbt_to_bmdr( xfs_bmbt_key_t *tkp; __be64 *tpp; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { ASSERT(rblock->bb_magic == cpu_to_be32(XFS_BMAP_CRC_MAGIC)); ASSERT(uuid_equal(&rblock->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)); @@ -561,7 +561,7 @@ xfs_bmbt_init_cursor( cur->bc_ops = &xfs_bmbt_ops; cur->bc_flags = XFS_BTREE_LONG_PTRS | XFS_BTREE_ROOT_IN_INODE; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; cur->bc_ino.forksize = XFS_IFORK_SIZE(ip, whichfork); diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h index eda85512..729e3bc5 100644 --- a/libxfs/xfs_bmap_btree.h +++ b/libxfs/xfs_bmap_btree.h @@ -16,7 +16,7 @@ struct xfs_trans; * Btree block header size depends on a superblock flag. */ #define XFS_BMBT_BLOCK_LEN(mp) \ - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + (xfs_has_crc(((mp))) ? \ XFS_BTREE_LBLOCK_CRC_LEN : XFS_BTREE_LBLOCK_LEN) #define XFS_BMBT_REC_ADDR(mp, block, index) \ diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index be4b8fa3..79be19ec 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -61,7 +61,7 @@ __xfs_btree_check_lblock( { struct xfs_mount *mp = cur->bc_mp; xfs_btnum_t btnum = cur->bc_btnum; - int crc = xfs_sb_version_hascrc(&mp->m_sb); + int crc = xfs_has_crc(mp); if (crc) { if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) @@ -126,7 +126,7 @@ __xfs_btree_check_sblock( { struct xfs_mount *mp = cur->bc_mp; xfs_btnum_t btnum = cur->bc_btnum; - int crc = xfs_sb_version_hascrc(&mp->m_sb); + int crc = xfs_has_crc(mp); if (crc) { if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) @@ -284,7 +284,7 @@ xfs_btree_lblock_verify_crc( struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_mount *mp = bp->b_mount; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn))) return false; return xfs_buf_verify_cksum(bp, XFS_BTREE_LBLOCK_CRC_OFF); @@ -322,7 +322,7 @@ xfs_btree_sblock_verify_crc( struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_mount *mp = bp->b_mount; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn))) return false; return xfs_buf_verify_cksum(bp, XFS_BTREE_SBLOCK_CRC_OFF); @@ -1087,7 +1087,7 @@ xfs_btree_init_block_int( __u64 owner, unsigned int flags) { - int crc = xfs_sb_version_hascrc(&mp->m_sb); + int crc = xfs_has_crc(mp); __u32 magic = xfs_btree_magic(crc, btnum); buf->bb_magic = cpu_to_be32(magic); @@ -4419,7 +4419,7 @@ xfs_btree_lblock_v5hdr_verify( struct xfs_mount *mp = bp->b_mount; struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return __this_address; if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; @@ -4469,7 +4469,7 @@ xfs_btree_sblock_v5hdr_verify( struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_perag *pag = bp->b_pag; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return __this_address; if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index f4e1fe80..196f0a9e 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -250,7 +250,7 @@ xfs_da3_node_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -439,7 +439,7 @@ xfs_da3_node_create( xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF); node = bp->b_addr; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_da3_node_hdr *hdr3 = bp->b_addr; memset(hdr3, 0, sizeof(struct xfs_da3_node_hdr)); diff --git a/libxfs/xfs_da_format.h b/libxfs/xfs_da_format.h index b876b44c..5a49caa5 100644 --- a/libxfs/xfs_da_format.h +++ b/libxfs/xfs_da_format.h @@ -789,7 +789,7 @@ struct xfs_attr3_rmt_hdr { #define XFS_ATTR3_RMT_CRC_OFF offsetof(struct xfs_attr3_rmt_hdr, rm_crc) #define XFS_ATTR3_RMT_BUF_SPACE(mp, bufsize) \ - ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \ + ((bufsize) - (xfs_has_crc((mp)) ? \ sizeof(struct xfs_attr3_rmt_hdr) : 0)) /* Number of bytes in a directory block. */ diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index 522f0ffc..4373e819 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -68,7 +68,7 @@ xfs_dir3_block_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -93,7 +93,7 @@ xfs_dir3_block_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -168,7 +168,7 @@ xfs_dir3_block_init( bp->b_ops = &xfs_dir3_block_buf_ops; xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_BLOCK_BUF); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { memset(hdr3, 0, sizeof(*hdr3)); hdr3->magic = cpu_to_be32(XFS_DIR3_BLOCK_MAGIC); hdr3->blkno = cpu_to_be64(bp->b_bn); diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c index d1dbf73a..76f55736 100644 --- a/libxfs/xfs_dir2_data.c +++ b/libxfs/xfs_dir2_data.c @@ -340,7 +340,7 @@ xfs_dir3_data_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -365,7 +365,7 @@ xfs_dir3_data_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -714,7 +714,7 @@ xfs_dir3_data_init( * Initialize the header. */ hdr = bp->b_addr; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; memset(hdr3, 0, sizeof(*hdr3)); diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index e25ee46e..cd63b37e 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -207,7 +207,7 @@ xfs_dir3_leaf_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -232,7 +232,7 @@ xfs_dir3_leaf_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -306,7 +306,7 @@ xfs_dir3_leaf_init( ASSERT(type == XFS_DIR2_LEAF1_MAGIC || type == XFS_DIR2_LEAFN_MAGIC); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; memset(leaf3, 0, sizeof(*leaf3)); diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 3c2653e9..2bccabaf 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -102,7 +102,7 @@ xfs_dir3_free_verify( if (!xfs_verify_magic(bp, hdr->magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) @@ -125,7 +125,7 @@ xfs_dir3_free_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -150,7 +150,7 @@ xfs_dir3_free_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -182,7 +182,7 @@ xfs_dir3_free_header_check( firstdb = (xfs_dir2_da_to_db(mp->m_dir_geo, fbno) - xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET)) * maxbests; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_free_hdr *hdr3 = bp->b_addr; if (be32_to_cpu(hdr3->firstdb) != firstdb) @@ -338,7 +338,7 @@ xfs_dir3_free_get_buf( memset(bp->b_addr, 0, sizeof(struct xfs_dir3_free_hdr)); memset(&hdr, 0, sizeof(hdr)); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_free_hdr *hdr3 = bp->b_addr; hdr.magic = XFS_DIR3_FREE_MAGIC; diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index c1cc2e71..6a57ad27 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -192,7 +192,7 @@ xfs_dir2_block_sfsize( * if there is a filetype field, add the extra byte to the namelen * for each entry that we see. */ - has_ftype = xfs_sb_version_hasftype(&mp->m_sb) ? 1 : 0; + has_ftype = xfs_has_ftype(mp) ? 1 : 0; count = i8count = namelen = 0; btp = xfs_dir2_block_tail_p(geo, hdr); diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c index 0a5a237d..b77f303c 100644 --- a/libxfs/xfs_dquot_buf.c +++ b/libxfs/xfs_dquot_buf.c @@ -104,7 +104,7 @@ xfs_dqblk_verify( struct xfs_dqblk *dqb, xfs_dqid_t id) /* used only during quotacheck */ { - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; @@ -132,7 +132,7 @@ xfs_dqblk_repair( dqb->dd_diskdq.d_type = type; dqb->dd_diskdq.d_id = cpu_to_be32(id); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { uuid_copy(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid); xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk), XFS_DQUOT_CRC_OFF); @@ -149,7 +149,7 @@ xfs_dquot_buf_verify_crc( int ndquots; int i; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return true; /* diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index fdd35202..d4690f28 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -398,7 +398,7 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; } -static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) +static inline bool xfs_sb_version_hasprojid32(struct xfs_sb *sbp) { return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || (xfs_sb_version_hasmorebits(sbp) && @@ -528,7 +528,7 @@ static inline bool xfs_dinode_good_version(struct xfs_sb *sbp, return version == 1 || version == 2; } -static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp) +static inline bool xfs_sb_version_haspquotino(struct xfs_sb *sbp) { return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; } @@ -1462,7 +1462,7 @@ struct xfs_dsymlink_hdr { #define XFS_SYMLINK_MAPS 3 #define XFS_SYMLINK_BUF_SPACE(mp, bufsize) \ - ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \ + ((bufsize) - (xfs_has_crc((mp)) ? \ sizeof(struct xfs_dsymlink_hdr) : 0)) @@ -1694,7 +1694,7 @@ struct xfs_rmap_key { typedef __be32 xfs_rmap_ptr_t; #define XFS_RMAP_BLOCK(mp) \ - (xfs_sb_version_hasfinobt(&((mp)->m_sb)) ? \ + (xfs_has_finobt(((mp))) ? \ XFS_FIBT_BLOCK(mp) + 1 : \ XFS_IBT_BLOCK(mp) + 1) @@ -1926,7 +1926,7 @@ struct xfs_acl { * limited only by the maximum size of the xattr that stores the information. */ #define XFS_ACL_MAX_ENTRIES(mp) \ - (xfs_sb_version_hascrc(&mp->m_sb) \ + (xfs_has_crc(mp) \ ? (XFS_XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ sizeof(struct xfs_acl_entry) \ : 25) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index c1f3d28a..567f9996 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -53,7 +53,7 @@ xfs_inobt_update( union xfs_btree_rec rec; rec.inobt.ir_startino = cpu_to_be32(irec->ir_startino); - if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) { + if (xfs_has_sparseinodes(cur->bc_mp)) { rec.inobt.ir_u.sp.ir_holemask = cpu_to_be16(irec->ir_holemask); rec.inobt.ir_u.sp.ir_count = irec->ir_count; rec.inobt.ir_u.sp.ir_freecount = irec->ir_freecount; @@ -73,7 +73,7 @@ xfs_inobt_btrec_to_irec( struct xfs_inobt_rec_incore *irec) { irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino); - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) { + if (xfs_has_sparseinodes(mp)) { irec->ir_holemask = be16_to_cpu(rec->inobt.ir_u.sp.ir_holemask); irec->ir_count = rec->inobt.ir_u.sp.ir_count; irec->ir_freecount = rec->inobt.ir_u.sp.ir_freecount; @@ -2473,7 +2473,7 @@ xfs_agi_verify( struct xfs_agi *agi = bp->b_addr; int i; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(agi->agi_lsn))) @@ -2492,7 +2492,7 @@ xfs_agi_verify( be32_to_cpu(agi->agi_level) > M_IGEO(mp)->inobt_maxlevels) return __this_address; - if (xfs_sb_version_hasfinobt(&mp->m_sb) && + if (xfs_has_finobt(mp) && (be32_to_cpu(agi->agi_free_level) < 1 || be32_to_cpu(agi->agi_free_level) > M_IGEO(mp)->inobt_maxlevels)) return __this_address; @@ -2523,7 +2523,7 @@ xfs_agi_read_verify( struct xfs_mount *mp = bp->b_mount; xfs_failaddr_t fa; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF)) xfs_verifier_error(bp, -EFSBADCRC, __this_address); else { @@ -2548,7 +2548,7 @@ xfs_agi_write_verify( return; } - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (bip) @@ -2948,7 +2948,7 @@ xfs_ialloc_check_shrink( int has; int error; - if (!xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (!xfs_has_sparseinodes(mp)) return 0; pag = xfs_perag_get(mp, agno); diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 5053c4a5..5fb96203 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -211,7 +211,7 @@ xfs_inobt_init_rec_from_cur( union xfs_btree_rec *rec) { rec->inobt.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino); - if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) { + if (xfs_has_sparseinodes(cur->bc_mp)) { rec->inobt.ir_u.sp.ir_holemask = cpu_to_be16(cur->bc_rec.i.ir_holemask); rec->inobt.ir_u.sp.ir_count = cur->bc_rec.i.ir_count; @@ -445,7 +445,7 @@ xfs_inobt_init_common( cur->bc_blocklog = mp->m_sb.sb_blocklog; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; /* take a reference for the cursor */ @@ -736,7 +736,7 @@ xfs_finobt_calc_reserves( xfs_extlen_t tree_len = 0; int error; - if (!xfs_sb_version_hasfinobt(&mp->m_sb)) + if (!xfs_has_finobt(mp)) return 0; if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) diff --git a/libxfs/xfs_ialloc_btree.h b/libxfs/xfs_ialloc_btree.h index e530c82b..8a322d40 100644 --- a/libxfs/xfs_ialloc_btree.h +++ b/libxfs/xfs_ialloc_btree.h @@ -19,7 +19,7 @@ struct xfs_perag; * Btree block header size depends on a superblock flag. */ #define XFS_INOBT_BLOCK_LEN(mp) \ - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ + (xfs_has_crc(((mp))) ? \ XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN) /* diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index f98f5c47..946261cd 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -512,7 +512,7 @@ xfs_dinode_verify( /* don't allow reflink/cowextsize if we don't have reflink */ if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) && - !xfs_sb_version_hasreflink(&mp->m_sb)) + !xfs_has_reflink(mp)) return __this_address; /* only regular files get reflink */ @@ -547,7 +547,7 @@ xfs_dinode_calc_crc( if (dip->di_version < 3) return; - ASSERT(xfs_sb_version_hascrc(&mp->m_sb)); + ASSERT(xfs_has_crc(mp)); crc = xfs_start_cksum_update((char *)dip, mp->m_sb.sb_inodesize, XFS_DINODE_CRC_OFF); dip->di_crc = xfs_end_cksum(crc); @@ -674,7 +674,7 @@ xfs_inode_validate_cowextsize( hint_flag = (flags2 & XFS_DIFLAG2_COWEXTSIZE); cowextsize_bytes = XFS_FSB_TO_B(mp, cowextsize); - if (hint_flag && !xfs_sb_version_hasreflink(&mp->m_sb)) + if (hint_flag && !xfs_has_reflink(mp)) return __this_address; if (hint_flag && !(S_ISDIR(mode) || S_ISREG(mode))) diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 2c5bcbc1..28c02047 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -41,10 +41,10 @@ typedef uint32_t xlog_tid_t; #define XFS_MIN_LOG_FACTOR 3 #define XLOG_REC_SHIFT(log) \ - BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ + BTOBB(1 << (xfs_has_logv2(log->l_mp) ? \ XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) #define XLOG_TOTAL_REC_SHIFT(log) \ - BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ + BTOBB(XLOG_MAX_ICLOGS << (xfs_has_logv2(log->l_mp) ? \ XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) /* get lsn fields */ diff --git a/libxfs/xfs_log_rlimit.c b/libxfs/xfs_log_rlimit.c index c8398b7d..116178fd 100644 --- a/libxfs/xfs_log_rlimit.c +++ b/libxfs/xfs_log_rlimit.c @@ -92,7 +92,7 @@ xfs_log_calc_minimum_size( if (tres.tr_logcount > 1) max_logres *= tres.tr_logcount; - if (xfs_sb_version_haslogv2(&mp->m_sb) && mp->m_sb.sb_logsunit > 1) + if (xfs_has_logv2(mp) && mp->m_sb.sb_logsunit > 1) lsunit = BTOBB(mp->m_sb.sb_logsunit); /* diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index 7a5a1a8d..ded0ebe1 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -208,7 +208,7 @@ xfs_refcountbt_verify( if (!xfs_verify_magic(bp, block->bb_magic)) return __this_address; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return __this_address; fa = xfs_btree_sblock_v5hdr_verify(bp); if (fa) @@ -461,7 +461,7 @@ xfs_refcountbt_calc_reserves( xfs_extlen_t tree_len; int error; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return 0; error = xfs_alloc_read_agf(mp, tp, pag->pag_agno, 0, &agbp); diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index ed7db353..e93010ff 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -704,7 +704,7 @@ xfs_rmap_free( struct xfs_btree_cur *cur; int error; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 0; cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag); @@ -958,7 +958,7 @@ xfs_rmap_alloc( struct xfs_btree_cur *cur; int error; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 0; cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag); @@ -2458,7 +2458,7 @@ xfs_rmap_update_is_needed( struct xfs_mount *mp, int whichfork) { - return xfs_sb_version_hasrmapbt(&mp->m_sb) && whichfork != XFS_COW_FORK; + return xfs_has_rmapbt(mp) && whichfork != XFS_COW_FORK; } /* diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 7a441f64..05d962d8 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -302,7 +302,7 @@ xfs_rmapbt_verify( if (!xfs_verify_magic(bp, block->bb_magic)) return __this_address; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return __this_address; fa = xfs_btree_sblock_v5hdr_verify(bp); if (fa) @@ -556,7 +556,7 @@ xfs_rmapbt_compute_maxlevels( * disallow reflinking when less than 10% of the per-AG metadata * block reservation since the fallback is a regular file copy. */ - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) mp->m_rmap_maxlevels = XFS_BTREE_MAXLEVELS; else mp->m_rmap_maxlevels = xfs_btree_compute_maxlevels( @@ -604,7 +604,7 @@ xfs_rmapbt_calc_reserves( xfs_extlen_t tree_len; int error; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 0; error = xfs_alloc_read_agf(mp, tp, pag->pag_agno, 0, &agbp); diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 100dd87d..25a4ffdb 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -237,7 +237,7 @@ xfs_validate_sb_common( return -EWRONGFS; } - if (xfs_sb_version_has_pquotino(sbp)) { + if (xfs_sb_version_haspquotino(sbp)) { if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) { xfs_notice(mp, "Version 5 of Super block has XFS_OQUOTA bits."); @@ -376,7 +376,7 @@ xfs_validate_sb_common( XFS_FSB_TO_B(mp, sbp->sb_width), 0, false)) return -EFSCORRUPTED; - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_sb_version_hascrc(sbp) && sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) { xfs_notice(mp, "v5 SB sanity check failed"); return -EFSCORRUPTED; @@ -425,7 +425,7 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) * We need to do these manipilations only if we are working * with an older version of on-disk superblock. */ - if (xfs_sb_version_has_pquotino(sbp)) + if (xfs_sb_version_haspquotino(sbp)) return; if (sbp->sb_qflags & XFS_OQUOTA_ENFD) @@ -543,7 +543,7 @@ xfs_sb_quota_to_disk( uint16_t qflags = from->sb_qflags; to->sb_uquotino = cpu_to_be64(from->sb_uquotino); - if (xfs_sb_version_has_pquotino(from)) { + if (xfs_sb_version_haspquotino(from)) { to->sb_qflags = cpu_to_be16(from->sb_qflags); to->sb_gquotino = cpu_to_be64(from->sb_gquotino); to->sb_pquotino = cpu_to_be64(from->sb_pquotino); @@ -768,7 +768,7 @@ xfs_sb_write_verify( if (error) goto out_error; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_sb_version_hascrc(&sb)) return; if (bip) @@ -1064,7 +1064,7 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_LAZYSB; if (xfs_sb_version_hasattr2(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_ATTR2; - if (xfs_sb_version_hasprojid32bit(sbp)) + if (xfs_sb_version_hasprojid32(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_PROJID32; if (xfs_sb_version_hascrc(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_V5SB; diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c index 8eb3d59f..e0a68319 100644 --- a/libxfs/xfs_symlink_remote.c +++ b/libxfs/xfs_symlink_remote.c @@ -39,7 +39,7 @@ xfs_symlink_hdr_set( { struct xfs_dsymlink_hdr *dsl = bp->b_addr; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return 0; memset(dsl, 0, sizeof(struct xfs_dsymlink_hdr)); @@ -86,7 +86,7 @@ xfs_symlink_verify( struct xfs_mount *mp = bp->b_mount; struct xfs_dsymlink_hdr *dsl = bp->b_addr; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return __this_address; if (!xfs_verify_magic(bp, dsl->sl_magic)) return __this_address; @@ -113,7 +113,7 @@ xfs_symlink_read_verify( xfs_failaddr_t fa; /* no verification of non-crc buffers */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF)) @@ -134,7 +134,7 @@ xfs_symlink_write_verify( xfs_failaddr_t fa; /* no verification of non-crc buffers */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; fa = xfs_symlink_verify(bp); @@ -170,7 +170,7 @@ xfs_symlink_local_to_remote( xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF); - if (!xfs_sb_version_hascrc(&mp->m_sb)) { + if (!xfs_has_crc(mp)) { bp->b_ops = NULL; memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c index fa5edb87..ea57e810 100644 --- a/libxfs/xfs_trans_resv.c +++ b/libxfs/xfs_trans_resv.c @@ -70,9 +70,9 @@ xfs_allocfree_log_count( uint blocks; blocks = num_ops * 2 * (2 * mp->m_ag_maxlevels - 1); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) blocks += num_ops * (2 * mp->m_rmap_maxlevels - 1); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) blocks += num_ops * (2 * mp->m_refc_maxlevels - 1); return blocks; @@ -154,7 +154,7 @@ STATIC uint xfs_calc_finobt_res( struct xfs_mount *mp) { - if (!xfs_sb_version_hasfinobt(&mp->m_sb)) + if (!xfs_has_finobt(mp)) return 0; return xfs_calc_inobt_res(mp); @@ -818,14 +818,14 @@ xfs_trans_resv_calc( * require a permanent reservation on space. */ resp->tr_write.tr_logres = xfs_calc_write_reservation(mp); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK; else resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT; resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT_REFLINK; else @@ -886,7 +886,7 @@ xfs_trans_resv_calc( resp->tr_growrtalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES; resp->tr_qm_dqalloc.tr_logres = xfs_calc_qm_dqalloc_reservation(mp); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK; else resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT; diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 93dd10fb..c4cc5ce5 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -169,7 +169,7 @@ xfs_internal_inum( xfs_ino_t ino) { return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || - (xfs_sb_version_hasquota(&mp->m_sb) && + (xfs_has_quota(mp) && xfs_is_quota_inode(&mp->m_sb, ino)); } diff --git a/repair/agheader.c b/repair/agheader.c index 2af24106..fc62c03a 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -376,7 +376,7 @@ secondary_sb_whack( * superblocks. If it is anything other than 0 it is considered garbage * data beyond the valid sb and explicitly zeroed above. */ - if (xfs_sb_version_has_pquotino(&mp->m_sb) && + if (xfs_sb_version_haspquotino(&mp->m_sb) && sb->sb_inprogress == 1 && sb->sb_pquotino != NULLFSINO) { if (!no_modify) { sb->sb_pquotino = 0; From patchwork Tue Sep 14 02:42:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F2D2C433FE for ; Tue, 14 Sep 2021 02:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17DA9610FB for ; Tue, 14 Sep 2021 02:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237098AbhINCnd (ORCPT ); Mon, 13 Sep 2021 22:43:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:53624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbhINCnd (ORCPT ); Mon, 13 Sep 2021 22:43:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D507D610D1; Tue, 14 Sep 2021 02:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587336; bh=uHhdo0g+9p9Df1VqBv3dS+jX5HZBM13wrBEIzN+nLBk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uFD0emFZ8C8RkKXN53ioLk8Gqkx6pJ1Hl/Vt/AoToaivm58dJRFhjmk5zc7ldnPSa xmT+ARcPXYFj4SniLpJEUw2lcjcaABwl3Trm7gJcFRRQMoSYs5TRA6BmDDERVi9/HP qdiQIv3IwFUT82uYzOIhYDlpqtihooFDYh5AHEVkoi+rzRIMi1R0OZp45jt7vIo2ar ieBWJBVyoIsHeqEKkCSpALvHIYP5rIHbOwQV3On3h3u81NI8T3Zw5y4jKcOD/MjP9X OeCp0rgqJAQlK8aTUMzYhURcZKfAwGwJLeVw0IhUEeKvy3IokEu2d2MfEDNOwC0Ap3 R8lW5g5zz/Rdw== Subject: [PATCH 25/43] xfs: convert mount flags to features From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:16 -0700 Message-ID: <163158733660.1604118.8914008454755284421.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 0560f31a09e523090d1ab2bfe21c69d028c2bdf2 Replace m_flags feature checks with xfs_has_() calls and rework the setup code to set flags in m_features. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 11 +++++++++++ libxfs/xfs_attr.c | 4 ++-- libxfs/xfs_attr_leaf.c | 41 +++++++++++++++++++++++------------------ libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_ialloc.c | 10 ++++------ 5 files changed, 42 insertions(+), 28 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 351ceaef..aed31404 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -194,6 +194,17 @@ __XFS_HAS_FEAT(inobtcounts, INOBTCNT) __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) +/* Kernel mount features that we don't support */ +#define __XFS_UNSUPP_FEAT(name) \ +static inline bool xfs_has_ ## name (struct xfs_mount *mp) \ +{ \ + return false; \ +} +__XFS_UNSUPP_FEAT(wsync) +__XFS_UNSUPP_FEAT(noattr2) +__XFS_UNSUPP_FEAT(ikeep) +__XFS_UNSUPP_FEAT(swalloc) + #define LIBXFS_MOUNT_DEBUGGER 0x0001 #define LIBXFS_MOUNT_32BITINODES 0x0002 #define LIBXFS_MOUNT_32BITINOOPT 0x0004 diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 07b19652..3a712e36 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -224,7 +224,7 @@ xfs_attr_try_sf_addname( if (!error && !(args->op_flags & XFS_DA_OP_NOTIME)) xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG); - if (dp->i_mount->m_flags & XFS_MOUNT_WSYNC) + if (xfs_has_wsync(dp->i_mount)) xfs_trans_set_sync(args->trans); return error; @@ -808,7 +808,7 @@ xfs_attr_set( * If this is a synchronous mount, make sure that the * transaction goes to disk before returning to the user. */ - if (mp->m_flags & XFS_MOUNT_WSYNC) + if (xfs_has_wsync(mp)) xfs_trans_set_sync(args->trans); if (!(args->op_flags & XFS_DA_OP_NOTIME)) diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 3fff838e..308fc0f7 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -565,7 +565,7 @@ xfs_attr_shortform_bytesfit( * literal area, but for the old format we are done if there is no * space in the fixed attribute fork. */ - if (!(mp->m_flags & XFS_MOUNT_ATTR2)) + if (!xfs_has_attr2(mp)) return 0; dsize = dp->i_df.if_bytes; @@ -618,21 +618,27 @@ xfs_attr_shortform_bytesfit( } /* - * Switch on the ATTR2 superblock bit (implies also FEATURES2) + * Switch on the ATTR2 superblock bit (implies also FEATURES2) unless: + * - noattr2 mount option is set, + * - on-disk version bit says it is already set, or + * - the attr2 mount option is not set to enable automatic upgrade from attr1. */ STATIC void -xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) +xfs_sbversion_add_attr2( + struct xfs_mount *mp, + struct xfs_trans *tp) { - if ((mp->m_flags & XFS_MOUNT_ATTR2) && - !(xfs_has_attr2(mp))) { - spin_lock(&mp->m_sb_lock); - if (!xfs_has_attr2(mp)) { - xfs_add_attr2(mp); - spin_unlock(&mp->m_sb_lock); - xfs_log_sb(tp); - } else - spin_unlock(&mp->m_sb_lock); - } + if (xfs_has_noattr2(mp)) + return; + if (mp->m_sb.sb_features2 & XFS_SB_VERSION2_ATTR2BIT) + return; + if (!xfs_has_attr2(mp)) + return; + + spin_lock(&mp->m_sb_lock); + xfs_add_attr2(mp); + spin_unlock(&mp->m_sb_lock); + xfs_log_sb(tp); } /* @@ -807,8 +813,7 @@ xfs_attr_sf_removename( * Fix up the start offset of the attribute fork */ totsize -= size; - if (totsize == sizeof(xfs_attr_sf_hdr_t) && - (mp->m_flags & XFS_MOUNT_ATTR2) && + if (totsize == sizeof(xfs_attr_sf_hdr_t) && xfs_has_attr2(mp) && (dp->i_df.if_format != XFS_DINODE_FMT_BTREE) && !(args->op_flags & XFS_DA_OP_ADDNAME)) { xfs_attr_fork_remove(dp, args->trans); @@ -818,7 +823,7 @@ xfs_attr_sf_removename( ASSERT(dp->i_forkoff); ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || (args->op_flags & XFS_DA_OP_ADDNAME) || - !(mp->m_flags & XFS_MOUNT_ATTR2) || + !xfs_has_attr2(mp) || dp->i_df.if_format == XFS_DINODE_FMT_BTREE); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); @@ -994,7 +999,7 @@ xfs_attr_shortform_allfit( bytes += xfs_attr_sf_entsize_byname(name_loc->namelen, be16_to_cpu(name_loc->valuelen)); } - if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && + if (xfs_has_attr2(dp->i_mount) && (dp->i_df.if_format != XFS_DINODE_FMT_BTREE) && (bytes == sizeof(struct xfs_attr_sf_hdr))) return -1; @@ -1119,7 +1124,7 @@ xfs_attr3_leaf_to_shortform( goto out; if (forkoff == -1) { - ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2); + ASSERT(xfs_has_attr2(dp->i_mount)); ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE); xfs_attr_fork_remove(dp, args->trans); goto out; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index db9e8566..bea9340a 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1040,7 +1040,7 @@ xfs_bmap_set_attrforkoff( ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size); if (!ip->i_forkoff) ip->i_forkoff = default_size; - else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version) + else if (xfs_has_attr2(ip->i_mount) && version) *version = 2; break; default: @@ -3415,7 +3415,7 @@ xfs_bmap_compute_alignments( int stripe_align = 0; /* stripe alignment for allocation is determined by mount parameters */ - if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC)) + if (mp->m_swidth && xfs_has_swalloc(mp)) stripe_align = mp->m_swidth; else if (mp->m_dalign) stripe_align = mp->m_dalign; diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 567f9996..4075ff5a 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -707,7 +707,7 @@ xfs_ialloc_ag_alloc( */ isaligned = 0; if (igeo->ialloc_align) { - ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN)); + ASSERT(!xfs_has_noalign(args.mp)); args.alignment = args.mp->m_dalign; isaligned = 1; } else @@ -1948,8 +1948,7 @@ xfs_difree_inobt( * remove the chunk if the block size is large enough for multiple inode * chunks (that might not be free). */ - if (!(mp->m_flags & XFS_MOUNT_IKEEP) && - rec.ir_free == XFS_INOBT_ALL_FREE && + if (!xfs_has_ikeep(mp) && rec.ir_free == XFS_INOBT_ALL_FREE && mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) { struct xfs_perag *pag = agbp->b_pag; @@ -2093,9 +2092,8 @@ xfs_difree_finobt( * enough for multiple chunks. Leave the finobt record to remain in sync * with the inobt. */ - if (rec.ir_free == XFS_INOBT_ALL_FREE && - mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK && - !(mp->m_flags & XFS_MOUNT_IKEEP)) { + if (!xfs_has_ikeep(mp) && rec.ir_free == XFS_INOBT_ALL_FREE && + mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) { error = xfs_btree_delete(cur, &i); if (error) goto error; From patchwork Tue Sep 14 02:42:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89F5BC433F5 for ; Tue, 14 Sep 2021 02:42:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72761606A5 for ; Tue, 14 Sep 2021 02:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234374AbhINCnj (ORCPT ); Mon, 13 Sep 2021 22:43:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:53646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCni (ORCPT ); Mon, 13 Sep 2021 22:43:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 512A4610D1; Tue, 14 Sep 2021 02:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587342; bh=0w9igD7+2sT+Dd33Aqwe00TVftNyIFMZBSeR+t3hogs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MNsTb89BxrNFrxGqojaPEYBrzLR7lQUiR7ND2GT9ggpotcWPgWw+vqbx4a6Eb2doQ eY9EIHA4DyReqZTaMhaEq70GtjMFzTgQPmd6ixYyk9A1cha9ywgE4WvB1+oXeIEbdU VMpF5TTxFMEurA3oTlMZWDmUG5/qsNDIGVvw2e8BZ7xSgpu3Q3f5DJtxIsoBV35C6z VkxWhf5dD3UnCMUGKROtN2T2WfCBwfDgXVoG0zK21g34xPMB8GwPphAvs7ZbSzWgys 2LSwOY8Z1s1eydNU1S2AYdC0pIg3ieQTbEMspsZ631oHUV42ZmWKan7NiSRLQVjJ2K I/nLFukzA92XQ== Subject: [PATCH 26/43] xfs: convert remaining mount flags to state flags From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:22 -0700 Message-ID: <163158734206.1604118.14166556549871621918.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 2e973b2cd4cdb993be94cca4c33f532f1ed05316 The remaining mount flags kept in m_flags are actually runtime state flags. These change dynamically, so they really should be updated atomically so we don't potentially lose an update due to racing modifications. Convert these remaining flags to be stored in m_opstate and use atomic bitops to set and clear the flags. This also adds a couple of simple wrappers for common state checks - read only and shutdown. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 38 ++++++++++++++++++++++++++++++++++++++ libxfs/init.c | 12 ++++++++---- libxfs/xfs_alloc.c | 2 +- libxfs/xfs_sb.c | 2 +- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index aed31404..0f7b9787 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -79,6 +79,7 @@ typedef struct xfs_mount { struct radix_tree_root m_perag_tree; uint m_flags; /* global mount flags */ uint64_t m_features; /* active filesystem features */ + unsigned long m_opstate; /* dynamic state flags */ bool m_finobt_nores; /* no per-AG finobt resv. */ uint m_qflags; /* quota status flags */ uint m_attroffset; /* inode attribute offset */ @@ -204,6 +205,43 @@ __XFS_UNSUPP_FEAT(wsync) __XFS_UNSUPP_FEAT(noattr2) __XFS_UNSUPP_FEAT(ikeep) __XFS_UNSUPP_FEAT(swalloc) +__XFS_UNSUPP_FEAT(readonly) + +/* + * Operational mount state flags + * + * XXX: need real atomic bit ops! + */ +#define XFS_OPSTATE_INODE32 0 /* inode32 allocator active */ + +#define __XFS_IS_OPSTATE(name, NAME) \ +static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ +{ \ + return (mp)->m_opstate & (1UL << XFS_OPSTATE_ ## NAME); \ +} \ +static inline bool xfs_clear_ ## name (struct xfs_mount *mp) \ +{ \ + bool ret = xfs_is_ ## name(mp); \ +\ + (mp)->m_opstate &= ~(1UL << XFS_OPSTATE_ ## NAME); \ + return ret; \ +} \ +static inline bool xfs_set_ ## name (struct xfs_mount *mp) \ +{ \ + bool ret = xfs_is_ ## name(mp); \ +\ + (mp)->m_opstate |= (1UL << XFS_OPSTATE_ ## NAME); \ + return ret; \ +} + +__XFS_IS_OPSTATE(inode32, INODE32) + +#define __XFS_UNSUPP_OPSTATE(name) \ +static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ +{ \ + return false; \ +} +__XFS_UNSUPP_OPSTATE(readonly) #define LIBXFS_MOUNT_DEBUGGER 0x0001 #define LIBXFS_MOUNT_32BITINODES 0x0002 diff --git a/libxfs/init.c b/libxfs/init.c index b0a6d1fc..e7009a2e 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -532,10 +532,13 @@ xfs_set_inode_alloc( * sufficiently large, set XFS_MOUNT_32BITINODES if we must alter * the allocator to accommodate the request. */ - if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32) + if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32) { + xfs_set_inode32(mp); mp->m_flags |= XFS_MOUNT_32BITINODES; - else + } else { + xfs_clear_inode32(mp); mp->m_flags &= ~XFS_MOUNT_32BITINODES; + } for (index = 0; index < agcount; index++) { struct xfs_perag *pag; @@ -544,7 +547,7 @@ xfs_set_inode_alloc( pag = xfs_perag_get(mp, index); - if (mp->m_flags & XFS_MOUNT_32BITINODES) { + if (xfs_is_inode32(mp)) { if (ino > XFS_MAXINUMBER_32) { pag->pagi_inodeok = 0; pag->pagf_metadata = 0; @@ -564,7 +567,7 @@ xfs_set_inode_alloc( xfs_perag_put(pag); } - return (mp->m_flags & XFS_MOUNT_32BITINODES) ? maxagi : agcount; + return xfs_is_inode32(mp) ? maxagi : agcount; } static struct xfs_buftarg * @@ -720,6 +723,7 @@ libxfs_mount( mp->m_finobt_nores = true; mp->m_flags = (LIBXFS_MOUNT_32BITINODES|LIBXFS_MOUNT_32BITINOOPT); + xfs_set_inode32(mp); mp->m_sb = *sb; INIT_RADIX_TREE(&mp->m_perag_tree, GFP_KERNEL); sbp = &(mp->m_sb); diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index b8725339..163c726f 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3162,7 +3162,7 @@ xfs_alloc_vextent( * the first a.g. fails. */ if ((args->datatype & XFS_ALLOC_INITIAL_USER_DATA) && - (mp->m_flags & XFS_MOUNT_32BITINODES)) { + xfs_is_inode32(mp)) { args->fsbno = XFS_AGB_TO_FSB(mp, ((mp->m_agfrotor / rotorstep) % mp->m_sb.sb_agcount), 0); diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 25a4ffdb..d2de96d1 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -120,7 +120,7 @@ xfs_validate_sb_read( "Superblock has unknown read-only compatible features (0x%x) enabled.", (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_UNKNOWN)); - if (!(mp->m_flags & XFS_MOUNT_RDONLY)) { + if (!xfs_is_readonly(mp)) { xfs_warn(mp, "Attempted to mount read-only compatible filesystem read-write."); xfs_warn(mp, From patchwork Tue Sep 14 02:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD3F0C433F5 for ; Tue, 14 Sep 2021 02:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD3B8610F9 for ; Tue, 14 Sep 2021 02:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236205AbhINCno (ORCPT ); Mon, 13 Sep 2021 22:43:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:53670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235706AbhINCno (ORCPT ); Mon, 13 Sep 2021 22:43:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3EA4610D1; Tue, 14 Sep 2021 02:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587347; bh=88kMTTtqTBBJhjS5KThb3f1QRpQlsBZCiQ74xdy3TIw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=fmWG4kZLo1UMEKl0sz7NS/fxW8S+kyv9fXQBeFFmHAHGMPC86jykjG4mQed1GiDP+ 6SkfBhy2fXOqrI+yZSZYrVGThkC/kNLGFKzJ7rckPMvBrM9JB9Pi5kPwEL+neLOAGg HkLi6oMKj+VwqTizYk3gL2rkn1X9+XZgpv82+rhx0PM0pEKU9ObfmFrEf0LxSt6ES4 CqFqbXqaQacbIwiENyvSItX9Yjte6NydCkC3AkGKtb+1O2/v3sCVINikarME7vDRCA rv3moyF/LGGcr2szYIq/cbmAVN5VBze9PqGhqHkdAhZjvbFB9uTkmk+r6Nj9jxgphz KiNlXQBGBfxqA== Subject: [PATCH 27/43] xfs: replace XFS_FORCED_SHUTDOWN with xfs_is_shutdown From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:27 -0700 Message-ID: <163158734752.1604118.2557899186280810389.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 75c8c50fa16a23f8ac89ea74834ae8ddd1558d75 Remove the shouty macro and instead use the inline function that matches other state/feature check wrapper naming. This conversion was done with sed. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 1 + libxfs/libxfs_priv.h | 1 - libxfs/xfs_alloc.c | 2 +- libxfs/xfs_attr.c | 4 ++-- libxfs/xfs_bmap.c | 16 ++++++++-------- libxfs/xfs_btree.c | 2 +- libxfs/xfs_ialloc.c | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 0f7b9787..29d0440e 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -242,6 +242,7 @@ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ return false; \ } __XFS_UNSUPP_OPSTATE(readonly) +__XFS_UNSUPP_OPSTATE(shutdown) #define LIBXFS_MOUNT_DEBUGGER 0x0001 #define LIBXFS_MOUNT_32BITINODES 0x0002 diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 07fc2942..3e5ff2a8 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -161,7 +161,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; (unlikely(expr) ? XFS_WARN_CORRUPT((mp), (expr)) : false) #define XFS_ERRLEVEL_LOW 1 -#define XFS_FORCED_SHUTDOWN(mp) 0 #define XFS_ILOCK_EXCL 0 #define XFS_STATS_INC(mp, count) do { (mp) = (mp); } while (0) #define XFS_STATS_DEC(mp, count, x) do { (mp) = (mp); } while (0) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 163c726f..c6159743 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3075,7 +3075,7 @@ xfs_alloc_read_agf( atomic64_add(allocbt_blks, &mp->m_allocbt_blks); } #ifdef DEBUG - else if (!XFS_FORCED_SHUTDOWN(mp)) { + else if (!xfs_is_shutdown(mp)) { ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks)); ASSERT(pag->pagf_btreeblks == be32_to_cpu(agf->agf_btreeblks)); ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount)); diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3a712e36..00f3ecb5 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -146,7 +146,7 @@ xfs_attr_get( XFS_STATS_INC(args->dp->i_mount, xs_attr_get); - if (XFS_FORCED_SHUTDOWN(args->dp->i_mount)) + if (xfs_is_shutdown(args->dp->i_mount)) return -EIO; args->geo = args->dp->i_mount->m_attr_geo; @@ -710,7 +710,7 @@ xfs_attr_set( int rmt_blks = 0; unsigned int total; - if (XFS_FORCED_SHUTDOWN(dp->i_mount)) + if (xfs_is_shutdown(dp->i_mount)) return -EIO; error = xfs_qm_dqattach(dp); diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index bea9340a..1735717c 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -3931,7 +3931,7 @@ xfs_bmapi_read( XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) return -EFSCORRUPTED; - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; XFS_STATS_INC(mp, xs_blk_mapr); @@ -4413,7 +4413,7 @@ xfs_bmapi_write( return -EFSCORRUPTED; } - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; XFS_STATS_INC(mp, xs_blk_mapw); @@ -4696,7 +4696,7 @@ xfs_bmapi_remap( return -EFSCORRUPTED; } - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; error = xfs_iread_extents(tp, ip, whichfork); @@ -5354,7 +5354,7 @@ __xfs_bunmapi( ifp = XFS_IFORK_PTR(ip, whichfork); if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp))) return -EFSCORRUPTED; - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); @@ -5845,7 +5845,7 @@ xfs_bmap_collapse_extents( return -EFSCORRUPTED; } - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); @@ -5923,7 +5923,7 @@ xfs_bmap_can_insert_extents( ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); - if (XFS_FORCED_SHUTDOWN(ip->i_mount)) + if (xfs_is_shutdown(ip->i_mount)) return -EIO; xfs_ilock(ip, XFS_ILOCK_EXCL); @@ -5960,7 +5960,7 @@ xfs_bmap_insert_extents( return -EFSCORRUPTED; } - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); @@ -6063,7 +6063,7 @@ xfs_bmap_split_extent( return -EFSCORRUPTED; } - if (XFS_FORCED_SHUTDOWN(mp)) + if (xfs_is_shutdown(mp)) return -EIO; /* Read in all the extents */ diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 79be19ec..da3895a6 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -371,7 +371,7 @@ xfs_btree_del_cursor( } ASSERT(cur->bc_btnum != XFS_BTNUM_BMAP || cur->bc_ino.allocated == 0 || - XFS_FORCED_SHUTDOWN(cur->bc_mp)); + xfs_is_shutdown(cur->bc_mp)); if (unlikely(cur->bc_flags & XFS_BTREE_STAGING)) kmem_free(cur->bc_ops); if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS) && cur->bc_ag.pag) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 4075ff5a..7ba6b5e9 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -236,7 +236,7 @@ xfs_check_agi_freecount( } } while (i == 1); - if (!XFS_FORCED_SHUTDOWN(cur->bc_mp)) + if (!xfs_is_shutdown(cur->bc_mp)) ASSERT(freecount == cur->bc_ag.pag->pagi_freecount); } return 0; @@ -1779,7 +1779,7 @@ xfs_dialloc( break; } - if (XFS_FORCED_SHUTDOWN(mp)) { + if (xfs_is_shutdown(mp)) { error = -EFSCORRUPTED; break; } @@ -2619,7 +2619,7 @@ xfs_ialloc_read_agi( * we are in the middle of a forced shutdown. */ ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) || - XFS_FORCED_SHUTDOWN(mp)); + xfs_is_shutdown(mp)); return 0; } From patchwork Tue Sep 14 02:42:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2870C433F5 for ; Tue, 14 Sep 2021 02:42:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83AD5610D1 for ; Tue, 14 Sep 2021 02:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbhINCnz (ORCPT ); Mon, 13 Sep 2021 22:43:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:53690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237763AbhINCnu (ORCPT ); Mon, 13 Sep 2021 22:43:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47D24606A5; Tue, 14 Sep 2021 02:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587353; bh=hPKIA8sy5+U7xHk6OK388JWVpWLk2Lv+JPcnMNNBOXw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=A3n+m+4+zRtsZryl401voCPWp9rhSx7/o6THkjQVwfGotJ5lIaX5QLP+jNikY1Vf/ lvO1N6HTAcjxI3zjvvkhKSrk/uvYFGdZ6w2QM1kKBVqDwszQ0cGr4iKopc5qv0UxNh 1YB53G/gZ4tHQLYhyly1hQhZlrFoaotYLrKOtzNORIIwRD2aDnzZFBWfK/u7nK9ZNn EATun4/gTcIJUg+YfDEYIS1qzXHvRWhzhgn0fZN3E/kqxV8h7jxnG80ugMeyEFYFuq GXy6qefJtynpFLqAQkt2HNVKeg85I8IpMHswRlIuQoyM4HWxp93jJj8hfj+GG7lagS nmbhD7kYVnxvQ== Subject: [PATCH 28/43] xfs: convert xfs_fs_geometry to use mount feature checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:33 -0700 Message-ID: <163158735300.1604118.1392708746486476878.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 03288b19093b9bcff72f0d5f90c578daf053f759 Reporting filesystem features to userspace is currently superblock based. Now we have a general mount-based feature infrastructure, switch to using the xfs_mount rather than the superblock directly. This reduces the size of the function by over 300 bytes. $ size -t fs/xfs/built-in.a text data bss dec hex filename before 1127855 311352 484 1439691 15f7cb (TOTALS) after 1127535 311352 484 1439371 15f68b (TOTALS) Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- db/info.c | 2 +- libxfs/xfs_sb.c | 46 ++++++++++++++++++++++++---------------------- libxfs/xfs_sb.h | 2 +- mkfs/xfs_mkfs.c | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/db/info.c b/db/info.c index fdee76ba..b69bae91 100644 --- a/db/info.c +++ b/db/info.c @@ -29,7 +29,7 @@ info_f( { struct xfs_fsop_geom geo; - libxfs_fs_geometry(&mp->m_sb, &geo, XFS_FS_GEOM_MAX_STRUCT_VER); + libxfs_fs_geometry(mp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER); xfs_report_geom(&geo, fsdevice, x.logname, x.rtname); return 0; } diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index d2de96d1..bc226208 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1014,10 +1014,12 @@ xfs_sync_sb_buf( void xfs_fs_geometry( - struct xfs_sb *sbp, + struct xfs_mount *mp, struct xfs_fsop_geom *geo, int struct_version) { + struct xfs_sb *sbp = &mp->m_sb; + memset(geo, 0, sizeof(struct xfs_fsop_geom)); geo->blocksize = sbp->sb_blocksize; @@ -1048,51 +1050,51 @@ xfs_fs_geometry( geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK | XFS_FSOP_GEOM_FLAGS_DIRV2 | XFS_FSOP_GEOM_FLAGS_EXTFLG; - if (xfs_sb_version_hasattr(sbp)) + if (xfs_has_attr(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_ATTR; - if (xfs_sb_version_hasquota(sbp)) + if (xfs_has_quota(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_QUOTA; - if (xfs_sb_version_hasalign(sbp)) + if (xfs_has_align(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_IALIGN; - if (xfs_sb_version_hasdalign(sbp)) + if (xfs_has_dalign(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_DALIGN; - if (xfs_sb_version_hassector(sbp)) - geo->flags |= XFS_FSOP_GEOM_FLAGS_SECTOR; - if (xfs_sb_version_hasasciici(sbp)) + if (xfs_has_asciici(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_DIRV2CI; - if (xfs_sb_version_haslazysbcount(sbp)) + if (xfs_has_lazysbcount(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_LAZYSB; - if (xfs_sb_version_hasattr2(sbp)) + if (xfs_has_attr2(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_ATTR2; - if (xfs_sb_version_hasprojid32(sbp)) + if (xfs_has_projid32(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_PROJID32; - if (xfs_sb_version_hascrc(sbp)) + if (xfs_has_crc(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_V5SB; - if (xfs_sb_version_hasftype(sbp)) + if (xfs_has_ftype(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_FTYPE; - if (xfs_sb_version_hasfinobt(sbp)) + if (xfs_has_finobt(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_FINOBT; - if (xfs_sb_version_hassparseinodes(sbp)) + if (xfs_has_sparseinodes(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_SPINODES; - if (xfs_sb_version_hasrmapbt(sbp)) + if (xfs_has_rmapbt(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_RMAPBT; - if (xfs_sb_version_hasreflink(sbp)) + if (xfs_has_reflink(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_REFLINK; - if (xfs_sb_version_hasbigtime(sbp)) + if (xfs_has_bigtime(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME; - if (xfs_sb_version_hasinobtcounts(sbp)) + if (xfs_has_inobtcounts(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_INOBTCNT; - if (xfs_sb_version_hassector(sbp)) + if (xfs_has_sector(mp)) { + geo->flags |= XFS_FSOP_GEOM_FLAGS_SECTOR; geo->logsectsize = sbp->sb_logsectsize; - else + } else { geo->logsectsize = BBSIZE; + } geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp); if (struct_version < 4) return; - if (xfs_sb_version_haslogv2(sbp)) + if (xfs_has_logv2(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_LOGV2; geo->logsunit = sbp->sb_logsunit; diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index d2dd99cb..8902f4bf 100644 --- a/libxfs/xfs_sb.h +++ b/libxfs/xfs_sb.h @@ -25,7 +25,7 @@ extern uint64_t xfs_sb_version_to_features(struct xfs_sb *sbp); extern int xfs_update_secondary_sbs(struct xfs_mount *mp); #define XFS_FS_GEOM_MAX_STRUCT_VER (4) -extern void xfs_fs_geometry(struct xfs_sb *sbp, struct xfs_fsop_geom *geo, +extern void xfs_fs_geometry(struct xfs_mount *mp, struct xfs_fsop_geom *geo, int struct_version); extern int xfs_sb_read_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 2340b7b1..63895f28 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -4038,7 +4038,7 @@ main( if (!quiet || dry_run) { struct xfs_fsop_geom geo; - libxfs_fs_geometry(sbp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER); + libxfs_fs_geometry(mp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER); xfs_report_geom(&geo, dfile, logfile, rtfile); if (dry_run) exit(0); From patchwork Tue Sep 14 02:42:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39C18C433EF for ; Tue, 14 Sep 2021 02:42:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 153F9610F9 for ; Tue, 14 Sep 2021 02:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhINCn5 (ORCPT ); Mon, 13 Sep 2021 22:43:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:53720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCnz (ORCPT ); Mon, 13 Sep 2021 22:43:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B78A5610D1; Tue, 14 Sep 2021 02:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587358; bh=ysWrmbWcxATbiKvepyvPcwErQtpowjHqCUUrKB+cbps=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Y77y0dlH1KWpBUHBOBRIoF3uYRqYQUeou0fpts3Cx9jObfpQILP/bP0ybJ1br1ZEH SQk2H5b2WFGuwLdEd3DDW9yG0dqDBJfCJgIR/m8Uyt5zoP6b/82M9OAYA9hlwiAgnn mh6M0ZAUpXBLZ/V1DwObG+YBQFXCcChauVgUffqe5NFgBgrQNvevopJZ+TEI113Pj9 OkOshB07/6fqH8byhDFl63LwqCcQYUfDiIdI/W+35qyvoPhAHktF2N2uALFkUctMyl FdqQxv0BMLLKyEGETI06jCUw3ae6W7NmCzyzNeDNwX1tNNmRPxiN4ah90kasB+h415 MVxPSvw2C8kUQ== Subject: [PATCH 29/43] xfs: open code sb verifier feature checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:38 -0700 Message-ID: <163158735848.1604118.17869848073585469108.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: fe08cc5044486096bfb5ce9d3db4e915e53281ea The superblock verifiers are one of the last places that use the sb version functions to do feature checks. This are all quite simple uses, and there aren't many of them so open code them all. Also, move the good version number check into xfs_sb.c instead of it being an inline function in xfs_format.h Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_format.h | 29 ------------- libxfs/xfs_sb.c | 116 +++++++++++++++++++++++++++++++++++---------------- libxfs/xfs_sb.h | 1 3 files changed, 81 insertions(+), 65 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index d4690f28..242bf251 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -265,7 +265,6 @@ typedef struct xfs_dsb { /* must be padded to 64 bit alignment */ } xfs_dsb_t; - /* * Misc. Flags - warning - these will be cleared by xfs_repair unless * a feature bit is set when the flag is used. @@ -280,34 +279,6 @@ typedef struct xfs_dsb { #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) -/* - * The first XFS version we support is a v4 superblock with V2 directories. - */ -static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp) -{ - if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) - return false; - if (!(sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)) - return false; - - /* check for unknown features in the fs */ - if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || - ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && - (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) - return false; - - return true; -} - -static inline bool xfs_sb_good_version(struct xfs_sb *sbp) -{ - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) - return true; - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) - return xfs_sb_good_v4_features(sbp); - return false; -} - static inline bool xfs_sb_version_hasrealtime(struct xfs_sb *sbp) { return sbp->sb_rblocks > 0; diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index bc226208..a2ad1516 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -28,6 +28,37 @@ * Physical superblock buffer manipulations. Shared with libxfs in userspace. */ +/* + * We support all XFS versions newer than a v4 superblock with V2 directories. + */ +bool +xfs_sb_good_version( + struct xfs_sb *sbp) +{ + /* all v5 filesystems are supported */ + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) + return true; + + /* versions prior to v4 are not supported */ + if (XFS_SB_VERSION_NUM(sbp) < XFS_SB_VERSION_4) + return false; + + /* V4 filesystems need v2 directories and unwritten extents */ + if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) + return false; + if (!(sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)) + return false; + + /* And must not have any unknown v4 feature bits set */ + if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || + ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && + (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) + return false; + + /* It's a supported v4 filesystem */ + return true; +} + uint64_t xfs_sb_version_to_features( struct xfs_sb *sbp) @@ -226,6 +257,7 @@ xfs_validate_sb_common( struct xfs_dsb *dsb = bp->b_addr; uint32_t agcount = 0; uint32_t rem; + bool has_dalign; if (!xfs_verify_magic(bp, dsb->sb_magicnum)) { xfs_warn(mp, "bad magic number"); @@ -237,12 +269,41 @@ xfs_validate_sb_common( return -EWRONGFS; } - if (xfs_sb_version_haspquotino(sbp)) { + /* + * Validate feature flags and state + */ + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) { + if (sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) { + xfs_notice(mp, +"Block size (%u bytes) too small for Version 5 superblock (minimum %d bytes)", + sbp->sb_blocksize, XFS_MIN_CRC_BLOCKSIZE); + return -EFSCORRUPTED; + } + + /* V5 has a separate project quota inode */ if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) { xfs_notice(mp, "Version 5 of Super block has XFS_OQUOTA bits."); return -EFSCORRUPTED; } + + /* + * Full inode chunks must be aligned to inode chunk size when + * sparse inodes are enabled to support the sparse chunk + * allocation algorithm and prevent overlapping inode records. + */ + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) { + uint32_t align; + + align = XFS_INODES_PER_CHUNK * sbp->sb_inodesize + >> sbp->sb_blocklog; + if (sbp->sb_inoalignmt != align) { + xfs_warn(mp, +"Inode block alignment (%u) must match chunk size (%u) for sparse inodes.", + sbp->sb_inoalignmt, align); + return -EINVAL; + } + } } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { xfs_notice(mp, @@ -250,24 +311,6 @@ xfs_validate_sb_common( return -EFSCORRUPTED; } - /* - * Full inode chunks must be aligned to inode chunk size when - * sparse inodes are enabled to support the sparse chunk - * allocation algorithm and prevent overlapping inode records. - */ - if (xfs_sb_version_hassparseinodes(sbp)) { - uint32_t align; - - align = XFS_INODES_PER_CHUNK * sbp->sb_inodesize - >> sbp->sb_blocklog; - if (sbp->sb_inoalignmt != align) { - xfs_warn(mp, -"Inode block alignment (%u) must match chunk size (%u) for sparse inodes.", - sbp->sb_inoalignmt, align); - return -EINVAL; - } - } - if (unlikely( sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) { xfs_warn(mp, @@ -367,7 +410,8 @@ xfs_validate_sb_common( * Either (sb_unit and !hasdalign) or (!sb_unit and hasdalign) * would imply the image is corrupted. */ - if (!!sbp->sb_unit ^ xfs_sb_version_hasdalign(sbp)) { + has_dalign = sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT; + if (!!sbp->sb_unit ^ has_dalign) { xfs_notice(mp, "SB stripe alignment sanity check failed"); return -EFSCORRUPTED; } @@ -376,12 +420,6 @@ xfs_validate_sb_common( XFS_FSB_TO_B(mp, sbp->sb_width), 0, false)) return -EFSCORRUPTED; - if (xfs_sb_version_hascrc(sbp) && - sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) { - xfs_notice(mp, "v5 SB sanity check failed"); - return -EFSCORRUPTED; - } - /* * Currently only very few inode sizes are supported. */ @@ -425,7 +463,7 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) * We need to do these manipilations only if we are working * with an older version of on-disk superblock. */ - if (xfs_sb_version_haspquotino(sbp)) + if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_5) return; if (sbp->sb_qflags & XFS_OQUOTA_ENFD) @@ -518,7 +556,8 @@ __xfs_sb_from_disk( * sb_meta_uuid is only on disk if it differs from sb_uuid and the * feature flag is set; if not set we keep it only in memory. */ - if (xfs_sb_version_hasmetauuid(to)) + if (XFS_SB_VERSION_NUM(to) == XFS_SB_VERSION_5 && + (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID)) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); else uuid_copy(&to->sb_meta_uuid, &from->sb_uuid); @@ -543,7 +582,12 @@ xfs_sb_quota_to_disk( uint16_t qflags = from->sb_qflags; to->sb_uquotino = cpu_to_be64(from->sb_uquotino); - if (xfs_sb_version_haspquotino(from)) { + + /* + * The in-memory superblock quota state matches the v5 on-disk format so + * just write them out and return + */ + if (XFS_SB_VERSION_NUM(from) == XFS_SB_VERSION_5) { to->sb_qflags = cpu_to_be16(from->sb_qflags); to->sb_gquotino = cpu_to_be64(from->sb_gquotino); to->sb_pquotino = cpu_to_be64(from->sb_pquotino); @@ -551,9 +595,9 @@ xfs_sb_quota_to_disk( } /* - * The in-core version of sb_qflags do not have XFS_OQUOTA_* - * flags, whereas the on-disk version does. So, convert incore - * XFS_{PG}QUOTA_* flags to on-disk XFS_OQUOTA_* flags. + * For older superblocks (v4), the in-core version of sb_qflags do not + * have XFS_OQUOTA_* flags, whereas the on-disk version does. So, + * convert incore XFS_{PG}QUOTA_* flags to on-disk XFS_OQUOTA_* flags. */ qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); @@ -653,7 +697,7 @@ xfs_sb_to_disk( to->sb_features2 = cpu_to_be32(from->sb_features2); to->sb_bad_features2 = cpu_to_be32(from->sb_bad_features2); - if (xfs_sb_version_hascrc(from)) { + if (XFS_SB_VERSION_NUM(from) == XFS_SB_VERSION_5) { to->sb_features_compat = cpu_to_be32(from->sb_features_compat); to->sb_features_ro_compat = cpu_to_be32(from->sb_features_ro_compat); @@ -663,7 +707,7 @@ xfs_sb_to_disk( cpu_to_be32(from->sb_features_log_incompat); to->sb_spino_align = cpu_to_be32(from->sb_spino_align); to->sb_lsn = cpu_to_be64(from->sb_lsn); - if (xfs_sb_version_hasmetauuid(from)) + if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); } } @@ -701,7 +745,7 @@ xfs_sb_read_verify( if (!xfs_buf_verify_cksum(bp, XFS_SB_CRC_OFF)) { /* Only fail bad secondaries on a known V5 filesystem */ if (bp->b_maps[0].bm_bn == XFS_SB_DADDR || - xfs_sb_version_hascrc(&mp->m_sb)) { + xfs_has_crc(mp)) { error = -EFSBADCRC; goto out_error; } @@ -768,7 +812,7 @@ xfs_sb_write_verify( if (error) goto out_error; - if (!xfs_sb_version_hascrc(&sb)) + if (XFS_SB_VERSION_NUM(&sb) != XFS_SB_VERSION_5) return; if (bip) diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index 8902f4bf..a5e14740 100644 --- a/libxfs/xfs_sb.h +++ b/libxfs/xfs_sb.h @@ -20,6 +20,7 @@ extern void xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp); extern void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from); extern void xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from); extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); +extern bool xfs_sb_good_version(struct xfs_sb *sbp); extern uint64_t xfs_sb_version_to_features(struct xfs_sb *sbp); extern int xfs_update_secondary_sbs(struct xfs_mount *mp); From patchwork Tue Sep 14 02:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D083C433F5 for ; Tue, 14 Sep 2021 02:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EC22610D1 for ; Tue, 14 Sep 2021 02:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237553AbhINCoB (ORCPT ); Mon, 13 Sep 2021 22:44:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCoA (ORCPT ); Mon, 13 Sep 2021 22:44:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3AAA061108; Tue, 14 Sep 2021 02:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587364; bh=5LHpClksbfndnh/XAoE8eWTDYdAPuhyfWp2U6e/6FzA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=gFQhttPcM3nR77uWk1uNV1b4NMV7JBqrlwUVkxhFEyIWGwRjk0NkFPT8sMLwxcXB8 40dyBELIEF9HIWjolox+OyBDwK8nN0A8oLSut0C9OiFx9VeYJEsOpBmUdPpbDDhs0s SBNr/U/nPnuFJQ1PO/xlR3EhbMORkbVsdKQPeGvpRAaBB6n7il6ltmmONBOczkWeUZ u41TKtICvN2wtKt+wdHUlTysoCKjEgMuWPqQu0tFaa7Bkb1uHNhADEVuS5JJFO6GlC 8aqGzPL8uEiYVVvJvEfrcvqhBdvSvsIqns1paGGwvQpwapOBTbrw4PmVAmfRiivCB1 05LXrJr8SvgHA== Subject: [PATCH 30/43] xfs: convert xfs_sb_version_has checks to use mount features From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:44 -0700 Message-ID: <163158736395.1604118.8064478644901107846.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: ebd9027d088b3a4e49d294f79e6cadb7b7a88b28 This is a conversion of the remaining xfs_sb_version_has..(sbp) checks to use xfs_has_..(mp) feature checks. This was largely done with a vim replacement macro that did: :0,$s/xfs_sb_version_has\(.*\)&\(.*\)->m_sb/xfs_has_\1\2/g A couple of other variants were also used, and the rest touched up by hand. $ size -t fs/xfs/built-in.a text data bss dec hex filename before 1127533 311352 484 1439369 15f689 (TOTALS) after 1125360 311352 484 1437196 15ee0c (TOTALS) Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_ag.c | 4 ++-- libxfs/xfs_alloc.c | 12 ++++++------ libxfs/xfs_alloc.h | 2 +- libxfs/xfs_alloc_btree.c | 2 +- libxfs/xfs_bmap_btree.c | 2 +- libxfs/xfs_btree.c | 6 +++--- libxfs/xfs_da_btree.c | 6 +++--- libxfs/xfs_dir2.c | 6 +++--- libxfs/xfs_dir2_block.c | 4 ++-- libxfs/xfs_dir2_data.c | 10 +++++----- libxfs/xfs_dir2_leaf.c | 4 ++-- libxfs/xfs_dir2_node.c | 4 ++-- libxfs/xfs_dir2_priv.h | 2 +- libxfs/xfs_dir2_sf.c | 10 +++++----- libxfs/xfs_dquot_buf.c | 2 +- libxfs/xfs_ialloc.c | 30 +++++++++++++++--------------- libxfs/xfs_ialloc_btree.c | 10 +++++----- libxfs/xfs_inode_buf.c | 10 +++++----- libxfs/xfs_log_format.h | 2 +- libxfs/xfs_refcount.c | 8 ++++---- libxfs/xfs_sb.c | 2 +- libxfs/xfs_trans_inode.c | 2 +- libxfs/xfs_trans_resv.c | 6 +++--- libxfs/xfs_trans_space.h | 6 ++---- 24 files changed, 75 insertions(+), 77 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 8051759a..2ae81fac 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -605,9 +605,9 @@ xfs_agiblock_init( } for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) { + if (xfs_has_inobtcounts(mp)) { agi->agi_iblocks = cpu_to_be32(1); - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) agi->agi_fblocks = cpu_to_be32(1); } } diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index c6159743..c60aeb63 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -2260,7 +2260,7 @@ xfs_alloc_min_freelist( min_free += min_t(unsigned int, levels[XFS_BTNUM_CNTi] + 1, mp->m_ag_maxlevels); /* space needed reverse mapping used space btree */ - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) min_free += min_t(unsigned int, levels[XFS_BTNUM_RMAPi] + 1, mp->m_rmap_maxlevels); @@ -2908,7 +2908,7 @@ xfs_agf_verify( be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > mp->m_rmap_maxlevels)) return __this_address; - if (xfs_sb_version_hasrmapbt(&mp->m_sb) && + if (xfs_has_rmapbt(mp) && be32_to_cpu(agf->agf_rmap_blocks) > be32_to_cpu(agf->agf_length)) return __this_address; @@ -2921,16 +2921,16 @@ xfs_agf_verify( if (bp->b_pag && be32_to_cpu(agf->agf_seqno) != bp->b_pag->pag_agno) return __this_address; - if (xfs_sb_version_haslazysbcount(&mp->m_sb) && + if (xfs_has_lazysbcount(mp) && be32_to_cpu(agf->agf_btreeblks) > be32_to_cpu(agf->agf_length)) return __this_address; - if (xfs_sb_version_hasreflink(&mp->m_sb) && + if (xfs_has_reflink(mp) && be32_to_cpu(agf->agf_refcount_blocks) > be32_to_cpu(agf->agf_length)) return __this_address; - if (xfs_sb_version_hasreflink(&mp->m_sb) && + if (xfs_has_reflink(mp) && (be32_to_cpu(agf->agf_refcount_level) < 1 || be32_to_cpu(agf->agf_refcount_level) > mp->m_refc_maxlevels)) return __this_address; @@ -3069,7 +3069,7 @@ xfs_alloc_read_agf( * counter only tracks non-root blocks. */ allocbt_blks = pag->pagf_btreeblks; - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) allocbt_blks -= be32_to_cpu(agf->agf_rmap_blocks) - 1; if (allocbt_blks > 0) atomic64_add(allocbt_blks, &mp->m_allocbt_blks); diff --git a/libxfs/xfs_alloc.h b/libxfs/xfs_alloc.h index e14c5693..df4aefaf 100644 --- a/libxfs/xfs_alloc.h +++ b/libxfs/xfs_alloc.h @@ -243,7 +243,7 @@ static inline __be32 * xfs_buf_to_agfl_bno( struct xfs_buf *bp) { - if (xfs_sb_version_hascrc(&bp->b_mount->m_sb)) + if (xfs_has_crc(bp->b_mount)) return bp->b_addr + sizeof(struct xfs_agfl); return bp->b_addr; } diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index a8a24fa4..94f2d7b6 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -293,7 +293,7 @@ xfs_allocbt_verify( if (!xfs_verify_magic(bp, block->bb_magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { fa = xfs_btree_sblock_v5hdr_verify(bp); if (fa) return fa; diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index f5f228bc..237af83e 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -426,7 +426,7 @@ xfs_bmbt_verify( if (!xfs_verify_magic(bp, block->bb_magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { /* * XXX: need a better way of verifying the owner here. Right now * just make sure there has been one set. diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index da3895a6..a763ef10 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -270,7 +270,7 @@ xfs_btree_lblock_calc_crc( struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_buf_log_item *bip = bp->b_log_item; - if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb)) + if (!xfs_has_crc(bp->b_mount)) return; if (bip) block->bb_u.l.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); @@ -308,7 +308,7 @@ xfs_btree_sblock_calc_crc( struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_buf_log_item *bip = bp->b_log_item; - if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb)) + if (!xfs_has_crc(bp->b_mount)) return; if (bip) block->bb_u.s.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); @@ -1746,7 +1746,7 @@ xfs_btree_lookup_get_block( return error; /* Check the inode owner since the verifiers don't. */ - if (xfs_sb_version_hascrc(&cur->bc_mp->m_sb) && + if (xfs_has_crc(cur->bc_mp) && !(cur->bc_ino.flags & XFS_BTCUR_BMBT_INVALID_OWNER) && (cur->bc_flags & XFS_BTREE_LONG_PTRS) && be64_to_cpu((*blkp)->bb_u.l.bb_owner) != diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index 196f0a9e..d2dec4aa 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -126,7 +126,7 @@ xfs_da3_node_hdr_from_disk( struct xfs_da3_icnode_hdr *to, struct xfs_da_intnode *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_da3_intnode *from3 = (struct xfs_da3_intnode *)from; to->forw = be32_to_cpu(from3->hdr.info.hdr.forw); @@ -153,7 +153,7 @@ xfs_da3_node_hdr_to_disk( struct xfs_da_intnode *to, struct xfs_da3_icnode_hdr *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_da3_intnode *to3 = (struct xfs_da3_intnode *)to; ASSERT(from->magic == XFS_DA3_NODE_MAGIC); @@ -188,7 +188,7 @@ xfs_da3_blkinfo_verify( if (!xfs_verify_magic16(bp, hdr->magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (be64_to_cpu(hdr3->blkno) != bp->b_bn) diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c index dff87439..f0721304 100644 --- a/libxfs/xfs_dir2.c +++ b/libxfs/xfs_dir2.c @@ -114,7 +114,7 @@ xfs_da_mount( dageo->fsblog = mp->m_sb.sb_blocklog; dageo->blksize = xfs_dir2_dirblock_bytes(&mp->m_sb); dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { dageo->node_hdr_size = sizeof(struct xfs_da3_node_hdr); dageo->leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr); dageo->free_hdr_size = sizeof(struct xfs_dir3_free_hdr); @@ -729,7 +729,7 @@ xfs_dir2_hashname( struct xfs_mount *mp, struct xfs_name *name) { - if (unlikely(xfs_sb_version_hasasciici(&mp->m_sb))) + if (unlikely(xfs_has_asciici(mp))) return xfs_ascii_ci_hashname(name); return xfs_da_hashname(name->name, name->len); } @@ -740,7 +740,7 @@ xfs_dir2_compname( const unsigned char *name, int len) { - if (unlikely(xfs_sb_version_hasasciici(&args->dp->i_mount->m_sb))) + if (unlikely(xfs_has_asciici(args->dp->i_mount))) return xfs_ascii_ci_compname(args, name, len); return xfs_da_compname(args, name, len); } diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index 4373e819..f5d0f703 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -50,7 +50,7 @@ xfs_dir3_block_verify( if (!xfs_verify_magic(bp, hdr3->magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (be64_to_cpu(hdr3->blkno) != bp->b_bn) @@ -118,7 +118,7 @@ xfs_dir3_block_header_check( { struct xfs_mount *mp = dp->i_mount; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; if (be64_to_cpu(hdr3->owner) != dp->i_ino) diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c index 76f55736..85cb14d3 100644 --- a/libxfs/xfs_dir2_data.c +++ b/libxfs/xfs_dir2_data.c @@ -26,7 +26,7 @@ xfs_dir2_data_bestfree_p( struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr) { - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) return ((struct xfs_dir3_data_hdr *)hdr)->best_free; return hdr->bestfree; } @@ -48,7 +48,7 @@ xfs_dir2_data_get_ftype( struct xfs_mount *mp, struct xfs_dir2_data_entry *dep) { - if (xfs_sb_version_hasftype(&mp->m_sb)) { + if (xfs_has_ftype(mp)) { uint8_t ftype = dep->name[dep->namelen]; if (likely(ftype < XFS_DIR3_FT_MAX)) @@ -67,7 +67,7 @@ xfs_dir2_data_put_ftype( ASSERT(ftype < XFS_DIR3_FT_MAX); ASSERT(dep->namelen != 0); - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) dep->name[dep->namelen] = ftype; } @@ -294,7 +294,7 @@ xfs_dir3_data_verify( if (!xfs_verify_magic(bp, hdr3->magic)) return __this_address; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (be64_to_cpu(hdr3->blkno) != bp->b_bn) @@ -398,7 +398,7 @@ xfs_dir3_data_header_check( { struct xfs_mount *mp = dp->i_mount; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_data_hdr *hdr3 = bp->b_addr; if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino) diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index cd63b37e..70b1f083 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -35,7 +35,7 @@ xfs_dir2_leaf_hdr_from_disk( struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_leaf *from3 = (struct xfs_dir3_leaf *)from; to->forw = be32_to_cpu(from3->hdr.info.hdr.forw); @@ -66,7 +66,7 @@ xfs_dir2_leaf_hdr_to_disk( struct xfs_dir2_leaf *to, struct xfs_dir3_icleaf_hdr *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_leaf *to3 = (struct xfs_dir3_leaf *)to; ASSERT(from->magic == XFS_DIR3_LEAF1_MAGIC || diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 2bccabaf..e7ed4b46 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -244,7 +244,7 @@ xfs_dir2_free_hdr_from_disk( struct xfs_dir3_icfree_hdr *to, struct xfs_dir2_free *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_free *from3 = (struct xfs_dir3_free *)from; to->magic = be32_to_cpu(from3->hdr.hdr.magic); @@ -271,7 +271,7 @@ xfs_dir2_free_hdr_to_disk( struct xfs_dir2_free *to, struct xfs_dir3_icfree_hdr *from) { - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { struct xfs_dir3_free *to3 = (struct xfs_dir3_free *)to; ASSERT(from->magic == XFS_DIR3_FREE_MAGIC); diff --git a/libxfs/xfs_dir2_priv.h b/libxfs/xfs_dir2_priv.h index 94943ce4..711709a2 100644 --- a/libxfs/xfs_dir2_priv.h +++ b/libxfs/xfs_dir2_priv.h @@ -196,7 +196,7 @@ xfs_dir2_data_entsize( len = offsetof(struct xfs_dir2_data_entry, name[0]) + namelen + sizeof(xfs_dir2_data_off_t) /* tag */; - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) len += sizeof(uint8_t); return round_up(len, XFS_DIR2_DATA_ALIGN); } diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index 6a57ad27..751b6347 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -48,7 +48,7 @@ xfs_dir2_sf_entsize( count += sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */ count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */ - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) count += sizeof(uint8_t); return count; } @@ -76,7 +76,7 @@ xfs_dir2_sf_get_ino( { uint8_t *from = sfep->name + sfep->namelen; - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) from++; if (!hdr->i8count) @@ -95,7 +95,7 @@ xfs_dir2_sf_put_ino( ASSERT(ino <= XFS_MAXINUMBER); - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) to++; if (hdr->i8count) @@ -135,7 +135,7 @@ xfs_dir2_sf_get_ftype( struct xfs_mount *mp, struct xfs_dir2_sf_entry *sfep) { - if (xfs_sb_version_hasftype(&mp->m_sb)) { + if (xfs_has_ftype(mp)) { uint8_t ftype = sfep->name[sfep->namelen]; if (ftype < XFS_DIR3_FT_MAX) @@ -153,7 +153,7 @@ xfs_dir2_sf_put_ftype( { ASSERT(ftype < XFS_DIR3_FT_MAX); - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) sfep->name[sfep->namelen] = ftype; } diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c index b77f303c..ecb4a002 100644 --- a/libxfs/xfs_dquot_buf.c +++ b/libxfs/xfs_dquot_buf.c @@ -68,7 +68,7 @@ xfs_dquot_verify( return __this_address; if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && - !xfs_sb_version_hasbigtime(&mp->m_sb)) + !xfs_has_bigtime(mp)) return __this_address; if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && !ddq->d_id) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 7ba6b5e9..cbccc072 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -297,7 +297,7 @@ xfs_ialloc_inode_init( * That means for v3 inode we log the entire buffer rather than just the * inode cores. */ - if (xfs_sb_version_has_v3inode(&mp->m_sb)) { + if (xfs_has_v3inodes(mp)) { version = 3; ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno)); @@ -630,7 +630,7 @@ xfs_ialloc_ag_alloc( #ifdef DEBUG /* randomly do sparse inode allocations */ - if (xfs_sb_version_hassparseinodes(&tp->t_mountp->m_sb) && + if (xfs_has_sparseinodes(tp->t_mountp) && igeo->ialloc_min_blks < igeo->ialloc_blks) do_sparse = prandom_u32() & 1; #endif @@ -749,7 +749,7 @@ xfs_ialloc_ag_alloc( * Finally, try a sparse allocation if the filesystem supports it and * the sparse allocation length is smaller than a full chunk. */ - if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) && + if (xfs_has_sparseinodes(args.mp) && igeo->ialloc_min_blks < igeo->ialloc_blks && args.fsbno == NULLFSBLOCK) { sparse_alloc: @@ -851,7 +851,7 @@ xfs_ialloc_ag_alloc( * from the previous call. Set merge false to replace any * existing record with this one. */ - if (xfs_sb_version_hasfinobt(&args.mp->m_sb)) { + if (xfs_has_finobt(args.mp)) { error = xfs_inobt_insert_sprec(args.mp, tp, agbp, pag, XFS_BTNUM_FINO, &rec, false); if (error) @@ -864,7 +864,7 @@ xfs_ialloc_ag_alloc( if (error) return error; - if (xfs_sb_version_hasfinobt(&args.mp->m_sb)) { + if (xfs_has_finobt(args.mp)) { error = xfs_inobt_insert(args.mp, tp, agbp, pag, newino, newlen, XFS_BTNUM_FINO); if (error) @@ -1443,7 +1443,7 @@ xfs_dialloc_ag( int offset; int i; - if (!xfs_sb_version_hasfinobt(&mp->m_sb)) + if (!xfs_has_finobt(mp)) return xfs_dialloc_ag_inobt(tp, agbp, pag, parent, inop); /* @@ -2182,7 +2182,7 @@ xfs_difree( /* * Fix up the free inode btree. */ - if (xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (xfs_has_finobt(mp)) { error = xfs_difree_finobt(mp, tp, agbp, pag, agino, &rec); if (error) goto error0; @@ -2766,7 +2766,7 @@ xfs_ialloc_setup_geometry( uint inodes; igeo->new_diflags2 = 0; - if (xfs_sb_version_hasbigtime(&mp->m_sb)) + if (xfs_has_bigtime(mp)) igeo->new_diflags2 |= XFS_DIFLAG2_BIGTIME; /* Compute inode btree geometry. */ @@ -2821,7 +2821,7 @@ xfs_ialloc_setup_geometry( * cannot change the behavior. */ igeo->inode_cluster_size_raw = XFS_INODE_BIG_CLUSTER_SIZE; - if (xfs_sb_version_has_v3inode(&mp->m_sb)) { + if (xfs_has_v3inodes(mp)) { int new_size = igeo->inode_cluster_size_raw; new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE; @@ -2839,7 +2839,7 @@ xfs_ialloc_setup_geometry( igeo->inodes_per_cluster = XFS_FSB_TO_INO(mp, igeo->blocks_per_cluster); /* Calculate inode cluster alignment. */ - if (xfs_sb_version_hasalign(&mp->m_sb) && + if (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt >= igeo->blocks_per_cluster) igeo->cluster_align = mp->m_sb.sb_inoalignmt; else @@ -2887,15 +2887,15 @@ xfs_ialloc_calc_rootino( first_bno += xfs_alloc_min_freelist(mp, NULL); /* ...the free inode btree root... */ - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) first_bno++; /* ...the reverse mapping btree root... */ - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) first_bno++; /* ...the reference count btree... */ - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) first_bno++; /* @@ -2913,9 +2913,9 @@ xfs_ialloc_calc_rootino( * Now round first_bno up to whatever allocation alignment is given * by the filesystem or was passed in. */ - if (xfs_sb_version_hasdalign(&mp->m_sb) && igeo->ialloc_align > 0) + if (xfs_has_dalign(mp) && igeo->ialloc_align > 0) first_bno = roundup(first_bno, sunit); - else if (xfs_sb_version_hasalign(&mp->m_sb) && + else if (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt > 1) first_bno = roundup(first_bno, mp->m_sb.sb_inoalignmt); diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 5fb96203..14b5918b 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -75,7 +75,7 @@ xfs_inobt_mod_blockcount( struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agi *agi = agbp->b_addr; - if (!xfs_sb_version_hasinobtcounts(&cur->bc_mp->m_sb)) + if (!xfs_has_inobtcounts(cur->bc_mp)) return; if (cur->bc_btnum == XFS_BTNUM_FINO) @@ -291,7 +291,7 @@ xfs_inobt_verify( * but beware of the landmine (i.e. need to check pag->pagi_init) if we * ever do. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { fa = xfs_btree_sblock_v5hdr_verify(bp); if (fa) return fa; @@ -510,7 +510,7 @@ xfs_inobt_commit_staged_btree( fields = XFS_AGI_ROOT | XFS_AGI_LEVEL; agi->agi_root = cpu_to_be32(afake->af_root); agi->agi_level = cpu_to_be32(afake->af_levels); - if (xfs_sb_version_hasinobtcounts(&cur->bc_mp->m_sb)) { + if (xfs_has_inobtcounts(cur->bc_mp)) { agi->agi_iblocks = cpu_to_be32(afake->af_blocks); fields |= XFS_AGI_IBLOCKS; } @@ -520,7 +520,7 @@ xfs_inobt_commit_staged_btree( fields = XFS_AGI_FREE_ROOT | XFS_AGI_FREE_LEVEL; agi->agi_free_root = cpu_to_be32(afake->af_root); agi->agi_free_level = cpu_to_be32(afake->af_levels); - if (xfs_sb_version_hasinobtcounts(&cur->bc_mp->m_sb)) { + if (xfs_has_inobtcounts(cur->bc_mp)) { agi->agi_fblocks = cpu_to_be32(afake->af_blocks); fields |= XFS_AGI_IBLOCKS; } @@ -739,7 +739,7 @@ xfs_finobt_calc_reserves( if (!xfs_has_finobt(mp)) return 0; - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) + if (xfs_has_inobtcounts(mp)) error = xfs_finobt_read_blocks(mp, tp, pag, &tree_len); else error = xfs_inobt_count_blocks(mp, tp, pag, XFS_BTNUM_FINO, diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 946261cd..2638e515 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -189,7 +189,7 @@ xfs_inode_from_disk( * inode. If the inode is unused, mode is zero and we shouldn't mess * with the uninitialized part of it. */ - if (!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) + if (!xfs_has_v3inodes(ip->i_mount)) ip->i_flushiter = be16_to_cpu(from->di_flushiter); inode->i_generation = be32_to_cpu(from->di_gen); inode->i_mode = be16_to_cpu(from->di_mode); @@ -232,7 +232,7 @@ xfs_inode_from_disk( if (from->di_dmevmask || from->di_dmstate) xfs_iflags_set(ip, XFS_IPRESERVE_DM_FIELDS); - if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { + if (xfs_has_v3inodes(ip->i_mount)) { inode_set_iversion_queried(inode, be64_to_cpu(from->di_changecount)); ip->i_crtime = xfs_inode_from_disk_ts(from, from->di_crtime); @@ -310,7 +310,7 @@ xfs_inode_to_disk( to->di_aformat = xfs_ifork_format(ip->i_afp); to->di_flags = cpu_to_be16(ip->i_diflags); - if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { + if (xfs_has_v3inodes(ip->i_mount)) { to->di_version = 3; to->di_changecount = cpu_to_be64(inode_peek_iversion(inode)); to->di_crtime = xfs_inode_to_disk_ts(ip, ip->i_crtime); @@ -410,7 +410,7 @@ xfs_dinode_verify( /* Verify v3 integrity information first */ if (dip->di_version >= 3) { - if (!xfs_sb_version_has_v3inode(&mp->m_sb)) + if (!xfs_has_v3inodes(mp)) return __this_address; if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, XFS_DINODE_CRC_OFF)) @@ -531,7 +531,7 @@ xfs_dinode_verify( /* bigtime iflag can only happen on bigtime filesystems */ if (xfs_dinode_has_bigtime(dip) && - !xfs_sb_version_hasbigtime(&mp->m_sb)) + !xfs_has_bigtime(mp)) return __this_address; return NULL; diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 28c02047..b322db52 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -434,7 +434,7 @@ struct xfs_log_dinode { }; #define xfs_log_dinode_size(mp) \ - (xfs_sb_version_has_v3inode(&(mp)->m_sb) ? \ + (xfs_has_v3inodes((mp)) ? \ sizeof(struct xfs_log_dinode) : \ offsetof(struct xfs_log_dinode, di_next_unlinked)) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 1c9e7722..2aa64d3e 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1252,7 +1252,7 @@ xfs_refcount_increase_extent( struct xfs_trans *tp, struct xfs_bmbt_irec *PREV) { - if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb)) + if (!xfs_has_reflink(tp->t_mountp)) return; __xfs_refcount_add(tp, XFS_REFCOUNT_INCREASE, PREV->br_startblock, @@ -1267,7 +1267,7 @@ xfs_refcount_decrease_extent( struct xfs_trans *tp, struct xfs_bmbt_irec *PREV) { - if (!xfs_sb_version_hasreflink(&tp->t_mountp->m_sb)) + if (!xfs_has_reflink(tp->t_mountp)) return; __xfs_refcount_add(tp, XFS_REFCOUNT_DECREASE, PREV->br_startblock, @@ -1616,7 +1616,7 @@ xfs_refcount_alloc_cow_extent( { struct xfs_mount *mp = tp->t_mountp; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return; __xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len); @@ -1635,7 +1635,7 @@ xfs_refcount_free_cow_extent( { struct xfs_mount *mp = tp->t_mountp; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return; /* Remove rmap entry */ diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index a2ad1516..18be9164 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -909,7 +909,7 @@ xfs_log_sb( * unclean shutdown, this will be corrected by log recovery rebuilding * the counters from the AGF block counts. */ - if (xfs_sb_version_haslazysbcount(&mp->m_sb)) { + if (xfs_has_lazysbcount(mp)) { mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c index 06d11a5c..276d57cf 100644 --- a/libxfs/xfs_trans_inode.c +++ b/libxfs/xfs_trans_inode.c @@ -133,7 +133,7 @@ xfs_trans_log_inode( * to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE | XFS_ILOG_TIMESTAMP)) && - xfs_sb_version_hasbigtime(&ip->i_mount->m_sb) && + xfs_has_bigtime(ip->i_mount) && !xfs_inode_has_bigtime(ip)) { ip->i_diflags2 |= XFS_DIFLAG2_BIGTIME; flags |= XFS_ILOG_CORE; diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c index ea57e810..d383528d 100644 --- a/libxfs/xfs_trans_resv.c +++ b/libxfs/xfs_trans_resv.c @@ -186,7 +186,7 @@ xfs_calc_inode_chunk_res( XFS_FSB_TO_B(mp, 1)); if (alloc) { /* icreate tx uses ordered buffers */ - if (xfs_sb_version_has_v3inode(&mp->m_sb)) + if (xfs_has_v3inodes(mp)) return res; size = XFS_FSB_TO_B(mp, 1); } @@ -267,7 +267,7 @@ xfs_calc_write_reservation( xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) + xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2), blksz); - if (xfs_sb_version_hasrealtime(&mp->m_sb)) { + if (xfs_has_realtime(mp)) { t2 = xfs_calc_inode_res(mp, 1) + xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), blksz) + @@ -316,7 +316,7 @@ xfs_calc_itruncate_reservation( t2 = xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) + xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4), blksz); - if (xfs_sb_version_hasrealtime(&mp->m_sb)) { + if (xfs_has_realtime(mp)) { t3 = xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) + xfs_calc_buf_res(xfs_rtalloc_log_count(mp, 2), blksz) + xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2), blksz); diff --git a/libxfs/xfs_trans_space.h b/libxfs/xfs_trans_space.h index 7ad3659c..50332be3 100644 --- a/libxfs/xfs_trans_space.h +++ b/libxfs/xfs_trans_space.h @@ -57,8 +57,7 @@ XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK) #define XFS_IALLOC_SPACE_RES(mp) \ (M_IGEO(mp)->ialloc_blks + \ - ((xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1) * \ - M_IGEO(mp)->inobt_maxlevels)) + ((xfs_has_finobt(mp) ? 2 : 1) * M_IGEO(mp)->inobt_maxlevels)) /* * Space reservation values for various transactions. @@ -94,8 +93,7 @@ #define XFS_SYMLINK_SPACE_RES(mp,nl,b) \ (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) #define XFS_IFREE_SPACE_RES(mp) \ - (xfs_sb_version_hasfinobt(&mp->m_sb) ? \ - M_IGEO(mp)->inobt_maxlevels : 0) + (xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0) #endif /* __XFS_TRANS_SPACE_H__ */ From patchwork Tue Sep 14 02:42:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7724C433F5 for ; Tue, 14 Sep 2021 02:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C2C0610D1 for ; Tue, 14 Sep 2021 02:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237737AbhINCoH (ORCPT ); Mon, 13 Sep 2021 22:44:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCoG (ORCPT ); Mon, 13 Sep 2021 22:44:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE1FC610D1; Tue, 14 Sep 2021 02:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587369; bh=jvEv/ApBeSfPV8v+dBSoZFKqZfI6tjPxTfz+6cVuZnI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HLHi5PKS7I841Cmp8JO781bazY2gYk58ZYjnAbj7qDJxVFJH4fwibdaU1i5FKiqyt Mv3lhR3eAd1b+G/AUQpWdKlSmPGrHLF8Ussl6LJ70HoVbP6auAzRC755dZ7kk/iixE 3o7vOOOhnbMAprE8bxNYWwK0iSU2+Z8sHjm+pyHwP0ediD8KPKVcywNcwvfzSwNnFE prrx6BlvJ1uLe3ZPLMdi4dsDAPwIS/okXcz6FCcVGxW/GqI4619kW+gda6WeBHeesv U8g5piyppuTanEdrP2oxSyw5+QbkYx+0mGhJyL8RcX44Eyf7bmSlOO/cbo+8R60OyN 0LjwNDQEnR3lQ== Subject: [PATCH 31/43] libxlog: replace xfs_sb_version checks with feature flag checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:49 -0700 Message-ID: <163158736945.1604118.14641958910467350750.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert the xfs_sb_version_hasfoo() to checks against mp->m_features. Signed-off-by: Darrick J. Wong --- libxlog/util.c | 6 +++--- libxlog/xfs_log_recover.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libxlog/util.c b/libxlog/util.c index a85d70c9..ad60036f 100644 --- a/libxlog/util.c +++ b/libxlog/util.c @@ -31,7 +31,7 @@ xlog_is_dirty( x->logBBsize = XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); x->logBBstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); x->lbsize = BBSIZE; - if (xfs_sb_version_hassector(&mp->m_sb)) + if (xfs_has_sector(mp)) x->lbsize <<= (mp->m_sb.sb_logsectlog - BBSHIFT); log->l_dev = mp->m_logdev_targp; @@ -39,13 +39,13 @@ xlog_is_dirty( log->l_logBBstart = x->logBBstart; log->l_sectBBsize = BTOBB(x->lbsize); log->l_mp = mp; - if (xfs_sb_version_hassector(&mp->m_sb)) { + if (xfs_has_sector(mp)) { log->l_sectbb_log = mp->m_sb.sb_logsectlog - BBSHIFT; ASSERT(log->l_sectbb_log <= mp->m_sectbb_log); /* for larger sector sizes, must have v2 or external log */ ASSERT(log->l_sectbb_log == 0 || log->l_logBBstart == 0 || - xfs_sb_version_haslogv2(&mp->m_sb)); + xfs_has_logv2(mp)); ASSERT(mp->m_sb.sb_logsectlog >= BBSHIFT); } log->l_sectbb_mask = (1 << log->l_sectbb_log) - 1; diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c index 40d18b88..592e4502 100644 --- a/libxlog/xfs_log_recover.c +++ b/libxlog/xfs_log_recover.c @@ -364,7 +364,7 @@ xlog_find_verify_log_record( * reset last_blk. Only when last_blk points in the middle of a log * record do we update last_blk. */ - if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) { + if (xfs_has_logv2(log->l_mp)) { uint h_size = be32_to_cpu(head->h_size); xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE; @@ -783,7 +783,7 @@ xlog_find_tail( * unmount record if there is one, so we pass the lsn of the * unmount record rather than the block after it. */ - if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) { + if (xfs_has_logv2(log->l_mp)) { int h_size = be32_to_cpu(rhead->h_size); int h_version = be32_to_cpu(rhead->h_version); @@ -1313,7 +1313,7 @@ xlog_unpack_data_crc( crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len)); if (crc != rhead->h_crc) { - if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) { + if (rhead->h_crc || xfs_has_crc(log->l_mp)) { xfs_alert(log->l_mp, "log record CRC mismatch: found 0x%x, expected 0x%x.", le32_to_cpu(rhead->h_crc), @@ -1326,7 +1326,7 @@ xlog_unpack_data_crc( * recover past this point. Abort recovery if we are enforcing * CRC protection by punting an error back up the stack. */ - if (xfs_sb_version_hascrc(&log->l_mp->m_sb)) + if (xfs_has_crc(log->l_mp)) return EFSCORRUPTED; } @@ -1352,7 +1352,7 @@ xlog_unpack_data( dp += BBSIZE; } - if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) { + if (xfs_has_logv2(log->l_mp)) { xlog_in_core_2_t *xhdr = (xlog_in_core_2_t *)rhead; for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) { j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); @@ -1431,7 +1431,7 @@ xlog_do_recovery_pass( * Read the header of the tail block and get the iclog buffer size from * h_size. Use this to tell how many sectors make up the log header. */ - if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) { + if (xfs_has_logv2(log->l_mp)) { /* * When using variable length iclogs, read first sector of * iclog header and extract the header size from it. Get a From patchwork Tue Sep 14 02:42:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 001F7C433EF for ; Tue, 14 Sep 2021 02:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4AAC610F9 for ; Tue, 14 Sep 2021 02:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237725AbhINCoS (ORCPT ); Mon, 13 Sep 2021 22:44:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:53864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237467AbhINCoL (ORCPT ); Mon, 13 Sep 2021 22:44:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BC13610D1; Tue, 14 Sep 2021 02:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587375; bh=is7hlzPg2R/JLjf9gGbteOjAmHUdXJ4U2IZQ+GBlCIs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Jk5w0DzxK7uDL7hH+FxXQZxmFiMs/qbsioE69HjAIcC1C4/kXuB1sRisxv7eYSvJD +SQt9stTRDBj5TPzMUIEoR2S4o8vawUrS61NOoSHbwrRzX2W1C8xBitRk8IVjDHaE/ ygKYFoRSB7slXqJ76vG10OOXElLBdkatQeX/2FJH8/xs+Z3MY0vfn+ppXUE20lkce3 tZhQdILtjcXcGVpixO1OamJmfMkTNi/5ILptuHcERwGZ+UYBJ2N/SARu1gHcsOumBQ TUN9HsdzCG85wVDh1L9aBHk+IUhcFDNdDEFdmDZF5NMDL8yH3tYZ1pEot62Q6YD20c H3v4kV2KjC46A== Subject: [PATCH 32/43] libxfs: replace xfs_sb_version checks with feature flag checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:42:54 -0700 Message-ID: <163158737492.1604118.6745890320211128923.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert the xfs_sb_version_hasfoo() to checks against mp->m_features. Signed-off-by: Darrick J. Wong --- libxfs/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libxfs/init.c b/libxfs/init.c index e7009a2e..593d0fa2 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -424,17 +424,17 @@ rtmount_init( xfs_daddr_t d; /* address of last block of subvolume */ int error; - if (mp->m_sb.sb_rblocks == 0) + if (!xfs_has_realtime(mp)) return 0; - if (xfs_sb_version_hasreflink(&mp->m_sb)) { + if (xfs_has_reflink(mp)) { fprintf(stderr, _("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"), progname); return -1; } - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (xfs_has_rmapbt(mp)) { fprintf(stderr, _("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"), progname); From patchwork Tue Sep 14 02:43:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 551D6C433F5 for ; Tue, 14 Sep 2021 02:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36B82610D1 for ; Tue, 14 Sep 2021 02:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234374AbhINCoT (ORCPT ); Mon, 13 Sep 2021 22:44:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:53908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237856AbhINCoR (ORCPT ); Mon, 13 Sep 2021 22:44:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB4BB610F9; Tue, 14 Sep 2021 02:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587380; bh=2w9pYtof5Cupp5Fq4q/8QU4809ELhyhp8dYD5PeR8s8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=U3qiooZcZbM8tpeZkGs90pdCE2NZ6ThQitaSiFoHug7cnCwFqKyDYR2r1bpY7NKdY w5zADYeBGm30xUryx5O6ExbZABRYq6Ml8+fagnGVPwj9gLhGhhWC9ZPBOepSLo7r9o BvU832vCfX70YWSc7SfRv1fSE1Hm/jxMvdpwR7hwPf/9uHLgPljXYsHH1JiayrXngB UUU3nh/rwKTt4cATdR0G3R83/tL3PL4o077XnSC5D3A/tF03L+0SIrZS8RGvFVYxxG 7BBRjkFG3R0Son4QpWK7n2bZtz5xLDH8lyh9lnHd1TP51Mco2SSd0anTnJlFMfRYdc 2MiPEpUf/uRnQ== Subject: [PATCH 33/43] xfs_{copy,db,logprint,repair}: replace xfs_sb_version checks with feature flag checks From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:00 -0700 Message-ID: <163158738037.1604118.6563213780558776723.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Convert the xfs_sb_version_hasfoo() to checks against mp->m_features. Signed-off-by: Darrick J. Wong --- copy/xfs_copy.c | 19 ++++++++---------- db/btblock.c | 2 +- db/btdump.c | 4 ++-- db/check.c | 18 ++++++++--------- db/crc.c | 2 +- db/frag.c | 2 +- db/fsmap.c | 2 +- db/fuzz.c | 4 ++-- db/init.c | 6 +++--- db/inode.c | 6 +++--- db/io.c | 4 ++-- db/logformat.c | 4 ++-- db/metadump.c | 22 ++++++++++---------- db/namei.c | 2 +- db/sb.c | 54 +++++++++++++++++++++++++------------------------- db/timelimit.c | 2 +- db/write.c | 4 ++-- libxfs/init.c | 4 ++-- libxfs/rdwr.c | 4 ++-- libxfs/util.c | 10 +++++---- logprint/logprint.c | 2 +- repair/agbtree.c | 10 +++++---- repair/agheader.c | 6 +++--- repair/attr_repair.c | 2 +- repair/dino_chunks.c | 2 +- repair/dinode.c | 24 +++++++++++----------- repair/incore.h | 4 ++-- repair/incore_ino.c | 2 +- repair/phase2.c | 20 +++++++++---------- repair/phase4.c | 2 +- repair/phase5.c | 30 ++++++++++++++-------------- repair/phase6.c | 14 ++++++------- repair/quotacheck.c | 4 ++-- repair/rmap.c | 16 +++++++-------- repair/scan.c | 32 +++++++++++++++--------------- repair/versions.c | 18 ++++++++--------- repair/xfs_repair.c | 8 ++++--- 37 files changed, 185 insertions(+), 186 deletions(-) diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index 5c4f65b4..c7efc3eb 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -523,8 +523,7 @@ sb_update_uuid( * we must copy the original sb_uuid to the sb_meta_uuid slot and set * the incompat flag for the feature on this copy. */ - if (xfs_sb_version_hascrc(&mp->m_sb) && - !xfs_sb_version_hasmetauuid(&mp->m_sb) && + if (xfs_has_crc(mp) && !xfs_has_metauuid(mp) && !uuid_equal(&tcarg->uuid, &mp->m_sb.sb_uuid)) { uint32_t feat; @@ -539,7 +538,7 @@ sb_update_uuid( platform_uuid_copy(&ag_hdr->xfs_sb->sb_uuid, &tcarg->uuid); /* We may have changed the UUID, so update the superblock CRC */ - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) xfs_update_cksum((char *)ag_hdr->xfs_sb, mp->m_sb.sb_sectsize, XFS_SB_CRC_OFF); } @@ -1040,7 +1039,7 @@ main(int argc, char **argv) pos - btree_buf.position); if (be32_to_cpu(block->bb_magic) != - (xfs_sb_version_hascrc(&mp->m_sb) ? + (xfs_has_crc(mp) ? XFS_ABTB_CRC_MAGIC : XFS_ABTB_MAGIC)) { do_log(_("Bad btree magic 0x%x\n"), be32_to_cpu(block->bb_magic)); @@ -1278,7 +1277,7 @@ write_log_header(int fd, wbuf *buf, xfs_mount_t *mp) } offset = libxfs_log_header(p, &buf->owner->uuid, - xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1, + xfs_has_logv2(mp) ? 2 : 1, mp->m_sb.sb_logsunit, XLOG_FMT, NULLCOMMITLSN, NULLCOMMITLSN, next_log_chunk, buf); do_write(buf->owner, NULL); @@ -1363,7 +1362,7 @@ format_log( * all existing metadata LSNs are valid (behind the current LSN) on the * target fs. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) cycle = mp->m_log->l_curr_cycle + 1; /* @@ -1371,7 +1370,7 @@ format_log( * write fails, mark the target inactive so the failure is reported. */ libxfs_log_clear(NULL, buf->data, logstart, length, &buf->owner->uuid, - xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1, + xfs_has_logv2(mp) ? 2 : 1, mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true); if (do_write(buf->owner, buf)) target[tcarg->id].state = INACTIVE; @@ -1386,7 +1385,7 @@ format_logs( wbuf logbuf; int logsize; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { logsize = XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks); if (!wbuf_init(&logbuf, logsize, w_buf.data_align, w_buf.min_io_size, w_buf.id)) @@ -1394,14 +1393,14 @@ format_logs( } for (i = 0, tcarg = targ; i < num_targets; i++) { - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) format_log(mp, tcarg, &logbuf); else clear_log(mp, tcarg); tcarg++; } - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) free(logbuf.data); return 0; diff --git a/db/btblock.c b/db/btblock.c index e57d5f46..24c65669 100644 --- a/db/btblock.c +++ b/db/btblock.c @@ -120,7 +120,7 @@ block_to_bt( } /* Magic is invalid/unknown. Guess based on iocur type */ - crc = xfs_sb_version_hascrc(&mp->m_sb); + crc = xfs_has_crc(mp); switch (iocur_top->typ->typnm) { case TYP_BMAPBTA: case TYP_BMAPBTD: diff --git a/db/btdump.c b/db/btdump.c index 920f595b..cb9ca082 100644 --- a/db/btdump.c +++ b/db/btdump.c @@ -159,7 +159,7 @@ dump_inode( if (attrfork) prefix = "a.bmbt"; - else if (xfs_sb_version_hascrc(&mp->m_sb)) + else if (xfs_has_crc(mp)) prefix = "u3.bmbt"; else prefix = "u.bmbt"; @@ -448,7 +448,7 @@ btdump_f( { bool aflag = false; bool iflag = false; - bool crc = xfs_sb_version_hascrc(&mp->m_sb); + bool crc = xfs_has_crc(mp); int c; if (cur_typ == NULL) { diff --git a/db/check.c b/db/check.c index 485e855e..a078e948 100644 --- a/db/check.c +++ b/db/check.c @@ -891,21 +891,21 @@ blockget_f( error++; } if ((sbversion & XFS_SB_VERSION_ATTRBIT) && - !xfs_sb_version_hasattr(&mp->m_sb)) { + !xfs_has_attr(mp)) { if (!sflag) dbprintf(_("sb versionnum missing attr bit %x\n"), XFS_SB_VERSION_ATTRBIT); error++; } if ((sbversion & XFS_SB_VERSION_QUOTABIT) && - !xfs_sb_version_hasquota(&mp->m_sb)) { + !xfs_has_quota(mp)) { if (!sflag) dbprintf(_("sb versionnum missing quota bit %x\n"), XFS_SB_VERSION_QUOTABIT); error++; } if (!(sbversion & XFS_SB_VERSION_ALIGNBIT) && - xfs_sb_version_hasalign(&mp->m_sb)) { + xfs_has_align(mp)) { if (!sflag) dbprintf(_("sb versionnum extra align bit %x\n"), XFS_SB_VERSION_ALIGNBIT); @@ -1628,7 +1628,7 @@ static bool is_reflink( dbm_t type2) { - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return false; if (type2 == DBM_DATA || type2 == DBM_RLDATA) return true; @@ -1988,7 +1988,7 @@ init( * at least one full inode record per block. Check this case explicitly. */ if (mp->m_sb.sb_inoalignmt || - (xfs_sb_version_hasalign(&mp->m_sb) && + (xfs_has_align(mp) && mp->m_sb.sb_inopblock >= XFS_INODES_PER_CHUNK)) sbversion |= XFS_SB_VERSION_ALIGNBIT; if ((mp->m_sb.sb_uquotino && mp->m_sb.sb_uquotino != NULLFSINO) || @@ -2814,7 +2814,7 @@ process_inode( uid = be32_to_cpu(dip->di_uid); gid = be32_to_cpu(dip->di_gid); diflags = be16_to_cpu(dip->di_flags); - if (xfs_sb_version_has_v3inode(&mp->m_sb)) + if (xfs_has_v3inodes(mp)) diflags2 = be64_to_cpu(dip->di_flags2); if (isfree) { if (be64_to_cpu(dip->di_nblocks) != 0) { @@ -4497,7 +4497,7 @@ scanfunc_ino( int ioff; struct xfs_ino_geometry *igeo = M_IGEO(mp); - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) blks_per_buf = igeo->blocks_per_cluster; else blks_per_buf = igeo->ialloc_blks; @@ -4586,7 +4586,7 @@ scanfunc_ino( ioff += inodes_per_buf; } - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) freecount = rp[i].ir_u.sp.ir_freecount; else freecount = be32_to_cpu(rp[i].ir_u.f.ir_freecount); @@ -4641,7 +4641,7 @@ scanfunc_fino( int ioff; struct xfs_ino_geometry *igeo = M_IGEO(mp); - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) blks_per_buf = igeo->blocks_per_cluster; else blks_per_buf = igeo->ialloc_blks; diff --git a/db/crc.c b/db/crc.c index b23417a1..7428b916 100644 --- a/db/crc.c +++ b/db/crc.c @@ -29,7 +29,7 @@ static const cmdinfo_t crc_cmd = void crc_init(void) { - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) add_command(&crc_cmd); } diff --git a/db/frag.c b/db/frag.c index cc00672e..9bc63614 100644 --- a/db/frag.c +++ b/db/frag.c @@ -474,7 +474,7 @@ scanfunc_ino( int ioff; struct xfs_ino_geometry *igeo = M_IGEO(mp); - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) blks_per_buf = igeo->blocks_per_cluster; else blks_per_buf = igeo->ialloc_blks; diff --git a/db/fsmap.c b/db/fsmap.c index d30b832c..8e130f5b 100644 --- a/db/fsmap.c +++ b/db/fsmap.c @@ -112,7 +112,7 @@ fsmap_f( xfs_fsblock_t start_fsb = 0; xfs_fsblock_t end_fsb = NULLFSBLOCK; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (!xfs_has_rmapbt(mp)) { dbprintf(_("Filesystem does not support reverse mapping btree.\n")); return 0; } diff --git a/db/fuzz.c b/db/fuzz.c index 65157bd0..ba64bad7 100644 --- a/db/fuzz.c +++ b/db/fuzz.c @@ -116,7 +116,7 @@ fuzz_f( if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF && - xfs_sb_version_hascrc(&mp->m_sb)) { + xfs_has_crc(mp)) { dbprintf(_("Cannot recalculate CRCs on this type of object\n")); return 0; } @@ -140,7 +140,7 @@ fuzz_f( local_ops.verify_read = stashed_ops->verify_read; iocur_top->bp->b_ops = &local_ops; - if (!xfs_sb_version_hascrc(&mp->m_sb)) { + if (!xfs_has_crc(mp)) { local_ops.verify_write = xfs_dummy_verify; } else if (corrupt) { local_ops.verify_write = xfs_dummy_verify; diff --git a/db/init.c b/db/init.c index 19f0900a..eec65d08 100644 --- a/db/init.c +++ b/db/init.c @@ -152,7 +152,7 @@ init( * xfs_check needs corrected incore superblock values */ if (sbp->sb_rootino != NULLFSINO && - xfs_sb_version_haslazysbcount(&mp->m_sb)) { + xfs_has_lazysbcount(mp)) { int error = -libxfs_initialize_perag_data(mp, sbp->sb_agcount); if (error) { fprintf(stderr, @@ -161,9 +161,9 @@ init( } } - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) type_set_tab_spcrc(); - else if (xfs_sb_version_hascrc(&mp->m_sb)) + else if (xfs_has_crc(mp)) type_set_tab_crc(); push_cur(); diff --git a/db/inode.c b/db/inode.c index 3453c089..22bc63a8 100644 --- a/db/inode.c +++ b/db/inode.c @@ -560,7 +560,7 @@ inode_u_sfdir2_count( ASSERT((char *)XFS_DFORK_DPTR(dip) - (char *)dip == byteize(startoff)); return dip->di_format == XFS_DINODE_FMT_LOCAL && (be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFDIR && - !xfs_sb_version_hasftype(&mp->m_sb); + !xfs_has_ftype(mp); } static int @@ -576,7 +576,7 @@ inode_u_sfdir3_count( ASSERT((char *)XFS_DFORK_DPTR(dip) - (char *)dip == byteize(startoff)); return dip->di_format == XFS_DINODE_FMT_LOCAL && (be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFDIR && - xfs_sb_version_hasftype(&mp->m_sb); + xfs_has_ftype(mp); } int @@ -691,7 +691,7 @@ set_cur_inode( if ((iocur_top->mode & S_IFMT) == S_IFDIR) iocur_top->dirino = ino; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { iocur_top->ino_crc_ok = libxfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, XFS_DINODE_CRC_OFF); diff --git a/db/io.c b/db/io.c index c79cf105..98f4e605 100644 --- a/db/io.c +++ b/db/io.c @@ -477,7 +477,7 @@ write_cur(void) return; } - if (!xfs_sb_version_hascrc(&mp->m_sb) || + if (!xfs_has_crc(mp) || !iocur_top->bp->b_ops || iocur_top->bp->b_ops->verify_write == xfs_dummy_verify) skip_crc = true; @@ -494,7 +494,7 @@ write_cur(void) write_cur_buf(); /* If we didn't write the crc automatically, re-check inode validity */ - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && skip_crc && iocur_top->ino_buf) { iocur_top->ino_crc_ok = libxfs_verify_cksum(iocur_top->data, mp->m_sb.sb_inodesize, diff --git a/db/logformat.c b/db/logformat.c index 3374c29b..38b0af11 100644 --- a/db/logformat.c +++ b/db/logformat.c @@ -24,7 +24,7 @@ logformat_f(int argc, char **argv) int error; int c; - logversion = xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1; + logversion = xfs_has_logv2(mp) ? 2 : 1; while ((c = getopt(argc, argv, "c:s:")) != EOF) { switch (c) { @@ -64,7 +64,7 @@ logformat_f(int argc, char **argv) mp->m_log->l_logBBsize = XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); mp->m_log->l_logBBstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); mp->m_log->l_sectBBsize = BBSIZE; - if (xfs_sb_version_hassector(&mp->m_sb)) + if (xfs_has_sector(mp)) mp->m_log->l_sectBBsize <<= (mp->m_sb.sb_logsectlog - BBSHIFT); mp->m_log->l_sectBBsize = BTOBB(mp->m_log->l_sectBBsize); diff --git a/db/metadump.c b/db/metadump.c index 96b098b0..2c649c15 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -574,7 +574,7 @@ copy_rmap_btree( xfs_agblock_t root; int levels; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 1; root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_RMAP]); @@ -646,7 +646,7 @@ copy_refcount_btree( xfs_agblock_t root; int levels; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return 1; root = be32_to_cpu(agf->agf_refcount_root); @@ -1536,13 +1536,13 @@ process_dir_data_block( blp = (xfs_dir2_leaf_entry_t *)btp; end_of_data = (char *)blp - block; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) wantmagic = XFS_DIR3_BLOCK_MAGIC; else wantmagic = XFS_DIR2_BLOCK_MAGIC; } else { /* leaf/node format */ end_of_data = mp->m_dir_geo->fsbcount << mp->m_sb.sb_blocklog; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) wantmagic = XFS_DIR3_DATA_MAGIC; else wantmagic = XFS_DIR2_DATA_MAGIC; @@ -1664,7 +1664,7 @@ process_symlink_block( } link = iocur_top->data; - if (xfs_sb_version_hascrc(&(mp)->m_sb)) + if (xfs_has_crc((mp))) link += sizeof(struct xfs_dsymlink_hdr); if (obfuscate) @@ -1675,7 +1675,7 @@ process_symlink_block( linklen = strlen(link); zlen = mp->m_sb.sb_blocksize - linklen; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) zlen -= sizeof(struct xfs_dsymlink_hdr); if (zlen < mp->m_sb.sb_blocksize) memset(link + linklen, 0, zlen); @@ -2476,7 +2476,7 @@ copy_inode_chunk( * Also make sure that that we don't process more than the single record * we've been passed (large block sizes can hold multiple inode chunks). */ - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) blks_per_buf = igeo->blocks_per_cluster; else blks_per_buf = igeo->ialloc_blks; @@ -2509,7 +2509,7 @@ copy_inode_chunk( if ((mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK && off != 0) || (mp->m_sb.sb_inopblock > XFS_INODES_PER_CHUNK && off % XFS_INODES_PER_CHUNK != 0) || - (xfs_sb_version_hasalign(&mp->m_sb) && + (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt != 0 && agbno % mp->m_sb.sb_inoalignmt != 0)) { if (show_warnings) @@ -2660,7 +2660,7 @@ copy_inodes( if (!scan_btree(agno, root, levels, TYP_INOBT, &finobt, scanfunc_ino)) return 0; - if (xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (xfs_has_finobt(mp)) { root = be32_to_cpu(agi->agi_free_root); levels = be32_to_cpu(agi->agi_free_level); @@ -2891,8 +2891,8 @@ copy_log(void) logstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); logblocks = XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); - logversion = xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1; - if (xfs_sb_version_hascrc(&mp->m_sb)) + logversion = xfs_has_logv2(mp) ? 2 : 1; + if (xfs_has_crc(mp)) cycle = log.l_curr_cycle + 1; libxfs_log_clear(NULL, iocur_top->data, logstart, logblocks, diff --git a/db/namei.c b/db/namei.c index 4e2047b2..e44667a9 100644 --- a/db/namei.c +++ b/db/namei.c @@ -231,7 +231,7 @@ get_dstr( struct xfs_mount *mp, uint8_t filetype) { - if (!xfs_sb_version_hasftype(&mp->m_sb)) + if (!xfs_has_ftype(mp)) return filetype_strings[XFS_DIR3_FT_UNKNOWN]; if (filetype >= XFS_DIR3_FT_MAX) diff --git a/db/sb.c b/db/sb.c index 94001943..7510e00f 100644 --- a/db/sb.c +++ b/db/sb.c @@ -266,7 +266,7 @@ sb_logzero(uuid_t *uuidp) * The log must always move forward on v5 superblocks. Bump it to the * next cycle. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) cycle = mp->m_log->l_curr_cycle + 1; dbprintf(_("Clearing log and setting UUID\n")); @@ -275,7 +275,7 @@ sb_logzero(uuid_t *uuidp) XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks), uuidp, - xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1, + xfs_has_logv2(mp) ? 2 : 1, mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true); if (error) { dbprintf(_("ERROR: cannot clear the log\n")); @@ -652,57 +652,57 @@ version_string( * We assume the state of these features now, so macros don't exist for * them any more. */ - if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT) + if (xfs_has_nlink(mp)) strcat(s, ",NLINK"); if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_SHAREDBIT) strcat(s, ",SHARED"); if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT) strcat(s, ",DIRV2"); - if (xfs_sb_version_hasattr(&mp->m_sb)) + if (xfs_has_attr(mp)) strcat(s, ",ATTR"); - if (xfs_sb_version_hasquota(&mp->m_sb)) + if (xfs_has_quota(mp)) strcat(s, ",QUOTA"); - if (xfs_sb_version_hasalign(&mp->m_sb)) + if (xfs_has_align(mp)) strcat(s, ",ALIGN"); - if (xfs_sb_version_hasdalign(&mp->m_sb)) + if (xfs_has_dalign(mp)) strcat(s, ",DALIGN"); - if (xfs_sb_version_haslogv2(&mp->m_sb)) + if (xfs_has_logv2(mp)) strcat(s, ",LOGV2"); /* This feature is required now as well */ - if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_EXTFLGBIT) + if (xfs_has_extflg(mp)) strcat(s, ",EXTFLG"); - if (xfs_sb_version_hassector(&mp->m_sb)) + if (xfs_has_sector(mp)) strcat(s, ",SECTOR"); - if (xfs_sb_version_hasasciici(&mp->m_sb)) + if (xfs_has_asciici(mp)) strcat(s, ",ASCII_CI"); - if (xfs_sb_version_hasmorebits(&mp->m_sb)) + if (mp->m_sb.sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) strcat(s, ",MOREBITS"); - if (xfs_sb_version_hasattr2(&mp->m_sb)) + if (xfs_has_attr2(mp)) strcat(s, ",ATTR2"); - if (xfs_sb_version_haslazysbcount(&mp->m_sb)) + if (xfs_has_lazysbcount(mp)) strcat(s, ",LAZYSBCOUNT"); - if (xfs_sb_version_hasprojid32(&mp->m_sb)) + if (xfs_has_projid32(mp)) strcat(s, ",PROJID32BIT"); - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) strcat(s, ",CRC"); - if (xfs_sb_version_hasftype(&mp->m_sb)) + if (xfs_has_ftype(mp)) strcat(s, ",FTYPE"); - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) strcat(s, ",FINOBT"); - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) strcat(s, ",SPARSE_INODES"); - if (xfs_sb_version_hasmetauuid(&mp->m_sb)) + if (xfs_has_metauuid(mp)) strcat(s, ",META_UUID"); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) strcat(s, ",RMAPBT"); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) strcat(s, ",REFLINK"); - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) + if (xfs_has_inobtcounts(mp)) strcat(s, ",INOBTCNT"); - if (xfs_sb_version_hasbigtime(&mp->m_sb)) + if (xfs_has_bigtime(mp)) strcat(s, ",BIGTIME"); - if (xfs_sb_version_needsrepair(&mp->m_sb)) + if (xfs_has_needsrepair(mp)) strcat(s, ",NEEDSREPAIR"); return s; } @@ -769,7 +769,7 @@ version_f( version = 0x0034 | XFS_SB_VERSION_LOGV2BIT; break; case XFS_SB_VERSION_4: - if (xfs_sb_version_haslogv2(&mp->m_sb)) + if (xfs_has_logv2(mp)) dbprintf( _("version 2 log format is already in use\n")); else @@ -788,7 +788,7 @@ version_f( return 0; } else if (!strcasecmp(argv[1], "attr1")) { - if (xfs_sb_version_hasattr2(&mp->m_sb)) { + if (xfs_has_attr2(mp)) { if (!(mp->m_sb.sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT)) mp->m_sb.sb_versionnum &= diff --git a/db/timelimit.c b/db/timelimit.c index 53a0a399..7b61e980 100644 --- a/db/timelimit.c +++ b/db/timelimit.c @@ -113,7 +113,7 @@ timelimit_f( } if (whatkind == SHOW_AUTO) { - if (xfs_sb_version_hasbigtime(&mp->m_sb)) + if (xfs_has_bigtime(mp)) whatkind = SHOW_BIGTIME; else whatkind = SHOW_CLASSIC; diff --git a/db/write.c b/db/write.c index 0592a099..70cb0518 100644 --- a/db/write.c +++ b/db/write.c @@ -127,7 +127,7 @@ write_f( if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF && - xfs_sb_version_hascrc(&mp->m_sb)) { + xfs_has_crc(mp)) { dbprintf(_("Cannot recalculate CRCs on this type of object\n")); return 0; } @@ -151,7 +151,7 @@ write_f( local_ops.verify_read = stashed_ops->verify_read; iocur_top->bp->b_ops = &local_ops; - if (!xfs_sb_version_hascrc(&mp->m_sb)) { + if (!xfs_has_crc(mp)) { local_ops.verify_write = xfs_dummy_verify; } else if (corrupt) { local_ops.verify_write = xfs_dummy_verify; diff --git a/libxfs/init.c b/libxfs/init.c index 593d0fa2..d36595cf 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -733,7 +733,7 @@ libxfs_mount( /* * Set whether we're using stripe alignment. */ - if (xfs_sb_version_hasdalign(&mp->m_sb)) { + if (xfs_has_dalign(mp)) { mp->m_dalign = sbp->sb_unit; mp->m_swidth = sbp->sb_width; } @@ -786,7 +786,7 @@ libxfs_mount( xfs_da_mount(mp); - if (xfs_sb_version_hasattr2(&mp->m_sb)) + if (xfs_has_attr2(mp)) mp->m_flags |= LIBXFS_MOUNT_ATTR2; /* Initialize the precomputed transaction reservations values */ diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 713ef9af..f4e76029 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1019,7 +1019,7 @@ xfs_verify_magic( struct xfs_mount *mp = bp->b_mount; int idx; - idx = xfs_sb_version_hascrc(&mp->m_sb); + idx = xfs_has_crc(mp); if (unlikely(WARN_ON(!bp->b_ops || !bp->b_ops->magic[idx]))) return false; return dmagic == bp->b_ops->magic[idx]; @@ -1038,7 +1038,7 @@ xfs_verify_magic16( struct xfs_mount *mp = bp->b_mount; int idx; - idx = xfs_sb_version_hascrc(&mp->m_sb); + idx = xfs_has_crc(mp); if (unlikely(WARN_ON(!bp->b_ops || !bp->b_ops->magic16[idx]))) return false; return dmagic == bp->b_ops->magic16[idx]; diff --git a/libxfs/util.c b/libxfs/util.c index 905f1784..9c8230cd 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -44,7 +44,7 @@ xfs_log_calc_unit_res( int iclog_size; uint num_headers; - if (xfs_sb_version_haslogv2(&mp->m_sb)) { + if (xfs_has_logv2(mp)) { iclog_size = XLOG_MAX_RECORD_BSIZE; iclog_header_size = BBTOB(iclog_size / XLOG_HEADER_CYCLE_SIZE); } else { @@ -125,7 +125,7 @@ xfs_log_calc_unit_res( unit_bytes += iclog_header_size; /* for roundoff padding for transaction data and one for commit record */ - if (xfs_sb_version_haslogv2(&mp->m_sb) && mp->m_sb.sb_logsunit > 1) { + if (xfs_has_logv2(mp) && mp->m_sb.sb_logsunit > 1) { /* log su roundoff */ unit_bytes += 2 * mp->m_sb.sb_logsunit; } else { @@ -226,7 +226,7 @@ xfs_inode_propagate_flags( } } else { if ((pip->i_diflags & XFS_DIFLAG_RTINHERIT) && - xfs_sb_version_hasrealtime(&ip->i_mount->m_sb)) + xfs_has_realtime(ip->i_mount)) di_flags |= XFS_DIFLAG_REALTIME; if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) { di_flags |= XFS_DIFLAG_EXTSIZE; @@ -282,7 +282,7 @@ libxfs_init_new_inode( ip->i_extsize = pip ? 0 : fsx->fsx_extsize; ip->i_diflags = pip ? 0 : xfs_flags2diflags(ip, fsx->fsx_xflags); - if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) { + if (xfs_has_v3inodes(ip->i_mount)) { VFS_I(ip)->i_version = 1; ip->i_diflags2 = pip ? ip->i_mount->m_ino_geo.new_diflags2 : xfs_flags2diflags2(ip, fsx->fsx_xflags); @@ -360,7 +360,7 @@ libxfs_iflush_int( ASSERT(ip->i_forkoff <= mp->m_sb.sb_inodesize); /* bump the change count on v3 inodes */ - if (xfs_sb_version_has_v3inode(&mp->m_sb)) + if (xfs_has_v3inodes(mp)) VFS_I(ip)->i_version++; /* diff --git a/logprint/logprint.c b/logprint/logprint.c index 430961ff..3514d013 100644 --- a/logprint/logprint.c +++ b/logprint/logprint.c @@ -86,7 +86,7 @@ logstat(xfs_mount_t *mp) x.logBBsize = XFS_FSB_TO_BB(mp, sb->sb_logblocks); x.logBBstart = XFS_FSB_TO_DADDR(mp, sb->sb_logstart); x.lbsize = BBSIZE; - if (xfs_sb_version_hassector(&mp->m_sb)) + if (xfs_has_sector(mp)) x.lbsize <<= (sb->sb_logsectlog - BBSHIFT); if (!x.logname && sb->sb_logstart == 0) { diff --git a/repair/agbtree.c b/repair/agbtree.c index f20dc9ba..0fd7ef5d 100644 --- a/repair/agbtree.c +++ b/repair/agbtree.c @@ -401,7 +401,7 @@ get_inobt_record( irec->ir_count = inocnt; irec->ir_freecount = finocnt; - if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) { + if (xfs_has_sparseinodes(cur->bc_mp)) { uint64_t sparse; int spmask; uint16_t holemask; @@ -452,7 +452,7 @@ init_ino_cursors( bool finobt; int error; - finobt = xfs_sb_version_hasfinobt(&sc->mp->m_sb); + finobt = xfs_has_finobt(sc->mp); init_rebuild(sc, &XFS_RMAP_OINFO_INOBT, free_space, btr_ino); /* Compute inode statistics. */ @@ -543,7 +543,7 @@ _("Error %d while creating inobt btree for AG %u.\n"), error, agno); /* Since we're not writing the AGI yet, no need to commit the cursor */ libxfs_btree_del_cursor(btr_ino->cur, 0); - if (!xfs_sb_version_hasfinobt(&sc->mp->m_sb)) + if (!xfs_has_finobt(sc->mp)) return; /* Add all observed finobt records. */ @@ -583,7 +583,7 @@ init_rmapbt_cursor( xfs_agnumber_t agno = pag->pag_agno; int error; - if (!xfs_sb_version_hasrmapbt(&sc->mp->m_sb)) + if (!xfs_has_rmapbt(sc->mp)) return; init_rebuild(sc, &XFS_RMAP_OINFO_AG, free_space, btr); @@ -654,7 +654,7 @@ init_refc_cursor( xfs_agnumber_t agno = pag->pag_agno; int error; - if (!xfs_sb_version_hasreflink(&sc->mp->m_sb)) + if (!xfs_has_reflink(sc->mp)) return; init_rebuild(sc, &XFS_RMAP_OINFO_REFC, free_space, btr); diff --git a/repair/agheader.c b/repair/agheader.c index fc62c03a..d8f912f2 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -97,7 +97,7 @@ verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i) /* don't check freespace btrees -- will be checked by caller */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return retval; if (platform_uuid_compare(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid)) { @@ -176,7 +176,7 @@ verify_set_agi(xfs_mount_t *mp, xfs_agi_t *agi, xfs_agnumber_t agno) /* don't check inode btree -- will be checked by caller */ - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return retval; if (platform_uuid_compare(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid)) { @@ -376,7 +376,7 @@ secondary_sb_whack( * superblocks. If it is anything other than 0 it is considered garbage * data beyond the valid sb and explicitly zeroed above. */ - if (xfs_sb_version_haspquotino(&mp->m_sb) && + if (xfs_has_pquotino(mp) && sb->sb_inprogress == 1 && sb->sb_pquotino != NULLFSINO) { if (!no_modify) { sb->sb_pquotino = 0; diff --git a/repair/attr_repair.c b/repair/attr_repair.c index bc3c2bef..df1b519f 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -393,7 +393,7 @@ rmtval_get(xfs_mount_t *mp, xfs_ino_t ino, blkmap_t *blkmap, int hdrsize = 0; int error; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) hdrsize = sizeof(struct xfs_attr3_rmt_hdr); /* ASSUMPTION: valuelen is a valid number, so use it for looping */ diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c index c87a435d..6d494f2d 100644 --- a/repair/dino_chunks.c +++ b/repair/dino_chunks.c @@ -628,7 +628,7 @@ process_inode_chunk( if (cluster_count == 0) cluster_count = 1; - if (xfs_sb_version_hassparseinodes(&mp->m_sb) && + if (xfs_has_sparseinodes(mp) && M_IGEO(mp)->inodes_per_cluster >= XFS_INODES_PER_HOLEMASK_BIT) can_punch_sparse = true; diff --git a/repair/dinode.c b/repair/dinode.c index f39ab2dc..3a79e18e 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -110,7 +110,7 @@ clear_dinode_core(struct xfs_mount *mp, xfs_dinode_t *dinoc, xfs_ino_t ino_num) { memset(dinoc, 0, sizeof(*dinoc)); dinoc->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) dinoc->di_version = 3; else dinoc->di_version = 2; @@ -556,7 +556,7 @@ _("%s fork in inode %" PRIu64 " claims metadata block %" PRIu64 "\n"), case XR_E_INUSE: case XR_E_MULT: if (type == XR_INO_DATA && - xfs_sb_version_hasreflink(&mp->m_sb)) + xfs_has_reflink(mp)) break; do_warn( _("%s fork in %s inode %" PRIu64 " claims used block %" PRIu64 "\n"), @@ -725,7 +725,7 @@ get_agino_buf( } *dipp = xfs_make_iptr(mp, bp, agino - cluster_agino); - ASSERT(!xfs_sb_version_hascrc(&mp->m_sb) || + ASSERT(!xfs_has_crc(mp) || XFS_AGINO_TO_INO(mp, agno, agino) == be64_to_cpu((*dipp)->di_ino)); return bp; @@ -771,7 +771,7 @@ process_btinode( *tot = 0; *nex = 0; - magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_BMAP_CRC_MAGIC + magic = xfs_has_crc(mp) ? XFS_BMAP_CRC_MAGIC : XFS_BMAP_MAGIC; level = be16_to_cpu(dib->bb_level); @@ -1164,7 +1164,7 @@ _("cannot read inode %" PRIu64 ", file block %" PRIu64 ", disk block %" PRIu64 " int bad_dqb = 0; /* We only print the first problem we find */ - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!libxfs_verify_cksum((char *)dqb, sizeof(*dqb), XFS_DQUOT_CRC_OFF)) { @@ -1288,7 +1288,7 @@ _("Bad symlink buffer CRC, block %" PRIu64 ", inode %" PRIu64 ".\n" byte_cnt = min(pathlen, byte_cnt); src = bp->b_addr; - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (!libxfs_symlink_hdr_ok(lino, offset, byte_cnt, bp)) { do_warn( @@ -2297,7 +2297,7 @@ process_dinode_int(xfs_mount_t *mp, * Of course if we make any modifications after this, the inode gets * rewritten, and the CRC is updated automagically. */ - if (xfs_sb_version_hascrc(&mp->m_sb) && + if (xfs_has_crc(mp) && !libxfs_verify_cksum((char *)dino, mp->m_sb.sb_inodesize, XFS_DINODE_CRC_OFF)) { retval = 1; @@ -2339,7 +2339,7 @@ process_dinode_int(xfs_mount_t *mp, if (!no_modify) { do_warn(_(" resetting version number\n")); dino->di_version = - xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2; + xfs_has_crc(mp) ? 3 : 2; *dirty = 1; } else do_warn(_(" would reset version number\n")); @@ -2368,7 +2368,7 @@ process_dinode_int(xfs_mount_t *mp, * we are called here that the inode has not already been modified in * memory and hence invalidated the CRC. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { if (be64_to_cpu(dino->di_ino) != lino) { if (!uncertain) do_warn( @@ -2573,7 +2573,7 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), } if ((flags2 & XFS_DIFLAG2_REFLINK) && - !xfs_sb_version_hasreflink(&mp->m_sb)) { + !xfs_has_reflink(mp)) { if (!uncertain) { do_warn( _("inode %" PRIu64 " is marked reflinked but file system does not support reflink\n"), @@ -2605,7 +2605,7 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), } if ((flags2 & XFS_DIFLAG2_COWEXTSIZE) && - !xfs_sb_version_hasreflink(&mp->m_sb)) { + !xfs_has_reflink(mp)) { if (!uncertain) { do_warn( _("inode %" PRIu64 " has CoW extent size hint but file system does not support reflink\n"), @@ -2637,7 +2637,7 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), } if (xfs_dinode_has_bigtime(dino) && - !xfs_sb_version_hasbigtime(&mp->m_sb)) { + !xfs_has_bigtime(mp)) { if (!uncertain) { do_warn( _("inode %" PRIu64 " is marked bigtime but file system does not support large timestamps\n"), diff --git a/repair/incore.h b/repair/incore.h index d64315fd..65c03dde 100644 --- a/repair/incore.h +++ b/repair/incore.h @@ -647,7 +647,7 @@ inorec_get_freecount( struct xfs_mount *mp, struct xfs_inobt_rec *rp) { - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) return rp->ir_u.sp.ir_freecount; return be32_to_cpu(rp->ir_u.f.ir_freecount); } @@ -658,7 +658,7 @@ inorec_set_freecount( struct xfs_inobt_rec *rp, int freecount) { - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) rp->ir_u.sp.ir_freecount = freecount; else rp->ir_u.f.ir_freecount = cpu_to_be32(freecount); diff --git a/repair/incore_ino.c b/repair/incore_ino.c index 299e4f94..0dd7a2f0 100644 --- a/repair/incore_ino.c +++ b/repair/incore_ino.c @@ -211,7 +211,7 @@ alloc_ftypes_array( { uint8_t *ptr; - if (!xfs_sb_version_hasftype(&mp->m_sb)) + if (!xfs_has_ftype(mp)) return NULL; ptr = calloc(XFS_INODES_PER_CHUNK, sizeof(*ptr)); diff --git a/repair/phase2.c b/repair/phase2.c index 81c01526..f6174172 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -34,7 +34,7 @@ zero_log( x.logBBsize = XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); x.logBBstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); x.lbsize = BBSIZE; - if (xfs_sb_version_hassector(&mp->m_sb)) + if (xfs_has_sector(mp)) x.lbsize <<= (mp->m_sb.sb_logsectlog - BBSHIFT); log->l_dev = mp->m_logdev_targp; @@ -42,13 +42,13 @@ zero_log( log->l_logBBstart = x.logBBstart; log->l_sectBBsize = BTOBB(x.lbsize); log->l_mp = mp; - if (xfs_sb_version_hassector(&mp->m_sb)) { + if (xfs_has_sector(mp)) { log->l_sectbb_log = mp->m_sb.sb_logsectlog - BBSHIFT; ASSERT(log->l_sectbb_log <= mp->m_sectbb_log); /* for larger sector sizes, must have v2 or external log */ ASSERT(log->l_sectbb_log == 0 || log->l_logBBstart == 0 || - xfs_sb_version_haslogv2(&mp->m_sb)); + xfs_has_logv2(mp)); ASSERT(mp->m_sb.sb_logsectlog >= BBSHIFT); } log->l_sectbb_mask = (1 << log->l_sectbb_log) - 1; @@ -111,7 +111,7 @@ zero_log( XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks), &mp->m_sb.sb_uuid, - xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1, + xfs_has_logv2(mp) ? 2 : 1, mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE, true); /* update the log data structure with new state */ @@ -127,7 +127,7 @@ zero_log( * Finally, seed the max LSN from the current state of the log if this * is a v5 filesystem. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) libxfs_max_lsn = log->l_last_sync_lsn; } @@ -135,19 +135,19 @@ static bool set_inobtcount( struct xfs_mount *mp) { - if (!xfs_sb_version_hascrc(&mp->m_sb)) { + if (!xfs_has_crc(mp)) { printf( _("Inode btree count feature only supported on V5 filesystems.\n")); exit(0); } - if (!xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (!xfs_has_finobt(mp)) { printf( _("Inode btree count feature requires free inode btree.\n")); exit(0); } - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) { + if (xfs_has_inobtcounts(mp)) { printf(_("Filesystem already has inode btree counts.\n")); exit(0); } @@ -162,13 +162,13 @@ static bool set_bigtime( struct xfs_mount *mp) { - if (!xfs_sb_version_hascrc(&mp->m_sb)) { + if (!xfs_has_crc(mp)) { printf( _("Large timestamp feature only supported on V5 filesystems.\n")); exit(0); } - if (xfs_sb_version_hasbigtime(&mp->m_sb)) { + if (xfs_has_bigtime(mp)) { printf(_("Filesystem already supports large timestamps.\n")); exit(0); } diff --git a/repair/phase4.c b/repair/phase4.c index eb043002..2260f6a3 100644 --- a/repair/phase4.c +++ b/repair/phase4.c @@ -240,7 +240,7 @@ process_rmap_data( queue_work(&wq, check_rmap_btrees, i, NULL); destroy_work_queue(&wq); - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return; create_work_queue(&wq, mp, platform_nproc()); diff --git a/repair/phase5.c b/repair/phase5.c index 79a8dbc2..74b1dcb9 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -162,17 +162,17 @@ build_agi( for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) agi->agi_unlinked[i] = cpu_to_be32(NULLAGINO); - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) platform_uuid_copy(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid); - if (xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (xfs_has_finobt(mp)) { agi->agi_free_root = cpu_to_be32(btr_fino->newbt.afake.af_root); agi->agi_free_level = cpu_to_be32(btr_fino->newbt.afake.af_levels); } - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) { + if (xfs_has_inobtcounts(mp)) { agi->agi_iblocks = cpu_to_be32(btr_ino->newbt.afake.af_blocks); agi->agi_fblocks = cpu_to_be32(btr_fino->newbt.afake.af_blocks); } @@ -265,7 +265,7 @@ build_agf_agfl( cpu_to_be32(btr_cnt->newbt.afake.af_levels); agf->agf_freeblks = cpu_to_be32(btr_bno->freeblks); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (xfs_has_rmapbt(mp)) { agf->agf_roots[XFS_BTNUM_RMAP] = cpu_to_be32(btr_rmap->newbt.afake.af_root); agf->agf_levels[XFS_BTNUM_RMAP] = @@ -274,7 +274,7 @@ build_agf_agfl( cpu_to_be32(btr_rmap->newbt.afake.af_blocks); } - if (xfs_sb_version_hasreflink(&mp->m_sb)) { + if (xfs_has_reflink(mp)) { agf->agf_refcount_root = cpu_to_be32(btr_refc->newbt.afake.af_root); agf->agf_refcount_level = @@ -286,7 +286,7 @@ build_agf_agfl( /* * Count and record the number of btree blocks consumed if required. */ - if (xfs_sb_version_haslazysbcount(&mp->m_sb)) { + if (xfs_has_lazysbcount(mp)) { unsigned int blks; /* * Don't count the root blocks as they are already @@ -294,7 +294,7 @@ build_agf_agfl( */ blks = btr_bno->newbt.afake.af_blocks + btr_cnt->newbt.afake.af_blocks - 2; - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) blks += btr_rmap->newbt.afake.af_blocks - 1; agf->agf_btreeblks = cpu_to_be32(blks); #ifdef XR_BLD_FREE_TRACE @@ -311,7 +311,7 @@ build_agf_agfl( XFS_BTNUM_CNT); #endif - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) platform_uuid_copy(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid); /* initialise the AGFL, then fill it if there are blocks left over. */ @@ -327,7 +327,7 @@ build_agf_agfl( /* setting to 0xff results in initialisation to NULLAGBLOCK */ memset(agfl, 0xff, mp->m_sb.sb_sectsize); freelist = xfs_buf_to_agfl_bno(agfl_buf); - if (xfs_sb_version_hascrc(&mp->m_sb)) { + if (xfs_has_crc(mp)) { agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC); agfl->agfl_seqno = cpu_to_be32(agno); platform_uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid); @@ -340,7 +340,7 @@ build_agf_agfl( freelist = xfs_buf_to_agfl_bno(agfl_buf); fill_agfl(btr_bno, freelist, &agfl_idx); fill_agfl(btr_cnt, freelist, &agfl_idx); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) fill_agfl(btr_rmap, freelist, &agfl_idx); /* Set the AGF counters for the AGFL. */ @@ -538,12 +538,12 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), #endif ASSERT(btr_bno.freeblks == btr_cnt.freeblks); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (xfs_has_rmapbt(mp)) { build_rmap_tree(&sc, agno, &btr_rmap); sb_fdblocks_ag[agno] += btr_rmap.newbt.afake.af_blocks - 1; } - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) build_refcount_tree(&sc, agno, &btr_refc); /* @@ -563,11 +563,11 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), finish_rebuild(mp, &btr_bno, lost_blocks); finish_rebuild(mp, &btr_cnt, lost_blocks); finish_rebuild(mp, &btr_ino, lost_blocks); - if (xfs_sb_version_hasfinobt(&mp->m_sb)) + if (xfs_has_finobt(mp)) finish_rebuild(mp, &btr_fino, lost_blocks); - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_has_rmapbt(mp)) finish_rebuild(mp, &btr_rmap, lost_blocks); - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) finish_rebuild(mp, &btr_refc, lost_blocks); /* diff --git a/repair/phase6.c b/repair/phase6.c index 696a6427..647dc1c5 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -505,7 +505,7 @@ mk_rbmino(xfs_mount_t *mp) set_nlink(VFS_I(ip), 1); /* account for sb ptr */ times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD; - if (xfs_sb_version_has_v3inode(&mp->m_sb)) { + if (xfs_has_v3inodes(mp)) { VFS_I(ip)->i_version = 1; ip->i_diflags2 = 0; times |= XFS_ICHGTIME_CREATE; @@ -745,7 +745,7 @@ mk_rsumino(xfs_mount_t *mp) set_nlink(VFS_I(ip), 1); /* account for sb ptr */ times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD; - if (xfs_sb_version_has_v3inode(&mp->m_sb)) { + if (xfs_has_v3inodes(mp)) { VFS_I(ip)->i_version = 1; ip->i_diflags2 = 0; times |= XFS_ICHGTIME_CREATE; @@ -844,7 +844,7 @@ mk_root_dir(xfs_mount_t *mp) set_nlink(VFS_I(ip), 2); /* account for . and .. */ times = XFS_ICHGTIME_CHG | XFS_ICHGTIME_MOD; - if (xfs_sb_version_has_v3inode(&mp->m_sb)) { + if (xfs_has_v3inodes(mp)) { VFS_I(ip)->i_version = 1; ip->i_diflags2 = 0; times |= XFS_ICHGTIME_CREATE; @@ -1474,13 +1474,13 @@ longform_dir2_entry_check_data( endptr = (char *)blp; if (endptr > (char *)btp) endptr = (char *)btp; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) wantmagic = XFS_DIR3_BLOCK_MAGIC; else wantmagic = XFS_DIR2_BLOCK_MAGIC; } else { endptr = (char *)d + mp->m_dir_geo->blksize; - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) wantmagic = XFS_DIR3_DATA_MAGIC; else wantmagic = XFS_DIR2_DATA_MAGIC; @@ -1787,7 +1787,7 @@ longform_dir2_entry_check_data( continue; /* validate ftype field if supported */ - if (xfs_sb_version_hasftype(&mp->m_sb)) { + if (xfs_has_ftype(mp)) { uint8_t dir_ftype; uint8_t ino_ftype; @@ -2684,7 +2684,7 @@ _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is a duplicate name"), } /* validate ftype field if supported */ - if (xfs_sb_version_hasftype(&mp->m_sb)) { + if (xfs_has_ftype(mp)) { uint8_t dir_ftype; uint8_t ino_ftype; diff --git a/repair/quotacheck.c b/repair/quotacheck.c index 5e007a18..758160d3 100644 --- a/repair/quotacheck.c +++ b/repair/quotacheck.c @@ -252,7 +252,7 @@ qc_dquot_check_type( * expect an exact match for user dquots and for non-root group and * project dquots. */ - if (xfs_sb_version_hascrc(&mp->m_sb) || type == XFS_DQTYPE_USER || id) + if (xfs_has_crc(mp) || type == XFS_DQTYPE_USER || id) return ddq_type == type; /* @@ -325,7 +325,7 @@ qc_check_dquot( } if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && - !xfs_sb_version_hasbigtime(&mp->m_sb)) { + !xfs_has_bigtime(mp)) { do_warn( _("%s id %u is marked bigtime but file system does not support large timestamps\n"), qflags_typestr(dquots->type), id); diff --git a/repair/rmap.c b/repair/rmap.c index 12fe7442..e48f6c1e 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -49,8 +49,8 @@ bool rmap_needs_work( struct xfs_mount *mp) { - return xfs_sb_version_hasreflink(&mp->m_sb) || - xfs_sb_version_hasrmapbt(&mp->m_sb); + return xfs_has_reflink(mp) || + xfs_has_rmapbt(mp); } /* @@ -387,7 +387,7 @@ rmap_add_fixed_ag_rec( /* inodes */ ino_rec = findfirst_inode_rec(agno); for (; ino_rec != NULL; ino_rec = next_ino_rec(ino_rec)) { - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) { + if (xfs_has_sparseinodes(mp)) { startidx = find_first_zero_bit(ino_rec->ir_sparse); nr = XFS_INODES_PER_CHUNK - popcnt(ino_rec->ir_sparse); } else { @@ -455,7 +455,7 @@ rmap_store_ag_btree_rec( struct bitmap *own_ag_bitmap = NULL; int error = 0; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 0; /* Release the ar_rmaps; they were put into the rmapbt during p5. */ @@ -761,7 +761,7 @@ compute_refcounts( size_t old_stack_nr; int error; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return 0; rmaps = ag_rmaps[agno].ar_rmaps; @@ -988,7 +988,7 @@ rmaps_verify_btree( int have; int error; - if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (!xfs_has_rmapbt(mp)) return 0; if (rmapbt_suspect) { if (no_modify && agno == 0) @@ -1025,7 +1025,7 @@ rmaps_verify_btree( * the regular lookup doesn't find anything or if it doesn't * match the observed rmap. */ - if (xfs_sb_version_hasreflink(&bt_cur->bc_mp->m_sb) && + if (xfs_has_reflink(bt_cur->bc_mp) && (!have || !rmap_is_good(rm_rec, &tmp))) { error = rmap_lookup_overlapped(bt_cur, rm_rec, &tmp, &have); @@ -1350,7 +1350,7 @@ check_refcounts( int i; int error; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) + if (!xfs_has_reflink(mp)) return 0; if (refcbt_suspect) { if (no_modify && agno == 0) diff --git a/repair/scan.c b/repair/scan.c index 52de8a04..909c4494 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -806,7 +806,7 @@ ino_issparse( struct xfs_inobt_rec *rp, int offset) { - if (!xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (!xfs_has_sparseinodes(mp)) return false; return xfs_inobt_is_sparse_disk(rp, offset); @@ -908,7 +908,7 @@ _("in use block (%d,%d-%d) mismatch in %s tree, state - %d,%" PRIx64 "\n"), * multiple inode owners are ok with * reflink enabled */ - if (xfs_sb_version_hasreflink(&mp->m_sb) && + if (xfs_has_reflink(mp) && !XFS_RMAP_NON_INODE_OWNER(owner)) break; fallthrough; @@ -1125,7 +1125,7 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), } else { bool bad; - if (xfs_sb_version_hasreflink(&mp->m_sb)) + if (xfs_has_reflink(mp)) bad = !rmap_in_order(b, laststartblock, owner, lastowner, offset, lastoffset); @@ -1762,7 +1762,7 @@ _("ir_freecount/free mismatch, inode chunk %d/%u, freecount %d nfree %d\n"), } /* verify sparse record formats have a valid inode count */ - if (xfs_sb_version_hassparseinodes(&mp->m_sb) && + if (xfs_has_sparseinodes(mp) && ninodes != rp->ir_u.sp.ir_count) { do_warn( _("invalid inode count, inode chunk %d/%u, count %d ninodes %d\n"), @@ -1938,7 +1938,7 @@ _("finobt record with no free inodes, inode chunk %d/%u\n"), agno, ino); } /* verify sparse record formats have a valid inode count */ - if (xfs_sb_version_hassparseinodes(&mp->m_sb) && + if (xfs_has_sparseinodes(mp) && ninodes != rp->ir_u.sp.ir_count) { do_warn( _("invalid inode count, inode chunk %d/%u, count %d ninodes %d\n"), @@ -2104,7 +2104,7 @@ _("%sbt btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), * ir_count holds the inode count for all * records on fs' with sparse inode support */ - if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + if (xfs_has_sparseinodes(mp)) icount = rp[i].ir_u.sp.ir_count; agcnts->agicount += icount; @@ -2264,7 +2264,7 @@ validate_agf( bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]); if (libxfs_verify_agbno(mp, agno, bno)) { - magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_ABTB_CRC_MAGIC + magic = xfs_has_crc(mp) ? XFS_ABTB_CRC_MAGIC : XFS_ABTB_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), agno, 0, scan_allocbt, 1, magic, agcnts, @@ -2276,7 +2276,7 @@ validate_agf( bno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]); if (libxfs_verify_agbno(mp, agno, bno)) { - magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_ABTC_CRC_MAGIC + magic = xfs_has_crc(mp) ? XFS_ABTC_CRC_MAGIC : XFS_ABTC_MAGIC; scan_sbtree(bno, be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), agno, 0, scan_allocbt, 1, magic, agcnts, @@ -2286,7 +2286,7 @@ validate_agf( bno, agno); } - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + if (xfs_has_rmapbt(mp)) { struct rmap_priv priv; unsigned int levels; @@ -2319,7 +2319,7 @@ validate_agf( } } - if (xfs_sb_version_hasreflink(&mp->m_sb)) { + if (xfs_has_reflink(mp)) { unsigned int levels; levels = be32_to_cpu(agf->agf_refcount_level); @@ -2358,7 +2358,7 @@ validate_agf( be32_to_cpu(agf->agf_longest), agcnts->agflongest, agno); } - if (xfs_sb_version_haslazysbcount(&mp->m_sb) && + if (xfs_has_lazysbcount(mp) && be32_to_cpu(agf->agf_btreeblks) != agcnts->agfbtreeblks) { do_warn(_("agf_btreeblks %u, counted %" PRIu64 " in ag %u\n"), be32_to_cpu(agf->agf_btreeblks), agcnts->agfbtreeblks, agno); @@ -2381,7 +2381,7 @@ validate_agi( bno = be32_to_cpu(agi->agi_root); if (libxfs_verify_agbno(mp, agno, bno)) { - magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_IBT_CRC_MAGIC + magic = xfs_has_crc(mp) ? XFS_IBT_CRC_MAGIC : XFS_IBT_MAGIC; scan_sbtree(bno, be32_to_cpu(agi->agi_level), agno, 0, scan_inobt, 1, magic, &priv, @@ -2391,10 +2391,10 @@ validate_agi( be32_to_cpu(agi->agi_root), agno); } - if (xfs_sb_version_hasfinobt(&mp->m_sb)) { + if (xfs_has_finobt(mp)) { bno = be32_to_cpu(agi->agi_free_root); if (libxfs_verify_agbno(mp, agno, bno)) { - magic = xfs_sb_version_hascrc(&mp->m_sb) ? + magic = xfs_has_crc(mp) ? XFS_FIBT_CRC_MAGIC : XFS_FIBT_MAGIC; scan_sbtree(bno, be32_to_cpu(agi->agi_free_level), agno, 0, scan_inobt, 1, magic, &priv, @@ -2405,7 +2405,7 @@ validate_agi( } } - if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) { + if (xfs_has_inobtcounts(mp)) { if (be32_to_cpu(agi->agi_iblocks) != priv.ino_blocks) do_warn(_("bad inobt block count %u, saw %u\n"), be32_to_cpu(agi->agi_iblocks), @@ -2426,7 +2426,7 @@ validate_agi( be32_to_cpu(agi->agi_freecount), agcnts->agifreecount, agno); } - if (xfs_sb_version_hasfinobt(&mp->m_sb) && + if (xfs_has_finobt(mp) && be32_to_cpu(agi->agi_freecount) != agcnts->fibtfreecount) { do_warn(_("agi_freecount %u, counted %u in ag %u finobt\n"), be32_to_cpu(agi->agi_freecount), agcnts->fibtfreecount, diff --git a/repair/versions.c b/repair/versions.c index 0b5376d7..b24965b2 100644 --- a/repair/versions.c +++ b/repair/versions.c @@ -33,10 +33,10 @@ void update_sb_version( struct xfs_mount *mp) { - if (fs_attributes && !xfs_sb_version_hasattr(&mp->m_sb)) + if (fs_attributes && !xfs_has_attr(mp)) xfs_sb_version_addattr(&mp->m_sb); - if (fs_attributes2 && !xfs_sb_version_hasattr2(&mp->m_sb)) + if (fs_attributes2 && !xfs_has_attr2(mp)) xfs_sb_version_addattr2(&mp->m_sb); /* V2 inode conversion is now always going to happen */ @@ -49,7 +49,7 @@ update_sb_version( * have quotas. */ if (fs_quotas) { - if (!xfs_sb_version_hasquota(&mp->m_sb)) + if (!xfs_has_quota(mp)) xfs_sb_version_addquota(&mp->m_sb); /* @@ -74,13 +74,13 @@ update_sb_version( } else { mp->m_sb.sb_qflags = 0; - if (xfs_sb_version_hasquota(&mp->m_sb)) { + if (xfs_has_quota(mp)) { lost_quotas = 1; mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT; } } - if (!fs_aligned_inodes && xfs_sb_version_hasalign(&mp->m_sb)) + if (!fs_aligned_inodes && xfs_has_align(mp)) mp->m_sb.sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; mp->m_features &= ~(XFS_FEAT_QUOTA | XFS_FEAT_ALIGN); @@ -142,10 +142,10 @@ _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n" return 1; } - if (xfs_sb_version_hasattr(&mp->m_sb)) + if (xfs_has_attr(mp)) fs_attributes = 1; - if (xfs_sb_version_hasattr2(&mp->m_sb)) + if (xfs_has_attr2(mp)) fs_attributes2 = 1; if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) { @@ -162,7 +162,7 @@ _("WARNING: you have a V1 inode filesystem. It would be converted to a\n" } } - if (xfs_sb_version_hasquota(&mp->m_sb)) { + if (xfs_has_quota(mp)) { fs_quotas = 1; if (mp->m_sb.sb_uquotino != 0 && mp->m_sb.sb_uquotino != NULLFSINO) @@ -175,7 +175,7 @@ _("WARNING: you have a V1 inode filesystem. It would be converted to a\n" have_pquotino = 1; } - if (xfs_sb_version_hasalign(&mp->m_sb)) { + if (xfs_has_align(mp)) { fs_aligned_inodes = 1; fs_ino_alignment = mp->m_sb.sb_inoalignmt; } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 7a142ceb..abde6fe8 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -640,7 +640,7 @@ format_log_max_lsn( xfs_daddr_t logblocks; int logversion; - if (!xfs_sb_version_hascrc(&mp->m_sb)) + if (!xfs_has_crc(mp)) return; /* @@ -660,7 +660,7 @@ format_log_max_lsn( new_cycle = max_cycle + 3; logstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); logblocks = XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); - logversion = xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1; + logversion = xfs_has_logv2(mp) ? 2 : 1; do_warn(_("Maximum metadata LSN (%d:%d) is ahead of log (%d:%d).\n"), max_cycle, max_block, log->l_curr_cycle, log->l_curr_block); @@ -793,7 +793,7 @@ force_needsrepair( struct xfs_buf *bp; int error; - if (!xfs_sb_version_hascrc(&mp->m_sb) || + if (!xfs_has_crc(mp) || xfs_sb_version_needsrepair(&mp->m_sb)) return; @@ -982,7 +982,7 @@ main(int argc, char **argv) mp->m_flags |= LIBXFS_MOUNT_WANT_CORRUPTED; /* Capture the first writeback so that we can set needsrepair. */ - if (xfs_sb_version_hascrc(&mp->m_sb)) + if (xfs_has_crc(mp)) mp->m_buf_writeback_fn = repair_capture_writeback; /* From patchwork Tue Sep 14 02:43:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD662C433F5 for ; Tue, 14 Sep 2021 02:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C66F0606A5 for ; Tue, 14 Sep 2021 02:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhINCoY (ORCPT ); Mon, 13 Sep 2021 22:44:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCoX (ORCPT ); Mon, 13 Sep 2021 22:44:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BE2B610D1; Tue, 14 Sep 2021 02:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587386; bh=ZnC/pFslMfH5VrW40wh0wjExF7WWyEQj2IXEehFIz7s=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mzcx0BKv5D1N5nwhGFO8v1wGcEVzYjK47GWtgxRC8sjr2weIH3iPA3iiRtRPxxn8n oGhkTcdJgoGQfpVHedU0MgrCfKbsrp+T0TpRUNfaK+lQtnNQ6Rok4tPByVJexQR3o6 rsd0msav14795KLLr5yDNwJuiL0b1nsD/NXCHwizoh7BIqo7edkOhocgAzblas515W gEfmJ3FJsi81cYNygh8vh/n6S8O57grDgvkhhCzmGWAE6eUgPtM8he92HD45GeNJJ8 QMMy+4OZKC1Tucts7FqwCzqjSyEjzjUcbBl8eX7bnVourKkdf88X77KqBhgADE0taf 1+7tNvA8hM9MQ== Subject: [PATCH 34/43] xfs: remove unused xfs_sb_version_has wrappers From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:05 -0700 Message-ID: <163158738595.1604118.13311984301163047176.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 2beb7b50ddd429f47b6cabd186b3102d2a6aa505 The vast majority of these wrappers are now unused. Remove them leaving just the small subset of wrappers that are used to either add feature bits or make the mount features field setup code simpler. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/libxfs.h | 56 ++++++++++++++++++ libxfs/xfs_format.h | 155 +-------------------------------------------------- 2 files changed, 59 insertions(+), 152 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 1d874fcb..04cf0e1f 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -217,4 +217,60 @@ bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); #include "xfs_attr.h" #include "topology.h" +/* + * Superblock helpers for programs that act on independent superblock + * structures. These used to be part of xfs_format.h. + */ +static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) +{ + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || + (xfs_sb_version_hasmorebits(sbp) && + (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); +} + +static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; +} + +static inline bool xfs_sb_version_hasmetauuid(struct xfs_sb *sbp) +{ + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID); +} + +static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) +{ + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || + (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); +} + +static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) +{ + return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); +} + +static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || + (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); +} + +static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) +{ + return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); +} + +static inline bool xfs_sb_version_needsrepair(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR); +} + +static inline bool xfs_sb_version_hassparseinodes(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_SPINODES); +} + #endif /* __LIBXFS_H__ */ diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 242bf251..00d19d18 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -279,11 +279,6 @@ typedef struct xfs_dsb { #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) -static inline bool xfs_sb_version_hasrealtime(struct xfs_sb *sbp) -{ - return sbp->sb_rblocks > 0; -} - /* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. @@ -293,9 +288,10 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) return sbp->sb_bad_features2 != sbp->sb_features2; } -static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp) +static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) { - return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT); + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || + (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); } static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) @@ -303,79 +299,17 @@ static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; } -static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp) -{ - return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); -} - static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) { sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; } -static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || - (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); -} - -static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) -{ - return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); -} - -static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || - (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); -} - -static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) -{ - return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); -} - -static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp) -{ - return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); -} - -static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || - (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); -} - -/* - * sb_features2 bit version macros. - */ -static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || - (xfs_sb_version_hasmorebits(sbp) && - (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); -} - -static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || - (xfs_sb_version_hasmorebits(sbp) && - (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT)); -} - static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) { sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; } -static inline bool xfs_sb_version_hasprojid32(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || - (xfs_sb_version_hasmorebits(sbp) && - (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); -} - static inline void xfs_sb_version_addprojid32(struct xfs_sb *sbp) { sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; @@ -474,13 +408,6 @@ xfs_sb_add_incompat_log_features( sbp->sb_features_log_incompat |= features; } -/* - * V5 superblock specific feature checks - */ -static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; -} /* * v5 file systems support V3 inodes only, earlier file systems support @@ -499,82 +426,6 @@ static inline bool xfs_dinode_good_version(struct xfs_sb *sbp, return version == 1 || version == 2; } -static inline bool xfs_sb_version_haspquotino(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; -} - -static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || - (xfs_sb_version_hasmorebits(sbp) && - (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); -} - -static inline bool xfs_sb_version_hasfinobt(xfs_sb_t *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && - (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT); -} - -static inline bool xfs_sb_version_hassparseinodes(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_SPINODES); -} - -/* - * XFS_SB_FEAT_INCOMPAT_META_UUID indicates that the metadata UUID - * is stored separately from the user-visible UUID; this allows the - * user-visible UUID to be changed on V5 filesystems which have a - * filesystem UUID stamped into every piece of metadata. - */ -static inline bool xfs_sb_version_hasmetauuid(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && - (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID); -} - -static inline bool xfs_sb_version_hasrmapbt(struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && - (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_RMAPBT); -} - -static inline bool xfs_sb_version_hasreflink(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK); -} - -static inline bool xfs_sb_version_hasbigtime(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_BIGTIME); -} - -/* - * Inode btree block counter. We record the number of inobt and finobt blocks - * in the AGI header so that we can skip the finobt walk at mount time when - * setting up per-AG reservations. - */ -static inline bool xfs_sb_version_hasinobtcounts(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT); -} - -static inline bool xfs_sb_version_needsrepair(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && - (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR); -} - -/* - * end of superblock version macros - */ - static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) { From patchwork Tue Sep 14 02:43:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E44C433F5 for ; Tue, 14 Sep 2021 02:43:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F130610D1 for ; Tue, 14 Sep 2021 02:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbhINCoa (ORCPT ); Mon, 13 Sep 2021 22:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:53964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbhINCo2 (ORCPT ); Mon, 13 Sep 2021 22:44:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB029606A5; Tue, 14 Sep 2021 02:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587391; bh=BPw+joGeRWhVGQbiB4/8ZsSLHMiYHqI5IOVKLY1nnVc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=akr4CwJTYJYhzaJteozGK7yCEOB+jaRvDMxH8hNCHupAndFpIf0/rZDw0RrdXjhU6 MRKltTXCaSijOZ+6fOChvb+Qp1sWrIKMSM0hhn61q0CX215JzLSgZ+GElnYDdiKoEb a0D5UIXacuwHW8jVljtkHRovs9+U2ItsAdC4jVZbaCwF0hSlBQd9qxAQp0Ke5qE70O ZOcaUuL5nxXY/0O8rTdU0LMKoAjKKvXpjXbHQTcpNqVSUl6qJaWdesHXAVMJIo0LzY blDd6Dqn07UinbGy6sT5G3NXwzEbqZB3RPZ7R/k9doFuEHUpp7nDiDuY0TE5+i3la9 maQ3aRFKMrpBw== Subject: [PATCH 35/43] xfs: introduce xfs_sb_is_v5 helper From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:11 -0700 Message-ID: <163158739143.1604118.2591659099155333338.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: d6837c1aab42e70141fd3875ba05eb69ffb220f0 Rather than open coding XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 checks everywhere, add a simple wrapper to encapsulate this and make the code easier to read. This allows us to remove the xfs_sb_version_has_v3inode() wrapper which is only used in xfs_format.h now and is just a version number check. There are a couple of places where we should be checking the mount feature bits rather than the superblock version (e.g. remount), so those are converted to use xfs_has_crc(mp) instead. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/xfs_format.h | 16 ++++++++-------- libxfs/xfs_sb.c | 45 +++++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 00d19d18..ee479feb 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -279,6 +279,11 @@ typedef struct xfs_dsb { #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) +static inline bool xfs_sb_is_v5(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; +} + /* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. @@ -290,7 +295,7 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) { - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || + return xfs_sb_is_v5(sbp) || (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); } @@ -413,15 +418,10 @@ xfs_sb_add_incompat_log_features( * v5 file systems support V3 inodes only, earlier file systems support * v2 and v1 inodes. */ -static inline bool xfs_sb_version_has_v3inode(struct xfs_sb *sbp) -{ - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; -} - static inline bool xfs_dinode_good_version(struct xfs_sb *sbp, uint8_t version) { - if (xfs_sb_version_has_v3inode(sbp)) + if (xfs_sb_is_v5(sbp)) return version == 3; return version == 1 || version == 2; } @@ -893,7 +893,7 @@ enum xfs_dinode_fmt { * Inode size for given fs. */ #define XFS_DINODE_SIZE(sbp) \ - (xfs_sb_version_has_v3inode(sbp) ? \ + (xfs_sb_is_v5(sbp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc)) #define XFS_LITINO(mp) \ diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 18be9164..198d211e 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -36,7 +36,7 @@ xfs_sb_good_version( struct xfs_sb *sbp) { /* all v5 filesystems are supported */ - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) + if (xfs_sb_is_v5(sbp)) return true; /* versions prior to v4 are not supported */ @@ -95,7 +95,7 @@ xfs_sb_version_to_features( features |= XFS_FEAT_FTYPE; } - if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5) + if (!xfs_sb_is_v5(sbp)) return features; /* Always on V5 features */ @@ -131,7 +131,7 @@ xfs_validate_sb_read( struct xfs_mount *mp, struct xfs_sb *sbp) { - if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5) + if (!xfs_sb_is_v5(sbp)) return 0; /* @@ -198,7 +198,7 @@ xfs_validate_sb_write( return -EFSCORRUPTED; } - if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5) + if (!xfs_sb_is_v5(sbp)) return 0; /* @@ -272,7 +272,7 @@ xfs_validate_sb_common( /* * Validate feature flags and state */ - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) { + if (xfs_sb_is_v5(sbp)) { if (sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) { xfs_notice(mp, "Block size (%u bytes) too small for Version 5 superblock (minimum %d bytes)", @@ -463,7 +463,7 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) * We need to do these manipilations only if we are working * with an older version of on-disk superblock. */ - if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_5) + if (xfs_sb_is_v5(sbp)) return; if (sbp->sb_qflags & XFS_OQUOTA_ENFD) @@ -556,7 +556,7 @@ __xfs_sb_from_disk( * sb_meta_uuid is only on disk if it differs from sb_uuid and the * feature flag is set; if not set we keep it only in memory. */ - if (XFS_SB_VERSION_NUM(to) == XFS_SB_VERSION_5 && + if (xfs_sb_is_v5(to) && (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID)) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); else @@ -587,7 +587,7 @@ xfs_sb_quota_to_disk( * The in-memory superblock quota state matches the v5 on-disk format so * just write them out and return */ - if (XFS_SB_VERSION_NUM(from) == XFS_SB_VERSION_5) { + if (xfs_sb_is_v5(from)) { to->sb_qflags = cpu_to_be16(from->sb_qflags); to->sb_gquotino = cpu_to_be64(from->sb_gquotino); to->sb_pquotino = cpu_to_be64(from->sb_pquotino); @@ -697,19 +697,20 @@ xfs_sb_to_disk( to->sb_features2 = cpu_to_be32(from->sb_features2); to->sb_bad_features2 = cpu_to_be32(from->sb_bad_features2); - if (XFS_SB_VERSION_NUM(from) == XFS_SB_VERSION_5) { - to->sb_features_compat = cpu_to_be32(from->sb_features_compat); - to->sb_features_ro_compat = - cpu_to_be32(from->sb_features_ro_compat); - to->sb_features_incompat = - cpu_to_be32(from->sb_features_incompat); - to->sb_features_log_incompat = - cpu_to_be32(from->sb_features_log_incompat); - to->sb_spino_align = cpu_to_be32(from->sb_spino_align); - to->sb_lsn = cpu_to_be64(from->sb_lsn); - if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) - uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); - } + if (!xfs_sb_is_v5(from)) + return; + + to->sb_features_compat = cpu_to_be32(from->sb_features_compat); + to->sb_features_ro_compat = + cpu_to_be32(from->sb_features_ro_compat); + to->sb_features_incompat = + cpu_to_be32(from->sb_features_incompat); + to->sb_features_log_incompat = + cpu_to_be32(from->sb_features_log_incompat); + to->sb_spino_align = cpu_to_be32(from->sb_spino_align); + to->sb_lsn = cpu_to_be64(from->sb_lsn); + if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) + uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); } /* @@ -812,7 +813,7 @@ xfs_sb_write_verify( if (error) goto out_error; - if (XFS_SB_VERSION_NUM(&sb) != XFS_SB_VERSION_5) + if (!xfs_sb_is_v5(&sb)) return; if (bip) From patchwork Tue Sep 14 02:43:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 038F4C433F5 for ; Tue, 14 Sep 2021 02:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFF1C61108 for ; Tue, 14 Sep 2021 02:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237802AbhINCof (ORCPT ); Mon, 13 Sep 2021 22:44:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbhINCod (ORCPT ); Mon, 13 Sep 2021 22:44:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A347606A5; Tue, 14 Sep 2021 02:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587397; bh=EAKxHy20icKh9uuHjpnhsG+OYHU9vNXRB/kiPNOQ9/g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XQDATCMslzd8zj5xQlPJ8Jt7NNmRShMLZmwoXJ8hFByFvBAE55nsvYAa8UFsBEoUV EMWCiNIrPRbvYLoh4boo5IUPSKukbshu29VRYJtezrIFMferGXmErybYe5auVDmoY9 AzxSGkqkqMqtbpNFv8OEqpV7nULFY/q++TYLz+d9J8BOgAv1aojlUESreZ7ODugzh8 +r/x8/4VRzlsuZ9KQ/CekbtRU/AbIbHhhlBRO9d9liwRB+ybEpRPwMwH+JeDjmv3Vq QiYEXw8XiE3koil+7nxeSCmG+QWx6xqEhfeklOnQNbF+DWIwrrpT8ZmGPRXysHC/7a neNWtPNE/5V4w== Subject: [PATCH 36/43] xfs: kill xfs_sb_version_has_v3inode() From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:16 -0700 Message-ID: <163158739690.1604118.2602850202124735343.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: cf28e17c9186c83e7e8702f844bc40b6e782ce6c All callers to xfs_dinode_good_version() and XFS_DINODE_SIZE() in both the kernel and userspace have a xfs_mount structure available which means they can use mount features checks instead looking directly are the superblock. Convert these functions to take a mount and use a xfs_has_v3inodes() check and move it out of the libxfs/xfs_format.h file as it really doesn't have anything to do with the definition of the on-disk format. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/check.c | 2 +- libxfs/xfs_format.h | 18 +++--------------- libxfs/xfs_ialloc.c | 3 +-- libxfs/xfs_inode_buf.c | 2 +- libxfs/xfs_inode_buf.h | 11 ++++++++++- repair/dinode.c | 2 +- repair/prefetch.c | 2 +- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/db/check.c b/db/check.c index a078e948..368f80c0 100644 --- a/db/check.c +++ b/db/check.c @@ -2796,7 +2796,7 @@ process_inode( error++; return; } - if (!libxfs_dinode_good_version(&mp->m_sb, dip->di_version)) { + if (!libxfs_dinode_good_version(mp, dip->di_version)) { if (isfree || v) dbprintf(_("bad version number %#x for inode %lld\n"), dip->di_version, ino); diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index ee479feb..2d7057b7 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -414,18 +414,6 @@ xfs_sb_add_incompat_log_features( } -/* - * v5 file systems support V3 inodes only, earlier file systems support - * v2 and v1 inodes. - */ -static inline bool xfs_dinode_good_version(struct xfs_sb *sbp, - uint8_t version) -{ - if (xfs_sb_is_v5(sbp)) - return version == 3; - return version == 1 || version == 2; -} - static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) { @@ -892,12 +880,12 @@ enum xfs_dinode_fmt { /* * Inode size for given fs. */ -#define XFS_DINODE_SIZE(sbp) \ - (xfs_sb_is_v5(sbp) ? \ +#define XFS_DINODE_SIZE(mp) \ + (xfs_has_v3inodes(mp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc)) #define XFS_LITINO(mp) \ - ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(&(mp)->m_sb)) + ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(mp)) /* * Inode data & attribute fork sizes, per inode. diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index cbccc072..3b96e828 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -332,7 +332,6 @@ xfs_ialloc_inode_init( xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); for (i = 0; i < M_IGEO(mp)->inodes_per_cluster; i++) { int ioffset = i << mp->m_sb.sb_inodelog; - uint isize = XFS_DINODE_SIZE(&mp->m_sb); free = xfs_make_iptr(mp, fbuf, i); free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); @@ -349,7 +348,7 @@ xfs_ialloc_inode_init( } else if (tp) { /* just log the inode core */ xfs_trans_log_buf(tp, fbuf, ioffset, - ioffset + isize - 1); + ioffset + XFS_DINODE_SIZE(mp) - 1); } } diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 2638e515..dfff5979 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -55,7 +55,7 @@ xfs_inode_buf_verify( dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog)); unlinked_ino = be32_to_cpu(dip->di_next_unlinked); di_ok = xfs_verify_magic16(bp, dip->di_magic) && - xfs_dinode_good_version(&mp->m_sb, dip->di_version) && + xfs_dinode_good_version(mp, dip->di_version) && xfs_verify_agino_or_null(mp, agno, unlinked_ino); if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP))) { diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 7f865bb4..585ed5a1 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -21,7 +21,7 @@ struct xfs_imap { int xfs_imap_to_bp(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_imap *imap, struct xfs_buf **bpp); -void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); +void xfs_dinode_calc_crc(struct xfs_mount *mp, struct xfs_dinode *dip); void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, xfs_lsn_t lsn); int xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); @@ -42,4 +42,13 @@ static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) struct timespec64 xfs_inode_from_disk_ts(struct xfs_dinode *dip, const xfs_timestamp_t ts); +static inline bool +xfs_dinode_good_version(struct xfs_mount *mp, uint8_t version) +{ + if (xfs_has_v3inodes(mp)) + return version == 3; + return version == 1 || version == 2; +} + + #endif /* __XFS_INODE_BUF_H__ */ diff --git a/repair/dinode.c b/repair/dinode.c index 3a79e18e..4da39dcc 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2329,7 +2329,7 @@ process_dinode_int(xfs_mount_t *mp, } } - if (!libxfs_dinode_good_version(&mp->m_sb, dino->di_version)) { + if (!libxfs_dinode_good_version(mp, dino->di_version)) { retval = 1; if (!uncertain) do_warn(_("bad version number 0x%x on inode %" PRIu64 "%c"), diff --git a/repair/prefetch.c b/repair/prefetch.c index 48affa18..ef5d40da 100644 --- a/repair/prefetch.c +++ b/repair/prefetch.c @@ -441,7 +441,7 @@ pf_read_inode_dirs( if (be16_to_cpu(dino->di_magic) != XFS_DINODE_MAGIC) continue; - if (!libxfs_dinode_good_version(&mp->m_sb, dino->di_version)) + if (!libxfs_dinode_good_version(mp, dino->di_version)) continue; if (be64_to_cpu(dino->di_size) <= XFS_DFORK_DSIZE(dino, mp)) From patchwork Tue Sep 14 02:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95321C433EF for ; Tue, 14 Sep 2021 02:43:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F022610D1 for ; Tue, 14 Sep 2021 02:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236205AbhINCok (ORCPT ); Mon, 13 Sep 2021 22:44:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:54034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235706AbhINCoj (ORCPT ); Mon, 13 Sep 2021 22:44:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D628606A5; Tue, 14 Sep 2021 02:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587402; bh=0gUrzyn26X7ZeQ4qwix4Dc84ue5GI9Kj8eM2Vmvyy6k=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=E4VIgttgt26B4V1ox3TEHpNB8bmCMgf3ErjilIZ2G0s8OX1fbwP2739D9FKnJ5j2b I8lctc3jD1S8lF49R5l+qG2QCkZTCaZILdejupDGgx3Mh7+UDNQa2/LWrL+F/V6roW keRodOyMGMV2iayPHljCxSfoPio+QJXFDhgnvjVaE+WFwQetne5BPGfcM7LAYH1DWj WXy7f44wyrZ8nZjoqxZJ9h+VylbPvjTsZCOM3hH148TkBTG6fpXRfnHw2yN9BTOfU/ +2gpUk5Z/6pGPU1DCUBAmVbpRj577S9FiOpPVEqNS8a+Y1BEUv0Jv0SPN2m+L+O9k8 zCYi60/fXy2ZA== Subject: [PATCH 37/43] libxfs: use opstate flags and functions for libxfs mount options From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:22 -0700 Message-ID: <163158740237.1604118.3025907636672209452.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Port the two LIBXFS_MOUNT flags that actually do anything to set opstate flags, in preparation for removing m_flags. Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 4 ++++ libxfs/init.c | 17 ++++++++++------- libxfs/libxfs_priv.h | 2 +- repair/xfs_repair.c | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 29d0440e..1f4f4390 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -213,6 +213,8 @@ __XFS_UNSUPP_FEAT(readonly) * XXX: need real atomic bit ops! */ #define XFS_OPSTATE_INODE32 0 /* inode32 allocator active */ +#define XFS_OPSTATE_DEBUGGER 1 /* is this the debugger? */ +#define XFS_OPSTATE_REPORT_CORRUPTION 2 /* report buffer corruption? */ #define __XFS_IS_OPSTATE(name, NAME) \ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ @@ -235,6 +237,8 @@ static inline bool xfs_set_ ## name (struct xfs_mount *mp) \ } __XFS_IS_OPSTATE(inode32, INODE32) +__XFS_IS_OPSTATE(debugger, DEBUGGER) +__XFS_IS_OPSTATE(reporting_corruption, REPORT_CORRUPTION) #define __XFS_UNSUPP_OPSTATE(name) \ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ diff --git a/libxfs/init.c b/libxfs/init.c index d36595cf..a96f5389 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -441,7 +441,7 @@ rtmount_init( return -1; } - if (mp->m_rtdev_targp->bt_bdev == 0 && !(flags & LIBXFS_MOUNT_DEBUGGER)) { + if (mp->m_rtdev_targp->bt_bdev == 0 && !xfs_is_debugger(mp)) { fprintf(stderr, _("%s: filesystem has a realtime subvolume\n"), progname); return -1; @@ -456,7 +456,7 @@ rtmount_init( /* * Allow debugger to be run without the realtime device present. */ - if (flags & LIBXFS_MOUNT_DEBUGGER) + if (xfs_is_debugger(mp)) return 0; /* @@ -715,10 +715,13 @@ libxfs_mount( struct xfs_buf *bp; struct xfs_sb *sbp; xfs_daddr_t d; - bool debugger = (flags & LIBXFS_MOUNT_DEBUGGER); int error; mp->m_features = xfs_sb_version_to_features(sb); + if (flags & LIBXFS_MOUNT_DEBUGGER) + xfs_set_debugger(mp); + if (flags & LIBXFS_MOUNT_WANT_CORRUPTED) + xfs_set_reporting_corruption(mp); libxfs_buftarg_init(mp, dev, logdev, rtdev); mp->m_finobt_nores = true; @@ -751,7 +754,7 @@ libxfs_mount( d = (xfs_daddr_t) XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { fprintf(stderr, _("%s: size check failed\n"), progname); - if (!(flags & LIBXFS_MOUNT_DEBUGGER)) + if (!xfs_is_debugger(mp)) return NULL; } @@ -800,7 +803,7 @@ libxfs_mount( XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); if (error) { fprintf(stderr, _("%s: data size check failed\n"), progname); - if (!debugger) + if (!xfs_is_debugger(mp)) return NULL; } else libxfs_buf_relse(bp); @@ -814,7 +817,7 @@ libxfs_mount( 0, &bp, NULL)) { fprintf(stderr, _("%s: log size checks failed\n"), progname); - if (!debugger) + if (!xfs_is_debugger(mp)) return NULL; } if (bp) @@ -842,7 +845,7 @@ libxfs_mount( if (error) { fprintf(stderr, _("%s: read of AG %u failed\n"), progname, sbp->sb_agcount); - if (!debugger) + if (!xfs_is_debugger(mp)) return NULL; fprintf(stderr, _("%s: limiting reads to AG 0\n"), progname); diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 3e5ff2a8..3fc13c52 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -153,7 +153,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; } while (0) #define XFS_WARN_CORRUPT(mp, expr) \ - ( ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED) ? \ + ( xfs_is_reporting_corruption(mp) ? \ (printf("%s: XFS_WARN_CORRUPT at %s:%d", #expr, \ __func__, __LINE__), true) : true) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index abde6fe8..bcd44cd5 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -979,7 +979,7 @@ main(int argc, char **argv) /* Spit out function & line on these corruption macros */ if (verbose > 2) - mp->m_flags |= LIBXFS_MOUNT_WANT_CORRUPTED; + xfs_set_reporting_corruption(mp); /* Capture the first writeback so that we can set needsrepair. */ if (xfs_has_crc(mp)) From patchwork Tue Sep 14 02:43:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E35F7C433EF for ; Tue, 14 Sep 2021 02:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C87F8610D1 for ; Tue, 14 Sep 2021 02:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237213AbhINCop (ORCPT ); Mon, 13 Sep 2021 22:44:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:54062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235706AbhINCoo (ORCPT ); Mon, 13 Sep 2021 22:44:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AC65610D1; Tue, 14 Sep 2021 02:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587408; bh=jhc/LzY7PKw1UL+pDL3snu2U824RWKsMEcZQhET9ztA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=J6lkSmwBTYJ+Meogx10LxR5IUydywx5fJSVSQ07Yqr+/qlVOfzTGv6lYftM6okhod la1fwoqdYJdTBKW/mq4AwFI6IJOmqS79xPK9S4krl1HcXwcU41xpehsJsTpvFxnbPw BtXwnd5n5GwFCtih/f5YSCaXpNYcMzOhB6x7YGB9Ju0LH777d3n3ZAAZlr+N6EI5Cl WdZQIQp0Cix1XU79GMeY7Re6Y511yxEDVMntIHyEVaYAXwTN5wS3Y23KPERj20KlM2 3dPTwpRf4f8g12aYXhHsUKbc/tlLvMERZcClQcf6sPfZxJ+zerELU46At3Bc4UMbZ0 Y1AuiBH6oWmpQ== Subject: [PATCH 38/43] libxfs: remove pointless *XFS_MOUNT* flags From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:27 -0700 Message-ID: <163158740784.1604118.16211586847965140773.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Get rid of these flags and the m_flags field, since none of them do anything anymore. Signed-off-by: Darrick J. Wong --- db/attrset.c | 4 ---- include/xfs_mount.h | 7 +------ libxfs/init.c | 11 ++--------- libxfs/libxfs_priv.h | 10 ---------- libxlog/xfs_log_recover.c | 1 - 5 files changed, 3 insertions(+), 30 deletions(-) diff --git a/db/attrset.c b/db/attrset.c index 98a08a49..6441809a 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -107,7 +107,6 @@ attr_set_f( break; case 'n': - mp->m_flags |= LIBXFS_MOUNT_COMPAT_ATTR; break; /* value length */ @@ -169,7 +168,6 @@ attr_set_f( set_cur_inode(iocur_top->ino); out: - mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR; if (args.dp) libxfs_irele(args.dp); if (args.value) @@ -211,7 +209,6 @@ attr_remove_f( break; case 'n': - mp->m_flags |= LIBXFS_MOUNT_COMPAT_ATTR; break; default: @@ -254,7 +251,6 @@ attr_remove_f( set_cur_inode(iocur_top->ino); out: - mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR; if (args.dp) libxfs_irele(args.dp); return 0; diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 1f4f4390..41fd374a 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -77,7 +77,6 @@ typedef struct xfs_mount { uint m_alloc_set_aside; /* space we can't use */ uint m_ag_max_usable; /* max space per AG */ struct radix_tree_root m_perag_tree; - uint m_flags; /* global mount flags */ uint64_t m_features; /* active filesystem features */ unsigned long m_opstate; /* dynamic state flags */ bool m_finobt_nores; /* no per-AG finobt resv. */ @@ -249,11 +248,7 @@ __XFS_UNSUPP_OPSTATE(readonly) __XFS_UNSUPP_OPSTATE(shutdown) #define LIBXFS_MOUNT_DEBUGGER 0x0001 -#define LIBXFS_MOUNT_32BITINODES 0x0002 -#define LIBXFS_MOUNT_32BITINOOPT 0x0004 -#define LIBXFS_MOUNT_COMPAT_ATTR 0x0008 -#define LIBXFS_MOUNT_ATTR2 0x0010 -#define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020 +#define LIBXFS_MOUNT_WANT_CORRUPTED 0x0002 #define LIBXFS_BHASHSIZE(sbp) (1<<10) diff --git a/libxfs/init.c b/libxfs/init.c index a96f5389..7845ba2c 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -532,13 +532,10 @@ xfs_set_inode_alloc( * sufficiently large, set XFS_MOUNT_32BITINODES if we must alter * the allocator to accommodate the request. */ - if ((mp->m_flags & XFS_MOUNT_SMALL_INUMS) && ino > XFS_MAXINUMBER_32) { + if (ino > XFS_MAXINUMBER_32) xfs_set_inode32(mp); - mp->m_flags |= XFS_MOUNT_32BITINODES; - } else { + else xfs_clear_inode32(mp); - mp->m_flags &= ~XFS_MOUNT_32BITINODES; - } for (index = 0; index < agcount; index++) { struct xfs_perag *pag; @@ -725,7 +722,6 @@ libxfs_mount( libxfs_buftarg_init(mp, dev, logdev, rtdev); mp->m_finobt_nores = true; - mp->m_flags = (LIBXFS_MOUNT_32BITINODES|LIBXFS_MOUNT_32BITINOOPT); xfs_set_inode32(mp); mp->m_sb = *sb; INIT_RADIX_TREE(&mp->m_perag_tree, GFP_KERNEL); @@ -789,9 +785,6 @@ libxfs_mount( xfs_da_mount(mp); - if (xfs_has_attr2(mp)) - mp->m_flags |= LIBXFS_MOUNT_ATTR2; - /* Initialize the precomputed transaction reservations values */ xfs_trans_init(mp); diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 3fc13c52..75f26f36 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -443,16 +443,6 @@ void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa); #define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address) /* mount stuff */ -#define XFS_MOUNT_32BITINODES LIBXFS_MOUNT_32BITINODES -#define XFS_MOUNT_ATTR2 LIBXFS_MOUNT_ATTR2 -#define XFS_MOUNT_SMALL_INUMS 0 /* ignored in userspace */ -#define XFS_MOUNT_WSYNC 0 /* ignored in userspace */ -#define XFS_MOUNT_NOALIGN 0 /* ignored in userspace */ -#define XFS_MOUNT_IKEEP 0 /* ignored in userspace */ -#define XFS_MOUNT_SWALLOC 0 /* ignored in userspace */ -#define XFS_MOUNT_RDONLY 0 /* ignored in userspace */ -#define XFS_MOUNT_BAD_SUMMARY 0 /* ignored in userspace */ - #define xfs_trans_set_sync(tp) ((void) 0) #define xfs_trans_buf_set_type(tp, bp, t) ({ \ int __t = (t); \ diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c index 592e4502..d43914b9 100644 --- a/libxlog/xfs_log_recover.c +++ b/libxlog/xfs_log_recover.c @@ -827,7 +827,6 @@ xlog_find_tail( * superblock counters from the perag headers if we * have a filesystem using non-persistent counters. */ - log->l_mp->m_flags |= XFS_MOUNT_WAS_CLEAN; } } From patchwork Tue Sep 14 02:43:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04F74C433F5 for ; Tue, 14 Sep 2021 02:43:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1719610D1 for ; Tue, 14 Sep 2021 02:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhINCou (ORCPT ); Mon, 13 Sep 2021 22:44:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237565AbhINCou (ORCPT ); Mon, 13 Sep 2021 22:44:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FFF9610D1; Tue, 14 Sep 2021 02:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587413; bh=UxQxJ4pMUx3E9hmdGz8f1royBn/yKmtMgQ/3n8+Whls=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Es0rR52+ZcRFOhG1HpqxU3K//FxFia2uC42J8tfHl2GkpWsXbhpI83LwgM+He2n2y JCMTjV5Fr4lQNDeLfLfoFU3HN6MK5PA5I5QKDP3fNtAMGBop86jZWHeAjPSvDtAHzK mdD6GjTFM1jjC9aCM4FAwxzjl/ckTZSUg/L5PQMFY4p69ow9tRRR5m8nJghMASUpRq Y+WUeNzQcKtM8Lbh+6rPqXQQ3zmAXjDyhy3EhmUR/0J3DWG5shBjXaQph6UF0JSio5 mi873VaCi5UajGBIpkCoMh7aPyBYY2dEQ9wwH6tHhX62cQWAGynsPm8ukUIZ6mPGQv DdIO0CMFRf1Fw== Subject: [PATCH 39/43] libxfs: always initialize internal buffer map From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:33 -0700 Message-ID: <163158741330.1604118.2384362360060613446.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The __initbuf function is responsible for initializing the fields of an xfs_buf. Buffers are always required to have a mapping, though in the typical case there's only one mapping, so we can use the internal one. The single-mapping b_maps init code at the end of the function doesn't quite get this right though -- if a single-mapping buffer in the cache was allowed to expire and now is being repurposed, it'll come out with b_maps == &__b_map, in which case we incorrectly skip initializing the map. This has gone unnoticed until now because (AFAICT) the code paths that use b_maps are the same ones that are called with multi-mapping buffers, which are initialized correctly. Anyway, the improperly initialized single-mappings will cause problems in upcoming patches where we turn b_bn into the cache key and require the use of b_maps[0].bm_bn for the buffer LBA. Fix this. Signed-off-by: Darrick J. Wong --- libxfs/rdwr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index f4e76029..03dc2917 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -251,9 +251,11 @@ __initbuf(struct xfs_buf *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, bp->b_ops = NULL; INIT_LIST_HEAD(&bp->b_li_list); - if (!bp->b_maps) { - bp->b_nmaps = 1; + if (!bp->b_maps) bp->b_maps = &bp->__b_map; + + if (bp->b_maps == &bp->__b_map) { + bp->b_nmaps = 1; bp->b_maps[0].bm_bn = bp->b_bn; bp->b_maps[0].bm_len = bp->b_length; } From patchwork Tue Sep 14 02:43:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82C67C433EF for ; Tue, 14 Sep 2021 02:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 687F3610F9 for ; Tue, 14 Sep 2021 02:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237553AbhINCo7 (ORCPT ); Mon, 13 Sep 2021 22:44:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:54120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237725AbhINCoz (ORCPT ); Mon, 13 Sep 2021 22:44:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EC78606A5; Tue, 14 Sep 2021 02:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587419; bh=2N3rnH7ZMYAPSxQPlbx4bB1HUZmbEq4QFBWc5Y6EJV0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uyWpogF9AQEHAzSlKy4aEVz/o5ihp4d0LgV30H1kEBG7aHNKbLTtT+/ZCgbBAiDII 9y0sPywUOy5TaYTJmp8vRg+hRBaB0/pfemiGmWdYOxPHTlqMuAUDq7hzLPGvhli2I9 dSb3SCJ3TVrULrClpDBW6ISI6Gk6gISGTsmg4vLTRRxuVA0h5bzrwGH80o/u0qSNjh gr0DzPJtH5G1agCssBYizKRiFRA6fwSQQc0C1wDaFIPuM7Qa/SyCKseQbrflnpIAIj 7n9fTaBVNRSeJly+Mce2WLgM7ySj8i7dnkR83sin+uZ7qFwD0ZRY927pxEYLpQ9R5f ZKN+1hlEmIwxg== Subject: [PATCH 40/43] libxfs: replace XFS_BUF_SET_ADDR with a function From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:38 -0700 Message-ID: <163158741878.1604118.17091065004793020901.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Replace XFS_BUF_SET_ADDR with a new function that will set the buffer block number correctly, then port the two users to it. Signed-off-by: Darrick J. Wong --- libxfs/libxfs_io.h | 5 ++++- libxlog/xfs_log_recover.c | 2 +- mkfs/xfs_mkfs.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 3cc4f4ee..bf489259 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -116,7 +116,10 @@ typedef unsigned int xfs_buf_flags_t; #define xfs_buf_offset(bp, offset) ((bp)->b_addr + (offset)) #define XFS_BUF_ADDR(bp) ((bp)->b_bn) -#define XFS_BUF_SET_ADDR(bp,blk) ((bp)->b_bn = (blk)) +static inline void xfs_buf_set_daddr(struct xfs_buf *bp, xfs_daddr_t blkno) +{ + bp->b_bn = blkno; +} void libxfs_buf_set_priority(struct xfs_buf *bp, int priority); int libxfs_buf_priority(struct xfs_buf *bp); diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c index d43914b9..3c24c021 100644 --- a/libxlog/xfs_log_recover.c +++ b/libxlog/xfs_log_recover.c @@ -114,7 +114,7 @@ xlog_bread_noalign( ASSERT(nbblks > 0); ASSERT(nbblks <= bp->b_length); - XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); + xfs_buf_set_daddr(bp, log->l_logBBstart + blk_no); bp->b_length = nbblks; bp->b_error = 0; diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 63895f28..057b3b09 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3505,8 +3505,8 @@ alloc_write_buf( error); exit(1); } - bp->b_bn = daddr; - bp->b_maps[0].bm_bn = daddr; + + xfs_buf_set_daddr(bp, daddr); return bp; } From patchwork Tue Sep 14 02:43:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE53CC433F5 for ; Tue, 14 Sep 2021 02:43:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0EC3610FB for ; Tue, 14 Sep 2021 02:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237763AbhINCpD (ORCPT ); Mon, 13 Sep 2021 22:45:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237725AbhINCpB (ORCPT ); Mon, 13 Sep 2021 22:45:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 896A6606A5; Tue, 14 Sep 2021 02:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587424; bh=U8AO+Iho7HzTkfvME2dKXiYXXJhVcl71xWj6zWgV4gU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=oGlEI1H/fxu65OFhXH/DbeMrKbWIWjvsM7X1W2OC24RBMPUADrQwIOHiwmncbDJNZ WXPbLyAQXCK1UEmedbjWlWdmMulNcjBMbv8ixrER98XTaAicJ+Vudje1vC6emTRd1+ /VGIu1QWVFdzZnwEGjR4KdseDYj/R86KuiDmB+9Y/DWLy5pDmenARUqhEXT08+uhvZ Uf58QSSZ626iJ117NB+X2FrQYhjo+sBjro2Qr2ZKuOxGrdpn3H6LuRC23Dyhs398cc ZThQsi15/WW9q3yGHeYVrxDOL1hvejO1Hrbj1W6FFC+bph99kgRxK5Y/dP+aTqQkiE LDF+d4COUC4KA== Subject: [PATCH 41/43] xfs: introduce xfs_buf_daddr() From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:44 -0700 Message-ID: <163158742426.1604118.6590610550397189841.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 04fcad80cd068731a779fb442f78234732683755 Introduce a helper function xfs_buf_daddr() to extract the disk address of the buffer from the struct xfs_buf. This will replace direct accesses to bp->b_bn and bp->b_maps[0].bm_bn, as well as the XFS_BUF_ADDR() macro. This patch introduces the helper function and replaces all uses of XFS_BUF_ADDR() as this is just a simple sed replacement. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- libxfs/libxfs_io.h | 14 ++++++++++++-- libxfs/logitem.c | 4 ++-- libxfs/xfs_alloc_btree.c | 2 +- libxfs/xfs_attr.c | 4 ++-- libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_bmap_btree.c | 2 +- libxfs/xfs_btree.c | 10 +++++----- libxfs/xfs_ialloc_btree.c | 2 +- libxfs/xfs_inode_buf.c | 2 +- libxfs/xfs_refcount_btree.c | 2 +- libxfs/xfs_rmap_btree.c | 2 +- libxfs/xfs_sb.c | 2 +- libxlog/xfs_log_recover.c | 2 +- repair/dino_chunks.c | 4 ++-- repair/prefetch.c | 20 ++++++++++---------- 15 files changed, 43 insertions(+), 33 deletions(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index bf489259..1f2ac25b 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -114,11 +114,21 @@ typedef unsigned int xfs_buf_flags_t; #define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) #define xfs_buf_offset(bp, offset) ((bp)->b_addr + (offset)) -#define XFS_BUF_ADDR(bp) ((bp)->b_bn) + +static inline xfs_daddr_t xfs_buf_daddr(struct xfs_buf *bp) +{ + /* XXX remove me */ + if (bp->b_bn != bp->b_maps[0].bm_bn && bp->b_bn != -1ULL) { + fprintf(stderr, "FARTS buf %p bn %lx bmbn %lx intmap? %d\n", bp, bp->b_bn, bp->b_maps[0].bm_bn, bp->b_maps == &bp->__b_map); + abort(); + } + return bp->b_maps[0].bm_bn; +} static inline void xfs_buf_set_daddr(struct xfs_buf *bp, xfs_daddr_t blkno) { - bp->b_bn = blkno; + assert(bp->b_bn == XFS_BUF_DADDR_NULL); + bp->b_maps[0].bm_bn = blkno; } void libxfs_buf_set_priority(struct xfs_buf *bp, int priority); diff --git a/libxfs/logitem.c b/libxfs/logitem.c index 4d4e8080..82e3af86 100644 --- a/libxfs/logitem.c +++ b/libxfs/logitem.c @@ -46,7 +46,7 @@ xfs_trans_buf_item_match( blip = (struct xfs_buf_log_item *)lip; if (blip->bli_item.li_type == XFS_LI_BUF && blip->bli_buf->b_target->bt_bdev == btp->bt_bdev && - XFS_BUF_ADDR(blip->bli_buf) == map[0].bm_bn && + xfs_buf_daddr(blip->bli_buf) == map[0].bm_bn && blip->bli_buf->b_length == len) { ASSERT(blip->bli_buf->b_map_count == nmaps); return blip->bli_buf; @@ -104,7 +104,7 @@ xfs_buf_item_init( xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF); bip->bli_buf = bp; bip->__bli_format.blf_type = XFS_LI_BUF; - bip->__bli_format.blf_blkno = (int64_t)XFS_BUF_ADDR(bp); + bip->__bli_format.blf_blkno = (int64_t)xfs_buf_daddr(bp); bip->__bli_format.blf_len = (unsigned short)bp->b_length; bp->b_log_item = bip; } diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c index 94f2d7b6..03ebefc3 100644 --- a/libxfs/xfs_alloc_btree.c +++ b/libxfs/xfs_alloc_btree.c @@ -85,7 +85,7 @@ xfs_allocbt_free_block( xfs_agblock_t bno; int error; - bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp)); + bno = xfs_daddr_to_agbno(cur->bc_mp, xfs_buf_daddr(bp)); error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1); if (error) return error; diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 00f3ecb5..e44b68e1 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -1540,7 +1540,7 @@ xfs_attr_fillstate(xfs_da_state_t *state) ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); for (blk = path->blk, level = 0; level < path->active; blk++, level++) { if (blk->bp) { - blk->disk_blkno = XFS_BUF_ADDR(blk->bp); + blk->disk_blkno = xfs_buf_daddr(blk->bp); blk->bp = NULL; } else { blk->disk_blkno = 0; @@ -1555,7 +1555,7 @@ xfs_attr_fillstate(xfs_da_state_t *state) ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); for (blk = path->blk, level = 0; level < path->active; blk++, level++) { if (blk->bp) { - blk->disk_blkno = XFS_BUF_ADDR(blk->bp); + blk->disk_blkno = xfs_buf_daddr(blk->bp); blk->bp = NULL; } else { blk->disk_blkno = 0; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 1735717c..1edf6236 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -235,7 +235,7 @@ xfs_bmap_get_bp( for (i = 0; i < XFS_BTREE_MAXLEVELS; i++) { if (!cur->bc_bufs[i]) break; - if (XFS_BUF_ADDR(cur->bc_bufs[i]) == bno) + if (xfs_buf_daddr(cur->bc_bufs[i]) == bno) return cur->bc_bufs[i]; } @@ -244,7 +244,7 @@ xfs_bmap_get_bp( struct xfs_buf_log_item *bip = (struct xfs_buf_log_item *)lip; if (bip->bli_item.li_type == XFS_LI_BUF && - XFS_BUF_ADDR(bip->bli_buf) == bno) + xfs_buf_daddr(bip->bli_buf) == bno) return bip->bli_buf; } diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 237af83e..aea9b5a8 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -280,7 +280,7 @@ xfs_bmbt_free_block( struct xfs_mount *mp = cur->bc_mp; struct xfs_inode *ip = cur->bc_ino.ip; struct xfs_trans *tp = cur->bc_tp; - xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(bp)); + xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, xfs_buf_daddr(bp)); struct xfs_owner_info oinfo; xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork); diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index a763ef10..ba1fb3c1 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -417,7 +417,7 @@ xfs_btree_dup_cursor( bp = cur->bc_bufs[i]; if (bp) { error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, - XFS_BUF_ADDR(bp), mp->m_bsize, + xfs_buf_daddr(bp), mp->m_bsize, 0, &bp, cur->bc_ops->buf_ops); if (error) { @@ -1189,10 +1189,10 @@ xfs_btree_buf_to_ptr( { if (cur->bc_flags & XFS_BTREE_LONG_PTRS) ptr->l = cpu_to_be64(XFS_DADDR_TO_FSB(cur->bc_mp, - XFS_BUF_ADDR(bp))); + xfs_buf_daddr(bp))); else { ptr->s = cpu_to_be32(xfs_daddr_to_agbno(cur->bc_mp, - XFS_BUF_ADDR(bp))); + xfs_buf_daddr(bp))); } } @@ -1736,7 +1736,7 @@ xfs_btree_lookup_get_block( error = xfs_btree_ptr_to_daddr(cur, pp, &daddr); if (error) return error; - if (bp && XFS_BUF_ADDR(bp) == daddr) { + if (bp && xfs_buf_daddr(bp) == daddr) { *blkp = XFS_BUF_TO_BLOCK(bp); return 0; } @@ -4500,7 +4500,7 @@ xfs_btree_sblock_verify( return __this_address; /* sibling pointer verification */ - agno = xfs_daddr_to_agno(mp, XFS_BUF_ADDR(bp)); + agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp)); if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) && !xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_leftsib))) return __this_address; diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c index 14b5918b..1a5289ce 100644 --- a/libxfs/xfs_ialloc_btree.c +++ b/libxfs/xfs_ialloc_btree.c @@ -155,7 +155,7 @@ __xfs_inobt_free_block( { xfs_inobt_mod_blockcount(cur, -1); return xfs_free_extent(cur->bc_tp, - XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(bp)), 1, + XFS_DADDR_TO_FSB(cur->bc_mp, xfs_buf_daddr(bp)), 1, &XFS_RMAP_OINFO_INOBT, resv); } diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index dfff5979..516dab25 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -45,7 +45,7 @@ xfs_inode_buf_verify( /* * Validate the magic number and version of every inode in the buffer */ - agno = xfs_daddr_to_agno(mp, XFS_BUF_ADDR(bp)); + agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp)); ni = XFS_BB_TO_FSB(mp, bp->b_length) * mp->m_sb.sb_inopblock; for (i = 0; i < ni; i++) { int di_ok; diff --git a/libxfs/xfs_refcount_btree.c b/libxfs/xfs_refcount_btree.c index ded0ebe1..62ef048c 100644 --- a/libxfs/xfs_refcount_btree.c +++ b/libxfs/xfs_refcount_btree.c @@ -101,7 +101,7 @@ xfs_refcountbt_free_block( struct xfs_mount *mp = cur->bc_mp; struct xfs_buf *agbp = cur->bc_ag.agbp; struct xfs_agf *agf = agbp->b_addr; - xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(bp)); + xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, xfs_buf_daddr(bp)); int error; trace_xfs_refcountbt_free_block(cur->bc_mp, cur->bc_ag.pag->pag_agno, diff --git a/libxfs/xfs_rmap_btree.c b/libxfs/xfs_rmap_btree.c index 05d962d8..ca72324b 100644 --- a/libxfs/xfs_rmap_btree.c +++ b/libxfs/xfs_rmap_btree.c @@ -120,7 +120,7 @@ xfs_rmapbt_free_block( xfs_agblock_t bno; int error; - bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp)); + bno = xfs_daddr_to_agbno(cur->bc_mp, xfs_buf_daddr(bp)); trace_xfs_rmapbt_free_block(cur->bc_mp, pag->pag_agno, bno, 1); be32_add_cpu(&agf->agf_rmap_blocks, -1); diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 198d211e..680441ae 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -190,7 +190,7 @@ xfs_validate_sb_write( * secondary superblocks, so allow this usage to continue because * we never read counters from such superblocks. */ - if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR && !sbp->sb_inprogress && + if (xfs_buf_daddr(bp) == XFS_SB_DADDR && !sbp->sb_inprogress && (sbp->sb_fdblocks > sbp->sb_dblocks || !xfs_verify_icount(mp, sbp->sb_icount) || sbp->sb_ifree > sbp->sb_icount)) { diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c index 3c24c021..79a405c5 100644 --- a/libxlog/xfs_log_recover.c +++ b/libxlog/xfs_log_recover.c @@ -118,7 +118,7 @@ xlog_bread_noalign( bp->b_length = nbblks; bp->b_error = 0; - return libxfs_readbufr(log->l_dev, XFS_BUF_ADDR(bp), bp, nbblks, 0); + return libxfs_readbufr(log->l_dev, xfs_buf_daddr(bp), bp, nbblks, 0); } int diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c index 6d494f2d..51cd06f0 100644 --- a/repair/dino_chunks.c +++ b/repair/dino_chunks.c @@ -686,7 +686,7 @@ process_inode_chunk( } pftrace("readbuf %p (%llu, %d) in AG %d", bplist[bp_index], - (long long)XFS_BUF_ADDR(bplist[bp_index]), + (long long)xfs_buf_daddr(bplist[bp_index]), bplist[bp_index]->b_length, agno); bplist[bp_index]->b_ops = &xfs_inode_buf_ops; @@ -985,7 +985,7 @@ process_inode_chunk( pftrace("put/writebuf %p (%llu) in AG %d", bplist[bp_index], (long long) - XFS_BUF_ADDR(bplist[bp_index]), agno); + xfs_buf_daddr(bplist[bp_index]), agno); if (dirty && !no_modify) { libxfs_buf_mark_dirty(bplist[bp_index]); diff --git a/repair/prefetch.c b/repair/prefetch.c index ef5d40da..48892617 100644 --- a/repair/prefetch.c +++ b/repair/prefetch.c @@ -153,7 +153,7 @@ pf_queue_io( pftrace("getbuf %c %p (%llu) in AG %d (fsbno = %lu) added to queue" "(inode_bufs_queued = %d, last_bno = %lu)", B_IS_INODE(flag) ? - 'I' : 'M', bp, (long long)XFS_BUF_ADDR(bp), args->agno, fsbno, + 'I' : 'M', bp, (long long)xfs_buf_daddr(bp), args->agno, fsbno, args->inode_bufs_queued, args->last_bno_read); pf_start_processing(args); @@ -523,12 +523,12 @@ pf_batch_read( * otherwise, find as many close together blocks and * read them in one read */ - first_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[0])); - last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) + + first_off = LIBXFS_BBTOOFF64(xfs_buf_daddr(bplist[0])); + last_off = LIBXFS_BBTOOFF64(xfs_buf_daddr(bplist[num-1])) + BBTOB(bplist[num-1]->b_length); while (num > 1 && last_off - first_off > pf_max_bytes) { num--; - last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) + + last_off = LIBXFS_BBTOOFF64(xfs_buf_daddr(bplist[num-1])) + BBTOB(bplist[num-1]->b_length); } if (num < ((last_off - first_off) >> (mp->m_sb.sb_blocklog + 3))) { @@ -538,7 +538,7 @@ pf_batch_read( */ last_off = first_off + BBTOB(bplist[0]->b_length); for (i = 1; i < num; i++) { - next_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[i])) + + next_off = LIBXFS_BBTOOFF64(xfs_buf_daddr(bplist[i])) + BBTOB(bplist[i]->b_length); if (next_off - last_off > pf_batch_bytes) break; @@ -549,7 +549,7 @@ pf_batch_read( for (i = 0; i < num; i++) { if (btree_delete(args->io_queue, XFS_DADDR_TO_FSB(mp, - XFS_BUF_ADDR(bplist[i]))) == NULL) + xfs_buf_daddr(bplist[i]))) == NULL) do_error(_("prefetch corruption\n")); } @@ -565,8 +565,8 @@ pf_batch_read( } #ifdef XR_PF_TRACE pftrace("reading bbs %llu to %llu (%d bufs) from %s queue in AG %d (last_bno = %lu, inode_bufs = %d)", - (long long)XFS_BUF_ADDR(bplist[0]), - (long long)XFS_BUF_ADDR(bplist[num-1]), num, + (long long)xfs_buf_daddr(bplist[0]), + (long long)xfs_buf_daddr(bplist[num-1]), num, (which != PF_SECONDARY) ? "pri" : "sec", args->agno, args->last_bno_read, args->inode_bufs_queued); #endif @@ -597,7 +597,7 @@ pf_batch_read( */ for (i = 0; i < num; i++) { - pbuf = ((char *)buf) + (LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[i])) - first_off); + pbuf = ((char *)buf) + (LIBXFS_BBTOOFF64(xfs_buf_daddr(bplist[i])) - first_off); size = BBTOB(bplist[i]->b_length); if (len < size) break; @@ -619,7 +619,7 @@ pf_batch_read( pftrace("putbuf %c %p (%llu) in AG %d", B_IS_INODE(libxfs_buf_priority(bplist[i])) ? 'I' : 'M', - bplist[i], (long long)XFS_BUF_ADDR(bplist[i]), + bplist[i], (long long)xfs_buf_daddr(bplist[i]), args->agno); libxfs_buf_relse(bplist[i]); } From patchwork Tue Sep 14 02:43:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58B1BC433F5 for ; Tue, 14 Sep 2021 02:43:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44462610FB for ; Tue, 14 Sep 2021 02:43:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237737AbhINCpH (ORCPT ); Mon, 13 Sep 2021 22:45:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:54182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237725AbhINCpG (ORCPT ); Mon, 13 Sep 2021 22:45:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13A6D610D1; Tue, 14 Sep 2021 02:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587430; bh=oc7aaZzIOvyF6TU/+8i9jBPfIJ2QZllpj2fy7eiU9LY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jwKAgb0VxcQsco+rd74ZXTYW5slsh/fQBu5+M+iYNp55iy3N89BdLxjgMH7669ukJ 8e9ltcgU/b+u33AtrYXgbKDu954YgUgI8ahwcJLtEHHyrnrwY2sD5Z6DfCkudHQbdW UzRAIjIH+cOmDPFUvkIAm6dSodyOkPTsxoD+dZT0z3+AulfjRZlD7f0F0/Us7/cSNt tagT4hPn7gpRrIHxq+odyhWGLXT5WUacrJtooYS/0x7lXdWjf/+RxuacMC7vtHinkv yPLdDGoijHvGtQAH4c3RoDoDogDwAgHboWad5O5k+g93VCJj70Y9a6UrSzYGBwuniR wW/YEJJOSuMIA== Subject: [PATCH 42/43] xfs: convert bp->b_bn references to xfs_buf_daddr() From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: Dave Chinner , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:49 -0700 Message-ID: <163158742975.1604118.4514194103138380098.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Source kernel commit: 9343ee76909e3f6466d85c9ebb0e343cdf54de71 Stop directly referencing b_bn in code outside the buffer cache, as b_bn is supposed to be used only as an internal cache index. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- db/metadump.c | 2 +- libxfs/util.c | 4 ++-- libxfs/xfs_ag.c | 1 - libxfs/xfs_attr_leaf.c | 4 ++-- libxfs/xfs_attr_remote.c | 8 ++++---- libxfs/xfs_bmap.c | 2 +- libxfs/xfs_btree.c | 25 +++++++++++++------------ libxfs/xfs_da_btree.c | 8 ++++---- libxfs/xfs_dir2_block.c | 4 ++-- libxfs/xfs_dir2_data.c | 4 ++-- libxfs/xfs_dir2_leaf.c | 4 ++-- libxfs/xfs_dir2_node.c | 6 +++--- libxfs/xfs_inode_buf.c | 2 +- libxfs/xfs_sb.c | 2 +- libxfs/xfs_symlink_remote.c | 4 ++-- repair/attr_repair.c | 8 ++++---- repair/phase6.c | 8 ++++---- repair/xfs_repair.c | 2 +- 18 files changed, 49 insertions(+), 49 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 2c649c15..48cda88a 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -204,7 +204,7 @@ write_buf( print_warning( "obfuscation corrupted block at %s bno 0x%llx/0x%x", bp->b_ops->name, - (long long)bp->b_bn, BBTOB(bp->b_length)); + (long long)xfs_buf_daddr(bp), BBTOB(bp->b_length)); } } diff --git a/libxfs/util.c b/libxfs/util.c index 9c8230cd..69cc477c 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -556,7 +556,7 @@ xfs_verifier_error( xfs_alert(NULL, "Metadata %s detected at %p, %s block 0x%llx/0x%x", bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", failaddr ? failaddr : __return_address, - bp->b_ops->name, bp->b_bn, BBTOB(bp->b_length)); + bp->b_ops->name, xfs_buf_daddr(bp), BBTOB(bp->b_length)); } /* @@ -589,7 +589,7 @@ xfs_buf_corruption_error( xfs_failaddr_t fa) { xfs_alert(NULL, "Metadata corruption detected at %p, %s block 0x%llx", - fa, bp->b_ops->name, bp->b_bn); + fa, bp->b_ops->name, xfs_buf_daddr(bp)); } /* diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 2ae81fac..9ba0bb34 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -311,7 +311,6 @@ xfs_get_aghdr_buf( if (error) return error; - bp->b_bn = blkno; bp->b_maps[0].bm_bn = blkno; bp->b_ops = ops; diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 308fc0f7..76a52573 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -1203,7 +1203,7 @@ xfs_attr3_leaf_to_node( memcpy(bp2->b_addr, bp1->b_addr, args->geo->blksize); if (xfs_has_crc(mp)) { struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; - hdr3->blkno = cpu_to_be64(bp2->b_bn); + hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp2)); } xfs_trans_log_buf(args->trans, bp2, 0, args->geo->blksize - 1); @@ -1271,7 +1271,7 @@ xfs_attr3_leaf_create( ichdr.magic = XFS_ATTR3_LEAF_MAGIC; - hdr3->blkno = cpu_to_be64(bp->b_bn); + hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr3->owner = cpu_to_be64(dp->i_ino); uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid); diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 73eb256e..afa93290 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -129,7 +129,7 @@ __xfs_attr3_rmt_read_verify( return 0; ptr = bp->b_addr; - bno = bp->b_bn; + bno = xfs_buf_daddr(bp); len = BBTOB(bp->b_length); ASSERT(len >= blksize); @@ -194,7 +194,7 @@ xfs_attr3_rmt_write_verify( return; ptr = bp->b_addr; - bno = bp->b_bn; + bno = xfs_buf_daddr(bp); len = BBTOB(bp->b_length); ASSERT(len >= blksize); @@ -283,7 +283,7 @@ xfs_attr_rmtval_copyout( uint8_t **dst) { char *src = bp->b_addr; - xfs_daddr_t bno = bp->b_bn; + xfs_daddr_t bno = xfs_buf_daddr(bp); int len = BBTOB(bp->b_length); int blksize = mp->m_attr_geo->blksize; @@ -331,7 +331,7 @@ xfs_attr_rmtval_copyin( uint8_t **src) { char *dst = bp->b_addr; - xfs_daddr_t bno = bp->b_bn; + xfs_daddr_t bno = xfs_buf_daddr(bp); int len = BBTOB(bp->b_length); int blksize = mp->m_attr_geo->blksize; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 1edf6236..d5ccce1f 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -732,7 +732,7 @@ xfs_bmap_extents_to_btree( */ abp->b_ops = &xfs_bmbt_buf_ops; ablock = XFS_BUF_TO_BLOCK(abp); - xfs_btree_init_block_int(mp, ablock, abp->b_bn, + xfs_btree_init_block_int(mp, ablock, xfs_buf_daddr(abp), XFS_BTNUM_BMAP, 0, 0, ip->i_ino, XFS_BTREE_LONG_PTRS); diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index ba1fb3c1..b42ee13d 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -67,7 +67,7 @@ __xfs_btree_check_lblock( if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (block->bb_u.l.bb_blkno != - cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL)) + cpu_to_be64(bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL)) return __this_address; if (block->bb_u.l.bb_pad != cpu_to_be32(0)) return __this_address; @@ -132,7 +132,7 @@ __xfs_btree_check_sblock( if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; if (block->bb_u.s.bb_blkno != - cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL)) + cpu_to_be64(bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL)) return __this_address; } @@ -1128,7 +1128,7 @@ xfs_btree_init_block( __u16 numrecs, __u64 owner) { - xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, + xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), xfs_buf_daddr(bp), btnum, level, numrecs, owner, 0); } @@ -1152,9 +1152,9 @@ xfs_btree_init_block_cur( else owner = cur->bc_ag.pag->pag_agno; - xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, - cur->bc_btnum, level, numrecs, - owner, cur->bc_flags); + xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), + xfs_buf_daddr(bp), cur->bc_btnum, level, + numrecs, owner, cur->bc_flags); } /* @@ -2924,10 +2924,11 @@ xfs_btree_new_iroot( */ memcpy(cblock, block, xfs_btree_block_len(cur)); if (cur->bc_flags & XFS_BTREE_CRC_BLOCKS) { + __be64 bno = cpu_to_be64(xfs_buf_daddr(cbp)); if (cur->bc_flags & XFS_BTREE_LONG_PTRS) - cblock->bb_u.l.bb_blkno = cpu_to_be64(cbp->b_bn); + cblock->bb_u.l.bb_blkno = bno; else - cblock->bb_u.s.bb_blkno = cpu_to_be64(cbp->b_bn); + cblock->bb_u.s.bb_blkno = bno; } be16_add_cpu(&block->bb_level, 1); @@ -3226,7 +3227,7 @@ xfs_btree_insrec( /* Get pointers to the btree buffer and block. */ block = xfs_btree_get_block(cur, level, &bp); - old_bn = bp ? bp->b_bn : XFS_BUF_DADDR_NULL; + old_bn = bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL; numrecs = xfs_btree_get_numrecs(block); #ifdef DEBUG @@ -3342,7 +3343,7 @@ xfs_btree_insrec( * some records into the new tree block), so use the regular key * update mechanism. */ - if (bp && bp->b_bn != old_bn) { + if (bp && xfs_buf_daddr(bp) != old_bn) { xfs_btree_get_keys(cur, block, lkey); } else if (xfs_btree_needs_key_update(cur, optr)) { error = xfs_btree_update_keys(cur, level); @@ -4423,7 +4424,7 @@ xfs_btree_lblock_v5hdr_verify( return __this_address; if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (block->bb_u.l.bb_blkno != cpu_to_be64(bp->b_bn)) + if (block->bb_u.l.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) return __this_address; if (owner != XFS_RMAP_OWN_UNKNOWN && be64_to_cpu(block->bb_u.l.bb_owner) != owner) @@ -4473,7 +4474,7 @@ xfs_btree_sblock_v5hdr_verify( return __this_address; if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn)) + if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) return __this_address; if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno) return __this_address; diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index d2dec4aa..0e504d2d 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -191,7 +191,7 @@ xfs_da3_blkinfo_verify( if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (be64_to_cpu(hdr3->blkno) != bp->b_bn) + if (be64_to_cpu(hdr3->blkno) != xfs_buf_daddr(bp)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) return __this_address; @@ -444,7 +444,7 @@ xfs_da3_node_create( memset(hdr3, 0, sizeof(struct xfs_da3_node_hdr)); ichdr.magic = XFS_DA3_NODE_MAGIC; - hdr3->info.blkno = cpu_to_be64(bp->b_bn); + hdr3->info.blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr3->info.owner = cpu_to_be64(args->dp->i_ino); uuid_copy(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid); } else { @@ -708,7 +708,7 @@ xfs_da3_root_split( oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { struct xfs_da3_intnode *node3 = (struct xfs_da3_intnode *)node; - node3->hdr.info.blkno = cpu_to_be64(bp->b_bn); + node3->hdr.info.blkno = cpu_to_be64(xfs_buf_daddr(bp)); } xfs_trans_log_buf(tp, bp, 0, size - 1); @@ -1216,7 +1216,7 @@ xfs_da3_root_join( xfs_trans_buf_copy_type(root_blk->bp, bp); if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; - da3->blkno = cpu_to_be64(root_blk->bp->b_bn); + da3->blkno = cpu_to_be64(xfs_buf_daddr(root_blk->bp)); } xfs_trans_log_buf(args->trans, root_blk->bp, 0, args->geo->blksize - 1); diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index f5d0f703..1b8c2521 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -53,7 +53,7 @@ xfs_dir3_block_verify( if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (be64_to_cpu(hdr3->blkno) != bp->b_bn) + if (be64_to_cpu(hdr3->blkno) != xfs_buf_daddr(bp)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) return __this_address; @@ -171,7 +171,7 @@ xfs_dir3_block_init( if (xfs_has_crc(mp)) { memset(hdr3, 0, sizeof(*hdr3)); hdr3->magic = cpu_to_be32(XFS_DIR3_BLOCK_MAGIC); - hdr3->blkno = cpu_to_be64(bp->b_bn); + hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr3->owner = cpu_to_be64(dp->i_ino); uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid); return; diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c index 85cb14d3..4e207986 100644 --- a/libxfs/xfs_dir2_data.c +++ b/libxfs/xfs_dir2_data.c @@ -297,7 +297,7 @@ xfs_dir3_data_verify( if (xfs_has_crc(mp)) { if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (be64_to_cpu(hdr3->blkno) != bp->b_bn) + if (be64_to_cpu(hdr3->blkno) != xfs_buf_daddr(bp)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) return __this_address; @@ -719,7 +719,7 @@ xfs_dir3_data_init( memset(hdr3, 0, sizeof(*hdr3)); hdr3->magic = cpu_to_be32(XFS_DIR3_DATA_MAGIC); - hdr3->blkno = cpu_to_be64(bp->b_bn); + hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr3->owner = cpu_to_be64(dp->i_ino); uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid); diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index 70b1f083..8827c96c 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -106,7 +106,7 @@ xfs_dir3_leaf1_check( if (leafhdr.magic == XFS_DIR3_LEAF1_MAGIC) { struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; - if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn) + if (be64_to_cpu(leaf3->info.blkno) != xfs_buf_daddr(bp)) return __this_address; } else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC) return __this_address; @@ -314,7 +314,7 @@ xfs_dir3_leaf_init( leaf3->info.hdr.magic = (type == XFS_DIR2_LEAF1_MAGIC) ? cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) : cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); - leaf3->info.blkno = cpu_to_be64(bp->b_bn); + leaf3->info.blkno = cpu_to_be64(xfs_buf_daddr(bp)); leaf3->info.owner = cpu_to_be64(owner); uuid_copy(&leaf3->info.uuid, &mp->m_sb.sb_meta_uuid); } else { diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index e7ed4b46..c0eb335c 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -65,7 +65,7 @@ xfs_dir3_leafn_check( if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC) { struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; - if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn) + if (be64_to_cpu(leaf3->info.blkno) != xfs_buf_daddr(bp)) return __this_address; } else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC) return __this_address; @@ -107,7 +107,7 @@ xfs_dir3_free_verify( if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (be64_to_cpu(hdr3->blkno) != bp->b_bn) + if (be64_to_cpu(hdr3->blkno) != xfs_buf_daddr(bp)) return __this_address; if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) return __this_address; @@ -343,7 +343,7 @@ xfs_dir3_free_get_buf( hdr.magic = XFS_DIR3_FREE_MAGIC; - hdr3->hdr.blkno = cpu_to_be64(bp->b_bn); + hdr3->hdr.blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr3->hdr.owner = cpu_to_be64(dp->i_ino); uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_meta_uuid); } else diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 516dab25..68bd5f52 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -68,7 +68,7 @@ xfs_inode_buf_verify( #ifdef DEBUG xfs_alert(mp, "bad inode magic/vsn daddr %lld #%d (magic=%x)", - (unsigned long long)bp->b_bn, i, + (unsigned long long)xfs_buf_daddr(bp), i, be16_to_cpu(dip->di_magic)); #endif xfs_buf_verifier_error(bp, -EFSCORRUPTED, diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 680441ae..d7e3526c 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -745,7 +745,7 @@ xfs_sb_read_verify( if (!xfs_buf_verify_cksum(bp, XFS_SB_CRC_OFF)) { /* Only fail bad secondaries on a known V5 filesystem */ - if (bp->b_maps[0].bm_bn == XFS_SB_DADDR || + if (xfs_buf_daddr(bp) == XFS_SB_DADDR || xfs_has_crc(mp)) { error = -EFSBADCRC; goto out_error; diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c index e0a68319..a5cbb40f 100644 --- a/libxfs/xfs_symlink_remote.c +++ b/libxfs/xfs_symlink_remote.c @@ -48,7 +48,7 @@ xfs_symlink_hdr_set( dsl->sl_bytes = cpu_to_be32(size); uuid_copy(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid); dsl->sl_owner = cpu_to_be64(ino); - dsl->sl_blkno = cpu_to_be64(bp->b_bn); + dsl->sl_blkno = cpu_to_be64(xfs_buf_daddr(bp)); bp->b_ops = &xfs_symlink_buf_ops; return sizeof(struct xfs_dsymlink_hdr); @@ -92,7 +92,7 @@ xfs_symlink_verify( return __this_address; if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid)) return __this_address; - if (bp->b_bn != be64_to_cpu(dsl->sl_blkno)) + if (xfs_buf_daddr(bp) != be64_to_cpu(dsl->sl_blkno)) return __this_address; if (be32_to_cpu(dsl->sl_offset) + be32_to_cpu(dsl->sl_bytes) >= XFS_SYMLINK_MAXLEN) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index df1b519f..927dd095 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -935,14 +935,14 @@ __check_attr_header( do_warn( _("expected owner inode %" PRIu64 ", got %llu, attr block %" PRIu64 "\n"), ino, (unsigned long long)be64_to_cpu(info->owner), - bp->b_bn); + xfs_buf_daddr(bp)); return 1; } /* verify block number */ - if (be64_to_cpu(info->blkno) != bp->b_bn) { + if (be64_to_cpu(info->blkno) != xfs_buf_daddr(bp)) { do_warn( _("expected block %" PRIu64 ", got %llu, inode %" PRIu64 "attr block\n"), - bp->b_bn, (unsigned long long)be64_to_cpu(info->blkno), + xfs_buf_daddr(bp), (unsigned long long)be64_to_cpu(info->blkno), ino); return 1; } @@ -950,7 +950,7 @@ _("expected block %" PRIu64 ", got %llu, inode %" PRIu64 "attr block\n"), if (platform_uuid_compare(&info->uuid, &mp->m_sb.sb_meta_uuid) != 0) { do_warn( _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"), - ino, bp->b_bn); + ino, xfs_buf_daddr(bp)); return 1; } diff --git a/repair/phase6.c b/repair/phase6.c index 647dc1c5..9e60c87b 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -1905,21 +1905,21 @@ __check_dir3_header( if (be64_to_cpu(owner) != ino) { do_warn( _("expected owner inode %" PRIu64 ", got %llu, directory block %" PRIu64 "\n"), - ino, (unsigned long long)be64_to_cpu(owner), bp->b_bn); + ino, (unsigned long long)be64_to_cpu(owner), xfs_buf_daddr(bp)); return 1; } /* verify block number */ - if (be64_to_cpu(blkno) != bp->b_bn) { + if (be64_to_cpu(blkno) != xfs_buf_daddr(bp)) { do_warn( _("expected block %" PRIu64 ", got %llu, directory inode %" PRIu64 "\n"), - bp->b_bn, (unsigned long long)be64_to_cpu(blkno), ino); + xfs_buf_daddr(bp), (unsigned long long)be64_to_cpu(blkno), ino); return 1; } /* verify uuid */ if (platform_uuid_compare(uuid, &mp->m_sb.sb_meta_uuid) != 0) { do_warn( _("wrong FS UUID, directory inode %" PRIu64 " block %" PRIu64 "\n"), - ino, bp->b_bn); + ino, xfs_buf_daddr(bp)); return 1; } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index bcd44cd5..4769c130 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -850,7 +850,7 @@ repair_capture_writeback( * avoid hook recursion when setting NEEDSREPAIR. Higher level code * modifying an sb must control the flag manually. */ - if (bp->b_ops == &xfs_sb_buf_ops || bp->b_bn == XFS_SB_DADDR) + if (bp->b_ops == &xfs_sb_buf_ops || xfs_buf_daddr(bp) == XFS_SB_DADDR) return; pthread_mutex_lock(&wb_mutex); From patchwork Tue Sep 14 02:43:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12491487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FF63C433EF for ; Tue, 14 Sep 2021 02:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34796610F9 for ; Tue, 14 Sep 2021 02:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237777AbhINCpM (ORCPT ); Mon, 13 Sep 2021 22:45:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:54214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhINCpM (ORCPT ); Mon, 13 Sep 2021 22:45:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84648606A5; Tue, 14 Sep 2021 02:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631587435; bh=0ytJwPl/d8MP7d7DBcGmB7eMBgXWXz1J+j0jei3hwU8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=f3iFFOzD/zjZJ1gTTdzGXts9pHGb+dhbkbGdlmjOfQtEiKFqhaTMTayM9elesEUo4 teRtIf8ikx5WK5fFoPEMOsq/HGToLIdxr7A+5GeKAGenzKbC21p727J5jGE5ujJ70J KPA81eCOI1FdnyrnSHhKygl8xlOXI1Bquf7SPzqjuXgIDruEfccME9YnbzUoyW0Hbm hLN8piRHofb0N7x1Or2Ly+jjvAQNXuqeuBVOoSrH0gfTXLjCs2mT24PjkO3lN5jS92 GQ+wxYLbd4CCunym+1ubdBjTTvPv/QVSnd+h38/i+YcFd91InqlvfQzmcAKswJkzl2 55Lf7Q6zPWCow== Subject: [PATCH 43/43] libxfs: rename buffer cache index variable b_bn From: "Darrick J. Wong" To: sandeen@sandeen.net, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Date: Mon, 13 Sep 2021 19:43:55 -0700 Message-ID: <163158743528.1604118.7773426223391954589.stgit@magnolia> In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia> References: <163158719952.1604118.14415288328687941574.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong To stop external users from using b_bn as the disk address of the buffer, rename it to b_rhash_key to indicate that it is the buffer cache index, not the block number of the buffer. Code that needs the disk address should use xfs_buf_daddr() to obtain it. Do the rename and clean up any of the remaining internal b_bn users. Also clean up any remaining b_bn cruft that is now unused. Inspired-by: Dave Chinner Signed-off-by: Darrick J. Wong --- libxfs/libxfs_io.h | 8 ++++---- libxfs/rdwr.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 1f2ac25b..e378f22b 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -79,7 +79,7 @@ struct xfs_buf_ops { struct xfs_buf { struct cache_node b_node; unsigned int b_flags; - xfs_daddr_t b_bn; + xfs_daddr_t b_cache_key; /* buffer cache index */ unsigned int b_length; struct xfs_buftarg *b_target; pthread_mutex_t b_lock; @@ -118,8 +118,8 @@ typedef unsigned int xfs_buf_flags_t; static inline xfs_daddr_t xfs_buf_daddr(struct xfs_buf *bp) { /* XXX remove me */ - if (bp->b_bn != bp->b_maps[0].bm_bn && bp->b_bn != -1ULL) { - fprintf(stderr, "FARTS buf %p bn %lx bmbn %lx intmap? %d\n", bp, bp->b_bn, bp->b_maps[0].bm_bn, bp->b_maps == &bp->__b_map); + if (bp->b_cache_key != bp->b_maps[0].bm_bn && bp->b_cache_key != -1ULL) { + fprintf(stderr, "FARTS buf %p bn %lx bmbn %lx intmap? %d\n", bp, bp->b_cache_key, bp->b_maps[0].bm_bn, bp->b_maps == &bp->__b_map); abort(); } return bp->b_maps[0].bm_bn; @@ -127,7 +127,7 @@ static inline xfs_daddr_t xfs_buf_daddr(struct xfs_buf *bp) static inline void xfs_buf_set_daddr(struct xfs_buf *bp, xfs_daddr_t blkno) { - assert(bp->b_bn == XFS_BUF_DADDR_NULL); + assert(bp->b_cache_key == XFS_BUF_DADDR_NULL); bp->b_maps[0].bm_bn = blkno; } diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 03dc2917..96f95ae3 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -205,7 +205,7 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key) struct xfs_bufkey *bkey = (struct xfs_bufkey *)key; if (bp->b_target->bt_bdev == bkey->buftarg->bt_bdev && - bp->b_bn == bkey->blkno) { + bp->b_cache_key == bkey->blkno) { if (bp->b_length == bkey->bblen) return CACHE_HIT; #ifdef IO_BCOMPARE_CHECK @@ -214,7 +214,7 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key) "%lx: Badness in key lookup (length)\n" "bp=(bno 0x%llx, len %u bytes) key=(bno 0x%llx, len %u bytes)\n", pthread_self(), - (unsigned long long)bp->b_bn, + (unsigned long long)xfs_buf_daddr(bp), BBTOB(bp->b_length), (unsigned long long)bkey->blkno, BBTOB(bkey->bblen)); @@ -230,7 +230,7 @@ __initbuf(struct xfs_buf *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, unsigned int bytes) { bp->b_flags = 0; - bp->b_bn = bno; + bp->b_cache_key = bno; bp->b_length = BTOBB(bytes); bp->b_target = btp; bp->b_mount = btp->bt_mount; @@ -256,7 +256,7 @@ __initbuf(struct xfs_buf *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, if (bp->b_maps == &bp->__b_map) { bp->b_nmaps = 1; - bp->b_maps[0].bm_bn = bp->b_bn; + bp->b_maps[0].bm_bn = bno; bp->b_maps[0].bm_len = bp->b_length; } } @@ -591,7 +591,7 @@ libxfs_readbufr(struct xfs_buftarg *btp, xfs_daddr_t blkno, struct xfs_buf *bp, error = __read_buf(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno), flags); if (!error && bp->b_target->bt_bdev == btp->bt_bdev && - bp->b_bn == blkno && + bp->b_cache_key == blkno && bp->b_length == len) bp->b_flags |= LIBXFS_B_UPTODATE; bp->b_error = error; @@ -833,14 +833,14 @@ libxfs_bwrite( fprintf(stderr, _("%s: write verifier failed on %s bno 0x%llx/0x%x\n"), __func__, bp->b_ops->name, - (long long)bp->b_bn, bp->b_length); + (long long)xfs_buf_daddr(bp), bp->b_length); return bp->b_error; } } if (!(bp->b_flags & LIBXFS_B_DISCONTIG)) { bp->b_error = __write_buf(fd, bp->b_addr, BBTOB(bp->b_length), - LIBXFS_BBTOOFF64(bp->b_bn), bp->b_flags); + LIBXFS_BBTOOFF64(xfs_buf_daddr(bp)), bp->b_flags); } else { int i; void *buf = bp->b_addr; @@ -861,7 +861,7 @@ libxfs_bwrite( fprintf(stderr, _("%s: write failed on %s bno 0x%llx/0x%x, err=%d\n"), __func__, bp->b_ops ? bp->b_ops->name : "(unknown)", - (long long)bp->b_bn, bp->b_length, -bp->b_error); + (long long)xfs_buf_daddr(bp), bp->b_length, -bp->b_error); } else { bp->b_flags |= LIBXFS_B_UPTODATE; bp->b_flags &= ~(LIBXFS_B_DIRTY | LIBXFS_B_UNCHECKED);