Commit Graph

5 Commits

Author SHA1 Message Date
robk-tahoe
abae0345ad tahoefuse: fix typo which could cause data corruption
a typo in the 'flags2mode' code would wind up passing the O_APPEND
flag into the os open() call, which would cause the file to be opened
in 'strict append' mode, i.e. all writes extend the file, regardless of
calls to seek.

this causes a problem for tahoefuse in that the seek() calls made to
filehandles open through fuse would be ignored when write()s occurred.
this was evidenced by corruption seen when using rsync.  it turns out
that rsync actually makes overlapping writes in some cases, i.e. even
when writing a new fresh file out, it still doesn't write a simple
contiguous span of data, but will make writes overlapping data already
written. this is probably related to the way it manages data blocks 
internally for rolling checksums etc.  at any rate, this bug would 
thus cause rsync in those cases to write a chunk of duplicate data
into the file - leading to tahoe securely and reliably storing the
wrong data.

fixing this, so that non-append file opens do not pass O_APPEND seems
to eliminate this problem.
2008-05-07 16:42:20 -07:00
robk-tahoe
8179daee4a tahoefuse: return bogus but useful data to statfs call
previously tahoefuse returned the fs stat for the filesystem the fuse plugin
was running upon (e.g. '/').  this works ok until you need to copy more to
tahoe than the local machine has free disk space, at which point Finder will
refuse to copy 'too much' data.

this changes it so that tahoe always reports 2TiB used of an 8TiB filesystem
this is entirely bogus, but allows copies of up to 2TiB to be initiated.
2008-05-07 16:40:09 -07:00
robk-tahoe
4bbaaff49f macfuse: fix unicode handling
at one point I'd thrown in a 'str' since fuse api bits required a str instance
but tahoe returns unicode objects from its json parsing.  that, naturally
enough should really be a utf8 encoded str of the unicode object...
2008-03-06 17:43:25 -07:00
robk-tahoe
6cac9c479c macfuse: slew of updates
various updates to improve the functionality of the mac fuse plugin


1. caching

previously, the experimental tahoefuse plugin pre-loaded the whole
structure of the specified mount into memory at launch time. changes
which were made through that fuse plugin would be remembered, but any
changes made through other tahoe clients would not be reflected.

now directory contents are only loaded when needed, and the data is
cached for a limited time.  any use of Directory objects should first
call maybe_refresh() which will check the time since the cache was last
loaded, and if the data is older than some validity period (currently
26s) then the directory's contents will be refetched and reloaded.
this replaces the 'load_dir()' method of TFS

whenever a local change is made to a Directory object, or when the
aforementioned cache reloading notices a change in directory data, the
mtime of the directory is automatically updated.
 

2. stat / metadata

the retrieval of 'stat' information for getattr(), and the way that
metadata is handled, has been refactored to better reflect the fact that
metadata in tahoe is only represented by 'edges' (i.e entries in 
directories) not on 'nodes' (files or directories themselves) hence a 
stat lookup should be a query to the parent directory (specifically the 
parent specified by the path being queried in the case that a node has 
multiple parents) for details known by that directory for the given 
child, rather than a query to the child itself.

the TStat utility class for returning stat information to the python-
fuse layer has been extended to accept a 'metadata' argument in its
constructor.  any fields found in the metadata dict which match the
names of the stat attributes are loaded into the TStat object.  the 
'ctime' and 'mtime' attributes are translated to st_ctime and st_mtime
to mesh with the existing timestamp handling code. any fields specified
by kwargs to the constructor override things that might be loaded from
the metadata dict.

Directory objects now track their children as a dict mapping name to 
(child_obj, metadata) tuples. This is because the metadata in tahoe
will be stored exclusively on the edges of the graph. each Directory
maintains its own mtime however, and get_stat() calls will report the
mtime of a directory based on the last modification of the Directory 
object, not based on any mtime records from the parent directory's 
metadata for that child.  This addresses the fact that since directories
may be shared, a given parent may or may not reflect the latest changes,
however one of the Finder's behaviours is to examine the stat of a
directory, and not to bother doing a readdir() if the stat is unchanged.
i.e. unless directories report their changes in their stat info, the
Finder will not show changes within that directory.


3. refactoring

reporting of many error codes has been refactored to raise IOError
subclasses with the appropriate errno.  this exploits python-fuse's
built-in mechanism for catching IOError and reporting the errno
embedded within it automatically, while simplifying the code within
the plugin.

the add_child() method on TFS was removed in favour of simply having an
add_child() method on Directory objects. this provides a more OO
approach in that Directory is responsible for maintaining its own in
memory state and also writing changes back to the node.  similarly for
remove_child()

these changes, along with the new tfs.compose_url() method, 
significantly simplify and improve readability of mkdir, rename methods
along with the newer link and unlink.  these also get improved error
reporting.

various operations (chmod, chown, truncate, utime) are now ignored.
previously they would report an unsupported operation (EOPNOTSUPP)
but now are simply logged and ignored.  this surpresses errors caused
by some client programs which try to use these operations, but at the
moment those operations are meaningless to the tahoe filesystem anyway.


4. link / unlink / rmdir

link, symlink calls are now supported, though with semantics differing
from posix, both equivalent.  unlink, rmdir calls are now supported, 
also equivalent.

link or symlink calls duplicate the uri of the named source and adds it
as a child of another directory according to the destination path.  for
directories, this creates a 'hard' link, i.e. the same directory will
appear in multiple locations within the filesystem, and changes in 
any place will be reflected everywhere.  for files, by contrast, since
the uri being duplicated is an immutable CHK uri, link/symlink for files
is equivalent to a copy - though significantly cheaper. (a file copy
with the fuse plugin is likely to cause a new file to be written and
uploaded, the link command simply adds an entry referring to an
existing uri)

in testing, the 'ln' command is unable to make hard links (i.e. call
link()) for directories, though symlink ('ln -s') is supported. 
either forms works equivalently for files.

unlink and rmdir both remove the specified entry from its parent
directory.


5. logging

the 'tfuse.log' file now only reports launches of the fuse plugin. once
the plugin has parsed the options, it reopens the log file with the
name of the mount, e.g. tfuse.root_dir.log, so that multiple instances
running concurrently will not interfere with each others' logging.


6. bug fixes

the tmp_file in the cache dir backing files opened for write was
intermittently failing to open the file.  added O_CREAT to the os.open
call so that files will be created if missing, not throw errors.

a failure to correctly parse arguments if no mount (dir_cap) name was
given but also no fuse options were given has been fixed. now the
command 'tahoe fuse mountpoint' will correctly default to root_dir
also when running from source, arguments to tahoefuse were not handled
to correctly match the 'tahoe fuse ...' behaviour.
2008-02-29 20:12:41 -07:00
robk-tahoe
6f5ccb1707 macfuse: move macfuse files around to simplify pythonpath
the mac/macfuse subdirectory needed to be added to the pythonpath in order
to build a binary incorporating the mac fuse system.  this change should
make those modules accessible relative to the mac/ directory which is
implicitly included in the .app build process.
2008-02-19 17:18:17 -07:00