1. 23 1月, 2018 1 次提交
  2. 12 12月, 2013 1 次提交
    • T
      kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly · 324a56e1
      Tejun Heo 提交于
      kernfs has just been separated out from sysfs and we're already in
      full conflict mode.  Nothing can make the situation any worse.  Let's
      take the chance to name things properly.
      
      This patch performs the following renames.
      
      * s/sysfs_elem_dir/kernfs_elem_dir/
      * s/sysfs_elem_symlink/kernfs_elem_symlink/
      * s/sysfs_elem_attr/kernfs_elem_file/
      * s/sysfs_dirent/kernfs_node/
      * s/sd/kn/ in kernfs proper
      * s/parent_sd/parent/
      * s/target_sd/target/
      * s/dir_sd/parent/
      * s/to_sysfs_dirent()/rb_to_kn()/
      * misc renames of local vars when they conflict with the above
      
      Because md, mic and gpio dig into sysfs details, this patch ends up
      modifying them.  All are sysfs_dirent renames and trivial.  While we
      can avoid these by introducing a dummy wrapping struct sysfs_dirent
      around kernfs_node, given the limited usage outside kernfs and sysfs
      proper, I don't think such workaround is called for.
      
      This patch is strictly rename only and doesn't introduce any
      functional difference.
      
      - mic / gpio renames were missing.  Spotted by kbuild test robot.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      324a56e1
  3. 30 11月, 2013 20 次提交
    • T
      sysfs, kernfs: remove cross inclusions of internal headers · bfc5c173
      Tejun Heo 提交于
      fs/kernfs/kernfs-internal.h needed to include fs/sysfs/sysfs.h because
      part of kernfs core implementation was living in sysfs.
      
      fs/sysfs/sysfs.h needed to include fs/kernfs/kernfs-internal.h because
      include/linux/kernfs.h didn't expose enough interface.
      
      The separation is complete and neither is true anymore.  Remove the
      cross inclusion and make sysfs a proper user of kernfs.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfc5c173
    • T
      sysfs, kernfs: move mount core code to fs/kernfs/mount.c · fa736a95
      Tejun Heo 提交于
      Move core mount code to fs/kernfs/mount.c.  The respective
      declarations in fs/sysfs/sysfs.h are moved to
      fs/kernfs/kernfs-internal.h.
      
      This is pure relocation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa736a95
    • T
      sysfs, kernfs: make super_blocks bind to different kernfs_roots · df394fb5
      Tejun Heo 提交于
      kernfs is being updated to allow multiple sysfs_dirent hierarchies so
      that it can also be used by other users.  Currently, sysfs
      super_blocks are always attached to one kernfs_root - sysfs_root - and
      distinguished only by their namespace tags.
      
      This patch adds sysfs_super_info->root and update
      sysfs_fill/test_super() so that super_blocks are identified by the
      combination of both the associated kernfs_root and namespace tag.
      This allows mounting different kernfs hierarchies.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df394fb5
    • T
      sysfs, kernfs: introduce sysfs_root_sd · 061447a4
      Tejun Heo 提交于
      Currently, it's assumed that there's a single kernfs hierarchy in the
      system anchored at sysfs_root which is defined as a global struct.  To
      allow other users of kernfs, this will be made dynamic.  Introduce a
      new global variable sysfs_root_sd which points to &sysfs_root and
      convert all &sysfs_root users.
      
      This patch doesn't introduce any behavior difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      061447a4
    • T
      sysfs, kernfs: make sysfs_super_info->ns const · 51a35e9f
      Tejun Heo 提交于
      Add const qualifier to sysfs_super_info->ns so that it's consistent
      with other namespace tag usages in sysfs.  Because kobject doesn't use
      const qualifier for namespace tags, this ends up requiring an explicit
      cast to drop const qualifier in free_sysfs_super_info().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51a35e9f
    • T
      sysfs, kernfs: move symlink core code to fs/kernfs/symlink.c · 2072f1af
      Tejun Heo 提交于
      Move core symlink code to fs/kernfs/symlink.c.  fs/sysfs/symlink.c now
      only contains sysfs wrappers around kernfs interfaces.  The respective
      declarations in fs/sysfs/sysfs.h are moved to
      fs/kernfs/kernfs-internal.h.
      
      This is pure relocation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2072f1af
    • T
      sysfs, kernfs: move file core code to fs/kernfs/file.c · 414985ae
      Tejun Heo 提交于
      Move core file code to fs/kernfs/file.c.  fs/sysfs/file.c now contains
      sysfs kernfs_ops callbacks, sysfs wrappers around kernfs interfaces,
      and sysfs_schedule_callback().  The respective declarations in
      fs/sysfs/sysfs.h are moved to fs/kernfs/kernfs-internal.h.
      
      This is pure relocation.
      
      v2: Refreshed on top of the v2 of "sysfs, kernfs: prepare read path
          for kernfs".
      
      v3: Refreshed on top of the v3 of "sysfs, kernfs: prepare read path
          for kernfs".
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      414985ae
    • T
      sysfs, kernfs: move dir core code to fs/kernfs/dir.c · fd7b9f7b
      Tejun Heo 提交于
      Move core dir code to fs/kernfs/dir.c.  fs/sysfs/dir.c now only
      contains sysfs_warn_dup() and sysfs wrappers around kernfs interfaces.
      The respective declarations in fs/sysfs/sysfs.h are moved to
      fs/kernfs/kernfs-internal.h.
      
      This is pure relocation.
      
      v2: sysfs_symlink_target_lock was mistakenly relocated to kernfs.  It
          should remain with sysfs.  Fixed.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd7b9f7b
    • T
      sysfs, kernfs: move inode code to fs/kernfs/inode.c · ffed24e2
      Tejun Heo 提交于
      There's nothing sysfs-specific in fs/sysfs/inode.c.  Move everything
      in it to fs/kernfs/inode.c.  The respective declarations in
      fs/sysfs/sysfs.h are moved to fs/kernfs/kernfs-internal.h.
      
      This is pure relocation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffed24e2
    • T
      sysfs, kernfs: move internal decls to fs/kernfs/kernfs-internal.h · ae6621b0
      Tejun Heo 提交于
      Move data structure, constant and basic accessor declarations from
      fs/sysfs/sysfs.h to fs/kernfs/kernfs-internal.h.  The two files
      currently include each other.  Once kernfs / sysfs separation is
      complete, the cross inclusions will be removed.  Inclusion protectors
      are added to fs/sysfs/sysfs.h to allow cross-inclusion.
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae6621b0
    • T
      sysfs, kernfs: introduce kernfs[_find_and]_get() and kernfs_put() · ccf73cf3
      Tejun Heo 提交于
      Introduce kernfs interface for finding, getting and putting
      sysfs_dirents.
      
      * sysfs_find_dirent() is renamed to kernfs_find_ns() and lockdep
        assertion for sysfs_mutex is added.
      
      * sysfs_get_dirent_ns() is renamed to kernfs_find_and_get().
      
      * Macro inline dancing around __sysfs_get/put() are removed and
        kernfs_get/put() are made proper functions implemented in
        fs/sysfs/dir.c.
      
      While the conversions are mostly equivalent, there's one difference -
      kernfs_get() doesn't return the input param as its return value.  This
      change is intentional.  While passing through the input increases
      writability in some areas, it is unnecessary and has been shown to
      cause confusion regarding how the last ref is handled.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ccf73cf3
    • T
      sysfs, kernfs: revamp sysfs_dirent active_ref lockdep annotation · 517e64f5
      Tejun Heo 提交于
      Currently, sysfs_dirent active_ref lockdep annotation uses
      attribute->[s]key as the lockdep key, which forces
      kernfs_create_file_ns() to assume that sysfs_dirent->priv is pointing
      to a struct attribute which may not be true for non-sysfs users.  This
      patch restructures the lockdep annotation such that
      
      * kernfs_ops contains lockdep_key which is used by default for files
        created kernfs_create_file_ns().
      
      * kernfs_create_file_ns_key() is introduced which takes an extra @key
        argument.  The created file will use the specified key for
        active_ref lockdep annotation.  If NULL is specified, lockdep for
        the file is disabled.
      
      * sysfs_add_file_mode_ns() is updated to use
        kernfs_create_file_ns_key() with the appropriate key from the
        attribute or NULL if ignore_lockdep is set.
      
      This makes the lockdep annotation properly contained in kernfs while
      allowing sysfs to cleanly keep its current behavior.  This patch
      doesn't introduce any behavior differences.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      517e64f5
    • T
      sysfs, kernfs: reorganize SYSFS_* constants · 2b25a629
      Tejun Heo 提交于
      We want to add one more SYSFS_FLAG_* but we can't use the next higher
      bit, 0x10000, as the flag field is 16bits wide.  The flags are
      currently arranged weirdly - 8 bits are set aside for the type flags
      when there are only three three used, the first flag starts at 0x1000
      instead of 0x0100 and flag literals have 5 digits (20 bits) when only
      4 digits can be used.
      
      Rearrange them so that type bits are only the lowest four, flags start
      at 0x0010 and similar flags are grouped.
      
      This patch doesn't cause any behavior difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b25a629
    • T
      sysfs, kernfs: remove sysfs_add_one() · 2d0cfbec
      Tejun Heo 提交于
      sysfs_add_one() is a wrapper around __sysfs_add_one() which prints out
      duplicate name warning if __sysfs_add_one() fails with -EEXIST.  The
      previous kernfs conversions moved all dup warnings to sysfs interface
      functions and sysfs_add_one() doesn't have any user left.
      
      Remove sysfs_add_one() and update __sysfs_add_one() to take its name.
      
      This patch doesn't make any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d0cfbec
    • T
      sysfs, kernfs: remove SYSFS_KOBJ_BIN_ATTR · a7dc66df
      Tejun Heo 提交于
      After kernfs_ops and sysfs_dirent->s_attr.size addition, the
      distinction between SYSFS_KOBJ_BIN_ATTR and SYSFS_KOBJ_ATTR is only
      necessary while creating files to decide which kernfs_ops to use.
      Afterwards, they behave exactly the same.
      
      This patch removes SYSFS_KOBJ_BIN_ATTR along with sysfs_is_bin().
      sysfs_add_file[_mode_ns]() are updated to take bool @is_bin instead of
      @type.
      
      This patch doesn't introduce any behavior changes.  This completely
      isolates the distinction between the two sysfs file types in the sysfs
      layer proper.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7dc66df
    • T
      sysfs, kernfs: add sysfs_dirent->s_attr.size · 471bd7b7
      Tejun Heo 提交于
      sysfs sets the size of regular files unconditionally at PAGE_SIZE and
      takes the size of bin files from bin_attribute.  The latter is a
      pretty bad interface which forces bin_attribute users to create a
      separate copy of bin_attribute for each instance of the file -
      e.g. pci resource files.
      
      Add sysfs_dirent->s_attr.size so that the size can be specified
      separately.  This unifies inode init paths of ATTR and BIN_ATTR
      identical and allows for generic size handling for kernfs.
      
      Unfortunately, this grows the size of sysfs_dirent by sizeof(loff_t).
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      471bd7b7
    • T
      sysfs, kernfs: introduce kernfs_ops · f6acf8bb
      Tejun Heo 提交于
      We're in the process of separating out core sysfs functionality into
      kernfs which will deal with sysfs_dirents directly.  This patch
      introduces kernfs_ops which hosts methods kernfs users implement and
      updates fs/sysfs/file.c such that sysfs_kf_*() functions populate
      kernfs_ops and kernfs_file_*() functions call the matching entries
      from kernfs_ops.
      
      kernfs_ops contains the following groups of methods.
      
      * seq_show() - for kernfs files which use seq_file for reads.
      
      * read() - for direct read implementations.  Used iff seq_show() is
        not implemented.
      
      * write() - for writes.
      
      * mmap() - for mmaps.
      
      Notes:
      
      * sysfs_elem_attr->ops is added so that kernfs_ops can be accessed
        from sysfs_dirent.  kernfs_ops() helper is added to verify locking
        and access the field.
      
      * SYSFS_FLAG_HAS_(SEQ_SHOW|MMAP) added.  sd->s_attr->ops is accessible
        only while holding active_ref and there are cases where we want to
        take different actions depending on which ops are implemented.
        These two flags cache whether the two ops are implemented for those.
      
      * kernfs_file_*() no longer test sysfs type but chooses different
        behaviors depending on which methods in kernfs_ops are implemented.
        The conversions are trivial except for the open path.  As
        kernfs_file_open() now decides whether to allow read/write accesses
        depending on the kernfs_ops implemented, the presence of methods in
        kobjs and attribute_bin should be propagated to kernfs_ops.
        sysfs_add_file_mode_ns() is updated so that it propagates presence /
        absence of the callbacks through _empty, _ro, _wo, _rw kernfs_ops.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f6acf8bb
    • T
      sysfs, kernfs: prepare open, release, poll paths for kernfs · c6fb4495
      Tejun Heo 提交于
      We're in the process of separating out core sysfs functionality into
      kernfs which will deal with sysfs_dirents directly.  This patch
      prepares the rest - open, release and poll.  There isn't much to do.
      Just renaming is enough.  As sysfs_file_operations and
      sysfs_bin_operations are identical now, use the same file_operations
      for both - kernfs_file_operations.
      
      This patch doesn't introduce any behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6fb4495
    • T
      sysfs, kernfs: introduce kernfs_create_dir[_ns]() · 93b2b8e4
      Tejun Heo 提交于
      Introduce kernfs interface to manipulate a directory which takes and
      returns sysfs_dirents.
      
      create_dir() is renamed to kernfs_create_dir_ns() and its argumantes
      and return value are updated.  create_dir() usages are replaced with
      kernfs_create_dir_ns() and sysfs_create_subdir() usages are replaced
      with kernfs_create_dir().  Dup warnings are handled explicitly by
      sysfs users of the kernfs interface.
      
      sysfs_enable_ns() is renamed to kernfs_enable_ns().
      
      This patch doesn't introduce any behavior changes.
      
      v2: Dummy implementation for !CONFIG_SYSFS updated to return -ENOSYS.
      
      v3: kernfs_enable_ns() added.
      
      v4: Refreshed on top of "sysfs: drop kobj_ns_type handling, take #2"
          so that this patch removes sysfs_enable_ns().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93b2b8e4
    • T
      sysfs, kernfs: replace sysfs_dirent->s_dir.kobj and ->s_attr.[bin_]attr with ->priv · 7c6e2d36
      Tejun Heo 提交于
      A directory sysfs_dirent points to the associated kobj.  A regular or
      bin file points to the associated [bin_]attribute.  This patch
      replaces sysfs_dirent->s_dir.kobj and ->s_attr.[bin_]attr with void *
      ->priv.
      
      This is to prepare for kernfs interface so that sysfs can specify the
      private data in the same way for directories and files.  This lower
      debuggability but not by much - the whole thing was overlaid in a
      union anyway.  If debuggability becomes an issue, we can later add
      ->priv accessors which explicitly check for the sysfs_dirent type and
      performs casting.
      
      This patch doesn't introduce any behavior difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c6e2d36
  4. 28 11月, 2013 4 次提交
    • T
      sysfs, kernfs: introduce kernfs_setattr() · 5d60418e
      Tejun Heo 提交于
      Introduce kernfs setattr interface - kernfs_setattr().
      
      sysfs_sd_setattr() is renamed to __kernfs_setattr() and
      kernfs_setattr() is a simple wrapper around it with sysfs_mutex
      locking.  sysfs_chmod_file() is updated to get an explicit ref on
      kobj->sd and then invoke kernfs_setattr() so that it doesn't have to
      use internal interface.
      
      This patch doesn't introduce any behavior differences.
      
      v2: Dummy implementation for !CONFIG_SYSFS updated to return -ENOSYS.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d60418e
    • T
      sysfs, kernfs: introduce kernfs_rename[_ns]() · 890ece16
      Tejun Heo 提交于
      Introduce kernfs rename interface, krenfs_rename[_ns]().
      
      This is just rename of sysfs_rename().  No functional changes.
      Function comment is added to kernfs_rename_ns() and @new_parent_sd is
      renamed to @new_parent for consistency with other kernfs interfaces.
      
      v2: Dummy implementation for !CONFIG_SYSFS updated to return -ENOSYS.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      890ece16
    • T
      sysfs, kernfs: introduce kernfs_remove[_by_name[_ns]]() · 879f40d1
      Tejun Heo 提交于
      Introduce kernfs removal interfaces - kernfs_remove() and
      kernfs_remove_by_name[_ns]().
      
      These are just renames of sysfs_remove() and sysfs_hash_and_remove().
      No functional changes.
      
      v2: Dummy kernfs_remove_by_name_ns() for !CONFIG_SYSFS updated to
          return -ENOSYS instead of 0.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      879f40d1
    • T
      sysfs: drop kobj_ns_type handling, take #2 · c84a3b27
      Tejun Heo 提交于
      The way namespace tags are implemented in sysfs is more complicated
      than necessary.  As each tag is a pointer value and required to be
      non-NULL under a namespace enabled parent, there's no need to record
      separately what type each tag is.  If multiple namespace types are
      needed, which currently aren't, we can simply compare the tag to a set
      of allowed tags in the superblock assuming that the tags, being
      pointers, won't have the same value across multiple types.
      
      This patch rips out kobj_ns_type handling from sysfs.  sysfs now has
      an enable switch to turn on namespace under a node.  If enabled, all
      children are required to have non-NULL namespace tags and filtered
      against the super_block's tag.
      
      kobject namespace determination is now performed in
      lib/kobject.c::create_dir() making sysfs_read_ns_type() unnecessary.
      The sanity checks are also moved.  create_dir() is restructured to
      ease such addition.  This removes most kobject namespace knowledge
      from sysfs proper which will enable proper separation and layering of
      sysfs.
      
      This is the second try.  The first one was cb26a311 ("sysfs: drop
      kobj_ns_type handling") which tried to automatically enable namespace
      if there are children with non-NULL namespace tags; however, it was
      broken for symlinks as they should inherit the target's tag iff
      namespace is enabled in the parent.  This led to namespace filtering
      enabled incorrectly for wireless net class devices through phy80211
      symlinks and thus network configuration failure.  a1212d27
      ("Revert "sysfs: drop kobj_ns_type handling"") reverted the commit.
      
      This shouldn't introduce any behavior changes, for real.
      
      v2: Dummy implementation of sysfs_enable_ns() for !CONFIG_SYSFS was
          missing and caused build failure.  Reported by kbuild test robot.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c84a3b27
  5. 07 11月, 2013 1 次提交
    • L
      Revert "sysfs: drop kobj_ns_type handling" · a1212d27
      Linus Torvalds 提交于
      This reverts commit cb26a311.
      
      It mysteriously causes NetworkManager to not find the wireless device
      for me.  As far as I can tell, Tejun *meant* for this commit to not make
      any semantic changes, but there clearly are some.  So revert it, taking
      into account some of the calling convention changes that happened in
      this area in subsequent commits.
      
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a1212d27
  6. 02 11月, 2013 1 次提交
    • T
      sysfs: rename sysfs_assoc_lock and explain what it's about · 0cae60f9
      Tejun Heo 提交于
      sysfs_assoc_lock is an odd piece of locking.  In general, whoever owns
      a kobject is responsible for synchronizing sysfs operations and sysfs
      proper assumes that, for example, removal won't race with any other
      operation; however, this doesn't work for symlinking because an entity
      performing symlink doesn't usually own the target kobject and thus has
      no control over its removal.
      
      sysfs_assoc_lock synchronizes symlink operations against kobj->sd
      disassociation so that symlink code doesn't end up dereferencing
      already freed sysfs_dirent by racing with removal of the target
      kobject.
      
      This is quite obscure and the generic name of the lock and lack of
      comments make it difficult to understand its role.  Let's rename it to
      sysfs_symlink_target_lock and add comments explaining what's going on.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cae60f9
  7. 30 10月, 2013 5 次提交
  8. 14 10月, 2013 1 次提交
    • T
      sysfs: make sysfs_file_ops() follow ignore_lockdep flag · 785a162d
      Tejun Heo 提交于
      375b611e ("sysfs: remove sysfs_buffer->ops") introduced
      sysfs_file_ops() which determines the associated file operation of a
      given sysfs_dirent.  As file ops access should be protected by an
      active reference, the new function includes a lockdep assertion on the
      sysfs_dirent; unfortunately, I forgot to take attr->ignore_lockdep
      flag into account and the lockdep assertion trips spuriously for files
      which opt out from active reference lockdep checking.
      
      # cat /sys/devices/pci0000:00/0000:00:01.2/usb1/authorized
      
       ------------[ cut here ]------------
       WARNING: CPU: 1 PID: 540 at /work/os/work/fs/sysfs/file.c:79 sysfs_file_ops+0x4e/0x60()
       Modules linked in:
       CPU: 1 PID: 540 Comm: cat Not tainted 3.11.0-work+ #3
       Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
        0000000000000009 ffff880016205c08 ffffffff81ca0131 0000000000000000
        ffff880016205c40 ffffffff81096d0d ffff8800166cb898 ffff8800166f6f60
        ffffffff8125a220 ffff880011ab1ec0 ffff88000aff0c78 ffff880016205c50
       Call Trace:
        [<ffffffff81ca0131>] dump_stack+0x4e/0x82
        [<ffffffff81096d0d>] warn_slowpath_common+0x7d/0xa0
        [<ffffffff81096dea>] warn_slowpath_null+0x1a/0x20
        [<ffffffff8125994e>] sysfs_file_ops+0x4e/0x60
        [<ffffffff8125a274>] sysfs_open_file+0x54/0x300
        [<ffffffff811df612>] do_dentry_open.isra.17+0x182/0x280
        [<ffffffff811df820>] finish_open+0x30/0x40
        [<ffffffff811f0623>] do_last+0x503/0xd90
        [<ffffffff811f0f6b>] path_openat+0xbb/0x6d0
        [<ffffffff811f23ba>] do_filp_open+0x3a/0x90
        [<ffffffff811e09a9>] do_sys_open+0x129/0x220
        [<ffffffff811e0abe>] SyS_open+0x1e/0x20
        [<ffffffff81caf3c2>] system_call_fastpath+0x16/0x1b
       ---[ end trace aa48096b111dafdb ]---
      
      Rename fs/sysfs/dir.c::ignore_lockdep() to sysfs_ignore_lockdep() and
      move it to fs/sysfs/sysfs.h and make sysfs_file_ops() skip lockdep
      assertion if sysfs_ignore_lockdep() is true.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      785a162d
  9. 06 10月, 2013 3 次提交
    • T
      sysfs: merge regular and bin file handling · 3124eb16
      Tejun Heo 提交于
      With the previous changes, sysfs regular file code is ready to handle
      bin files too.  This patch makes bin files share the regular file
      path.
      
      * sysfs_create/remove_bin_file() are moved to fs/sysfs/file.c.
      
      * sysfs_init_inode() is updated to use the new sysfs_bin_operations
        instead of bin_fops for bin files.
      
      * fs/sysfs/bin.c and the related pieces are removed.
      
      This patch shouldn't introduce any behavior difference to bin file
      accesses.
      
      Overall, this unification reduces the amount of duplicate logic, makes
      behaviors more consistent and paves the road for building simpler and
      more versatile interface which will allow other subsystems to make use
      of sysfs for their pseudo filesystems.
      
      v2: Stale fs/sysfs/bin.c reference dropped from
          Documentation/DocBook/filesystems.tmpl.  Reported by kbuild test
          robot.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3124eb16
    • T
      sysfs: copy bin mmap support from fs/sysfs/bin.c to fs/sysfs/file.c · 73d97146
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch copies mmap support from bin so that fs/sysfs/file.c can
      handle mmapping bin files.
      
      The code is copied mostly verbatim with the following updates.
      
      * ->mmapped and ->vm_ops are added to sysfs_open_file and bin_buffer
        references are replaced with sysfs_open_file ones.
      
      * Symbols are prefixed with sysfs_.
      
      * sysfs_unmap_bin_file() grabs sysfs_open_dirent and traverses
        ->files.  Invocation of this function is added to
        sysfs_addrm_finish().
      
      * sysfs_bin_mmap() is added to sysfs_bin_operations.
      
      This is a preparation and the new mmap path isn't used yet.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73d97146
    • T
      sysfs: prepare path write for unified regular / bin file handling · f9b9a621
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch prepares the write path.
      
      bin file write is almost identical to regular file write except that
      the write length is capped by the inode size and @off is passed to the
      write method.  This patch adds bin file handling to sysfs_write_file()
      so that it can handle both regular and bin files.
      
      A new file_operations struct sysfs_bin_operations is added, which
      currently only hosts sysfs_write_file() and generic_file_llseek().
      This isn't used yet but will eventually replace fs/sysfs/bin.c.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9b9a621
  10. 04 10月, 2013 2 次提交
    • T
      sysfs: introduce [__]sysfs_remove() · 250f7c3f
      Tejun Heo 提交于
      Given a sysfs_dirent, there is no reason to have multiple versions of
      removal functions.  A function which removes the specified
      sysfs_dirent and its descendants is enough.
      
      This patch intorduces [__}sysfs_remove() which replaces all internal
      variations of removal functions.  This will be the only removal
      function in the planned new sysfs_dirent based interface.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      250f7c3f
    • T
      sysfs: remove sysfs_addrm_cxt->parent_sd · d69ac5a0
      Tejun Heo 提交于
      sysfs_addrm_start/finish() enclose sysfs_dirent additions and
      deletions and sysfs_addrm_cxt is used to record information necessary
      to finish the operations.  Currently, sysfs_addrm_start() takes
      @parent_sd, records it in sysfs_addrm_cxt, and assumes that all
      operations in the block are performed under that @parent_sd.
      
      This assumption has been fine until now but we want to make some
      operations behave recursively and, while having @parent_sd recorded in
      sysfs_addrm_cxt doesn't necessarily prevents that, it becomes
      confusing.
      
      This patch removes sysfs_addrm_cxt->parent_sd and makes
      sysfs_add_one() take an explicit @parent_sd parameter.  Note that
      sysfs_remove_one() doesn't need the extra argument as its parent is
      always known from the target @sd.
      
      While at it, add __acquires/releases() notations to
      sysfs_addrm_start/finish() respectively.
      
      This patch doesn't make any functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d69ac5a0
  11. 27 9月, 2013 1 次提交
    • T
      sysfs: @name comes before @ns · cfec0bc8
      Tejun Heo 提交于
      Some internal sysfs functions which take explicit namespace argument
      are weird in that they place the optional @ns in front of @name which
      is contrary to the established convention.  This is confusing and
      error-prone especially as @ns and @name may be interchanged without
      causing compilation warning.
      
      Swap the positions of @name and @ns in the following internal
      functions.
      
       sysfs_find_dirent()
       sysfs_rename()
       sysfs_hash_and_remove()
       sysfs_name_hash()
       sysfs_name_compare()
       create_dir()
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfec0bc8