• Dave Chinner's avatar
    xfs: Pre-calculate per-AG agbno geometry · 0800169e
    Dave Chinner authored
    There is a lot of overhead in functions like xfs_verify_agbno() that
    repeatedly calculate the geometry limits of an AG. These can be
    pre-calculated as they are static and the verification context has
    a per-ag context it can quickly reference.
    
    In the case of xfs_verify_agbno(), we now always have a perag
    context handy, so we can store the AG length and the minimum valid
    block in the AG in the perag. This means we don't have to calculate
    it on every call and it can be inlined in callers if we move it
    to xfs_ag.h.
    
    Move xfs_ag_block_count() to xfs_ag.c because it's really a
    per-ag function and not an XFS type function. We need a little
    bit of rework that is specific to xfs_initialise_perag() to allow
    growfs to calculate the new perag sizes before we've updated the
    primary superblock during the grow (chicken/egg situation).
    
    Note that we leave the original xfs_verify_agbno in place in
    xfs_types.c as a static function as other callers in that file do
    not have per-ag contexts so still need to go the long way. It's been
    renamed to xfs_verify_agno_agbno() to indicate it takes both an agno
    and an agbno to differentiate it from new function.
    
    Future commits will make similar changes for other per-ag geometry
    validation functions.
    
    Further:
    
    $ size --totals fs/xfs/built-in.a
    	   text    data     bss     dec     hex filename
    before	1483006	 329588	    572	1813166	 1baaae	(TOTALS)
    after	1482185	 329588	    572	1812345	 1ba779	(TOTALS)
    
    This rework reduces the binary size by ~820 bytes, indicating
    that much less work is being done to bounds check the agbno values
    against on per-ag geometry information.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
    0800169e
xfs_ag.h 5.91 KB