diff --git a/README.md b/README.md index f532b49e..12eb8e7c 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ This repository contains a pre-generated suite of 328 seq-1 workloads (workloads python xfsMonkey.py -f /dev/sda -d /dev/cow_ram0 -t btrfs -e 102400 -u build/tests/seq1/ > outfile ``` -Sit back and relax. This is going to take about 35 minutes to complete if run on a single machine. This will run all the 328 tests of seq-1 on a `btrfs` file system `100MB` in size. The bug reports can be found in the folder `diff_results`. The workloads are named j-lang<1-328>, and, if any of these resulted in a bug, you will see a bug report with the same name as that of the workload, describing the difference between the expected and actual state. +Sit back and relax. This is going to take about 12 minutes to complete if run on a single machine. This will run all the 328 tests of seq-1 on a `btrfs` file system `100MB` in size. The bug reports can be found in the folder `diff_results`. The workloads are named j-lang<1-328>, and, if any of these resulted in a bug, you will see a bug report with the same name as that of the workload, describing the difference between the expected and actual state. ## Tutorial ## This tutorial walks you through the workflow of workload generation to testing, using a small bounded space of seq-1 workloads. Generating and running the tests in this tutorial will take less than 2 minutes. diff --git a/code/harness/DiskContents.cpp b/code/harness/DiskContents.cpp index fc3af4e6..5eeacbe4 100644 --- a/code/harness/DiskContents.cpp +++ b/code/harness/DiskContents.cpp @@ -135,7 +135,7 @@ int DiskContents::mount_disk() { return -1; } // sleep after mount - unsigned int to_sleep = 1; + unsigned int to_sleep = 0; do { to_sleep = sleep(to_sleep); } while (to_sleep > 0); diff --git a/code/harness/FsSpecific.h b/code/harness/FsSpecific.h index 3403d5fd..03ff3629 100644 --- a/code/harness/FsSpecific.h +++ b/code/harness/FsSpecific.h @@ -85,7 +85,7 @@ class Ext2FsSpecific : public ExtFsSpecific { static constexpr char kFsType[] = "ext2"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \ FOUR_SIXTEEN == 1 static const unsigned int kDelaySeconds = 20; @@ -100,7 +100,7 @@ class Ext3FsSpecific : public ExtFsSpecific { static constexpr char kFsType[] = "ext3"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \ FOUR_SIXTEEN == 1 static const unsigned int kDelaySeconds = 42; @@ -115,7 +115,7 @@ class Ext4FsSpecific : public ExtFsSpecific { static constexpr char kFsType[] = "ext4"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 ||\ FOUR_SIXTEEN == 1 static const unsigned int kDelaySeconds = 42; @@ -138,7 +138,7 @@ class BtrfsFsSpecific : public FsSpecific { static constexpr char kFsType[] = "btrfs"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif THREE_THIRTEEN == 1 || FOUR_FOUR == 1 || FOUR_FIFTEEN == 1 || \ FOUR_SIXTEEN == 1 static const unsigned int kDelaySeconds = 40; @@ -161,7 +161,7 @@ class F2fsFsSpecific : public FsSpecific { static constexpr char kFsType[] = "f2fs"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif THREE_THIRTEEN == 1 static const unsigned int kDelaySeconds = 15; #elif FOUR_FOUR == 1 @@ -187,7 +187,7 @@ class XfsFsSpecific : public FsSpecific { static constexpr char kFsType[] = "xfs"; #if TWO_SEC == 1 - static const unsigned int kDelaySeconds = 2; + static const unsigned int kDelaySeconds = 0; #elif FOUR_FIFTEEN == 1 || FOUR_SIXTEEN == 1 static const unsigned int kDelaySeconds = 97; #else diff --git a/code/harness/Tester.cpp b/code/harness/Tester.cpp index 0f059eac..6d208984 100755 --- a/code/harness/Tester.cpp +++ b/code/harness/Tester.cpp @@ -273,16 +273,34 @@ int Tester::insert_cow_brd() { } int Tester::remove_cow_brd() { + // Sometimes the disk wrapper module takes time to unload. + // So retry cow-brd unload for upto a second. + milliseconds elapsed; if (cow_brd_inserted) { if (cow_brd_fd != -1) { close(cow_brd_fd); cow_brd_fd = -1; cow_brd_inserted = false; } - if (system(COW_BRD_RMMOD) != 0) { - cow_brd_inserted = true; - return WRAPPER_REMOVE_ERR; - } + int res, num_tries = 0; + string command = COW_BRD_RMMOD SILENT; + time_point rmmod_start_time = steady_clock::now(); + do { + res = system(command.c_str()); + time_point rmmod_end_time = steady_clock::now(); + elapsed = duration_cast(rmmod_end_time - rmmod_start_time); + if (res != 0) { + usleep(500); + num_tries ++; + } + } while (res != 0 && elapsed.count() < 1000); + + if (res != 0) { + cow_brd_inserted = true; + return WRAPPER_REMOVE_ERR; + } + + //cout << "Time to rmmod " << elapsed.count() << " num tries = " << num_tries << endl; } return SUCCESS; } @@ -307,11 +325,27 @@ int Tester::insert_wrapper() { } int Tester::remove_wrapper() { + milliseconds elapsed; if (wrapper_inserted) { - if (system(WRAPPER_RMMOD) != 0) { - wrapper_inserted = true; - return WRAPPER_REMOVE_ERR; - } + int res, num_tries = 0; + string command = WRAPPER_RMMOD SILENT; + time_point rmmod_start_time = steady_clock::now(); + do { + res = system(command.c_str()); + time_point rmmod_end_time = steady_clock::now(); + elapsed = duration_cast(rmmod_end_time - rmmod_start_time); + if (res != 0) { + usleep(500); + num_tries ++; + } + } while (res != 0 && elapsed.count() < 1000); + + if (res != 0) { + wrapper_inserted = true; + return WRAPPER_REMOVE_ERR; + } + + cout << "Time to rmmod " << elapsed.count() << " num tries = " << num_tries << endl; } wrapper_inserted = false; return SUCCESS; @@ -1116,7 +1150,16 @@ bool Tester::test_write_data(const int disk_fd, } void Tester::cleanup_harness() { - if (umount_device() != SUCCESS) { + int umount_res; + int err; + do { + umount_res = umount_device(); + if (umount_res < 0) { + err = errno; + usleep(500); + } + } while (umount_res < 0 && err == EBUSY); + if (umount_res < 0) { cerr << "Unable to unmount device" << endl; permuter_unload_class(); test_unload_class(); diff --git a/code/harness/c_harness.cpp b/code/harness/c_harness.cpp index 93dc53a2..b6040970 100644 --- a/code/harness/c_harness.cpp +++ b/code/harness/c_harness.cpp @@ -572,12 +572,13 @@ int main(int argc, char** argv) { } // TODO(ashmrtn): Can probably remove this... + /* cout << "Sleeping after mount" << endl; unsigned int to_sleep = MOUNT_DELAY; do { to_sleep = sleep(to_sleep); } while (to_sleep > 0); - + */ /*************************************************************************** * Run the actual workload that we will be testing. diff --git a/xfsMonkey.py b/xfsMonkey.py index 7730ee6e..f6cf51f4 100755 --- a/xfsMonkey.py +++ b/xfsMonkey.py @@ -92,7 +92,8 @@ def main(): #This is the directory that contains the bug reports from this xfsMonkey run subprocess.call('mkdir diff_results', shell=True) - + subprocess.call('echo 0 > missing; echo 0 > stat; echo 0 > bugs; echo 0 > others', shell=True) + #Get the relative path to test directory xfsMonkeyTestPath = './' + parsed_args.test_path