From patchwork Mon Apr 22 16:26:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13638747 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9A5E153BFE for ; Mon, 22 Apr 2024 16:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713804049; cv=none; b=KQ7qaA3YGJpMbsjor8VrqGskLAYbBwsH4DJv0hftMppm9HQPh+krdr/JAGRh22O5h1TSvMxfZotqCqDX+oQDXvvl+FaTWgJhaz0IlSJf0/a4z3jLg6fG4irnN0WWhHljqMPyf8cOf1Ik91sZdTijHLodXph/KqfXR5/lUpBf0BU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713804049; c=relaxed/simple; bh=xBdqNSpQfYAPtMtOBkzeDjQB8lwX4ELnytvU2/LkD+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QkIECdSlA5onpTCFVWcQgr4o8WaJc+EGscX9tBFHxZvI6SlIEwMOp+GcFA5bsLTBzO5C6aahyz/a+GXQ33zvQ82iie8F/SMwWADpIt421tbxSD39yGBBr5ap29ww1AdHzqYxA2BLQ1PY+yZK+hdLQMoP/gJ0rw6wc+qM0SJDp+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eE/R52lJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eE/R52lJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9005C116B1; Mon, 22 Apr 2024 16:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713804049; bh=xBdqNSpQfYAPtMtOBkzeDjQB8lwX4ELnytvU2/LkD+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eE/R52lJMuBsd4AjMTUvAnAMk9bhMB24pYIU4oB2g1gluF7j2ZZQTUQyb3TGCod09 tpQCA9GEUMElLDQ0/j/lj1yi0r8aeuXMF/4Rw+gAA0LY1ZSZ/KBpDhx1clTMZUJ9Ev f9tLpU+d/aok7OPEQqjCKP2p7XGA/12wLikPhcJSSjBjoJFitWD5di8hJWlgSgbU6W FUIZ6t135YssKd/vSFdd4XQ4DkJE7R2pUn2YE7S0UvOkABLYI9lZMf0DKsb/JgnL5W Z2r1KzwGghw5Wvl+cz8dZMd4x4zir9h4NqjltQ2o6vKcDm028qd1hIwoEEQHiTgARC b9fpvBMs9MqOg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, hch@lst.de Subject: [PATCH 67/67] xfs: remove conditional building of rt geometry validator functions Date: Mon, 22 Apr 2024 18:26:29 +0200 Message-ID: <20240422163832.858420-69-cem@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422163832.858420-2-cem@kernel.org> References: <20240422163832.858420-2-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Darrick J. Wong" Source kernel commit: 881f78f472556ed05588172d5b5676b48dc48240 I mistakenly turned off CONFIG_XFS_RT in the Kconfig file for arm64 variant of the djwong-wtf git branch. Unfortunately, it took me a good hour to figure out that RT wasn't built because this is what got printed to dmesg: XFS (sda2): realtime geometry sanity check failed XFS (sda2): Metadata corruption detected at xfs_sb_read_verify+0x170/0x190 [xfs], xfs_sb block 0x0 Whereas I would have expected: XFS (sda2): Not built with CONFIG_XFS_RT XFS (sda2): RT mount failed The root cause of these problems is the conditional compilation of the new functions xfs_validate_rtextents and xfs_compute_rextslog that I introduced in the two commits listed below. The !RT versions of these functions return false and 0, respectively, which causes primary superblock validation to fail, which explains the first message. Move the two functions to other parts of libxfs that are not conditionally defined by CONFIG_XFS_RT and remove the broken stubs so that validation works again. Fixes: e14293803f4e ("xfs: don't allow overly small or large realtime volumes") Fixes: a6a38f309afc ("xfs: make rextslog computation consistent with mkfs") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 14 -------------- libxfs/xfs_rtbitmap.h | 16 ---------------- libxfs/xfs_sb.c | 14 ++++++++++++++ libxfs/xfs_sb.h | 2 ++ libxfs/xfs_types.h | 12 ++++++++++++ 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 79af7cda3..08a4128fc 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1116,20 +1116,6 @@ xfs_rtbitmap_blockcount( return howmany_64(rtextents, NBBY * mp->m_sb.sb_blocksize); } -/* - * Compute the maximum level number of the realtime summary file, as defined by - * mkfs. The historic use of highbit32 on a 64-bit quantity prohibited correct - * use of rt volumes with more than 2^32 extents. - */ -uint8_t -xfs_compute_rextslog( - xfs_rtbxlen_t rtextents) -{ - if (!rtextents) - return 0; - return xfs_highbit64(rtextents); -} - /* * Compute the number of rtbitmap words needed to populate every block of a * bitmap that is large enough to track the given number of rt extents. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 274dc7dae..152a66750 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -351,20 +351,6 @@ xfs_rtfree_extent( int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, xfs_filblks_t rtlen); -uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents); - -/* Do we support an rt volume having this number of rtextents? */ -static inline bool -xfs_validate_rtextents( - xfs_rtbxlen_t rtextents) -{ - /* No runt rt volumes */ - if (rtextents == 0) - return false; - - return true; -} - xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents); unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp, @@ -383,8 +369,6 @@ unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp, # define xfs_rtsummary_read_buf(a,b) (-ENOSYS) # define xfs_rtbuf_cache_relse(a) (0) # define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) -# define xfs_compute_rextslog(rtx) (0) -# define xfs_validate_rtextents(rtx) (false) static inline xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents) { diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 7a72d5a17..402f03a55 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1375,3 +1375,17 @@ xfs_validate_stripe_geometry( } return true; } + +/* + * Compute the maximum level number of the realtime summary file, as defined by + * mkfs. The historic use of highbit32 on a 64-bit quantity prohibited correct + * use of rt volumes with more than 2^32 extents. + */ +uint8_t +xfs_compute_rextslog( + xfs_rtbxlen_t rtextents) +{ + if (!rtextents) + return 0; + return xfs_highbit64(rtextents); +} diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index 19134b23c..2e8e8d63d 100644 --- a/libxfs/xfs_sb.h +++ b/libxfs/xfs_sb.h @@ -38,4 +38,6 @@ extern int xfs_sb_get_secondary(struct xfs_mount *mp, extern bool xfs_validate_stripe_geometry(struct xfs_mount *mp, __s64 sunit, __s64 swidth, int sectorsize, bool silent); +uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents); + #endif /* __XFS_SB_H__ */ diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 20b5375f2..62e02d538 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -251,4 +251,16 @@ bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off); bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off, xfs_fileoff_t len); +/* Do we support an rt volume having this number of rtextents? */ +static inline bool +xfs_validate_rtextents( + xfs_rtbxlen_t rtextents) +{ + /* No runt rt volumes */ + if (rtextents == 0) + return false; + + return true; +} + #endif /* __XFS_TYPES_H__ */