1. 25 7月, 2008 11 次提交
    • I
      autofs4: check kernel communication pipe is valid for write · e64be33c
      Ian Kent 提交于
      It is possible for an autofs mount to become catatonic (and for the daemon
      communication pipe to become NULL) after a wait has been initiallized but
      before the request has been sent to the daemon.  We need to check for this
      before sending the request packet.
      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>
      e64be33c
    • I
      autofs4: add missing kfree · f4c7da02
      Ian Kent 提交于
      It see that the patch tittled "autofs4 - fix pending mount race" is
      missing a change that I had recently made.
      
      It's missing a kfree for the case mutex_lock_interruptible() fails
      to aquire the wait queue mutex.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f4c7da02
    • I
      autofs4: fix pending mount race · a1362fe9
      Ian Kent 提交于
      Close a race between a pending mount that is about to finish and a new
      lookup for the same directory.
      
      Process P1 triggers a mount of directory foo.  It sets
      DCACHE_AUTOFS_PENDING in the ->lookup routine, creates a waitq entry for
      'foo', and calls out to the daemon to perform the mount.  The autofs
      daemon will then create the directory 'foo', using a new dentry that will
      be hashed in the dcache.
      
      Before the mount completes, another process, P2, tries to walk into the
      'foo' directory.  The vfs path walking code finds an entry for 'foo' and
      calls the revalidate method.  Revalidate finds that the entry is not
      PENDING (because PENDING was never set on the dentry created by the
      mkdir), but it does find the directory is empty.  Revalidate calls
      try_to_fill_dentry, which sets the PENDING flag and then calls into the
      autofs4 wait code to trigger or wait for a mount of 'foo'.  The wait code
      finds the entry for 'foo' and goes to sleep waiting for the completion of
      the mount.
      
      Yet another process, P3, tries to walk into the 'foo' directory.  This
      process again finds a dentry in the dcache for 'foo', and calls into the
      autofs revalidate code.
      
      The revalidate code finds that the PENDING flag is set, and so calls
      try_to_fill_dentry.
      
      a) try_to_fill_dentry sets the PENDING flag redundantly for this
         dentry, then calls into the autofs4 wait code.
      
      b) the autofs4 wait code takes the waitq mutex and searches for an
         entry for 'foo'
      
      Between a and b, P1 is woken up because the mount completed.  P1 takes the
      wait queue mutex, clears the PENDING flag from the dentry, and removes the
      waitqueue entry for 'foo' from the list.
      
      When it releases the waitq mutex, P3 (eventually) acquires it.  At this
      time, it looks for an existing waitq for 'foo', finds none, and so creates
      a new one and calls out to the daemon to mount the 'foo' directory.
      
      Now, the reason that three processes are required to trigger this race is
      that, because the PENDING flag is not set on the dentry created by mkdir,
      the window for the race would be way to slim for it to ever occur.
      Basically, between the testing of d_mountpoint(dentry) and the taking of
      the waitq mutex, the mount would have to complete and the daemon would
      have to be woken up, and that in turn would have to wake up P1.  This is
      simply impossible.  Add the third process, though, and it becomes slightly
      more likely.
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      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>
      a1362fe9
    • I
      autofs4: fix waitq locking · 5a11d4d0
      Ian Kent 提交于
      The autofs4_catatonic_mode() function accesses the wait queue without any
      locking but can be called at any time.  This could lead to a possible
      double free of the name field of the wait and a double fput of the daemon
      communication pipe or an fput of a NULL file pointer.
      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>
      5a11d4d0
    • J
      autofs4: use struct qstr in waitq.c · 70b52a0a
      Jeff Moyer 提交于
      The autofs_wait_queue already contains all of the fields of the
      struct qstr, so change it into a qstr.
      
      This patch, from Jeff Moyer, has been modified a liitle by myself.
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      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>
      70b52a0a
    • I
      autofs4: use lookup intent flags to trigger mounts · 6d5cb926
      Ian Kent 提交于
      When an open(2) call is made on an autofs mount point directory that
      already exists and the O_DIRECTORY flag is not used the needed mount
      callback to the daemon is not done. This leads to the path walk
      continuing resulting in a callback to the daemon with an incorrect
      key. open(2) is called without O_DIRECTORY by the "find" utility but
      this should be handled properly anyway.
      
      This happens because autofs needs to use the lookup flags to decide
      when to callback to the daemon to perform a mount to prevent mount
      storms. For example, an autofs indirect mount map that has the "browse"
      option will have the mount point directories are pre-created and the
      stat(2) call made by a color ls against each directory will cause all
      these directories to be mounted. It is unfortunate we need to resort
      to this but mount maps can be quite large. Additionally, if a user
      manually umounts an autofs indirect mount the directory isn't removed
      which also leads to this situation.
      
      To resolve this autofs needs to use the lookup intent flags to enable
      it to make this decision. This patch adds this check and triggers a
      call back if any of the lookup intent flags are set as all these calls
      warrant a mount attempt be requested.
      
      I know that external VFS code which uses the lookup flags is something
      that the VFS would like to eliminate but I have no choice as I can't
      see any other way to do this. A VFS dentry or inode operation callback
      which returns the lookup "type" (requires a definition) would be
      sufficient. But this change is needed now and I'm not aware of the form
      that coming VFS changes will take so I'm not willing to propose anything
      along these lines.
      
      If anyone can provide an alternate method I would be happy to use it.
      
      [akpm@linux-foundation.org: fix build for concurrent VFS changes]
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6d5cb926
    • I
      autofs4: don't release directory mutex if called in oz_mode · c432c258
      Ian Kent 提交于
      Since we now delay hashing of dentrys until the ->mkdir() call, droping
      and re-taking the directory mutex within the ->lookup() function when we
      are being called by user space is not needed.  This can lead to a race
      when other processes are attempting to access the same directory during
      mount point directory creation.
      
      In this case we need to hang onto the mutex to ensure we don't get user
      processes trying to create a mount request for a newly created dentry
      after the mount point entry has already been created.  This ensures that
      when we need to check a dentry passed to autofs4_wait(), if it is hashed,
      it is always the mount point dentry and not a new dentry created by
      another lookup during directory creation.
      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>
      c432c258
    • I
      autofs4: fix symlink name allocation · ef581a74
      Ian Kent 提交于
      The length of the symlink name has been moved but it needs to be set
      before allocating space for it in the dentry info struct.  This corrects a
      mistake in a recent patch.
      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>
      ef581a74
    • I
      autofs4: use look aside list for lookups · 25767378
      Ian Kent 提交于
      A while ago a patch to resolve a deadlock during directory creation was
      merged.  This delayed the hashing of lookup dentrys until the ->mkdir()
      (or ->symlink()) operation completed to ensure we always went through
      ->lookup() instead of also having processes go through ->revalidate() so
      our VFS locking remained consistent.
      
      Now we are seeing a couple of side affects of that change in situations
      with heavy mount activity.
      
      Two cases have been identified:
      
      1) When a mount request is triggered, due to the delayed hashing, the
         directory created by user space for the mount point doesn't have the
         DCACHE_AUTOFS_PENDING flag set.  In the case of an autofs multi-mount
         where a tree of mount point directories are created this can lead to
         the path walk continuing rather than the dentry being sent to the wait
         queue to wait for request completion.  This is because, if the pending
         flag isn't set, the criteria for deciding this is a mount in progress
         fails to hold, namely that the dentry is not a mount point and has no
         subdirectories.
      
      2) A mount request dentry is initially created negative and unhashed.
         It remains this way until the ->mkdir() callback completes.  Since it
         is unhashed a fresh dentry is used when the user space mount request
         creates the mount point directory.  This leaves the original dentry
         negative and unhashed.  But revalidate has no way to tell the VFS that
         the dentry has changed, other than to force another ->lookup() by
         returning false, which is at best wastefull and at worst not possible.
         This results in an -ENOENT return from the original path walk when in
         fact the mount succeeded.
      
      To resolve this we need to ensure that the same dentry is used in all
      calls to ->lookup() during the course of a mount request.  This patch
      achieves that by adding the initial dentry to a look aside list and
      removes it at ->mkdir() or ->symlink() completion (or when the dentry is
      released), since these are the only create operations autofs4 supports.
      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>
      25767378
    • I
      autofs4: revert - redo lookup in ttfd · caf7da3d
      Ian Kent 提交于
      This patch series enables the use of a single dentry for lookups prior to
      the dentry being hashed and so we no longer need to redo the lookup.  This
      patch reverts the patch of commit
      03379044.
      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>
      caf7da3d
    • I
      autofs4: don't make expiring dentry negative · 5f6f4f28
      Ian Kent 提交于
      Correct the error of making a positive dentry negative after it has been
      instantiated.
      
      The code that makes this error attempts to re-use the dentry from a
      concurrent expire and mount to resolve a race and the dentry used for the
      lookup must be negative for mounts to trigger in the required cases.  The
      fact is that the dentry doesn't need to be re-used because all that is
      needed is to preserve the flag that indicates an expire is still
      incomplete at the time of the mount request.
      
      This change uses the the dentry to check the flag and wait for the expire
      to complete then discards it instead of attempting to re-use it.
      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>
      5f6f4f28
  2. 01 5月, 2008 5 次提交
  3. 30 4月, 2008 1 次提交
  4. 29 4月, 2008 1 次提交
  5. 15 2月, 2008 2 次提交
  6. 09 2月, 2008 1 次提交
  7. 20 10月, 2007 1 次提交
    • P
      pid namespaces: round up the API · a47afb0f
      Pavel Emelianov 提交于
      The set of functions process_session, task_session, process_group and
      task_pgrp is confusing, as the names can be mixed with each other when looking
      at the code for a long time.
      
      The proposals are to
      * equip the functions that return the integer with _nr suffix to
        represent that fact,
      * and to make all functions work with task (not process) by making
        the common prefix of the same name.
      
      For monotony the routines signal_session() and set_signal_session() are
      replaced with task_session_nr() and set_task_session(), especially since they
      are only used with the explicit task->signal dereference.
      Signed-off-by: NPavel Emelianov <xemul@openvz.org>
      Acked-by: NSerge E. Hallyn <serue@us.ibm.com>
      Cc: Kirill Korotaev <dev@openvz.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: Herbert Poetzl <herbert@13thfloor.at>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a47afb0f
  8. 19 10月, 2007 1 次提交
  9. 17 10月, 2007 1 次提交
  10. 23 8月, 2007 1 次提交
    • I
      autofs4: deadlock during create · 1864f7bd
      Ian Kent 提交于
      Due to inconsistent locking in the VFS between calls to lookup and
      revalidate deadlock can occur in the automounter.
      
      The inconsistency is that the directory inode mutex is held for both lookup
      and revalidate calls when called via lookup_hash whereas it is held only
      for lookup during a path walk.  Consequently, if the mutex is held during a
      call to revalidate autofs4 can't release the mutex to callback the daemon
      as it can't know whether it owns the mutex.
      
      This situation happens when a process tries to create a directory within an
      automount and a second process also tries to create the same directory
      between the lookup and the mkdir.  Since the first process has dropped the
      mutex for the daemon callback, the second process takes it during
      revalidate leading to deadlock between the autofs daemon and the second
      process when the daemon tries to create the mount point directory.
      
      After spending quite a bit of time trying to resolve this on more than one
      occassion, using rather complex and ulgy approaches, it turns out that just
      delaying the hashing of the dentry until the create operation works fine.
      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>
      1864f7bd
  11. 11 5月, 2007 1 次提交
  12. 09 5月, 2007 1 次提交
  13. 13 4月, 2007 1 次提交
  14. 21 2月, 2007 3 次提交
  15. 13 2月, 2007 2 次提交
  16. 14 12月, 2006 1 次提交
    • R
      [PATCH] getting rid of all casts of k[cmz]alloc() calls · 5cbded58
      Robert P. J. Day 提交于
      Run this:
      
      	#!/bin/sh
      	for f in $(grep -Erl "\([^\)]*\) *k[cmz]alloc" *) ; do
      	  echo "De-casting $f..."
      	  perl -pi -e "s/ ?= ?\([^\)]*\) *(k[cmz]alloc) *\(/ = \1\(/" $f
      	done
      
      And then go through and reinstate those cases where code is casting pointers
      to non-pointers.
      
      And then drop a few hunks which conflicted with outstanding work.
      
      Cc: Russell King <rmk@arm.linux.org.uk>, Ian Molton <spyro@f2s.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Paul Fulghum <paulkf@microgate.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Karsten Keil <kkeil@suse.de>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: Jeff Garzik <jeff@garzik.org>
      Cc: James Bottomley <James.Bottomley@steeleye.com>
      Cc: Ian Kent <raven@themaw.net>
      Cc: Steven French <sfrench@us.ibm.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Neil Brown <neilb@cse.unsw.edu.au>
      Cc: Jaroslav Kysela <perex@suse.cz>
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      5cbded58
  17. 09 12月, 2006 1 次提交
  18. 08 12月, 2006 1 次提交
    • J
      [PATCH] autofs: fix error code path in autofs_fill_sb() · c949d4eb
      Jiri Kosina 提交于
      When kernel is compiled with old version of autofs (CONFIG_AUTOFS_FS), and
      new (observed at least with 5.x.x) automount deamon is started, kernel
      correctly reports incompatible version of kernel and userland daemon, but
      then screws things up instead of correct handling of the error:
      
       autofs: kernel does not match daemon version
       =====================================
       [ BUG: bad unlock balance detected! ]
       -------------------------------------
       automount/4199 is trying to release lock (&type->s_umount_key) at:
       [<c0163b9e>] get_sb_nodev+0x76/0xa4
       but there are no more locks to release!
      
       other info that might help us debug this:
       no locks held by automount/4199.
      
       stack backtrace:
        [<c0103b15>] dump_trace+0x68/0x1b2
        [<c0103c77>] show_trace_log_lvl+0x18/0x2c
        [<c01041db>] show_trace+0xf/0x11
        [<c010424d>] dump_stack+0x12/0x14
        [<c012e02c>] print_unlock_inbalance_bug+0xe7/0xf3
        [<c012fd4f>] lock_release+0x8d/0x164
        [<c012b452>] up_write+0x14/0x27
        [<c0163b9e>] get_sb_nodev+0x76/0xa4
        [<c0163689>] vfs_kern_mount+0x83/0xf6
        [<c016373e>] do_kern_mount+0x2d/0x3e
        [<c017513f>] do_mount+0x607/0x67a
        [<c0175224>] sys_mount+0x72/0xa4
        [<c0102b96>] sysenter_past_esp+0x5f/0x99
       DWARF2 unwinder stuck at sysenter_past_esp+0x5f/0x99
       Leftover inexact backtrace:
        =======================
      
      and then deadlock comes.
      
      The problem: autofs_fill_super() returns EINVAL to get_sb_nodev(), but
      before that, it calls kill_anon_super() to destroy the superblock which
      won't be needed.  This is however way too soon to call kill_anon_super(),
      because get_sb_nodev() has to perform its own cleanup of the superblock
      first (deactivate_super(), etc.).  The correct time to call
      kill_anon_super() is in the autofs_kill_sb() callback, which is called by
      deactivate_super() at proper time, when the superblock is ready to be
      killed.
      
      I can see the same faulty codepath also in autofs4.  This patch solves
      issues in both filesystems in a same way - it postpones the
      kill_anon_super() until the proper time is signalized by deactivate_super()
      calling the kill_sb() callback.
      
      [raven@themaw.net: update comment]
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      Acked-by: NIan Kent <raven@themaw.net>
      Cc: <stable@kernel.org>
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      c949d4eb
  19. 15 11月, 2006 1 次提交
  20. 12 10月, 2006 1 次提交
  21. 01 10月, 2006 2 次提交