fi
}
+# Return a file path that can be used to shut down the scratch filesystem.
+# Caller should _require_scratch_shutdown before using this.
+_scratch_shutdown_handle()
+{
+ if [ $FSTYP = "overlay" ]; then
+ echo $OVL_BASE_SCRATCH_MNT
+ else
+ echo $SCRATCH_MNT
+ fi
+}
+
_test_mount()
{
if [ "$FSTYP" == "overlay" ]; then
static int max_fd = -1;
static unsigned int nr_opened = 0;
static float start_time;
-static int shutdown_fs = 0;
+static int shutdown_fd = -1;
void clock_time(float *time)
{
end_time - start_time);
fflush(stdout);
- if (shutdown_fs) {
+ if (shutdown_fd >= 0) {
/*
* Flush the log so that we have to process the
* unlinked inodes the next time we mount.
int flag = XFS_FSOP_GOING_FLAGS_LOGFLUSH;
int ret;
- ret = ioctl(min_fd, XFS_IOC_GOINGDOWN, &flag);
+ ret = ioctl(shutdown_fd, XFS_IOC_GOINGDOWN, &flag);
if (ret) {
perror("shutdown");
exit(2);
/*
* Try to put as many files on the unlinked list and then kill them.
- * The first argument is a directory to chdir into; passing any second arg
- * will shut down the fs instead of closing files.
+ * The first argument is a directory to chdir into; the second argumennt (if
+ * provided) is a file path that will be opened and then used to shut down the
+ * fs before the program exits.
*/
int main(int argc, char *argv[])
{
if (ret)
perror(argv[1]);
}
- if (argc > 2 && !strcmp(argv[2], "shutdown"))
- shutdown_fs = 1;
+ if (argc > 2) {
+ shutdown_fd = open(argv[2], O_RDONLY);
+ if (shutdown_fd < 0) {
+ perror(argv[2]);
+ return 1;
+ }
+ }
clock_time(&start_time);
while (1)
# Open a lot of unlinked files
echo create >> $seqres.full
-$here/src/t_open_tmpfiles $SCRATCH_MNT shutdown >> $seqres.full
+$here/src/t_open_tmpfiles $SCRATCH_MNT $(_scratch_shutdown_handle) >> $seqres.full
# Unmount to prove that we can clean it all
echo umount >> $seqres.full
# Open a lot of unlinked files
echo create >> $seqres.full
-$here/src/t_open_tmpfiles $SCRATCH_MNT shutdown >> $seqres.full
+$here/src/t_open_tmpfiles $SCRATCH_MNT $(_scratch_shutdown_handle) >> $seqres.full
# Unmount to prove that we can clean it all
echo umount >> $seqres.full