Skip to content
  1. Mar 25, 2011
    • Dave Chinner's avatar
      fs: remove inode_lock from iput_final and prune_icache · f283c86a
      Dave Chinner authored
      
      
      Now that inode state changes are protected by the inode->i_lock and
      the inode LRU manipulations by the inode_lru_lock, we can remove the
      inode_lock from prune_icache and the initial part of iput_final().
      
      instead of using the inode_lock to protect the inode during
      iput_final, use the inode->i_lock instead. This protects the inode
      against new references being taken while we change the inode state
      to I_FREEING, as well as preventing prune_icache from grabbing the
      inode while we are manipulating it. Hence we no longer need the
      inode_lock in iput_final prior to setting I_FREEING on the inode.
      
      For prune_icache, we no longer need the inode_lock to protect the
      LRU list, and the inodes themselves are protected against freeing
      races by the inode->i_lock. Hence we can lift the inode_lock from
      prune_icache as well.
      
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      f283c86a
    • Dave Chinner's avatar
      fs: Lock the inode LRU list separately · 02afc410
      Dave Chinner authored
      
      
      Introduce the inode_lru_lock to protect the inode_lru list. This
      lock is nested inside the inode->i_lock to allow the inode to be
      added to the LRU list in iput_final without needing to deal with
      lock inversions. This keeps iput_final() clean and neat.
      
      Further, where marking the inode I_FREEING and removing it from the
      LRU, move the LRU list manipulation within the inode->i_lock to keep
      the list manipulation consistent with iput_final. This also means
      that most of the open coded LRU list removal + unused inode
      accounting can now use the inode_lru_list_del() wrappers which
      cleans the code up further.
      
      However, this locking change means what the LRU traversal in
      prune_icache() inverts this lock ordering and needs to use trylock
      semantics on the inode->i_lock to avoid deadlocking. In these cases,
      if we fail to lock the inode we move it to the back of the LRU to
      prevent spinning on it.
      
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      02afc410
    • Dave Chinner's avatar
      fs: factor inode disposal · b2b2af8e
      Dave Chinner authored
      
      
      We have a couple of places that dispose of inodes. factor the
      disposal into evict() to isolate this code and make it simpler to
      peel away the inode_lock from the code.
      
      While doing this, change the logic flow in iput_final() to separate
      the different cases that need to be handled to make the transitions
      the inode goes through more obvious.
      
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b2b2af8e
    • Dave Chinner's avatar
      fs: protect inode->i_state with inode->i_lock · 250df6ed
      Dave Chinner authored
      
      
      Protect inode state transitions and validity checks with the
      inode->i_lock. This enables us to make inode state transitions
      independently of the inode_lock and is the first step to peeling
      away the inode_lock from the code.
      
      This requires that __iget() is done atomically with i_state checks
      during list traversals so that we don't race with another thread
      marking the inode I_FREEING between the state check and grabbing the
      reference.
      
      Also remove the unlock_new_inode() memory barrier optimisation
      required to avoid taking the inode_lock when clearing I_NEW.
      Simplify the code by simply taking the inode->i_lock around the
      state change and wakeup. Because the wakeup is no longer tricky,
      remove the wake_up_inode() function and open code the wakeup where
      necessary.
      
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      250df6ed
    • Jesper Juhl's avatar
      autofs4: Do not potentially dereference NULL pointer returned by fget() in... · 3dc8fe4d
      Jesper Juhl authored
      
      autofs4: Do not potentially dereference NULL pointer returned by fget() in autofs_dev_ioctl_setpipefd()
      
      In fs/autofs4/dev-ioctl.c::autofs_dev_ioctl_setpipefd() we call fget(),
      which may return NULL, but we do not explicitly test for that NULL return
      so we may end up dereferencing a NULL pointer - bad.
      
      When I originally submitted this patch I had chosen EBUSY as the return
      value to use if this happens. Ian Kent was kind enough to explain why that
      would most likely be wrong and why EBADF should most likely be used
      instead. This version of the patch uses EBADF.
      
      Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3dc8fe4d
    • Ian Kent's avatar
      autofs4 - remove autofs4_lock · e7854723
      Ian Kent authored
      
      
      The autofs4_lock introduced by the rcu-walk changes has unnecessarily
      broad scope. The locking is better handled by the per-autofs super
      block lookup_lock.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      e7854723
    • Ian Kent's avatar
      autofs4 - fix d_manage() return on rcu-walk · 83fb96bf
      Ian Kent authored
      
      
      The daemon never needs to block and, in the rcu-walk case an error
      return isn't used, so always return zero.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      83fb96bf
    • Ian Kent's avatar
      autofs4 - fix autofs4_expire_indirect() traversal · d4a85e35
      Ian Kent authored
      
      
      The vfs-scale changes changed the traversal used in
      autofs4_expire_indirect() from a list to a depth first tree traversal
      which isn't right.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d4a85e35
    • Ian Kent's avatar
      autofs4 - fix dentry leak in autofs4_expire_direct() · f9398c23
      Ian Kent authored
      
      
      There is a missing dput() when returning from autofs4_expire_direct()
      when we see that the dentry is already a pending mount.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      f9398c23
    • Ian Kent's avatar
      autofs4 - reinstate last used update on access · 3c319985
      Ian Kent authored
      
      
      When direct (and offset) mounts were introduced the the last used
      timeout could no longer be updated in ->d_revalidate(). This is
      because covered direct mounts would be followed over without calling
      the autofs file system. As a result the definition of the busyness
      check for all entries was changed to be "actually busy" being an open
      file or working directory within the automount. But now we have a call
      back in the follow so the last used update on any access can be
      re-instated. This requires DCACHE_MANAGE_TRANSIT to always be set.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3c319985
    • Ian Kent's avatar
      vfs - check non-mountpoint dentry might block in __follow_mount_rcu() · 62a7375e
      Ian Kent authored
      
      
      When following a mount in rcu-walk mode we must check if the incoming dentry
      is telling us it may need to block, even if it isn't actually a mountpoint.
      
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      62a7375e
  2. Mar 24, 2011