set_inode_isadir(irec, ino_offset);
}
-static struct xfs_inode *
+static bool
ensure_rtgroup_file(
struct xfs_rtgroup *rtg,
- enum xfs_rtg_inodes type,
- const char *name,
- int (*create)(struct xfs_rtgroup *rtg,
- struct xfs_inode *ip,
- struct xfs_trans *tp,
- bool init))
+ enum xfs_rtg_inodes type)
{
struct xfs_mount *mp = rtg->rtg_mount;
struct xfs_inode *ip = rtg->rtg_inodes[type];
- struct xfs_imeta_update upd = { };
- const char *path;
+ const char *name = xfs_rtginode_name(type);
int error;
+ if (!xfs_rtginode_enabled(rtg, type))
+ return false;
+
if (no_modify) {
if (!ip)
- do_warn(_("would reset rtgroup %u %s btree\n"),
+ do_warn(_("would reset rtgroup %u %s inode\n"),
rtg->rtg_rgno, name);
- return NULL;
+ return false;
}
- path = xfs_rtginode_path(rtg->rtg_rgno, type);
- if (!path)
- do_error(
+ if (ip) {
+ struct xfs_imeta_update upd = { };
+ const char *path;
+
+ path = xfs_rtginode_path(rtg->rtg_rgno, type);
+ if (!path)
+ do_error(
_("Couldn't create rtgroup %u %s file path\n"),
- rtg->rtg_rgno, name);
+ rtg->rtg_rgno, name);
- if (ip) {
/*
* Since we're reattaching this file to the metadata directory
* tree, try to remove all the parent pointers that might be
/* Reset the link count to something sane. */
set_nlink(VFS_I(ip), 1);
libxfs_trans_log_inode(upd.tp, ip, XFS_ILOG_CORE);
+
+ error = -libxfs_imeta_commit(&upd);
+ if (error)
+ do_error(
+ _("Couldn't commit new rtgroup %u %s inode %llu, error %d\n"),
+ rtg->rtg_rgno, name,
+ (unsigned long long)upd.ip->i_ino,
+ error);
+ kfree(path);
} else {
/*
* The inode was bad or gone, so just make a new one and give
* our reference to the rtgroup structure.
*/
- do_warn(_("resetting rtgroup %u %s btree\n"),
+ do_warn(_("resetting rtgroup %u %s inode\n"),
rtg->rtg_rgno, name);
- error = -libxfs_imeta_start_create(mp->m_rtdirip, path, &upd);
- if (error)
- do_error(
- _("Couldn't grab resources to recreate rtgroup %u %s, error %d\n"),
- rtg->rtg_rgno, name, error);
-
- error = -xfs_imeta_create(&upd, S_IFREG);
+ error = -xfs_rtginode_create(rtg, type, false);
if (error)
do_error(
_("Couldn't create rtgroup %u %s inode, error %d\n"),
rtg->rtg_rgno, name, error);
- error = -create(rtg, upd.ip, upd.tp, false);
- if (error)
- do_error(
- _("Couldn't create rtgroup %u %s inode, error %d\n"),
- rtg->rtg_rgno, name, error);
+ ip = rtg->rtg_inodes[type];
}
/* Mark the inode in use. */
- mark_ino_inuse(mp, upd.ip->i_ino, S_IFREG, upd.dp->i_ino);
- mark_ino_metadata(mp, upd.ip->i_ino);
-
- error = -libxfs_imeta_commit(&upd);
- if (error)
- do_error(
- _("Couldn't commit new rtgroup %u %s inode %llu, error %d\n"),
- rtg->rtg_rgno, name, (unsigned long long)upd.ip->i_ino,
- error);
-
- kfree(path);
- return upd.ip;
+ mark_ino_inuse(mp, ip->i_ino, S_IFREG, mp->m_rtdirip->i_ino);
+ mark_ino_metadata(mp, ip->i_ino);
+ return true;
}
static void
struct xfs_rtgroup *rtg,
xfs_filblks_t est_fdblocks)
{
- struct xfs_inode *ip;
-
- if (!xfs_has_rtrmapbt(rtg->rtg_mount))
- return;
-
- ip = ensure_rtgroup_file(rtg, XFS_RTG_RMAP, "rmap",
- libxfs_rtrmapbt_create);
- if (ip) {
- populate_rtgroup_rmapbt(rtg, ip, est_fdblocks);
- libxfs_irele(ip);
- }
+ if (ensure_rtgroup_file(rtg, XFS_RTG_RMAP))
+ populate_rtgroup_rmapbt(rtg, est_fdblocks);
}
static void
struct xfs_rtgroup *rtg,
xfs_filblks_t est_fdblocks)
{
- struct xfs_inode *ip;
-
- if (!xfs_has_rtreflink(rtg->rtg_mount))
- return;
-
- ip = ensure_rtgroup_file(rtg, XFS_RTG_REFCOUNT, "refcount",
- libxfs_rtrefcountbt_create);
- if (ip) {
- populate_rtgroup_refcountbt(rtg, ip, est_fdblocks);
- libxfs_irele(ip);
- }
+ if (ensure_rtgroup_file(rtg, XFS_RTG_REFCOUNT))
+ populate_rtgroup_refcountbt(rtg, est_fdblocks);
}
/* Initialize a root directory. */