#write #mount #random #delay #block #shutdown

app outoforderfs

Randomized write delays for filesystem tests. Mount your filesystem though the outoforderfs, then interrupt the latter with Cltr+C to check how will the former react to losing a random subset of N last written blocks

2 releases

Uses old Rust 2015

0.1.1 Mar 20, 2016
0.1.0 Mar 20, 2016

#36 in #shutdown

MIT license

37KB
523 lines

outoforderfs

FUSE single-file filesystem simulating dirty block device shutdown (each write is delayed randomly)

$ target/debug/outoforderfs
Usage: outoforderfs source_file mountpoint_file blocksize maxtime_ms maxdirtyblocks
 outoforderfs 'mirrors' source file to mountpoint_file,
 but writes to mountpoint_file get delivered
 to source_file after a random delay, in random order.
 The reason is to see what happens of some other FS in case of
 surprise removal (or sudden shutdown) of the storage.
Example session (approximate):
 1$ dd if=/dev/zero bs=4096 count=2560 of=sf.dat
 1$ touch mp.dat
 1$ outoforderfs sf.dat mp.dat 4096 10000 100
 1$ (switch to a new tab)
 2$   mkfs mp.dat
 2$   mount mp.dat -o loop mnt
 2$   start using mnt (filling with logs, creating sqlite, etc)
 1$ ^C
 1$ outoforderfs sf.dat mp.dat 4096 10000 100
 2$   umount mnt
 2$   mount mp.dat -o loop mnt
 2$   inspect mnt for breakage, incomplete/zeroed files, etc

Eye-catcher:

$ ./visualtest.sh 
# write 80 spaces to sf.dat
+ target/debug/outoforderfs sf.dat mp.dat 1 5000 1000
# write 80 dots to mp.dat
# Contant of sf.dat against time
                                                                                
                                                 .                              
                                                 .                            . 
                                                 .                            ..
                .             .                  .           .                ..
                .             .                  .           .                ..
                .             .                  .           .                ..
                .             .             .    .           .                ..
                .             .             .    .           .                ..
               .. .           .             .    .           . .              ..
               .. .           .             .    .           . .              ..
               .. .           .             .    .           . .              ..
               .. .           .             .    .           . .              ..
               .. .           .             .    .           . .              ..
               .. .           .             .    .           . .              ..
               .. .        .  .             .    .           . .              ..
              ... .        .  .             .    .           . . .            ..
              ... .        .  .             .    .           . . .            ..
              ... .        .  .             .    .           . . .            ..
              ... .        .  .             .    .           . . .            ..
              ... .      . .  .             .    .           . . .        .   ..
         .    ... .      . .  .             .    .           . . .        .   ..
         .   .... .      . .  .             .    .           . . .        .   ..
         .   .... .      . .  .             .    .           . . .        .   ..
         .   .... .      . .  .       .     .    .           . . .        .   ..
         .   .... .      . .  .       .     .    .           . . .        .   ..
         .   .... .      . .  . .     .     .    .           . . .        .   ..
         .   .... .      . .  . .     .     .   ..           . . .        .   ..
         .   .... .      . .  . .     .     .   ..           . . .        .   ..
         .   .... .      . .  . .     .     .   ..           . . .        .   ..
         .  ..... .     .. .  . .     .     .   ..           . . .        .   ..
         .  ..... .     .. .  . .     .     .   ..           . . .        .   ..
         .  ..... .     .. .  . .     .     .   ..           . . .    .  ..   ..
         .  ..... .     .. .  . .     .     .   ..           . . .    .  ..   ..
         .  ..... .     .. .  . ..    .     .   ..           . . .    .  ..   ..
         .  ..... .     .. .  . ..    .     .   ..           . . .    .  ..   ..
         .  ..... .     .. .  . ..    .     .   ..           . . .    .  ..   ..
         .. ..... .     .. .  . ..    .     .   ..           . . .    .  ...  ..
         .. ..... .     .. .  . ..    .     .   ..         . . . .    .  ...  ..
         .. ..... .     .. .  . ..    .     .   ....       . . . .    .  ...  ..
         .. ..... .     .. .  . ..    .     .   ....       . . . .    .  ...  ..
         .. ..... .     .. .  . ..    .     . . ....    .  . . . .    .  ...  ..
  .      .. ..... .     .. .  . ..    .     . . ....    .  . . . .    .  ...  ..
  .      .. ..... .     .. .  . ..    .     . . ....  ...  . . . .    .  ...  ..
  .      .. ..... .     .. .  . ..    .     . . ....  ...  . . . .    .  ...  ..
  .      .. ..... .     .. .  . ..    .     . . ....  ...  . . . .    .  ...  ..
  .  .   .. ..... .     .. .  . ..    .     . . ....  ...  . . . .    .  ...  ..
  .  .   .. ..... .     .. .  . ..    ..    . . ....  ...  . . . .    .  ...  ..
  .  .   .. ..... .     .. .  . ..    ..    . . ....  ...  . . . .    .  ...  ..
  .  .   .. ..... .   . .. .  . ..    ..    . . ....  ...  . . . .    .  ...  ..
