]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libfrog: define LIBFROG_BULKSTAT_CHUNKSIZE to remove dependence on XFS_INODES_PER_CHUNK
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 20 Nov 2020 22:03:27 +0000 (17:03 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 20 Nov 2020 22:03:27 +0000 (17:03 -0500)
"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 <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs.h
libfrog/bulkstat.h
scrub/fscounters.c
scrub/inodes.c

index af0d36cef361f0c40678b8be3202c392fa20a9e9..e97158c8d223f535533afde56eb65c40a4e99bf6 100644 (file)
@@ -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 <xfs/xfs_types.h>
 /* Include deprecated/compat pre-vfs xfs-specific symbols */
 #include <xfs/xfs_fs_compat.h>
index 56ef7f9a82371fb54cd74a0bca48ebf5252f638e..2f440b14f93d85c2e55bb9a2aba774989b49a758 100644 (file)
@@ -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,
index e9901fcdf6dfb15f9b85dda1259000ea55748157..e6c3e01811f6fa47c22c2ecabefb8d512658c57b 100644 (file)
@@ -9,7 +9,6 @@
 #include <sys/statvfs.h>
 #include "platform_defs.h"
 #include "xfs_arch.h"
-#include "xfs_format.h"
 #include "libfrog/paths.h"
 #include "libfrog/workqueue.h"
 #include "xfs_scrub.h"
index 5ef752fe39d3386e54781b96b3a55313213ac146..bdc12df314798f7739ce6243507971dc7729f162 100644 (file)
@@ -10,7 +10,6 @@
 #include <sys/statvfs.h>
 #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;