]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_scrub: try harder to fill the bulkstat array with bulkstat()
authorDarrick J. Wong <djwong@kernel.org>
Mon, 24 Feb 2025 18:21:44 +0000 (10:21 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 25 Feb 2025 17:15:57 +0000 (09:15 -0800)
commit7ae92e1cb0aeeb333ac38393a5b3dbcda1ac769e
tree197c10da660fe0c832f9a1827a5db0c07114c8b2
parent20dbdd616162b0a8503437f0f8ebda4f786a9714
xfs_scrub: try harder to fill the bulkstat array with bulkstat()

Sometimes, the last bulkstat record returned by the first xfrog_bulkstat
call in bulkstat_for_inumbers will contain an inumber less than the
highest allocated inode mentioned in the inumbers record.  This happens
either because the inodes have been freed, or because the the kernel
encountered a corrupt inode during bulkstat and stopped filling up the
array.

In both cases, we can call bulkstat again to try to fill up the rest of
the array.  If there are newly allocated inodes, they'll be returned; if
we've truly hit the end of the filesystem, the kernel will return zero
records; and if the first allocated inode is indeed corrupt, the kernel
will return EFSCORRUPTED.

As an optimization to avoid the single-step code, call bulkstat with an
increasing ino parameter until the bulkstat array is full or the kernel
tells us there are no bulkstat records to return.  This speeds things
up a bit in cases where the allocmask is all ones and only the second
inode is corrupt.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libfrog/bitmask.h
scrub/inodes.c