19 Oct, 2007

5 commits

  • Add two new flags for setattr: FATTR_ATIME_NOW and FATTR_MTIME_NOW. These
    mean, that atime or mtime should be changed to the current time.

    Also it is now possible to update atime or mtime individually, not just
    together.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Clean up supplying open file to the setattr operation. In addition to being a
    cleanup it prepares for the changes in the way the open file is passed to the
    setattr method.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Add necessary protocol changes for supplying a file handle with the getattr
    operation. Step the API version to 7.9.

    This patch doesn't actually supply the file handle, because that needs some
    kind of VFS support, which we haven't yet been able to agree upon.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Getattr and lookup operations can be running in parallel to attribute changing
    operations, such as write and setattr.

    This means, that if for example getattr was slower than a write, the cached
    size attribute could be set to a stale value.

    To prevent this race, introduce a per-filesystem attribute version counter.
    This counter is incremented whenever cached attributes are modified, and the
    incremented value stored in the inode.

    Before storing new attributes in the cache, getattr and lookup check, using
    the version number, whether the attributes have been modified during the
    request's lifetime. If so, the returned attributes are not cached, because
    they might be stale.

    Thanks to Jakub Bogusz for the bug report and test program.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Miklos Szeredi
    Cc: Jakub Bogusz
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • The following operation didn't check if sending the request was allowed:

    setattr
    listxattr
    statfs

    Some other operations don't explicitly do the check, but VFS calls
    ->permission() which checks this.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

17 Oct, 2007

5 commits

  • Define a new function fuse_refresh_attributes() that conditionally refreshes
    the attributes based on the validity timeout.

    In fuse_permission() only refresh the attributes for checking the execute bits
    if necessary.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • The VFS checks sticky bits on the parent directory even if the filesystem
    defines it's own ->permission(). In some situations (sshfs, mountlo, etc) the
    user does have permission to delete a file even if the attribute based
    checking would not allow it.

    So work around this by storing the permission bits separately and returning
    them in stat(), but cutting the permission bits off from inode->i_mode.

    This is slightly hackish, but it's probably not worth it to add new
    infrastructure in VFS and a slight performance penalty for all filesystems,
    just for the sake of fuse.

    [Jan Engelhardt] cosmetic fixes
    Signed-off-by: Miklos Szeredi
    Cc: Jan Engelhardt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • fuse_permission() didn't refresh inode attributes before using them, even if
    the validity has already expired.

    Thanks to Junjiro Okajima for spotting this.

    Also remove some old code to unconditionally refresh the attributes on the
    root inode.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Memory mappings were only truncated on an explicit truncate, but not when the
    file size was changed externally.

    Fix this by moving the truncation code from fuse_setattr to
    fuse_change_attributes.

    Yes, there are races between write and and external truncation, but we can't
    really do anything about them.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Make lifetime of 'struct fuse_file' independent from 'struct file' by adding a
    reference counter and destructor.

    This will enable asynchronous page writeback, where it cannot be guaranteed,
    that the file is not released while a request with this file handle is being
    served.

    The actual RELEASE request is only sent when there are no more references to
    the fuse_file.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

24 May, 2007

1 commit

  • The wrong lookup flag was tested in ->create() causing havoc (error or
    Oops) when a regular file was created with mknod() in a fuse filesystem.

    Thanks to J. Cameijo Cerdeira for the report.

    Kernels 2.6.18 onward are affected. Please apply to -stable as well.

    Signed-off-by: Miklos Szeredi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

09 Apr, 2007

1 commit


13 Feb, 2007

1 commit

  • Many struct inode_operations in the kernel can be "const". Marking them const
    moves these to the .rodata section, which avoids false sharing with potential
    dirty data. In addition it'll catch accidental writes at compile time to
    these shared resources.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

09 Dec, 2006

1 commit


08 Dec, 2006

2 commits


26 Nov, 2006

1 commit

  • Fix bug in certain error paths of lookup routines. The request object was
    reused for sending FORGET, which is illegal. This bug could cause an Oops
    in 2.6.18. In earlier versions it might silently corrupt memory, but this
    is very unlikely.

    These error paths are never triggered by libfuse, so this wasn't noticed
    even with the 2.6.18 kernel, only with a filesystem using the raw kernel
    interface.

    Thanks to Russ Cox for the bug report and test filesystem.

    Signed-off-by: Miklos Szeredi
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

17 Oct, 2006

4 commits

  • There's no locking for ->d_revalidate, so fuse_dentry_revalidate() should use
    dget_parent() instead of simply dereferencing ->d_parent.

    Due to topology changes in the directory tree the parent could become negative
    or be destroyed while being used. There hasn't been any reports about this
    yet.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Fuse considered it an error (EIO) if lookup returned a directory inode, to
    which a dentry already refered. This is because directory aliases are not
    allowed.

    But in a network filesystem this could happen legitimately, if a directory is
    moved on a remote client. This patch attempts to relax the restriction by
    trying to first evict the offending alias from the cache. If this fails, it
    still returns an error (EBUSY).

    A rarer situation is if an mkdir races with an indenpendent lookup, which
    finds the newly created directory already moved. In this situation the mkdir
    should return success, but that would be incorrect, since the dentry cannot be
    instantiated, so return EBUSY.

    Previously checking for a directory alias and instantiation of the dentry
    weren't done atomically in lookup/mkdir, hence two such calls racing with each
    other could create aliased directories. To prevent this introduce a new
    per-connection mutex: fuse_conn->inst_mutex, which is taken for instantiations
    with a directory inode.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • An inode could be returned by independent parallel lookups, in this case an
    update of the lookup counter could be lost resulting in a memory leak in
    userspace.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Fuse didn't always call i_size_write() with i_mutex held which caused rare
    hangs on SMP/32bit. This bug has been present since fuse-2.2, well before
    being merged into mainline.

    The simplest solution is to protect i_size_write() with the per-connection
    spinlock. Using i_mutex for this purpose would require some restructuring of
    the code and I'm not even sure it's always safe to acquire i_mutex in all
    places i_size needs to be set.

    Since most of vmtruncate is already duplicated for other reasons, duplicate
    the remaining part as well, making all i_size_write() calls internal to fuse.

    Using i_size_write() was unnecessary in fuse_init_inode(), since this function
    is only called on a newly created locked inode.

    Reported by a few people over the years, but special thanks to Dana Henriksen
    who was persistent enough in helping me debug it.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

