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

prealloc failed: operation not supported #22

Closed
v03 opened this issue Apr 19, 2016 · 4 comments
Closed

prealloc failed: operation not supported #22

v03 opened this issue Apr 19, 2016 · 4 comments

Comments

@v03
Copy link

v03 commented Apr 19, 2016

When I try to setup encryption dir on the ZFS (ZoL 0.6.5.6-0ubuntu8 on ubuntu 16.04. gocryptfs is pulled from github using go get... and the latest commit is f035d3e) the files fail to be created.

Empty files work fine, but writing content to them fails.

$ gocryptfs -init foo                                                     ⏎
Choose a password for protecting your files.
Password: 
Repeat: 
The filesystem has been created successfully.

$ gocryptfs -debug -f foo bar
Debug output enabled
Password: 
Decrypting master key... 
done.

Now when I do touch bar/asdf it works fine. But trying to write something to it, using echo 1 > bar/asdf results in echo: write error: operation not supported and the following message in the gocryptfs running in foreground:

FS.GetAttr('asdf')
encryptPath 'asdf' -> './d2pkC2SxDZKpB2pWoii1sA==' (err: <nil>)
FS.GetAttr failed: 2=no such file or directory
encryptPath 'asdf' -> './d2pkC2SxDZKpB2pWoii1sA==' (err: <nil>)
getBackingPath: /home/123/foo + asdf -> /home/123/foo/d2pkC2SxDZKpB2pWoii1sA==
FS.GetAttr('asdf')
encryptPath 'asdf' -> './d2pkC2SxDZKpB2pWoii1sA==' (err: <nil>)
ino1068371: FUSE Write: offset=0 length=5
ino1068371: createHeader: prealloc failed: operation not supported

It doesn't matter what means of writing the file I use. cp, rsync etc all fail in the same way.

The very same version works if I put "foo" dir on tmpfs or ext4.

@rfjakob
Copy link
Owner

rfjakob commented Apr 19, 2016

Apparently ZFS does not support fallocate ( openzfs/zfs#326 ). gocryptfs uses fallocate to allocate space before it uses it, to prevent running out of space in the middle of an operation, leaving a broken file behind.
I'm not sure how to handle this best.

@v03
Copy link
Author

v03 commented Apr 20, 2016

Would it be possible to just check if we have enough space (+some to be safe)? At least under ZFS and simillar, to support it at all.

rfjakob added a commit that referenced this issue Apr 20, 2016
This makes gocryptfs work at all on ZFS.
See #22 .
@rfjakob
Copy link
Owner

rfjakob commented Apr 20, 2016

Ok I am checking now if fallocate is not supported at all. In this case, gocrypts will print a warning (only once) and continue working.

Now if the disk runs out of space while writing to a file, the incompletely written block (max 4kB) will be unreadable (it will report an I/O error if you try to read it). But you can still truncate or delete the file.

@rfjakob
Copy link
Owner

rfjakob commented Apr 27, 2016

Ok I guess this is resolved. Closing the ticket.

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

2 participants