return NULL;
}
-/* Update inode pointers in the superblock. */
-static inline void
-xfs_imeta_log_sb(
- struct xfs_trans *tp)
-{
- struct xfs_mount *mp = tp->t_mountp;
- struct xfs_buf *bp = xfs_trans_getsb(tp);
-
- /*
- * Update the inode flags in the ondisk superblock without touching
- * the summary counters. We have not quiesced inode chunk allocation,
- * so we cannot coordinate with updates to the icount and ifree percpu
- * counters.
- */
- xfs_sb_to_disk(bp->b_addr, &mp->m_sb);
- xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
- xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1);
-}
-
-/*
- * Create a new metadata inode and set a superblock pointer to this new inode.
- * The superblock field must not already be pointing to an inode.
- */
-STATIC int
-xfs_imeta_sb_create(
- struct xfs_imeta_update *upd,
- umode_t mode)
-{
- struct xfs_icreate_args args = {
- .nlink = S_ISDIR(mode) ? 2 : 1,
- };
- struct xfs_mount *mp = upd->mp;
- xfs_ino_t *sb_inop;
- xfs_ino_t ino;
- int error;
-
- /* Files rooted in the superblock do not have parents. */
- xfs_icreate_args_rootfile(&args, mp, mode, false);
-
- /* Reject if the sb already points to some inode. */
- sb_inop = xfs_imeta_path_to_sb_inop(mp, upd->path);
- if (!sb_inop)
- return -EINVAL;
-
- if (*sb_inop != NULLFSINO)
- return -EEXIST;
-
- /* Create a new inode and set the sb pointer. */
- error = xfs_dialloc(&upd->tp, NULL, mode, &ino);
- if (error)
- return error;
- error = xfs_icreate(upd->tp, ino, &args, &upd->ip);
- if (error)
- return error;
- upd->ip_locked = true;
-
- /*
- * If we ever need the ability to create rt metadata files on a
- * pre-metadir filesystem, we'll need to dqattach the child here.
- * Currently we assume that mkfs will create the files and quotacheck
- * will account for them.
- */
-
- /* Update superblock pointer. */
- *sb_inop = ino;
- xfs_imeta_log_sb(upd->tp);
-
- trace_xfs_imeta_sb_create(upd);
- return 0;
-}
-
/* Functions for storing and retrieving metadata directory inode values. */
static inline void
ASSERT(xfs_imeta_path_check(upd->path));
- *ipp = NULL;
+ if (WARN_ON_ONCE(!xfs_has_metadir(mp)))
+ return -EIO;
- if (xfs_has_metadir(mp))
- error = xfs_imeta_dir_create(upd, mode);
- else
- error = xfs_imeta_sb_create(upd, mode);
+ *ipp = NULL;
+ error = xfs_imeta_dir_create(upd, mode);
*ipp = upd->ip;
return error;
}