From: Darrick J. Wong Date: Fri, 20 Nov 2020 22:03:27 +0000 (-0500) Subject: libfrog: define LIBFROG_BULKSTAT_CHUNKSIZE to remove dependence on XFS_INODES_PER_CHUNK X-Git-Tag: xfsprogs-5.10-fixes_2020-12-06~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e749bfafc7f2a386c95d80525fc0dd879f6cbe7f;p=thirdparty%2Fxfsprogs-dev.git libfrog: define LIBFROG_BULKSTAT_CHUNKSIZE to remove dependence on XFS_INODES_PER_CHUNK "Online" XFS programs like scrub have no business importing the internal disk format headers to discover things like the optimum number of inodes to request through a bulkstat request. That number can be derived from the ioctl definition, so define a new constant in terms of that instead of pulling in the ondisk format unnecessarily. Note: This patch will be needed to work around new definitions in the bigtime patchset that will break scrub builds, so clean this up instead of adding more #includes to the two scrub source files. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/include/xfs.h b/include/xfs.h index af0d36cef..e97158c8d 100644 --- a/include/xfs.h +++ b/include/xfs.h @@ -38,6 +38,8 @@ extern int xfs_assert_largefile[sizeof(off_t)-8]; #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #endif +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) + #include /* Include deprecated/compat pre-vfs xfs-specific symbols */ #include diff --git a/libfrog/bulkstat.h b/libfrog/bulkstat.h index 56ef7f9a8..2f440b14f 100644 --- a/libfrog/bulkstat.h +++ b/libfrog/bulkstat.h @@ -6,6 +6,10 @@ #ifndef __LIBFROG_BULKSTAT_H__ #define __LIBFROG_BULKSTAT_H__ +/* This is the minimum reasonable size of a bulkstat request. */ +#define LIBFROG_BULKSTAT_CHUNKSIZE \ + (NBBY * sizeof_field(struct xfs_inumbers, xi_allocmask)) + /* Bulkstat wrappers */ struct xfs_bstat; int xfrog_bulkstat_single(struct xfs_fd *xfd, uint64_t ino, unsigned int flags, diff --git a/scrub/fscounters.c b/scrub/fscounters.c index e9901fcdf..e6c3e0181 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -9,7 +9,6 @@ #include #include "platform_defs.h" #include "xfs_arch.h" -#include "xfs_format.h" #include "libfrog/paths.h" #include "libfrog/workqueue.h" #include "xfs_scrub.h" diff --git a/scrub/inodes.c b/scrub/inodes.c index 5ef752fe3..bdc12df31 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -10,7 +10,6 @@ #include #include "platform_defs.h" #include "xfs_arch.h" -#include "xfs_format.h" #include "handle.h" #include "libfrog/paths.h" #include "libfrog/workqueue.h" @@ -74,7 +73,7 @@ bulkstat_for_inumbers( * Check each of the stats we got back to make sure we got the inodes * we asked for. */ - for (i = 0, bs = bstat; i < XFS_INODES_PER_CHUNK; i++) { + for (i = 0, bs = bstat; i < LIBFROG_BULKSTAT_CHUNKSIZE; i++) { if (!(inumbers->xi_allocmask & (1ULL << i))) continue; if (bs->bs_ino == inumbers->xi_startino + i) { @@ -134,7 +133,7 @@ scan_ag_inodes( sizeof(handle.ha_fid.fid_len); handle.ha_fid.fid_pad = 0; - error = -xfrog_bulkstat_alloc_req(XFS_INODES_PER_CHUNK, 0, &breq); + error = -xfrog_bulkstat_alloc_req(LIBFROG_BULKSTAT_CHUNKSIZE, 0, &breq); if (error) { str_liberror(ctx, error, descr); si->aborted = true;