1. 12 7月, 2007 18 次提交
    • T
      sysfs: rename sysfs_dirent->s_type to s_flags and make room for flags · b402d72c
      Tejun Heo 提交于
      Rename sysfs_dirent->s_type to s_flags, pack type into lower eight
      bits and reserve the rest for flags.  sysfs_type() can used to access
      the type.  All existing sd->s_type accesses are converted to use
      sysfs_type().  While at it, type test is changed to equality test
      instead of bit-and test where appropriate.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b402d72c
    • T
      sysfs: use singly-linked list for sysfs_dirent tree · 0c73f18b
      Tejun Heo 提交于
      Make sysfs_dirent use singly linked list for its tree structure.
      sysfs_link_sibling() and sysfs_unlink_sibling() functions are added to
      handle simpler cases.  It adds some complexity and cpu cycle overhead
      but reduced memory footprint is worthwhile on big machines.
      
      This change reduces the sizeof sysfs_dirent from 104 to 88 on 64bit
      and from 60 to 52 on 32bit.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0c73f18b
    • T
      sysfs: slim down sysfs_dirent->s_active · 8619f979
      Tejun Heo 提交于
      Make sysfs_dirent->s_active an atomic_t instead of rwsem.  This
      reduces the size of sysfs_dirent from 136 to 104 on 64bit and from 76
      to 60 on 32bit with lock debugging turned off.  With lock debugging
      turned on the reduction is much larger.
      
      s_active starts at zero and each active reference increments s_active.
      Putting a reference decrements s_active.  Deactivation subtracts
      SD_DEACTIVATED_BIAS which is currently INT_MIN and assumed to be small
      enough to make s_active negative.  If s_active is negative,
      sysfs_get() no longer grants new references.  Deactivation succeeds
      immediately if there is no active user; otherwise, it waits using a
      completion for the last put.
      
      Due to the removal of lockdep tricks, this change makes things less
      trickier in release_sysfs_dirent().  As all the complexity is
      contained in three s_active functions, I think it's more readable this
      way.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8619f979
    • T
      sysfs: move s_active functions to fs/sysfs/dir.c · b6b4a439
      Tejun Heo 提交于
      These functions are about to receive more complexity and doesn't
      really need to be inlined in the first place.  Move them from
      fs/sysfs/sysfs.h to fs/sysfs/dir.c.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b6b4a439
    • T
      sysfs: use iget_locked() instead of new_inode() · 8312a8d7
      Tejun Heo 提交于
      After dentry is reclaimed, sysfs always used to allocate new dentry
      and inode if the file is accessed again.  This causes problem with
      operations which only pin the inode.  For example, if inotify watch is
      added to a sysfs file and the dentry for the file is reclaimed, the
      next update event creates new dentry and new inode making the inotify
      watch miss all the events from there on.
      
      This patch fixes it by using iget_locked() instead of new_inode().
      sysfs_new_inode() is renamed to sysfs_get_inode() and inode is
      initialized iff the inode is newly allocated.  sysfs_instantiate() is
      responsible for unlocking new inodes.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8312a8d7
    • T
      sysfs: reorganize sysfs_new_indoe() and sysfs_create() · fc9f54b9
      Tejun Heo 提交于
      Reorganize/clean up sysfs_new_inode() and sysfs_create().
      
      * sysfs_init_inode() is separated out from sysfs_new_inode() and is
        responsible for basic initialization.
      * sysfs_instantiate() replaces the last step of sysfs_create() and is
        responsible for dentry instantitaion.
      * type-specific initialization is moved out to the callers.
      * mode is specified only once when creating a sysfs_dirent.
      * spurious list_del_init(&sd->s_sibling) dropped from create_dir()
      
      This change is to
      
      * prepare for inode allocation fix.
      * separate alloc and init code for synchronization update.
      * make dentry/inode initialization more flexible for later changes.
      
      This patch doesn't introduce visible behavior change.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fc9f54b9
    • 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: reimplement symlink using sysfs_dirent tree · 2b29ac25
      Tejun Heo 提交于
      sysfs symlink is implemented by referencing dentry and kobject from
      sysfs_dirent - symlink entry references kobject, dentry is used to
      walk the tree.  This complicates object lifetimes rules and is
      dangerous - for example, there is no way to tell to which module the
      target of a symlink belongs and referencing that kobject can make it
      linger after the module is gone.
      
      This patch reimplements symlink using only sysfs_dirent tree.  sd for
      a symlink points and holds reference to the target sysfs_dirent and
      all walking is done using sysfs_dirent tree.  Simpler and safer.
      
      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>
      2b29ac25
    • T
      sysfs: implement kobj_sysfs_assoc_lock · aecdceda
      Tejun Heo 提交于
      kobj->dentry can go away anytime unless the user controls when the
      associated sysfs node is deleted.  This patch implements
      kobj_sysfs_assoc_lock which protects kobj->dentry.  This will be used
      to maintain kobj based API when converting sysfs to use sysfs_dirent
      tree instead of dentry/kobject.
      
      Note that this lock belongs to kobject/driver-model not sysfs.  Once
      sysfs is converted to not use kobject in its interface, this can be
      removed from sysfs.
      
      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>
      aecdceda
    • 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
    • T
      sysfs: add sysfs_dirent->s_parent · 13b3086d
      Tejun Heo 提交于
      Add sysfs_dirent->s_parent.  With this patch, each sd points to and
      holds a reference to its parent.  This allows walking sysfs tree
      without referencing sd->s_dentry which can go away anytime if the user
      doesn't control when it's deleted.
      
      sd->s_parent is initialized and parent is referenced in
      sysfs_attach_dirent().  Reference to parent is released when the sd is
      released, so as long as reference to a sd is held, s_parent can be
      followed.
      
      dentry walk in sysfs_readdir() is convereted to s_parent walk.
      
      This will be used to reimplement symlink such that it uses only
      sysfs_dirent tree.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      13b3086d
    • T
      sysfs: consolidate sysfs_dirent creation functions · a26cd722
      Tejun Heo 提交于
      Currently there are four functions to create sysfs_dirent -
      __sysfs_new_dirent(), sysfs_new_dirent(), __sysfs_make_dirent() and
      sysfs_make_dirent().  Other than sysfs_make_dirent(), no function has
      two users if calls to implement other functions are excluded.
      
      This patch consolidates sysfs_dirent creation functions into the
      following two.
      
      * sysfs_new_dirent() : allocate and initialize
      * sysfs_attach_dirent() : attach to sysfs_dirent hierarchy and/or
      			  associate with dentry
      
      This simplifies interface and gives callers more flexibility.  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>
      a26cd722
    • T
      sysfs: make sysfs_put() ignore NULL sd · 7a23ad44
      Tejun Heo 提交于
      Make sysfs_put() ignore NULL sd instead of oopsing.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7a23ad44
    • T
      sysfs: move release_sysfs_dirent() to dir.c · fa7f912a
      Tejun Heo 提交于
      There is no reason this function should be inlined and soon to follow
      sysfs object reference simplification will make it heavier.  Move it
      to dir.c.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fa7f912a
  2. 13 6月, 2007 2 次提交
  3. 24 2月, 2007 1 次提交
    • A
      sysfs: move struct sysfs_dirent to private header · d56c3eae
      Adam J. Richter 提交于
      struct sysfs_dirent is private to the fs/sysfs/ subtree.  It is
      not even referenced as an opaque structure outside of that subtree.
      
      The following patch moves the declaration from include/linux/sysfs.h to
      fs/sysfs/sysfs.h, making it clearer that nothing else in the kernel
      dereferences it.
      
      I have been running this patch for years.  Please integrate and forward
      upstream if there are no objections.
      
      From: "Adam J. Richter" <adam@yggdrasil.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d56c3eae
  4. 13 2月, 2007 1 次提交
  5. 08 2月, 2007 2 次提交
    • 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
    • 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
  6. 08 12月, 2006 1 次提交
  7. 26 9月, 2006 1 次提交
  8. 15 4月, 2006 1 次提交
    • N
      [PATCH] sysfs: Allow sysfs attribute files to be pollable · 4508a7a7
      NeilBrown 提交于
      It works like this:
        Open the file
        Read all the contents.
        Call poll requesting POLLERR or POLLPRI (so select/exceptfds works)
        When poll returns,
           close the file and go to top of loop.
         or lseek to start of file and go back to the 'read'.
      
      Events are signaled by an object manager calling
         sysfs_notify(kobj, dir, attr);
      
      If the dir is non-NULL, it is used to find a subdirectory which
      contains the attribute (presumably created by sysfs_create_group).
      
      This has a cost of one int  per attribute, one wait_queuehead per kobject,
      one int per open file.
      
      The name "sysfs_notify" may be confused with the inotify
      functionality.  Maybe it would be nice to support inotify for sysfs
      attributes as well?
      
      This patch also uses sysfs_notify to allow /sys/block/md*/md/sync_action
      to be pollable
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4508a7a7
  9. 29 3月, 2006 1 次提交
  10. 21 3月, 2006 1 次提交
  11. 24 6月, 2005 1 次提交
  12. 21 6月, 2005 2 次提交
  13. 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