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
Copying a file onto ceph-fuse fails when the source is read-only #3919
Comments
Trying to copy a read-only file onto a ceph-fuse filesystem fails, returning an `EACCES` error. This happens when the destination doesn't exist yet, and a new file is created. By checking that the error matches, and that the destination file is empty, we can fix this issue while waiting for a proper Ceph fix to be upstreamed. Fixes: libuv#3919 Refs: nodejs/node#37284 Refs: libuv#3117 Refs: libuv#3322
This sounds like a bug in the ceph kernel driver. I am not sure it is up to libuv to address driver bugs? |
Not sure myself, I provided the fix as we originally believed it was an error with the I'm also bringing this up to the Ceph tracker as soon as my account gets activated, which if resolved properly could also fix other problems that the PR i provided can't work around, such as a file manually created as read-only and then truncated with |
If it was created read-only already, then the required open permissions ( |
I think I didn't explain myself properly, sorry, I meant manual opening and manually trimming in sequence, like: var fd = fs.openSync('file', 'w', 0o400);
fs.truncateSync(fd, 0); Although this code doesn't make sense, it would incur in the same issue. That's all I meant. |
Trying to copy a read-only file onto a ceph-fuse filesystem fails, returning an `EACCES` error. This happens when the destination doesn't exist yet, and a new file is created. By checking that the error matches, and that the destination file is empty, we can fix this issue while waiting for a proper Ceph fix to be upstreamed. Fixes: #3919 Refs: nodejs/node#37284 Refs: #3117 Refs: #3322
Description
Trying to copy a read-only file onto a
ceph-fuse
filesystem fails, currently unknown if it affects CephFS itself. This is an outstanding issue introduced with 278cfa0 in August 2020, and has been afflicting releases since Node v12.19.0.Replication
Using Node the simplest way to reproduce the error is the following one-liner, where
/tmp/foo
has 0444 mode:Details
When
uv__fs_copyfile()
is called, while opening the destination file it creates it with the mode of the source file. Since it can't be opened exclusively, after some checks it attempts to truncate it:libuv/src/unix/fs.c
Lines 1306 to 1310 in 9581e3d
When
ftruncate()
is called on a read-only file on CephFS though, it returns anEACCES
error, which then stops the file copying. This can be solved in 3 ways:+w
while opening the file to ensure that the error doesn't occur:fchmod()
in the next instruction:libuv/src/unix/fs.c
Line 1313 in 9581e3d
I assumed that
ftruncate()
was always called, even on new files, to reduce the potential for races when opened non exclusively, so I chose option 3 and wrote a tiny exception handler in the style of the surrounding code to make sure to adhere to the standard. PR incoming in a few moments.I'm also opening an issue on the Ceph tracker, but I think that using the check to guard against those errors would prove beneficial, and hopefully be readily available as soon as Node v20.
References
The text was updated successfully, but these errors were encountered: