xfs: introduce fake roots for inode-rooted btrees

Create an in-core fake root for inode-rooted btree types so that callers
can generate a whole new btree using the upcoming btree bulk load
function without making the new tree accessible from the rest of the
filesystem.  It is up to the individual btree type to provide a function
to create a staged cursor (presumably with the appropriate callouts to
update the fakeroot) and then commit the staged root back into the
filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
Darrick J. Wong
2020-03-11 10:42:34 -07:00
parent e06536a692
commit 349e1c0380
5 changed files with 160 additions and 2 deletions

View File

@@ -645,6 +645,17 @@ xfs_btree_ptr_addr(
((char *)block + xfs_btree_ptr_offset(cur, n, level));
}
struct xfs_ifork *
xfs_btree_ifork_ptr(
struct xfs_btree_cur *cur)
{
ASSERT(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE);
if (cur->bc_flags & XFS_BTREE_STAGING)
return cur->bc_ino.ifake->if_fork;
return XFS_IFORK_PTR(cur->bc_ino.ip, cur->bc_ino.whichfork);
}
/*
* Get the root block which is stored in the inode.
*
@@ -655,9 +666,8 @@ STATIC struct xfs_btree_block *
xfs_btree_get_iroot(
struct xfs_btree_cur *cur)
{
struct xfs_ifork *ifp;
struct xfs_ifork *ifp = xfs_btree_ifork_ptr(cur);
ifp = XFS_IFORK_PTR(cur->bc_ino.ip, cur->bc_ino.whichfork);
return (struct xfs_btree_block *)ifp->if_broot;
}