Skip to content

Commit

Permalink
Update stressfs to trigger race now the logging code serializes writes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frans Kaashoek committed Sep 27, 2011
1 parent 5304c85 commit 9b972c0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions stressfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// appends to the idequeue results in a race.

// For this to work, you should also add a spin within iderw's
// idequeue traversal loop. Spinning 40000 times demonstrated the bug
// after about 5 runs of stressfs in QEMU on a 2.1GHz CPU.
// idequeue traversal loop. Adding the following demonstrated a panic
// after about 5 runs of stressfs in QEMU on a 2.1GHz CPU:
// for (i = 0; i < 40000; i++)
// asm volatile("");

#include "types.h"
#include "stat.h"
Expand All @@ -16,19 +18,29 @@ main(int argc, char *argv[])
{
int fd, i;
char path[] = "stressfs0";
char data[512];

printf(1, "stressfs starting\n");
memset(data, 'a', sizeof(data));

for(i = 0; i < 4; i++)
if(fork() > 0)
break;

printf(1, "%d\n", i);
printf(1, "write %d\n", i);

path[8] += i;
fd = open(path, O_CREATE | O_RDWR);
for(i = 0; i < 100; i++)
printf(fd, "%d\n", i);
for(i = 0; i < 20; i++)
// printf(fd, "%d\n", i);
write(fd, data, sizeof(data));
close(fd);

printf(1, "read\n");

fd = open(path, O_RDONLY);
for (i = 0; i < 20; i++)
read(fd, data, sizeof(data));
close(fd);

wait();
Expand Down

0 comments on commit 9b972c0

Please sign in to comment.