1. 08 Dec, 2006 1 commit
  2. 07 Dec, 2006 1 commit
  3. 31 Jul, 2006 1 commit
    • Arjan van de Ven's avatar
      [PATCH] inotify: fix deadlock found by lockdep · 5b6509aa
      Arjan van de Ven authored
      
      This is a real deadlock, a nice complex one:
      (warning: long explanation follows so that Andrew can have a complete
      patch description)
      
      it's an ABCDA deadlock:
      
      A iprune_mutex
      B inode->inotify_mutex
      C ih->mutex
      D dev->ev_mutex
      
      The AB relationship comes straight from invalidate_inodes()
      
      int invalidate_inodes(struct super_block * sb)
      {
              int busy;
              LIST_HEAD(throw_away);
      
              mutex_lock(&iprune_mutex);
              spin_lock(&inode_lock);
              inotify_unmount_inodes(&sb->s_inodes);
      
      where inotify_umount_inodes() takes the
                      mutex_lock(&inode->inotify_mutex);
      
      The BC relationship comes directly from inotify_find_update_watch():
      s32 inotify_find_update_watch(struct inotify_handle *ih, struct inode *inode,
                                    u32 mask)
      {
         ...
              mutex_lock(&inode->inotify_mutex);
              mutex_lock(&ih->mutex);
      
      The CD relationship comes from inotify_rm_wd:
      inotify_rm_wd does
              mutex_lock(&inode->inotify_mutex);
              mutex_lock(&ih->mutex)
      and then calls inotify_remove_watch_locked() which calls
      notify_dev_queue_event() which does
      	        mutex_lock(&dev->ev_mutex);
      
      (this strictly is a BCD relationship)
      
      The DA relationship comes from the most interesting part:
      
        [<ffffffff8022d9f2>] shrink_icache_memory+0x42/0x270
        [<ffffffff80240dc4>] shrink_slab+0x11d/0x1c9
        [<ffffffff802b5104>] try_to_free_pages+0x187/0x244
        [<ffffffff8020efed>] __alloc_pages+0x1cd/0x2e0
        [<ffffffff8025e1f8>] cache_alloc_refill+0x3f8/0x821
        [<ffffffff8020a5e5>] kmem_cache_alloc+0x85/0xcb
        [<ffffffff802db027>] kernel_event+0x2e/0x122
        [<ffffffff8021d61c>] inotify_dev_queue_event+0xcc/0x140
      
      inotify_dev_queue_event schedules a kernel_event which does a
      kmem_cache_alloc( , GFP_KERNEL) which may try to shrink slabs, including
      the inode cache .. which then takes iprune_mutex.
      
      And voila, there is an AB, a BC, a CD relationship (even a direct BCD),
      and also now a DA relationship -> a circular type AB-BA deadlock but
      involving 4 locks.
      
      The solution is simple: kernel_event() is NOT allowed to use GFP_KERNEL,
      but must use GFP_NOFS to not cause recursion into the VFS.
      Signed-off-by: default avatarArjan van de Ven <arjan@linux.intel.com>
      Acked-by: default avatarIngo Molnar <mingo@elte.hu>
      Acked-by: default avatarRobert Love <rml@novell.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      5b6509aa
  4. 23 Jun, 2006 1 commit
    • David Howells's avatar
      [PATCH] VFS: Permit filesystem to override root dentry on mount · 454e2398
      David Howells authored
      
      Extend the get_sb() filesystem operation to take an extra argument that
      permits the VFS to pass in the target vfsmount that defines the mountpoint.
      
      The filesystem is then required to manually set the superblock and root dentry
      pointers.  For most filesystems, this should be done with simple_set_mnt()
      which will set the superblock pointer and then set the root dentry to the
      superblock's s_root (as per the old default behaviour).
      
      The get_sb() op now returns an integer as there's now no need to return the
      superblock pointer.
      
      This patch permits a superblock to be implicitly shared amongst several mount
      points, such as can be done with NFS to avoid potential inode aliasing.  In
      such a case, simple_set_mnt() would not be called, and instead the mnt_root
      and mnt_sb would be set directly.
      
      The patch also makes the following changes:
      
       (*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
           pointer argument and return an integer, so most filesystems have to change
           very little.
      
       (*) If one of the convenience function is not used, then get_sb() should
           normally call simple_set_mnt() to instantiate the vfsmount. This will
           always return 0, and so can be tail-called from get_sb().
      
       (*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
           dcache upon superblock destruction rather than shrink_dcache_anon().
      
           This is required because the superblock may now have multiple trees that
           aren't actually bound to s_root, but that still need to be cleaned up. The
           currently called functions assume that the whole tree is rooted at s_root,
           and that anonymous dentries are not the roots of trees which results in
           dentries being left unculled.
      
           However, with the way NFS superblock sharing are currently set to be
           implemented, these assumptions are violated: the root of the filesystem is
           simply a dummy dentry and inode (the real inode for '/' may well be
           inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
           with child trees.
      
           [*] Anonymous until discovered from another tree.
      
       (*) The documentation has been adjusted, including the additional bit of
           changing ext2_* into foo_* in the documentation.
      
      [akpm@osdl.org: convert ipath_fs, do other stuff]
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Cc: Nathan Scott <nathans@sgi.com>
      Cc: Roland Dreier <rolandd@cisco.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      454e2398
  5. 20 Jun, 2006 3 commits