1. 04 1月, 2012 2 次提交
  2. 20 10月, 2011 1 次提交
    • E
      sysfs: Implement support for tagged files in sysfs. · 487505c2
      Eric W. Biederman 提交于
      Looking up files in sysfs is hard to understand and analyize because we
      currently allow placing untagged files in tagged directories.  In the
      implementation of that we have two subtly different meanings of NULL.
      NULL meaning there is no tag on a directory entry and NULL meaning
      we don't care which namespace the lookup is performed for.  This
      multiple uses of NULL have resulted in subtle bugs (since fixed)
      in the code.
      
      Currently it is only the bonding driver that needs to have an untagged
      file in a tagged directory.
      
      To untagle this mess I am adding support for tagged files to sysfs.
      Modifying the bonding driver to implement bonding_masters as a tagged
      file.  Registering bonding_masters once for each network namespace.
      Then I am removing support for untagged entries in tagged sysfs
      directories.
      
      Resulting in code that is much easier to reason about.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      487505c2
  3. 27 7月, 2011 1 次提交
  4. 13 6月, 2011 1 次提交
    • A
      Delay struct net freeing while there's a sysfs instance refering to it · a685e089
      Al Viro 提交于
      	* new refcount in struct net, controlling actual freeing of the memory
      	* new method in kobj_ns_type_operations (->drop_ns())
      	* ->current_ns() semantics change - it's supposed to be followed by
      corresponding ->drop_ns().  For struct net in case of CONFIG_NET_NS it bumps
      the new refcount; net_drop_ns() decrements it and calls net_free() if the
      last reference has been dropped.  Method renamed to ->grab_current_ns().
      	* old net_free() callers call net_drop_ns() instead.
      	* sysfs_exit_ns() is gone, along with a large part of callchain
      leading to it; now that the references stored in ->ns[...] stay valid we
      do not need to hunt them down and replace them with NULL.  That fixes
      problems in sysfs_lookup() and sysfs_readdir(), along with getting rid
      of sb->s_instances abuse.
      
      	Note that struct net *shutdown* logics has not changed - net_cleanup()
      is called exactly when it used to be called.  The only thing postponed by
      having a sysfs instance refering to that struct net is actual freeing of
      memory occupied by struct net.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      a685e089
  5. 14 5月, 2011 1 次提交
  6. 17 10月, 2010 1 次提交
  7. 24 8月, 2010 1 次提交
  8. 06 8月, 2010 2 次提交
  9. 22 5月, 2010 5 次提交
    • 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
    • C
      sysfs: add struct file* to bin_attr callbacks · 2c3c8bea
      Chris Wright 提交于
      This allows bin_attr->read,write,mmap callbacks to check file specific data
      (such as inode owner) as part of any privilege validation.
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2c3c8bea
    • E
      sysfs: Don't use enums in inline function declaration. · 27eabc7c
      Eric W. Biederman 提交于
      It appears gcc can't cope with using an enum that is only declared in
      an inline function declaration, that doesn't even use the variable
      that is so declared.
      
      Avoid the silliness and replace the enum with an int, and make gcc
      happy.
      Signed-off-by: NEric W. Biederman <ebiederm@aristanetworks.com>
      Acked-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      27eabc7c
    • S
      sysfs: Comment sysfs directory tagging logic · be867b19
      Serge E. Hallyn 提交于
      Add some in-line comments to explain the new infrastructure, which
      was introduced to support sysfs directory tagging with namespaces.
      I think an overall description someplace might be good too, but it
      didn't really seem to fit into Documentation/filesystems/sysfs.txt,
      which appears more geared toward users, rather than maintainers, of
      sysfs.
      
      (Tejun, please let me know if I can make anything clearer or failed
      altogether to comment something that should be commented.)
      Signed-off-by: NSerge E. Hallyn <serue@us.ibm.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Tejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      be867b19
    • 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
  10. 08 3月, 2010 5 次提交
  11. 24 12月, 2009 1 次提交
  12. 20 10月, 2008 1 次提交
    • P
      x86: sysfs: kill owner field from attribute · 01e8ef11
      Parag Warudkar 提交于
      Tejun's commit 7b595756 made sysfs
      attribute->owner unnecessary.  But the field was left in the structure to
      ease the merge.  It's been over a year since that change and it is now
      time to start killing attribute->owner along with its users - one arch at
      a time!
      
      This patch is attempt #1 to get rid of attribute->owner only for
      CONFIG_X86_64 or CONFIG_X86_32 .  We will deal with other arches later on
      as and when possible - avr32 will be the next since that is something I
      can test.  Compile (make allyesconfig / make allmodconfig / custom config)
      and boot tested.
      
      akpm: the idea is that we put the declaration of sttribute.owner inside
      `#ifndef CONFIG_X86'.  But that proved to be too ambitious for now because
      new usages kept on turning up in subsystem trees.
      
      [akpm: remove the ifdef for now]
      Signed-off-by: NParag Warudkar <parag.lkml@gmail.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Tejun Heo <htejun@gmail.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Jean Delvare <khali@linux-fr.org>
      Cc: Roland Dreier <rolandd@cisco.com>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      01e8ef11
  13. 17 10月, 2008 5 次提交
    • E
      kobject: Cleanup kobject_rename and !CONFIG_SYSFS · 0b4a4fea
      Eric W. Biederman 提交于
      It finally dawned on me what the clean fix to sysfs_rename_dir
      calling kobject_set_name is.  Move the work into kobject_rename
      where it belongs.  The callers serialize us anyway so this is
      safe.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0b4a4fea
    • E
      kobject: Fix kobject_rename and !CONFIG_SYSFS · 030c1d2b
      Eric W. Biederman 提交于
      When looking at kobject_rename I found two bugs with
      that exist when sysfs support is disabled in the kernel.
      
      kobject_rename does not change the name on the kobject when
      sysfs support is not compiled in.
      
      kobject_rename without locking attempts to check the
      validity of a rename operation, which the kobject layer
      simply does not have the infrastructure to do.
      
      This patch documents the previously unstated requirement of
      kobject_rename that is the responsibility of the caller to
      provide mutual exclusion and to be certain that the new_name
      for the kobject is valid.
      
      This patch modifies sysfs_rename_dir in !CONFIG_SYSFS case
      to call kobject_set_name to actually change the kobject_name.
      
      This patch removes the bogus and misleading check in kobject_rename
      that attempts to see if a rename is valid.  The check is bogus
      because we do not have the proper locking.  The check is misleading
      because it looks like we can and do perform checking at the kobject
      level that we don't.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      030c1d2b
    • T
      sysfs: Make dir and name args to sysfs_notify() const · 8c0e3998
      Trent Piepho 提交于
      Because they can be, and because code like this produces a warning if
      they're not:
      
      struct device_attribute dev_attr;
      
      sysfs_notify(&kobj, NULL, dev_attr.attr.name);
      Signed-off-by: NTrent Piepho <tpiepho@freescale.com>
      CC: Neil Brown <neilb@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8c0e3998
    • N
      sysfs: Support sysfs_notify from atomic context with new sysfs_notify_dirent · f1282c84
      Neil Brown 提交于
      Support sysfs_notify from atomic context with new sysfs_notify_dirent
      
      sysfs_notify currently takes sysfs_mutex.
      This means that it cannot be called in atomic context.
      sysfs_mutex  is sometimes held over a malloc (sysfs_rename_dir)
      so it can block on low memory.
      
      In md I want to be able to notify on a sysfs attribute from
      atomic context, and I don't want to block on low memory because I
      could be in the writeout path for freeing memory.
      
      So:
       - export the "sysfs_dirent" structure along with sysfs_get, sysfs_put
         and sysfs_get_dirent so I can get the sysfs_dirent that I want to
         notify on and hold it in an md structure.
       - split sysfs_notify_dirent out of sysfs_notify so the sysfs_dirent
         can be notified on with no blocking (just a spinlock).
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f1282c84
    • A
      sysfs: crash debugging · ae87221d
      Andrew Morton 提交于
      Print the name of the last-accessed sysfs file when we oops, to help track
      down oopses which occur in sysfs store/read handlers.  Because these oopses
      tend to not leave any trace of the offending code in the stack traces.
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ae87221d
  14. 22 7月, 2008 1 次提交
  15. 05 5月, 2008 1 次提交
    • I
      sysfs: build fix · e73b65f1
      Ingo Molnar 提交于
      x86.git testing found the following build failure on v2.6.26-rc1:
      
        In file included from include/linux/kobject.h:22,
                         from include/linux/module.h:17,
                         from include/linux/crypto.h:22,
                         from arch/x86/kernel/asm-offsets_32.c:8,
                         from arch/x86/kernel/asm-offsets.c:3:
        include/linux/sysfs.h:201: error: redefinition of 'sysfs_update_group'
        include/linux/sysfs.h:195: error: previous definition of 'sysfs_update_group' was here
        make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
        make: *** [prepare0] Error 2
      
      with the following config:
      
          http://redhat.com/~mingo/misc/config-Sun_May__4_07_09_30_CEST_2008.bad
      
      the reason for the build failure is the duplicate definition of the
      sysfs_update_group() inline function in include/linux/sysfs.h.
      
      The duplication was a merge error: it was added via -mm by commit
      v2.6.25-7262-g2850699c, "sysfs: sysfs_update_group stub for
      CONFIG_SYSFS=n" a day before v2.6.26-rc1, but a day before that the same
      commit was already merged upstream via the sysfs tree, with commit
      v2.6.25-7211-g1cbfb7a5.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e73b65f1
  16. 01 5月, 2008 2 次提交
  17. 23 4月, 2008 1 次提交
  18. 20 4月, 2008 1 次提交
  19. 24 1月, 2008 1 次提交
  20. 13 10月, 2007 4 次提交
  21. 12 7月, 2007 2 次提交
    • Z
      sysfs: add parameter "struct bin_attribute *" in .read/.write methods for sysfs binary attributes · 91a69029
      Zhang Rui 提交于
      Well, first of all, I don't want to change so many files either.
      
      What I do:
      Adding a new parameter "struct bin_attribute *" in the
      .read/.write methods for the sysfs binary attributes.
      
      In fact, only the four lines change in fs/sysfs/bin.c and
      include/linux/sysfs.h do the real work.
      But I have to update all the files that use binary attributes
      to make them compatible with the new .read and .write methods.
      I'm not sure if I missed any. :(
      
      Why I do this:
      For a sysfs attribute, we can get a pointer pointing to the
      struct attribute in the .show/.store method,
      while we can't do this for the binary attributes.
      I don't know why this is different, but this does make it not
      so handy to use the binary attributes as the regular ones.
      So I think this patch is reasonable. :)
      
      Who benefits from it:
      The patch that exposes ACPI tables in sysfs
      requires such an improvement.
      All the table binary attributes share the same .read method.
      Parameter "struct bin_attribute *" is used to get
      the table signature and instance number which are used to
      distinguish different ACPI table binary attributes.
      
      Without this parameter, we need to offer different .read methods
      for different ACPI table binary attributes.
      This is impossible as there are various ACPI tables on different
      platforms, and we don't know what they are until they are loaded.
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      91a69029
    • T
      sysfs: make directory dentries and inodes reclaimable · 51225039
      Tejun Heo 提交于
      This patch makes dentries and inodes for sysfs directories
      reclaimable.
      
      * sysfs_notify() is modified to walk sysfs_dirent tree instead of
        dentry tree.
      
      * sysfs_update_file() and sysfs_chmod_file() use sysfs_get_dentry() to
        grab the victim dentry.
      
      * sysfs_rename_dir() and sysfs_move_dir() grab all dentries using
        sysfs_get_dentry() on startup.
      
      * Dentries for all shadowed directories are pinned in memory to serve
        as lookup start point.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      51225039