1. 28 May, 2010 13 commits
    • Nick Piggin's avatar
      fs: convert simple fs to new truncate · 3322e79a
      Nick Piggin authored
      Convert simple filesystems: ramfs, configfs, sysfs, block_dev to new truncate
      sequence.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3322e79a
    • npiggin@suse.de's avatar
      kill spurious reference to vmtruncate · 15c6fd97
      npiggin@suse.de authored
      Lots of filesystems calls vmtruncate despite not implementing the old
      ->truncate method.  Switch them to use simple_setsize and add some
      comments about the truncate code where it seems fitting.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      15c6fd97
    • npiggin@suse.de's avatar
      fs: introduce new truncate sequence · 7bb46a67
      npiggin@suse.de authored
      Introduce a new truncate calling sequence into fs/mm subsystems. Rather than
      setattr > vmtruncate > truncate, have filesystems call their truncate sequence
      from ->setattr if filesystem specific operations are required. vmtruncate is
      deprecated, and truncate_pagecache and inode_newsize_ok helpers introduced
      previously should be used.
      
      simple_setattr is introduced for simple in-ram filesystems to implement
      the new truncate sequence. Eventually all filesystems should be converted
      to implement a setattr, and the default code in notify_change should go
      away.
      
      simple_setsize is also introduced to perform just the ATTR_SIZE portion
      of simple_setattr (ie. changing i_size and trimming pagecache).
      
      To implement the new truncate sequence:
      - filesystem specific manipulations (eg freeing blocks) must be done in
        the setattr method rather than ->truncate.
      - vmtruncate can not be used by core code to trim blocks past i_size in
        the event of write failure after allocation, so this must be performed
        in the fs code.
      - convert usage of helpers block_write_begin, nobh_write_begin,
        cont_write_begin, and *blockdev_direct_IO* to use _newtrunc postfixed
        variants. These avoid calling vmtruncate to trim blocks (see previous).
      - inode_setattr should not be used. generic_setattr is a new function
        to be used to copy simple attributes into the generic inode.
      - make use of the better opportunity to handle errors with the new sequence.
      
      Big problem with the previous calling sequence: the filesystem is not called
      until i_size has already changed.  This means it is not allowed to fail the
      call, and also it does not know what the previous i_size was. Also, generic
      code calling vmtruncate to truncate allocated blocks in case of error had
      no good way to return a meaningful error (or, for example, atomically handle
      block deallocation).
      
      Cc: Christoph Hellwig <hch@lst.de>
      Acked-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7bb46a67
    • Randy Dunlap's avatar
      fs/super: fix kernel-doc warning · 7000d3c4
      Randy Dunlap authored
      Fix fs/super.c kernel-doc warning and function notation:
      Warning(fs/super.c:957): No description found for parameter 'sb'
      Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7000d3c4
    • Erik van der Kouwe's avatar
      fs/minix: bugfix, number of indirect block ptrs per block depends on block size · 0ab7620a
      Erik van der Kouwe authored
      The MINIX filesystem driver used a constant number of indirect block
      pointers in an indirect block. This worked only for filesystems with 1kb
      block, while the MINIX default block size is now 4kb. As a consequence,
      large files were read incorrectly on such filesystems and writing a
      large file would cause the filesystem to become corrupted. This patch
      computes the number of indirect block pointers based on the block size,
      making the driver work for each block size.
      
      I would like to thank Feiran Zheng ('Fam') for pointing out the cause
      of the corruption.
      Signed-off-by: default avatarErik van der Kouwe <vdkouwe@cs.vu.nl>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      0ab7620a
    • Christoph Hellwig's avatar
      rename the generic fsync implementations · 1b061d92
      Christoph Hellwig authored
      We don't name our generic fsync implementations very well currently.
      The no-op implementation for in-memory filesystems currently is called
      simple_sync_file which doesn't make too much sense to start with,
      the the generic one for simple filesystems is called simple_fsync
      which can lead to some confusion.
      
      This patch renames the generic file fsync method to generic_file_fsync
      to match the other generic_file_* routines it is supposed to be used
      with, and the no-op implementation to noop_fsync to make it obvious
      what to expect.  In addition add some documentation for both methods.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      1b061d92
    • Christoph Hellwig's avatar
      drop unused dentry argument to ->fsync · 7ea80859
      Christoph Hellwig authored
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7ea80859
    • Julia Lawall's avatar
      fs: Add missing mutex_unlock · cc967be5
      Julia Lawall authored
      Add a mutex_unlock missing on the error path.  At other exists from the
      function that return an error flag, the mutex is unlocked, so do the same
      here.
      
      The semantic match that finds this problem is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @@
      expression E1;
      @@
      
      * mutex_lock(E1,...);
        <+... when != E1
        if (...) {
          ... when != E1
      *   return ...;
        }
        ...+>
      * mutex_unlock(E1,...);
      // </smpl>
      Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      cc967be5
    • Al Viro's avatar
      Fix racy use of anon_inode_getfd() in perf_event.c · ea635c64
      Al Viro authored
      once anon_inode_getfd() is called, you can't expect *anything* about
      struct file that descriptor points to - another thread might be doing
      whatever it likes with descriptor table at that point.
      
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      ea635c64
    • Al Viro's avatar
      get rid of the magic around f_count in aio · d7065da0
      Al Viro authored
      __aio_put_req() plays sick games with file refcount.  What
      it wants is fput() from atomic context; it's almost always
      done with f_count > 1, so they only have to deal with delayed
      work in rare cases when their reference happens to be the
      last one.  Current code decrements f_count and if it hasn't
      hit 0, everything is fine.  Otherwise it keeps a pointer
      to struct file (with zero f_count!) around and has delayed
      work do __fput() on it.
      
      Better way to do it: use atomic_long_add_unless( , -1, 1)
      instead of !atomic_long_dec_and_test().  IOW, decrement it
      only if it's not the last reference, leave refcount alone
      if it was.  And use normal fput() in delayed work.
      
      I've made that atomic_long_add_unless call a new helper -
      fput_atomic().  Drops a reference to file if it's safe to
      do in atomic (i.e. if that's not the last one), tells if
      it had been able to do that.  aio.c converted to it, __fput()
      use is gone.  req->ki_file *always* contributes to refcount
      now.  And __fput() became static.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d7065da0
    • Neil Brown's avatar
      VFS: fix recent breakage of FS_REVAL_DOT · 176306f5
      Neil Brown authored
      Commit 1f36f774 broke FS_REVAL_DOT semantics.
      
      In particular, before this patch, the command
         ls -l
      in an NFS mounted directory would always check if the directory on the server
      had changed and if so would flush and refill the pagecache for the dir.
      After this patch, the same "ls -l" will repeatedly return stale date until
      the cached attributes for the directory time out.
      
      The following patch fixes this by ensuring the d_revalidate is called by
      do_last when "." is being looked-up.
      link_path_walk has already called d_revalidate, but in that case LOOKUP_OPEN
      is not set so nfs_lookup_verify_inode chooses not to do any validation.
      
      The following patch restores the original behaviour.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      176306f5
    • Al Viro's avatar
      Revert "anon_inode: set S_IFREG on the anon_inode" · 1eb2cbb6
      Al Viro authored
      This reverts commit a7cf4145.
      1eb2cbb6
    • Linus Torvalds's avatar
  2. 27 May, 2010 27 commits