Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename crash conssistency #67

Open
OmSaran opened this issue May 9, 2022 · 1 comment
Open

Rename crash conssistency #67

OmSaran opened this issue May 9, 2022 · 1 comment

Comments

@OmSaran
Copy link
Contributor

OmSaran commented May 9, 2022

There appears to be a bug in rename atomicity in SplitFS.

Occurs in the following sequence of operations:

  1. Create file1
  2. Create file2
  3. rename file1 -> file2

SplitFS does the following during recovery:

  1. Re-create file1 (since after rename file1 is lost)
  2. Do nothing since file2 exists
  3. Skip rename (step 3) since file2 exists.

End state of the filesystem leaves it in an inconsistent/non-atomic state where file1 and file2 exist after recovery while file2 only exists before recovery.

@OmSaran
Copy link
Contributor Author

OmSaran commented May 9, 2022

It can be reproduced with a program like this:

renam.c

#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>

#define FILE1 "/mnt/pmem_emul/file1.txt"
#define FILE2 "/mnt/pmem_emul/file2.txt"

void prep_file(const char * name, int num) {
    char buf[] = "filex.txt";
    int ret, fd;

    buf[4] = num + '0';
    
    remove(name);

    fd = open(name, O_WRONLY | O_CREAT, 0644);
    assert(fd > 0);
}

int main() {
    prep_file(FILE1, 1);
    prep_file(FILE2, 2);

    rename(FILE1, FILE2);
    _exit(2); // crash the program without flushing the op/append logs.
}

After the program execution, but before recovery, we see the following file: file2.txt only.
After the program execution and after recovery, we see the following files: file1.txt, file2.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant