From: Goswin v. B. <gos...@we...> - 2014-03-25 09:56:22
|
On Sun, Mar 09, 2014 at 11:08:56AM +0100, Hans Beckerus wrote: > On 2014-03-07 12:59, Hans Beckérus wrote: > > Hi. If a user mounts a fuse file system like below > > > > /path/adir -> /path/bdir > > > > and then moves a file from /path/cdir to /path/adir the operation is > > instant (which is understandable since no actual media access is > > required). > > But if we instead move a file from /path/cdir to /path/bdir then the > > file will be created and written to using a set of fuse callbacks to > > the file system. > > This is also understandable and makes perfect sense, but it is slow :( > > Since in reality this is the same as moving the file to adir, would it > > be possible to > > bypass the fuse operations completely to speed up the operation? > > Eventhough all the write() operations makes a lot of sense, it would > > still be interesting > > to know if someone have any ideas. I can easily detect the scenario in > > the implementation, sure, but fuse will still bombard it with write() > > calls. What will happen if > > I simply moved the file the "real" way and then simply returned EOF on > > the first write? Would that be asking for trouble :) I am using the > > high-level API. > I guess this is not that easy as it sounds. First of all there is no > guarantee that source and destination actually belongs to the same file > system. > Secondly, as a file system written on top of FUSE it actually does not > get information about the source file, does it? All it gets is a request to > create a new file and write to it. Would this be possible using the > low-level API? > > > Thanks. > > Hans No. The problem is the "mv" binary. It checks wether the old and new path belong to the same filesystem (which they don't) and then does a copy + delete instead of calling rename() directly. Also in general there is no way to know wether a fuse filesystem can be bypassed like you suggest. What if it wants to compress the file on write, encrypt it or add a checksum to it on the fly? So adding any kind of workaround to "mv" for this is out of the question. What you can do is write yourself an alias for "mv" that checks the source and destination paths and if it is a move from or to your fuse filesystem then it actualy calls mv with the underlying paths. But beware of cache inconsistencies then. The new file might not appear below the fuse mountpoint for a while if you have caching enabled. MfG Goswin |