1. 27 9月, 2013 1 次提交
    • T
      sysfs: make attr namespace interface less convoluted · 58292cbe
      Tejun Heo 提交于
      sysfs ns (namespace) implementation became more convoluted than
      necessary while trying to hide ns information from visible interface.
      The relatively recent attr ns support is a good example.
      
      * attr ns tag is determined by sysfs_ops->namespace() callback while
        dir tag is determined by kobj_type->namespace().  The placement is
        arbitrary.
      
      * Instead of performing operations with explicit ns tag, the namespace
        callback is routed through sysfs_attr_ns(), sysfs_ops->namespace(),
        class_attr_namespace(), class_attr->namespace().  It's not simpler
        in any sense.  The only thing this convolution does is traversing
        the whole stack backwards.
      
      The namespace callbacks are unncessary because the operations involved
      are inherently synchronous.  The information can be provided in in
      straight-forward top-down direction and reversing that direction is
      unnecessary and against basic design principles.
      
      This backward interface is unnecessarily convoluted and hinders
      properly separating out sysfs from driver model / kobject for proper
      layering.  This patch updates attr ns support such that
      
      * sysfs_ops->namespace() and class_attr->namespace() are dropped.
      
      * sysfs_{create|remove}_file_ns(), which take explicit @ns param, are
        added and sysfs_{create|remove}_file() are now simple wrappers
        around the ns aware functions.
      
      * ns handling is dropped from sysfs_chmod_file().  Nobody uses it at
        this point.  sysfs_chmod_file_ns() can be added later if necessary.
      
      * Explicit @ns is propagated through class_{create|remove}_file_ns()
        and netdev_class_{create|remove}_file_ns().
      
      * driver/net/bonding which is currently the only user of attr
        namespace is updated to use netdev_class_{create|remove}_file_ns()
        with @bh->net as the ns tag instead of using the namespace callback.
      
      This patch should be an equivalent conversion without any functional
      difference.  It makes the code easier to follow, reduces lines of code
      a bit and helps proper separation and layering.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58292cbe
  2. 23 8月, 2013 1 次提交
  3. 22 8月, 2013 7 次提交
  4. 17 7月, 2013 2 次提交
  5. 26 1月, 2013 1 次提交
  6. 11 4月, 2012 1 次提交
    • B
      sysfs: Prevent crash on unset sysfs group attributes · 5631f2c1
      Bruno Prémont 提交于
      Do not let the kernel crash when a device is registered with
      sysfs while group attributes are not set (aka NULL).
      
      Warn about the offender with some information about the offending
      device.
      
      This would warn instead of trying NULL pointer deref like:
       BUG: unable to handle kernel NULL pointer dereference at (null)
       IP: [<ffffffff81152673>] internal_create_group+0x83/0x1a0
       PGD 0
       Oops: 0000 [#1] SMP
       CPU 0
       Modules linked in:
      
       Pid: 1, comm: swapper/0 Not tainted 3.4.0-rc1-x86_64 #3 HP ProLiant DL360 G4
       RIP: 0010:[<ffffffff81152673>]  [<ffffffff81152673>] internal_create_group+0x83/0x1a0
       RSP: 0018:ffff88019485fd70  EFLAGS: 00010202
       RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000001
       RDX: ffff880192e99908 RSI: ffff880192e99630 RDI: ffffffff81a26c60
       RBP: ffff88019485fdc0 R08: 0000000000000000 R09: 0000000000000000
       R10: ffff880192e99908 R11: 0000000000000000 R12: ffffffff81a16a00
       R13: ffff880192e99908 R14: ffffffff81a16900 R15: 0000000000000000
       FS:  0000000000000000(0000) GS:ffff88019bc00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000000 CR3: 0000000001a0c000 CR4: 00000000000007f0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process swapper/0 (pid: 1, threadinfo ffff88019485e000, task ffff880194878000)
       Stack:
        ffff88019485fdd0 ffff880192da9d60 0000000000000000 ffff880192e99908
        ffff880192e995d8 0000000000000001 ffffffff81a16a00 ffff880192da9d60
        0000000000000000 0000000000000000 ffff88019485fdd0 ffffffff811527be
       Call Trace:
        [<ffffffff811527be>] sysfs_create_group+0xe/0x10
        [<ffffffff81376ca6>] device_add_groups+0x46/0x80
        [<ffffffff81377d3d>] device_add+0x46d/0x6a0
        ...
      Signed-off-by: NBruno Prémont <bonbons@linux-vserver.org>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5631f2c1
  7. 04 1月, 2012 1 次提交
  8. 11 5月, 2011 1 次提交
  9. 30 11月, 2010 1 次提交
  10. 17 10月, 2010 1 次提交
  11. 22 5月, 2010 1 次提交
    • 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
  12. 27 7月, 2008 1 次提交
  13. 23 4月, 2008 1 次提交
  14. 08 2月, 2008 1 次提交
    • G
      sysfs: remove BUG_ON() from sysfs_remove_group() · 969affd2
      Greg Kroah-Hartman 提交于
      It's possible that the caller of sysfs_remove_group messed up and passed in an attribute group that was not really registered to this kobject.  But don't panic for such a foolish error, spit out a warning about what happened, and continue on our way safely.
      
      Cc: Roland Dreier <rdreier@cisco.com>
      Cc: Tejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      969affd2
  15. 24 1月, 2008 1 次提交
  16. 13 10月, 2007 2 次提交
  17. 12 7月, 2007 1 次提交
  18. 28 4月, 2007 1 次提交
  19. 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
  20. 24 6月, 2005 1 次提交
  21. 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