Factor repeated code in xfs_ialloc_ag_alloc
PATCH 1/2 Factor repeated code in xfs_ialloc_ag_alloc
Factor repeated code that determines the cluster alignment of an inode extent.
Signed-off-by Dave Chinner <[email protected]>
--- fs/xfs/xfs_ialloc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
fs/xfs/xfs_ialloc.c +13 -13
@@ -107,6 +107,16 @@ xfs_ialloc_log_di(/* * Allocation group level functions. */ +static inline int +xfs_ialloc_cluster_alignment ( +xfs_alloc_arg_t *args) +{ +if (xfs_sb_version_hasalign (&args->mp->m_sb) && + args->mp->m_sb.sb_inoalignmt >= +XFS_B_TO_FSBT (args->mp,XFS_INODE_CLUSTER_SIZE (args->mp))) +return args->mp->m_sb.sb_inoalignmt; +return 1 ; +}/* * Allocate new inodes in the allocation group specified by agbp.
@@ -191,13 +201,8 @@ xfs_ialloc_ag_alloc(ASSERT (!(args.mp->m_flags &XFS_MOUNT_NOALIGN )); args.alignment = args.mp->m_dalign; isaligned =1 ; - }else if (xfs_sb_version_hasalign (&args.mp->m_sb) && - args.mp->m_sb.sb_inoalignmt >= -XFS_B_TO_FSBT (args.mp, -XFS_INODE_CLUSTER_SIZE (args.mp))) - args.alignment = args.mp->m_sb.sb_inoalignmt; -else - args.alignment =1 ; + }else + args.alignment =xfs_ialloc_cluster_alignment (&args);/* * Need to figure out where to allocate the inode blocks. * Ideally they should be spaced out through the a.g.
@@ -230,12 +235,7 @@ xfs_ialloc_ag_alloc( args.agbno =be32_to_cpu (agi->agi_root); args.fsbno =XFS_AGB_TO_FSB (args.mp,be32_to_cpu (agi->agi_seqno), args.agbno); -if (xfs_sb_version_hasalign (&args.mp->m_sb) && - args.mp->m_sb.sb_inoalignmt >= -XFS_B_TO_FSBT (args.mp,XFS_INODE_CLUSTER_SIZE (args.mp))) - args.alignment = args.mp->m_sb.sb_inoalignmt; -else - args.alignment =1 ; + args.alignment =xfs_ialloc_cluster_alignment (&args);if ((error =xfs_alloc_vextent (&args)))return error; }
Quoted 2 lines · David Chinner
Factor repeated code that determines the cluster alignment of an inode extent.
Nice one, looks good.