summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_rtbitmap.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-10-16 09:51:16 -0700
committerDarrick J. Wong <djwong@kernel.org>2023-10-18 16:53:00 -0700
commit663b8db7b0256b81152b2f786e45ecf12bdf265f (patch)
treeeef619bc233dbe4eb8d796a0fca9a5573210faf3 /fs/xfs/libxfs/xfs_rtbitmap.h
parentbd85af280de66a946022775a876edf0c553e3f35 (diff)
xfs: use accessor functions for summary info wordsrefactor-rtbitmap-accessors-6.7_2023-10-19
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 <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/libxfs/xfs_rtbitmap.h')
-rw-r--r--fs/xfs/libxfs/xfs_rtbitmap.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h
index a3e8288bedea..fdfa98e0ee52 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.h
+++ b/fs/xfs/libxfs/xfs_rtbitmap.h
@@ -232,16 +232,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.
*/