1. 12 12月, 2013 3 次提交
    • T
      kernfs: s/sysfs/kernfs/ in various data structures · c525aadd
      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_open_dirent/kernfs_open_node/
      * s/sysfs_open_file/kernfs_open_file/
      * s/sysfs_inode_attrs/kernfs_iattrs/
      * s/sysfs_addrm_cxt/kernfs_addrm_cxt/
      * s/sysfs_super_info/kernfs_super_info/
      * s/sysfs_info()/kernfs_info()/
      * s/sysfs_open_dirent_lock/kernfs_open_node_lock/
      * s/sysfs_open_file_mutex/kernfs_open_file_mutex/
      * s/sysfs_of()/kernfs_of()/
      
      This patch is strictly rename only and doesn't introduce any
      functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c525aadd
    • T
      kernfs: drop s_ prefix from kernfs_node members · adc5e8b5
      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.
      
      s_ prefix for kernfs members is used inconsistently and a misnomer
      now.  It's not like kernfs_node is used widely across the kernel
      making the ability to grep for the members particularly useful.  Let's
      just drop the prefix.
      
      This patch is strictly rename only and doesn't introduce any
      functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adc5e8b5
    • 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
  2. 04 12月, 2013 2 次提交
    • T
      kernfs: implement "trusted.*" xattr support · 2322392b
      Tejun Heo 提交于
      kernfs inherited "security.*" xattr support from sysfs.  This patch
      extends xattr support to "trusted.*" using simple_xattr_*().  As
      trusted xattrs are restricted to CAP_SYS_ADMIN, simple_xattr_*() which
      uses kernel memory for storage shouldn't be problematic.
      
      Note that the existing "security.*" support doesn't implement
      get/remove/list and the this patch only implements those ops for
      "trusted.*".  We probably want to extend those ops to include support
      for "security.*".
      
      This patch will allow using kernfs from cgroup which requires
      "trusted.*" xattr support.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: David P. Quigley <dpquigl@tycho.nsa.gov>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2322392b
    • T
      kernfs: update sysfs_init_inode_attrs() · 9a8049af
      Tejun Heo 提交于
      sysfs_init_inode_attrs() is a bit clumsy to use requiring the caller
      to check whether @sd->s_iattr is already set or not.  Rename it to
      sysfs_inode_attrs(), update it to check whether @sd->s_iattr is
      already initialized before trying to initialize it and return
      @sd->s_iattr.  This simplifies the callers.
      
      While at it,
      
      * Rename struct sysfs_inode_attrs pointer variables to "attrs".  As
        kernfs no longer deals with "struct attribute", this isn't confusing
        and makes it easier to distinguish from struct iattr pointers.
      
      * A new field will be added to sysfs_inode_attrs.  Reindent in
        preparation.
      
      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>
      9a8049af
  3. 30 11月, 2013 11 次提交
    • 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: make sysfs_dirent definition public · cf9e5a73
      Tejun Heo 提交于
      sysfs_dirent includes some information which should be available to
      kernfs users - the type, flags, name and parent pointer.  This patch
      moves sysfs_dirent definition from kernfs/kernfs-internal.h to
      include/linux/kernfs.h so that kernfs users can access them.
      
      The type part of flags is exported as enum kernfs_node_type, the flags
      kernfs_node_flag, sysfs_type() and kernfs_enable_ns() are moved to
      include/linux/kernfs.h and the former is updated to return the enum
      type.  sysfs_dirent->s_parent and ->s_name are marked explicitly as
      public.
      
      This patch doesn't introduce any functional changes.
      
      v2: Flags exported too and kernfs_enable_ns() definition moved.
      
      v3: While moving kernfs_enable_ns() to include/linux/kernfs.h, v1 and
          v2 put the definition outside CONFIG_SYSFS replacing the dummy
          implementation with the actual implementation too.  Unfortunately,
          this can lead to oops when !CONFIG_SYSFS because
          kernfs_enable_ns() may be called on a NULL @sd and now tries to
          dereference @sd instead of not doing anything.  This issue was
          reported by Yuanhan Liu.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NYuanhan Liu <yuanhan.liu@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf9e5a73
    • 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: prepare mount path for kernfs · 4b93dc9b
      Tejun Heo 提交于
      We're in the process of separating out core sysfs functionality into
      kernfs which will deal with sysfs_dirents directly.  This patch
      rearranges mount path so that the kernfs and sysfs parts are separate.
      
      * As sysfs_super_info won't be visible outside kernfs proper,
        kernfs_super_ns() is added to allow kernfs users to access a
        super_block's namespace tag.
      
      * Generic mount operation is separated out into kernfs_mount_ns().
        sysfs_mount() now just performs sysfs-specific permission check,
        acquires namespace tag, and invokes kernfs_mount_ns().
      
      * Generic superblock release is separated out into kernfs_kill_sb()
        which can be used directly as file_system_type->kill_sb().  As sysfs
        needs to put the namespace tag, sysfs_kill_sb() wraps
        kernfs_kill_sb() with ns tag put.
      
      * sysfs_dir_cachep init and sysfs_inode_init() are separated out into
        kernfs_init().  kernfs_init() uses only small amount of memory and
        trying to handle and propagate kernfs_init() failure doesn't make
        much sense.  Use SLAB_PANIC for sysfs_dir_cachep and make
        sysfs_inode_init() panic on failure.
      
        After this change, kernfs_init() should be called before
        sysfs_init(), fs/namespace.c::mnt_init() modified accordingly.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b93dc9b
    • T
      sysfs, kernfs: make inode number ida per kernfs_root · bc755553
      Tejun Heo 提交于
      kernfs is being updated to allow multiple sysfs_dirent hierarchies so
      that it can also be used by other users.  Currently, inode number is
      allocated using a global ida, sysfs_ino_ida; however, inos for
      different hierarchies should be handled separately.
      
      This patch makes ino allocation per kernfs_root.  sysfs_ino_ida is
      replaced by kernfs_root->ino_ida and sysfs_new_dirent() is updated to
      take @root and allocate ino from it.  ida_simple_get/remove() are used
      instead of sysfs_ino_lock and sysfs_alloc/free_ino().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc755553
    • T
      sysfs, kernfs: implement kernfs_create/destroy_root() · ba7443bc
      Tejun Heo 提交于
      There currently is single kernfs hierarchy in the whole system which
      is used for sysfs.  kernfs needs to support multiple hierarchies to
      allow other users.  This patch introduces struct kernfs_root which
      serves as the root of each kernfs hierarchy and implements
      kernfs_create/destroy_root().
      
      * Each kernfs_root is associated with a root sd (sysfs_dentry).  The
        root is freed when the root sd is released and kernfs_destory_root()
        simply invokes kernfs_remove() on the root sd.  sysfs_remove_one()
        is updated to handle release of the root sd.  Note that ps_iattr
        update in sysfs_remove_one() is trivially updated for readability.
      
      * Root sd's are now dynamically allocated using sysfs_new_dirent().
        Update sysfs_alloc_ino() so that it gives out ino from 1 so that the
        root sd still gets ino 1.
      
      * While kernfs currently only points to the root sd, it'll soon grow
        fields which are specific to each hierarchy.  As determining a given
        sd's root will be necessary, sd->s_dir.root is added.  This backlink
        fits better as a separate field in sd; however, sd->s_dir is inside
        union with space to spare, so use it to save space and provide
        kernfs_root() accessor to determine the root sd.
      
      * As hierarchies may be destroyed now, each mount needs to hold onto
        the hierarchy it's attached to.  Update sysfs_fill_super() and
        sysfs_kill_sb() so that they get and put the kernfs_root
        respectively.
      
      * sysfs_root is replaced with kernfs_root which is dynamically created
        by invoking kernfs_create_root() from sysfs_init().
      
      This patch doesn't introduce any visible behavior changes.
      
      v2: kernfs_create_root() forgot to set @sd->priv.  Fixed.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba7443bc
    • 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