[PATCH 03/26] libfrog: define LIBFROG_BULKSTAT_CHUNKSIZE to remove dependence on XFS_INODES_PER_CHUNK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

"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@xxxxxxxxxx>
---
 include/xfs.h      |    2 ++
 libfrog/bulkstat.h |    4 ++++
 scrub/fscounters.c |    1 -
 scrub/inodes.c     |    5 ++---
 4 files changed, 8 insertions(+), 4 deletions(-)


diff --git a/include/xfs.h b/include/xfs.h
index af0d36cef361..e97158c8d223 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 <xfs/xfs_types.h>
 /* Include deprecated/compat pre-vfs xfs-specific symbols */
 #include <xfs/xfs_fs_compat.h>
diff --git a/libfrog/bulkstat.h b/libfrog/bulkstat.h
index 56ef7f9a8237..2f440b14f93d 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 9a240d49477b..f21b24e0935c 100644
--- a/scrub/fscounters.c
+++ b/scrub/fscounters.c
@@ -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"
diff --git a/scrub/inodes.c b/scrub/inodes.c
index 5ef752fe39d3..bdc12df31479 100644
--- a/scrub/inodes.c
+++ b/scrub/inodes.c
@@ -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;




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux