Skip to content

Commit

Permalink
fuzzy: add a custom xfs find utility for scrub stress tests
Browse files Browse the repository at this point in the history
Create a new find(1) like utility that doesn't crash on directory tree
changes (like find does due to bugs in its loop detector) and actually
implements the custom xfs attribute predicates that we need for scrub
stress tests.  This program will be needed for a future patch where we
add stress tests for scrub and repair of file metadata.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
  • Loading branch information
Darrick J. Wong authored and Zorro Lang committed Feb 7, 2023
1 parent e926c8f commit 3fec479
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ tags
/src/writemod
/src/writev_on_pagefault
/src/xfsctl
/src/xfsfind
/src/aio-dio-regress/aio-dio-append-write-fallocate-race
/src/aio-dio-regress/aio-dio-append-write-read-race
/src/aio-dio-regress/aio-dio-cow-race
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ AC_PACKAGE_WANT_LINUX_FS_H
AC_PACKAGE_WANT_LIBBTRFSUTIL

AC_HAVE_COPY_FILE_RANGE
AC_HAVE_SEEK_DATA
AC_HAVE_BMV_OF_SHARED
AC_HAVE_NFTW
AC_HAVE_RLIMIT_NOFILE

AC_CHECK_FUNCS([renameat2])
AC_CHECK_FUNCS([reallocarray])
AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]])
Expand Down
4 changes: 4 additions & 0 deletions include/builddefs.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ HAVE_FIEMAP = @have_fiemap@
HAVE_FALLOCATE = @have_fallocate@
HAVE_COPY_FILE_RANGE = @have_copy_file_range@
HAVE_LIBBTRFSUTIL = @have_libbtrfsutil@
HAVE_SEEK_DATA = @have_seek_data@
HAVE_NFTW = @have_nftw@
HAVE_BMV_OF_SHARED = @have_bmv_of_shared@
HAVE_RLIMIT_NOFILE = @have_rlimit_nofile@

GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall

Expand Down
44 changes: 44 additions & 0 deletions m4/package_libcdev.m4
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,47 @@ AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
AC_SUBST(have_copy_file_range)
])

# Check if we have SEEK_DATA
AC_DEFUN([AC_HAVE_SEEK_DATA],
[ AC_MSG_CHECKING([for SEEK_DATA])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
]], [[
lseek(-1, 0, SEEK_DATA);
]])],[have_seek_data=yes
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_SUBST(have_seek_data)
])

# Check if we have nftw
AC_DEFUN([AC_HAVE_NFTW],
[ AC_MSG_CHECKING([for nftw])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <stddef.h>
#include <ftw.h>
]], [[
nftw("/", (int (*)(const char *, const struct stat *, int, struct FTW *))1, 0, 0);
]])],[have_nftw=yes
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_SUBST(have_nftw)
])

# Check if we have RLIMIT_NOFILE
AC_DEFUN([AC_HAVE_RLIMIT_NOFILE],
[ AC_MSG_CHECKING([for RLIMIT_NOFILE])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <sys/time.h>
#include <sys/resource.h>
]], [[
struct rlimit rlimit;
rlimit.rlim_cur = 0;
getrlimit(RLIMIT_NOFILE, &rlimit);
]])],[have_rlimit_nofile=yes
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_SUBST(have_rlimit_nofile)
])
15 changes: 15 additions & 0 deletions m4/package_xfslibs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,18 @@ AC_DEFUN([AC_PACKAGE_NEED_XFSCTL_MACRO],
exit 1
])
])

# Check if we have BMV_OF_SHARED from the GETBMAPX ioctl
AC_DEFUN([AC_HAVE_BMV_OF_SHARED],
[ AC_MSG_CHECKING([for BMV_OF_SHARED])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <xfs/xfs.h>
]], [[
struct getbmapx obj;
ioctl(-1, XFS_IOC_GETBMAPX, &obj);
obj.bmv_oflags |= BMV_OF_SHARED;
]])],[have_bmv_of_shared=yes
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_SUBST(have_bmv_of_shared)
])
10 changes: 10 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ ifeq ($(HAVE_LIBCAP), true)
LLDLIBS += -lcap
endif

ifeq ($(HAVE_SEEK_DATA), yes)
ifeq ($(HAVE_NFTW), yes)
ifeq ($(HAVE_BMV_OF_SHARED), yes)
ifeq ($(HAVE_RLIMIT_NOFILE), yes)
TARGETS += xfsfind
endif
endif
endif
endif

CFILES = $(TARGETS:=.c)
LDIRT = $(TARGETS) fssum

Expand Down
Loading

0 comments on commit 3fec479

Please sign in to comment.