@@ -21,7 +21,7 @@
int main(int argc, char **argv)
{
int i;
- int fd;
+ int fd, test_dir_fd;
int ret;
int failed = 0;
char fname[MAXPATHLEN];
@@ -44,6 +44,12 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
+ test_dir_fd = open(test_dir, O_RDONLY|O_DIRECTORY);
+ if (test_dir_fd < 0) {
+ perror(test_dir);
+ return EXIT_FAILURE;
+ }
+
ret = path_to_fshandle(test_dir, (void **)fshandle, &fshlen);
if (ret < 0) {
perror("path_to_fshandle");
@@ -66,7 +72,7 @@ int main(int argc, char **argv)
}
/* sync to get the new inodes to hit the disk */
- sync();
+ syncfs(test_dir_fd);
/* create the handles */
for (i=0; i < NUMFILES; i++) {
@@ -89,10 +95,10 @@ int main(int argc, char **argv)
}
/* sync to get log forced for unlink transactions to hit the disk */
- sync();
+ syncfs(test_dir_fd);
/* sync once more FTW */
- sync();
+ syncfs(test_dir_fd);
/*
* now drop the caches so that unlinked inodes are reclaimed and
@@ -120,6 +126,7 @@ int main(int argc, char **argv)
free_handle(handle[i], hlen[i]);
failed++;
}
+ close(test_dir_fd);
if (failed)
return EXIT_FAILURE;
return EXIT_SUCCESS;
xfs/238 runs stale_handle to create 1000 inodes, grab their file handles, unlink them and then try to open them from the stored file handles. It takes a ridiculously long time to run under check-parallel because it runs sync() multiple times: xfs/238 144s When running check-parallel, sync() can take a -long- time to run as there can be dozens of filesystems that need to be synced, not to mention sync getting hung up behind all the mount and unmounts that are also being run. Convert the sync() calls to syncfs() so that they only try to sync the filesystem under test and not the entire system. This avoids interactions and delays with other tests and mount/unmount operations, hence allowing both the test and the overall check-parallel operation to run faster: xfs/238 5s Signed-off-by: Dave Chinner <dchinner@redhat.com> --- src/stale_handle.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)