linux-stable/fs/xfs/libxfs
Omar Sandoval 355e353213 xfs: cache minimum realtime summary level
The realtime summary is a two-dimensional array on disk, effectively:

u32 rsum[log2(number of realtime extents) + 1][number of blocks in the bitmap]

rsum[log][bbno] is the number of extents of size 2**log which start in
bitmap block bbno.

xfs_rtallocate_extent_near() uses xfs_rtany_summary() to check whether
rsum[log][bbno] != 0 for any log level. However, the summary array is
stored in row-major order (i.e., like an array in C), so all of these
entries are not adjacent, but rather spread across the entire summary
file. In the worst case (a full bitmap block), xfs_rtany_summary() has
to check every level.

This means that on a moderately-used realtime device, an allocation will
waste a lot of time finding, reading, and releasing buffers for the
realtime summary. In particular, one of our storage services (which runs
on servers with 8 very slow CPUs and 15 8 TB XFS realtime filesystems)
spends almost 5% of its CPU cycles in xfs_rtbuf_get() and
xfs_trans_brelse() called from xfs_rtany_summary().

One solution would be to also store the summary with the dimensions
swapped. However, this would require a disk format change to a very old
component of XFS.

Instead, we can cache the minimum size which contains any extents. We do
so lazily; rather than guaranteeing that the cache contains the precise
minimum, it always contains a loose lower bound which we tighten when we
read or update a summary block. This only uses a few kilobytes of memory
and is already serialized via the realtime bitmap and summary inode
locks, so the cost is minimal. With this change, the same workload only
spends 0.2% of its CPU cycles in the realtime allocator.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-12-12 08:47:17 -08:00
..
xfs_ag.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_ag.h xfs: factor the ag length extension code into libxfs 2018-05-15 18:12:51 -07:00
xfs_ag_resv.c xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_ag_resv.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_alloc.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_alloc.h xfs: const-ify xfs_owner_info arguments 2018-12-12 08:47:16 -08:00
xfs_alloc_btree.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_alloc_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr.c xfs: Add attibute remove and helper functions 2018-10-18 17:21:23 +11:00
xfs_attr.h xfs: Add attibute remove and helper functions 2018-10-18 17:21:23 +11:00
xfs_attr_leaf.c xfs: fix overflow in xfs_attr3_leaf_verify 2018-11-06 07:50:50 -08:00
xfs_attr_leaf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_remote.c xfs: remove last of unnecessary xfs_defer_cancel() callers 2018-09-29 13:41:58 +10:00
xfs_attr_remote.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_sf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bit.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bit.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bmap.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_bmap.h xfs: const-ify xfs_owner_info arguments 2018-12-12 08:47:16 -08:00
xfs_bmap_btree.c xfs: pass transaction to xfs_defer_add() 2018-08-02 23:05:14 -07:00
xfs_bmap_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_btree.c xfs: fix inverted return from xfs_btree_sblock_verify_crc 2018-12-04 08:50:49 -08:00
xfs_btree.h xfs: fold dfops into the transaction 2018-08-02 23:05:14 -07:00
xfs_cksum.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xfs_da_btree.c xfs: check da node magic in _node_lookup_int 2018-08-01 07:42:43 -07:00
xfs_da_btree.h xfs: fold dfops into the transaction 2018-08-02 23:05:14 -07:00
xfs_da_format.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_da_format.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_defer.c xfs: streamline defer op type handling 2018-12-12 08:47:16 -08:00
xfs_defer.h xfs: streamline defer op type handling 2018-12-12 08:47:16 -08:00
xfs_dir2.c xfs: fold dfops into the transaction 2018-08-02 23:05:14 -07:00
xfs_dir2.h xfs: fold dfops into the transaction 2018-08-02 23:05:14 -07:00
xfs_dir2_block.c xfs: clean up MIN/MAX 2018-06-08 10:07:52 -07:00
xfs_dir2_data.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_dir2_leaf.c xfs: clean up MIN/MAX 2018-06-08 10:07:52 -07:00
xfs_dir2_node.c xfs: use swap macro in xfs_dir2_leafn_rebalance 2018-07-17 14:25:57 -07:00
xfs_dir2_priv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_dir2_sf.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_dquot_buf.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_errortag.h xfs: force summary counter recalc at next mount 2018-07-23 09:08:01 -07:00
xfs_format.h xfs: add a block to inode count converter 2018-12-12 08:47:16 -08:00
xfs_fs.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_ialloc.c xfs: precalculate cluster alignment in inodes and blocks 2018-12-12 08:47:17 -08:00
xfs_ialloc.h xfs: remove dfops parameter from ifree call stack 2018-07-11 22:26:07 -07:00
xfs_ialloc_btree.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_ialloc_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_iext_tree.c xfs: use WRITE_ONCE to update if_seq 2018-08-07 10:57:12 -07:00
xfs_inode_buf.c xfs: validate inode di_forkoff 2018-09-29 13:50:13 +10:00
xfs_inode_buf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_inode_fork.c xfs: remove the xfs_ifork_t typedef 2018-07-30 07:57:48 -07:00
xfs_inode_fork.h xfs: maintain a sequence count for inode fork manipulations 2018-07-31 13:18:09 -07:00
xfs_log_format.h xfs: refactor unmount record write 2018-07-23 09:08:01 -07:00
xfs_log_recover.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_log_rlimit.c xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_quota_defs.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_refcount.c xfs: pass transaction to xfs_defer_add() 2018-08-02 23:05:14 -07:00
xfs_refcount.h xfs: pass transaction to xfs_defer_add() 2018-08-02 23:05:14 -07:00
xfs_refcount_btree.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_refcount_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rmap.c xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_rmap.h xfs: remove xfs_rmap_ag_owner and friends 2018-12-12 08:47:16 -08:00
xfs_rmap_btree.c xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rmap_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rtbitmap.c xfs: cache minimum realtime summary level 2018-12-12 08:47:17 -08:00
xfs_sb.c xfs: remove suport for filesystems without unwritten extent flag 2018-10-18 17:18:58 +11:00
xfs_sb.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_shared.h xfs: replace dop_low with transaction flag 2018-08-02 23:05:13 -07:00
xfs_symlink_remote.c xfs: zero length symlinks are not valid 2018-12-12 08:47:15 -08:00
xfs_trans_resv.c xfs: clean up MIN/MAX 2018-06-08 10:07:52 -07:00
xfs_trans_resv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_trans_space.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_types.c xfs: precalculate cluster alignment in inodes and blocks 2018-12-12 08:47:17 -08:00
xfs_types.h xfs: verify icount in superblock write 2018-07-31 13:18:09 -07:00