1. 14 10月, 2014 2 次提交
  2. 09 10月, 2014 1 次提交
    • I
      autofs - remove obsolete d_invalidate() from expire · b3ca406f
      Ian Kent 提交于
      Biederman's umount-on-rmdir series changes d_invalidate() to sumarily remove
      mounts under the passed in dentry regardless of whether they are busy
      or not. So calling this in fs/autofs4/expire.c:autofs4_tree_busy() is
      definitely the wrong thing to do becuase it will silently umount entries
      instead of just cleaning stale dentrys.
      
      But this call shouldn't be needed and testing shows that automounting
      continues to function without it.
      
      As Al Viro correctly surmises the original intent of the call was to
      perform what shrink_dcache_parent() does.
      
      If at some time in the future I see stale dentries accumulating
      following failed mounts I'll revisit the issue and possibly add a
      shrink_dcache_parent() call if needed.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      b3ca406f
  3. 09 8月, 2014 1 次提交
  4. 24 1月, 2014 1 次提交
    • I
      autofs: fix symlinks aren't checked for expiry · 8dc51fe5
      Ian Kent 提交于
      The autofs4 module doesn't consider symlinks for expire as it did in the
      older autofs v3 module (so it's actually a long standing regression).
      
      The user space daemon has focused on the use of bind mounts instead of
      symlinks for a long time now and that's why this has not been noticed.
      But with the future addition of amd map parsing to automount(8), not to
      mention amd itself (of am-utils), symlink expiry will be needed.
      
      The direct and offset mount types can't be symlinks and the tree mounts of
      version 4 were always real mounts so only indirect mounts need expire
      symlinks.
      
      Since the current users of the autofs4 module haven't reported this as a
      problem to date this patch probably isn't a candidate for backport to
      stable.
      Signed-off-by: NIan Kent <ikent@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8dc51fe5
  5. 05 7月, 2013 1 次提交
  6. 07 5月, 2013 1 次提交
    • D
      autofs - remove autofs dentry mount check · ce8a5dbd
      David Jeffery 提交于
      When checking if an autofs mount point is busy it isn't sufficient to
      only check if it's a mount point.
      
      For example, if the mount of an offset mountpoint in a tree is denied
      for this host by its export and the dentry becomes a process working
      directory the check incorrectly returns the mount as not in use at
      expire.
      
      This can happen since the default when mounting within a tree is
      nostrict, which means ingnore mount fails on mounts within the tree and
      continue.  The nostrict option is meant to allow mounting in this case.
      Signed-off-by: NDavid Jeffery <djeffery@redhat.com>
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ce8a5dbd
  7. 14 12月, 2012 1 次提交
    • I
      autofs4 - dont clear DCACHE_NEED_AUTOMOUNT on rootless mount · f55fb0c2
      Ian Kent 提交于
      The DCACHE_NEED_AUTOMOUNT flag is cleared on mount and set on expire
      for autofs rootless multi-mount dentrys to prevent unnecessary calls
      to ->d_automount().
      
      Since DCACHE_MANAGE_TRANSIT is always set on autofs dentrys ->d_managed()
      is always called so the check can be done in ->d_manage() without the
      need to change the flag. This still avoids unnecessary calls to
      ->d_automount(), adds negligible overhead and eliminates a seriously
      ugly check in the expire code.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f55fb0c2
  8. 17 8月, 2012 2 次提交
    • I
      autofs4 - fix expire check · d807ff83
      Ian Kent 提交于
      In some cases when an autofs indirect mount is contained in a file
      system that is marked as shared (such as when systemd does the
      equivalent of "mount --make-rshared /" early in the boot), mounts
      stop expiring.
      
      When this happens the first expiry check on a mountpoint dentry in
      autofs_expire_indirect() sees a mountpoint dentry with a higher
      than minimal reference count. Consequently the dentry is condidered
      busy and the actual expiry check is never done.
      
      This particular check was originally meant as an optimisation to
      detect a path walk in progress but with the addition of rcu-walk
      it can be ineffective anyway.
      
      Removing the test allows automounts to expire again since the
      actual expire check doesn't rely on the dentry reference count.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d807ff83
    • I
      autofs4 - fix get_next_positive_subdir() · a45440f0
      Ian Kent 提交于
      Following a report of a crash during an automount expire I found that
      the locking in fs/autofs4/expire.c:get_next_positive_subdir() was wrong.
      Not only is the locking wrong but the function is more complex than it
      needs to be.
      
      The function is meant to calculate (and dget) the next entry in the list
      of directories contained in the root of an autofs mount point (an autofs
      indirect mount to be precise). The main problem was that the d_lock of
      the owner of the list was not being taken when walking the list, which
      lead to list corruption under load. The only other lock that needs to
      be taken is against the next dentry candidate so it can be checked for
      usability.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a45440f0
  9. 14 2月, 2012 1 次提交
  10. 25 3月, 2011 4 次提交
  11. 18 1月, 2011 1 次提交
    • I
      autofs4 - fix get_next_positive_dentry() · c14cc63a
      Ian Kent 提交于
      The initialization condition in fs/autofs4/expire.c:get_next_positive_dentry()
      appears to be incorrect. If prev == NULL I believe that root should be
      returned.
      
      Further down, at the current dentry check for it being simple_positive()
      it looks like the d_lock for dentry p should be dropped instead of dentry
      ret, otherwise when p is assinged to ret we end up with no lock on p and
      a lost lock on ret, which leads to a deadlock.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      c14cc63a
  12. 16 1月, 2011 3 次提交
    • I
      autofs4: Add d_manage() dentry operation · b5b80177
      Ian Kent 提交于
      This patch required a previous patch to add the ->d_automount()
      dentry operation.
      
      Add a function to use the newly defined ->d_manage() dentry operation
      for blocking during mount and expire.
      
      Whether the VFS calls the dentry operations d_automount() and d_manage()
      is controled by the DMANAGED_AUTOMOUNT and DMANAGED_TRANSIT flags. autofs
      uses the d_automount() operation to callback to user space to request
      mount operations and the d_manage() operation to block walks into mounts
      that are under construction or destruction.
      
      In order to prevent these functions from being called unnecessarily the
      DMANAGED_* flags are cleared for cases which would cause this. In the
      common case the DMANAGED_AUTOMOUNT and DMANAGED_TRANSIT flags are both
      set for dentrys waiting to be mounted. The DMANAGED_TRANSIT flag is
      cleared upon successful mount request completion and set during expire
      runs, both during the dentry expire check, and if selected for expire,
      is left set until a subsequent successful mount request completes.
      
      The exception to this is the so-called rootless multi-mount which has
      no actual mount at its base. In this case the DMANAGED_AUTOMOUNT flag
      is cleared upon successful mount request completion as well and set
      again after a successful expire.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      b5b80177
    • I
      autofs4: Add d_automount() dentry operation · 10584211
      Ian Kent 提交于
      Add a function to use the newly defined ->d_automount() dentry operation
      for triggering mounts instead of doing the user space callback in ->lookup()
      and ->d_revalidate().
      
      Note, to be useful the subsequent patch to add the ->d_manage() dentry
      operation is also needed so the discussion of functionality is deferred to
      that patch.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      10584211
    • D
      Add a dentry op to allow processes to be held during pathwalk transit · cc53ce53
      David Howells 提交于
      Add a dentry op (d_manage) to permit a filesystem to hold a process and make it
      sleep when it tries to transit away from one of that filesystem's directories
      during a pathwalk.  The operation is keyed off a new dentry flag
      (DCACHE_MANAGE_TRANSIT).
      
      The filesystem is allowed to be selective about which processes it holds and
      which it permits to continue on or prohibits from transiting from each flagged
      directory.  This will allow autofs to hold up client processes whilst letting
      its userspace daemon through to maintain the directory or the stuff behind it
      or mounted upon it.
      
      The ->d_manage() dentry operation:
      
      	int (*d_manage)(struct path *path, bool mounting_here);
      
      takes a pointer to the directory about to be transited away from and a flag
      indicating whether the transit is undertaken by do_add_mount() or
      do_move_mount() skipping through a pile of filesystems mounted on a mountpoint.
      
      It should return 0 if successful and to let the process continue on its way;
      -EISDIR to prohibit the caller from skipping to overmounted filesystems or
      automounting, and to use this directory; or some other error code to return to
      the user.
      
      ->d_manage() is called with namespace_sem writelocked if mounting_here is true
      and no other locks held, so it may sleep.  However, if mounting_here is true,
      it may not initiate or wait for a mount or unmount upon the parameter
      directory, even if the act is actually performed by userspace.
      
      Within fs/namei.c, follow_managed() is extended to check with d_manage() first
      on each managed directory, before transiting away from it or attempting to
      automount upon it.
      
      follow_down() is renamed follow_down_one() and should only be used where the
      filesystem deliberately intends to avoid management steps (e.g. autofs).
      
      A new follow_down() is added that incorporates the loop done by all other
      callers of follow_down() (do_add/move_mount(), autofs and NFSD; whilst AFS, NFS
      and CIFS do use it, their use is removed by converting them to use
      d_automount()).  The new follow_down() calls d_manage() as appropriate.  It
      also takes an extra parameter to indicate if it is being called from mount code
      (with namespace_sem writelocked) which it passes to d_manage().  follow_down()
      ignores automount points so that it can be used to mount on them.
      
      __follow_mount_rcu() is made to abort rcu-walk mode if it hits a directory with
      DCACHE_MANAGE_TRANSIT set on the basis that we're probably going to have to
      sleep.  It would be possible to enter d_manage() in rcu-walk mode too, and have
      that determine whether to abort or not itself.  That would allow the autofs
      daemon to continue on in rcu-walk mode.
      
      Note that DCACHE_MANAGE_TRANSIT on a directory should be cleared when it isn't
      required as every tranist from that directory will cause d_manage() to be
      invoked.  It can always be set again when necessary.
      
      ==========================
      WHAT THIS MEANS FOR AUTOFS
      ==========================
      
      Autofs currently uses the lookup() inode op and the d_revalidate() dentry op to
      trigger the automounting of indirect mounts, and both of these can be called
      with i_mutex held.
      
      autofs knows that the i_mutex will be held by the caller in lookup(), and so
      can drop it before invoking the daemon - but this isn't so for d_revalidate(),
      since the lock is only held on _some_ of the code paths that call it.  This
      means that autofs can't risk dropping i_mutex from its d_revalidate() function
      before it calls the daemon.
      
      The bug could manifest itself as, for example, a process that's trying to
      validate an automount dentry that gets made to wait because that dentry is
      expired and needs cleaning up:
      
      	mkdir         S ffffffff8014e05a     0 32580  24956
      	Call Trace:
      	 [<ffffffff885371fd>] :autofs4:autofs4_wait+0x674/0x897
      	 [<ffffffff80127f7d>] avc_has_perm+0x46/0x58
      	 [<ffffffff8009fdcf>] autoremove_wake_function+0x0/0x2e
      	 [<ffffffff88537be6>] :autofs4:autofs4_expire_wait+0x41/0x6b
      	 [<ffffffff88535cfc>] :autofs4:autofs4_revalidate+0x91/0x149
      	 [<ffffffff80036d96>] __lookup_hash+0xa0/0x12f
      	 [<ffffffff80057a2f>] lookup_create+0x46/0x80
      	 [<ffffffff800e6e31>] sys_mkdirat+0x56/0xe4
      
      versus the automount daemon which wants to remove that dentry, but can't
      because the normal process is holding the i_mutex lock:
      
      	automount     D ffffffff8014e05a     0 32581      1              32561
      	Call Trace:
      	 [<ffffffff80063c3f>] __mutex_lock_slowpath+0x60/0x9b
      	 [<ffffffff8000ccf1>] do_path_lookup+0x2ca/0x2f1
      	 [<ffffffff80063c89>] .text.lock.mutex+0xf/0x14
      	 [<ffffffff800e6d55>] do_rmdir+0x77/0xde
      	 [<ffffffff8005d229>] tracesys+0x71/0xe0
      	 [<ffffffff8005d28d>] tracesys+0xd5/0xe0
      
      which means that the system is deadlocked.
      
      This patch allows autofs to hold up normal processes whilst the daemon goes
      ahead and does things to the dentry tree behind the automouter point without
      risking a deadlock as almost no locks are held in d_manage() and none in
      d_automount().
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Was-Acked-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      cc53ce53
  13. 07 1月, 2011 5 次提交
    • N
      fs: dcache remove d_mounted · 5f57cbcc
      Nick Piggin 提交于
      Rather than keep a d_mounted count in the dentry, set a dentry flag instead.
      The flag can be cleared by checking the hash table to see if there are any
      mounts left, which is not time critical because it is performed at detach time.
      
      The mounted state of a dentry is only used to speculatively take a look in the
      mount hash table if it is set -- before following the mount, vfsmount lock is
      taken and mount re-checked without races.
      
      This saves 4 bytes on 32-bit, nothing on 64-bit but it does provide a hole I
      might use later (and some configs have larger than 32-bit spinlocks which might
      make use of the hole).
      
      Autofs4 conversion and changelog by Ian Kent <raven@themaw.net>:
      In autofs4, when expring direct (or offset) mounts we need to ensure that we
      block user path walks into the autofs mount, which is covered by another mount.
      To do this we clear the mounted status so that follows stop before walking into
      the mount and are essentially blocked until the expire is completed. The
      automount daemon still finds the correct dentry for the umount due to the
      follow mount logic in fs/autofs4/root.c:autofs4_follow_link(), which is set as
      an inode operation for direct and offset mounts only and is called following
      the lookup that stopped at the covered mount.
      
      At the end of the expire the covering mount probably has gone away so the
      mounted status need not be restored. But we need to check this and only restore
      the mounted status if the expire failed.
      
      XXX: autofs may not work right if we have other mounts go over the top of it?
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      5f57cbcc
    • N
      fs: dcache remove dcache_lock · b5c84bf6
      Nick Piggin 提交于
      dcache_lock no longer protects anything. remove it.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      b5c84bf6
    • N
      fs: dcache scale subdirs · 2fd6b7f5
      Nick Piggin 提交于
      Protect d_subdirs and d_child with d_lock, except in filesystems that aren't
      using dcache_lock for these anyway (eg. using i_mutex).
      
      Note: if we change the locking rule in future so that ->d_child protection is
      provided only with ->d_parent->d_lock, it may allow us to reduce some locking.
      But it would be an exception to an otherwise regular locking scheme, so we'd
      have to see some good results. Probably not worthwhile.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      2fd6b7f5
    • N
      fs: dcache scale d_unhashed · da502956
      Nick Piggin 提交于
      Protect d_unhashed(dentry) condition with d_lock. This means keeping
      DCACHE_UNHASHED bit in synch with hash manipulations.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      da502956
    • N
      fs: dcache scale dentry refcount · b7ab39f6
      Nick Piggin 提交于
      Make d_count non-atomic and protect it with d_lock. This allows us to ensure a
      0 refcount dentry remains 0 without dcache_lock. It is also fairly natural when
      we start protecting many other dentry members with d_lock.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      b7ab39f6
  14. 04 3月, 2010 1 次提交
  15. 16 12月, 2009 2 次提交
  16. 01 9月, 2009 1 次提交
  17. 12 6月, 2009 1 次提交
  18. 03 5月, 2009 1 次提交
  19. 01 4月, 2009 1 次提交
  20. 07 1月, 2009 1 次提交
    • I
      autofs4: make autofs type usage explicit · a92daf6b
      Ian Kent 提交于
      - the type assigned at mount when no type is given is changed
        from 0 to AUTOFS_TYPE_INDIRECT. This was done because 0 and
        AUTOFS_TYPE_INDIRECT were being treated implicitly as the same
        type.
      
      - previously, an offset mount had it's type set to
        AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET but the mount control
        re-implementation needs to be able distinguish all three types.
        So this was changed to make the type setting explicit.
      
      - a type AUTOFS_TYPE_ANY was added for use by the re-implementation
        when checking if a given path is a mountpoint. It's not really a
        type as we use this to ask if a given path is a mountpoint in the
        autofs_dev_ioctl_ismountpoint() function.
      
      - functions to set and test the autofs mount types have been added to
        improve readability and make the type usage explicit.
      
      - the mount type is used from user space for the mount control
        re-implementtion so, for consistency, all the definitions have
        been moved to the user space include file include/linux/auto_fs4.h.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a92daf6b
  21. 07 11月, 2008 1 次提交
  22. 17 10月, 2008 2 次提交
    • I
      autofs4: add miscellaneous device for ioctls · 8d7b48e0
      Ian Kent 提交于
      Add a miscellaneous device to the autofs4 module for routing ioctls.  This
      provides the ability to obtain an ioctl file handle for an autofs mount
      point that is possibly covered by another mount.
      
      The actual problem with autofs is that it can't reconnect to existing
      mounts.  Immediately one things of just adding the ability to remount
      autofs file systems would solve it, but alas, that can't work.  This is
      because autofs direct mounts and the implementation of "on demand mount
      and expire" of nested mount trees have the file system mounted on top of
      the mount trigger dentry.
      
      To resolve this a miscellaneous device node for routing ioctl commands to
      these mount points has been implemented in the autofs4 kernel module and a
      library added to autofs.  This provides the ability to open a file
      descriptor for these over mounted autofs mount points.
      
      Please refer to Documentation/filesystems/autofs4-mount-control.txt for a
      discussion of the problem, implementation alternatives considered and a
      description of the interface.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8d7b48e0
    • I
      autofs4: cleanup autofs mount type usage · bb979d7f
      Ian Kent 提交于
      Usage of the AUTOFS_TYPE_* defines is a little confusing and appears
      inconsistent.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bb979d7f
  23. 25 7月, 2008 3 次提交
  24. 01 5月, 2008 2 次提交