From patchwork Thu Feb 15 12:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558264 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 382FE57872 for ; Thu, 15 Feb 2024 12:09:15 +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=1707998956; cv=none; b=I6bAecA4tujwuTa2VOm2UHxOorFt48/IuHvlRxvT1xDnKlFnvnQyQqROXWUO6CyGna+2gMbe8YPywbr4TJNBBUPjOwppVNNyHWYVifxS9k4uhBlPatmlSJT2zSP1+vpU1hr/hxBBowYRCwpQhFY5bm4RTyNIARWZyfptBAud3sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998956; c=relaxed/simple; bh=iwDMepkuoscv3NdEa0bdBQ71P/lOFy4WfEClCFIYWls=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bazk/AK5h/kod/nMoXB7EWTh2XB0X6ss7JXu6d9OpaxxW1PU/T1Bmmb7ViYgmlizSfFLzGksto57EKnhnnEA4bptvMOhfh0PyBF1ZIauDBfoUXWwwR+/Q1xHwsLhetQcg3bDs592Uo4oo992BHHdRY7nCXklzl/XgeNUovvLFx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BjfOdRLK; 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="BjfOdRLK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 150D3C433C7 for ; Thu, 15 Feb 2024 12:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998955; bh=iwDMepkuoscv3NdEa0bdBQ71P/lOFy4WfEClCFIYWls=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BjfOdRLKgW5I2f79X4D8xYoHnBBDQBzQDs6rIjlynvCPZO8qmAbJN4KuK+JQjIDT5 ZpXh3YjLXhWZKPGyp9NBD61pwsha1rmunsDb6afZ2iHu2MYZMUBRDOnrGQK2k9vRLP 74k5rzH0VJzP4oL5KCPWWsCl7soUa/sPvwbsORj0XURbm6n/x72dSVGoj0lXfuFxfc ZTW3NR46oxzyLN+x7O9T5rDH7stfioQ4Lck2N9A+TOM6hRW2zNHv05MM8K2jQKTc0I mPyrMeN1exYmZIaDPqiydJQTi1lx9nyNmhRLLhSI5keTfvUCBLdsUPaX2mk8HjxVuJ 4vBpbB5WY4kXg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 01/35] xfs: bump max fsgeom struct version Date: Thu, 15 Feb 2024 13:08:13 +0100 Message-ID: <20240215120907.1542854-2-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 9488062805943c2d63350d3ef9e4dc093799789a The latest version of the fs geometry structure is v5. Bump this constant so that xfs_db and mkfs calls to libxfs_fs_geometry will fill out all the fields. IOWs, this commit is a no-op for the kernel, but will be useful for userspace reporting in later changes. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_sb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index a5e14740e..19134b23c 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) +#define XFS_FS_GEOM_MAX_STRUCT_VER (5) 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, From patchwork Thu Feb 15 12:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558265 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 4F14657872 for ; Thu, 15 Feb 2024 12:09:16 +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=1707998957; cv=none; b=dXvyUiHoVWPgRjSzhHGL7NlKeWLsC/iGR8MpMEfp6ZequBL0cL64oJ99GGnvnnY73VSA/pw1H5SCLTMqotUzDZkDE0ARRarWZvW+0GWqe2CWJNJjpNF1/QLeK8iXsFanzUOBGARDB1WKtB6d31qmAiZwauKZZO2I1GDexIQwuiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998957; c=relaxed/simple; bh=P6dT2IrOzvHkh0DUIgtUXOIUjL8DP7i7+uZNjtnqZio=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j8Pbkfgl+dK8qu3uR38C36zWbf/yHVPgYYAvBhXg1XYBYDP7Gh9ZFG3CHp9Ap11MuyGRozDh15pjb4SYUtmfMsrF8bznhhaV5SHmdwOJgH336b1Gm36QLf4/BXypAQQxzl0GPzO7aaduuUM0U0I/KxotkkgWoURuaCQzedIiSRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=guch9t/X; 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="guch9t/X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DF36C433F1 for ; Thu, 15 Feb 2024 12:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998956; bh=P6dT2IrOzvHkh0DUIgtUXOIUjL8DP7i7+uZNjtnqZio=; h=From:To:Subject:Date:In-Reply-To:References:From; b=guch9t/X06Fr5ea/azhETxeLmuOGryBHyN2ACH3eWvpsoHEsjkPOTydZl+NjJlZpU 9a/JAOkaNf0Cm7nbuGg0nqisJ+rEVE7j8/mVZYvk0e6KHTrSSTDWb3wOaUfB9yGQRS ClPcivDJkVc/6RV/Hq/28dgIAUU1HeZmGnFSw5ukVC+piAIJXA0iPV36Dxv1SBmAUY SQM9f7l8g63KCra4AqiMePk09lIRP/YPW+2WHoFe+WbogDdlJl/4iT4pB5PgClMvp5 bNpDURCVJxAbjS/E/s7Kvijec3qFUsFYZB4pWU5wWKFDPD/+5NP8AEMRoSR2Umi3zo OYXgSZn3f4/Hw== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 02/35] xfs: hoist freeing of rt data fork extent mappings Date: Thu, 15 Feb 2024 13:08:14 +0100 Message-ID: <20240215120907.1542854-3-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 6c664484337b37fa0cf6e958f4019623e30d40f7 Currently, xfs_bmap_del_extent_real contains a bunch of code to convert the physical extent of a data fork mapping for a realtime file into rt extents and pass that to the rt extent freeing function. Since the details of this aren't needed when CONFIG_XFS_REALTIME=n, move it to xfs_rtbitmap.c to reduce code size when realtime isn't enabled. This will (one day) enable realtime EFIs to reuse the same unit-converting call with less code duplication. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/libxfs_api_defs.h | 1 + libxfs/libxfs_priv.h | 1 + libxfs/xfs_bmap.c | 19 +++---------------- libxfs/xfs_rtbitmap.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 04277c009..a16efa007 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -176,6 +176,7 @@ #define xfs_rmap_query_range libxfs_rmap_query_range #define xfs_rtfree_extent libxfs_rtfree_extent +#define xfs_rtfree_blocks libxfs_rtfree_blocks #define xfs_sb_from_disk libxfs_sb_from_disk #define xfs_sb_quota_from_disk libxfs_sb_quota_from_disk #define xfs_sb_read_secondary libxfs_sb_read_secondary diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 5a7decf97..21d772cf4 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -497,6 +497,7 @@ xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); /* XXX: this is clearly a bug - a shared header needs to export this */ /* xfs_rtalloc.c */ int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); +int libxfs_rtfree_blocks(struct xfs_trans *, xfs_fsblock_t, xfs_filblks_t); bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); struct xfs_rtalloc_rec { diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 2bd23d40e..5744b882b 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -5050,33 +5050,20 @@ xfs_bmap_del_extent_real( flags = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { - xfs_filblks_t len; - xfs_extlen_t mod; - - len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize, - &mod); - ASSERT(mod == 0); - if (!(bflags & XFS_BMAPI_REMAP)) { - xfs_fsblock_t bno; - - bno = div_u64_rem(del->br_startblock, - mp->m_sb.sb_rextsize, &mod); - ASSERT(mod == 0); - - error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); + error = xfs_rtfree_blocks(tp, del->br_startblock, + del->br_blockcount); if (error) goto done; } do_fx = 0; - nblks = len * mp->m_sb.sb_rextsize; qfield = XFS_TRANS_DQ_RTBCOUNT; } else { do_fx = 1; - nblks = del->br_blockcount; qfield = XFS_TRANS_DQ_BCOUNT; } + nblks = del->br_blockcount; del_endblock = del->br_startblock + del->br_blockcount; if (cur) { diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index bc8312caf..2c20c6538 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1003,6 +1003,39 @@ xfs_rtfree_extent( return 0; } +/* + * Free some blocks in the realtime subvolume. rtbno and rtlen are in units of + * rt blocks, not rt extents; must be aligned to the rt extent size; and rtlen + * cannot exceed XFS_MAX_BMBT_EXTLEN. + */ +int +xfs_rtfree_blocks( + struct xfs_trans *tp, + xfs_fsblock_t rtbno, + xfs_filblks_t rtlen) +{ + struct xfs_mount *mp = tp->t_mountp; + xfs_rtblock_t bno; + xfs_filblks_t len; + xfs_extlen_t mod; + + ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN); + + len = div_u64_rem(rtlen, mp->m_sb.sb_rextsize, &mod); + if (mod) { + ASSERT(mod == 0); + return -EIO; + } + + bno = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod); + if (mod) { + ASSERT(mod == 0); + return -EIO; + } + + return xfs_rtfree_extent(tp, bno, len); +} + /* Find all the free records within a given range. */ int xfs_rtalloc_query_range( From patchwork Thu Feb 15 12:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558266 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 5BBD612BF0A for ; Thu, 15 Feb 2024 12:09:17 +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=1707998958; cv=none; b=jZ1Sq9aY1IS+RzQmKpKN97I65JhqwLKof4fiEExjsWnI0gduF0+J+6cyHNvTq7VAxYc8logj/upGhy0Q4mHj9uqvZ9Yww7jHTz4sPXG6N3V36AP6AhyNoBhcyuN30wWL3IvshyK/WJ1ebz8mpg42+MQnwD3XbCKReQcwC/HnP+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998958; c=relaxed/simple; bh=0kGi0ZBqv4YPq+st3TjI96DpFb7s4oMCZSz7ydWjXQQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MtPG/SzDeKXbqgYOVZ1tT+hlbt4dRyB5y2JZQZlZCtTzLTz99nnRO3ImNbLIANqIpYQHCJmuzLyH+wDjzpGvpYqGaNsO0TeKksomuQBvr2+x6rXgwSm5futqfDR23EjAVfnvmPJdafP81FdQoOeWqW9W78FK8/3A37LgTEvRNzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BRBhyK7Q; 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="BRBhyK7Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38B9CC433A6 for ; Thu, 15 Feb 2024 12:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998957; bh=0kGi0ZBqv4YPq+st3TjI96DpFb7s4oMCZSz7ydWjXQQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BRBhyK7QIjSSF78WWVtoIt9i3FBp/037HMbgBupCUkK1FIOMSmTJSOO0wFXVd/c54 qBgBkOwPX4YfIDWeiHkMhe7zGTnOtO/F9k7szXJXbrB6Z99Iev54zPeEymHtV+dSso /ADiflceIv43jIY4xOy66gcaPiGrIMnL/+tbd092180zXcZOI5bZgbhZnnj7Xu1sWH j4q2vipfPIWxOADD+Nwfl8TtsQS9AhaMw/Dn/G3a/W9l4yGRYRsWJ+G36ZspILBloP clWBhDju11u8Bmne9igHf3X6PJGftnjQmqqGqljA70Gvhin7Px477oy6IvCZEuhrfd +Ep1Pg11OrZZQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 03/35] xfs: fix units conversion error in xfs_bmap_del_extent_delay Date: Thu, 15 Feb 2024 13:08:15 +0100 Message-ID: <20240215120907.1542854-4-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: ddd98076d5c075c8a6c49d9e6e8ee12844137f23 The unit conversions in this function do not make sense. First we convert a block count to bytes, then divide that bytes value by rextsize, which is in blocks, to get an rt extent count. You can't divide bytes by blocks to get a (possibly multiblock) extent value. Fortunately nobody uses delalloc on the rt volume so this hasn't mattered. Fixes: fa5c836ca8eb5 ("xfs: refactor xfs_bunmapi_cow") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 5744b882b..6fbfcb25a 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4820,7 +4820,7 @@ xfs_bmap_del_extent_delay( ASSERT(got_endoff >= del_endoff); if (isrt) { - uint64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount); + uint64_t rtexts = del->br_blockcount; do_div(rtexts, mp->m_sb.sb_rextsize); xfs_mod_frextents(mp, rtexts); From patchwork Thu Feb 15 12:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558267 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 6742712BF17 for ; Thu, 15 Feb 2024 12:09:19 +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=1707998959; cv=none; b=DMEuhQLzikG8wvEDUXq57MlWB3UH5FNIDMKVAFSqfzXHWyJiNptWAaPoVWtESV8wstuz6ToiUKsvvIXro/Hy1jcaR79gGP3jWR30OcTQsQBZ1aghQFEAHu0MpnStEVZ7BCFY5F77p4OnreWK49txVKdnSzitWL+78at4MJrIEVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998959; c=relaxed/simple; bh=PUZr2Cy0g5IXniPfdiNvYvPSIb0bDK6fHaUy8yjCtm4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lGFA+jDHMzcCADiRMUq0OPCuasp8nBY5iRI0hSxz7+rYLqrWokFvPdEaNQ3MzxGYkQgup/3ZSC4Y6YtlZmH66V17wkAhOMHhyUCmQvHFEtdlwTnqr6rVpRJD4Lg8ZrgxbEShm9rOUPsATG5LVzBQ3Rkq4J+8AaUQwfnqLWhg+MA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LLHzvi/0; 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="LLHzvi/0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E453C433F1 for ; Thu, 15 Feb 2024 12:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998958; bh=PUZr2Cy0g5IXniPfdiNvYvPSIb0bDK6fHaUy8yjCtm4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LLHzvi/0540lXm3mqw1SzTnWYbyY7zr7LZKNNoIx7pZ0VVHGHqhEnl1IebgJCrz/c lzpk1seBL3y3atwheJqzajADnx7qeowPA4Vok7FW/KLt+m/+IGIK36ePCQmD5J0ptI 5hvXPnKeH2erYiMg8DGctMTvVG/FwrDNvd7uKjIYpUAuOjXUL6y93AquSitQVIUUK+ TKCvqPzhKNjiVm00EqCcZuaJJrMEQMsmJaxM6CMcxKRce6mNS51zDC5+Vn+44EaT66 73BEW78BQbGAjkc+4a/t4FJk0Kdg6nr6keITYeqAVKGtAcrEgiroGDyLCOy7LwVqAw po4iA8oO2eqww== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 04/35] xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h Date: Thu, 15 Feb 2024 13:08:16 +0100 Message-ID: <20240215120907.1542854-5-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 13928113fc5b5e79c91796290a99ed991ac0efe2 Move all the declarations for functionality in xfs_rtbitmap.c into a separate xfs_rtbitmap.h header file. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/libxfs_priv.h | 56 ++--------------------------- libxfs/xfs_bmap.c | 1 + libxfs/xfs_rtbitmap.c | 1 + libxfs/xfs_rtbitmap.h | 82 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 54 deletions(-) create mode 100644 libxfs/xfs_rtbitmap.h diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 21d772cf4..ed437e38e 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -37,6 +37,8 @@ #ifndef __LIBXFS_INTERNAL_XFS_H__ #define __LIBXFS_INTERNAL_XFS_H__ +#define CONFIG_XFS_RT + #include "libxfs_api_defs.h" #include "platform_defs.h" #include "xfs.h" @@ -494,23 +496,6 @@ void xfs_inode_verifier_error(struct xfs_inode *ip, int error, void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); -/* XXX: this is clearly a bug - a shared header needs to export this */ -/* xfs_rtalloc.c */ -int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); -int libxfs_rtfree_blocks(struct xfs_trans *, xfs_fsblock_t, xfs_filblks_t); -bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); - -struct xfs_rtalloc_rec { - xfs_rtblock_t ar_startext; - xfs_rtblock_t ar_extcount; -}; - -typedef int (*xfs_rtalloc_query_range_fn)( - struct xfs_mount *mp, - 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); @@ -547,43 +532,6 @@ xfs_agnumber_t xfs_set_inode_alloc(struct xfs_mount *mp, xfs_agnumber_t agcount); /* Keep static checkers quiet about nonstatic functions by exporting */ -int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t block, int issum, struct xfs_buf **bpp); -int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, int val, - xfs_rtblock_t *new, int *stat); -int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtblock_t limit, - xfs_rtblock_t *rtblock); -int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtblock_t limit, - xfs_rtblock_t *rtblock); -int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, int val); -int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, - int log, xfs_rtblock_t bbno, int delta, - struct xfs_buf **rbpp, xfs_fsblock_t *rsb, - xfs_suminfo_t *sum); -int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, - xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, - xfs_fsblock_t *rsb); -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_mount *mp, - struct xfs_trans *tp, - 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_mount *mp, - struct xfs_trans *tp, - xfs_rtalloc_query_range_fn fn, - void *priv); -bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); -int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, - bool *is_free); /* xfs_bmap_util.h */ struct xfs_bmalloca; int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp, diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 6fbfcb25a..bc82b71f3 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -29,6 +29,7 @@ #include "xfs_ag.h" #include "xfs_ag_resv.h" #include "xfs_refcount.h" +#include "xfs_rtbitmap.h" struct kmem_cache *xfs_bmap_intent_cache; diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 2c20c6538..bd0925c9a 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -14,6 +14,7 @@ #include "xfs_inode.h" #include "xfs_bmap.h" #include "xfs_trans.h" +#include "xfs_rtbitmap.h" /* * Realtime allocator bitmap functions shared with userspace. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h new file mode 100644 index 000000000..546dea34b --- /dev/null +++ b/libxfs/xfs_rtbitmap.h @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. + * All Rights Reserved. + */ +#ifndef __XFS_RTBITMAP_H__ +#define __XFS_RTBITMAP_H__ + +/* + * XXX: Most of the realtime allocation functions deal in units of realtime + * extents, not realtime blocks. This looks funny when paired with the type + * name and screams for a larger cleanup. + */ +struct xfs_rtalloc_rec { + xfs_rtblock_t ar_startext; + xfs_rtblock_t ar_extcount; +}; + +typedef int (*xfs_rtalloc_query_range_fn)( + struct xfs_mount *mp, + struct xfs_trans *tp, + const struct xfs_rtalloc_rec *rec, + void *priv); + +#ifdef CONFIG_XFS_RT +int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t block, int issum, struct xfs_buf **bpp); +int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_extlen_t len, int val, + xfs_rtblock_t *new, int *stat); +int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_rtblock_t limit, + xfs_rtblock_t *rtblock); +int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_rtblock_t limit, + xfs_rtblock_t *rtblock); +int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_extlen_t len, int val); +int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, + int log, xfs_rtblock_t bbno, int delta, + struct xfs_buf **rbpp, xfs_fsblock_t *rsb, + xfs_suminfo_t *sum); +int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, + xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, + xfs_fsblock_t *rsb); +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_mount *mp, struct xfs_trans *tp, + 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_mount *mp, struct xfs_trans *tp, + xfs_rtalloc_query_range_fn fn, + void *priv); +bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); +int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_extlen_t len, + bool *is_free); +/* + * Free an extent in the realtime subvolume. Length is expressed in + * realtime extents, as is the block number. + */ +int /* error */ +xfs_rtfree_extent( + struct xfs_trans *tp, /* transaction pointer */ + xfs_rtblock_t bno, /* starting block number to free */ + xfs_extlen_t len); /* length of extent freed */ + +/* Same as above, but in units of rt blocks. */ +int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, + xfs_filblks_t rtlen); +#else /* CONFIG_XFS_RT */ +# define xfs_rtfree_extent(t,b,l) (-ENOSYS) +# define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) +# define xfs_rtalloc_query_range(m,t,l,h,f,p) (-ENOSYS) +# define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS) +# define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) +# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) +#endif /* CONFIG_XFS_RT */ + +#endif /* __XFS_RTBITMAP_H__ */ From patchwork Thu Feb 15 12:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558268 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 7539657872 for ; Thu, 15 Feb 2024 12:09:20 +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=1707998960; cv=none; b=ftF/bCNuq6PEu9vw/KThmlVaZyl4qZD1nOcmseJ5v0HwUT+amc1Ev6KyL6p4LNGeEXXTqAoH93O9vQ1hqdmibmpF6GaXKB4HSSE7hkyQlj+7oPCUHqmoXrSEwouWUABkK/Zki9+VMUiZmKaqyeC1l73RRriqyJzsTuFcufpgq6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998960; c=relaxed/simple; bh=L6QMV4aPv1MMujgRZVU3v+++6VqNMWDsTRCOxgcTWqg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CAtihaTSTFMa0H2DHRPzFQdCPokJkinEgX3iJubyb03LipxeXqylhf4au+sca48gM9nQMaASIHqAriX5VnsrvMOaJ3TINjGQvusbLTnwjouq0RsaMmFRapkJa/GhCytsUVAFFa/P2cK2vqMezgRiRhO2uivLrsvS8E1UqbURfW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IhDo1kgH; 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="IhDo1kgH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71731C43399 for ; Thu, 15 Feb 2024 12:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998960; bh=L6QMV4aPv1MMujgRZVU3v+++6VqNMWDsTRCOxgcTWqg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IhDo1kgH8tDu2eJOeMxQJf4IfO8ftj/IFcsyqyOVbLNK6hu0hgciY8ZgzpxzxC10y 3Vug4/Podpt22AH73mbhY9jGLHgWbMFrUmMg61jTEQghsCeR2C48Ib/DyJqRO2UIUz mV9qJzOcRXfsLr1K17zabcFb3ubziIJeQODDPfpdafFJ3LZUBP6ga8FAfj58qWfShV OkuQFaNVOvQiZkw0K108lTCxSguwi6WtH3xcsNeQK82wcJjbmycqp3QKHtdK8N5NGF R/0JhkboYt8+xjc58QHnILEkdm2khwpzmvIdbvHerfZREQ3ZD0JMJypUsf/3BngJvp T7GiJlQw/xskw== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 05/35] xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator Date: Thu, 15 Feb 2024 13:08:17 +0100 Message-ID: <20240215120907.1542854-6-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: a684c538bc14410565e8939393089670fa1e19dd In most of the filesystem, we use xfs_extlen_t to store the length of a file (or AG) space mapping in units of fs blocks. Unfortunately, the realtime allocator also uses it to store the length of a rt space mapping in units of rt extents. This is confusing, since one rt extent can consist of many fs blocks. Separate the two by introducing a new type (xfs_rtxlen_t) to store the length of a space mapping (in units of realtime extents) that would be found in a file. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 12 ++++++------ libxfs/xfs_rtbitmap.h | 11 +++++------ libxfs/xfs_types.h | 1 + 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index bd0925c9a..976b1aca6 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -532,7 +532,7 @@ xfs_rtmodify_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ xfs_rtblock_t start, /* starting block to modify */ - xfs_extlen_t len, /* length of extent to modify */ + xfs_rtxlen_t len, /* length of extent to modify */ int val) /* 1 for free, 0 for allocated */ { xfs_rtword_t *b; /* current word in buffer */ @@ -688,7 +688,7 @@ xfs_rtfree_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ xfs_rtblock_t start, /* starting block to free */ - xfs_extlen_t len, /* length to free */ + xfs_rtxlen_t len, /* length to free */ struct xfs_buf **rbpp, /* in/out: summary block buffer */ xfs_fsblock_t *rsb) /* in/out: summary block number */ { @@ -764,7 +764,7 @@ xfs_rtcheck_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ xfs_rtblock_t start, /* starting block number of extent */ - xfs_extlen_t len, /* length of extent */ + xfs_rtxlen_t len, /* length of extent */ int val, /* 1 for free, 0 for allocated */ xfs_rtblock_t *new, /* out: first block not matching */ int *stat) /* out: 1 for matches, 0 for not */ @@ -940,7 +940,7 @@ xfs_rtcheck_alloc_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ xfs_rtblock_t bno, /* starting block number of extent */ - xfs_extlen_t len) /* length of extent */ + xfs_rtxlen_t len) /* length of extent */ { xfs_rtblock_t new; /* dummy for xfs_rtcheck_range */ int stat; @@ -963,7 +963,7 @@ int /* error */ xfs_rtfree_extent( xfs_trans_t *tp, /* transaction pointer */ xfs_rtblock_t bno, /* starting block number to free */ - xfs_extlen_t len) /* length of extent freed */ + xfs_rtxlen_t len) /* length of extent freed */ { int error; /* error value */ xfs_mount_t *mp; /* file system mount structure */ @@ -1114,7 +1114,7 @@ xfs_rtalloc_extent_is_free( struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, - xfs_extlen_t len, + xfs_rtxlen_t len, bool *is_free) { xfs_rtblock_t end; diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 546dea34b..d44496101 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -26,7 +26,7 @@ typedef int (*xfs_rtalloc_query_range_fn)( int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, int val, + xfs_rtblock_t start, xfs_rtxlen_t len, int val, xfs_rtblock_t *new, int *stat); int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_rtblock_t limit, @@ -35,7 +35,7 @@ int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_rtblock_t limit, xfs_rtblock_t *rtblock); int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, int val); + xfs_rtblock_t start, xfs_rtxlen_t len, int val); int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, int log, xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, xfs_fsblock_t *rsb, @@ -44,7 +44,7 @@ int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, xfs_fsblock_t *rsb); int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, + xfs_rtblock_t start, xfs_rtxlen_t len, struct xfs_buf **rbpp, xfs_fsblock_t *rsb); int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, const struct xfs_rtalloc_rec *low_rec, @@ -53,9 +53,8 @@ int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, int xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtalloc_query_range_fn fn, void *priv); -bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_extlen_t len, + xfs_rtblock_t start, xfs_rtxlen_t len, bool *is_free); /* * Free an extent in the realtime subvolume. Length is expressed in @@ -65,7 +64,7 @@ int /* error */ xfs_rtfree_extent( struct xfs_trans *tp, /* transaction pointer */ xfs_rtblock_t bno, /* starting block number to free */ - xfs_extlen_t len); /* length of extent freed */ + xfs_rtxlen_t len); /* length of extent freed */ /* Same as above, but in units of rt blocks. */ int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 851220021..713cb7031 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -11,6 +11,7 @@ typedef uint32_t prid_t; /* project ID */ typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ typedef uint32_t xfs_extlen_t; /* extent length in blocks */ +typedef uint32_t xfs_rtxlen_t; /* file extent length in rtextents */ typedef uint32_t xfs_agnumber_t; /* allocation group number */ typedef uint64_t xfs_extnum_t; /* # of extents in a file */ typedef uint32_t xfs_aextnum_t; /* # extents in an attribute fork */ From patchwork Thu Feb 15 12:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558269 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 616D95466D for ; Thu, 15 Feb 2024 12:09:21 +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=1707998961; cv=none; b=oVZstcmvnz8zpu7IErSTHBMCS6oc+rodOsRUyd5b0Rem5/fAx9TvUoqLN+MYyvNje57ov+4Qyt3NPGvB/V/NPLuGURHB0axkWapuOUSXOedlDpbFQfLQZYgX8mn87pYUyUJ7K8Pmptty+iz5vKseFrI2foXkEEIhl8gL+JGiCxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998961; c=relaxed/simple; bh=rdaNw4/APeaBiP64rgMozc9f5nvV9fJx9rM9HpkrQF4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J33BcC7lY5LuOHfHEsvJJWZ20B0BNNsh2JfW/O4foAHjvVMGQji3lSivBnatsEtDdeGSIp3NVZ5/C1em1ziWSQv7e/27d9d34zdNHekFYRV1S3V7MPZiWf2Cp93yap4Jvlmkfj4fc9y9L+jqkd4CkQnV2VQmNzeMGBk7KePlEN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TuEAazeK; 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="TuEAazeK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95A8EC433F1 for ; Thu, 15 Feb 2024 12:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998961; bh=rdaNw4/APeaBiP64rgMozc9f5nvV9fJx9rM9HpkrQF4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TuEAazeKzdQoN32Z3FY+jDpk7XAicw1Aq1oofF9m4qPFWpX05Sm0Ug48oBpROjHPm p/0EJugRaRdQAECbX6/+09y77CRmZRzaKIm7hu6n15bCLZPkKS2gBI+EUMJjBLmnXu /qeqonOcZ5DOYPmJFhfo0HAAcffnnpakr1qhTA/UQpBWln6TNMjC9PU0VTo58xHwEg Im05XVcISv4i3v5eRcOrfRHoa4fKhy8VJyml9fi7qJZ19UvOphEfpS4F1sQC++hRdy QpTij7kCaiTJtne7Ip09gswDCQl+1QAjCe02vS6TO9lokaL6e7vM9ZGyXOTNH5/AaH HN3C/73L1MFEg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 06/35] xfs: convert rt bitmap/summary block numbers to xfs_fileoff_t Date: Thu, 15 Feb 2024 13:08:18 +0100 Message-ID: <20240215120907.1542854-7-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 03f4de332e2e79db36ed2156fb2350480f142bec We should use xfs_fileoff_t to store the file block offset of any location within the realtime bitmap or summary files. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 22 +++++++++++----------- libxfs/xfs_rtbitmap.h | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 976b1aca6..9a9097edd 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -53,7 +53,7 @@ int xfs_rtbuf_get( xfs_mount_t *mp, /* file system mount structure */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t block, /* block number in bitmap or summary */ + xfs_fileoff_t block, /* block number in bitmap or summary */ int issum, /* is summary not bitmap */ struct xfs_buf **bpp) /* output: buffer for the block */ { @@ -99,7 +99,7 @@ xfs_rtfind_back( { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ - xfs_rtblock_t block; /* bitmap block number */ + xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ @@ -274,7 +274,7 @@ xfs_rtfind_forw( { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ - xfs_rtblock_t block; /* bitmap block number */ + xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ @@ -444,15 +444,15 @@ xfs_rtmodify_summary_int( xfs_mount_t *mp, /* file system mount structure */ xfs_trans_t *tp, /* transaction pointer */ int log, /* log2 of extent size */ - xfs_rtblock_t bbno, /* bitmap block number */ + xfs_fileoff_t bbno, /* bitmap block number */ int delta, /* change to make to summary info */ struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fsblock_t *rsb, /* in/out: summary block number */ + xfs_fileoff_t *rsb, /* in/out: summary block number */ xfs_suminfo_t *sum) /* out: summary info for this block */ { struct xfs_buf *bp; /* buffer for the summary block */ int error; /* error value */ - xfs_fsblock_t sb; /* summary fsblock */ + xfs_fileoff_t sb; /* summary fsblock */ int so; /* index into the summary file */ xfs_suminfo_t *sp; /* pointer to returned data */ @@ -514,10 +514,10 @@ xfs_rtmodify_summary( xfs_mount_t *mp, /* file system mount structure */ xfs_trans_t *tp, /* transaction pointer */ int log, /* log2 of extent size */ - xfs_rtblock_t bbno, /* bitmap block number */ + xfs_fileoff_t bbno, /* bitmap block number */ int delta, /* change to make to summary info */ struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fsblock_t *rsb) /* in/out: summary block number */ + xfs_fileoff_t *rsb) /* in/out: summary block number */ { return xfs_rtmodify_summary_int(mp, tp, log, bbno, delta, rbpp, rsb, NULL); @@ -537,7 +537,7 @@ xfs_rtmodify_range( { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ - xfs_rtblock_t block; /* bitmap block number */ + xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ @@ -690,7 +690,7 @@ xfs_rtfree_range( xfs_rtblock_t start, /* starting block to free */ xfs_rtxlen_t len, /* length to free */ struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fsblock_t *rsb) /* in/out: summary block number */ + xfs_fileoff_t *rsb) /* in/out: summary block number */ { xfs_rtblock_t end; /* end of the freed extent */ int error; /* error value */ @@ -771,7 +771,7 @@ xfs_rtcheck_range( { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ - xfs_rtblock_t block; /* bitmap block number */ + xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index d44496101..e2ea6d31c 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -24,7 +24,7 @@ typedef int (*xfs_rtalloc_query_range_fn)( #ifdef CONFIG_XFS_RT int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t block, int issum, struct xfs_buf **bpp); + xfs_fileoff_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_rtxlen_t len, int val, xfs_rtblock_t *new, int *stat); @@ -37,15 +37,15 @@ int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_rtxlen_t len, int val); int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, - int log, xfs_rtblock_t bbno, int delta, - struct xfs_buf **rbpp, xfs_fsblock_t *rsb, + int log, xfs_fileoff_t bbno, int delta, + struct xfs_buf **rbpp, xfs_fileoff_t *rsb, xfs_suminfo_t *sum); int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, - xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, - xfs_fsblock_t *rsb); + xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, + xfs_fileoff_t *rsb); int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtblock_t start, xfs_rtxlen_t len, - struct xfs_buf **rbpp, xfs_fsblock_t *rsb); + struct xfs_buf **rbpp, xfs_fileoff_t *rsb); int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, const struct xfs_rtalloc_rec *low_rec, const struct xfs_rtalloc_rec *high_rec, From patchwork Thu Feb 15 12:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558270 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 69A025466D for ; Thu, 15 Feb 2024 12:09:22 +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=1707998962; cv=none; b=AngD/mmzsINQUiGQYwrWJmDnyGPny4UuOUb87762tFsouH/Lta9lHggruiX4T87/12FneseEJ6AB5Att+SA5FF4eF2KbhaXmwX8exNk/+P8F0kSUo70W8knmD8bak1jnGSQNOvXaCjyk6YF4MIBt5oazb6dVghw8KFXYwd2WYoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998962; c=relaxed/simple; bh=mMi/G9zn+6Fz5fX/wG8ZRULif4pWOPN+5mqky3tt3KY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sfTrr2bMayUWxWZYSJuzaBaAciImyYp2K7GUNjGW6H2pjXnoR2qv0QsebOc53I+fCoKO/K2fniHnKbJXBmXYz2670ZmtA8nLaRFzZnOYJFwAePLkSAXAlmypwTWsUSRcEGMqkkxSJIWMSCjgLj34bnqnnnx5GYUnzr6PQn4za1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eXpcaKCB; 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="eXpcaKCB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF445C43394 for ; Thu, 15 Feb 2024 12:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998962; bh=mMi/G9zn+6Fz5fX/wG8ZRULif4pWOPN+5mqky3tt3KY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eXpcaKCBcjb7w3Tm5FlzqPoc5Uk3lctkyky69dkA6UsF+wTPMgvYiy/YcHU+FDA2q Zamr8UzCdxlthjrzru4gAYhEZXhbxryReSZ8JyMxPTb4LeRN8F1k67bmOrblXOHPF5 kMX8+8RMxMW35jBpPkPHmO4Vgk78ST5pZe6uQ+m7boLciUsKebPLZsP10uA1gFvXGd KbcZiOHNHxvAjxl65uwXzDFGhqbU/PTKR5XhamxTgbme881o1B2PkeJIK5vSYhlDW5 TYI3bWaf0zUiGUysso9qUIHlSNbPyrs33RsXLLhLR1gQLKisSIWHmngVV/z33ClWd2 OZHWPB1TP5++g== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 07/35] xfs: convert rt bitmap extent lengths to xfs_rtbxlen_t Date: Thu, 15 Feb 2024 13:08:19 +0100 Message-ID: <20240215120907.1542854-8-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: f29c3e745dc253bf9d9d06ddc36af1a534ba1dd0 XFS uses xfs_rtblock_t for many different uses, which makes it much more difficult to perform a unit analysis on the codebase. One of these (ab)uses is when we need to store the length of a free space extent as stored in the realtime bitmap. Because there can be up to 2^64 realtime extents in a filesystem, we need a new type that is larger than xfs_rtxlen_t for callers that are querying the bitmap directly. This means scrub and growfs. Create this type as "xfs_rtbxlen_t" and use it to store 64-bit rtx lengths. 'b' stands for 'bitmap' or 'big'; reader's choice. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_format.h | 2 +- libxfs/xfs_rtbitmap.h | 2 +- libxfs/xfs_types.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 371dc0723..20acb8573 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -98,7 +98,7 @@ typedef struct xfs_sb { uint32_t sb_blocksize; /* logical block size, bytes */ xfs_rfsblock_t sb_dblocks; /* number of data blocks */ xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ - xfs_rtblock_t sb_rextents; /* number of realtime extents */ + xfs_rtbxlen_t sb_rextents; /* number of realtime extents */ uuid_t sb_uuid; /* user-visible file system unique id */ xfs_fsblock_t sb_logstart; /* starting block of log if internal */ xfs_ino_t sb_rootino; /* root inode number */ diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index e2ea6d31c..b0a81fb8d 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -13,7 +13,7 @@ */ struct xfs_rtalloc_rec { xfs_rtblock_t ar_startext; - xfs_rtblock_t ar_extcount; + xfs_rtbxlen_t ar_extcount; }; typedef int (*xfs_rtalloc_query_range_fn)( diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 713cb7031..9af98a975 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -32,6 +32,7 @@ typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ typedef uint64_t xfs_fileoff_t; /* block number in a file */ typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ +typedef uint64_t xfs_rtbxlen_t; /* rtbitmap extent length in rtextents */ typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ From patchwork Thu Feb 15 12:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558272 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 9713912BF05 for ; Thu, 15 Feb 2024 12:09:23 +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=1707998964; cv=none; b=GpELORMb0IFjZ4Bx93EU+GpgSrgB8+tLQzZupAE/1dPUrKGo3DoZkoagM54d5Y6jFC9ovJkBs3/sROPA32+JdEX9Ar4T2k0dnM3hICOr+KBVgg9ko6HMZ7J5Z+t7E0WjeVKpCl2fpnTvKENUAA6834WdunoFzoaasmyCvKGepjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998964; c=relaxed/simple; bh=rwBI/dDE7Qmp1j9UqVsna3tIx+wdSx8uJoAzprPTOqo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wl48bVKEpC6+mK7IHFbctTaH/PQYz7W04dhHbGcxEeg/ZZ5bbY1aHeKWZ5IX4Xknl1baE0VYPtOhwg5gJRsispBRwZzZo4ddQsVUV0z2MGuYnTr/H+XdQOn0RSSI9GwBLltVjv16UXB8rLnD+atepy32t+HDdhnmBQQq5DkAGWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QV/9bgsD; 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="QV/9bgsD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4F9EC433C7 for ; Thu, 15 Feb 2024 12:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998963; bh=rwBI/dDE7Qmp1j9UqVsna3tIx+wdSx8uJoAzprPTOqo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QV/9bgsDLPihNefTVL0100nYvTPzNj2LACyeiay84mV7NC1Ru9fDNpT1kKtOecMcC 6DXRV+j27YYBNlPfFgiR6h/dIUn0qWAl5yjMvxFCHyUFuPxDNlDs9UgpagooKCuslI HaqpD1v9sFiVrPBIZeyCVZBxoJ6ZTH9TxZYUJ00QGCHM13GWTLRZkFo5y5CIDneUk3 wxmk9dbiG63Pb1jfRq9cWSByZqVVeCchQf/03e05kasoaQqUo1cy1BYLyL7F73JEd8 AJaAGB8YivTz37rvsTGsR39LZ3dOr/5oYCA/r2atK4p0mlQJyBNHucyHI+Pll8DiVC pGV1uwO9Iz/Ow== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 08/35] xfs: rename xfs_verify_rtext to xfs_verify_rtbext Date: Thu, 15 Feb 2024 13:08:20 +0100 Message-ID: <20240215120907.1542854-9-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 3d2b6d034f0feb7741b313f978a2fe45e917e1be This helper function validates that a range of *blocks* in the realtime section is completely contained within the realtime section. It does /not/ validate ranges of *rtextents*. Rename the function to avoid suggesting that it does, and change the type of the @len parameter since xfs_rtblock_t is a position unit, not a length unit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_types.c | 4 ++-- libxfs/xfs_types.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index bc82b71f3..69549a94a 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -6190,8 +6190,8 @@ xfs_bmap_validate_extent( return __this_address; if (XFS_IS_REALTIME_INODE(ip) && whichfork == XFS_DATA_FORK) { - if (!xfs_verify_rtext(mp, irec->br_startblock, - irec->br_blockcount)) + if (!xfs_verify_rtbext(mp, irec->br_startblock, + irec->br_blockcount)) return __this_address; } else { if (!xfs_verify_fsbext(mp, irec->br_startblock, diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 87abc8244..74ab1965a 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -148,10 +148,10 @@ xfs_verify_rtbno( /* Verify that a realtime device extent is fully contained inside the volume. */ bool -xfs_verify_rtext( +xfs_verify_rtbext( struct xfs_mount *mp, xfs_rtblock_t rtbno, - xfs_rtblock_t len) + xfs_filblks_t len) { if (rtbno + len <= rtbno) return false; diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 9af98a975..9e45f13f6 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -231,8 +231,8 @@ bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); -bool xfs_verify_rtext(struct xfs_mount *mp, xfs_rtblock_t rtbno, - xfs_rtblock_t len); +bool xfs_verify_rtbext(struct xfs_mount *mp, xfs_rtblock_t rtbno, + xfs_filblks_t len); bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount); bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off); void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min, From patchwork Thu Feb 15 12:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558271 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 9492012BEA6 for ; Thu, 15 Feb 2024 12:09:24 +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=1707998964; cv=none; b=Gk09kpAkPDRnSvNOBwDnhtSi+z8b5LfXkftRAE0ZDpQ/nErBz5PImyNABWN5vWgYOKZWLXsuWmHI2ZZF2shDTUR6wycT8Zf6WDM545ekuaYKb0gHc6GGwrq+Yto7sfJTF3SZcueoL6bPajkoxOaHS80OzGYOZuJfpg1Zyj7amIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998964; c=relaxed/simple; bh=l7laD9kY8taAQOekYLAh4twtUeH45R8YrJUFJJKNaNI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TZMeUcY3JTShApcUg19/BWm9YuKj4Por9+MBTf5MuH0klZrzcwsrP3MsB7Qn/4TMIQmLk8DHgf70af6KjbpCLdldcMp9at3W28hyRE6V51KReLlAfF5aLKXTxDGAFC4eTlmk98iztfNR63OQhvVty2DCl6plNrM17qdzV7VyARM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HWRPwetX; 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="HWRPwetX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4ED5C43390 for ; Thu, 15 Feb 2024 12:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998964; bh=l7laD9kY8taAQOekYLAh4twtUeH45R8YrJUFJJKNaNI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HWRPwetXg65WIaW22qVaHQoLaodX49JySQN70BOK5C6LTQZ/3kpaLOvtBYWWnQakt Utc6nRyY1t78k+yfpcpuIv8Kwcpaid0q46PtqtHTjSYxz1ZwtjPRz+8mDfl5cBnXTo bNNgCGUJohtHVsFE33jQ1JviZbWE7/DS9OK6/5Tpo5ezHpxC4hVgz5iibPI5P+Pex8 V4xYFL2juWWe9GBtV6DtAOxrx7NlDB+W2t2mMoHO3/yMXnXzqTwhEn3mFoIndKX3lJ rC1JXNJbwq2SOM8Ya5xM+/fF778MNr6jPqU8BWVLpdf1CthIFfUpU4lfKe9eewJU9j ce8qL/P7htamg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 09/35] xfs: convert rt extent numbers to xfs_rtxnum_t Date: Thu, 15 Feb 2024 13:08:21 +0100 Message-ID: <20240215120907.1542854-10-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 2d5f216b77e33f9b503bd42998271da35d4b7055 Further disambiguate the xfs_rtblock_t uses by creating a new type, xfs_rtxnum_t, to store the position of an extent within the realtime section, in units of rtextents. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 86 +++++++++++++++++++++---------------------- libxfs/xfs_rtbitmap.h | 26 ++++++------- libxfs/xfs_types.h | 2 + 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 9a9097edd..4085f29b6 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -93,9 +93,9 @@ int xfs_rtfind_back( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t start, /* starting block to look at */ - xfs_rtblock_t limit, /* last block to look at */ - xfs_rtblock_t *rtblock) /* out: start block found */ + xfs_rtxnum_t start, /* starting rtext to look at */ + xfs_rtxnum_t limit, /* last rtext to look at */ + xfs_rtxnum_t *rtx) /* out: start rtext found */ { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ @@ -103,9 +103,9 @@ xfs_rtfind_back( struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ - xfs_rtblock_t firstbit; /* first useful bit in the word */ - xfs_rtblock_t i; /* current bit number rel. to start */ - xfs_rtblock_t len; /* length of inspected area */ + xfs_rtxnum_t firstbit; /* first useful bit in the word */ + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t len; /* length of inspected area */ xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ @@ -154,7 +154,7 @@ xfs_rtfind_back( */ xfs_trans_brelse(tp, bp); i = bit - XFS_RTHIBIT(wdiff); - *rtblock = start - i + 1; + *rtx = start - i + 1; return 0; } i = bit - firstbit + 1; @@ -200,7 +200,7 @@ xfs_rtfind_back( */ xfs_trans_brelse(tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); - *rtblock = start - i + 1; + *rtx = start - i + 1; return 0; } i += XFS_NBWORD; @@ -247,7 +247,7 @@ xfs_rtfind_back( */ xfs_trans_brelse(tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); - *rtblock = start - i + 1; + *rtx = start - i + 1; return 0; } else i = len; @@ -256,7 +256,7 @@ xfs_rtfind_back( * No match, return that we scanned the whole area. */ xfs_trans_brelse(tp, bp); - *rtblock = start - i + 1; + *rtx = start - i + 1; return 0; } @@ -268,9 +268,9 @@ int xfs_rtfind_forw( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t start, /* starting block to look at */ - xfs_rtblock_t limit, /* last block to look at */ - xfs_rtblock_t *rtblock) /* out: start block found */ + xfs_rtxnum_t start, /* starting rtext to look at */ + xfs_rtxnum_t limit, /* last rtext to look at */ + xfs_rtxnum_t *rtx) /* out: start rtext found */ { xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ @@ -278,9 +278,9 @@ xfs_rtfind_forw( struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ - xfs_rtblock_t i; /* current bit number rel. to start */ - xfs_rtblock_t lastbit; /* last useful bit in the word */ - xfs_rtblock_t len; /* length of inspected area */ + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t lastbit; /* last useful bit in the word */ + xfs_rtxnum_t len; /* length of inspected area */ xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ @@ -328,7 +328,7 @@ xfs_rtfind_forw( */ xfs_trans_brelse(tp, bp); i = XFS_RTLOBIT(wdiff) - bit; - *rtblock = start + i - 1; + *rtx = start + i - 1; return 0; } i = lastbit - bit; @@ -373,7 +373,7 @@ xfs_rtfind_forw( */ xfs_trans_brelse(tp, bp); i += XFS_RTLOBIT(wdiff); - *rtblock = start + i - 1; + *rtx = start + i - 1; return 0; } i += XFS_NBWORD; @@ -417,7 +417,7 @@ xfs_rtfind_forw( */ xfs_trans_brelse(tp, bp); i += XFS_RTLOBIT(wdiff); - *rtblock = start + i - 1; + *rtx = start + i - 1; return 0; } else i = len; @@ -426,7 +426,7 @@ xfs_rtfind_forw( * No match, return that we scanned the whole area. */ xfs_trans_brelse(tp, bp); - *rtblock = start + i - 1; + *rtx = start + i - 1; return 0; } @@ -531,7 +531,7 @@ int xfs_rtmodify_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t start, /* starting block to modify */ + xfs_rtxnum_t start, /* starting rtext to modify */ xfs_rtxlen_t len, /* length of extent to modify */ int val) /* 1 for free, 0 for allocated */ { @@ -687,15 +687,15 @@ int xfs_rtfree_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t start, /* starting block to free */ + xfs_rtxnum_t start, /* starting rtext to free */ xfs_rtxlen_t len, /* length to free */ struct xfs_buf **rbpp, /* in/out: summary block buffer */ xfs_fileoff_t *rsb) /* in/out: summary block number */ { - xfs_rtblock_t end; /* end of the freed extent */ + xfs_rtxnum_t end; /* end of the freed extent */ int error; /* error value */ - xfs_rtblock_t postblock; /* first block freed > end */ - xfs_rtblock_t preblock; /* first block freed < start */ + xfs_rtxnum_t postblock; /* first rtext freed > end */ + xfs_rtxnum_t preblock; /* first rtext freed < start */ end = start + len - 1; /* @@ -763,10 +763,10 @@ int xfs_rtcheck_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t start, /* starting block number of extent */ + xfs_rtxnum_t start, /* starting rtext number of extent */ xfs_rtxlen_t len, /* length of extent */ int val, /* 1 for free, 0 for allocated */ - xfs_rtblock_t *new, /* out: first block not matching */ + xfs_rtxnum_t *new, /* out: first rtext not matching */ int *stat) /* out: 1 for matches, 0 for not */ { xfs_rtword_t *b; /* current word in buffer */ @@ -775,8 +775,8 @@ xfs_rtcheck_range( struct xfs_buf *bp; /* buf for the block */ xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ - xfs_rtblock_t i; /* current bit number rel. to start */ - xfs_rtblock_t lastbit; /* last useful bit in word */ + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t wdiff; /* difference from wanted value */ int word; /* word number in the buffer */ @@ -939,14 +939,14 @@ STATIC int /* error */ xfs_rtcheck_alloc_range( xfs_mount_t *mp, /* file system mount point */ xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t bno, /* starting block number of extent */ + xfs_rtxnum_t start, /* starting rtext number of extent */ xfs_rtxlen_t len) /* length of extent */ { - xfs_rtblock_t new; /* dummy for xfs_rtcheck_range */ + xfs_rtxnum_t new; /* dummy for xfs_rtcheck_range */ int stat; int error; - error = xfs_rtcheck_range(mp, tp, bno, len, 0, &new, &stat); + error = xfs_rtcheck_range(mp, tp, start, len, 0, &new, &stat); if (error) return error; ASSERT(stat); @@ -962,7 +962,7 @@ xfs_rtcheck_alloc_range( int /* error */ xfs_rtfree_extent( xfs_trans_t *tp, /* transaction pointer */ - xfs_rtblock_t bno, /* starting block number to free */ + xfs_rtxnum_t start, /* starting rtext number to free */ xfs_rtxlen_t len) /* length of extent freed */ { int error; /* error value */ @@ -975,14 +975,14 @@ xfs_rtfree_extent( ASSERT(mp->m_rbmip->i_itemp != NULL); ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); - error = xfs_rtcheck_alloc_range(mp, tp, bno, len); + error = xfs_rtcheck_alloc_range(mp, tp, start, len); if (error) return error; /* * Free the range of realtime blocks. */ - error = xfs_rtfree_range(mp, tp, bno, len, &sumbp, &sb); + error = xfs_rtfree_range(mp, tp, start, len, &sumbp, &sb); if (error) { return error; } @@ -1016,7 +1016,7 @@ xfs_rtfree_blocks( xfs_filblks_t rtlen) { struct xfs_mount *mp = tp->t_mountp; - xfs_rtblock_t bno; + xfs_rtxnum_t start; xfs_filblks_t len; xfs_extlen_t mod; @@ -1028,13 +1028,13 @@ xfs_rtfree_blocks( return -EIO; } - bno = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod); + start = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod); if (mod) { ASSERT(mod == 0); return -EIO; } - return xfs_rtfree_extent(tp, bno, len); + return xfs_rtfree_extent(tp, start, len); } /* Find all the free records within a given range. */ @@ -1048,9 +1048,9 @@ xfs_rtalloc_query_range( void *priv) { struct xfs_rtalloc_rec rec; - xfs_rtblock_t rtstart; - xfs_rtblock_t rtend; - xfs_rtblock_t high_key; + xfs_rtxnum_t rtstart; + xfs_rtxnum_t rtend; + xfs_rtxnum_t high_key; int is_free; int error = 0; @@ -1113,11 +1113,11 @@ int xfs_rtalloc_extent_is_free( struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, + xfs_rtxnum_t start, xfs_rtxlen_t len, bool *is_free) { - xfs_rtblock_t end; + xfs_rtxnum_t end; int matches; int error; diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index b0a81fb8d..5e2afb7fe 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -7,12 +7,10 @@ #define __XFS_RTBITMAP_H__ /* - * XXX: Most of the realtime allocation functions deal in units of realtime - * extents, not realtime blocks. This looks funny when paired with the type - * name and screams for a larger cleanup. + * Functions for walking free space rtextents in the realtime bitmap. */ struct xfs_rtalloc_rec { - xfs_rtblock_t ar_startext; + xfs_rtxnum_t ar_startext; xfs_rtbxlen_t ar_extcount; }; @@ -26,16 +24,16 @@ typedef int (*xfs_rtalloc_query_range_fn)( int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, xfs_fileoff_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtxlen_t len, int val, - xfs_rtblock_t *new, int *stat); + xfs_rtxnum_t start, xfs_rtxlen_t len, int val, + xfs_rtxnum_t *new, int *stat); int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtblock_t limit, - xfs_rtblock_t *rtblock); + xfs_rtxnum_t start, xfs_rtxnum_t limit, + xfs_rtxnum_t *rtblock); int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtblock_t limit, - xfs_rtblock_t *rtblock); + xfs_rtxnum_t start, xfs_rtxnum_t limit, + xfs_rtxnum_t *rtblock); int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtxlen_t len, int val); + xfs_rtxnum_t start, xfs_rtxlen_t len, int val); int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, int log, xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, xfs_fileoff_t *rsb, @@ -44,7 +42,7 @@ int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, xfs_fileoff_t *rsb); int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtxlen_t len, + xfs_rtxnum_t start, xfs_rtxlen_t len, struct xfs_buf **rbpp, xfs_fileoff_t *rsb); int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, const struct xfs_rtalloc_rec *low_rec, @@ -54,7 +52,7 @@ int xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp, xfs_rtalloc_query_range_fn fn, void *priv); int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtblock_t start, xfs_rtxlen_t len, + xfs_rtxnum_t start, xfs_rtxlen_t len, bool *is_free); /* * Free an extent in the realtime subvolume. Length is expressed in @@ -63,7 +61,7 @@ int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, int /* error */ xfs_rtfree_extent( struct xfs_trans *tp, /* transaction pointer */ - xfs_rtblock_t bno, /* starting block number to free */ + xfs_rtxnum_t start, /* starting rtext number to free */ xfs_rtxlen_t len); /* length of extent freed */ /* Same as above, but in units of rt blocks. */ diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 9e45f13f6..c78237852 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -32,6 +32,7 @@ typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ typedef uint64_t xfs_fileoff_t; /* block number in a file */ typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ +typedef uint64_t xfs_rtxnum_t; /* rtextent number */ typedef uint64_t xfs_rtbxlen_t; /* rtbitmap extent length in rtextents */ typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ @@ -49,6 +50,7 @@ typedef void * xfs_failaddr_t; #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) #define NULLRTBLOCK ((xfs_rtblock_t)-1) #define NULLFILEOFF ((xfs_fileoff_t)-1) +#define NULLRTEXTNO ((xfs_rtxnum_t)-1) #define NULLAGBLOCK ((xfs_agblock_t)-1) #define NULLAGNUMBER ((xfs_agnumber_t)-1) From patchwork Thu Feb 15 12:08:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558273 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 B1CAE12BF05 for ; Thu, 15 Feb 2024 12:09:25 +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=1707998965; cv=none; b=mH3ftAoAVRX//6WMihIaFpzAFLXYyv6bJrfVP2Svs4So740kz9ssI/3soG6hD9/q7xpl1ficGBm2ZXyDbHEls16H+aijOjR+DOsVXIg/gbjl9f7QPFsdl6eO2kmR+IM1FZritE1E+++pLzGG1LvCnf6nMq/uArekTWEoHwkKCPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998965; c=relaxed/simple; bh=PB8ilCHKP8GzzZuAIVKf4rn7luzGnu1YgWgU6lDuW3I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g9yem9j7AIPM3KGu22nzxMd2JOm0miIElkHropcoPtH29FJa4psuJS/SeJdRYXCG8AW0JRsRGtrMB0E/cX6LCFUMyqjPcirNSX4PhVqqp6gg28zggDBob+M7QJiHgDtYPT6EDW+I+h97GG2Laj/l5DuZYnzLm3DC693KB1gyVKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j+RRrUln; 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="j+RRrUln" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3250C43399 for ; Thu, 15 Feb 2024 12:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998965; bh=PB8ilCHKP8GzzZuAIVKf4rn7luzGnu1YgWgU6lDuW3I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j+RRrUlnlGknWyk2AQYD3MLqxlGCPA76uBCCF3BaWqjxxmPtIV3gBe6gdF6pqr3/9 KYApi1lcBh9AssYcy3vNYLA+jHDK2NJxFe9IFbyspppbqbLqLDk29etxiRoYDRlh3i XbyK9u0Y8+0sZTrPV9qHZVoong73pelqCkc78+j2TBAWi8Bz87l+2mtpV8qGSzBv1T v1http1HrcxaXFgVrIUQuvRl+JgDjn8ueCQIyFgq7+qQyM64aKYkqr6UV43ecCHB6q j5x0YJaMF8WwIr9LCo5MASlXXjrJGXDIF812oNtsMtF7LS9/6L6tTGw9lw4OApvvpI 4c+ir/iIeXxcg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 10/35] xfs: create a helper to convert rtextents to rtblocks Date: Thu, 15 Feb 2024 13:08:22 +0100 Message-ID: <20240215120907.1542854-11-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: fa5a387230861116c2434c20d29fc4b3fd077d24 Create a helper to convert a realtime extent to a realtime block. Later on we'll change the helper to use bit shifts when possible. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 5e2afb7fe..099ea8902 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -6,6 +6,22 @@ #ifndef __XFS_RTBITMAP_H__ #define __XFS_RTBITMAP_H__ +static inline xfs_rtblock_t +xfs_rtx_to_rtb( + struct xfs_mount *mp, + xfs_rtxnum_t rtx) +{ + return rtx * mp->m_sb.sb_rextsize; +} + +static inline xfs_extlen_t +xfs_rtxlen_to_extlen( + struct xfs_mount *mp, + xfs_rtxlen_t rtxlen) +{ + return rtxlen * mp->m_sb.sb_rextsize; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558274 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 D178012BF12 for ; Thu, 15 Feb 2024 12:09:26 +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=1707998966; cv=none; b=LVMz0Vj8dlJyWv6zGMkjwmIX/BiOD1ObFfWL0J6zQxGg+YHFfK+L4lKkDbT6hWgRtywqxTg+0M3BeaV7ozcz89NzTTYjWqp2iUJtm11WVCPocprnlSGmLfi1n0NN+E9K4a0chYcGORwat3FmF16qnA9H983hPD7Easl64fe1Ydw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998966; c=relaxed/simple; bh=++EEa5bXqdIYjo7MtuUYygu+PMTyK4qiPTg/SvOtpcI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TC3okc+QS25vjsHVbzLw86d9GM2jJ9SY6I8RHQp4mAYAp6sJBFThUIP8KSPhAwyimUrNFP7iFFPI9dHaDcU96dE8kwqfFHgRaAkgNUyv6SlGaRunGo+zOEP3P7WXP0QKMqoTcu3bvqTo9I8wl6bW8Xi0+V3pJ+RkhN5d0RWJJ2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kTrqmI8B; 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="kTrqmI8B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D400C433C7 for ; Thu, 15 Feb 2024 12:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998966; bh=++EEa5bXqdIYjo7MtuUYygu+PMTyK4qiPTg/SvOtpcI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kTrqmI8Bqvfs7EZLWlKs8pOg4EKi7SljqiA8D8OHhHYV1C0gxpMLiPITIV7h1TWW2 oehdyXEy8ulsmBnJZG4QZiPP/9PjJXXX7lwNlZXnVWjZZvsXHG5CqFpxBfV/NSIn3Z 4nNkqyjMKzEYh3+ST+ZU4r7JeZdFFLrgZ9etzw6rA2Ik14ve3rtB/sbTj1aqmlxRin Kj3GXgbck9LxP+ENfvYQjcpZTlrP9IgO21w73LHU7Uu72BgUSkhvE4Yn/Ca/ZTILyU aK6K09nPZXsU6waOP0adVY0tOIfhTsVxV5dAbGg+NEX+hh48Nnk+upOmKLn2dh6WD3 mue9/hixa8V9Q== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 11/35] xfs: create a helper to compute leftovers of realtime extents Date: Thu, 15 Feb 2024 13:08:23 +0100 Message-ID: <20240215120907.1542854-12-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 68db60bf01c131c09bbe35adf43bd957a4c124bc Create a helper to compute the misalignment between a file extent (xfs_extlen_t) and a realtime extent. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_rtbitmap.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 69549a94a..6e863c8a4 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -2983,7 +2983,7 @@ xfs_bmap_extsize_align( * If realtime, and the result isn't a multiple of the realtime * extent size we need to remove blocks until it is. */ - if (rt && (temp = (align_alen % mp->m_sb.sb_rextsize))) { + if (rt && (temp = xfs_extlen_to_rtxmod(mp, align_alen))) { /* * We're not covering the original request, or * we won't be able to once we fix the length. @@ -3010,7 +3010,7 @@ xfs_bmap_extsize_align( else { align_alen -= orig_off - align_off; align_off = orig_off; - align_alen -= align_alen % mp->m_sb.sb_rextsize; + align_alen -= xfs_extlen_to_rtxmod(mp, align_alen); } /* * Result doesn't cover the request, fail it. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 099ea8902..b6a4c46bd 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -22,6 +22,15 @@ xfs_rtxlen_to_extlen( return rtxlen * mp->m_sb.sb_rextsize; } +/* Compute the misalignment between an extent length and a realtime extent .*/ +static inline unsigned int +xfs_extlen_to_rtxmod( + struct xfs_mount *mp, + xfs_extlen_t len) +{ + return len % mp->m_sb.sb_rextsize; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558275 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 D2F8712BEB2 for ; Thu, 15 Feb 2024 12:09:27 +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=1707998967; cv=none; b=NGf/eDzc79Z/6ip7wzy58QVDtqz0H8GARdVFyN0THToqGUx9sXjDX+kgtsVzXNUcN4fq5ObPHZoOKFTY9UiNoQ0as1FAZQCIrqTRHH5Es0BmAdfn43rri1SZIur3cVyUCsiqQqgTgnYmISGI8rDlCRrwAcLT2xvWP98kj4FVmvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998967; c=relaxed/simple; bh=+AyRkOzk2qrkE10/2BsMvLQaKTMtgxEmEHYQ5NjLOCI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e06cwV207P90NhVSYcubTcAKMPwmMGwzpkQ2YRMpAqRj2KfExJADPG+aDvFQbBso6bXlk9Q+xdsUY85lCYiTjGWKfY15D9o2r3HPC3v13ZkEhd20MIQh8i3zPsIcLZUzfMF8wOp35E/FmotaP7/Vhm06mQMN+02w0tC6Ga/aZHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p4tq5V6A; 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="p4tq5V6A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26CD5C433F1 for ; Thu, 15 Feb 2024 12:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998967; bh=+AyRkOzk2qrkE10/2BsMvLQaKTMtgxEmEHYQ5NjLOCI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p4tq5V6ASi0YPrzk/w+hKcfJ3VIB1SMEDXFCcGywudjSsGqPMkt9QnG2BfE797n08 OpF88viwEJqBlS0jcmh9WXeC32ptZK3HJHhrMbRM5DB8IHLpoo8I47OWzyVwmg6cqK yimxzzdyam1O0bJ5Rmwxd10WK5cnW1BXqx+opNAIVNdlsHqr/Jr6x/+/PbSpkns5rN gZW9j4mOe1H4uNQ2PvVUexBLLaRQQ+YkT+/5DC1DWOs2QMGwZkzNPlxFmQiTRLH0fT fYkGqm335TQapHhqf2YMtwU4neCNwZsc7KbqKspzglk1fPPQW31vRDOILhCk3VD5pY Yc6m/nwsro9fg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 12/35] xfs: create a helper to convert extlen to rtextlen Date: Thu, 15 Feb 2024 13:08:24 +0100 Message-ID: <20240215120907.1542854-13-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 2c2b981b737a519907429f62148bbd9e40e01132 Create a helper to compute the realtime extent (xfs_rtxlen_t) from an extent length (xfs_extlen_t) value. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.h | 8 ++++++++ libxfs/xfs_trans_resv.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index b6a4c46bd..e2a36fc15 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -31,6 +31,14 @@ xfs_extlen_to_rtxmod( return len % mp->m_sb.sb_rextsize; } +static inline xfs_rtxlen_t +xfs_extlen_to_rtxlen( + struct xfs_mount *mp, + xfs_extlen_t len) +{ + return len / mp->m_sb.sb_rextsize; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c index 04c444806..53c190b72 100644 --- a/libxfs/xfs_trans_resv.c +++ b/libxfs/xfs_trans_resv.c @@ -18,6 +18,7 @@ #include "xfs_trans.h" #include "xfs_trans_space.h" #include "xfs_quota_defs.h" +#include "xfs_rtbitmap.h" #define _ALLOC true #define _FREE false @@ -219,7 +220,7 @@ xfs_rtalloc_block_count( unsigned int blksz = XFS_FSB_TO_B(mp, 1); unsigned int rtbmp_bytes; - rtbmp_bytes = (XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize) / NBBY; + rtbmp_bytes = xfs_extlen_to_rtxlen(mp, XFS_MAX_BMBT_EXTLEN) / NBBY; return (howmany(rtbmp_bytes, blksz) + 1) * num_ops; } From patchwork Thu Feb 15 12:08:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558276 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 DE68812BEB2 for ; Thu, 15 Feb 2024 12:09:28 +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=1707998968; cv=none; b=XMpXY0kECI58mcWYmAD9N9FEqvDlP9Not2yazKW9Kw15rrOJTUQmlqOFNzZ6DXK2vMfEV7puJ4sibOQUaVNd9G70vnYUshDCsh4czOIJ6yWcNBoCCneg1Mlx10KTL07C0wjw1gd2nrhA8Jrm9RTxxnklFWBy8paE0supc/e7U18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998968; c=relaxed/simple; bh=ifo7fiZZWt9x9jab5yMPDYoK3W1l5WG9/s7nnehAaB8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ejm7H4GZDiQMXctBpY9PJ3klctzX6cxXV9YhmlYPEHM4nNDM/fkiD3euHfn/CNOukmJKnnhz1ioRzXs1uZQe0NMdOwoy4omzwZD7xLWnFYC0BUNfLtC/4xOkv3DS1LSHTe5x7z1Bc2LP30zrKk6xPllqVLe6C/Nbdo+pYBXKD00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OtE1rRRq; 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="OtE1rRRq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29D25C433C7 for ; Thu, 15 Feb 2024 12:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998968; bh=ifo7fiZZWt9x9jab5yMPDYoK3W1l5WG9/s7nnehAaB8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OtE1rRRqNz0xGdSO7j1Z284UCKZJntBC8eIzPCPd/zNB5FBNwP/uPOZO3aVUPe8DA ee9+ToZHyL9Yz/XMaONcgNJnCkum7/MRGgdFoHP01O53DZ/bbiNjkzqt58saaDbHG7 PuE8j+XRa53kXr84wE+x1qvjfrsVwvg/TifDzAHTsmovqfdpb2cEWt+KTJ8CriKJ08 mGIIZDjbpoLzjXZ4MhqEcp/fU9MgdAuES3V6RVhoWIFMeSIHLCzvlN+5ZO5Tot4lly VXal29sHboTFEBg0lFKybUS80Ao1lcOH9CIHRn/aOHaoAG2MI6hdASfXWNAHeDuAEh tsInYnL8kTfpg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 13/35] xfs: create helpers to convert rt block numbers to rt extent numbers Date: Thu, 15 Feb 2024 13:08:25 +0100 Message-ID: <20240215120907.1542854-14-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 5dc3a80d46a450481df7f7e9fe673ba3eb4514c3 Create helpers to do unit conversions of rt block numbers to rt extent numbers. There are three variations -- one to compute the rt extent number from an rt block number; one to compute the offset of an rt block within an rt extent; and one to extract both. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 8 ++++---- libxfs/xfs_rtbitmap.c | 4 ++-- libxfs/xfs_rtbitmap.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 6e863c8a4..6d7fa88f9 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -5270,7 +5270,6 @@ __xfs_bunmapi( int tmp_logflags; /* partial logging flags */ int wasdel; /* was a delayed alloc extent */ int whichfork; /* data or attribute fork */ - xfs_fsblock_t sum; xfs_filblks_t len = *rlen; /* length to unmap in file */ xfs_fileoff_t end; struct xfs_iext_cursor icur; @@ -5365,8 +5364,8 @@ __xfs_bunmapi( if (!isrt) goto delete; - sum = del.br_startblock + del.br_blockcount; - div_u64_rem(sum, mp->m_sb.sb_rextsize, &mod); + mod = xfs_rtb_to_rtxoff(mp, + del.br_startblock + del.br_blockcount); if (mod) { /* * Realtime extent not lined up at the end. @@ -5413,7 +5412,8 @@ __xfs_bunmapi( goto error0; goto nodelete; } - div_u64_rem(del.br_startblock, mp->m_sb.sb_rextsize, &mod); + + mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); if (mod) { xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 4085f29b6..48e709a28 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1022,13 +1022,13 @@ xfs_rtfree_blocks( ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN); - len = div_u64_rem(rtlen, mp->m_sb.sb_rextsize, &mod); + len = xfs_rtb_to_rtxrem(mp, rtlen, &mod); if (mod) { ASSERT(mod == 0); return -EIO; } - start = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod); + start = xfs_rtb_to_rtxrem(mp, rtbno, &mod); if (mod) { ASSERT(mod == 0); return -EIO; diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index e2a36fc15..9df583083 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -39,6 +39,37 @@ xfs_extlen_to_rtxlen( return len / mp->m_sb.sb_rextsize; } +/* Convert an rt block number into an rt extent number. */ +static inline xfs_rtxnum_t +xfs_rtb_to_rtx( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return div_u64(rtbno, mp->m_sb.sb_rextsize); +} + +/* Return the offset of an rt block number within an rt extent. */ +static inline xfs_extlen_t +xfs_rtb_to_rtxoff( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return do_div(rtbno, mp->m_sb.sb_rextsize); +} + +/* + * Crack an rt block number into an rt extent number and an offset within that + * rt extent. Returns the rt extent number directly and the offset in @off. + */ +static inline xfs_rtxnum_t +xfs_rtb_to_rtxrem( + struct xfs_mount *mp, + xfs_rtblock_t rtbno, + xfs_extlen_t *off) +{ + return div_u64_rem(rtbno, mp->m_sb.sb_rextsize, off); +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558277 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 41C5212BEA6 for ; Thu, 15 Feb 2024 12:09:29 +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=1707998970; cv=none; b=pQkFGPsYvIU8Y0skA8GNjIPfW1Ui+tjzrRjdLk5JhYITp4I03DttG2+AM40iTCcVJatEMBzYM6IHax0BYj2ecnB1bdTY/y2vS+cdIFZe9wUX9il9+iD3WGcESfFcUJfWFxfSMpykOsKpI7eJkUcgsSx6a110Pm+cmL2gP5bj0iQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998970; c=relaxed/simple; bh=1hTYCq5GEeH5KRsbMo42uXCqFVK31IkpM4gyQ4lh55k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o5oGlygVnVFSa/NhoqYSATVzX6/VePJeQuKHX++jupDmcC+oIItMCYWEfg4hwuaLJhOo/tBWX8ONraIRUfD7OW+FXC/mv+0XUOdKgESeFR6CRoFmJacV4jIrREs9dMJUd2NFhPycDDRrKCD3nXF0rrZVh4X2PmqXHU+R1eKia04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i7lNRx2H; 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="i7lNRx2H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40B7DC433C7 for ; Thu, 15 Feb 2024 12:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998969; bh=1hTYCq5GEeH5KRsbMo42uXCqFVK31IkpM4gyQ4lh55k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i7lNRx2HJrHTizwwAUbvly4YXLaqvnIl25ZHI+AUy8g4318cAYILhIUMp++cC3twX Mho2zrx38CGc2muZsMZqSVclt1WQWjnxyU4mPRDIixJmIg3mkNKONARQOdnJ9mDbY1 OXl3zXA55VUkOCuYd+sr2MHOgDu3R2NmlySiynAPjGcL5I1+bezeTQhVqTDMwDbpAa Lstst7HjHmxmC0oVs4xtF64equ0Q96cHOKB6u7qZ54gl+XLWcOURxZeErkh3An/x0a a4yonH8WlH2SX8odlscRVkCZ5Cw8N5yiYVH/stL9savLEihjwDeR0wQy6AUBJHL6UQ h3Nv8/uwShLew== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 14/35] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Date: Thu, 15 Feb 2024 13:08:26 +0100 Message-ID: <20240215120907.1542854-15-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 055641248f649b52620a5fe8774bea253690e057 Convert these calls to use the helpers, and clean up all these places where the same variable can have different units depending on where it is in the function. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_bmap.c | 8 ++------ libxfs/xfs_rtbitmap.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 6d7fa88f9..8fde0dc25 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4820,12 +4820,8 @@ xfs_bmap_del_extent_delay( ASSERT(got->br_startoff <= del->br_startoff); ASSERT(got_endoff >= del_endoff); - if (isrt) { - uint64_t rtexts = del->br_blockcount; - - do_div(rtexts, mp->m_sb.sb_rextsize); - xfs_mod_frextents(mp, rtexts); - } + if (isrt) + xfs_mod_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount)); /* * Update the inode delalloc counter now and wait to update the diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 9df583083..ff901bf3d 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -70,6 +70,20 @@ xfs_rtb_to_rtxrem( return div_u64_rem(rtbno, mp->m_sb.sb_rextsize, off); } +/* + * Convert an rt block number into an rt extent number, rounding up to the next + * rt extent if the rt block is not aligned to an rt extent boundary. + */ +static inline xfs_rtxnum_t +xfs_rtb_to_rtxup( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + if (do_div(rtbno, mp->m_sb.sb_rextsize)) + rtbno++; + return rtbno; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558278 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 95E9612BEB2 for ; Thu, 15 Feb 2024 12:09:30 +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=1707998971; cv=none; b=pyLecXgzz1v5xWyOsbQHC2O5mve7WLmtfm06jvlhpi7bIc/fRaB/9l6Dl8wWh5oC5TlqKcQRWrPwDXekCBq7RPb+YWxh9Kle2Fbazc7+01J/qK1R6Lc4KF1OitSHyB4vNNSEWG2EkISDgh2GmASbDzB3heVR7IziFlbKXzeZWdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998971; c=relaxed/simple; bh=aF5dRwNQ/BF1IpXi4abHzlZmZWbHmY0a6+YWF1iZbDM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JVqY6N3NJokit93oatEspilSZNOdmQXRbZsADNkEPzanDkROxNLU/MOrMDDDzEOpAPksMxJ8nS5UEiclkAPVcJt7yoRnurk+i/iy/g3qi0LbTfQCFwEDV9Pkx+u6+q+Jp6UVPhyQgMTnSZnvHzmukSXAuSNOfyfwf3y4VGdO9p4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S4no1EHw; 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="S4no1EHw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47AA6C43390 for ; Thu, 15 Feb 2024 12:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998970; bh=aF5dRwNQ/BF1IpXi4abHzlZmZWbHmY0a6+YWF1iZbDM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=S4no1EHwGrTugoaOg4CbzfPD2Lm88xYSxXD9nd7mw/72TzmBThL4Qt5FMeOJSRymH b4RmVoE5SXWuhvPasIcJWZdIQ1EW4oNxAEtbFvDlZbNrwKZpmyMbBLsDiED4clJtKO lMmTv7Er9FQd1dls3fxGWq0+6ABRE6bjkSxBubOcSgEHhq4FNsvgNPia1eTiOkgZK6 /oSrylnt9eoxvmnBA0AaSHSSZcJ2kag0K6DU9IkgJ68i1gTS+5vKjfVeqbFqifebWG 3IDFcW0sAMdtnR/aj/9Q8hRwYJyFzFyiYTpt+dJ8dJckDchmEjAl2l6qiF/5d7MIvx IQevcUA2b/8/A== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 15/35] xfs: create rt extent rounding helpers for realtime extent blocks Date: Thu, 15 Feb 2024 13:08:27 +0100 Message-ID: <20240215120907.1542854-16-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 5f57f7309d9ab9d24d50c5707472b1ed8af4eabc Create a pair of functions to round rtblock numbers up or down to the nearest rt extent. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index ff901bf3d..ecf5645dd 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -84,6 +84,24 @@ xfs_rtb_to_rtxup( return rtbno; } +/* Round this rtblock up to the nearest rt extent size. */ +static inline xfs_rtblock_t +xfs_rtb_roundup_rtx( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return roundup_64(rtbno, mp->m_sb.sb_rextsize); +} + +/* Round this rtblock down to the nearest rt extent size. */ +static inline xfs_rtblock_t +xfs_rtb_rounddown_rtx( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return rounddown_64(rtbno, mp->m_sb.sb_rextsize); +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558280 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 6022A12BF15 for ; Thu, 15 Feb 2024 12:09:32 +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=1707998973; cv=none; b=JojhHhW03x8q5PgE5ut1RojqYEfbZDQ6nHMHx4iWjQ6cBWvERGQiSfDrFN3BxqW4gWEukP69dlLCchkOWxYGYelDAsIxm9gu1Oj7b7MRkm7FmHNaGaqBv2OY1DbX15u78L3xe2uosj0o0q6Dkz0XGSYaUgkUL9TRRZreak4upSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998973; c=relaxed/simple; bh=+yX8qFceCEYbhtGXifMqEc6KWzkYECr3QfVEK89BUjA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GmVcI9K84CZ+Zvyy/YkLhnE4T+dYcPTUw9O0MzZ8SklELIZZkihM1qCw4IMJmi+8M4v1Yn8S8KgGGAqsZaus8xr1n4XSpaRDA4B434BHXavlofCVaE0PPPFz2Ot0Qs3O2eJAz7zKHA+c2DkDEeo9zbdihzoVfQkvcOwLUK6l9WA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gXgcDFB6; 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="gXgcDFB6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A314C433F1 for ; Thu, 15 Feb 2024 12:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998971; bh=+yX8qFceCEYbhtGXifMqEc6KWzkYECr3QfVEK89BUjA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gXgcDFB6ehih2iiS+AOmXox+yrDWATx/xhmPyRtlrbgbAF6EaA7QjoNdS2aGVvRmy hAx1UUj4Luype54p6ZR4nsaLKWjo/8AAkycQ4b5jTfo6EBg2IsgUv2byDLDkYSyNP1 NcWDF8RhI9NHG7VXBIL7cQ9+9/IRbsb8Q1TPkk15Qqv62vMbXi5xdLwkQxLADOD1Ye Wk5TGB+/XOAbC74f0BThQxc2BYEu3elikMzUw2J7tyfxJVucG57p6tGvg3qFtb2e0U 7sfVmELlzANfCzJCg+si0gJSPARKy1qu4THnoPDfIYx805a6TrAlWV8Atoj1Kqoxmo HnjHm/hQzhlIg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 16/35] xfs: use shifting and masking when converting rt extents, if possible Date: Thu, 15 Feb 2024 13:08:28 +0100 Message-ID: <20240215120907.1542854-17-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: ef5a83b7e597038d1c734ddb4bc00638082c2bf1 Avoid the costs of integer division (32-bit and 64-bit) if the realtime extent size is a power of two. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- include/xfs_mount.h | 2 ++ libxfs/libxfs_priv.h | 24 ++++++++++++++++++++++++ libxfs/xfs_rtbitmap.h | 29 +++++++++++++++++++++++++++++ libxfs/xfs_sb.c | 2 ++ 4 files changed, 57 insertions(+) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 9adc1f898..98d5b199d 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -71,6 +71,7 @@ typedef struct xfs_mount { uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */ uint8_t m_agno_log; /* log #ag's */ + int8_t m_rtxblklog; /* log2 of rextsize, if possible */ uint m_blockmask; /* sb_blocksize-1 */ uint m_blockwsize; /* sb_blocksize in words */ uint m_blockwmask; /* blockwsize-1 */ @@ -93,6 +94,7 @@ typedef struct xfs_mount { struct radix_tree_root m_perag_tree; uint64_t m_features; /* active filesystem features */ uint64_t m_low_space[XFS_LOWSP_MAX]; + uint64_t m_rtxblkmask; /* rt extent block mask */ unsigned long m_opstate; /* dynamic state flags */ bool m_finobt_nores; /* no per-AG finobt resv. */ uint m_qflags; /* quota status flags */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index ed437e38e..30ff8dba9 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -323,6 +323,30 @@ roundup_pow_of_two(uint v) return 0; } +/* If @b is a power of 2, return log2(b). Else return -1. */ +static inline int8_t log2_if_power2(unsigned long b) +{ + unsigned long mask = 1; + unsigned int i; + unsigned int ret = 1; + + if (!is_power_of_2(b)) + return -1; + + for (i = 0; i < NBBY * sizeof(unsigned long); i++, mask <<= 1) { + if (b & mask) + ret = i; + } + + return ret; +} + +/* If @b is a power of 2, return a mask of the lower bits, else return zero. */ +static inline unsigned long long mask64_if_power2(unsigned long b) +{ + return is_power_of_2(b) ? b - 1 : 0; +} + /* buffer management */ #define XBF_TRYLOCK 0 #define XBF_UNMAPPED 0 diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index ecf5645dd..3686a53e0 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -11,6 +11,9 @@ xfs_rtx_to_rtb( struct xfs_mount *mp, xfs_rtxnum_t rtx) { + if (mp->m_rtxblklog >= 0) + return rtx << mp->m_rtxblklog; + return rtx * mp->m_sb.sb_rextsize; } @@ -19,6 +22,9 @@ xfs_rtxlen_to_extlen( struct xfs_mount *mp, xfs_rtxlen_t rtxlen) { + if (mp->m_rtxblklog >= 0) + return rtxlen << mp->m_rtxblklog; + return rtxlen * mp->m_sb.sb_rextsize; } @@ -28,6 +34,9 @@ xfs_extlen_to_rtxmod( struct xfs_mount *mp, xfs_extlen_t len) { + if (mp->m_rtxblklog >= 0) + return len & mp->m_rtxblkmask; + return len % mp->m_sb.sb_rextsize; } @@ -36,6 +45,9 @@ xfs_extlen_to_rtxlen( struct xfs_mount *mp, xfs_extlen_t len) { + if (mp->m_rtxblklog >= 0) + return len >> mp->m_rtxblklog; + return len / mp->m_sb.sb_rextsize; } @@ -45,6 +57,9 @@ xfs_rtb_to_rtx( struct xfs_mount *mp, xfs_rtblock_t rtbno) { + if (likely(mp->m_rtxblklog >= 0)) + return rtbno >> mp->m_rtxblklog; + return div_u64(rtbno, mp->m_sb.sb_rextsize); } @@ -54,6 +69,9 @@ xfs_rtb_to_rtxoff( struct xfs_mount *mp, xfs_rtblock_t rtbno) { + if (likely(mp->m_rtxblklog >= 0)) + return rtbno & mp->m_rtxblkmask; + return do_div(rtbno, mp->m_sb.sb_rextsize); } @@ -67,6 +85,11 @@ xfs_rtb_to_rtxrem( xfs_rtblock_t rtbno, xfs_extlen_t *off) { + if (likely(mp->m_rtxblklog >= 0)) { + *off = rtbno & mp->m_rtxblkmask; + return rtbno >> mp->m_rtxblklog; + } + return div_u64_rem(rtbno, mp->m_sb.sb_rextsize, off); } @@ -79,6 +102,12 @@ xfs_rtb_to_rtxup( struct xfs_mount *mp, xfs_rtblock_t rtbno) { + if (likely(mp->m_rtxblklog >= 0)) { + if (rtbno & mp->m_rtxblkmask) + return (rtbno >> mp->m_rtxblklog) + 1; + return rtbno >> mp->m_rtxblklog; + } + if (do_div(rtbno, mp->m_sb.sb_rextsize)) rtbno++; return rtbno; diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 01935017c..1ebdb7ec4 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -973,6 +973,8 @@ xfs_sb_mount_common( mp->m_blockmask = sbp->sb_blocksize - 1; mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG; mp->m_blockwmask = mp->m_blockwsize - 1; + mp->m_rtxblklog = log2_if_power2(sbp->sb_rextsize); + mp->m_rtxblkmask = mask64_if_power2(sbp->sb_rextsize); mp->m_alloc_mxr[0] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 1); mp->m_alloc_mxr[1] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 0); From patchwork Thu Feb 15 12:08: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: 13558279 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 2C98612BEB2 for ; Thu, 15 Feb 2024 12:09:33 +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=1707998973; cv=none; b=ektbxU5oQcK320NeSqUfA6TvIgESnLedYVjXWSYRUnoTNb7q1ZDOe31UfN7B0JC7SvfJ1Z9IBGs4qEQTk5sfKKPqnbieQGfWYstBEapEILLBTwlJ/vyNb/Bk55+/mcUDKAp4p0wei8yaLOQwwL6cz01z6N+UMsAFId1Z82GAF28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998973; c=relaxed/simple; bh=0H7VqrmcTBcTq0KZc0Bp0rVhfWS4fIbvu8K87pnwH7g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wb6EBNPd6L1ypY08TDmFbByE2CWkHYC4jgD8mAUNBEkT8r58GgUIZNxCJwuzqnKM7bC2ijYGUnaLDTy27r/MBlPFHxHZMGyJ4IaYPabiM4l9dLsPCepZyT16DTwOLRlx+GbGPGXcjtIGnYPUwvJVNOSTjpra16BLNXAYTSUdusw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HI5BHLrI; 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="HI5BHLrI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72E89C433C7 for ; Thu, 15 Feb 2024 12:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998973; bh=0H7VqrmcTBcTq0KZc0Bp0rVhfWS4fIbvu8K87pnwH7g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HI5BHLrICcjeyfHZH0uKUGIJms4bdjEpigxfkCm8XBWuRi2I5f2JV/BbOQgYzUZMF j2iaNLEC/o6bmeBi5qeTx68je3JVwvegpjGAgGFyWt8KNhiKXXIZ5PeEqkoMXFGcDU tltft0U5vpFf79FkCKXkmvOonEBYbI18OAmMbZ5hIu+TS0p0TE0O+bdEZEEjHHn0aw 4P31oSrC/vxRHdiJLICzNexhjQFfwVPttlwilRgl73qXKQgxpIEaQ9RR4IgTbxR1DB OAV1mak5EH5dKsL69lcMKSTnir5DlsLLPeLBE9tvAcNuVNpR1pGTKgoMPaDINXHNYT 3wwDsMZiRkO2w== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 17/35] xfs: convert the rtbitmap block and bit macros to static inline functions Date: Thu, 15 Feb 2024 13:08:29 +0100 Message-ID: <20240215120907.1542854-18-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 90d98a6ada1da0f8797ff3f5adafd175dd8c0a81 Replace these macros with typechecked helper functions. Eventually we're going to add more logic to the helpers and it'll be easier if we don't have to macro it up. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_format.h | 5 ----- libxfs/xfs_rtbitmap.c | 30 +++++++++++++++--------------- libxfs/xfs_rtbitmap.h | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 20acb8573..0e2ee8202 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1155,11 +1155,6 @@ static inline bool xfs_dinode_has_large_extent_counts( ((xfs_suminfo_t *)((bp)->b_addr + \ (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp)))) -#define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log) -#define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log) -#define XFS_BITTOWORD(mp,bi) \ - ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp))) - #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b)) #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 48e709a28..540cb1481 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -109,12 +109,12 @@ xfs_rtfind_back( xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ - int word; /* word number in the buffer */ + unsigned int word; /* word number in the buffer */ /* * Compute and read in starting bitmap block for starting block. */ - block = XFS_BITTOBLOCK(mp, start); + block = xfs_rtx_to_rbmblock(mp, start); error = xfs_rtbuf_get(mp, tp, block, 0, &bp); if (error) { return error; @@ -123,7 +123,7 @@ xfs_rtfind_back( /* * Get the first word's index & point to it. */ - word = XFS_BITTOWORD(mp, start); + word = xfs_rtx_to_rbmword(mp, start); b = &bufp[word]; bit = (int)(start & (XFS_NBWORD - 1)); len = start - limit + 1; @@ -284,12 +284,12 @@ xfs_rtfind_forw( xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ - int word; /* word number in the buffer */ + unsigned int word; /* word number in the buffer */ /* * Compute and read in starting bitmap block for starting block. */ - block = XFS_BITTOBLOCK(mp, start); + block = xfs_rtx_to_rbmblock(mp, start); error = xfs_rtbuf_get(mp, tp, block, 0, &bp); if (error) { return error; @@ -298,7 +298,7 @@ xfs_rtfind_forw( /* * Get the first word's index & point to it. */ - word = XFS_BITTOWORD(mp, start); + word = xfs_rtx_to_rbmword(mp, start); b = &bufp[word]; bit = (int)(start & (XFS_NBWORD - 1)); len = limit - start + 1; @@ -545,12 +545,12 @@ xfs_rtmodify_range( int i; /* current bit number rel. to start */ int lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask o frelevant bits for value */ - int word; /* word number in the buffer */ + unsigned int word; /* word number in the buffer */ /* * Compute starting bitmap block number. */ - block = XFS_BITTOBLOCK(mp, start); + block = xfs_rtx_to_rbmblock(mp, start); /* * Read the bitmap block, and point to its data. */ @@ -562,7 +562,7 @@ xfs_rtmodify_range( /* * Compute the starting word's address, and starting bit. */ - word = XFS_BITTOWORD(mp, start); + word = xfs_rtx_to_rbmword(mp, start); first = b = &bufp[word]; bit = (int)(start & (XFS_NBWORD - 1)); /* @@ -728,7 +728,7 @@ xfs_rtfree_range( if (preblock < start) { error = xfs_rtmodify_summary(mp, tp, XFS_RTBLOCKLOG(start - preblock), - XFS_BITTOBLOCK(mp, preblock), -1, rbpp, rsb); + xfs_rtx_to_rbmblock(mp, preblock), -1, rbpp, rsb); if (error) { return error; } @@ -740,7 +740,7 @@ xfs_rtfree_range( if (postblock > end) { error = xfs_rtmodify_summary(mp, tp, XFS_RTBLOCKLOG(postblock - end), - XFS_BITTOBLOCK(mp, end + 1), -1, rbpp, rsb); + xfs_rtx_to_rbmblock(mp, end + 1), -1, rbpp, rsb); if (error) { return error; } @@ -751,7 +751,7 @@ xfs_rtfree_range( */ error = xfs_rtmodify_summary(mp, tp, XFS_RTBLOCKLOG(postblock + 1 - preblock), - XFS_BITTOBLOCK(mp, preblock), 1, rbpp, rsb); + xfs_rtx_to_rbmblock(mp, preblock), 1, rbpp, rsb); return error; } @@ -779,12 +779,12 @@ xfs_rtcheck_range( xfs_rtxnum_t lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t wdiff; /* difference from wanted value */ - int word; /* word number in the buffer */ + unsigned int word; /* word number in the buffer */ /* * Compute starting bitmap block number */ - block = XFS_BITTOBLOCK(mp, start); + block = xfs_rtx_to_rbmblock(mp, start); /* * Read the bitmap block. */ @@ -796,7 +796,7 @@ xfs_rtcheck_range( /* * Compute the starting word's address, and starting bit. */ - word = XFS_BITTOWORD(mp, start); + word = xfs_rtx_to_rbmword(mp, start); b = &bufp[word]; bit = (int)(start & (XFS_NBWORD - 1)); /* diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 3686a53e0..5c4325702 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -131,6 +131,33 @@ xfs_rtb_rounddown_rtx( return rounddown_64(rtbno, mp->m_sb.sb_rextsize); } +/* Convert an rt extent number to a file block offset in the rt bitmap file. */ +static inline xfs_fileoff_t +xfs_rtx_to_rbmblock( + struct xfs_mount *mp, + xfs_rtxnum_t rtx) +{ + return rtx >> mp->m_blkbit_log; +} + +/* Convert an rt extent number to a word offset within an rt bitmap block. */ +static inline unsigned int +xfs_rtx_to_rbmword( + struct xfs_mount *mp, + xfs_rtxnum_t rtx) +{ + return (rtx >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp); +} + +/* Convert a file block offset in the rt bitmap file to an rt extent number. */ +static inline xfs_rtxnum_t +xfs_rbmblock_to_rtx( + struct xfs_mount *mp, + xfs_fileoff_t rbmoff) +{ + return rbmoff << mp->m_blkbit_log; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558281 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 9900B12C53A for ; Thu, 15 Feb 2024 12:09:34 +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=1707998974; cv=none; b=q0Tg5DVPizd6qoZWfrbtawI7nC/Dm2y8LsVTgYDc2pWK/rEV8noWL7fGfQRrrppKNRNFyU9KSz71oGZuQ2RQLV1EuYKL5h2qP34pmCBpcWwbD1BzOqk5ziYvfvNPlzcYWF8MnNxGVgUFMf1nRPplfj4QRUO9MkOQuk2GLqFeFq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998974; c=relaxed/simple; bh=RmXDb4XRDYLkoB9Rn4+TMfoQ5dHfGq6qvQIClnHO/Os=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JLr/zUzGJnmAz/1FCPCWdwmaifIEnR3YKbLjlY9xCj1I4++b67VA/lOE05Tlq9rfcdmQVrPF3rjE8eit2smXqosl08syyaQOym8Cw4iOcD+I4w+oS77xx7YQevb54yo85Ceu175vQ1lqLBWRkptRrUmfdXe0AD8mPn5INUrw6QM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GUZal3+Z; 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="GUZal3+Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7787AC43390 for ; Thu, 15 Feb 2024 12:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998974; bh=RmXDb4XRDYLkoB9Rn4+TMfoQ5dHfGq6qvQIClnHO/Os=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GUZal3+ZM84XKiUwau6Kqc0Q0Du/umZrZ2fLM9TO0QI/ZbOLAwKc4s9OSDUCkvN7u fyvRWxBcvYQXJcrYdwgO/Ur1Zp+e+Zrrg+/SpkZ8K3Oe1GDS2yOugiT8AUZl/phU2a Fh3NU5AenUChAUT7Y63tL3VXGNNUgLXLUpPXzhci2aMw2k6OFZ+3VTMdMoDB6AijKo zGrBGUj8yaBsiHjEF+1O/0FADzs8KChn2umLPlRE14l/vNU5ELThsPA3vJEgA9K5wX LzmPfGkpo8WG7qplarxW5WGWFJjgIFy4Ecxtsnd0fzj9YWP0KysomG7hw42i648kRb Vh67Sq8alIXjQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 18/35] xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macros Date: Thu, 15 Feb 2024 13:08:30 +0100 Message-ID: <20240215120907.1542854-19-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: add3cddaea509071d01bf1d34df0d05db1a93a07 Remove these trivial macros since they're not even part of the ondisk format. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_format.h | 2 -- libxfs/xfs_rtbitmap.c | 16 ++++++++-------- libxfs/xfs_rtbitmap.h | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 0e2ee8202..ac6dd1023 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1142,8 +1142,6 @@ static inline bool xfs_dinode_has_large_extent_counts( #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize) #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask) -#define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize) -#define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask) /* * RT Summary and bit manipulation macros. diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 540cb1481..6776e45c1 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -172,7 +172,7 @@ xfs_rtfind_back( return error; } bufp = bp->b_addr; - word = XFS_BLOCKWMASK(mp); + word = mp->m_blockwsize - 1; b = &bufp[word]; } else { /* @@ -218,7 +218,7 @@ xfs_rtfind_back( return error; } bufp = bp->b_addr; - word = XFS_BLOCKWMASK(mp); + word = mp->m_blockwsize - 1; b = &bufp[word]; } else { /* @@ -336,7 +336,7 @@ xfs_rtfind_forw( * Go on to next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * If done with this block, get the previous one. */ @@ -381,7 +381,7 @@ xfs_rtfind_forw( * Go on to next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * If done with this block, get the next one. */ @@ -591,7 +591,7 @@ xfs_rtmodify_range( * Go on to the next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * Log the changed part of this block. * Get the next one. @@ -631,7 +631,7 @@ xfs_rtmodify_range( * Go on to the next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * Log the changed part of this block. * Get the next one. @@ -834,7 +834,7 @@ xfs_rtcheck_range( * Go on to next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * If done with this block, get the next one. */ @@ -880,7 +880,7 @@ xfs_rtcheck_range( * Go on to next block if that's where the next word is * and we need the next word. */ - if (++word == XFS_BLOCKWSIZE(mp) && i < len) { + if (++word == mp->m_blockwsize && i < len) { /* * If done with this block, get the next one. */ diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 5c4325702..a382b38c6 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -146,7 +146,7 @@ xfs_rtx_to_rbmword( struct xfs_mount *mp, xfs_rtxnum_t rtx) { - return (rtx >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp); + return (rtx >> XFS_NBWORDLOG) & (mp->m_blockwsize - 1); } /* Convert a file block offset in the rt bitmap file to an rt extent number. */ From patchwork Thu Feb 15 12:08:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558282 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 598C612C528 for ; Thu, 15 Feb 2024 12:09:35 +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=1707998975; cv=none; b=PGbfWzgr8kj5v6BPmHpVZNJ2WBCezoeLxZDXkHk6aZs80FMk6QUOW24E3vrgkaJ0WQBMbqZwPiNnNiNic6w97Qxu4xwXn21zWoujlNY7vvNk38pAhxw7EwV5etD0uICQFwuYcnhcrtyCnV6fB4LVV4Ut/q8DcxNz0rkbeXTu88A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998975; c=relaxed/simple; bh=sforYTTci2irX6gJYBl8Bz1X0/VBmVBV2BtOtGD7Ux0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mNEVjoA9yRDhp1LcRnmiL43CRzNAd9EdqYswTMNMJuRxA1rVUhpG5F96FxR2CGSPL4JlL3qGPq9F5LrySZrW8XZOrgMOom94PL24Xis0yrd+u6tPbG1qB/dn3FKx6U0XcIWcIN5e1Zzrr5Gy+lmILeVDizoiWCXDMNhttu6ny4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CD19kbNo; 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="CD19kbNo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95779C433C7 for ; Thu, 15 Feb 2024 12:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998975; bh=sforYTTci2irX6gJYBl8Bz1X0/VBmVBV2BtOtGD7Ux0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CD19kbNoRQHif13tH9DlFcCzk8Y92PC829k31man3xtJbROZOQx4lbBOADBLFUYtc O954XhAOIma140M2qd5bp3SezgZb0Mj/ld+4F2Rcy/XMTFE740pMrG7nbMKTe7Rwa4 3LCUA+52Op7kF5quhyGQr2MCKb7WYXatd1I90TfELccFqbtyUUbI+YXpcgp67hX9GF VzyilQc6Z5b7ICGHjCp5QvWa2AS8N1Fh2R7gLmy5Fky6j4yJdGK7xJmLkkdMcayIiu MtRoMISZ7ZSnZE9kHttzG4BHbMEBwi/PihR8OrgsjpinJrmfTe5SX/37BrQY/LpD4y Ask91JqBtXCfQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 19/35] xfs: convert open-coded xfs_rtword_t pointer accesses to helper Date: Thu, 15 Feb 2024 13:08:31 +0100 Message-ID: <20240215120907.1542854-20-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: a9948626849c2c65dfd201b5e9d855e62937de61 There are a bunch of places where we use open-coded logic to find a pointer to an xfs_rtword_t within a rt bitmap buffer. Convert all that to helper functions for better type safety. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 59 +++++++++++++++++++++++-------------------- libxfs/xfs_rtbitmap.h | 11 ++++++++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 6776e45c1..fce88c759 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -101,7 +101,6 @@ xfs_rtfind_back( int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ - xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ xfs_rtxnum_t firstbit; /* first useful bit in the word */ xfs_rtxnum_t i; /* current bit number rel. to start */ @@ -119,12 +118,12 @@ xfs_rtfind_back( if (error) { return error; } - bufp = bp->b_addr; + /* * Get the first word's index & point to it. */ word = xfs_rtx_to_rbmword(mp, start); - b = &bufp[word]; + b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); len = start - limit + 1; /* @@ -171,9 +170,9 @@ xfs_rtfind_back( if (error) { return error; } - bufp = bp->b_addr; + word = mp->m_blockwsize - 1; - b = &bufp[word]; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the previous word in the buffer. @@ -217,9 +216,9 @@ xfs_rtfind_back( if (error) { return error; } - bufp = bp->b_addr; + word = mp->m_blockwsize - 1; - b = &bufp[word]; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the previous word in the buffer. @@ -276,7 +275,6 @@ xfs_rtfind_forw( int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ - xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ xfs_rtxnum_t i; /* current bit number rel. to start */ xfs_rtxnum_t lastbit; /* last useful bit in the word */ @@ -294,12 +292,12 @@ xfs_rtfind_forw( if (error) { return error; } - bufp = bp->b_addr; + /* * Get the first word's index & point to it. */ word = xfs_rtx_to_rbmword(mp, start); - b = &bufp[word]; + b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); len = limit - start + 1; /* @@ -345,8 +343,9 @@ xfs_rtfind_forw( if (error) { return error; } - b = bufp = bp->b_addr; + word = 0; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the previous word in the buffer. @@ -390,8 +389,9 @@ xfs_rtfind_forw( if (error) { return error; } - b = bufp = bp->b_addr; + word = 0; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the next word in the buffer. @@ -539,7 +539,6 @@ xfs_rtmodify_range( int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ - xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ xfs_rtword_t *first; /* first used word in the buffer */ int i; /* current bit number rel. to start */ @@ -558,12 +557,12 @@ xfs_rtmodify_range( if (error) { return error; } - bufp = bp->b_addr; + /* * Compute the starting word's address, and starting bit. */ word = xfs_rtx_to_rbmword(mp, start); - first = b = &bufp[word]; + first = b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); /* * 0 (allocated) => all zeroes; 1 (free) => all ones. @@ -597,14 +596,15 @@ xfs_rtmodify_range( * Get the next one. */ xfs_trans_log_buf(tp, bp, - (uint)((char *)first - (char *)bufp), - (uint)((char *)b - (char *)bufp)); + (uint)((char *)first - (char *)bp->b_addr), + (uint)((char *)b - (char *)bp->b_addr)); error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); if (error) { return error; } - first = b = bufp = bp->b_addr; + word = 0; + first = b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the next word in the buffer @@ -637,14 +637,15 @@ xfs_rtmodify_range( * Get the next one. */ xfs_trans_log_buf(tp, bp, - (uint)((char *)first - (char *)bufp), - (uint)((char *)b - (char *)bufp)); + (uint)((char *)first - (char *)bp->b_addr), + (uint)((char *)b - (char *)bp->b_addr)); error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); if (error) { return error; } - first = b = bufp = bp->b_addr; + word = 0; + first = b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the next word in the buffer @@ -674,8 +675,9 @@ xfs_rtmodify_range( * Log any remaining changed bytes. */ if (b > first) - xfs_trans_log_buf(tp, bp, (uint)((char *)first - (char *)bufp), - (uint)((char *)b - (char *)bufp - 1)); + xfs_trans_log_buf(tp, bp, + (uint)((char *)first - (char *)bp->b_addr), + (uint)((char *)b - (char *)bp->b_addr - 1)); return 0; } @@ -773,7 +775,6 @@ xfs_rtcheck_range( int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ - xfs_rtword_t *bufp; /* starting word in buffer */ int error; /* error value */ xfs_rtxnum_t i; /* current bit number rel. to start */ xfs_rtxnum_t lastbit; /* last useful bit in word */ @@ -792,12 +793,12 @@ xfs_rtcheck_range( if (error) { return error; } - bufp = bp->b_addr; + /* * Compute the starting word's address, and starting bit. */ word = xfs_rtx_to_rbmword(mp, start); - b = &bufp[word]; + b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); /* * 0 (allocated) => all zero's; 1 (free) => all one's. @@ -843,8 +844,9 @@ xfs_rtcheck_range( if (error) { return error; } - b = bufp = bp->b_addr; + word = 0; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the next word in the buffer. @@ -889,8 +891,9 @@ xfs_rtcheck_range( if (error) { return error; } - b = bufp = bp->b_addr; + word = 0; + b = xfs_rbmblock_wordptr(bp, word); } else { /* * Go on to the next word in the buffer. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index a382b38c6..3252ed217 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -158,6 +158,17 @@ xfs_rbmblock_to_rtx( return rbmoff << mp->m_blkbit_log; } +/* Return a pointer to a bitmap word within a rt bitmap block. */ +static inline xfs_rtword_t * +xfs_rbmblock_wordptr( + struct xfs_buf *bp, + unsigned int index) +{ + xfs_rtword_t *words = bp->b_addr; + + return words + index; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558283 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 6110F12BF18 for ; Thu, 15 Feb 2024 12:09:36 +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=1707998976; cv=none; b=J7csM6Wdyi6h+WIaIUmHMFp1YJrRT7SCb3XRiV1+rkHOKwWrQptG7mQwN4SwNofScxzMpt38boMvnuD7q5ZgiOnGxLIU0i6YbwI8XRtxiw2nqOsfNFEprgGTXoRj1lKwIuDesAtDB+Ox+AyMcQjDKTGGDgrCYDDll9WMoJIDTks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998976; c=relaxed/simple; bh=nO4TmfvRjwfHglKYbjpy0Qg/7uYkkjdnObJ2lXjU614=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rq+JhHhL8aNTZor0i81lN0Ud9g3/en2WRRtuHKoE273xYWBljCdnfG4E9nchce7ncHix+BB5TVBHl5PTgEGBhP8CHZpi9e5m656XYAqKJaBUgbyC543miyLSBL/M0EQfplybaH3yQRGZQ18iNlVJLSeNdwHlkFiQ/3F4pBGnstg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vl6vACbs; 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="Vl6vACbs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6C5AC433C7 for ; Thu, 15 Feb 2024 12:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998976; bh=nO4TmfvRjwfHglKYbjpy0Qg/7uYkkjdnObJ2lXjU614=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Vl6vACbsANbxO+LbmAnN9QY2r26XCAvWEQKO52Ug9tG7R6repPrUYGafroJtuy/QZ /qOBz4IwQ6ekJTv2CbkCorKLdE6w3vRrLeMYSK4VLsuepYfW1p3bIfsIVZXDpBkQTb xSpDTM5iJlFxGTPVPCOVIEvb5Ve3Cc+XWv9vAycnRMgUojA0zHDf/Xg+GC49hmb9ky oagHA1dlEnh5nC/hT1hu1J2uXaIkEUXMKcnyhyeCiSfwF1ZJQpxrQw0jnFeij7Lxo6 SOMrXxmYaVhngb2/9jTKYzG09RS86HrUxMQoyH0dBN2rRc+JGyebLYi5ju1VWZN8tI FKSFPvJtVyfog== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 20/35] xfs: convert rt summary macros to helpers Date: Thu, 15 Feb 2024 13:08:32 +0100 Message-ID: <20240215120907.1542854-21-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 097b4b7b64ef67a4703b89fd4064480b61557fd5 Convert the realtime summary file macros to helper functions so that we can improve type checking. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- db/check.c | 5 ++-- include/libxfs.h | 1 + libxfs/xfs_format.h | 9 +------- libxfs/xfs_rtbitmap.c | 10 ++++---- libxfs/xfs_rtbitmap.h | 53 +++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_types.h | 2 ++ repair/rt.c | 5 ++-- 7 files changed, 69 insertions(+), 16 deletions(-) diff --git a/db/check.c b/db/check.c index fdf1f6a1e..9d5576c33 100644 --- a/db/check.c +++ b/db/check.c @@ -20,6 +20,7 @@ #include "init.h" #include "malloc.h" #include "dir2.h" +#include "xfs_rtbitmap.h" typedef enum { IS_USER_QUOTA, IS_PROJECT_QUOTA, IS_GROUP_QUOTA, @@ -3648,7 +3649,7 @@ process_rtbitmap( len = ((int)bmbno - start_bmbno) * bitsperblock + (bit - start_bit); log = XFS_RTBLOCKLOG(len); - offs = XFS_SUMOFFS(mp, log, start_bmbno); + offs = xfs_rtsumoffs(mp, log, start_bmbno); sumcompute[offs]++; prevbit = 0; } @@ -3661,7 +3662,7 @@ process_rtbitmap( len = ((int)bmbno - start_bmbno) * bitsperblock + (bit - start_bit); log = XFS_RTBLOCKLOG(len); - offs = XFS_SUMOFFS(mp, log, start_bmbno); + offs = xfs_rtsumoffs(mp, log, start_bmbno); sumcompute[offs]++; } } diff --git a/include/libxfs.h b/include/libxfs.h index 486566391..9cec394ca 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -44,6 +44,7 @@ struct iomap; #define __round_mask(x, y) ((__typeof__(x))((y)-1)) #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) #define unlikely(x) (x) +#define likely(x) (x) /* * This mirrors the kernel include for xfs_buf.h - it's implicitly included in diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index ac6dd1023..d48e3a395 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1144,15 +1144,8 @@ static inline bool xfs_dinode_has_large_extent_counts( #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask) /* - * RT Summary and bit manipulation macros. + * RT bit manipulation macros. */ -#define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb))) -#define XFS_SUMOFFSTOBLOCK(mp,s) \ - (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog) -#define XFS_SUMPTR(mp,bp,so) \ - ((xfs_suminfo_t *)((bp)->b_addr + \ - (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp)))) - #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b)) #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index fce88c759..c635e8c2e 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -453,17 +453,18 @@ xfs_rtmodify_summary_int( struct xfs_buf *bp; /* buffer for the summary block */ int error; /* error value */ xfs_fileoff_t sb; /* summary fsblock */ - int so; /* index into the summary file */ + xfs_rtsumoff_t so; /* index into the summary file */ xfs_suminfo_t *sp; /* pointer to returned data */ + unsigned int infoword; /* * Compute entry number in the summary file. */ - so = XFS_SUMOFFS(mp, log, bbno); + so = xfs_rtsumoffs(mp, log, bbno); /* * Compute the block number in the summary file. */ - sb = XFS_SUMOFFSTOBLOCK(mp, so); + sb = xfs_rtsumoffs_to_block(mp, so); /* * If we have an old buffer, and the block number matches, use that. */ @@ -491,7 +492,8 @@ xfs_rtmodify_summary_int( /* * Point to the summary information, modify/log it, and/or copy it out. */ - sp = XFS_SUMPTR(mp, bp, so); + infoword = xfs_rtsumoffs_to_infoword(mp, so); + sp = xfs_rsumblock_infoptr(bp, infoword); if (delta) { uint first = (uint)((char *)sp - (char *)bp->b_addr); diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 3252ed217..167ea6a08 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -6,6 +6,9 @@ #ifndef __XFS_RTBITMAP_H__ #define __XFS_RTBITMAP_H__ +/* For userspace XFS_RT is always defined */ +#define CONFIG_XFS_RT + static inline xfs_rtblock_t xfs_rtx_to_rtb( struct xfs_mount *mp, @@ -169,6 +172,56 @@ xfs_rbmblock_wordptr( return words + index; } +/* + * Convert a rt extent length and rt bitmap block number to a xfs_suminfo_t + * offset within the rt summary file. + */ +static inline xfs_rtsumoff_t +xfs_rtsumoffs( + struct xfs_mount *mp, + int log2_len, + xfs_fileoff_t rbmoff) +{ + return log2_len * mp->m_sb.sb_rbmblocks + rbmoff; +} + +/* + * Convert an xfs_suminfo_t offset to a file block offset within the rt summary + * file. + */ +static inline xfs_fileoff_t +xfs_rtsumoffs_to_block( + struct xfs_mount *mp, + xfs_rtsumoff_t rsumoff) +{ + return XFS_B_TO_FSBT(mp, rsumoff * sizeof(xfs_suminfo_t)); +} + +/* + * Convert an xfs_suminfo_t offset to an info word offset within an rt summary + * block. + */ +static inline unsigned int +xfs_rtsumoffs_to_infoword( + struct xfs_mount *mp, + xfs_rtsumoff_t rsumoff) +{ + unsigned int mask = mp->m_blockmask >> XFS_SUMINFOLOG; + + return rsumoff & mask; +} + +/* Return a pointer to a summary info word within a rt summary block. */ +static inline xfs_suminfo_t * +xfs_rsumblock_infoptr( + struct xfs_buf *bp, + unsigned int index) +{ + xfs_suminfo_t *info = bp->b_addr; + + return info + index; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index c78237852..533200c4c 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -19,6 +19,7 @@ typedef int64_t xfs_fsize_t; /* bytes in a file */ typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */ +typedef uint32_t xfs_rtsumoff_t; /* offset of an rtsummary info word */ typedef uint32_t xfs_rtword_t; /* word type for bitmap manipulations */ typedef int64_t xfs_lsn_t; /* log sequence number */ @@ -149,6 +150,7 @@ typedef uint32_t xfs_dqid_t; */ #define XFS_NBBYLOG 3 /* log2(NBBY) */ #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */ +#define XFS_SUMINFOLOG 2 /* log2(sizeof(xfs_suminfo_t)) */ #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG) #define XFS_NBWORD (1 << XFS_NBWORDLOG) #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1) diff --git a/repair/rt.c b/repair/rt.c index a4cca7aa2..abe58b569 100644 --- a/repair/rt.c +++ b/repair/rt.c @@ -13,6 +13,7 @@ #include "protos.h" #include "err_protos.h" #include "rt.h" +#include "xfs_rtbitmap.h" #define xfs_highbit64 libxfs_highbit64 /* for XFS_RTBLOCKLOG macro */ @@ -91,7 +92,7 @@ generate_rtinfo(xfs_mount_t *mp, } else if (in_extent == 1) { len = (int) (extno - start_ext); log = XFS_RTBLOCKLOG(len); - offs = XFS_SUMOFFS(mp, log, start_bmbno); + offs = xfs_rtsumoffs(mp, log, start_bmbno); sumcompute[offs]++; in_extent = 0; } @@ -107,7 +108,7 @@ generate_rtinfo(xfs_mount_t *mp, if (in_extent == 1) { len = (int) (extno - start_ext); log = XFS_RTBLOCKLOG(len); - offs = XFS_SUMOFFS(mp, log, start_bmbno); + offs = xfs_rtsumoffs(mp, log, start_bmbno); sumcompute[offs]++; } From patchwork Thu Feb 15 12:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558284 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 7B97C12BF17 for ; Thu, 15 Feb 2024 12:09:37 +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=1707998977; cv=none; b=JEOyTt4ffr4Z/thpIpweLZelzRx7Sd3JyG/gBX8nHHQraFk+SZ+jD+ePjvRoWcZrXtfm5x84wX3ux3N6LZEdAJOP9eUNutv5ULI8T7+wT38CbvjRNxJMkrrlaQh4z1MVHzHgPjy4PeeA15HL2wIh902Gye/O1SIBbbVN4GsYO4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998977; c=relaxed/simple; bh=/2TRymqznSIRb1u4AXkxfrlF50drOHbBMDHG4ERiNXg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ePEsSJAFR1nOlJ4Gss1iYE54dh2uJxZZ7lEdvOG7txLfvIqlhOIRcxnYPO7Cl0rhx6vEKtqXT8xjIGIlBhrIZ9sQanL0L2AWcrTe0AiI8Dx/uh7U6lsUd7s3ZVIMFUMPYdZpRBR1Nr7TluZVWKK+aW8Z/pVpIbIvhfrWzoL/mqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=beUVwdbk; 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="beUVwdbk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B625DC433F1 for ; Thu, 15 Feb 2024 12:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998977; bh=/2TRymqznSIRb1u4AXkxfrlF50drOHbBMDHG4ERiNXg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=beUVwdbkVDiUMB7ozP2BB9pBwEdY5v6XG9yMy64WuNndQTlQG9EsEug/EG0EtaU7s lKyrAsscFRs3efHKVX1xSUJQLGFCD3cgHcSGs5sxnvowIepvoZIRlP/A2WmN2r/kPK /h46V/OLip+Bfg0+QFRXHLej+W9KfefOjNGSZe1Zo6l+b8wIOJypYSNt0JPvUL3PDy M6OUeqj8+7SAp02lemGADokNWVhDpXcxPK+10x4pS3Nz4tSIY2UpcXGk1YHoyLG5VZ D2DwbcgzMFyzd/mflDzTiOJGJ0KLeqkxx0Q60z/rJ/c27ohxznBZzu/AhaekZS2PQ1 aP1UC+gUE1RbQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 21/35] xfs: convert to new timestamp accessors Date: Thu, 15 Feb 2024 13:08:33 +0100 Message-ID: <20240215120907.1542854-22-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Layton Source kernel commit: 75d1e312bbbd175fa27ffdd4c4fe9e8cc7d047ec Convert to using the new inode timestamp accessor functions. [Carlos: Also partially port 077c212f0344ae and 12cd4402365166] Signed-off-by: Jeff Layton Link: https://lore.kernel.org/r/20231004185347.80880-75-jlayton@kernel.org Signed-off-by: Christian Brauner Signed-off-by: Carlos Maiolino --- include/xfs_inode.h | 74 ++++++++++++++++++++++++++++++++++++++-- libxfs/util.c | 2 +- libxfs/xfs_inode_buf.c | 10 +++--- libxfs/xfs_rtbitmap.c | 6 +++- libxfs/xfs_trans_inode.c | 2 +- mkfs/proto.c | 2 +- 6 files changed, 86 insertions(+), 10 deletions(-) diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 986815e5c..a351bb0d9 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -41,8 +41,8 @@ struct inode { unsigned long i_state; /* Not actually used in userspace */ uint32_t i_generation; uint64_t i_version; - struct timespec64 i_atime; - struct timespec64 i_mtime; + struct timespec64 __i_atime; + struct timespec64 __i_mtime; struct timespec64 __i_ctime; /* use inode_*_ctime accessors! */ spinlock_t i_lock; }; @@ -69,6 +69,76 @@ static inline void ihold(struct inode *inode) inode->i_count++; } +static inline time64_t inode_get_atime_sec(const struct inode *inode) +{ + return inode->__i_atime.tv_sec; +} + +static inline long inode_get_atime_nsec(const struct inode *inode) +{ + return inode->__i_atime.tv_nsec; +} + +static inline struct timespec64 inode_get_atime(const struct inode *inode) +{ + return inode->__i_atime; +} + +static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->__i_atime = ts; + return ts; +} + +static inline struct timespec64 inode_set_atime(struct inode *inode, + time64_t sec, long nsec) +{ + struct timespec64 ts = { .tv_sec = sec, + .tv_nsec = nsec }; + return inode_set_atime_to_ts(inode, ts); +} + +static inline time64_t inode_get_mtime_sec(const struct inode *inode) +{ + return inode->__i_mtime.tv_sec; +} + +static inline long inode_get_mtime_nsec(const struct inode *inode) +{ + return inode->__i_mtime.tv_nsec; +} + +static inline struct timespec64 inode_get_mtime(const struct inode *inode) +{ + return inode->__i_mtime; +} + +static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->__i_mtime = ts; + return ts; +} + +static inline struct timespec64 inode_set_mtime(struct inode *inode, + time64_t sec, long nsec) +{ + struct timespec64 ts = { .tv_sec = sec, + .tv_nsec = nsec }; + return inode_set_mtime_to_ts(inode, ts); +} + +static inline time64_t inode_get_ctime_sec(const struct inode *inode) +{ + return inode->__i_ctime.tv_sec; +} + +static inline long inode_get_ctime_nsec(const struct inode *inode) +{ + return inode->__i_ctime.tv_nsec; +} + static inline struct timespec64 inode_get_ctime(const struct inode *inode) { return inode->__i_ctime; diff --git a/libxfs/util.c b/libxfs/util.c index 8f79b0cd1..8517bfb64 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -291,7 +291,7 @@ libxfs_init_new_inode( if (!pip) ip->i_diflags2 = xfs_flags2diflags2(ip, fsx->fsx_xflags); - ip->i_crtime = VFS_I(ip)->i_mtime; /* struct copy */ + ip->i_crtime = inode_get_mtime(VFS_I(ip)); /* struct copy */ ip->i_cowextsize = pip ? 0 : fsx->fsx_cowextsize; } diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index fccab4193..74a1bd227 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -217,8 +217,10 @@ xfs_inode_from_disk( * a time before epoch is converted to a time long after epoch * on 64 bit systems. */ - inode->i_atime = xfs_inode_from_disk_ts(from, from->di_atime); - inode->i_mtime = xfs_inode_from_disk_ts(from, from->di_mtime); + inode_set_atime_to_ts(inode, + xfs_inode_from_disk_ts(from, from->di_atime)); + inode_set_mtime_to_ts(inode, + xfs_inode_from_disk_ts(from, from->di_mtime)); inode_set_ctime_to_ts(inode, xfs_inode_from_disk_ts(from, from->di_ctime)); @@ -312,8 +314,8 @@ xfs_inode_to_disk( to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff); to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16); - to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime); - to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime); + to->di_atime = xfs_inode_to_disk_ts(ip, inode_get_atime(inode)); + to->di_mtime = xfs_inode_to_disk_ts(ip, inode_get_mtime(inode)); to->di_ctime = xfs_inode_to_disk_ts(ip, inode_get_ctime(inode)); to->di_nlink = cpu_to_be32(inode->i_nlink); to->di_gen = cpu_to_be32(inode->i_generation); diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index c635e8c2e..9a8bd93b7 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -974,6 +974,7 @@ xfs_rtfree_extent( xfs_mount_t *mp; /* file system mount structure */ xfs_fsblock_t sb; /* summary file block number */ struct xfs_buf *sumbp = NULL; /* summary file block buffer */ + struct timespec64 atime; mp = tp->t_mountp; @@ -1003,7 +1004,10 @@ xfs_rtfree_extent( mp->m_sb.sb_rextents) { if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM)) mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM; - *(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0; + + atime = inode_get_atime(VFS_I(mp->m_rbmip)); + atime.tv_sec = 0; + inode_set_atime_to_ts(VFS_I(mp->m_rbmip), atime); xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); } return 0; diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c index ca8e82376..c171a525c 100644 --- a/libxfs/xfs_trans_inode.c +++ b/libxfs/xfs_trans_inode.c @@ -62,7 +62,7 @@ xfs_trans_ichgtime( tv = current_time(inode); if (flags & XFS_ICHGTIME_MOD) - inode->i_mtime = tv; + inode_set_mtime_to_ts(inode, tv); if (flags & XFS_ICHGTIME_CHG) inode_set_ctime_to_ts(inode, tv); if (flags & XFS_ICHGTIME_CREATE) diff --git a/mkfs/proto.c b/mkfs/proto.c index ea31cfe5c..e9c633ed3 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -688,7 +688,7 @@ rtinit( mp->m_sb.sb_rbmino = rbmip->i_ino; rbmip->i_disk_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize; rbmip->i_diflags = XFS_DIFLAG_NEWRTBM; - *(uint64_t *)&VFS_I(rbmip)->i_atime = 0; + inode_set_atime(VFS_I(rbmip), 0, 0); libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE); libxfs_log_sb(tp); mp->m_rbmip = rbmip; From patchwork Thu Feb 15 12:08:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558285 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 81B8B12C52D for ; Thu, 15 Feb 2024 12:09:38 +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=1707998978; cv=none; b=DnVTMekP5+UeY34olyCIz03/7HLu4/XkBcnbRD4sodbT4cfQhUjNixms3A0Bf+aol2BbCwcdvhtgHptLmGsSOHzNpmVenPEdWRoXWgz8fcBO4TACAo56oD8TWlXY25lztslzzIecdyqUbRjH6KpHd0dfkko0aogFbd8x9JvGXGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998978; c=relaxed/simple; bh=Y/yn3sAcjhMIy3/jQ7defAH55IyOPTHBNnj7zVT7jGY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h8O34HeJSuV+pcSME/Yfk5olosqVlXBXs+Heq4CcL+dT9Xjk+gXP3hd4s0YgdGKJho0OKKSLoCdLk//0BvRfGY92tHxIb/aed1drYvFb6INoEwo21IUEEHJP1qnqZUPA9MC2VqLniXHlm4mVetj5lT9Xzu7MEel3gA5oNFFgBS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D9i0rb50; 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="D9i0rb50" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C87E1C433C7 for ; Thu, 15 Feb 2024 12:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998978; bh=Y/yn3sAcjhMIy3/jQ7defAH55IyOPTHBNnj7zVT7jGY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=D9i0rb50uByngULnoHD5g1+uyROQ1b4cuW00EGXJ28KaLhgnQMHpBZPKa1Q9XOMtt 2XVS1uCP/rGXKIBG4XXGAsf7sMG2DliImva8vtNEcgT/BKzCSy0YU88Mn6+W6flbjM UVGf6RFYZObOQPdsNokMSNsQoG3fkoewQvWEZEBsKH95EUg4LKNY1eZn6v6ebqFiSc mvWhqM78RxythUisFaDeMQriMd+PrFw1jXG+3JC9mMJOzPOkEA0LXnDFGGDYqvUmyr S9Ssf/A+zQbi4vhiKz+J23CFQOa/7JSOZxasaIvwAiwE6hcfZ6oWaeAEla33Erp2XR BHxakNOczeCUQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 22/35] xfs: create helpers for rtbitmap block/wordcount computations Date: Thu, 15 Feb 2024 13:08:34 +0100 Message-ID: <20240215120907.1542854-23-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: d0448fe76ac1a9ccbce574577a4c82246d17eec4 Create helper functions that compute the number of blocks or words necessary to store the rt bitmap. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 27 +++++++++++++++++++++++++++ libxfs/xfs_rtbitmap.h | 12 ++++++++++++ libxfs/xfs_trans_resv.c | 9 +++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 9a8bd93b7..92473d4a5 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1137,3 +1137,30 @@ xfs_rtalloc_extent_is_free( *is_free = matches; return 0; } + +/* + * Compute the number of rtbitmap blocks needed to track the given number of rt + * extents. + */ +xfs_filblks_t +xfs_rtbitmap_blockcount( + struct xfs_mount *mp, + xfs_rtbxlen_t rtextents) +{ + return howmany_64(rtextents, NBBY * mp->m_sb.sb_blocksize); +} + +/* + * 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. + */ +unsigned long long +xfs_rtbitmap_wordcount( + struct xfs_mount *mp, + xfs_rtbxlen_t rtextents) +{ + xfs_filblks_t blocks; + + blocks = xfs_rtbitmap_blockcount(mp, rtextents); + return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG; +} diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 167ea6a08..618c96468 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -283,6 +283,11 @@ xfs_rtfree_extent( /* Same as above, but in units of rt blocks. */ int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, xfs_filblks_t rtlen); + +xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t + rtextents); +unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp, + xfs_rtbxlen_t rtextents); #else /* CONFIG_XFS_RT */ # define xfs_rtfree_extent(t,b,l) (-ENOSYS) # define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) @@ -290,6 +295,13 @@ int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, # define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS) # define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) # define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) +static inline xfs_filblks_t +xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents) +{ + /* shut up gcc */ + return 0; +} +# define xfs_rtbitmap_wordcount(mp, r) (0) #endif /* CONFIG_XFS_RT */ #endif /* __XFS_RTBITMAP_H__ */ diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c index 53c190b72..82b3d1522 100644 --- a/libxfs/xfs_trans_resv.c +++ b/libxfs/xfs_trans_resv.c @@ -217,11 +217,12 @@ xfs_rtalloc_block_count( struct xfs_mount *mp, unsigned int num_ops) { - unsigned int blksz = XFS_FSB_TO_B(mp, 1); - unsigned int rtbmp_bytes; + unsigned int rtbmp_blocks; + xfs_rtxlen_t rtxlen; - rtbmp_bytes = xfs_extlen_to_rtxlen(mp, XFS_MAX_BMBT_EXTLEN) / NBBY; - return (howmany(rtbmp_bytes, blksz) + 1) * num_ops; + rtxlen = xfs_extlen_to_rtxlen(mp, XFS_MAX_BMBT_EXTLEN); + rtbmp_blocks = xfs_rtbitmap_blockcount(mp, rtxlen); + return (rtbmp_blocks + 1) * num_ops; } /* From patchwork Thu Feb 15 12:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558286 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 89D2B12C52D for ; Thu, 15 Feb 2024 12:09:39 +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=1707998979; cv=none; b=K+pu1xdnmBx5ijkCoA+w3iuZ+4Mpwtg3JC4YVBWV0vrdVV7GEZbOnLoildtoZI2d/fzw8f8lV+UA6kmW2eItxnCMdxehpTYqjN1DFRtL/whux6CqMAR8y9HD4sNlFWLPhRdtoSKT9ywg8el4IfDiM+x7di7q/yFkW8TO2sYqYRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998979; c=relaxed/simple; bh=Hapw8RLZtMCGqImN4gU5aJXU2WmntO4RaNRvfJlDBDA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CmO103IWbknukH2N9QVFt+bhexAQRrVmwi/l61Q9UFVvRjCBaN5qsRZqwt+rIO31xjZD8jqDpkS44x6WZoV0pspnFwf7v0E9T3sZL0jIZ4dA1mUFXJz7YsyORrHH5oSY4EQcfK8p5cARAZBxMY+giaNIvKKrq8ofhFfBGR2/3R0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mbn364Cy; 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="Mbn364Cy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDC3EC433C7 for ; Thu, 15 Feb 2024 12:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998979; bh=Hapw8RLZtMCGqImN4gU5aJXU2WmntO4RaNRvfJlDBDA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Mbn364CyDvl3uAfr5pkwH9gfaxpfHBLtYM3O0VWXdmdXINSKpuXYlDkg2LsKDZ77N 0Cpw5UvFK/6UTi1i02Jz6TYfKxy7jkCa0lf7Bep2GdEuMd1wKLnvGWGLS9XFaVqfqS K7K7yw5P6xEvnFY8f6tiRtBBR1bw9wL83dOwdKx10QSRwDbihBM7J371B4hvTFjsi0 n/CNEljCZ8tcsTBBn2/+IUez8A9nhLUIm14fWXkiP8gx/wo2pSrc/PDBWYHPdhshGQ vBKfYo0DtD3qXuaqRZNNrt14EWsVxvpQey74LvGNSUvcxKkRnVnQZAXWQbM5i+g59s S//Bg6AOu9K5A== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 23/35] xfs: create a helper to handle logging parts of rt bitmap/summary blocks Date: Thu, 15 Feb 2024 13:08:35 +0100 Message-ID: <20240215120907.1542854-24-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 312d61021b8947446aa9ec80b78b9230e8cb3691 Create an explicit helper function to log parts of rt bitmap and summary blocks. While we're at it, fix an off-by-one error in two of the rtbitmap logging calls that led to unnecessarily large log items but was otherwise benign. Note that the upcoming rtgroups patchset will add block headers to the rtbitmap and rtsummary files. The helpers in this and the next few patches take a less than direct route through xfs_rbmblock_wordptr and xfs_rsumblock_infoptr to avoid helper churn in that patchset. Suggested-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 55 +++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 92473d4a5..562b40a1a 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -430,6 +430,21 @@ xfs_rtfind_forw( return 0; } +/* Log rtsummary counter at @infoword. */ +static inline void +xfs_trans_log_rtsummary( + struct xfs_trans *tp, + struct xfs_buf *bp, + unsigned int infoword) +{ + size_t first, last; + + first = (void *)xfs_rsumblock_infoptr(bp, infoword) - bp->b_addr; + last = first + sizeof(xfs_suminfo_t) - 1; + + xfs_trans_log_buf(tp, bp, first, last); +} + /* * Read and/or modify the summary information for a given extent size, * bitmap block combination. @@ -495,8 +510,6 @@ xfs_rtmodify_summary_int( infoword = xfs_rtsumoffs_to_infoword(mp, so); sp = xfs_rsumblock_infoptr(bp, infoword); if (delta) { - uint first = (uint)((char *)sp - (char *)bp->b_addr); - *sp += delta; if (mp->m_rsum_cache) { if (*sp == 0 && log == mp->m_rsum_cache[bbno]) @@ -504,7 +517,7 @@ xfs_rtmodify_summary_int( if (*sp != 0 && log < mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; } - xfs_trans_log_buf(tp, bp, first, first + sizeof(*sp) - 1); + xfs_trans_log_rtsummary(tp, bp, infoword); } if (sum) *sum = *sp; @@ -525,6 +538,22 @@ xfs_rtmodify_summary( delta, rbpp, rsb, NULL); } +/* Log rtbitmap block from the word @from to the byte before @next. */ +static inline void +xfs_trans_log_rtbitmap( + struct xfs_trans *tp, + struct xfs_buf *bp, + unsigned int from, + unsigned int next) +{ + size_t first, last; + + first = (void *)xfs_rbmblock_wordptr(bp, from) - bp->b_addr; + last = ((void *)xfs_rbmblock_wordptr(bp, next) - 1) - bp->b_addr; + + xfs_trans_log_buf(tp, bp, first, last); +} + /* * Set the given range of bitmap bits to the given value. * Do whatever I/O and logging is required. @@ -546,6 +575,7 @@ xfs_rtmodify_range( int i; /* current bit number rel. to start */ int lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask o frelevant bits for value */ + unsigned int firstword; /* first word used in the buffer */ unsigned int word; /* word number in the buffer */ /* @@ -563,7 +593,7 @@ xfs_rtmodify_range( /* * Compute the starting word's address, and starting bit. */ - word = xfs_rtx_to_rbmword(mp, start); + firstword = word = xfs_rtx_to_rbmword(mp, start); first = b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); /* @@ -597,15 +627,13 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_buf(tp, bp, - (uint)((char *)first - (char *)bp->b_addr), - (uint)((char *)b - (char *)bp->b_addr)); + xfs_trans_log_rtbitmap(tp, bp, firstword, word); error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); if (error) { return error; } - word = 0; + firstword = word = 0; first = b = xfs_rbmblock_wordptr(bp, word); } else { /* @@ -638,15 +666,13 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_buf(tp, bp, - (uint)((char *)first - (char *)bp->b_addr), - (uint)((char *)b - (char *)bp->b_addr)); + xfs_trans_log_rtbitmap(tp, bp, firstword, word); error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); if (error) { return error; } - word = 0; + firstword = word = 0; first = b = xfs_rbmblock_wordptr(bp, word); } else { /* @@ -671,15 +697,14 @@ xfs_rtmodify_range( *b |= mask; else *b &= ~mask; + word++; b++; } /* * Log any remaining changed bytes. */ if (b > first) - xfs_trans_log_buf(tp, bp, - (uint)((char *)first - (char *)bp->b_addr), - (uint)((char *)b - (char *)bp->b_addr - 1)); + xfs_trans_log_rtbitmap(tp, bp, firstword, word); return 0; } From patchwork Thu Feb 15 12:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558287 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 AA0EF12AAD0 for ; Thu, 15 Feb 2024 12:09:40 +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=1707998980; cv=none; b=fEtbS94F/rMQSCMsIySC+I6u7TPfvffYYZxvWM2GPDKQN2z5DevbUwac7+7rVOMPCMinrC0FOJpGP7gfK/l0Q4nRRUMcxSr+EK5Q2ZJbKoLdfpwk9LbsmycD6dHVPzdGYSJtVpVyvwsD8eXCFcQUoGjCbLaRByI3P+NU9Av1Bj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998980; c=relaxed/simple; bh=YCStQVUxbpgtDq8CZQGtxRipKvur8mhevHIiJ1VAZhA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yjmn9JfwOZh2Ry7dEVYi31JBynh0HyvMTb9ZyCRLpsjtAFwGpEe+pW/6RbDwMFiwtFolZtihtBt6b0Xwft8QBOhzRBDzrLklG30vt7MS0RF9AWyhCM/CPpKRIPoCVcnnUtlaUE9yY6AG59521aQLaNQjqakL3nMob8rSTJtr31E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qO10uXEH; 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="qO10uXEH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6CFEC433F1 for ; Thu, 15 Feb 2024 12:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998980; bh=YCStQVUxbpgtDq8CZQGtxRipKvur8mhevHIiJ1VAZhA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qO10uXEHDheZTteXzWLJNO6qfgFYufrHoFFG4KXvJxx96VpnTFe8WlXWzg3bjXqvm 89TK4hnFG/rnxnvUOts9Npjp2rrajETPR8UsGDe2j6xb8ICQJhrTKH7UJO87CyRyR9 /LQG8Ci3mtogAlCCMgPIiLM1shNzaWFtIrtvMWB6IrE+1H2O60612/IW+VCA/0fQ9T gAAPv6NiUNsK++85cBDtKHfMQwGdKi5Dg6p6EswONpysdRyRkKg0xPdJfDFmDNkc8n t0xnPFJzQu+c3IS5VFWDCRnurxoyW69cW31MXb2t9cnCgARE1QUvkMpSMDZ9zk1Xw8 dDmQ2NNHCjOHQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 24/35] xfs: use accessor functions for bitmap words Date: Thu, 15 Feb 2024 13:08:36 +0100 Message-ID: <20240215120907.1542854-25-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 97e993830a1cdd86ad7d207308b9f55a00660edd Create get and set functions for rtbitmap words so that we can redefine the ondisk format with a specific endianness. Note that this requires the definition of a distinct type for ondisk rtbitmap words so that the compiler can perform proper typechecking as we go back and forth. In the upcoming rtgroups feature, we're going to fix the problem that rtwords are written in host endian order, which means we'll need the distinct rtword/rtword_raw types. Suggested-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_format.h | 8 ++++ libxfs/xfs_rtbitmap.c | 109 +++++++++++++----------------------------- libxfs/xfs_rtbitmap.h | 27 ++++++++++- 3 files changed, 67 insertions(+), 77 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index d48e3a395..2af891d5d 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -690,6 +690,14 @@ struct xfs_agfl { ASSERT(xfs_daddr_to_agno(mp, d) == \ xfs_daddr_to_agno(mp, (d) + (len) - 1))) +/* + * Realtime bitmap information is accessed by the word, which is currently + * stored in host-endian format. + */ +union xfs_rtword_raw { + __u32 old; +}; + /* * XFS Timestamps * ============== diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 562b40a1a..f7be9ea5f 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -97,7 +97,6 @@ xfs_rtfind_back( xfs_rtxnum_t limit, /* last rtext to look at */ xfs_rtxnum_t *rtx) /* out: start rtext found */ { - xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ @@ -108,6 +107,7 @@ xfs_rtfind_back( xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; unsigned int word; /* word number in the buffer */ /* @@ -123,14 +123,14 @@ xfs_rtfind_back( * Get the first word's index & point to it. */ word = xfs_rtx_to_rbmword(mp, start); - b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); len = start - limit + 1; /* * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - want = (*b & ((xfs_rtword_t)1 << bit)) ? -1 : 0; + incore = xfs_rtbitmap_getword(bp, word); + want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the * partial word. @@ -147,7 +147,7 @@ xfs_rtfind_back( * Calculate the difference between the value there * and what we're looking for. */ - if ((wdiff = (*b ^ want) & mask)) { + if ((wdiff = (incore ^ want) & mask)) { /* * Different. Mark where we are and return. */ @@ -172,12 +172,6 @@ xfs_rtfind_back( } word = mp->m_blockwsize - 1; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the previous word in the buffer. - */ - b--; } } else { /* @@ -193,7 +187,8 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - if ((wdiff = *b ^ want)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. */ @@ -218,12 +213,6 @@ xfs_rtfind_back( } word = mp->m_blockwsize - 1; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the previous word in the buffer. - */ - b--; } } /* @@ -240,7 +229,8 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - if ((wdiff = (*b ^ want) & mask)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. */ @@ -271,7 +261,6 @@ xfs_rtfind_forw( xfs_rtxnum_t limit, /* last rtext to look at */ xfs_rtxnum_t *rtx) /* out: start rtext found */ { - xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ @@ -282,6 +271,7 @@ xfs_rtfind_forw( xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t want; /* mask for "good" values */ xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; unsigned int word; /* word number in the buffer */ /* @@ -297,14 +287,14 @@ xfs_rtfind_forw( * Get the first word's index & point to it. */ word = xfs_rtx_to_rbmword(mp, start); - b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); len = limit - start + 1; /* * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - want = (*b & ((xfs_rtword_t)1 << bit)) ? -1 : 0; + incore = xfs_rtbitmap_getword(bp, word); + want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the * partial word. @@ -320,7 +310,7 @@ xfs_rtfind_forw( * Calculate the difference between the value there * and what we're looking for. */ - if ((wdiff = (*b ^ want) & mask)) { + if ((wdiff = (incore ^ want) & mask)) { /* * Different. Mark where we are and return. */ @@ -345,12 +335,6 @@ xfs_rtfind_forw( } word = 0; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the previous word in the buffer. - */ - b++; } } else { /* @@ -366,7 +350,8 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - if ((wdiff = *b ^ want)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. */ @@ -391,12 +376,6 @@ xfs_rtfind_forw( } word = 0; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the next word in the buffer. - */ - b++; } } /* @@ -411,7 +390,8 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - if ((wdiff = (*b ^ want) & mask)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. */ @@ -566,15 +546,14 @@ xfs_rtmodify_range( xfs_rtxlen_t len, /* length of extent to modify */ int val) /* 1 for free, 0 for allocated */ { - xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ int error; /* error value */ - xfs_rtword_t *first; /* first used word in the buffer */ int i; /* current bit number rel. to start */ int lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask o frelevant bits for value */ + xfs_rtword_t incore; unsigned int firstword; /* first word used in the buffer */ unsigned int word; /* word number in the buffer */ @@ -594,7 +573,6 @@ xfs_rtmodify_range( * Compute the starting word's address, and starting bit. */ firstword = word = xfs_rtx_to_rbmword(mp, start); - first = b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); /* * 0 (allocated) => all zeroes; 1 (free) => all ones. @@ -613,10 +591,12 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ + incore = xfs_rtbitmap_getword(bp, word); if (val) - *b |= mask; + incore |= mask; else - *b &= ~mask; + incore &= ~mask; + xfs_rtbitmap_setword(bp, word, incore); i = lastbit - bit; /* * Go on to the next block if that's where the next word is @@ -634,12 +614,6 @@ xfs_rtmodify_range( } firstword = word = 0; - first = b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the next word in the buffer - */ - b++; } } else { /* @@ -655,7 +629,7 @@ xfs_rtmodify_range( /* * Set the word value correctly. */ - *b = val; + xfs_rtbitmap_setword(bp, word, val); i += XFS_NBWORD; /* * Go on to the next block if that's where the next word is @@ -673,12 +647,6 @@ xfs_rtmodify_range( } firstword = word = 0; - first = b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the next word in the buffer - */ - b++; } } /* @@ -693,17 +661,18 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ + incore = xfs_rtbitmap_getword(bp, word); if (val) - *b |= mask; + incore |= mask; else - *b &= ~mask; + incore &= ~mask; + xfs_rtbitmap_setword(bp, word, incore); word++; - b++; } /* * Log any remaining changed bytes. */ - if (b > first) + if (word > firstword) xfs_trans_log_rtbitmap(tp, bp, firstword, word); return 0; } @@ -798,7 +767,6 @@ xfs_rtcheck_range( xfs_rtxnum_t *new, /* out: first rtext not matching */ int *stat) /* out: 1 for matches, 0 for not */ { - xfs_rtword_t *b; /* current word in buffer */ int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ struct xfs_buf *bp; /* buf for the block */ @@ -807,6 +775,7 @@ xfs_rtcheck_range( xfs_rtxnum_t lastbit; /* last useful bit in word */ xfs_rtword_t mask; /* mask of relevant bits for value */ xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; unsigned int word; /* word number in the buffer */ /* @@ -825,7 +794,6 @@ xfs_rtcheck_range( * Compute the starting word's address, and starting bit. */ word = xfs_rtx_to_rbmword(mp, start); - b = xfs_rbmblock_wordptr(bp, word); bit = (int)(start & (XFS_NBWORD - 1)); /* * 0 (allocated) => all zero's; 1 (free) => all one's. @@ -847,7 +815,8 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - if ((wdiff = (*b ^ val) & mask)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. */ @@ -873,12 +842,6 @@ xfs_rtcheck_range( } word = 0; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the next word in the buffer. - */ - b++; } } else { /* @@ -894,7 +857,8 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - if ((wdiff = *b ^ val)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = incore ^ val)) { /* * Different, compute first wrong bit and return. */ @@ -920,12 +884,6 @@ xfs_rtcheck_range( } word = 0; - b = xfs_rbmblock_wordptr(bp, word); - } else { - /* - * Go on to the next word in the buffer. - */ - b++; } } /* @@ -940,7 +898,8 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - if ((wdiff = (*b ^ val) & mask)) { + incore = xfs_rtbitmap_getword(bp, word); + if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. */ diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 618c96468..02ee57f87 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -162,16 +162,39 @@ xfs_rbmblock_to_rtx( } /* Return a pointer to a bitmap word within a rt bitmap block. */ -static inline xfs_rtword_t * +static inline union xfs_rtword_raw * xfs_rbmblock_wordptr( struct xfs_buf *bp, unsigned int index) { - xfs_rtword_t *words = bp->b_addr; + union xfs_rtword_raw *words = bp->b_addr; return words + index; } +/* Convert an ondisk bitmap word to its incore representation. */ +static inline xfs_rtword_t +xfs_rtbitmap_getword( + struct xfs_buf *bp, + unsigned int index) +{ + union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index); + + return word->old; +} + +/* Set an ondisk bitmap word from an incore representation. */ +static inline void +xfs_rtbitmap_setword( + struct xfs_buf *bp, + unsigned int index, + xfs_rtword_t value) +{ + union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index); + + word->old = value; +} + /* * Convert a rt extent length and rt bitmap block number to a xfs_suminfo_t * offset within the rt summary file. From patchwork Thu Feb 15 12:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558288 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 C7A2D12AAD0 for ; Thu, 15 Feb 2024 12:09:41 +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=1707998981; cv=none; b=NnvJfoqppAKUi/R98T8LCn6YjNonQx1fzN+PSsaitimNNPNbgngqdd7iUP4TuOClRcjBwb8Icg6b+7FprSQ9C4lnhdRPNN6hQgclRH4AjglsCKLfx2plrMXssQ7z5rNIQmFqLFsG1YN6W6kWiSJ7ycbMabXkjL27GoA69NK/Xzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998981; c=relaxed/simple; bh=2xEh/EpLrzrAQCmFKqLpJt2vP+35rnPX9Dqa0wjGYww=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cbqZ8f3rO/ehRZogA64n51/m3kToTruH/kYdVD6g+QFS3kgrd3xQ8PXf479o/srLtRleDbB6z+swjFAyrb9mWUca4aT2Pi82qrrHhXOvMnuAgMnOWewD6n5pb7wsr1oRXHgXR5UewuGQYPmCFiLmIVgvgOn2qU0DmsHF2CBOwhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZUAihS7A; 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="ZUAihS7A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FC84C433C7 for ; Thu, 15 Feb 2024 12:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998981; bh=2xEh/EpLrzrAQCmFKqLpJt2vP+35rnPX9Dqa0wjGYww=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZUAihS7AYBzQHB20nPbKA+PAkweP6grT2CmpkC3htlD/gEl3+azZ8kHrpIdntGTkq dd3c/dCWRp/t+tQ1AbUFaZw2TQe8YzE1mt0blCl9T8D91ooBapl4nBz2YlW9flbhq+ 8mQe6PTSnnGCwTW96OLzK1Kib/B265P4yozPEqrh7K1ZfxHJU1vg8Hc6MrwreSYG0Y NpbXfnrBIGOYKRb8rHIJrdqUk+dOPYfvHRLgC9aFdfTi2A8hMS+z9ksCay4PwYwZSq w/p+5qOdI+tTAQ7iQSJkJ5ZdZlXrIflbzXB5CHdr7e0EdxVY7Rt6LzgCHkmvSRwxV4 KibM6bKQE6MBg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 25/35] xfs: create helpers for rtsummary block/wordcount computations Date: Thu, 15 Feb 2024 13:08:37 +0100 Message-ID: <20240215120907.1542854-26-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: bd85af280de66a946022775a876edf0c553e3f35 Create helper functions that compute the number of blocks or words necessary to store the rt summary file. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 29 +++++++++++++++++++++++++++++ libxfs/xfs_rtbitmap.h | 7 +++++++ 2 files changed, 36 insertions(+) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index f7be9ea5f..44064b6b3 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1148,3 +1148,32 @@ xfs_rtbitmap_wordcount( blocks = xfs_rtbitmap_blockcount(mp, rtextents); return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG; } + +/* Compute the number of rtsummary blocks needed to track the given rt space. */ +xfs_filblks_t +xfs_rtsummary_blockcount( + struct xfs_mount *mp, + unsigned int rsumlevels, + xfs_extlen_t rbmblocks) +{ + unsigned long long rsumwords; + + rsumwords = (unsigned long long)rsumlevels * rbmblocks; + return XFS_B_TO_FSB(mp, rsumwords << XFS_WORDLOG); +} + +/* + * Compute the number of rtsummary info words needed to populate every block of + * a summary file that is large enough to track the given rt space. + */ +unsigned long long +xfs_rtsummary_wordcount( + struct xfs_mount *mp, + unsigned int rsumlevels, + xfs_extlen_t rbmblocks) +{ + xfs_filblks_t blocks; + + blocks = xfs_rtsummary_blockcount(mp, rsumlevels, rbmblocks); + return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG; +} diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 02ee57f87..62138df6d 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -311,6 +311,11 @@ xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents); unsigned long long xfs_rtbitmap_wordcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents); + +xfs_filblks_t xfs_rtsummary_blockcount(struct xfs_mount *mp, + unsigned int rsumlevels, xfs_extlen_t rbmblocks); +unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp, + unsigned int rsumlevels, xfs_extlen_t rbmblocks); #else /* CONFIG_XFS_RT */ # define xfs_rtfree_extent(t,b,l) (-ENOSYS) # define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) @@ -325,6 +330,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents) return 0; } # define xfs_rtbitmap_wordcount(mp, r) (0) +# define xfs_rtsummary_blockcount(mp, l, b) (0) +# define xfs_rtsummary_wordcount(mp, l, b) (0) #endif /* CONFIG_XFS_RT */ #endif /* __XFS_RTBITMAP_H__ */ From patchwork Thu Feb 15 12:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558289 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 DF74A57872 for ; Thu, 15 Feb 2024 12:09:42 +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=1707998983; cv=none; b=uVczFxyo78jPU/e7CVJWMo+w6iHabh5JpNA22Z/7J+vhAM9yPX356FEGmmqOte1cpjiANIZBNe4OJKKePHQNvpNsFnJn/zirs2cnluACU63mSNcnsIZr9y7TieBWmrzfANAGVJ6wgpm4zYsM/v4lBiOoAjV+bwbh24ZaB3lh1Ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998983; c=relaxed/simple; bh=1On0fX3NB/NOv4ztxAPBzxWSRWhiBImnIFdRwbEPHsc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a3cHmd4orTofk0uNYc3z1y351TUlHzVr6PgNyOzHx4Xd2LYs9AnF8TYeTbCLrlh3pRXAjshAEXLpc/vjIkGiuEdpyH7IaDNTRDCm07MzPn5T5Xxvgbd7BwPsruBrk6+pmBIJd2pqKayXNY8T80PwRavMnLyRJ1YYez/WTfXqOx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CnB6Ak7I; 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="CnB6Ak7I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E018C433C7 for ; Thu, 15 Feb 2024 12:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998982; bh=1On0fX3NB/NOv4ztxAPBzxWSRWhiBImnIFdRwbEPHsc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CnB6Ak7Io04hliGKLTG3Syg5FHT/VdhcDE4Ql5ViinCt2b6K/GDpjHHJoAkwd6HVB tjl+nXGJ33BmTzmKKLnxQIpFxM4BCJ6RVh5NQLGCyGBT0H85oYOs5fgECo+z5rWfaj qaIY89Fos4k8d0cpgtJKfI7LjhLasOCHjuEgsZsahTADJcn7Db1jVpnlcDwujOaToy wXUgf0NjgAYP8/Uxv0YP3Ph7o0zBzb7nJXQc15fdVM1HGmV9Xqui48x5kII4Ds/Dz3 rBHzYSPGJnopop/iCWtKQDyUdhFtjfnkR74LCqB/su6nro1Vl4liike+DUvRxsOWR1 FTHy794TB66Eg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 26/35] xfs: use accessor functions for summary info words Date: Thu, 15 Feb 2024 13:08:38 +0100 Message-ID: <20240215120907.1542854-27-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 663b8db7b0256b81152b2f786e45ecf12bdf265f Create get and set functions for rtsummary words so that we can redefine the ondisk format with a specific endianness. Note that this requires the definition of a distinct type for ondisk summary info words so that the compiler can perform proper typechecking. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_format.h | 8 ++++++++ libxfs/xfs_rtbitmap.c | 15 ++++++++------- libxfs/xfs_rtbitmap.h | 28 ++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 2af891d5d..9a88aba15 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -698,6 +698,14 @@ union xfs_rtword_raw { __u32 old; }; +/* + * Realtime summary counts are accessed by the word, which is currently + * stored in host-endian format. + */ +union xfs_suminfo_raw { + __u32 old; +}; + /* * XFS Timestamps * ============== diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 44064b6b3..869d26e79 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -449,7 +449,6 @@ xfs_rtmodify_summary_int( int error; /* error value */ xfs_fileoff_t sb; /* summary fsblock */ xfs_rtsumoff_t so; /* index into the summary file */ - xfs_suminfo_t *sp; /* pointer to returned data */ unsigned int infoword; /* @@ -488,19 +487,21 @@ xfs_rtmodify_summary_int( * Point to the summary information, modify/log it, and/or copy it out. */ infoword = xfs_rtsumoffs_to_infoword(mp, so); - sp = xfs_rsumblock_infoptr(bp, infoword); if (delta) { - *sp += delta; + xfs_suminfo_t val = xfs_suminfo_add(bp, infoword, delta); + if (mp->m_rsum_cache) { - if (*sp == 0 && log == mp->m_rsum_cache[bbno]) + if (val == 0 && log == mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno]++; - if (*sp != 0 && log < mp->m_rsum_cache[bbno]) + if (val != 0 && log < mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; } xfs_trans_log_rtsummary(tp, bp, infoword); + if (sum) + *sum = val; + } else if (sum) { + *sum = xfs_suminfo_get(bp, infoword); } - if (sum) - *sum = *sp; return 0; } diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 62138df6d..e4268faa6 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -235,16 +235,40 @@ xfs_rtsumoffs_to_infoword( } /* Return a pointer to a summary info word within a rt summary block. */ -static inline xfs_suminfo_t * +static inline union xfs_suminfo_raw * xfs_rsumblock_infoptr( struct xfs_buf *bp, unsigned int index) { - xfs_suminfo_t *info = bp->b_addr; + union xfs_suminfo_raw *info = bp->b_addr; return info + index; } +/* Get the current value of a summary counter. */ +static inline xfs_suminfo_t +xfs_suminfo_get( + struct xfs_buf *bp, + unsigned int index) +{ + union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index); + + return info->old; +} + +/* Add to the current value of a summary counter and return the new value. */ +static inline xfs_suminfo_t +xfs_suminfo_add( + struct xfs_buf *bp, + unsigned int index, + int delta) +{ + union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index); + + info->old += delta; + return info->old; +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ From patchwork Thu Feb 15 12:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558290 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 3DDAA57872 for ; Thu, 15 Feb 2024 12:09:44 +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=1707998984; cv=none; b=aa1Vvxb2izZiEdHZQwLPf+GU/VYcWVgldW4YXbPFauDZi1ryO1nDGhlZ8L5WoiBRGs6R134ADrJX4JQhONzctC/ZcAkYVF9zQ03nVpsjuS1TANhAGZ5J551+LPf6+mhDBFjMn/h0YPQ8w6sXdFlqSJVPPRoB0oRBy0dkD60hfcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998984; c=relaxed/simple; bh=9sCnNI/dZsC4YE6cV6Yi9BO+eIhqpTIl1WjtGQaFBQg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i5+PYhahE1I2Wr+w+Jyu2W5tyKBok8pfbV3xgZ1Vw1HvY4umFnWx6Ke9K+jNNPp/UmE8SgfLj6+G7sJYVUF4+xvdU0IRJsShBChP/p2UczhTnisMt+T+sdZfW83PuNx6scubAIrLj4V068OJNkweS2JENSXcD89MRtfM1JORNNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uO1OHjJp; 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="uO1OHjJp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38137C433C7 for ; Thu, 15 Feb 2024 12:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998984; bh=9sCnNI/dZsC4YE6cV6Yi9BO+eIhqpTIl1WjtGQaFBQg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uO1OHjJphKE9HV72vZi+xNNqTyN+jbj4EJP7+u3SnVp2WMT0dp9Tb8naKSKM753Bc ezAlT/LDKN2iQtm7hW7Ix+LtXs3/nVS36F8wN0SF9jAAvxYKLfYLjaxczshx+GEOtt QWFJ4XHoLszth7y/nfjlYlg5s2SLj9zWws3T4zsuAwt9v8sTEmtiHUZNjaEKcKZQY7 Ag0zPXqZMIV/Z805jGuEe8Pu+nnJMIJyOydotpcv1q0Nfbr4Ku0z9nbP6DVkOcb6iJ ayxzgn4vIFCOOEBPLWuVZuJpx2vP4AaKKD4MFKkx7B6QajTmRG5BX6+xnaI5YMnujU jOACouPAqgNXw== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 27/35] xfs: consolidate realtime allocation arguments Date: Thu, 15 Feb 2024 13:08:39 +0100 Message-ID: <20240215120907.1542854-28-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Dave Chinner Source kernel commit: 41f33d82cfd310e344fc9183f02cc9e0d2d27663 Consolidate the arguments passed around the rt allocator into a struct xfs_rtalloc_arg similar to how the btree allocator arguments are consolidated in a struct xfs_alloc_arg.... Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 368 +++++++++++++++++++++--------------------- libxfs/xfs_rtbitmap.h | 46 +++--- 2 files changed, 211 insertions(+), 203 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 869d26e79..53e2c1c89 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -51,17 +51,17 @@ const struct xfs_buf_ops xfs_rtbuf_ops = { */ int xfs_rtbuf_get( - xfs_mount_t *mp, /* file system mount structure */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_fileoff_t block, /* block number in bitmap or summary */ - int issum, /* is summary not bitmap */ - struct xfs_buf **bpp) /* output: buffer for the block */ + struct xfs_rtalloc_args *args, + xfs_fileoff_t block, /* block number in bitmap or summary */ + int issum, /* is summary not bitmap */ + struct xfs_buf **bpp) /* output: buffer for the block */ { - struct xfs_buf *bp; /* block buffer, result */ - xfs_inode_t *ip; /* bitmap or summary inode */ - xfs_bmbt_irec_t map; - int nmap = 1; - int error; /* error value */ + struct xfs_mount *mp = args->mp; + struct xfs_buf *bp; /* block buffer, result */ + struct xfs_inode *ip; /* bitmap or summary inode */ + struct xfs_bmbt_irec map; + int nmap = 1; + int error; ip = issum ? mp->m_rsumip : mp->m_rbmip; @@ -73,13 +73,13 @@ xfs_rtbuf_get( return -EFSCORRUPTED; ASSERT(map.br_startblock != NULLFSBLOCK); - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, + error = xfs_trans_read_buf(mp, args->tp, mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, map.br_startblock), mp->m_bsize, 0, &bp, &xfs_rtbuf_ops); if (error) return error; - xfs_trans_buf_set_type(tp, bp, issum ? XFS_BLFT_RTSUMMARY_BUF + xfs_trans_buf_set_type(args->tp, bp, issum ? XFS_BLFT_RTSUMMARY_BUF : XFS_BLFT_RTBITMAP_BUF); *bpp = bp; return 0; @@ -91,30 +91,30 @@ xfs_rtbuf_get( */ int xfs_rtfind_back( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext to look at */ - xfs_rtxnum_t limit, /* last rtext to look at */ - xfs_rtxnum_t *rtx) /* out: start rtext found */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext to look at */ + xfs_rtxnum_t limit, /* last rtext to look at */ + xfs_rtxnum_t *rtx) /* out: start rtext found */ { - int bit; /* bit number in the word */ - xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ - int error; /* error value */ - xfs_rtxnum_t firstbit; /* first useful bit in the word */ - xfs_rtxnum_t i; /* current bit number rel. to start */ - xfs_rtxnum_t len; /* length of inspected area */ - xfs_rtword_t mask; /* mask of relevant bits for value */ - xfs_rtword_t want; /* mask for "good" values */ - xfs_rtword_t wdiff; /* difference from wanted value */ - xfs_rtword_t incore; - unsigned int word; /* word number in the buffer */ + struct xfs_mount *mp = args->mp; + int bit; /* bit number in the word */ + xfs_fileoff_t block; /* bitmap block number */ + struct xfs_buf *bp; /* buf for the block */ + int error; /* error value */ + xfs_rtxnum_t firstbit; /* first useful bit in the word */ + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t len; /* length of inspected area */ + xfs_rtword_t mask; /* mask of relevant bits for value */ + xfs_rtword_t want; /* mask for "good" values */ + xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; + unsigned int word; /* word number in the buffer */ /* * Compute and read in starting bitmap block for starting block. */ block = xfs_rtx_to_rbmblock(mp, start); - error = xfs_rtbuf_get(mp, tp, block, 0, &bp); + error = xfs_rtbuf_get(args, block, 0, &bp); if (error) { return error; } @@ -151,7 +151,7 @@ xfs_rtfind_back( /* * Different. Mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i = bit - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -165,8 +165,8 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, --block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, --block, 0, &bp); if (error) { return error; } @@ -192,7 +192,7 @@ xfs_rtfind_back( /* * Different, mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -206,8 +206,8 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, --block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, --block, 0, &bp); if (error) { return error; } @@ -234,7 +234,7 @@ xfs_rtfind_back( /* * Different, mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -244,7 +244,7 @@ xfs_rtfind_back( /* * No match, return that we scanned the whole area. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); *rtx = start - i + 1; return 0; } @@ -255,30 +255,30 @@ xfs_rtfind_back( */ int xfs_rtfind_forw( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext to look at */ - xfs_rtxnum_t limit, /* last rtext to look at */ - xfs_rtxnum_t *rtx) /* out: start rtext found */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext to look at */ + xfs_rtxnum_t limit, /* last rtext to look at */ + xfs_rtxnum_t *rtx) /* out: start rtext found */ { - int bit; /* bit number in the word */ - xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ - int error; /* error value */ - xfs_rtxnum_t i; /* current bit number rel. to start */ - xfs_rtxnum_t lastbit; /* last useful bit in the word */ - xfs_rtxnum_t len; /* length of inspected area */ - xfs_rtword_t mask; /* mask of relevant bits for value */ - xfs_rtword_t want; /* mask for "good" values */ - xfs_rtword_t wdiff; /* difference from wanted value */ - xfs_rtword_t incore; - unsigned int word; /* word number in the buffer */ + struct xfs_mount *mp = args->mp; + int bit; /* bit number in the word */ + xfs_fileoff_t block; /* bitmap block number */ + struct xfs_buf *bp; /* buf for the block */ + int error; + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t lastbit;/* last useful bit in the word */ + xfs_rtxnum_t len; /* length of inspected area */ + xfs_rtword_t mask; /* mask of relevant bits for value */ + xfs_rtword_t want; /* mask for "good" values */ + xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; + unsigned int word; /* word number in the buffer */ /* * Compute and read in starting bitmap block for starting block. */ block = xfs_rtx_to_rbmblock(mp, start); - error = xfs_rtbuf_get(mp, tp, block, 0, &bp); + error = xfs_rtbuf_get(args, block, 0, &bp); if (error) { return error; } @@ -314,7 +314,7 @@ xfs_rtfind_forw( /* * Different. Mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i = XFS_RTLOBIT(wdiff) - bit; *rtx = start + i - 1; return 0; @@ -328,8 +328,8 @@ xfs_rtfind_forw( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; } @@ -355,7 +355,7 @@ xfs_rtfind_forw( /* * Different, mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *rtx = start + i - 1; return 0; @@ -369,8 +369,8 @@ xfs_rtfind_forw( /* * If done with this block, get the next one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; } @@ -395,7 +395,7 @@ xfs_rtfind_forw( /* * Different, mark where we are and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *rtx = start + i - 1; return 0; @@ -405,7 +405,7 @@ xfs_rtfind_forw( /* * No match, return that we scanned the whole area. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); *rtx = start + i - 1; return 0; } @@ -436,20 +436,20 @@ xfs_trans_log_rtsummary( */ int xfs_rtmodify_summary_int( - xfs_mount_t *mp, /* file system mount structure */ - xfs_trans_t *tp, /* transaction pointer */ - int log, /* log2 of extent size */ - xfs_fileoff_t bbno, /* bitmap block number */ - int delta, /* change to make to summary info */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb, /* in/out: summary block number */ - xfs_suminfo_t *sum) /* out: summary info for this block */ + struct xfs_rtalloc_args *args, + int log, /* log2 of extent size */ + xfs_fileoff_t bbno, /* bitmap block number */ + int delta, /* change to make to summary info */ + struct xfs_buf **rbpp, /* in/out: summary block buffer */ + xfs_fileoff_t *rsb, /* in/out: summary block number */ + xfs_suminfo_t *sum) /* out: summary info for this block */ { - struct xfs_buf *bp; /* buffer for the summary block */ - int error; /* error value */ - xfs_fileoff_t sb; /* summary fsblock */ - xfs_rtsumoff_t so; /* index into the summary file */ - unsigned int infoword; + struct xfs_mount *mp = args->mp; + struct xfs_buf *bp; /* buffer for the summary block */ + int error; + xfs_fileoff_t sb; /* summary fsblock */ + xfs_rtsumoff_t so; /* index into the summary file */ + unsigned int infoword; /* * Compute entry number in the summary file. @@ -472,8 +472,8 @@ xfs_rtmodify_summary_int( * If there was an old one, get rid of it first. */ if (*rbpp) - xfs_trans_brelse(tp, *rbpp); - error = xfs_rtbuf_get(mp, tp, sb, 1, &bp); + xfs_trans_brelse(args->tp, *rbpp); + error = xfs_rtbuf_get(args, sb, 1, &bp); if (error) { return error; } @@ -496,7 +496,7 @@ xfs_rtmodify_summary_int( if (val != 0 && log < mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; } - xfs_trans_log_rtsummary(tp, bp, infoword); + xfs_trans_log_rtsummary(args->tp, bp, infoword); if (sum) *sum = val; } else if (sum) { @@ -507,16 +507,14 @@ xfs_rtmodify_summary_int( int xfs_rtmodify_summary( - xfs_mount_t *mp, /* file system mount structure */ - xfs_trans_t *tp, /* transaction pointer */ - int log, /* log2 of extent size */ - xfs_fileoff_t bbno, /* bitmap block number */ - int delta, /* change to make to summary info */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb) /* in/out: summary block number */ + struct xfs_rtalloc_args *args, + int log, /* log2 of extent size */ + xfs_fileoff_t bbno, /* bitmap block number */ + int delta, /* change to make to summary info */ + struct xfs_buf **rbpp, /* in/out: summary block buffer */ + xfs_fileoff_t *rsb) /* in/out: summary block number */ { - return xfs_rtmodify_summary_int(mp, tp, log, bbno, - delta, rbpp, rsb, NULL); + return xfs_rtmodify_summary_int(args, log, bbno, delta, rbpp, rsb, NULL); } /* Log rtbitmap block from the word @from to the byte before @next. */ @@ -541,22 +539,22 @@ xfs_trans_log_rtbitmap( */ int xfs_rtmodify_range( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext to modify */ - xfs_rtxlen_t len, /* length of extent to modify */ - int val) /* 1 for free, 0 for allocated */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext to modify */ + xfs_rtxlen_t len, /* length of extent to modify */ + int val) /* 1 for free, 0 for allocated */ { - int bit; /* bit number in the word */ - xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ - int error; /* error value */ - int i; /* current bit number rel. to start */ - int lastbit; /* last useful bit in word */ - xfs_rtword_t mask; /* mask o frelevant bits for value */ - xfs_rtword_t incore; - unsigned int firstword; /* first word used in the buffer */ - unsigned int word; /* word number in the buffer */ + struct xfs_mount *mp = args->mp; + int bit; /* bit number in the word */ + xfs_fileoff_t block; /* bitmap block number */ + struct xfs_buf *bp; /* buf for the block */ + int error; + int i; /* current bit number rel. to start */ + int lastbit; /* last useful bit in word */ + xfs_rtword_t mask; /* mask of relevant bits for value */ + xfs_rtword_t incore; + unsigned int firstword; /* first word used in the buffer */ + unsigned int word; /* word number in the buffer */ /* * Compute starting bitmap block number. @@ -565,7 +563,7 @@ xfs_rtmodify_range( /* * Read the bitmap block, and point to its data. */ - error = xfs_rtbuf_get(mp, tp, block, 0, &bp); + error = xfs_rtbuf_get(args, block, 0, &bp); if (error) { return error; } @@ -608,8 +606,9 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(tp, bp, firstword, word); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); + xfs_trans_log_rtbitmap(args->tp, bp, firstword, + word); + error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; } @@ -641,11 +640,11 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(tp, bp, firstword, word); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); - if (error) { + xfs_trans_log_rtbitmap(args->tp, bp, firstword, + word); + error = xfs_rtbuf_get(args, ++block, 0, &bp); + if (error) return error; - } firstword = word = 0; } @@ -674,7 +673,7 @@ xfs_rtmodify_range( * Log any remaining changed bytes. */ if (word > firstword) - xfs_trans_log_rtbitmap(tp, bp, firstword, word); + xfs_trans_log_rtbitmap(args->tp, bp, firstword, word); return 0; } @@ -684,23 +683,23 @@ xfs_rtmodify_range( */ int xfs_rtfree_range( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext to free */ - xfs_rtxlen_t len, /* length to free */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb) /* in/out: summary block number */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext to free */ + xfs_rtxlen_t len, /* length to free */ + struct xfs_buf **rbpp, /* in/out: summary block buffer */ + xfs_fileoff_t *rsb) /* in/out: summary block number */ { - xfs_rtxnum_t end; /* end of the freed extent */ - int error; /* error value */ - xfs_rtxnum_t postblock; /* first rtext freed > end */ - xfs_rtxnum_t preblock; /* first rtext freed < start */ + struct xfs_mount *mp = args->mp; + xfs_rtxnum_t end; /* end of the freed extent */ + int error; /* error value */ + xfs_rtxnum_t postblock; /* first rtext freed > end */ + xfs_rtxnum_t preblock; /* first rtext freed < start */ end = start + len - 1; /* * Modify the bitmap to mark this extent freed. */ - error = xfs_rtmodify_range(mp, tp, start, len, 1); + error = xfs_rtmodify_range(args, start, len, 1); if (error) { return error; } @@ -709,14 +708,14 @@ xfs_rtfree_range( * We need to find the beginning and end of the extent so we can * properly update the summary. */ - error = xfs_rtfind_back(mp, tp, start, 0, &preblock); + error = xfs_rtfind_back(args, start, 0, &preblock); if (error) { return error; } /* * Find the next allocated block (end of allocated extent). */ - error = xfs_rtfind_forw(mp, tp, end, mp->m_sb.sb_rextents - 1, + error = xfs_rtfind_forw(args, end, mp->m_sb.sb_rextents - 1, &postblock); if (error) return error; @@ -725,7 +724,7 @@ xfs_rtfree_range( * old extent, add summary data for them to be allocated. */ if (preblock < start) { - error = xfs_rtmodify_summary(mp, tp, + error = xfs_rtmodify_summary(args, XFS_RTBLOCKLOG(start - preblock), xfs_rtx_to_rbmblock(mp, preblock), -1, rbpp, rsb); if (error) { @@ -737,7 +736,7 @@ xfs_rtfree_range( * old extent, add summary data for them to be allocated. */ if (postblock > end) { - error = xfs_rtmodify_summary(mp, tp, + error = xfs_rtmodify_summary(args, XFS_RTBLOCKLOG(postblock - end), xfs_rtx_to_rbmblock(mp, end + 1), -1, rbpp, rsb); if (error) { @@ -748,7 +747,7 @@ xfs_rtfree_range( * Increment the summary information corresponding to the entire * (new) free extent. */ - error = xfs_rtmodify_summary(mp, tp, + error = xfs_rtmodify_summary(args, XFS_RTBLOCKLOG(postblock + 1 - preblock), xfs_rtx_to_rbmblock(mp, preblock), 1, rbpp, rsb); return error; @@ -760,24 +759,24 @@ xfs_rtfree_range( */ int xfs_rtcheck_range( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext number of extent */ - xfs_rtxlen_t len, /* length of extent */ - int val, /* 1 for free, 0 for allocated */ - xfs_rtxnum_t *new, /* out: first rtext not matching */ - int *stat) /* out: 1 for matches, 0 for not */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext number of extent */ + xfs_rtxlen_t len, /* length of extent */ + int val, /* 1 for free, 0 for allocated */ + xfs_rtxnum_t *new, /* out: first rtext not matching */ + int *stat) /* out: 1 for matches, 0 for not */ { - int bit; /* bit number in the word */ - xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ - int error; /* error value */ - xfs_rtxnum_t i; /* current bit number rel. to start */ - xfs_rtxnum_t lastbit; /* last useful bit in word */ - xfs_rtword_t mask; /* mask of relevant bits for value */ - xfs_rtword_t wdiff; /* difference from wanted value */ - xfs_rtword_t incore; - unsigned int word; /* word number in the buffer */ + struct xfs_mount *mp = args->mp; + int bit; /* bit number in the word */ + xfs_fileoff_t block; /* bitmap block number */ + struct xfs_buf *bp; /* buf for the block */ + int error; + xfs_rtxnum_t i; /* current bit number rel. to start */ + xfs_rtxnum_t lastbit; /* last useful bit in word */ + xfs_rtword_t mask; /* mask of relevant bits for value */ + xfs_rtword_t wdiff; /* difference from wanted value */ + xfs_rtword_t incore; + unsigned int word; /* word number in the buffer */ /* * Compute starting bitmap block number @@ -786,7 +785,7 @@ xfs_rtcheck_range( /* * Read the bitmap block. */ - error = xfs_rtbuf_get(mp, tp, block, 0, &bp); + error = xfs_rtbuf_get(args, block, 0, &bp); if (error) { return error; } @@ -821,7 +820,7 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i = XFS_RTLOBIT(wdiff) - bit; *new = start + i; *stat = 0; @@ -836,8 +835,8 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; } @@ -863,7 +862,7 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *new = start + i; *stat = 0; @@ -878,8 +877,8 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - xfs_trans_brelse(tp, bp); - error = xfs_rtbuf_get(mp, tp, ++block, 0, &bp); + xfs_trans_brelse(args->tp, bp); + error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; } @@ -904,7 +903,7 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *new = start + i; *stat = 0; @@ -915,7 +914,7 @@ xfs_rtcheck_range( /* * Successful, return. */ - xfs_trans_brelse(tp, bp); + xfs_trans_brelse(args->tp, bp); *new = start + i; *stat = 1; return 0; @@ -925,55 +924,56 @@ xfs_rtcheck_range( /* * Check that the given extent (block range) is allocated already. */ -STATIC int /* error */ +STATIC int xfs_rtcheck_alloc_range( - xfs_mount_t *mp, /* file system mount point */ - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext number of extent */ - xfs_rtxlen_t len) /* length of extent */ + struct xfs_rtalloc_args *args, + xfs_rtxnum_t start, /* starting rtext number of extent */ + xfs_rtxlen_t len) /* length of extent */ { - xfs_rtxnum_t new; /* dummy for xfs_rtcheck_range */ - int stat; - int error; + xfs_rtxnum_t new; /* dummy for xfs_rtcheck_range */ + int stat; + int error; - error = xfs_rtcheck_range(mp, tp, start, len, 0, &new, &stat); + error = xfs_rtcheck_range(args, start, len, 0, &new, &stat); if (error) return error; ASSERT(stat); return 0; } #else -#define xfs_rtcheck_alloc_range(m,t,b,l) (0) +#define xfs_rtcheck_alloc_range(a,b,l) (0) #endif /* * Free an extent in the realtime subvolume. Length is expressed in * realtime extents, as is the block number. */ -int /* error */ +int xfs_rtfree_extent( - xfs_trans_t *tp, /* transaction pointer */ - xfs_rtxnum_t start, /* starting rtext number to free */ - xfs_rtxlen_t len) /* length of extent freed */ + xfs_trans_t *tp, /* transaction pointer */ + xfs_rtxnum_t start, /* starting rtext number to free */ + xfs_rtxlen_t len) /* length of extent freed */ { - int error; /* error value */ - xfs_mount_t *mp; /* file system mount structure */ - xfs_fsblock_t sb; /* summary file block number */ - struct xfs_buf *sumbp = NULL; /* summary file block buffer */ - struct timespec64 atime; - - mp = tp->t_mountp; + struct xfs_mount *mp = tp->t_mountp; + struct xfs_rtalloc_args args = { + .mp = mp, + .tp = tp, + }; + int error; + xfs_fsblock_t sb; /* summary file block number */ + struct xfs_buf *sumbp = NULL; /* summary file block buffer */ + struct timespec64 atime; ASSERT(mp->m_rbmip->i_itemp != NULL); ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); - error = xfs_rtcheck_alloc_range(mp, tp, start, len); + error = xfs_rtcheck_alloc_range(&args, start, len); if (error) return error; /* * Free the range of realtime blocks. */ - error = xfs_rtfree_range(mp, tp, start, len, &sumbp, &sb); + error = xfs_rtfree_range(&args, start, len, &sumbp, &sb); if (error) { return error; } @@ -1041,6 +1041,10 @@ xfs_rtalloc_query_range( xfs_rtalloc_query_range_fn fn, void *priv) { + struct xfs_rtalloc_args args = { + .mp = mp, + .tp = tp, + }; struct xfs_rtalloc_rec rec; xfs_rtxnum_t rtstart; xfs_rtxnum_t rtend; @@ -1060,13 +1064,13 @@ xfs_rtalloc_query_range( rtstart = low_rec->ar_startext; while (rtstart <= high_key) { /* Is the first block free? */ - error = xfs_rtcheck_range(mp, tp, rtstart, 1, 1, &rtend, + error = xfs_rtcheck_range(&args, rtstart, 1, 1, &rtend, &is_free); if (error) break; /* How long does the extent go for? */ - error = xfs_rtfind_forw(mp, tp, rtstart, high_key, &rtend); + error = xfs_rtfind_forw(&args, rtstart, high_key, &rtend); if (error) break; @@ -1111,11 +1115,15 @@ xfs_rtalloc_extent_is_free( xfs_rtxlen_t len, bool *is_free) { + struct xfs_rtalloc_args args = { + .mp = mp, + .tp = tp, + }; xfs_rtxnum_t end; int matches; int error; - error = xfs_rtcheck_range(mp, tp, start, len, 1, &end, &matches); + error = xfs_rtcheck_range(&args, start, len, 1, &end, &matches); if (error) return error; diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index e4268faa6..025a7efc2 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -9,6 +9,11 @@ /* For userspace XFS_RT is always defined */ #define CONFIG_XFS_RT +struct xfs_rtalloc_args { + struct xfs_mount *mp; + struct xfs_trans *tp; +}; + static inline xfs_rtblock_t xfs_rtx_to_rtb( struct xfs_mount *mp, @@ -284,29 +289,24 @@ typedef int (*xfs_rtalloc_query_range_fn)( void *priv); #ifdef CONFIG_XFS_RT -int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_fileoff_t block, int issum, struct xfs_buf **bpp); -int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtxnum_t start, xfs_rtxlen_t len, int val, - xfs_rtxnum_t *new, int *stat); -int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtxnum_t start, xfs_rtxnum_t limit, - xfs_rtxnum_t *rtblock); -int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtxnum_t start, xfs_rtxnum_t limit, - xfs_rtxnum_t *rtblock); -int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtxnum_t start, xfs_rtxlen_t len, int val); -int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, - int log, xfs_fileoff_t bbno, int delta, - struct xfs_buf **rbpp, xfs_fileoff_t *rsb, - xfs_suminfo_t *sum); -int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, - xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, - xfs_fileoff_t *rsb); -int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_rtxnum_t start, xfs_rtxlen_t len, - struct xfs_buf **rbpp, xfs_fileoff_t *rsb); +int xfs_rtbuf_get(struct xfs_rtalloc_args *args, xfs_fileoff_t block, + int issum, struct xfs_buf **bpp); +int xfs_rtcheck_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, + xfs_rtxlen_t len, int val, xfs_rtxnum_t *new, int *stat); +int xfs_rtfind_back(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, + xfs_rtxnum_t limit, xfs_rtxnum_t *rtblock); +int xfs_rtfind_forw(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, + xfs_rtxnum_t limit, xfs_rtxnum_t *rtblock); +int xfs_rtmodify_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, + xfs_rtxlen_t len, int val); +int xfs_rtmodify_summary_int(struct xfs_rtalloc_args *args, int log, + xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, + xfs_fileoff_t *rsb, xfs_suminfo_t *sum); +int xfs_rtmodify_summary(struct xfs_rtalloc_args *args, int log, + xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, + xfs_fileoff_t *rsb); +int xfs_rtfree_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, + xfs_rtxlen_t len, struct xfs_buf **rbpp, xfs_fileoff_t *rsb); int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, const struct xfs_rtalloc_rec *low_rec, const struct xfs_rtalloc_rec *high_rec, From patchwork Thu Feb 15 12:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558291 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 B495157872 for ; Thu, 15 Feb 2024 12:09:45 +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=1707998985; cv=none; b=fqK+ulyDW0Ccw1A2g3NYI1xIc/et7RKJ1erh6WvU+oPanC3CYh4kG33rdnZlrMJcqe+UfHQHHDRHUFx6QIfrUplqxy0epG6bdNsWx0HulEspGG5CTxzQM1LYG/CJUaliizfBhU9+N8kH1miRBxFBbUB+98FWri9QOQ28LfLr6lE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998985; c=relaxed/simple; bh=7uPNxdBG4LP7W6/xenwEhoVdXYeT8A9UIR7GmzN6WWg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HmHsqkTwrBR+SFpoRpRgsF7RDRvPvxS1yRQvUk+Jid1KiAsU7BSGFIfn3pwNNNXpi3kQYKxKQFgjA/sTyqEEoQubat5bsE4qyNDGJVN8s1U8zD1fEKCIUbIhlUMj3pNfxTB4BsQByQdGkM3flJxnHDnQRutExxjnr/nt6L8uyWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p8gHePrK; 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="p8gHePrK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C4CFC433F1 for ; Thu, 15 Feb 2024 12:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998985; bh=7uPNxdBG4LP7W6/xenwEhoVdXYeT8A9UIR7GmzN6WWg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p8gHePrKBVW8KXlQyuHgVQ5VJR7ajml0y5hLmqDFWBLd1wusg0D/OzdrmteOh+wTd /MWAHgqccjWK8AGwZ82R6JhLNKqlIzlQVU9gkYk7dciI9zgCjDK+/EfGfCEMoZfXzS JzbRIonQOBb4lIxQRWLjNmjzG6MNxtMaQv8Au1kmydtpwlGCTVfHYTaK4HXkhDYHb1 Iltb46VZF4j9agJ9Q1YB8KZM+iee4ifBmurCwuvYtA6yg3mLKGcNzjeMtT4+e9Pom1 HxN5QSDzynKy1Cs8FK9qpOB3v6HJDfWyvbXtotln/YE4MFg5G8tY++LS32lJG0UrXA 50hhsd0PXIv0w== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 28/35] xfs: cache last bitmap block in realtime allocator Date: Thu, 15 Feb 2024 13:08:40 +0100 Message-ID: <20240215120907.1542854-29-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Omar Sandoval Source kernel commit: e94b53ff699c2674a9ec083342a5254866210ade Profiling a workload on a highly fragmented realtime device showed a ton of CPU cycles being spent in xfs_trans_read_buf() called by xfs_rtbuf_get(). Further tracing showed that much of that was repeated calls to xfs_rtbuf_get() for the same block of the realtime bitmap. These come from xfs_rtallocate_extent_block(): as it walks through ranges of free bits in the bitmap, each call to xfs_rtcheck_range() and xfs_rtfind_{forw,back}() gets the same bitmap block. If the bitmap block is very fragmented, then this is _a lot_ of buffer lookups. The realtime allocator already passes around a cache of the last used realtime summary block to avoid repeated reads (the parameters rbpp and rsb). We can do the same for the realtime bitmap. This replaces rbpp and rsb with a struct xfs_rtbuf_cache, which caches the most recently used block for both the realtime bitmap and summary. xfs_rtbuf_get() now handles the caching instead of the callers, which requires plumbing xfs_rtbuf_cache to more functions but also makes sure we don't miss anything. Signed-off-by: Omar Sandoval Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 147 ++++++++++++++++++++++-------------------- libxfs/xfs_rtbitmap.h | 17 +++-- 2 files changed, 88 insertions(+), 76 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 53e2c1c89..e9c70ff88 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -45,6 +45,23 @@ const struct xfs_buf_ops xfs_rtbuf_ops = { .verify_write = xfs_rtbuf_verify_write, }; +/* Release cached rt bitmap and summary buffers. */ +void +xfs_rtbuf_cache_relse( + struct xfs_rtalloc_args *args) +{ + if (args->rbmbp) { + xfs_trans_brelse(args->tp, args->rbmbp); + args->rbmbp = NULL; + args->rbmoff = NULLFILEOFF; + } + if (args->sumbp) { + xfs_trans_brelse(args->tp, args->sumbp); + args->sumbp = NULL; + args->sumoff = NULLFILEOFF; + } +} + /* * Get a buffer for the bitmap or summary file block specified. * The buffer is returned read and locked. @@ -57,13 +74,42 @@ xfs_rtbuf_get( struct xfs_buf **bpp) /* output: buffer for the block */ { struct xfs_mount *mp = args->mp; + struct xfs_buf **cbpp; /* cached block buffer */ + xfs_fileoff_t *coffp; /* cached block number */ struct xfs_buf *bp; /* block buffer, result */ struct xfs_inode *ip; /* bitmap or summary inode */ struct xfs_bmbt_irec map; + enum xfs_blft type; int nmap = 1; int error; - ip = issum ? mp->m_rsumip : mp->m_rbmip; + if (issum) { + cbpp = &args->sumbp; + coffp = &args->sumoff; + ip = mp->m_rsumip; + type = XFS_BLFT_RTSUMMARY_BUF; + } else { + cbpp = &args->rbmbp; + coffp = &args->rbmoff; + ip = mp->m_rbmip; + type = XFS_BLFT_RTBITMAP_BUF; + } + + /* + * If we have a cached buffer, and the block number matches, use that. + */ + if (*cbpp && *coffp == block) { + *bpp = *cbpp; + return 0; + } + /* + * Otherwise we have to have to get the buffer. If there was an old + * one, get rid of it first. + */ + if (*cbpp) { + xfs_trans_brelse(args->tp, *cbpp); + *cbpp = NULL; + } error = xfs_bmapi_read(ip, block, 1, &map, &nmap, 0); if (error) @@ -79,9 +125,9 @@ xfs_rtbuf_get( if (error) return error; - xfs_trans_buf_set_type(args->tp, bp, issum ? XFS_BLFT_RTSUMMARY_BUF - : XFS_BLFT_RTBITMAP_BUF); - *bpp = bp; + xfs_trans_buf_set_type(args->tp, bp, type); + *cbpp = *bpp = bp; + *coffp = block; return 0; } @@ -151,7 +197,6 @@ xfs_rtfind_back( /* * Different. Mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i = bit - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -165,7 +210,6 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, --block, 0, &bp); if (error) { return error; @@ -192,7 +236,6 @@ xfs_rtfind_back( /* * Different, mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -206,7 +249,6 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, --block, 0, &bp); if (error) { return error; @@ -234,7 +276,6 @@ xfs_rtfind_back( /* * Different, mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_NBWORD - 1 - XFS_RTHIBIT(wdiff); *rtx = start - i + 1; return 0; @@ -244,7 +285,6 @@ xfs_rtfind_back( /* * No match, return that we scanned the whole area. */ - xfs_trans_brelse(args->tp, bp); *rtx = start - i + 1; return 0; } @@ -314,7 +354,6 @@ xfs_rtfind_forw( /* * Different. Mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i = XFS_RTLOBIT(wdiff) - bit; *rtx = start + i - 1; return 0; @@ -328,7 +367,6 @@ xfs_rtfind_forw( /* * If done with this block, get the previous one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; @@ -355,7 +393,6 @@ xfs_rtfind_forw( /* * Different, mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *rtx = start + i - 1; return 0; @@ -369,7 +406,6 @@ xfs_rtfind_forw( /* * If done with this block, get the next one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; @@ -395,7 +431,6 @@ xfs_rtfind_forw( /* * Different, mark where we are and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *rtx = start + i - 1; return 0; @@ -405,7 +440,6 @@ xfs_rtfind_forw( /* * No match, return that we scanned the whole area. */ - xfs_trans_brelse(args->tp, bp); *rtx = start + i - 1; return 0; } @@ -440,8 +474,6 @@ xfs_rtmodify_summary_int( int log, /* log2 of extent size */ xfs_fileoff_t bbno, /* bitmap block number */ int delta, /* change to make to summary info */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb, /* in/out: summary block number */ xfs_suminfo_t *sum) /* out: summary info for this block */ { struct xfs_mount *mp = args->mp; @@ -459,30 +491,11 @@ xfs_rtmodify_summary_int( * Compute the block number in the summary file. */ sb = xfs_rtsumoffs_to_block(mp, so); - /* - * If we have an old buffer, and the block number matches, use that. - */ - if (*rbpp && *rsb == sb) - bp = *rbpp; - /* - * Otherwise we have to get the buffer. - */ - else { - /* - * If there was an old one, get rid of it first. - */ - if (*rbpp) - xfs_trans_brelse(args->tp, *rbpp); - error = xfs_rtbuf_get(args, sb, 1, &bp); - if (error) { - return error; - } - /* - * Remember this buffer and block for the next call. - */ - *rbpp = bp; - *rsb = sb; - } + + error = xfs_rtbuf_get(args, sb, 1, &bp); + if (error) + return error; + /* * Point to the summary information, modify/log it, and/or copy it out. */ @@ -510,11 +523,9 @@ xfs_rtmodify_summary( struct xfs_rtalloc_args *args, int log, /* log2 of extent size */ xfs_fileoff_t bbno, /* bitmap block number */ - int delta, /* change to make to summary info */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb) /* in/out: summary block number */ + int delta) /* in/out: summary block number */ { - return xfs_rtmodify_summary_int(args, log, bbno, delta, rbpp, rsb, NULL); + return xfs_rtmodify_summary_int(args, log, bbno, delta, NULL); } /* Log rtbitmap block from the word @from to the byte before @next. */ @@ -685,9 +696,7 @@ int xfs_rtfree_range( struct xfs_rtalloc_args *args, xfs_rtxnum_t start, /* starting rtext to free */ - xfs_rtxlen_t len, /* length to free */ - struct xfs_buf **rbpp, /* in/out: summary block buffer */ - xfs_fileoff_t *rsb) /* in/out: summary block number */ + xfs_rtxlen_t len) /* in/out: summary block number */ { struct xfs_mount *mp = args->mp; xfs_rtxnum_t end; /* end of the freed extent */ @@ -716,7 +725,7 @@ xfs_rtfree_range( * Find the next allocated block (end of allocated extent). */ error = xfs_rtfind_forw(args, end, mp->m_sb.sb_rextents - 1, - &postblock); + &postblock); if (error) return error; /* @@ -725,8 +734,8 @@ xfs_rtfree_range( */ if (preblock < start) { error = xfs_rtmodify_summary(args, - XFS_RTBLOCKLOG(start - preblock), - xfs_rtx_to_rbmblock(mp, preblock), -1, rbpp, rsb); + XFS_RTBLOCKLOG(start - preblock), + xfs_rtx_to_rbmblock(mp, preblock), -1); if (error) { return error; } @@ -737,8 +746,8 @@ xfs_rtfree_range( */ if (postblock > end) { error = xfs_rtmodify_summary(args, - XFS_RTBLOCKLOG(postblock - end), - xfs_rtx_to_rbmblock(mp, end + 1), -1, rbpp, rsb); + XFS_RTBLOCKLOG(postblock - end), + xfs_rtx_to_rbmblock(mp, end + 1), -1); if (error) { return error; } @@ -747,10 +756,9 @@ xfs_rtfree_range( * Increment the summary information corresponding to the entire * (new) free extent. */ - error = xfs_rtmodify_summary(args, - XFS_RTBLOCKLOG(postblock + 1 - preblock), - xfs_rtx_to_rbmblock(mp, preblock), 1, rbpp, rsb); - return error; + return xfs_rtmodify_summary(args, + XFS_RTBLOCKLOG(postblock + 1 - preblock), + xfs_rtx_to_rbmblock(mp, preblock), 1); } /* @@ -820,7 +828,6 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(args->tp, bp); i = XFS_RTLOBIT(wdiff) - bit; *new = start + i; *stat = 0; @@ -835,7 +842,6 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; @@ -862,7 +868,6 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *new = start + i; *stat = 0; @@ -877,7 +882,6 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - xfs_trans_brelse(args->tp, bp); error = xfs_rtbuf_get(args, ++block, 0, &bp); if (error) { return error; @@ -903,7 +907,6 @@ xfs_rtcheck_range( /* * Different, compute first wrong bit and return. */ - xfs_trans_brelse(args->tp, bp); i += XFS_RTLOBIT(wdiff); *new = start + i; *stat = 0; @@ -914,7 +917,6 @@ xfs_rtcheck_range( /* * Successful, return. */ - xfs_trans_brelse(args->tp, bp); *new = start + i; *stat = 1; return 0; @@ -959,8 +961,6 @@ xfs_rtfree_extent( .tp = tp, }; int error; - xfs_fsblock_t sb; /* summary file block number */ - struct xfs_buf *sumbp = NULL; /* summary file block buffer */ struct timespec64 atime; ASSERT(mp->m_rbmip->i_itemp != NULL); @@ -973,10 +973,10 @@ xfs_rtfree_extent( /* * Free the range of realtime blocks. */ - error = xfs_rtfree_range(&args, start, len, &sumbp, &sb); - if (error) { - return error; - } + error = xfs_rtfree_range(&args, start, len); + if (error) + goto out; + /* * Mark more blocks free in the superblock. */ @@ -995,7 +995,10 @@ xfs_rtfree_extent( inode_set_atime_to_ts(VFS_I(mp->m_rbmip), atime); xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); } - return 0; + error = 0; +out: + xfs_rtbuf_cache_relse(&args); + return error; } /* @@ -1086,6 +1089,7 @@ xfs_rtalloc_query_range( rtstart = rtend + 1; } + xfs_rtbuf_cache_relse(&args); return error; } @@ -1124,6 +1128,7 @@ xfs_rtalloc_extent_is_free( int error; error = xfs_rtcheck_range(&args, start, len, 1, &end, &matches); + xfs_rtbuf_cache_relse(&args); if (error) return error; diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 025a7efc2..ac8cd1412 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -12,6 +12,12 @@ struct xfs_rtalloc_args { struct xfs_mount *mp; struct xfs_trans *tp; + + struct xfs_buf *rbmbp; /* bitmap block buffer */ + struct xfs_buf *sumbp; /* summary block buffer */ + + xfs_fileoff_t rbmoff; /* bitmap block number */ + xfs_fileoff_t sumoff; /* summary block number */ }; static inline xfs_rtblock_t @@ -289,6 +295,8 @@ typedef int (*xfs_rtalloc_query_range_fn)( void *priv); #ifdef CONFIG_XFS_RT +void xfs_rtbuf_cache_relse(struct xfs_rtalloc_args *args); + int xfs_rtbuf_get(struct xfs_rtalloc_args *args, xfs_fileoff_t block, int issum, struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, @@ -300,13 +308,11 @@ int xfs_rtfind_forw(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, int xfs_rtmodify_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, xfs_rtxlen_t len, int val); int xfs_rtmodify_summary_int(struct xfs_rtalloc_args *args, int log, - xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, - xfs_fileoff_t *rsb, xfs_suminfo_t *sum); + xfs_fileoff_t bbno, int delta, xfs_suminfo_t *sum); int xfs_rtmodify_summary(struct xfs_rtalloc_args *args, int log, - xfs_fileoff_t bbno, int delta, struct xfs_buf **rbpp, - xfs_fileoff_t *rsb); + xfs_fileoff_t bbno, int delta); int xfs_rtfree_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, - xfs_rtxlen_t len, struct xfs_buf **rbpp, xfs_fileoff_t *rsb); + xfs_rtxlen_t len); int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, const struct xfs_rtalloc_rec *low_rec, const struct xfs_rtalloc_rec *high_rec, @@ -346,6 +352,7 @@ unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp, # define xfs_rtalloc_query_range(m,t,l,h,f,p) (-ENOSYS) # define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS) # define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) +# define xfs_rtbuf_cache_relse(a) (0) # define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) static inline xfs_filblks_t xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents) From patchwork Thu Feb 15 12:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558292 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 7DBAA57872 for ; Thu, 15 Feb 2024 12:09:46 +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=1707998986; cv=none; b=Ph4K17sVX0kFCL9l6VgPd6dGkzWMVzgKIUt+GcgWInEB/xH94ym8k/6rDuLmmdR+YqwDRJb6hSVMLAXXFuHZMMEpyjzukzVAVMHuDUVFrrVbRVlnkAfW37KVKyv8epCSV2+Mqx9f+mq0gr3x4gyNiinXKBMHKxKQQtqxnkr+gkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998986; c=relaxed/simple; bh=gxUSt//5D8i/CKRHGXmQHxicDiI6MN5QPutSc2eCIqM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LzDtBDPwqTZrc1qtYf9rqsAtrbOssZ3NJqvyVEazB3zJE/mYnIapwF4nmvpB9PRtVXjHOsKwy66Deew+2a2ZTuRfv/e/PK6EJqYv3TumNh/3gJN1Tbs+1IRtQqHjfHULW7vIc86ZMe0PSfrR9ICAr17/2yCGzMX429lyWRMJIGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z1EZ4JYu; 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="Z1EZ4JYu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF72DC43399 for ; Thu, 15 Feb 2024 12:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998986; bh=gxUSt//5D8i/CKRHGXmQHxicDiI6MN5QPutSc2eCIqM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Z1EZ4JYuswUF5BTD74ZYfBJHvKFinr5QtCaIterB+tZpll66grIrWL9dahrHMcTAk UI4053yd8EbpyuMJTy/w+kmEL/ojrEf5aRniTCONwltTtmWkkccoe1v09OQSNFVFYP GCRoHdf9dauYnrmc/wMYRXYDkQMCRq7uSYe7EmxZs6Q5HbXQPCzxBf97yksadGdibk FQm70sjnv+fHJ6oDTL4W3X/L0zZXuspwdXA9M1OUBQPDOWx0uMdq0M/LwIzFLf6Q2T +tRQrZEL+xPqJWWh2X2kSxM4DWn+LJsAOaf048f3/2dVxNywp8Y32okXPuEv5XOCnR T913cIBdzV9HA== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 29/35] xfs: simplify xfs_rtbuf_get calling conventions Date: Thu, 15 Feb 2024 13:08:41 +0100 Message-ID: <20240215120907.1542854-30-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: 5b1d0ae9753f0654ab56c1e06155b3abf2919d71 Now that xfs_rtalloc_args holds references to the last-read bitmap and summary blocks, we don't need to pass the buffer pointer out of xfs_rtbuf_get. Callers no longer have to xfs_trans_brelse on their own, though they are required to call xfs_rtbuf_cache_relse before the xfs_rtalloc_args goes out of scope. While we're at it, create some trivial helpers so that we don't have to remember if "0" means "bitmap" and "1" means "summary". Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 115 ++++++++++++++++++------------------------ libxfs/xfs_rtbitmap.h | 22 +++++++- 2 files changed, 69 insertions(+), 68 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index e9c70ff88..bc3ce7bce 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -70,8 +70,7 @@ int xfs_rtbuf_get( struct xfs_rtalloc_args *args, xfs_fileoff_t block, /* block number in bitmap or summary */ - int issum, /* is summary not bitmap */ - struct xfs_buf **bpp) /* output: buffer for the block */ + int issum) /* is summary not bitmap */ { struct xfs_mount *mp = args->mp; struct xfs_buf **cbpp; /* cached block buffer */ @@ -98,10 +97,9 @@ xfs_rtbuf_get( /* * If we have a cached buffer, and the block number matches, use that. */ - if (*cbpp && *coffp == block) { - *bpp = *cbpp; + if (*cbpp && *coffp == block) return 0; - } + /* * Otherwise we have to have to get the buffer. If there was an old * one, get rid of it first. @@ -126,7 +124,7 @@ xfs_rtbuf_get( return error; xfs_trans_buf_set_type(args->tp, bp, type); - *cbpp = *bpp = bp; + *cbpp = bp; *coffp = block; return 0; } @@ -145,7 +143,6 @@ xfs_rtfind_back( struct xfs_mount *mp = args->mp; int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ int error; /* error value */ xfs_rtxnum_t firstbit; /* first useful bit in the word */ xfs_rtxnum_t i; /* current bit number rel. to start */ @@ -160,10 +157,9 @@ xfs_rtfind_back( * Compute and read in starting bitmap block for starting block. */ block = xfs_rtx_to_rbmblock(mp, start); - error = xfs_rtbuf_get(args, block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, block); + if (error) return error; - } /* * Get the first word's index & point to it. @@ -175,7 +171,7 @@ xfs_rtfind_back( * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the @@ -210,10 +206,9 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - error = xfs_rtbuf_get(args, --block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, --block); + if (error) return error; - } word = mp->m_blockwsize - 1; } @@ -231,7 +226,7 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. @@ -249,10 +244,9 @@ xfs_rtfind_back( /* * If done with this block, get the previous one. */ - error = xfs_rtbuf_get(args, --block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, --block); + if (error) return error; - } word = mp->m_blockwsize - 1; } @@ -271,7 +265,7 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. @@ -303,7 +297,6 @@ xfs_rtfind_forw( struct xfs_mount *mp = args->mp; int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ int error; xfs_rtxnum_t i; /* current bit number rel. to start */ xfs_rtxnum_t lastbit;/* last useful bit in the word */ @@ -318,10 +311,9 @@ xfs_rtfind_forw( * Compute and read in starting bitmap block for starting block. */ block = xfs_rtx_to_rbmblock(mp, start); - error = xfs_rtbuf_get(args, block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, block); + if (error) return error; - } /* * Get the first word's index & point to it. @@ -333,7 +325,7 @@ xfs_rtfind_forw( * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the @@ -367,10 +359,9 @@ xfs_rtfind_forw( /* * If done with this block, get the previous one. */ - error = xfs_rtbuf_get(args, ++block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, ++block); + if (error) return error; - } word = 0; } @@ -388,7 +379,7 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. @@ -406,10 +397,9 @@ xfs_rtfind_forw( /* * If done with this block, get the next one. */ - error = xfs_rtbuf_get(args, ++block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, ++block); + if (error) return error; - } word = 0; } @@ -426,7 +416,7 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. @@ -477,7 +467,6 @@ xfs_rtmodify_summary_int( xfs_suminfo_t *sum) /* out: summary info for this block */ { struct xfs_mount *mp = args->mp; - struct xfs_buf *bp; /* buffer for the summary block */ int error; xfs_fileoff_t sb; /* summary fsblock */ xfs_rtsumoff_t so; /* index into the summary file */ @@ -492,7 +481,7 @@ xfs_rtmodify_summary_int( */ sb = xfs_rtsumoffs_to_block(mp, so); - error = xfs_rtbuf_get(args, sb, 1, &bp); + error = xfs_rtsummary_read_buf(args, sb); if (error) return error; @@ -501,7 +490,8 @@ xfs_rtmodify_summary_int( */ infoword = xfs_rtsumoffs_to_infoword(mp, so); if (delta) { - xfs_suminfo_t val = xfs_suminfo_add(bp, infoword, delta); + xfs_suminfo_t val = xfs_suminfo_add(args->sumbp, infoword, + delta); if (mp->m_rsum_cache) { if (val == 0 && log == mp->m_rsum_cache[bbno]) @@ -509,11 +499,11 @@ xfs_rtmodify_summary_int( if (val != 0 && log < mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; } - xfs_trans_log_rtsummary(args->tp, bp, infoword); + xfs_trans_log_rtsummary(args->tp, args->sumbp, infoword); if (sum) *sum = val; } else if (sum) { - *sum = xfs_suminfo_get(bp, infoword); + *sum = xfs_suminfo_get(args->sumbp, infoword); } return 0; } @@ -558,7 +548,6 @@ xfs_rtmodify_range( struct xfs_mount *mp = args->mp; int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ int error; int i; /* current bit number rel. to start */ int lastbit; /* last useful bit in word */ @@ -574,10 +563,9 @@ xfs_rtmodify_range( /* * Read the bitmap block, and point to its data. */ - error = xfs_rtbuf_get(args, block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, block); + if (error) return error; - } /* * Compute the starting word's address, and starting bit. @@ -601,12 +589,12 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if (val) incore |= mask; else incore &= ~mask; - xfs_rtbitmap_setword(bp, word, incore); + xfs_rtbitmap_setword(args->rbmbp, word, incore); i = lastbit - bit; /* * Go on to the next block if that's where the next word is @@ -617,12 +605,11 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(args->tp, bp, firstword, + xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, word); - error = xfs_rtbuf_get(args, ++block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, ++block); + if (error) return error; - } firstword = word = 0; } @@ -640,7 +627,7 @@ xfs_rtmodify_range( /* * Set the word value correctly. */ - xfs_rtbitmap_setword(bp, word, val); + xfs_rtbitmap_setword(args->rbmbp, word, val); i += XFS_NBWORD; /* * Go on to the next block if that's where the next word is @@ -651,9 +638,9 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(args->tp, bp, firstword, + xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, word); - error = xfs_rtbuf_get(args, ++block, 0, &bp); + error = xfs_rtbitmap_read_buf(args, ++block); if (error) return error; @@ -672,19 +659,19 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if (val) incore |= mask; else incore &= ~mask; - xfs_rtbitmap_setword(bp, word, incore); + xfs_rtbitmap_setword(args->rbmbp, word, incore); word++; } /* * Log any remaining changed bytes. */ if (word > firstword) - xfs_trans_log_rtbitmap(args->tp, bp, firstword, word); + xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, word); return 0; } @@ -777,7 +764,6 @@ xfs_rtcheck_range( struct xfs_mount *mp = args->mp; int bit; /* bit number in the word */ xfs_fileoff_t block; /* bitmap block number */ - struct xfs_buf *bp; /* buf for the block */ int error; xfs_rtxnum_t i; /* current bit number rel. to start */ xfs_rtxnum_t lastbit; /* last useful bit in word */ @@ -793,10 +779,9 @@ xfs_rtcheck_range( /* * Read the bitmap block. */ - error = xfs_rtbuf_get(args, block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, block); + if (error) return error; - } /* * Compute the starting word's address, and starting bit. @@ -823,7 +808,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. @@ -842,10 +827,9 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - error = xfs_rtbuf_get(args, ++block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, ++block); + if (error) return error; - } word = 0; } @@ -863,7 +847,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = incore ^ val)) { /* * Different, compute first wrong bit and return. @@ -882,10 +866,9 @@ xfs_rtcheck_range( /* * If done with this block, get the next one. */ - error = xfs_rtbuf_get(args, ++block, 0, &bp); - if (error) { + error = xfs_rtbitmap_read_buf(args, ++block); + if (error) return error; - } word = 0; } @@ -902,7 +885,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(bp, word); + incore = xfs_rtbitmap_getword(args->rbmbp, word); if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index ac8cd1412..b5505da7a 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -298,7 +298,24 @@ typedef int (*xfs_rtalloc_query_range_fn)( void xfs_rtbuf_cache_relse(struct xfs_rtalloc_args *args); int xfs_rtbuf_get(struct xfs_rtalloc_args *args, xfs_fileoff_t block, - int issum, struct xfs_buf **bpp); + int issum); + +static inline int +xfs_rtbitmap_read_buf( + struct xfs_rtalloc_args *args, + xfs_fileoff_t block) +{ + return xfs_rtbuf_get(args, block, 0); +} + +static inline int +xfs_rtsummary_read_buf( + struct xfs_rtalloc_args *args, + xfs_fileoff_t block) +{ + return xfs_rtbuf_get(args, block, 1); +} + int xfs_rtcheck_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, xfs_rtxlen_t len, int val, xfs_rtxnum_t *new, int *stat); int xfs_rtfind_back(struct xfs_rtalloc_args *args, xfs_rtxnum_t start, @@ -351,7 +368,8 @@ unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp, # define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) # define xfs_rtalloc_query_range(m,t,l,h,f,p) (-ENOSYS) # define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS) -# define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) +# define xfs_rtbitmap_read_buf(a,b) (-ENOSYS) +# 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) static inline xfs_filblks_t From patchwork Thu Feb 15 12:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558293 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 20E1212BF3D for ; Thu, 15 Feb 2024 12:09:47 +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=1707998988; cv=none; b=JqivAREqXMeCB7R0/pO04r5UG+VO4Ta02173M/tFKRz9NZEA3Aoqw6dQrk+YzQacWMeBTSSwwT3fOmlbUygiYYTvcS8VZrlNCQzTt+n1D4MMtBCd8w2/AEqwcs5oC4xvuZNMDAziv2JbOM4wJ/wGO2fBa2DiF+hEvt3CdjACQV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998988; c=relaxed/simple; bh=OzlZIYmL9LsNFiOGzKu9Cs/L6LMBKv8mToJm2XKDYro=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R2qMBhnT8XR3pV4BVqU0qdF5qK8xvsfVp5S2ntISHe1dUSEw6WssbDdT9OLuAZmLlCi3jVq25yg6EyzUuUDn79bj9Sg3dKY5wXfg7HBcyAJi35TRm8DhokcggA3ftSUcCanAJnsqM+SorD82LB/D03+MJEMN5LijnzN3WR8asQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TdxkiUMS; 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="TdxkiUMS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D371FC433C7 for ; Thu, 15 Feb 2024 12:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998987; bh=OzlZIYmL9LsNFiOGzKu9Cs/L6LMBKv8mToJm2XKDYro=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TdxkiUMSrIaCBcj2ZKlxbFSpHFyOAvG+vnVSGGusNg1l2kmnE24N29bx1zWZ6vk36 UrJZtuhQq6P8MyMsOzAHzy8VeqCxDot0MmCETWtcJwXDi6T4yB6+HsrE5+zxA+Qj+h VvKgF98FM2xU/FFEwkWQadrhGZFPo69puikwDQbvYbURfOI2odOOoCsF2GjZznICYo bTArC8ZgUM2lQPMmbHNF9VcQmLRLvyaHCQtD0twprjqsLOVYEr1NkMg5bPnXee1kc0 4aLiaGYRY6I0SZXbgVuZur/PdoFPCi3mFEOaEyTQAFOTdU9ApNDRrlCgRnbAJzVLEN cyvvHNTHsn5rQ== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 30/35] xfs: simplify rt bitmap/summary block accessor functions Date: Thu, 15 Feb 2024 13:08:42 +0100 Message-ID: <20240215120907.1542854-31-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-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: e2cf427c91494ea0d1173a911090c39665c5fdef Simplify the calling convention of these functions since the xfs_rtalloc_args structure contains the parameters we need. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 61 ++++++++++++++++++++----------------------- libxfs/xfs_rtbitmap.h | 24 ++++++++--------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index bc3ce7bce..f5d7e14ab 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -171,7 +171,7 @@ xfs_rtfind_back( * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the @@ -226,7 +226,7 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. @@ -265,7 +265,7 @@ xfs_rtfind_back( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. @@ -325,7 +325,7 @@ xfs_rtfind_forw( * Compute match value, based on the bit at start: if 1 (free) * then all-ones, else all-zeroes. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0; /* * If the starting position is not word-aligned, deal with the @@ -379,7 +379,7 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = incore ^ want)) { /* * Different, mark where we are and return. @@ -416,7 +416,7 @@ xfs_rtfind_forw( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = (incore ^ want) & mask)) { /* * Different, mark where we are and return. @@ -437,16 +437,16 @@ xfs_rtfind_forw( /* Log rtsummary counter at @infoword. */ static inline void xfs_trans_log_rtsummary( - struct xfs_trans *tp, - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int infoword) { + struct xfs_buf *bp = args->sumbp; size_t first, last; - first = (void *)xfs_rsumblock_infoptr(bp, infoword) - bp->b_addr; + first = (void *)xfs_rsumblock_infoptr(args, infoword) - bp->b_addr; last = first + sizeof(xfs_suminfo_t) - 1; - xfs_trans_log_buf(tp, bp, first, last); + xfs_trans_log_buf(args->tp, bp, first, last); } /* @@ -490,8 +490,7 @@ xfs_rtmodify_summary_int( */ infoword = xfs_rtsumoffs_to_infoword(mp, so); if (delta) { - xfs_suminfo_t val = xfs_suminfo_add(args->sumbp, infoword, - delta); + xfs_suminfo_t val = xfs_suminfo_add(args, infoword, delta); if (mp->m_rsum_cache) { if (val == 0 && log == mp->m_rsum_cache[bbno]) @@ -499,11 +498,11 @@ xfs_rtmodify_summary_int( if (val != 0 && log < mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; } - xfs_trans_log_rtsummary(args->tp, args->sumbp, infoword); + xfs_trans_log_rtsummary(args, infoword); if (sum) *sum = val; } else if (sum) { - *sum = xfs_suminfo_get(args->sumbp, infoword); + *sum = xfs_suminfo_get(args, infoword); } return 0; } @@ -521,17 +520,17 @@ xfs_rtmodify_summary( /* Log rtbitmap block from the word @from to the byte before @next. */ static inline void xfs_trans_log_rtbitmap( - struct xfs_trans *tp, - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int from, unsigned int next) { + struct xfs_buf *bp = args->rbmbp; size_t first, last; - first = (void *)xfs_rbmblock_wordptr(bp, from) - bp->b_addr; - last = ((void *)xfs_rbmblock_wordptr(bp, next) - 1) - bp->b_addr; + first = (void *)xfs_rbmblock_wordptr(args, from) - bp->b_addr; + last = ((void *)xfs_rbmblock_wordptr(args, next) - 1) - bp->b_addr; - xfs_trans_log_buf(tp, bp, first, last); + xfs_trans_log_buf(args->tp, bp, first, last); } /* @@ -589,12 +588,12 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if (val) incore |= mask; else incore &= ~mask; - xfs_rtbitmap_setword(args->rbmbp, word, incore); + xfs_rtbitmap_setword(args, word, incore); i = lastbit - bit; /* * Go on to the next block if that's where the next word is @@ -605,8 +604,7 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, - word); + xfs_trans_log_rtbitmap(args, firstword, word); error = xfs_rtbitmap_read_buf(args, ++block); if (error) return error; @@ -627,7 +625,7 @@ xfs_rtmodify_range( /* * Set the word value correctly. */ - xfs_rtbitmap_setword(args->rbmbp, word, val); + xfs_rtbitmap_setword(args, word, val); i += XFS_NBWORD; /* * Go on to the next block if that's where the next word is @@ -638,8 +636,7 @@ xfs_rtmodify_range( * Log the changed part of this block. * Get the next one. */ - xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, - word); + xfs_trans_log_rtbitmap(args, firstword, word); error = xfs_rtbitmap_read_buf(args, ++block); if (error) return error; @@ -659,19 +656,19 @@ xfs_rtmodify_range( /* * Set/clear the active bits. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if (val) incore |= mask; else incore &= ~mask; - xfs_rtbitmap_setword(args->rbmbp, word, incore); + xfs_rtbitmap_setword(args, word, incore); word++; } /* * Log any remaining changed bytes. */ if (word > firstword) - xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, word); + xfs_trans_log_rtbitmap(args, firstword, word); return 0; } @@ -808,7 +805,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. @@ -847,7 +844,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = incore ^ val)) { /* * Different, compute first wrong bit and return. @@ -885,7 +882,7 @@ xfs_rtcheck_range( /* * Compute difference between actual and desired value. */ - incore = xfs_rtbitmap_getword(args->rbmbp, word); + incore = xfs_rtbitmap_getword(args, word); if ((wdiff = (incore ^ val) & mask)) { /* * Different, compute first wrong bit and return. diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index b5505da7a..db2f8c924 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -175,10 +175,10 @@ xfs_rbmblock_to_rtx( /* Return a pointer to a bitmap word within a rt bitmap block. */ static inline union xfs_rtword_raw * xfs_rbmblock_wordptr( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index) { - union xfs_rtword_raw *words = bp->b_addr; + union xfs_rtword_raw *words = args->rbmbp->b_addr; return words + index; } @@ -186,10 +186,10 @@ xfs_rbmblock_wordptr( /* Convert an ondisk bitmap word to its incore representation. */ static inline xfs_rtword_t xfs_rtbitmap_getword( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index) { - union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index); + union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index); return word->old; } @@ -197,11 +197,11 @@ xfs_rtbitmap_getword( /* Set an ondisk bitmap word from an incore representation. */ static inline void xfs_rtbitmap_setword( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index, xfs_rtword_t value) { - union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index); + union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index); word->old = value; } @@ -248,10 +248,10 @@ xfs_rtsumoffs_to_infoword( /* Return a pointer to a summary info word within a rt summary block. */ static inline union xfs_suminfo_raw * xfs_rsumblock_infoptr( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index) { - union xfs_suminfo_raw *info = bp->b_addr; + union xfs_suminfo_raw *info = args->sumbp->b_addr; return info + index; } @@ -259,10 +259,10 @@ xfs_rsumblock_infoptr( /* Get the current value of a summary counter. */ static inline xfs_suminfo_t xfs_suminfo_get( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index) { - union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index); + union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index); return info->old; } @@ -270,11 +270,11 @@ xfs_suminfo_get( /* Add to the current value of a summary counter and return the new value. */ static inline xfs_suminfo_t xfs_suminfo_add( - struct xfs_buf *bp, + struct xfs_rtalloc_args *args, unsigned int index, int delta) { - union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index); + union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index); info->old += delta; return info->old; From patchwork Thu Feb 15 12:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558294 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 BE52712BF3D for ; Thu, 15 Feb 2024 12:09:48 +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=1707998988; cv=none; b=BhaAzNPAGv3WmX/K16GR2mtr9VKxkib4ZZXWp/Y74q+A5gZzX+uQIfjyRVAkDoO/SKObqPC8UBMPsKMi/amuauoBiX1PdDWJMMXPdgqpGN0jAzAcs95KtCPjODeiEvlc6+bXoV9qP9uoF2mthBdhvGxmv8e8PQnNyCubIF4poGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998988; c=relaxed/simple; bh=RBb03EdagAhI/bHRj44FCDnhVADWmsEHQUtoLfdQNSw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qI0uRubwpaRTGBaS/WqRdkKJSpqZsVAowH4DnUgfJReq0mcnbyqS+w31PKg5OI/BEacuJYKsgUnrWzknRFTgc0KrHmKDZr5jEfaGiaM5WcM3ZMHMdFlny430YcUazEOdCHLqqezX7H+4G7rVwqkvCANwQ5C6cI5hjNqWSkGcumY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f5VHn3kq; 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="f5VHn3kq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F42BC433F1 for ; Thu, 15 Feb 2024 12:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998988; bh=RBb03EdagAhI/bHRj44FCDnhVADWmsEHQUtoLfdQNSw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f5VHn3kqgnmdPSumS2DRgO1+JybWzT7TFO3xpds99ku8PwAbtNReJhZCn77pc0Th3 G3EVGWiC35fJwy8LnkCGHeEmWHgxg705E8tXNbjSVp6KMFA/G1QVIh58sadKh+dAm8 EaG2gjO1cXIKCsbkC2Axq79zz4Z/+LZFubvlROh6jZ+T8azbhT2/7ft+YQ99DhKAEu 0lQwLif6Qg5gBWUczhf/Gh17VpTG1hyf0RLNemLejqUHiYs6ADRiNdRZKE5xA8zLVM 0klrPC5e1OGWryouIBV5kDGbaxWURK+APiGtOoPTfbOnbLNV3oc1ksbXqV0G6J5isW 9MlKACLC3BTEA== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 31/35] xfs: invert the realtime summary cache Date: Thu, 15 Feb 2024 13:08:43 +0100 Message-ID: <20240215120907.1542854-32-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Omar Sandoval Source kernel commit: e23aaf450de733044a74bc95528f728478b61c2a In commit 355e3532132b ("xfs: cache minimum realtime summary level"), I added a cache of the minimum level of the realtime summary that has any free extents. However, it turns out that the _maximum_ level is more useful for upcoming optimizations, and basically equivalent for the existing usage. So, let's change the meaning of the cache to be the maximum level + 1, or 0 if there are no free extents. For example, if the cache contains: {0, 4} then there are no free extents starting in realtime bitmap block 0, and there are no free extents larger than or equal to 2^4 blocks starting in realtime bitmap block 1. The cache is a loose upper bound, so there may or may not be free extents smaller than 2^4 blocks in realtime bitmap block 1. Signed-off-by: Omar Sandoval Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- libxfs/xfs_rtbitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index f5d7e14ab..8f313339e 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -493,10 +493,10 @@ xfs_rtmodify_summary_int( xfs_suminfo_t val = xfs_suminfo_add(args, infoword, delta); if (mp->m_rsum_cache) { - if (val == 0 && log == mp->m_rsum_cache[bbno]) - mp->m_rsum_cache[bbno]++; - if (val != 0 && log < mp->m_rsum_cache[bbno]) + if (val == 0 && log + 1 == mp->m_rsum_cache[bbno]) mp->m_rsum_cache[bbno] = log; + if (val != 0 && log >= mp->m_rsum_cache[bbno]) + mp->m_rsum_cache[bbno] = log + 1; } xfs_trans_log_rtsummary(args, infoword); if (sum) From patchwork Thu Feb 15 12:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558295 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 DC15912BF3D for ; Thu, 15 Feb 2024 12:09: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=1707998989; cv=none; b=Qi9rrNUKrPHKVAi6LKS/4PnLiZANpZSIC0MobglvnZUSEHZP5CzBDNVd9iykl/t61lpxV/NHzkDwg1HO/fnb4t1rVPqp8uta2eoKGDIvKpZS7JQUaO8dXAGUf8MEkcp6gD86HnRe3yq1iZqFlQUY1UwKgyrSAQUeSmnp9YYvAh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998989; c=relaxed/simple; bh=upNxpAC6a9CxfIzP/Focb5P46yMPD/5h1nRmmHgCHfk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TFSTnIpQ5oG97CY/fHte6HuaYVho+VGuxp1SQS0sPfEmGH0dQ/3H5AdkHilShEG8wnDAWRblm7KxfJeroAuHDloan6UTMi6Nno8un7ng9Pcf+bqMU/FWp9+kS+2G3FHQLKpbCVX1YEJcyJwfOPy4UPIP8Zlb5Wnu2byHY1AjGT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tZCiAowe; 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="tZCiAowe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1498FC433C7 for ; Thu, 15 Feb 2024 12:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998989; bh=upNxpAC6a9CxfIzP/Focb5P46yMPD/5h1nRmmHgCHfk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tZCiAowedXOXg0zvd9trMOwpJsP+gahLsU6ID4PYWttCftReNy0Q1pH4KaCRmKtZq kmftufPSzUg4HSyXUypcfjm05nexbxFdfI2OJInrANT+jhilM+Hc2WIvzO015hg/GC ZzsDhxC1NBevlGHBAikrcDwF7Wtp4U+m4cqbXXYC0WenyCuGBXgkc0dL0HlBqxhqwE sItvv6q8JvH0bwUM0Q2NHtHz8mTJpUrntVYDmVwNQZvM3VuLwWFzqYOODKdbEONCnj mUgbn2QpVny/vWH0biICjImNH5ap4zeVAtwXW3MKxbGG+ozWA51xW2YUzfun9rRSed o4Qn8AmDIe34w== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 32/35] xfs: factor out xfs_defer_pending_abort Date: Thu, 15 Feb 2024 13:08:44 +0100 Message-ID: <20240215120907.1542854-33-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Long Li Source kernel commit: 2a5db859c6825b5d50377dda9c3cc729c20cad43 Factor out xfs_defer_pending_abort() from xfs_defer_trans_abort(), which not use transaction parameter, so it can be used after the transaction life cycle. Signed-off-by: Long Li Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Signed-off-by: Carlos Maiolino --- libxfs/xfs_defer.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 77a94f58f..16060ef88 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -240,21 +240,18 @@ xfs_defer_create_intents( return ret; } -/* Abort all the intents that were committed. */ STATIC void -xfs_defer_trans_abort( - struct xfs_trans *tp, - struct list_head *dop_pending) +xfs_defer_pending_abort( + struct xfs_mount *mp, + struct list_head *dop_list) { struct xfs_defer_pending *dfp; const struct xfs_defer_op_type *ops; - trace_xfs_defer_trans_abort(tp, _RET_IP_); - /* Abort intent items that don't have a done item. */ - list_for_each_entry(dfp, dop_pending, dfp_list) { + list_for_each_entry(dfp, dop_list, dfp_list) { ops = defer_op_types[dfp->dfp_type]; - trace_xfs_defer_pending_abort(tp->t_mountp, dfp); + trace_xfs_defer_pending_abort(mp, dfp); if (dfp->dfp_intent && !dfp->dfp_done) { ops->abort_intent(dfp->dfp_intent); dfp->dfp_intent = NULL; @@ -262,6 +259,16 @@ xfs_defer_trans_abort( } } +/* Abort all the intents that were committed. */ +STATIC void +xfs_defer_trans_abort( + struct xfs_trans *tp, + struct list_head *dop_pending) +{ + trace_xfs_defer_trans_abort(tp, _RET_IP_); + xfs_defer_pending_abort(tp->t_mountp, dop_pending); +} + /* * Capture resources that the caller said not to release ("held") when the * transaction commits. Caller is responsible for zero-initializing @dres. From patchwork Thu Feb 15 12:08:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558296 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 1F8BA12BF12 for ; Thu, 15 Feb 2024 12:09:51 +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=1707998991; cv=none; b=Q6nPZWc3oAa05HCAQ2WoHXy9tQCPfnUxXgw37LsUyCQ27wOMy+R7Fe2hqmQqktzHaYgu9a0+AD9Eqp7e4V+PrBlfnWk2vKiUQ+GTWg0VT2/TEeYn+JhUWBunBVuLxp5Ad+07qV/emQFsqh3fqi3osXaGdPVjkCiKFkoH2qEEJAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998991; c=relaxed/simple; bh=werjl0WBtx1G1eMLbnvqIxKDJ9WZaOHzhv9BJSy7kOU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqeTKFAl1lUfP2QL+G7j8Sem+gynEOJcCCNRwtQvkNzbpbwkZNfiZMw7lGl8hVMJKbZSPBTw3yJsHzc0MZqaCK0H6RjCK3qomxRsMy505e9I0EPPnJqVrV0++xmKnyHrO0ZCUjCWvwkQ5CJtcTvRfSCMchhy2tkz1MwmNDn95kE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ovVQoUMg; 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="ovVQoUMg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33E41C433F1 for ; Thu, 15 Feb 2024 12:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998991; bh=werjl0WBtx1G1eMLbnvqIxKDJ9WZaOHzhv9BJSy7kOU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ovVQoUMgJRSWnascLJZEyyV4chK+Pg4poqwme+tv1QcuuOqT9r15ZNch71lyMs2Zw c2ECsjCO9kK0yQjbHsuTivCUmY5CzB+y8WMm16ujvXpq9EdIeJn1/bwJtEe0adavH4 CkTvK/mXAAlDWZ7e/FeJ1AZReGN21RPf4pmVn11UgM05EMsihqCrUozN9ycPc79aV1 OSzarCOsK6rR1GqemvfIYYVF71B5/qVpc0gywHRb7m1d85ypSLayYYnajmZANOisu0 Y2lgTZZCf8pyNYdo89wBoT2pHYI7X5M3kKJUJcwNSwCBHrAfCBy5bAhcVUvAVe4lrD PuwgKuPScNrDg== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 33/35] xfs: abort intent items when recovery intents fail Date: Thu, 15 Feb 2024 13:08:45 +0100 Message-ID: <20240215120907.1542854-34-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Long Li Source kernel commit: f8f9d952e42dd49ae534f61f2fa7ca0876cb9848 When recovering intents, we capture newly created intent items as part of point, we forget to remove those newly created intent items from the AIL and hang: [root@localhost ~]# cat /proc/539/stack [<0>] xfs_ail_push_all_sync+0x174/0x230 [<0>] xfs_unmount_flush_inodes+0x8d/0xd0 [<0>] xfs_mountfs+0x15f7/0x1e70 [<0>] xfs_fs_fill_super+0x10ec/0x1b20 [<0>] get_tree_bdev+0x3c8/0x730 [<0>] vfs_get_tree+0x89/0x2c0 [<0>] path_mount+0xecf/0x1800 [<0>] do_mount+0xf3/0x110 [<0>] __x64_sys_mount+0x154/0x1f0 [<0>] do_syscall_64+0x39/0x80 [<0>] entry_SYSCALL_64_after_hwframe+0x63/0xcd When newly created intent items fail to commit via transaction, intent recovery hasn't created done items for these newly created intent items, so the capture structure is the sole owner of the captured intent items. We must release them explicitly or else they leak: unreferenced object 0xffff888016719108 (size 432): comm "mount", pid 529, jiffies 4294706839 (age 144.463s) hex dump (first 32 bytes): 08 91 71 16 80 88 ff ff 08 91 71 16 80 88 ff ff ..q.......q..... 18 91 71 16 80 88 ff ff 18 91 71 16 80 88 ff ff ..q.......q..... backtrace: [] xfs_efi_init+0x18f/0x1d0 [] xfs_extent_free_create_intent+0x50/0x150 [] xfs_defer_create_intents+0x16a/0x340 [] xfs_defer_ops_capture_and_commit+0x8e/0xad0 [] xfs_cui_item_recover+0x819/0x980 [] xlog_recover_process_intents+0x246/0xb70 [] xlog_recover_finish+0x8a/0x9a0 [] xfs_log_mount_finish+0x2bb/0x4a0 [] xfs_mountfs+0x14bf/0x1e70 [] xfs_fs_fill_super+0x10d0/0x1b20 [] get_tree_bdev+0x3d2/0x6d0 [] vfs_get_tree+0x89/0x2c0 [] path_mount+0xecf/0x1800 [] do_mount+0xf3/0x110 [] __x64_sys_mount+0x154/0x1f0 [] do_syscall_64+0x39/0x80 Fix the problem above by abort intent items that don't have a done item when recovery intents fail. Fixes: e6fff81e4870 ("xfs: proper replay of deferred ops queued during log recovery") Signed-off-by: Long Li Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Signed-off-by: Carlos Maiolino --- libxfs/xfs_defer.c | 5 +++-- libxfs/xfs_defer.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 16060ef88..7ff125c5f 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -758,12 +758,13 @@ xfs_defer_ops_capture( /* Release all resources that we used to capture deferred ops. */ void -xfs_defer_ops_capture_free( +xfs_defer_ops_capture_abort( struct xfs_mount *mp, struct xfs_defer_capture *dfc) { unsigned short i; + xfs_defer_pending_abort(mp, &dfc->dfc_dfops); xfs_defer_cancel_list(mp, &dfc->dfc_dfops); for (i = 0; i < dfc->dfc_held.dr_bufs; i++) @@ -804,7 +805,7 @@ xfs_defer_ops_capture_and_commit( /* Commit the transaction and add the capture structure to the list. */ error = xfs_trans_commit(tp); if (error) { - xfs_defer_ops_capture_free(mp, dfc); + xfs_defer_ops_capture_abort(mp, dfc); return error; } diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 114a3a493..8788ad5f6 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -121,7 +121,7 @@ int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, struct list_head *capture_list); void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, struct xfs_defer_resources *dres); -void xfs_defer_ops_capture_free(struct xfs_mount *mp, +void xfs_defer_ops_capture_abort(struct xfs_mount *mp, struct xfs_defer_capture *d); void xfs_defer_resources_rele(struct xfs_defer_resources *dres); From patchwork Thu Feb 15 12:08:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558297 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 2214212BF0A for ; Thu, 15 Feb 2024 12:09:52 +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=1707998992; cv=none; b=FGnP87UibS9U7qDXqnjiPTfSug64CC3eEQU0LPB7d3ily1fMD5w5K5PMJtmAt3kxmJ/Q6eNCV+ysr231au4jaq6GyGTTrqWCF0vfxX2mwJ5zc/7tTsKN+pdFxeTYfvi61pgnN8k9kS/miXSrYc10tndlZ4VjcqQrMM2wIz9uX4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998992; c=relaxed/simple; bh=3rnLT1Ahuz/kvVWZz9pzrW828ZRP4WMTH7uYl/ELZOg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BTaiXmlTGFsyql7B57CMbcz7gA/nQ3IGCP60ODlahw7DjsAbo5YaTbEhQhF+4CzskWjC9eFTPkeFT8RyRRXqCvO0iOhugb8IUffl9hvEf0VC3Vv9Gq4iQFvAVdx8DoU4B1oqKgjbAEFZejOIhly/SeiGu45osrAz19V1cu4XNnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UeS1kfSq; 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="UeS1kfSq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EFDCC433C7 for ; Thu, 15 Feb 2024 12:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998992; bh=3rnLT1Ahuz/kvVWZz9pzrW828ZRP4WMTH7uYl/ELZOg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UeS1kfSqafcLQEEQSEWohDcgs+Ucf+a9ViYFCX2qtD7cYrMgaGSHvG/RgR9/b8VOH EJZCmMHOZnXuOp8Pa3wO8Sarma+NJc6lMVAcrs9quiO6Z//1zN75m2H/uhaowuFBAs FRA45fCb4zJR4Yoe3cWSvp6k98sJFdn5QL9kLpjItfJSn3eEHP54Q7Vm8mKYsY+Ws3 CWdN8uDe4G0+k2KPOAzgmxSOBnf0x0mPjZVCFozhHN45VEOXswqtlbzK0TLpApgxl6 sOABSiegpgqvjYar45N5q5VcWhDcR6E9iPMlkyT0XL1cCp0uZjNkRkIjP/y+FSmrnI XUPcMf6LM0Q8Q== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 34/35] xfs: fix internal error from AGFL exhaustion Date: Thu, 15 Feb 2024 13:08:46 +0100 Message-ID: <20240215120907.1542854-35-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Omar Sandoval Source kernel commit: f63a5b3769ad7659da4c0420751d78958ab97675 We've been seeing XFS errors like the following: XFS: Internal error i != 1 at line 3526 of file fs/xfs/libxfs/xfs_btree.c. Caller xfs_btree_insert+0x1ec/0x280 ... Call Trace: xfs_corruption_error+0x94/0xa0 xfs_btree_insert+0x221/0x280 xfs_alloc_fixup_trees+0x104/0x3e0 xfs_alloc_ag_vextent_size+0x667/0x820 xfs_alloc_fix_freelist+0x5d9/0x750 xfs_free_extent_fix_freelist+0x65/0xa0 __xfs_free_extent+0x57/0x180 ... This is the XFS_IS_CORRUPT() check in xfs_btree_insert() when xfs_btree_insrec() fails. After converting this into a panic and dissecting the core dump, I found that xfs_btree_insrec() is failing because it's trying to split a leaf node in the cntbt when the AG free list is empty. In particular, it's failing to get a block from the AGFL _while trying to refill the AGFL_. If a single operation splits every level of the bnobt and the cntbt (and the rmapbt if it is enabled) at once, the free list will be empty. Then, when the next operation tries to refill the free list, it allocates space. If the allocation does not use a full extent, it will need to insert records for the remaining space in the bnobt and cntbt. And if those new records go in full leaves, the leaves (and potentially more nodes up to the old root) need to be split. Fix it by accounting for the additional splits that may be required to refill the free list in the calculation for the minimum free list size. P.S. As far as I can tell, this bug has existed for a long time -- maybe back to xfs-history commit afdf80ae7405 ("Add XFS_AG_MAXLEVELS macros ...") in April 1994! It requires a very unlucky sequence of events, and in fact we didn't hit it until a particular sparse mmap workload updated from 5.12 to 5.19. But this bug existed in 5.12, so it must've been exposed by some other change in allocation or writeback patterns. It's also much less likely to be hit with the rmapbt enabled, since that increases the minimum free list size and is unlikely to split at the same time as the bnobt and cntbt. Reviewed-by: "Darrick J. Wong" Reviewed-by: Dave Chinner Signed-off-by: Omar Sandoval Signed-off-by: Chandan Babu R Signed-off-by: Carlos Maiolino --- libxfs/xfs_alloc.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 4519a0555..7ac7c2f6c 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -2271,16 +2271,37 @@ xfs_alloc_min_freelist( ASSERT(mp->m_alloc_maxlevels > 0); + /* + * For a btree shorter than the maximum height, the worst case is that + * every level gets split and a new level is added, then while inserting + * another entry to refill the AGFL, every level under the old root gets + * split again. This is: + * + * (full height split reservation) + (AGFL refill split height) + * = (current height + 1) + (current height - 1) + * = (new height) + (new height - 2) + * = 2 * new height - 2 + * + * For a btree of maximum height, the worst case is that every level + * under the root gets split, then while inserting another entry to + * refill the AGFL, every level under the root gets split again. This is + * also: + * + * 2 * (current height - 1) + * = 2 * (new height - 1) + * = 2 * new height - 2 + */ + /* space needed by-bno freespace btree */ min_free = min_t(unsigned int, levels[XFS_BTNUM_BNOi] + 1, - mp->m_alloc_maxlevels); + mp->m_alloc_maxlevels) * 2 - 2; /* space needed by-size freespace btree */ min_free += min_t(unsigned int, levels[XFS_BTNUM_CNTi] + 1, - mp->m_alloc_maxlevels); + mp->m_alloc_maxlevels) * 2 - 2; /* space needed reverse mapping used space btree */ if (xfs_has_rmapbt(mp)) min_free += min_t(unsigned int, levels[XFS_BTNUM_RMAPi] + 1, - mp->m_rmap_maxlevels); + mp->m_rmap_maxlevels) * 2 - 2; return min_free; } From patchwork Thu Feb 15 12:08:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13558298 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 2A12912BF0A for ; Thu, 15 Feb 2024 12:09:53 +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=1707998993; cv=none; b=tswqdjE5OA1p7rCOItUY9BiRVbyGsLGfPGjkyhmCE36bH7HUnMCh+SbHA93AP/ehegpkF3sxaeMyKo4U2yzsXP8y6pa9sscdQssd3hLCtaOs/KEb0JTvMa/IEQ85clBiRucUTLzNX7SM450/ip2l08LsuBjZOHoWaoVv3UON7Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707998993; c=relaxed/simple; bh=IN5irApq31LsjPtg7aXGWkdUpdoADnJdoNPN4bcSQd0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZ9NpuOFFL99Er89fMNGzXYdQB85Zi5tawQlkdkIXQ7XzQa3d13wG0UCzSt2j4n8GN48Yx4NMaynCHUBHym8GBqulaqildO/58WDgup+t6y5tNzv01GEB+b+2xk2QNpL52VEb6sEdZJR2B5Y8QrM7vty4B3n1pEwF5nDwk8VFKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kY+fYMOy; 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="kY+fYMOy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71822C433C7 for ; Thu, 15 Feb 2024 12:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707998993; bh=IN5irApq31LsjPtg7aXGWkdUpdoADnJdoNPN4bcSQd0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kY+fYMOyoPsfd2Ql5kErQc/Aq+VLBu1QRedQXK0z/ldgtyCJ9+mFKpf9AsNuUfFJb AxmuylDckBRVxUKmOIkcrVJpAsE/L0LNWmLQ3FLpYzCHZY5f/knUwEv2JtQqT5gtNf J87hpaTv+X2SDzb7/DTf1j2YVlL8gZSC8ilv+BoGr0g/JIYJQMUF4o5XEbua7FUZ98 4k2a27e+T+/MmcGDMUeYqYX7HHuA32Rrei9pSh36xBjj6sLEz+5/2n+Xdhh2o1qwzn J4A30xn3hWeJ1stRhyHoNECNin2AQ5w6mxEDxGh9YMucCvfJs0Tg2WNiChenNekBEf OSxehyuZ6oX4A== From: cem@kernel.org To: linux-xfs@vger.kernel.org Subject: [PATCH 35/35] xfs: inode recovery does not validate the recovered inode Date: Thu, 15 Feb 2024 13:08:47 +0100 Message-ID: <20240215120907.1542854-36-cem@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215120907.1542854-1-cem@kernel.org> References: <20240215120907.1542854-1-cem@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Dave Chinner Source kernel commit: 038ca189c0d2c1570b4d922f25b524007c85cf94 Discovered when trying to track down a weird recovery corruption issue that wasn't detected at recovery time. The specific corruption was a zero extent count field when big extent counts are in use, and it turns out the dinode verifier doesn't detect that specific corruption case, either. So fix it too. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Carlos Maiolino --- libxfs/xfs_inode_buf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 74a1bd227..fd351c252 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -507,6 +507,9 @@ xfs_dinode_verify( if (mode && nextents + naextents > nblocks) return __this_address; + if (nextents + naextents == 0 && nblocks != 0) + return __this_address; + if (S_ISDIR(mode) && nextents > mp->m_dir_geo->max_extents) return __this_address;