# Now write 80 asterisks to mp.dat
  .  .   .. ..... .   . .. .. . ..    ..    . . ....  ...  . . . .    .  ...  ..
  .  .   .. ..... .   . .. .. . ..    ..    . . ....  ...  . . . .    .  ...  ..
  .  .   *. ..... .   . .. ..*. ..    ..    * . ....  ...  . . . .   *.  ...  ..
  .  .   *. ..... .   . .. ..*. ..    ..    * . ....  ...  * . . .   *.  ...  ..
  .  .   *. ..... .   . .. ..*. ..    ..    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ..... .   . .. ..*. ..    ..    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    ..    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    ..    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . ....  ...  * . . .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . ....  ...  * .*. .   *.  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...*. .   . .. ..*. ..    .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...*. .   . .. ..*. .. *  .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .. *  .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .. *  .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .. *  .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .. *  .*    * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .. *  .* *  * . .*..  ...  * .*. .   **  ...  ..
  . *.   *. ...** *  *. .. ..*. .* *  .* *  * . .*..  ...  * .*. .   **  ...* ..
  . *.   *. ...** * **. .. ..*. .* *  .* *  * . .*.. *...  * .*. .   **  ...* ..
  . *.   *. ...** * **.*.. ..*. .* *  .* *  * . .*.. *...  * .*. .   **  ...* ..
  . *.   *. ...** * **.*.. ..*.*.* *  .* *  * . .*..**...  * .*. .  ***  ...* ..
  . *.   *. ...** * **.*.. ..*.*.* *  .* *  * . .*..**...  * .*. .  ***  ...* ..
 *. *.   *. ...** * **.*.. ..*.*.* *  .* *  * . .*..**...  * .*. .  ***  ...* ..
 *. *.*  *. ...** * **.*.. ..*.*.* *  .* *  * . .*..**...* * .*. .  ***  ...* ..
 *. *.*  *. ...** * **.*.. ..*.*.* *  .* *  * . .*..**...* * .*. .  ***  ...* ..
 *. *.*  *. ...** * **.*..*..*.*.* *  ** *  * **.*..**...* * .*. .  ***  ...**..
 *. *.*  *.*...** * **.*..*..*.*.* *  ** *  * **.*..**...* * .*. .  ***  ..***..
 *. *.*  *.*...** * **.*..*..*.*.***  ** *  * **.*..**.*.* * .*. .  ***  ..***..
**.**.*  *.*...** * **.*..*..*.*.***  ** *  * **.*..**.*.* * .*. .  ***  ..***..
**.**.*  *.*...** * **.*..*..*.*.***  ** *  * **.*..**.*.* **.*. .  ***  ..***..
**.**.*  *.*...**** **.*..*..*.*.***  ** * ** **.*..****.* **.*. .  *****..***..
**.**.*  *.*...**** **.*..*..*.*.*** *** * ** **.*..****.* **.*.*.  *****..***..
**.**.* **.*...**** **.**.*..*.*.*** *** * ** **.*..****.* **.*.*.  *****..***..
**.**.* **.*...**** **.**.*..*.*.*** *** * ** **.*..****.* **.*.*.  *****..***..
**.**.* **.*...**** **.**.*..*.*.*** *** * ** **.*..****.* **.*.*.  *****..***..
**.**.* **.*...**** **.**.*..*.*.*** ***** *****.*..****.* **.*.*.  *****..***..
**.**.****.*...**** **.**.*..*.*.*** ***** *****.*..****.* **.*.*.  *****..***..
**.**.****.*...*******.**.*..*.*.*** ***** *****.*..****.****.*.*.  *****..***..
**.**.******..********.**.*..*.*.*** ***** *****.*..****.****.*.*. *******.***.*
**.**.*******.********.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.**.*******.********.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.**.*******.********.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.**.*******.********.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.**.*******.********.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.*******************.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.*******************.**.*..*.*.***************.*..****.****.*.*.********.***.*
**.*******************.**.*..*.*.***************.*..****.****.*.*.********.***.*
^C
16 dirty blocks lost

Dependencies

~2MB
~30K SLoC