xfs: Pre-calculate per-AG agino geometry
authorDave Chinner <dchinner@redhat.com>
Thu, 7 Jul 2022 09:13:10 +0000 (19:13 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 7 Jul 2022 09:13:10 +0000 (19:13 +1000)
commit2d6ca8321c354e1cb6f6b1963c4f7bd053d2e272
tree462b4eb09dd29556c31efee4957aafbaa2593fb1
parent0800169e3e2c97a033e8b7f3d1e6c689e0d71a19
xfs: Pre-calculate per-AG agino geometry

There is a lot of overhead in functions like xfs_verify_agino() 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_agino(), we now always have a perag
context handy, so we can store the minimum and maximum agino values
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.

xfs_verify_agino_or_null() gets the same perag treatment.

xfs_agino_range() is moved to xfs_ag.c as it's not really a type
function, and it's use is largely restricted as the first and last
aginos can be grabbed straight from the perag in most cases.

Note that we leave the original xfs_verify_agino 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_agino() to indicate it takes both an agno
and an agino to differentiate it from new function.

$ size --totals fs/xfs/built-in.a
   text    data     bss     dec     hex filename
before 1482185  329588     572 1812345  1ba779 (TOTALS)
after 1481937  329588     572 1812097  1ba681 (TOTALS)

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_types.c
fs/xfs/libxfs/xfs_types.h
fs/xfs/scrub/agheader.c
fs/xfs/scrub/ialloc.c
fs/xfs/scrub/repair.c
fs/xfs/xfs_inode.c