]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
xfs: only allocate memory for scrubbing attributes when we need it
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 5 Jul 2019 17:29:56 +0000 (10:29 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 5 Jul 2019 17:29:56 +0000 (10:29 -0700)
commit6d6ccedd76823c28115bd6925342ceb73bab6cd4
tree36366452bf5bf8a5dbc9b5b9d2371791444b72c4
parent00816759337cd28bc5290a24dcb527fd9d30680e
xfs: only allocate memory for scrubbing attributes when we need it

In examining a flame graph of time spent running xfs_scrub on various
filesystems, I noticed that we spent nearly 7% of the total runtime on
allocating a zeroed 65k buffer for every SCRUB_TYPE_XATTR invocation.
We do this even if none of the attribute values were anywhere near 64k
in size, even if there were no attribute blocks to check space on, and
even if it just turns out there are no attributes at all.

Therefore, rearrange the xattr buffer setup code to support reallocating
with a bigger buffer and redistribute the callers of that function so
that we only allocate memory just prior to needing it, and only allocate
as much as we need.  If we can't get memory with the ILOCK held we'll
bail out with EDEADLOCK which will allocate the maximum memory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/scrub/attr.c
fs/xfs/scrub/attr.h