01 Oct, 2006

1 commit

  • Some filesystems, instead of simply decrementing i_nlink, simply zero it
    during an unlink operation. We need to catch these in addition to the
    decrement operations.

    Signed-off-by: Dave Hansen
    Acked-by: Christoph Hellwig
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dave Hansen
     

30 Sep, 2006

1 commit

  • In the "operation does permission checking" model used by fuse, chdir
    permission is not checked, since there's no chdir method.

    For this case set a lookup flag, which will be passed to ->permission(), so
    fuse can distinguish it from permission checks for other operations.

    Signed-off-by: Miklos Szeredi
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

01 Aug, 2006

2 commits

  • It is entirely possible (though rare) that jiffies half-wraps around, while a
    dentry/inode remains in the cache. This could mean that the dentry/inode is
    not invalidated for another half wraparound-time.

    To get around this problem, use 64-bit jiffies. The only problem with this is
    that dentry->d_time is 32 bits on 32-bit archs. So use d_fsdata as the high
    32 bits. This is an ugly hack, but far simpler, than having to allocate
    private data just for this purpose.

    Since 64-bit jiffies can be assumed never to wrap around, simple comparison
    can be used, and a zero time value can represent "invalid".

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • An attribute and entry timeout of zero should mean, that the entity is
    invalidated immediately after the operation. Previously invalidation only
    happened at the next clock tick.

    Reported and tested by Craig Davies.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

26 Jun, 2006

1 commit

  • Don't put requests into the background when a fatal interrupt occurs while the
    request is in userspace. This removes a major wart from the implementation.

    Backgrounding of requests was introduced to allow breaking of deadlocks.
    However now the same can be achieved by aborting the filesystem through the
    'abort' sysfs attribute.

    This is a change in the interface, but should not cause problems, since these
    kinds of deadlocks never happen during normal operation.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

11 Apr, 2006

1 commit

  • FUSE allocated most requests from a fixed size pool filled at mount time.
    However in some cases (release/forget) non-pool requests were used. File
    locking operations aren't well served by the request pool, since they may
    block indefinetly thus exhausting the pool.

    This patch removes the request pool and always allocates requests on demand.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

29 Mar, 2006

1 commit

  • This is a conversion to make the various file_operations structs in fs/
    const. Basically a regexp job, with a few manual fixups

    The goal is both to increase correctness (harder to accidentally write to
    shared datastructures) and reducing the false sharing of cachelines with
    things that get dirty in .data (while .rodata is nicely read only and thus
    cache clean)

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

01 Mar, 2006

1 commit

  • If negative entries (nodeid == 0) were sent in reply to LOOKUP requests,
    two bugs could be triggered:

    - looking up a negative entry would return -EIO,

    - revaildate on an entry which turned negative would send a FORGET
    request with zero nodeid, which would cause an abort() in the
    library.

    The above would only happen if the 'negative_timeout=N' option was used,
    otherwise lookups reply -ENOENT, which worked correctly.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

17 Jan, 2006

2 commits


07 Jan, 2006

6 commits

  • Previously invalid types were quietly changed to regular files, but at
    revalidation the inode was changed to bad. This was rather inconsistent
    behavior.

    Now check if the type is valid on initial lookup, and return -EIO if not.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Change the way a too large request is handled. Until now in this case the
    device read returned -EINVAL and the operation returned -EIO.

    Make it more flexibible by not returning -EINVAL from the read, but restarting
    it instead.

    Also remove the fixed limit on setxattr data and let the filesystem provide as
    large a read buffer as it needs to handle the extended attribute data.

    The symbolic link length is already checked by VFS to be less than PATH_MAX,
    so the extra check against FUSE_SYMLINK_MAX is not needed.

    The check in fuse_create_open() against FUSE_NAME_MAX is not needed, since the
    dentry has already been looked up, and hence the name already checked.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Make file operations on a bad inode fail. This just makes things a
    bit more consistent.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Document some not-so-trivial functions.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Add support for caching negative dentries.

    Up till now, ->d_revalidate() always forced a new lookup on these. Now let
    the lookup method return a zero node ID (not used for anything else) meaning a
    negative entry, but with a positive cache timeout. The old way of signaling
    negative entry (replying ENOENT) still works.

    Userspace should check the ABI minor version to see whether sending a zero ID
    is allowed by the kernel or not.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Simplify fuse_lookup() and related functions.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

29 Nov, 2005

2 commits


07 Nov, 2005

1 commit

  • This patch passes the file handle supplied in iattr to userspace, in case the
    ->setattr() was invoked from sys_ftruncate(). This solves the permission
    checking (or lack thereof) in ftruncate() for the class of filesystems served
    by an unprivileged userspace process.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi