24 Feb, 2008

1 commit

  • I added a nasty local variable shadowing bug to fuse in 2.6.24, with the
    result, that the 'default_permissions' mount option is basically ignored.

    How did this happen?

    - old err declaration in inner scope
    - new err getting declared in outer scope
    - 'return err' from inner scope getting removed
    - old declaration not being noticed

    -Wshadow would have saved us, but it doesn't seem practical for
    the kernel :(

    More testing would have also saved us :((

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

    Miklos Szeredi
     

09 Feb, 2008

1 commit


08 Feb, 2008

2 commits


07 Feb, 2008

3 commits

  • Libfuse basically creates a new thread for each new request. This is fine for
    synchronous requests, which are naturally limited. However background
    requests (especially writepage) can cause a thread creation storm.

    To avoid this, limit the number of background requests available to userspace.

    This is done by introducing another queue for background requests, and a
    counter for the number of "active" requests, which are currently available for
    userspace.

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

    Miklos Szeredi
     
  • Move the fields 'dentry' and 'vfsmount' into the request specific union, since
    these are only used for the RELEASE request.

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

    Miklos Szeredi
     
  • Invalidate attributes on create, since st_ctime is updated. Reported by
    Szabolcs Szakacsits.

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

    Miklos Szeredi
     

25 Jan, 2008

4 commits


30 Nov, 2007

6 commits

  • Invalidate attributes on rename, since some filesystems may update
    st_ctime. Reported by Szabolcs Szakacsits

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

    Miklos Szeredi
     
  • I found problems accessing (executing) previously existing files, until
    I did chmod on them (or setattr).

    If the fi->attr_version is not initialized, then it could be
    larger than fc->attr_version until a setattr is executed, and as a
    result the inode attributes would never be set.

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

    John Muir
     
  • FUSE_FILE_OPS is meant to signal that the kernel will send the open file to to
    the userspace filesystem for operations on open files, so that sillyrenaming
    unlinked files becomes unnecessary.

    However this needs VFS changes, which won't make it into 2.6.24.

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

    Miklos Szeredi
     
  • Some open flags (O_APPEND, O_DIRECT) can be changed with fcntl(F_SETFL, ...)
    after open, but fuse currently only sends the flags to userspace in open.

    To make it possible to correcly handle changing flags, send the
    current value to userspace in each read and write.

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

    Miklos Szeredi
     
  • Extract repeated code into helper function, as suggested by Akpm.

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

    Miklos Szeredi
     
  • Currently reading a fuse file will stop at cached i_size and return
    EOF, even though the file might have grown since the attributes were
    last updated.

    So detect if trying to read past EOF, and refresh the attributes
    before continuing with the read.

    Thanks to mpb for the report.

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

    Miklos Szeredi
     

15 Nov, 2007

1 commit


19 Oct, 2007

11 commits

  • There are cases when the filesystem will be passed the buffer from a single
    read or write call, namely:

    1) in 'direct-io' mode (not O_DIRECT), read/write requests don't go
    through the page cache, but go directly to the userspace fs

    2) currently buffered writes are done with single page requests, but
    if Nick's ->perform_write() patch goes it, it will be possible to
    do larger write requests. But only if the original write() was
    also bigger than a page.

    In these cases the filesystem might want to give a hint to the app
    about the optimal I/O size.

    Allow the userspace filesystem to supply a blksize value to be returned by
    stat() and friends. If the field is zero, it defaults to the old
    PAGE_CACHE_SIZE value.

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

    Miklos Szeredi
     
  • For mandatory locking the userspace filesystem needs to know the lock
    ownership for read, write and truncate operations.

    This patch adds the necessary fields to the protocol.

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

    Miklos Szeredi
     
  • This patch adds a new helper function fuse_write_fill() which makes it
    possible to send WRITE requests asynchronously.

    A new flag for WRITE requests is also added which indicates that this a write
    from the page cache, and not a "normal" file write.

    This patch is in preparation for writable mmap support.

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

    Miklos Szeredi
     
  • Each WRITE request must carry a valid file descriptor. When a page is written
    back from a memory mapping, the file through which the page was dirtied is not
    available, so a new mechananism is needed to find a suitable file in
    ->writepage(s).

    A list of fuse_files is added to fuse_inode. The file is removed from the
    list in fuse_release().

    This patch is in preparation for writable mmap support.

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

    Miklos Szeredi
     
  • It is trivial to add support for flock(2) semantics to the existing protocol,
    by setting the lock owner field to the file pointer, and passing a new
    FUSE_LK_FLOCK flag with the locking request.

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

    Miklos Szeredi
     
  • This patch allows fuse filesystems to implement open(..., O_TRUNC) as a single
    request, instead of separate truncate and open requests.

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

    Miklos Szeredi
     
  • 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

11 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
     
  • Don't return -ENOENT for a read() on the fuse device when the request was
    aborted. Instead return -ENODEV, meaning the filesystem has been
    force-umounted or aborted.

    Previously ENOENT meant that the request was interrupted, but now the
    'aborted' flag is not set in case of interrupts.

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

    Miklos Szeredi
     
  • Don't set 'aborted' flag on a request if it's interrupted. We have to wait
    for the answer anyway, and this would only a very little time while copying
    the reply.

    This means, that write() on the fuse device will not return -ENOENT during
    normal operation, only if the filesystem is aborted by a forced umount or
    through the fusectl interface.

    This could simplify userspace code somewhat when backward compatibility with
    earlier kernel versions is not required.

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

    Miklos Szeredi
     
  • Move dput/mntput pair from request_end() to fuse_release_end(), because
    there's no other place they are used.

    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
     
  • Aufs seems to depend on a positive i_nlink value. So fill in a dummy but sane
    value for the root inode at mount time.

    The inode attributes are refreshed with the correct values at the first
    opportunity.

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

    Miklos Szeredi
     
  • Other than truncate, there are two cases, when fuse tries to get rid
    of cached pages:

    a) in open, if KEEP_CACHE flag is not set
    b) in getattr, if file size changed spontaneously

    Until now invalidate_mapping_pages() were used, which didn't get rid
    of mapped pages. This is wrong, and becomes more wrong as dirty pages
    are introduced. So instead properly invalidate all pages with
    invalidate_inode_pages2().

    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
     
  • Use wake_up_all instead of wake_up in put_reserved_req(), otherwise it is
    possible that the right task is not woken up.

    Also create a separate reserved_req_waitq in addition to the blocked_waitq,
    since they fulfill totally separate functions.

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

    Miklos Szeredi