aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-11-01 16:32:45 -0400
committerEric Sandeen <sandeen@sandeen.net>2019-11-01 16:32:45 -0400
commit0f402dd89532e99804fcf733bd1a9c22513fced8 (patch)
tree8ebb963df29702c38062714788d7b8b7a17507e6
parentc9b349bde09807f641af9180d6c672ae699e6e08 (diff)
downloadxfsprogs-dev-0f402dd89532e99804fcf733bd1a9c22513fced8.tar.gz
xfs_scrub: request fewer bmaps when we can
In xfs_iterate_filemaps, we query the number of bmaps for a given file that we're going to iterate, so feed that information to bmap so that the kernel won't waste time allocating in-kernel memory unnecessarily. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--scrub/filemap.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/scrub/filemap.c b/scrub/filemap.c
index bdc6d8f901..f92e962013 100644
--- a/scrub/filemap.c
+++ b/scrub/filemap.c
@@ -71,7 +71,6 @@ xfs_iterate_filemaps(
map->bmv_length = ULLONG_MAX;
else
map->bmv_length = BTOBB(key->bm_length);
- map->bmv_count = BMAP_NR;
map->bmv_iflags = BMV_IF_NO_DMAPI_READ | BMV_IF_PREALLOC |
BMV_IF_NO_HOLES;
switch (whichfork) {
@@ -97,6 +96,13 @@ xfs_iterate_filemaps(
goto out;
}
+ if (fsx.fsx_nextents == 0) {
+ moveon = true;
+ goto out;
+ }
+
+ map->bmv_count = min(fsx.fsx_nextents + 1, BMAP_NR);
+
while ((error = ioctl(fd, XFS_IOC_GETBMAPX, map)) == 0) {
for (i = 0, p = &map[i + 1]; i < map->bmv_entries; i++, p++) {
bmap.bm_offset = BBTOB(p->bmv_offset);