Skip to content

Instantly share code, notes, and snippets.

@davidstrauss
Last active December 13, 2015 21:38
Show Gist options
  • Save davidstrauss/4978565 to your computer and use it in GitHub Desktop.
Save davidstrauss/4978565 to your computer and use it in GitHub Desktop.

David

The high-level API currently renames unlinked files to ".fuse_hiddenXXX" and manages them using the standard file access callbacks provided by the FUSE-based file system. This creates poor performance for network-based FUSE file systems that already open file descriptors against files managed in a local cache. It's unnecessary to ever write such files up to a server.

For such file systems (including our recent work on FuseDAV), it would be better to just invoke unlink(), even while the file is still open. The hard_remove option is close, but it breaks further access by those other open handles. The low-level API allows managing references directly, but it also requires rewriting to an API that maps more poorly to WebDAV and -- according to the NTFS3g benchmarks -- runs slower.

Would a patch be welcome to add a never_hide option? I may roll one for internal use, regardless.

David

On some deeper inspection of the library code, it looks like this wouldn't be so trivial. Still, would there be interest in something like the ability to implement a high-level "hide" callback with the same parameters as "rename" that gets called instead of "rename" when implemented?

Miklos

-ohard_remove,nopath should work.

Ah, 'nopath' is undocumented it seems. I'll fix that.

David

Does that still provide the updated path on write and release when a rename has happened? I'd still like the following to work:

f = open("a.txt", O_RDWR);
write(f, "123", 3);
rename("a.txt", "b.txt");
write(f, "123", 3); // Writes to b.txt from this point.
close(f);

I just want a clean way to handle not writing to the server on the write/release here:

f = open("a.txt", O_RDWR);
unlink("a.txt");
write(f, "123", 3); // Writes only locally.
close(f);

Opening a temp file and then unlinking it is a common pattern we'd like to optimize.

Miklos

Okay, what you really want is fuse_op->flag_nullpath_ok = 1 and 'hard_remove'. That will provide the path when available but give NULL if the file has been unlinked. Note, your caching optimization will break if there are other hard links to the file. E.g.

fd = open("x");
link("x", "y");
unlink("x");
write(fd, ...);
close(fd);

will not work as expected.

David

Perfectly understandable (and, really, unavoidable with WebDAV). Thank you for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment