summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:14:48 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-12-15 17:29:07 -0800
commitaf71edfea550f602944e72175e5b7e3907732e32 (patch)
tree228b6bd967616f728072702e9225800ca152270d /fs/xfs
parent0e83cb16d0866b30f1c19362062c3479160cb3f4 (diff)
xfs: disable the agi rotor for metadata inodes
Ideally, we'd put all the metadata inodes in one place if we could, so that the metadata all stay reasonably close together instead of spreading out over the disk. Furthermore, if the log is internal we'd probably prefer to keep the metadata near the log. Therefore, disable AGI rotoring for metadata inode allocations. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c16
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.h2
-rw-r--r--fs/xfs/libxfs/xfs_imeta.c4
-rw-r--r--fs/xfs/scrub/tempfile.c2
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_symlink.c2
6 files changed, 16 insertions, 14 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 340c58a66618..4614460b7f47 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1765,26 +1765,28 @@ out_release:
int
xfs_dialloc(
struct xfs_trans **tpp,
- xfs_ino_t parent,
+ struct xfs_inode *pip,
umode_t mode,
xfs_ino_t *new_ino)
{
struct xfs_mount *mp = (*tpp)->t_mountp;
- xfs_agnumber_t agno;
- int error = 0;
- xfs_agnumber_t start_agno;
struct xfs_perag *pag;
struct xfs_ino_geometry *igeo = M_IGEO(mp);
+ xfs_ino_t ino;
+ xfs_ino_t parent = pip ? pip->i_ino : 0;
+ xfs_agnumber_t agno;
+ xfs_agnumber_t start_agno;
bool ok_alloc = true;
int flags;
- xfs_ino_t ino;
+ int error = 0;
/*
* Directories, symlinks, and regular files frequently allocate at least
* one block, so factor that potential expansion when we examine whether
- * an AG has enough space for file creation.
+ * an AG has enough space for file creation. Try to keep metadata
+ * files all in the same AG.
*/
- if (S_ISDIR(mode))
+ if (S_ISDIR(mode) && (!pip || !xfs_is_metadata_inode(pip)))
start_agno = xfs_ialloc_next_ag(mp);
else {
start_agno = XFS_INO_TO_AGNO(mp, parent);
diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
index d4191f133607..9ff7b98d827c 100644
--- a/fs/xfs/libxfs/xfs_ialloc.h
+++ b/fs/xfs/libxfs/xfs_ialloc.h
@@ -36,7 +36,7 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
* Allocate an inode on disk. Mode is used to tell whether the new inode will
* need space, and whether it is a directory.
*/
-int xfs_dialloc(struct xfs_trans **tpp, xfs_ino_t parent, umode_t mode,
+int xfs_dialloc(struct xfs_trans **tpp, struct xfs_inode *dp, umode_t mode,
xfs_ino_t *new_ino);
int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c
index 1bba953502b5..4b383bc7d7cd 100644
--- a/fs/xfs/libxfs/xfs_imeta.c
+++ b/fs/xfs/libxfs/xfs_imeta.c
@@ -211,7 +211,7 @@ xfs_imeta_sb_create(
return -EEXIST;
/* Create a new inode and set the sb pointer. */
- error = xfs_dialloc(tpp, 0, mode, &ino);
+ error = xfs_dialloc(tpp, NULL, mode, &ino);
if (error)
return error;
error = xfs_icreate(*tpp, ino, &args, ipp);
@@ -571,7 +571,7 @@ xfs_imeta_dir_create(
* entry pointing to them, but a directory also the "." entry
* pointing to itself.
*/
- error = xfs_dialloc(tpp, dp->i_ino, mode, &ino);
+ error = xfs_dialloc(tpp, dp, mode, &ino);
if (error)
goto out_ilock;
error = xfs_icreate(*tpp, ino, &args, ipp);
diff --git a/fs/xfs/scrub/tempfile.c b/fs/xfs/scrub/tempfile.c
index 1c4a74ed9219..eaa5449bf945 100644
--- a/fs/xfs/scrub/tempfile.c
+++ b/fs/xfs/scrub/tempfile.c
@@ -94,7 +94,7 @@ xrep_tempfile_create(
goto out_release_dquots;
/* Allocate inode, set up directory. */
- error = xfs_dialloc(&tp, dp->i_ino, mode, &ino);
+ error = xfs_dialloc(&tp, dp, mode, &ino);
if (error)
goto out_trans_cancel;
error = xfs_icreate(tp, ino, &args, &sc->tempip);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9f3da29562d7..3b56c6c52a7c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -750,7 +750,7 @@ xfs_create(
* entry pointing to them, but a directory also the "." entry
* pointing to itself.
*/
- error = xfs_dialloc(&tp, dp->i_ino, args->mode, &ino);
+ error = xfs_dialloc(&tp, dp, args->mode, &ino);
if (!error)
error = xfs_icreate(tp, ino, args, &ip);
if (error)
@@ -856,7 +856,7 @@ xfs_create_tmpfile(
if (error)
goto out_release_dquots;
- error = xfs_dialloc(&tp, dp->i_ino, args->mode, &ino);
+ error = xfs_dialloc(&tp, dp, args->mode, &ino);
if (!error)
error = xfs_icreate(tp, ino, args, &ip);
if (error)
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 8da0b103e650..177987c3716f 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -297,7 +297,7 @@ xfs_symlink(
/*
* Allocate an inode for the symlink.
*/
- error = xfs_dialloc(&tp, dp->i_ino, S_IFLNK, &ino);
+ error = xfs_dialloc(&tp, dp, S_IFLNK, &ino);
if (!error)
error = xfs_icreate(tp, ino, &args, &ip);
if (error)