]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: create routine to allocate and initialize a realtime refcount btree inode
authorDarrick J. Wong <djwong@kernel.org>
Fri, 9 Aug 2024 13:16:03 +0000 (15:16 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 12 Aug 2024 11:53:07 +0000 (13:53 +0200)
Create a library routine to allocate and initialize an empty realtime
refcountbt inode.  We'll use this for growfs, mkfs, and repair.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_rtgroup.c
fs/xfs/libxfs/xfs_rtrefcount_btree.c
fs/xfs/libxfs/xfs_rtrefcount_btree.h

index 9c6997b432d2c9e015458a678386cffcbb2a88c2..51fd11e4a79e425eaa366a27f6d8d728362c3581 100644 (file)
@@ -34,6 +34,7 @@
 #include "xfs_metafile.h"
 #include "xfs_metadir.h"
 #include "xfs_rtrmap_btree.h"
+#include "xfs_rtrefcount_btree.h"
 
 /*
  * Passive reference counting access wrappers to the rtgroup structures.  If
@@ -422,6 +423,7 @@ static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTG_MAX] = {
                .metafile_type  = XFS_METAFILE_RTREFCOUNT,
                .format         = XFS_DINODE_FMT_REFCOUNT,
                .enabled        = xfs_has_rtreflink,
+               .create         = xfs_rtrefcountbt_create,
        },
 };
 
index c04291b7ac997d8ff26ac3e4fd14c8dc06e31429..f753c6630d60aad5fe19d42df08ed876a8739681 100644 (file)
@@ -699,3 +699,28 @@ xfs_iflush_rtrefcount(
                        ifp->if_broot_bytes, dfp,
                        XFS_DFORK_SIZE(dip, ip->i_mount, XFS_DATA_FORK));
 }
+
+/*
+ * Create a realtime refcount btree inode.
+ */
+int
+xfs_rtrefcountbt_create(
+       struct xfs_rtgroup      *rtg,
+       struct xfs_inode        *ip,
+       struct xfs_trans        *tp,
+       bool                    init)
+{
+       struct xfs_ifork        *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
+
+       ifp->if_format = XFS_DINODE_FMT_REFCOUNT;
+       ASSERT(ifp->if_broot_bytes == 0);
+       ASSERT(ifp->if_bytes == 0);
+
+       /* Initialize the empty incore btree root. */
+       xfs_iroot_alloc(ip, XFS_DATA_FORK,
+                       xfs_rtrefcount_broot_space_calc(ip->i_mount, 0, 0));
+       xfs_btree_init_block(ip->i_mount, ifp->if_broot, &xfs_rtrefcountbt_ops,
+                       0, 0, ip->i_ino);
+       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE | XFS_ILOG_DBROOT);
+       return 0;
+}
index 3e587ca765e17988689d357fd44ba57039f90457..484bd2b091a3084f3b5a343220140e04784710c6 100644 (file)
@@ -184,4 +184,7 @@ void xfs_rtrefcountbt_to_disk(struct xfs_mount *mp,
                struct xfs_rtrefcount_root *dblock, int dblocklen);
 void xfs_iflush_rtrefcount(struct xfs_inode *ip, struct xfs_dinode *dip);
 
+int xfs_rtrefcountbt_create(struct xfs_rtgroup *rtg, struct xfs_inode *ip,
+               struct xfs_trans *tp, bool init);
+
 #endif /* __XFS_RTREFCOUNT_BTREE_H__ */