Skip to content

Commit 4f50143

Browse files
authored
Some more explanation.
1 parent ef7aebe commit 4f50143

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

README.md

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,42 +62,54 @@ void dsync_foo() {
6262
```
6363
3. Special case of `fsync`: Since `fsync` is an `fsync_wrapper` too, it must get its own version of osync definition and dsync definition. And it does! The osync definition of `fsync` is called `osync` and it's a system call that guarantees order and eventual durability. The dsync definition of `fsync` is called `dsync` and it's a system call that guaratess immediate durability (blocks). For more details, check the Optimistic Crash Cosnsistency paper linked above.
6464
### Safety of the Script_Optfs ###
65-
Optfs needs some improvements in cases of conditionals, as it is possible to compromise program correctness if an `fsync_wrapper` is called inside a conditional. Consider the following case:
65+
The script is safe in most cases, but there certainly are cases we don't account for.
66+
This script can deal with scope, so you can have functions with the same name in multiple files, as long as more than one of those functions doesn't have external linkage, our script will take care it. We went through great lengths to ensure that.
67+
However, cases where a switch statement is used, like the following:
6668
```C
67-
void foo(x) {
68-
bar1();
69-
if (x == 0) {
70-
bar1();
69+
function foo(fd1, fd2, expression) {
70+
switch (expression) {
71+
case 1:
72+
fsync(fd1);
73+
break;
74+
case 2:
75+
fsync(fd2);
76+
break;
77+
default:
78+
fsync(fd1);
79+
fsync(fd2);
7180
}
72-
else {
73-
bar1();
74-
}
75-
}
81+
}
7682
```
77-
This would get converted to:
83+
would get converted to the following:
7884
```C
79-
void osync_foo(x) { /* this osync definition is correct */
80-
osync_bar1();
81-
if (x == 0) {
82-
osync_bar1();
85+
function osync_foo(fd1, fd2, expression) { /* this definition is correct */
86+
switch (expression) {
87+
case 1:
88+
osync(fd1);
89+
break;
90+
case 2:
91+
osync(fd2);
92+
break;
93+
default:
94+
osync(fd1);
95+
osync(fd2);
8396
}
84-
else {
85-
osync_bar1();
97+
}
98+
99+
function dsync_foo(fd1, fd2, expression) { /* thsi definition isn't corrrect */
100+
switch (expression) {
101+
case 1:
102+
osync(fd1);
103+
break; /* this function is a dsync definition, yet it doesn't ever call dsync if case 1 is called */
104+
case 2:
105+
osync(fd2);
106+
break; /* same in this case, dsync definitions should call dsync before they return */
107+
default:
108+
osync(fd1);
109+
dsync(fd2); /* only in this case will dsync actually ever be invoked */
86110
}
87-
}
88-
89-
void dsync_foo(x) { /* this dsync definition is not correct */
90-
osync_bar1();
91-
if (x == 0) {
92-
osync_bar1();
93-
}
94-
else {
95-
dsync_bar1();
96-
}
97-
}
111+
}
98112
```
99-
In this case, our code doesn't work for the case where `x = 0`.
100-
We have noticed that in most cases libraries tend not to use this kind of code, so it should work well in most cases.
101113
### Authors ###
102114
Tom Gong (tom.gong@utexas.edu) and Subrat Mainali (mainali.subrat@utexas.edu)
103115
Under [Dr. Vijay Chidambram](http://www.cs.utexas.edu/~vijay/), UT Austin.

0 commit comments

Comments
 (0)