diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-01-05 17:45:35 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-03-25 17:08:36 -0700 |
commit | 6cf9200fdd495ded9fe7dfa3394344e2421b0b58 (patch) | |
tree | e221652aa3ca0aeaafd250bbeb68dad8d83293f4 | |
parent | c269b1c4d716aec1fe536d3be215b37bd26a290d (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>
-rw-r--r-- | fs/xfs/libxfs/xfs_ialloc.c | 47 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_ialloc.h | 2 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_util.c | 2 |
3 files changed, 32 insertions, 19 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 5cc31b814b2a..a6c088314420 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -940,20 +940,21 @@ xfs_ialloc_next_ag( */ STATIC xfs_agnumber_t xfs_ialloc_ag_select( - xfs_trans_t *tp, /* transaction pointer */ - xfs_ino_t parent, /* parent directory inode number */ - umode_t mode) /* bits set to indicate file type */ + struct xfs_trans *tp, + struct xfs_inode *pip, + umode_t mode) { - xfs_agnumber_t agcount; /* number of ag's in the filesystem */ - xfs_agnumber_t agno; /* current ag number */ - int flags; /* alloc buffer locking flags */ - xfs_extlen_t ineed; /* blocks needed for inode allocation */ - xfs_extlen_t longest = 0; /* longest extent available */ - xfs_mount_t *mp; /* mount point structure */ - int needspace; /* file mode implies space allocated */ - xfs_perag_t *pag; /* per allocation group data */ - xfs_agnumber_t pagno; /* parent (starting) ag number */ - int error; + struct xfs_mount *mp; + struct xfs_perag *pag; + xfs_ino_t parent = pip ? pip->i_ino : 0; + xfs_agnumber_t agcount; + xfs_agnumber_t agno; + xfs_agnumber_t pagno; + xfs_extlen_t ineed; + xfs_extlen_t longest = 0; /* longest extent available */ + int needspace; /* file mode implies space allocated */ + int flags; + int error; /* * Files of these types need at least one block if length > 0 @@ -962,9 +963,21 @@ xfs_ialloc_ag_select( needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode); mp = tp->t_mountp; agcount = mp->m_maxagi; - if (S_ISDIR(mode)) + if (pip && xfs_is_metadata_inode(pip)) { + /* + * Try to squash all the metadata inodes into the parent's + * AG, or the one with the log if the log is internal, or + * AG 0 if all else fails. + */ + if (xfs_verify_ino(mp, parent)) + pagno = XFS_INO_TO_AGNO(mp, parent); + else if (mp->m_sb.sb_logstart != 0) + pagno = XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart); + else + pagno = 0; + } else if (S_ISDIR(mode)) { pagno = xfs_ialloc_next_ag(mp); - else { + } else { pagno = XFS_INO_TO_AGNO(mp, parent); if (pagno >= agcount) pagno = 0; @@ -1768,7 +1781,7 @@ xfs_dialloc_roll( int xfs_dialloc_select_ag( struct xfs_trans **tpp, - xfs_ino_t parent, + struct xfs_inode *pip, umode_t mode, struct xfs_buf **IO_agbp) { @@ -1788,7 +1801,7 @@ xfs_dialloc_select_ag( * We do not have an agbp, so select an initial allocation * group for inode allocation. */ - start_agno = xfs_ialloc_ag_select(*tpp, parent, mode); + start_agno = xfs_ialloc_ag_select(*tpp, pip, mode); if (start_agno == NULLAGNUMBER) return 0; diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h index 3526b1b7e42b..a50dd3d8d312 100644 --- a/fs/xfs/libxfs/xfs_ialloc.h +++ b/fs/xfs/libxfs/xfs_ialloc.h @@ -47,7 +47,7 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) int /* error */ xfs_dialloc_select_ag( struct xfs_trans **tpp, /* double pointer of transaction */ - xfs_ino_t parent, /* parent inode (directory) */ + struct xfs_inode *pip, /* parent inode (directory) */ umode_t mode, /* mode bits for new inode */ struct xfs_buf **IO_agbp); diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 3cfbb6f4ef3a..e0ae99e2a0a0 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -344,7 +344,7 @@ xfs_dir_ialloc( * Call the space management code to pick the on-disk inode to be * allocated. */ - error = xfs_dialloc_select_ag(tpp, parent_ino, args->mode, &agibp); + error = xfs_dialloc_select_ag(tpp, dp, args->mode, &agibp); if (error) return error; |