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

First file in directory being written to read-only branch #59

Open
lopsided98 opened this issue Feb 11, 2017 · 2 comments
Open

First file in directory being written to read-only branch #59

lopsided98 opened this issue Feb 11, 2017 · 2 comments

Comments

@lopsided98
Copy link

lopsided98 commented Feb 11, 2017

With copy-on-write enabled, I am noticing that certain files are being written to a read only branch. This seems to have something to do with the fact that the files are located on an NFS share.

As far as I can tell, the problem seems to be that the first file written to a directory that does not exist in the read-write branch, but does exist in the read-only branch, is written to both branches. I haven't been able to pinpoint all the situations where this does or does not occur, but I created a script that demonstrates some interesting cases.

#!/bin/bash

mkdir lower upper union

# Cases 1 and 2
mkdir -p lower/dir1 lower/dir2

# Case 4
mkdir -p upper/dir4

unionfs -ocow,debug_file=debug.log upper=RW:lower=RO union

# Case 1
touch union/dir1/file.txt
touch union/dir1/file2.txt

# Case 2
touch union/dir2/file.txt
touch union/dir2/file2.txt

# Case 3
mkdir -p union/dir3
touch union/dir3/file.txt

# Case 4
touch union/dir4/file.txt

tree lower
echo
tree upper
echo
tree union

fusermount -u union
  • Case 1 and 2: Before mounting, the dir1 and dir2 exist in lower, but not upper. This causes the first file created in each directory to be written to lower, the read-only branch, which is incorrect behavior
  • Case 3: Before mounting, dir3 does not exist in either branch. After mounting, it is created and is correctly written only to upper.
  • Case 4: Before mounting, dir4 exists only in upper. After mounting, when a file is written to it, the file is correctly created within upper.

I believe the problem is related to NFS because the test script works correctly on my laptop as well as in a tmpfs on the system where I am experiencing the problem.

Here is the debug log created while running the script (name of NFS share and username have been redacted) as well as the output of the script:

Debug mode, log will be written to debug.log
build_path(): 131: from: unionfs_post_opts():334 path: /nfsshare/home/myuser/unionfs/upper/
build_path(): 132: return 0
build_path(): 131: from: unionfs_post_opts():334 path: /nfsshare/home/myuser/unionfs/lower/
build_path(): 132: return 0
touch: setting times of 'union/dir1/file.txt': Invalid argument
touch: setting times of 'union/dir2/file.txt': Invalid argument
lower
├── dir1
│   └── file.txt
└── dir2
    └── file.txt

2 directories, 2 files

upper
├── dir1
│   ├── file2.txt
│   └── file.txt
├── dir2
│   ├── file2.txt
│   └── file.txt
├── dir3
│   └── file.txt
└── dir4
    └── file.txt

4 directories, 6 files

union
├── dir1
│   ├── file2.txt
│   └── file.txt
├── dir2
│   ├── file2.txt
│   └── file.txt
├── dir3
│   └── file.txt
└── dir4
    └── file.txt

4 directories, 6 files

Here is the expected output (running in a tmpfs) and debug log:

Debug mode, log will be written to debug.log
build_path(): 131: from: unionfs_post_opts():334 path: /tmp/union-test/upper/
build_path(): 132: return 0
build_path(): 131: from: unionfs_post_opts():334 path: /tmp/union-test/lower/
build_path(): 132: return 0
lower
├── dir1
└── dir2

2 directories, 0 files

upper
├── dir1
│   ├── file2.txt
│   └── file.txt
├── dir2
│   ├── file2.txt
│   └── file.txt
├── dir3
│   └── file.txt
└── dir4
    └── file.txt

4 directories, 6 files

union
├── dir1
│   ├── file2.txt
│   └── file.txt
├── dir2
│   ├── file2.txt
│   └── file.txt
├── dir3
│   └── file.txt
└── dir4
    └── file.txt

4 directories, 6 files
@rpodgorny
Copy link
Owner

thanks for such detailed bug report! i'll gladly investigate it but do you have any idea how to create a nfs testbed (on localhost) in the most straightforward way? ideally, such that would work in travis (ubuntu based) as well?

@Tuupertunut
Copy link
Contributor

I cannot reproduce this on unionfs-fuse 3.2 using NFS. A case was recently fixed (#128) where writes could happen in a read-only branch. Can you still reproduce this?

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

3 participants