1. 22 8月, 2013 4 次提交
  2. 26 1月, 2013 1 次提交
  3. 05 9月, 2012 1 次提交
  4. 27 7月, 2010 3 次提交
  5. 22 5月, 2010 2 次提交
    • E
      sysfs: Implement sysfs tagged directory support. · 3ff195b0
      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/*, /sys/devices/virtual/net/*, and
      potentially a few other directories of the form /sys/ ... /net/*.
      
      What this patch does is to add an additional tag field to the
      sysfs dirent structure.  For directories that should show different
      contents depending on the context such as /sys/class/net/, and
      /sys/devices/virtual/net/ this tag field is used to specify the
      context in which those directories should be visible.  Effectively
      this is the same as creating multiple distinct directories with
      the same name but internally to sysfs the result is nicer.
      
      I am calling the concept of a single directory that looks like multiple
      directories all at the same path in the filesystem tagged directories.
      
      For the networking namespace the set of directories whose contents I need
      to filter with tags can depend on the presence or absence of hotplug
      hardware or which modules are currently loaded.  Which means I need
      a simple race free way to setup those directories as tagged.
      
      To achieve a reace free design all tagged directories are created
      and managed by sysfs itself.
      
      Users of this interface:
      - define a type in the sysfs_tag_type enumeration.
      - call sysfs_register_ns_types with the type and it's operations
      - sysfs_exit_ns when an individual tag is no longer valid
      
      - Implement mount_ns() which returns the ns of the calling process
        so we can attach it to a sysfs superblock.
      - Implement ktype.namespace() which returns the ns of a syfs kobject.
      
      Everything else is left up to sysfs and the driver layer.
      
      For the network namespace mount_ns and namespace() are essentially
      one line functions, and look to remain that.
      
      Tags are currently represented a const void * pointers as that is
      both generic, prevides enough information for equality comparisons,
      and is trivial to create for current users, as it is just the
      existing namespace pointer.
      
      The work needed in sysfs is more extensive.  At each directory
      or symlink creating I need to check if the directory it is being
      created in is a tagged directory and if so generate the appropriate
      tag to place on the sysfs_dirent.  Likewise at each symlink or
      directory removal I need to check if the sysfs directory it is
      being removed from is a tagged directory and if so figure out
      which tag goes along with the name I am deleting.
      
      Currently only directories which hold kobjects, and
      symlinks are supported.  There is not enough information
      in the current file attribute interfaces to give us anything
      to discriminate on which makes it useless, and there are
      no potential users which makes it an uninteresting problem
      to solve.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NBenjamin Thery <benjamin.thery@bull.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3ff195b0
    • E
      sysfs: Implement sysfs_delete_link · 746edb7a
      Eric W. Biederman 提交于
      When removing a symlink sysfs_remove_link does not provide
      enough information to figure out which tagged directory the symlink
      falls in.  So I need sysfs_delete_link which is passed the target
      of the symlink to delete.
      
      sysfs_rename_link is updated to call sysfs_delete_link instead
      of sysfs_remove_link as we have all of the information necessary
      and the callers are interesting.
      
      Both of these functions now have enough information to find a symlink
      in a tagged directory.  The only restriction is that they must be called
      before the target kobject is renamed or deleted.  If they are called
      later I loose track of which tag the target kobject was marked with
      and can no longer find the old symlink to remove it.
      
      This patch was split from an earlier patch.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NBenjamin Thery <benjamin.thery@bull.net>
      Signed-off-by: NDaniel Lezcano <dlezcano@fr.ibm.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      746edb7a
  6. 16 5月, 2010 1 次提交
  7. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  8. 08 3月, 2010 1 次提交
  9. 12 12月, 2009 2 次提交
  10. 10 9月, 2009 1 次提交
    • D
      sysfs: Add labeling support for sysfs · ddd29ec6
      David P. Quigley 提交于
      This patch adds a setxattr handler to the file, directory, and symlink
      inode_operations structures for sysfs. The patch uses hooks introduced in the
      previous patch to handle the getting and setting of security information for
      the sysfs inodes. As was suggested by Eric Biederman the struct iattr in the
      sysfs_dirent structure has been replaced by a structure which contains the
      iattr, secdata and secdata length to allow the changes to persist in the event
      that the inode representing the sysfs_dirent is evicted. Because sysfs only
      stores this information when a change is made all the optional data is moved
      into one dynamically allocated field.
      
      This patch addresses an issue where SELinux was denying virtd access to the PCI
      configuration entries in sysfs. The lack of setxattr handlers for sysfs
      required that a single label be assigned to all entries in sysfs. Granting virtd
      access to every entry in sysfs is not an acceptable solution so fine grained
      labeling of sysfs is required such that individual entries can be labeled
      appropriately.
      
      [sds:  Fixed compile-time warnings, coding style, and setting of inode security init flags.]
      Signed-off-by: NDavid P. Quigley <dpquigl@tycho.nsa.gov>
      Signed-off-by: NStephen D. Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      ddd29ec6
  11. 16 6月, 2009 1 次提交
  12. 22 7月, 2008 1 次提交
  13. 18 4月, 2008 1 次提交
  14. 25 1月, 2008 1 次提交
    • K
      sysfs: create optimal relative symlink targets · 2f90a851
      Kay Sievers 提交于
      Instead of walking from the source down to the root of sysfs, and back
      to the target, we stop at the first directory the source and the target
      share.
      
      This link:
        /devices/pci0000:00/0000:00:1d.7/usb1/1-0:1.0/ep_81
      
      pointed to:
        ../../../../../devices/pci0000:00/0000:00:1d.0/usb2/2-0:1.0/usb_endpoint/usbdev2.1_ep81
      
      now it just points to:
        usb_endpoint/usbdev1.1_ep81
      
      Thanks to Denis Cheng for bringing this up, and sending the initial patch.
      
      CC: Denis Cheng <crquan@gmail.com>
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2f90a851
  15. 13 10月, 2007 6 次提交
  16. 19 7月, 2007 2 次提交
    • T
      sysfs: cosmetic clean up on node creation failure paths · 967e35dc
      Tejun Heo 提交于
      Node addition failure is detected by testing return value of
      sysfs_addfm_finish() which returns the number of added and removed
      nodes.  As the function is called as the last step of addition right
      on top of error handling block, the if blocks looked like the
      following.
      
      	if (sysfs_addrm_finish(&acxt))
      		success handling, usually return;
      	/* fall through to error handling */
      
      This is the opposite of usual convention in sysfs and makes the code
      difficult to understand.  This patch inverts the test and makes those
      blocks look more like others.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Cc: Gabriel C <nix.or.die@googlemail.com>
      Cc: Miles Lane <miles.lane@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      967e35dc
    • T
      sysfs: kill an extra put in sysfs_create_link() failure path · a1da4dfe
      Tejun Heo 提交于
      There is a subtle bug in sysfs_create_link() failure path.  When
      symlink creation fails because there's already a node with the same
      name, the target sysfs_dirent is put twice - once by failure path of
      sysfs_create_link() and once more when the symlink is released.
      
      Fix it by making only the symlink node responsible for putting
      target_sd.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Cc: Gabriel C <nix.or.die@googlemail.com>
      Cc: Miles Lane <miles.lane@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a1da4dfe
  17. 12 7月, 2007 10 次提交
    • T
      sysfs: restructure add/remove paths and fix inode update · fb6896da
      Tejun Heo 提交于
      The original add/remove code had the following problems.
      
      * parent's timestamps are updated on dentry instantiation.  this is
        incorrect with reclaimable files.
      
      * updating parent's timestamps isn't synchronized.
      
      * parent nlink update assumes the inode is accessible which won't be
        true once directory dentries are made reclaimable.
      
      This patch restructures add/remove paths to resolve the above
      problems.  Add/removal are done in the following steps.
      
      1. sysfs_addrm_start() : acquire locks including sysfs_mutex and other
         resources.
      
      2-a. sysfs_add_one() : add new sd.  linking the new sd into the
           children list is caller's responsibility.
      
      2-b. sysfs_remove_one() : remove a sd.  unlinking the sd from the
           children list is caller's responsibility.
      
      3. sysfs_addrm_finish() : release all resources and clean up.
      
      Steps 2-a and/or 2-b can be repeated multiple times.
      
      Parent's inode is looked up during sysfs_addrm_start().  If available
      (always at the moment), it's pinned and nlink is updated as sd's are
      added and removed.  Timestamps are updated during finish if any sd has
      been added or removed.  If parent's inode is not available during
      start, sysfs_mutex ensures that parent inode is not created till
      add/remove is complete.
      
      All the complexity is contained inside the helper functions.
      Especially, dentry/inode handling is properly hidden from the rest of
      sysfs which now mostly operate on sysfs_dirents.  As an added bonus,
      codes which use these helpers to add and remove sysfs_dirents are now
      more structured and simpler.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fb6896da
    • T
      sysfs: use sysfs_mutex to protect the sysfs_dirent tree · 3007e997
      Tejun Heo 提交于
      As kobj sysfs dentries and inodes are gonna be made reclaimable,
      i_mutex can't be used to protect sysfs_dirent tree.  Use sysfs_mutex
      globally instead.  As the whole tree is protected with sysfs_mutex,
      there is no reason to keep sysfs_rename_sem.  Drop it.
      
      While at it, add docbook comments to functions which require
      sysfs_mutex locking.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3007e997
    • T
      sysfs: consolidate sysfs spinlocks · 5f995323
      Tejun Heo 提交于
      Replace sysfs_lock and kobj_sysfs_assoc_lock with sysfs_assoc_lock.
      sysfs_lock was originally to be used to protect sysfs_dirent tree but
      mutex seems better choice, so there is no reason to keep sysfs_lock
      separate.  Merge the two spinlocks into one.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      5f995323
    • T
      sysfs: make kobj point to sysfs_dirent instead of dentry · 608e266a
      Tejun Heo 提交于
      As kobj sysfs dentries and inodes are gonna be made reclaimable,
      dentry can't be used as naming token for sysfs file/directory, replace
      kobj->dentry with kobj->sd.  The only external interface change is
      shadow directory handling.  All other changes are contained in kobj
      and sysfs.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      608e266a
    • T
      sysfs: implement sysfs_find_dirent() and sysfs_get_dirent() · f0b0af47
      Tejun Heo 提交于
      Implement sysfs_find_dirent() and sysfs_get_dirent().
      sysfs_dirent_exist() is replaced by sysfs_find_dirent().  These will
      be used to make directory entries reclamiable.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f0b0af47
    • 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: 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: 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: flatten cleanup paths in sysfs_add_link() and create_dir() · dfeb9fb0
      Tejun Heo 提交于
      Flatten cleanup paths in sysfs_add_link() and create_dir() to improve
      readability and ease further changes to these functions.  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>
      dfeb9fb0
  18. 13 2月, 2007 1 次提交