Skip to content
This repository
Browse code

Update stressfs to trigger race now the logging code serializes writes

  • Loading branch information...
commit 9b972c06b172531e5792fc0e05d83319d325e0ee 1 parent 5304c85
authored

Showing 1 changed file with 17 additions and 5 deletions. Show diff stats Hide diff stats

  1. 22  stressfs.c
22  stressfs.c
@@ -2,8 +2,10 @@
2 2
 // appends to the idequeue results in a race.
3 3
 
4 4
 // For this to work, you should also add a spin within iderw's
5  
-// idequeue traversal loop.  Spinning 40000 times demonstrated the bug
6  
-// after about 5 runs of stressfs in QEMU on a 2.1GHz CPU.
  5
+// idequeue traversal loop.  Adding the following demonstrated a panic
  6
+// after about 5 runs of stressfs in QEMU on a 2.1GHz CPU:
  7
+//    for (i = 0; i < 40000; i++)
  8
+//      asm volatile("");
7 9
 
8 10
 #include "types.h"
9 11
 #include "stat.h"
@@ -16,19 +18,29 @@ main(int argc, char *argv[])
16 18
 {
17 19
   int fd, i;
18 20
   char path[] = "stressfs0";
  21
+  char data[512];
19 22
 
20 23
   printf(1, "stressfs starting\n");
  24
+  memset(data, 'a', sizeof(data));
21 25
 
22 26
   for(i = 0; i < 4; i++)
23 27
     if(fork() > 0)
24 28
       break;
25 29
 
26  
-  printf(1, "%d\n", i);
  30
+  printf(1, "write %d\n", i);
27 31
 
28 32
   path[8] += i;
29 33
   fd = open(path, O_CREATE | O_RDWR);
30  
-  for(i = 0; i < 100; i++)
31  
-    printf(fd, "%d\n", i);
  34
+  for(i = 0; i < 20; i++)
  35
+//    printf(fd, "%d\n", i);
  36
+    write(fd, data, sizeof(data));
  37
+  close(fd);
  38
+
  39
+  printf(1, "read\n");
  40
+
  41
+  fd = open(path, O_RDONLY);
  42
+  for (i = 0; i < 20; i++)
  43
+    read(fd, data, sizeof(data));
32 44
   close(fd);
33 45
 
34 46
   wait();

0 notes on commit 9b972c0

Please sign in to comment.
Something went wrong with that request. Please try again.