1. 12 7月, 2007 6 次提交
    • T
      sysfs: reimplement sysfs_drop_dentry() · dbde0fcf
      Tejun Heo 提交于
      This patch reimplements sysfs_drop_dentry() such that remove_dir() can
      use it to drop dentry instead of using a separate mechanism.  With
      this change, making directories reclaimable is much easier.
      
      This patch used to contain fixes for two race conditions around
      sd->s_dentry but that part has been separated out and included into
      mainline early as commit 6aa054aa and
      dd14cbc9.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      dbde0fcf
    • T
      sysfs: separate out sysfs_attach_dentry() · 198a2a84
      Tejun Heo 提交于
      Consolidate sd <-> dentry association into sysfs_attach_dentry() and
      call it after dentry and inode are properly set up.  This is in
      preparation of sysfs_drop_dentry() updates.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      198a2a84
    • T
      sysfs: kill attribute file orphaning · 73107cb3
      Tejun Heo 提交于
      Now that sysfs_dirent can be disconnected from kobject on deletion,
      there is no need to orphan each attribute files.  All [bin_]attribute
      nodes are automatically orphaned when the parent node is deleted.
      Kill attribute file orphaning.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      73107cb3
    • T
      sysfs: implement sysfs_dirent active reference and immediate disconnect · 0ab66088
      Tejun Heo 提交于
      sysfs: implement sysfs_dirent active reference and immediate disconnect
      
      Opening a sysfs node references its associated kobject, so userland
      can arbitrarily prolong lifetime of a kobject which complicates
      lifetime rules in drivers.  This patch implements active reference and
      makes the association between kobject and sysfs immediately breakable.
      
      Now each sysfs_dirent has two reference counts - s_count and s_active.
      s_count is a regular reference count which guarantees that the
      containing sysfs_dirent is accessible.  As long as s_count reference
      is held, all sysfs internal fields in sysfs_dirent are accessible
      including s_parent and s_name.
      
      The newly added s_active is active reference count.  This is acquired
      by invoking sysfs_get_active() and it's the caller's responsibility to
      ensure sysfs_dirent itself is accessible (should be holding s_count
      one way or the other).  Dereferencing sysfs_dirent to access objects
      out of sysfs proper requires active reference.  This includes access
      to the associated kobjects, attributes and ops.
      
      The active references can be drained and denied by calling
      sysfs_deactivate().  All active sysfs_dirents must be deactivated
      after deletion but before the default reference is dropped.  This
      enables immediate disconnect of sysfs nodes.  Once a sysfs_dirent is
      deleted, it won't access any entity external to sysfs proper.
      
      Because attr/bin_attr ops access both the node itself and its parent
      for kobject, they need to hold active references to both.
      sysfs_get/put_active_two() helpers are provided to help grabbing both
      references.  Parent's is acquired first and released last.
      
      Unlike other operations, mmapped area lingers on after mmap() is
      finished and the module implement implementing it and kobj need to
      stay referenced till all the mapped pages are gone.  This is
      accomplished by holding one set of active references to the bin_attr
      and its parent if there have been any mmap during lifetime of an
      openfile.  The references are dropped when the openfile is released.
      
      This change makes sysfs lifetime rules independent from both kobject's
      and module's.  It not only fixes several race conditions caused by
      sysfs not holding onto the proper module when referencing kobject, but
      also helps fixing and simplifying lifetime management in driver model
      and drivers by taking sysfs out of the equation.
      
      Please read the following message for more info.
      
        http://article.gmane.org/gmane.linux.kernel/510293Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0ab66088
    • T
      sysfs: make sysfs_dirent->s_element a union · 3e519038
      Tejun Heo 提交于
      Make sd->s_element a union of sysfs_elem_{dir|symlink|attr|bin_attr}
      and rename it to s_elem.  This is to achieve...
      
      * some level of type checking : changing symlink to point to
        sysfs_dirent instead of kobject is much safer and less painful now.
      * easier / standardized dereferencing
      * allow sysfs_elem_* to contain more than one entry
      
      Where possible, pointer is obtained by directly deferencing from sd
      instead of going through other entities.  This reduces dependencies to
      dentry, inode and kobject.  to_attr() and to_bin_attr() are unused now
      and removed.
      
      This is in preparation of object reference simplification.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3e519038
    • T
      sysfs: add sysfs_dirent->s_name · 0c096b50
      Tejun Heo 提交于
      Add s_name to sysfs_dirent.  This is to further reduce dependency to
      the associated dentry.  Name is copied for directories and symlinks
      but not for attributes.
      
      Where possible, name dereferences are converted to use sd->s_name.
      sysfs_symlink->link_name and sysfs_get_name() are unused now and
      removed.
      
      This change allows symlink to be implemented using sysfs_dirent tree
      proper, which is the last remaining dentry-dependent sysfs walk.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0c096b50
  2. 13 6月, 2007 3 次提交
  3. 22 5月, 2007 1 次提交
    • A
      Detach sched.h from mm.h · e8edc6e0
      Alexey Dobriyan 提交于
      First thing mm.h does is including sched.h solely for can_do_mlock() inline
      function which has "current" dereference inside. By dealing with can_do_mlock()
      mm.h can be detached from sched.h which is good. See below, why.
      
      This patch
      a) removes unconditional inclusion of sched.h from mm.h
      b) makes can_do_mlock() normal function in mm/mlock.c
      c) exports can_do_mlock() to not break compilation
      d) adds sched.h inclusions back to files that were getting it indirectly.
      e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
         getting them indirectly
      
      Net result is:
      a) mm.h users would get less code to open, read, preprocess, parse, ... if
         they don't need sched.h
      b) sched.h stops being dependency for significant number of files:
         on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
         after patch it's only 3744 (-8.3%).
      
      Cross-compile tested on
      
      	all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
      	alpha alpha-up
      	arm
      	i386 i386-up i386-defconfig i386-allnoconfig
      	ia64 ia64-up
      	m68k
      	mips
      	parisc parisc-up
      	powerpc powerpc-up
      	s390 s390-up
      	sparc sparc-up
      	sparc64 sparc64-up
      	um-x86_64
      	x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
      
      as well as my two usual configs.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e8edc6e0
  4. 16 3月, 2007 1 次提交
  5. 07 3月, 2007 1 次提交
    • H
      [PATCH] suspend regression: sysfs deadlock · 266d4f40
      Hugh Dickins 提交于
      Suspend deadlocks when trying to unregister /sys/block/sr0.
      
      This comes from Oliver's commit 94bebf4d
      "Driver core: fix race in sysfs between sysfs_remove_file() and
      read()/write()".
      
      sysfs_write_file downs buffer->sem while calling flush_write_buffer, and
      flushing that particular write buffer entails downing buffer->sem in
      orphan_all_buffers, resulting in the obvious self-deadlock.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      266d4f40
  6. 13 2月, 2007 1 次提交
  7. 08 2月, 2007 3 次提交
    • E
      sysfs: Shadow directory support · b592fcfe
      Eric W. Biederman 提交于
      The problem.  When implementing a network namespace I need to be able
      to have multiple network devices with the same name.  Currently this
      is a problem for /sys/class/net/*. 
      
      What I want is a separate /sys/class/net directory in sysfs for each
      network namespace, and I want to name each of them /sys/class/net.
      
      I looked and the VFS actually allows that.  All that is needed is
      for /sys/class/net to implement a follow link method to redirect
      lookups to the real directory you want. 
      
      Implementing a follow link method that is sensitive to the current
      network namespace turns out to be 3 lines of code so it looks like a
      clean approach.  Modifying sysfs so it doesn't get in my was is a bit
      trickier. 
      
      I am calling the concept of multiple directories all at the same path
      in the filesystem shadow directories.  With the directory entry really
      at that location the shadow master. 
      
      The following patch modifies sysfs so it can handle a directory
      structure slightly different from the kobject tree so I can implement
      the shadow directories for handling /sys/class/net/.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Cc: Maneesh Soni <maneesh@in.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b592fcfe
    • F
      sysfs: suppress lockdep warnings · d3fc373a
      Frederik Deweerdt 提交于
      Lockdep issues the following warning:
      [    9.064000] =============================================
      [    9.064000] [ INFO: possible recursive locking detected ]
      [    9.064000] 2.6.20-rc3-mm1 #3
      [    9.064000] ---------------------------------------------
      [    9.064000] init/1 is trying to acquire lock:
      [    9.064000]  (&sysfs_inode_imutex_key){--..}, at: [<c03e6afc>] mutex_lock+0x1c/0x1f
      [    9.064000]
      [    9.064000] but task is already holding lock:
      [    9.064000]  (&sysfs_inode_imutex_key){--..}, at: [<c03e6afc>] mutex_lock+0x1c/0x1f
      [    9.065000]
      [    9.065000] other info that might help us debug this:
      [    9.065000] 2 locks held by init/1:
      [    9.065000]  #0:  (tty_mutex){--..}, at: [<c03e6afc>] mutex_lock+0x1c/0x1f
      [    9.065000]  #1:  (&sysfs_inode_imutex_key){--..}, at: [<c03e6afc>] mutex_lock+0x1c/0x1f
      [    9.065000]
      [    9.065000] stack backtrace:
      [    9.065000]  [<c010390d>] show_trace_log_lvl+0x1a/0x30
      [    9.066000]  [<c0103935>] show_trace+0x12/0x14
      [    9.066000]  [<c0103a2f>] dump_stack+0x16/0x18
      [    9.066000]  [<c0138cb8>] print_deadlock_bug+0xb9/0xc3
      [    9.066000]  [<c0138d17>] check_deadlock+0x55/0x5a
      [    9.066000]  [<c013a953>] __lock_acquire+0x371/0xbf0
      [    9.066000]  [<c013b7a9>] lock_acquire+0x69/0x83
      [    9.066000]  [<c03e6b7e>] __mutex_lock_slowpath+0x75/0x2d1
      [    9.066000]  [<c03e6afc>] mutex_lock+0x1c/0x1f
      [    9.066000]  [<c01b249c>] sysfs_drop_dentry+0xb1/0x133
      [    9.066000]  [<c01b25d1>] sysfs_hash_and_remove+0xb3/0x142
      [    9.066000]  [<c01b30ed>] sysfs_remove_file+0xd/0x10
      [    9.067000]  [<c02849e0>] device_remove_file+0x23/0x2e
      [    9.067000]  [<c02850b2>] device_del+0x188/0x1e6
      [    9.067000]  [<c028511b>] device_unregister+0xb/0x15
      [    9.067000]  [<c0285318>] device_destroy+0x9c/0xa9
      [    9.067000]  [<c0261431>] vcs_remove_sysfs+0x1c/0x3b
      [    9.067000]  [<c0267a08>] con_close+0x5e/0x6b
      [    9.067000]  [<c02598f2>] release_dev+0x4c4/0x6e5
      [    9.067000]  [<c0259faa>] tty_release+0x12/0x1c
      [    9.067000]  [<c0174872>] __fput+0x177/0x1a0
      [    9.067000]  [<c01746f5>] fput+0x3b/0x41
      [    9.068000]  [<c0172ee1>] filp_close+0x36/0x65
      [    9.068000]  [<c0172f73>] sys_close+0x63/0xa4
      [    9.068000]  [<c0102a96>] sysenter_past_esp+0x5f/0x99
      [    9.068000]  =======================
      
      This is due to sysfs_hash_and_remove() holding dir->d_inode->i_mutex
      before calling sysfs_drop_dentry() which calls orphan_all_buffers()
      which in turn takes node->i_mutex.
      Signed-off-by: NFrederik Deweerdt <frederik.deweerdt@gmail.com>
      Cc: Oliver Neukum <oliver@neukum.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d3fc373a
    • O
      Driver core: fix race in sysfs between sysfs_remove_file() and read()/write() · 94bebf4d
      Oliver Neukum 提交于
      This patch prevents a race between IO and removing a file from sysfs.
      It introduces a list of sysfs_buffers associated with a file at the inode.
      Upon removal of a file the list is walked and the buffers marked orphaned.
      IO to orphaned buffers fails with -ENODEV. The driver can safely free
      associated data structures or be unloaded.
      Signed-off-by: NOliver Neukum <oliver@neukum.name>
      Acked-by: NManeesh Soni <maneesh@in.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      94bebf4d
  8. 27 9月, 2006 1 次提交
  9. 26 9月, 2006 1 次提交
  10. 13 7月, 2006 1 次提交
  11. 29 6月, 2006 1 次提交
  12. 01 4月, 2006 1 次提交
  13. 21 3月, 2006 2 次提交
  14. 12 1月, 2006 1 次提交
  15. 10 1月, 2006 1 次提交
  16. 27 8月, 2005 1 次提交
    • J
      [PATCH] Fix oops in sysfs_hash_and_remove_file() · 36676bcb
      James Bottomley 提交于
      The problem arises if an entity in sysfs is created and removed without
      ever having been made completely visible.  In SCSI this is triggered by
      removing a device while it's initialising.
      
      The problem appears to be that because it was never made visible in sysfs,
      the sysfs dentry has a null d_inode which oopses when a reference is made
      to it.  The solution is simply to check d_inode and assume the object was
      never made visible (and thus doesn't need deleting) if it's NULL.
      
      (akpm: possibly a stopgap for 2.6.13 scsi problems.  May not be the
      long-term fix)
      Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      36676bcb
  17. 30 7月, 2005 1 次提交
  18. 24 6月, 2005 1 次提交
  19. 21 6月, 2005 2 次提交
  20. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4