kernfs: s/sysfs/kernfs/
Subsystems (6)
Tejun Heo
maintainerPATCH 1/1 kernfs: s/sysfs/kernfs/
Hello,
kernfs just got separated out from sysfs and contains a lot of names carried over from sysfs which are misnomers. Thanks to the code movement and large-scale reorganization, kernfs code is already in full conflict mode with any patches generated against sysfs prior the separation and in a lot of cases those conflicts won't be simple "file moved there" conflicts but deeper ones due to the large scale refactoring which happened for the separation.
We can't really make the situation much worse. Let's take the chance and rename things so that the misnomers in kernfs don't cause confusions in the future.
This patchset contains the following six rename patches.
0001-kernfs-s-sysfs_dirent-kernfs_node-and-rename-its-fri.patch 0002-kernfs-drop-s_-prefix-from-kernfs_node-members.patch 0003-kernfs-s-sysfs-kernfs-in-various-data-structures.patch 0004-kernfs-s-sysfs-kernfs-in-constants.patch 0005-kernfs-s-sysfs-kernfs-in-global-variables.patch 0006-kernfs-s-sysfs-kernfs-in-internal-functions-and-what.patch
While the patches are fairly large, they are all trivial rename patches. Nothing else. There's no functional change to the code base before and after.
This patchset is based on the current driver-core-next a8b1c0193602 ("Documentation: start documenting driver design patterns") and also available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-kernfs-rename
diffstat follows.
drivers/gpio/gpiolib.c | 4 drivers/md/bitmap.c | 2 drivers/md/bitmap.h | 2 drivers/md/md.h | 10 drivers/misc/mic/host/mic_device.h | 2 fs/kernfs/dir.c | 776 ++++++++++++++++++------------------- fs/kernfs/file.c | 389 +++++++++--------- fs/kernfs/inode.c | 227 +++++----- fs/kernfs/kernfs-internal.h | 96 ++-- fs/kernfs/mount.c | 56 +- fs/kernfs/symlink.c | 110 ++--- fs/sysfs/dir.c | 66 +-- fs/sysfs/file.c | 132 +++--- fs/sysfs/group.c | 96 ++-- fs/sysfs/mount.c | 4 fs/sysfs/symlink.c | 76 +-- fs/sysfs/sysfs.h | 10 include/linux/kernfs.h | 226 +++++----- include/linux/kobject.h | 2 include/linux/sysfs.h | 20 lib/kobject.c | 2 21 files changed, 1154 insertions(+), 1154 deletions(-)
Thanks.
--
tejun
Tejun Heo
maintainerPATCH 2/6 kernfs: drop s_ prefix from kernfs_node members
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.
--- fs/kernfs/dir.c | 198 ++++++++++++++++++++++---------------------- fs/kernfs/file.c | 52 ++++++------ fs/kernfs/inode.c | 30 +++---- fs/kernfs/kernfs-internal.h | 6 +- fs/kernfs/symlink.c | 32 +++---- fs/sysfs/dir.c | 12 +-- fs/sysfs/file.c | 16 ++-- fs/sysfs/symlink.c | 6 +- include/linux/kernfs.h | 38 ++++----- 9 files changed, 193 insertions(+), 197 deletions(-)
fs/kernfs/dir.c +97 -101
@@ -19,7 +19,7 @@DEFINE_MUTEX (sysfs_mutex); -#define rb_to_kn (X ) rb_entry((X), struct kernfs_node, s_rb) +#define rb_to_kn (X ) rb_entry((X), struct kernfs_node, rb)/** * sysfs_name_hash
@@ -47,18 +47,17 @@ static unsigned int sysfs_name_hash(const char *name, const void *ns)static int sysfs_name_compare (unsigned int hash,const char *name,const void *ns,const struct kernfs_node *kn) { -if (hash != kn->s_hash) -return hash - kn->s_hash; -if (ns != kn->s_ns) -return ns - kn->s_ns; -return strcmp (name, kn->s_name); +if (hash != kn->hash) +return hash - kn->hash; +if (ns != kn->ns) +return ns - kn->ns; +return strcmp (name, kn->name); }static int sysfs_sd_compare (const struct kernfs_node *left,const struct kernfs_node *right) { -return sysfs_name_compare (left->s_hash, left->s_name, left->s_ns, - right); +return sysfs_name_compare (left->hash, left->name, left->ns, right); }/**
@@ -66,7 +65,7 @@ static int sysfs_sd_compare(const struct kernfs_node *left,* @kn: kernfs_node of interest * * Link @kn into its sibling rbtree which starts from -* @kn->s_parent->s_dir.children. +* @kn->parent->dir.children. * * Locking: * mutex_lock(sysfs_mutex)
@@ -76,11 +75,11 @@ static int sysfs_sd_compare(const struct kernfs_node *left,*/ static int sysfs_link_sibling (struct kernfs_node *kn) { -struct rb_node **node = &kn->s_parent->s_dir.children.rb_node; +struct rb_node **node = &kn->parent->dir.children.rb_node;struct rb_node *parent =NULL ;if (sysfs_type (kn) ==SYSFS_DIR ) - kn->s_parent->s_dir.subdirs++; + kn->parent->dir.subdirs++;while (*node) {struct kernfs_node *pos;
@@ -90,15 +89,15 @@ static int sysfs_link_sibling(struct kernfs_node *kn) parent = *node; result =sysfs_sd_compare (kn, pos);if (result <0 ) - node = &pos->s_rb.rb_left; + node = &pos->rb.rb_left;else if (result >0 ) - node = &pos->s_rb.rb_right; + node = &pos->rb.rb_right;else return -EEXIST ; }/* add new node and rebalance the tree */ -rb_link_node (&kn->s_rb, parent, node); -rb_insert_color (&kn->s_rb, &kn->s_parent->s_dir.children); +rb_link_node (&kn->rb, parent, node); +rb_insert_color (&kn->rb, &kn->parent->dir.children);return 0 ; }
@@ -107,7 +106,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)* @kn: kernfs_node of interest * * Unlink @kn from its sibling rbtree which starts from -* kn->s_parent->s_dir.children. +* kn->parent->dir.children. * * Locking: * mutex_lock(sysfs_mutex)
@@ -115,9 +114,9 @@ static int sysfs_link_sibling(struct kernfs_node *kn)static void sysfs_unlink_sibling (struct kernfs_node *kn) {if (sysfs_type (kn) ==SYSFS_DIR ) - kn->s_parent->s_dir.subdirs--; + kn->parent->dir.subdirs--; -rb_erase (&kn->s_rb, &kn->s_parent->s_dir.children); +rb_erase (&kn->rb, &kn->parent->dir.children); }/**
@@ -135,10 +134,10 @@ struct kernfs_node *sysfs_get_active(struct kernfs_node *kn)if (unlikely (!kn))return NULL ; -if (!atomic_inc_unless_negative (&kn->s_active)) +if (!atomic_inc_unless_negative (&kn->active))return NULL ; -if (kn->s_flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &SYSFS_FLAG_LOCKDEP )rwsem_acquire_read (&kn->dep_map,0 ,1 , _RET_IP_);return kn; }
@@ -157,9 +156,9 @@ void sysfs_put_active(struct kernfs_node *kn)if (unlikely (!kn))return ; -if (kn->s_flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &SYSFS_FLAG_LOCKDEP )rwsem_release (&kn->dep_map,1 , _RET_IP_); - v =atomic_dec_return (&kn->s_active); + v =atomic_dec_return (&kn->active);if (likely (v !=SD_DEACTIVATED_BIAS ))return ;
@@ -181,7 +180,7 @@ static void sysfs_deactivate(struct kernfs_node *kn)DECLARE_COMPLETION_ONSTACK (wait);int v; -BUG_ON (!(kn->s_flags &SYSFS_FLAG_REMOVED )); +BUG_ON (!(kn->flags &SYSFS_FLAG_REMOVED ));if (!(sysfs_type (kn) &SYSFS_ACTIVE_REF ))return ;
@@ -192,7 +191,7 @@ static void sysfs_deactivate(struct kernfs_node *kn)/* atomic_add_return() is a mb(), put_active() will always see * the updated kn->u.completion. */ - v =atomic_add_return (SD_DEACTIVATED_BIAS , &kn->s_active); + v =atomic_add_return (SD_DEACTIVATED_BIAS , &kn->active);if (v !=SD_DEACTIVATED_BIAS ) {lock_contended (&kn->dep_map, _RET_IP_);
@@ -210,8 +209,8 @@ static void sysfs_deactivate(struct kernfs_node *kn)void kernfs_get (struct kernfs_node *kn) {if (kn) { -WARN_ON (!atomic_read (&kn->s_count)); -atomic_inc (&kn->s_count); +WARN_ON (!atomic_read (&kn->count)); +atomic_inc (&kn->count); } }EXPORT_SYMBOL_GPL (kernfs_get);
@@ -227,36 +226,36 @@ void kernfs_put(struct kernfs_node *kn)struct kernfs_node *parent;struct kernfs_root *root; -if (!kn || !atomic_dec_and_test (&kn->s_count)) +if (!kn || !atomic_dec_and_test (&kn->count))return ; root =kernfs_root (kn); repeat:/* Moving/renaming is always done while holding reference. -* kn->s_parent won't change beneath us. +* kn->parent won't change beneath us. */ - parent = kn->s_parent; + parent = kn->parent; -WARN (!(kn->s_flags &SYSFS_FLAG_REMOVED ), +WARN (!(kn->flags &SYSFS_FLAG_REMOVED ),"sysfs: free using entry: %s/%s\n" , - parent ? parent->s_name :"" , kn->s_name); + parent ? parent->name :"" , kn->name);if (sysfs_type (kn) ==SYSFS_KOBJ_LINK ) -kernfs_put (kn->s_symlink.target_kn); +kernfs_put (kn->symlink.target_kn);if (sysfs_type (kn) &SYSFS_COPY_NAME ) -kfree (kn->s_name); -if (kn->s_iattr) { -if (kn->s_iattr->ia_secdata) -security_release_secctx (kn->s_iattr->ia_secdata, - kn->s_iattr->ia_secdata_len); -simple_xattrs_free (&kn->s_iattr->xattrs); +kfree (kn->name); +if (kn->iattr) { +if (kn->iattr->ia_secdata) +security_release_secctx (kn->iattr->ia_secdata, + kn->iattr->ia_secdata_len); +simple_xattrs_free (&kn->iattr->xattrs); } -kfree (kn->s_iattr); -ida_simple_remove (&root->ino_ida, kn->s_ino); +kfree (kn->iattr); +ida_simple_remove (&root->ino_ida, kn->ino);kmem_cache_free (sysfs_dir_cachep, kn); kn = parent;if (kn) { -if (atomic_dec_and_test (&kn->s_count)) +if (atomic_dec_and_test (&kn->count)) goto repeat; }else {/* just released the root kn, free @root too */
@@ -269,7 +268,7 @@ EXPORT_SYMBOL_GPL(kernfs_put);static int sysfs_dentry_delete (const struct dentry *dentry) {struct kernfs_node *kn = dentry->d_fsdata; -return !(kn && !(kn->s_flags &SYSFS_FLAG_REMOVED )); +return !(kn && !(kn->flags &SYSFS_FLAG_REMOVED )); }static int sysfs_dentry_revalidate (struct dentry *dentry,unsigned int flags)
@@ -283,20 +282,20 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)mutex_lock (&sysfs_mutex);/* The sysfs dirent has been deleted */ -if (kn->s_flags &SYSFS_FLAG_REMOVED ) +if (kn->flags &SYSFS_FLAG_REMOVED ) goto out_bad;/* The sysfs dirent has been moved? */ -if (dentry->d_parent->d_fsdata != kn->s_parent) +if (dentry->d_parent->d_fsdata != kn->parent) goto out_bad;/* The sysfs dirent has been renamed */ -if (strcmp (dentry->d_name.name, kn->s_name) !=0 ) +if (strcmp (dentry->d_name.name, kn->name) !=0 ) goto out_bad;/* The sysfs dirent has been moved to a different namespace */ -if (kn->s_parent &&kernfs_ns_enabled (kn->s_parent) && -sysfs_info (dentry->d_sb)->ns != kn->s_ns) +if (kn->parent &&kernfs_ns_enabled (kn->parent) && +sysfs_info (dentry->d_sb)->ns != kn->ns) goto out_bad;mutex_unlock (&sysfs_mutex);
@@ -356,14 +355,14 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, ret =ida_simple_get (&root->ino_ida,1 ,0 ,GFP_KERNEL );if (ret <0 ) goto err_out2; - kn->s_ino = ret; + kn->ino = ret; -atomic_set (&kn->s_count,1 ); -atomic_set (&kn->s_active,0 ); +atomic_set (&kn->count,1 ); +atomic_set (&kn->active,0 ); - kn->s_name = name; - kn->s_mode = mode; - kn->s_flags = type |SYSFS_FLAG_REMOVED ; + kn->name = name; + kn->mode = mode; + kn->flags = type |SYSFS_FLAG_REMOVED ;return kn;
@@ -400,9 +399,9 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt)* @kn: kernfs_node to be added * @parent: the parent kernfs_node to add @kn to * -* Get @parent and set @kn->s_parent to it and increment nlink of -* the parent inode if @kn is a directory and link into the children -* list of the parent. +* Get @parent and set @kn->parent to it and increment nlink of the +* parent inode if @kn is a directory and link into the children list +* of the parent. * * This function should be called between calls to * sysfs_addrm_start() and sysfs_addrm_finish() and should be
@@ -422,18 +421,17 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct kernfs_node *kn,struct sysfs_inode_attrs *ps_iattr;int ret; -if (has_ns != (bool )kn->s_ns) { +if (has_ns != (bool )kn->ns) {WARN (1 ,KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n" , - has_ns ?"required" :"invalid" , - parent->s_name, kn->s_name); + has_ns ?"required" :"invalid" , parent->name, kn->name);return -EINVAL ; }if (sysfs_type (parent) !=SYSFS_DIR )return -EINVAL ; - kn->s_hash =sysfs_name_hash (kn->s_name, kn->s_ns); - kn->s_parent = parent; + kn->hash =sysfs_name_hash (kn->name, kn->ns); + kn->parent = parent;kernfs_get (parent); ret =sysfs_link_sibling (kn);
@@ -441,14 +439,14 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct kernfs_node *kn,return ret;/* Update timestamps on the parent */ - ps_iattr = parent->s_iattr; + ps_iattr = parent->iattr;if (ps_iattr) {struct iattr *ps_iattrs = &ps_iattr->ia_iattr; ps_iattrs->ia_ctime = ps_iattrs->ia_mtime =CURRENT_TIME ; }/* Mark the entry added into directory tree */ - kn->s_flags &= ~SYSFS_FLAG_REMOVED ; + kn->flags &= ~SYSFS_FLAG_REMOVED ;return 0 ; }
@@ -477,21 +475,21 @@ static void sysfs_remove_one(struct sysfs_addrm_cxt *acxt,* Removal can be called multiple times on the same node. Only the * first invocation is effective and puts the base ref. */ -if (kn->s_flags &SYSFS_FLAG_REMOVED ) +if (kn->flags &SYSFS_FLAG_REMOVED )return ; -if (kn->s_parent) { +if (kn->parent) {sysfs_unlink_sibling (kn);/* Update timestamps on the parent */ - ps_iattr = kn->s_parent->s_iattr; + ps_iattr = kn->parent->iattr;if (ps_iattr) { ps_iattr->ia_iattr.ia_ctime =CURRENT_TIME ; ps_iattr->ia_iattr.ia_mtime =CURRENT_TIME ; } } - kn->s_flags |=SYSFS_FLAG_REMOVED ; + kn->flags |=SYSFS_FLAG_REMOVED ; kn->u.removed_list = acxt->removed; acxt->removed = kn; }
@@ -538,7 +536,7 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,const unsigned char *name, const void *ns) { - struct rb_node *node = parent->s_dir.children.rb_node; + struct rb_node *node = parent->dir.children.rb_node;bool has_ns =kernfs_ns_enabled (parent);unsigned int hash;
@@ -546,8 +544,7 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,if (has_ns != (bool )ns) {WARN (1 ,KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n" , - has_ns ?"required" :"invalid" , - parent->s_name, name); + has_ns ?"required" :"invalid" , parent->name, name);return NULL ; }
@@ -617,9 +614,9 @@ struct kernfs_root *kernfs_create_root(void *priv)return ERR_PTR (-ENOMEM ); } - kn->s_flags &= ~SYSFS_FLAG_REMOVED ; + kn->flags &= ~SYSFS_FLAG_REMOVED ; kn->priv = priv; - kn->s_dir.root = root; + kn->dir.root = root; root->kn = kn;
@@ -661,8 +658,8 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,if (!kn)return ERR_PTR (-ENOMEM ); - kn->s_dir.root = parent->s_dir.root; - kn->s_ns = ns; + kn->dir.root = parent->dir.root; + kn->ns = ns; kn->priv = priv;/* link in */
@@ -738,7 +735,7 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos)if (sysfs_type (pos) !=SYSFS_DIR )break ; - rbn =rb_first (&pos->s_dir.children); + rbn =rb_first (&pos->dir.children);if (!rbn)break ;
@@ -773,12 +770,12 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,return NULL ;/* if there's an unvisited sibling, visit its leftmost descendant */ - rbn =rb_next (&pos->s_rb); + rbn =rb_next (&pos->rb);if (rbn)return sysfs_leftmost_descendant (rb_to_kn (rbn));/* no sibling left, visit parent */ -return pos->s_parent; +return pos->parent; } static void __kernfs_remove(struct sysfs_addrm_cxt *acxt,
@@ -789,7 +786,7 @@ static void __kernfs_remove(struct sysfs_addrm_cxt *acxt,if (!kn)return ; -pr_debug ("sysfs %s: removing\n" , kn->s_name); +pr_debug ("sysfs %s: removing\n" , kn->name); next =NULL ; do {
@@ -865,8 +862,8 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,mutex_lock (&sysfs_mutex); error =0 ; -if ((kn->s_parent == new_parent) && (kn->s_ns == new_ns) && - (strcmp (kn->s_name, new_name) ==0 )) +if ((kn->parent == new_parent) && (kn->ns == new_ns) && + (strcmp (kn->name, new_name) ==0 )) goto out;/* nothing to rename */ error = -EEXIST ;
@@ -874,14 +871,14 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, goto out;/* rename kernfs_node */ -if (strcmp (kn->s_name, new_name) !=0 ) { +if (strcmp (kn->name, new_name) !=0 ) { error = -ENOMEM ; new_name =kstrdup (new_name,GFP_KERNEL );if (!new_name) goto out; -kfree (kn->s_name); - kn->s_name = new_name; +kfree (kn->name); + kn->name = new_name; }/*
@@ -889,10 +886,10 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,*/ sysfs_unlink_sibling (kn);kernfs_get (new_parent); -kernfs_put (kn->s_parent); - kn->s_ns = new_ns; - kn->s_hash =sysfs_name_hash (kn->s_name, kn->s_ns); - kn->s_parent = new_parent; +kernfs_put (kn->parent); + kn->ns = new_ns; + kn->hash =sysfs_name_hash (kn->name, kn->ns); + kn->parent = new_parent;sysfs_link_sibling (kn); error =0 ;
@@ -904,7 +901,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,/* Relationship between s_mode and the DT_xxx types */ static inline unsigned char dt_type (struct kernfs_node *kn) { -return (kn->s_mode >>12 ) &15 ; +return (kn->mode >>12 ) &15 ; }static int sysfs_dir_release (struct inode *inode,struct file *filp)
@@ -917,29 +914,28 @@ static struct kernfs_node *sysfs_dir_pos(const void *ns, struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) { if (pos) { - int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) && - pos->s_parent == parent && - hash == pos->s_hash; + int valid = !(pos->flags & SYSFS_FLAG_REMOVED) && + pos->parent == parent && hash == pos->hash;kernfs_put (pos);if (!valid) pos =NULL ; }if (!pos && (hash >1 ) && (hash <INT_MAX )) { -struct rb_node *node = parent->s_dir.children.rb_node; +struct rb_node *node = parent->dir.children.rb_node;while (node) { pos =rb_to_kn (node); -if (hash < pos->s_hash) +if (hash < pos->hash) node = node->rb_left; -else if (hash > pos->s_hash) +else if (hash > pos->hash) node = node->rb_right;else break ; } }/* Skip over entries in the wrong namespace */ -while (pos && pos->s_ns != ns) { -struct rb_node *node =rb_next (&pos->s_rb); +while (pos && pos->ns != ns) { +struct rb_node *node =rb_next (&pos->rb);if (!node) pos =NULL ;else
@@ -954,12 +950,12 @@ static struct kernfs_node *sysfs_dir_next_pos(const void *ns, pos =sysfs_dir_pos (ns, parent, ino, pos);if (pos)do { -struct rb_node *node =rb_next (&pos->s_rb); +struct rb_node *node =rb_next (&pos->rb);if (!node) pos =NULL ;else pos =rb_to_kn (node); - }while (pos && pos->s_ns != ns); + }while (pos && pos->ns != ns);return pos; }
@@ -980,12 +976,12 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)for (pos =sysfs_dir_pos (ns, parent, ctx->pos, pos); pos; pos =sysfs_dir_next_pos (ns, parent, ctx->pos, pos)) { -const char *name = pos->s_name; +const char *name = pos->name;unsigned int type =dt_type (pos);int len =strlen (name); -ino_t ino = pos->s_ino; +ino_t ino = pos->ino; - ctx->pos = pos->s_hash; + ctx->pos = pos->hash; file->private_data = pos;kernfs_get (pos);
fs/kernfs/file.c +26 -26
158 lines not on this page · raw message
fs/kernfs/inode.c +15 -15
@@ -50,23 +50,23 @@ static struct sysfs_inode_attrs *sysfs_inode_attrs(struct kernfs_node *kn) {struct iattr *iattrs; -if (kn->s_iattr) -return kn->s_iattr; +if (kn->iattr) +return kn->iattr; - kn->s_iattr =kzalloc (sizeof (struct sysfs_inode_attrs ),GFP_KERNEL ); -if (!kn->s_iattr) + kn->iattr =kzalloc (sizeof (struct sysfs_inode_attrs ),GFP_KERNEL ); +if (!kn->iattr)return NULL ; - iattrs = &kn->s_iattr->ia_iattr; + iattrs = &kn->iattr->ia_iattr;/* assign default attributes */ - iattrs->ia_mode = kn->s_mode; + iattrs->ia_mode = kn->mode; iattrs->ia_uid =GLOBAL_ROOT_UID ; iattrs->ia_gid =GLOBAL_ROOT_GID ; iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime =CURRENT_TIME ; -simple_xattrs_init (&kn->s_iattr->xattrs); +simple_xattrs_init (&kn->iattr->xattrs); -return kn->s_iattr; +return kn->iattr; }static int __kernfs_setattr (struct kernfs_node *kn,const struct iattr *iattr)
@@ -93,7 +93,7 @@ static int __kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr) iattrs->ia_ctime = iattr->ia_ctime;if (ia_valid &ATTR_MODE ) {umode_t mode = iattr->ia_mode; - iattrs->ia_mode = kn->s_mode = mode; + iattrs->ia_mode = kn->mode = mode; }return 0 ; }
@@ -256,9 +256,9 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)static void sysfs_refresh_inode (struct kernfs_node *kn,struct inode *inode) { -struct sysfs_inode_attrs *attrs = kn->s_iattr; +struct sysfs_inode_attrs *attrs = kn->iattr; - inode->i_mode = kn->s_mode; + inode->i_mode = kn->mode;if (attrs) {/* * kernfs_node has non-default attributes get them from
@@ -270,7 +270,7 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) }if (sysfs_type (kn) ==SYSFS_DIR ) -set_nlink (inode, kn->s_dir.subdirs +2 ); +set_nlink (inode, kn->dir.subdirs +2 ); } int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -295,7 +295,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; inode->i_op = &sysfs_inode_operations; -set_default_inode_attr (inode, kn->s_mode); +set_default_inode_attr (inode, kn->mode);sysfs_refresh_inode (kn, inode);/* initialize inode according to type */
@@ -305,7 +305,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) inode->i_fop = &sysfs_dir_operations;break ;case SYSFS_KOBJ_ATTR : - inode->i_size = kn->s_attr.size; + inode->i_size = kn->attr.size; inode->i_fop = &kernfs_file_operations;break ;case SYSFS_KOBJ_LINK :
@@ -337,7 +337,7 @@ struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn) {struct inode *inode; - inode =iget_locked (sb, kn->s_ino); + inode =iget_locked (sb, kn->ino);if (inode && (inode->i_state &I_NEW ))sysfs_init_inode (kn, inode);
fs/kernfs/kernfs-internal.h +3 -3
@@ -39,9 +39,9 @@ struct sysfs_inode_attrs {static inline struct kernfs_root *kernfs_root (struct kernfs_node *kn) {/* if parent exists, it's always a dir; otherwise, @sd is a dir */ -if (kn->s_parent) - kn = kn->s_parent; -return kn->s_dir.root; +if (kn->parent) + kn = kn->parent; +return kn->dir.root; }/*
fs/kernfs/symlink.c +16 -16
@@ -36,8 +36,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,return ERR_PTR (-ENOMEM );if (kernfs_ns_enabled (parent)) - kn->s_ns = target->s_ns; - kn->s_symlink.target_kn = target; + kn->ns = target->ns; + kn->symlink.target_kn = target;kernfs_get (target);/* ref owned by symlink */ sysfs_addrm_start (&acxt);
@@ -60,24 +60,24 @@ static int sysfs_get_target_path(struct kernfs_node *parent,/* go up to the root, stop at the base */ base = parent; -while (base->s_parent) { - kn = target->s_parent; -while (kn->s_parent && base != kn) - kn = kn->s_parent; +while (base->parent) { + kn = target->parent; +while (kn->parent && base != kn) + kn = kn->parent;if (base == kn)break ;strcpy (s,"../" ); s +=3 ; - base = base->s_parent; + base = base->parent; }/* determine end of target string for reverse fillup */ kn = target; -while (kn->s_parent && kn != base) { - len +=strlen (kn->s_name) +1 ; - kn = kn->s_parent; +while (kn->parent && kn != base) { + len +=strlen (kn->name) +1 ; + kn = kn->parent; }/* check limits */
@@ -89,15 +89,15 @@ static int sysfs_get_target_path(struct kernfs_node *parent,/* reverse fillup of target string from target to base */ kn = target; -while (kn->s_parent && kn != base) { -int slen =strlen (kn->s_name); +while (kn->parent && kn != base) { +int slen =strlen (kn->name); len -= slen; -strncpy (s + len, kn->s_name, slen); +strncpy (s + len, kn->name, slen);if (len) s[--len] ='/' ; - kn = kn->s_parent; + kn = kn->parent; }return 0 ;
@@ -106,8 +106,8 @@ static int sysfs_get_target_path(struct kernfs_node *parent,static int sysfs_getlink (struct dentry *dentry,char *path) {struct kernfs_node *kn = dentry->d_fsdata; -struct kernfs_node *parent = kn->s_parent; -struct kernfs_node *target = kn->s_symlink.target_kn; +struct kernfs_node *parent = kn->parent; +struct kernfs_node *target = kn->symlink.target_kn;int error;mutex_lock (&sysfs_mutex);
fs/sysfs/dir.c +6 -6
@@ -29,11 +29,11 @@ DEFINE_SPINLOCK(sysfs_symlink_target_lock);*/ static char *sysfs_pathname (struct kernfs_node *kn,char *path) { -if (kn->s_parent) { -sysfs_pathname (kn->s_parent, path); +if (kn->parent) { +sysfs_pathname (kn->parent, path);strlcat (path,"/" ,PATH_MAX ); } -strlcat (path, kn->s_name,PATH_MAX ); +strlcat (path, kn->name,PATH_MAX );return path; }
@@ -121,7 +121,7 @@ void sysfs_remove_dir(struct kobject *kobj)int sysfs_rename_dir_ns (struct kobject *kobj,const char *new_name,const void *new_ns) { -struct kernfs_node *parent = kobj->sd->s_parent; +struct kernfs_node *parent = kobj->sd->parent;return kernfs_rename_ns (kobj->sd, parent, new_name, new_ns); }
@@ -132,9 +132,9 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,struct kernfs_node *kn = kobj->sd;struct kernfs_node *new_parent; -BUG_ON (!kn->s_parent); +BUG_ON (!kn->parent); new_parent = new_parent_kobj && new_parent_kobj->sd ? new_parent_kobj->sd : sysfs_root_kn; -return kernfs_rename_ns (kn, new_parent, kn->s_name, new_ns); +return kernfs_rename_ns (kn, new_parent, kn->name, new_ns); }
fs/sysfs/file.c +8 -8
@@ -27,9 +27,9 @@*/ static const struct sysfs_ops *sysfs_file_ops (struct kernfs_node *kn) { -struct kobject *kobj = kn->s_parent->priv; +struct kobject *kobj = kn->parent->priv; -if (kn->s_flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &SYSFS_FLAG_LOCKDEP )lockdep_assert_held (kn);return kobj->ktype ? kobj->ktype->sysfs_ops :NULL ; }
@@ -42,7 +42,7 @@ static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)static int sysfs_kf_seq_show (struct seq_file *sf,void *v) {struct sysfs_open_file *of = sf->private; -struct kobject *kobj = of->kn->s_parent->priv; +struct kobject *kobj = of->kn->parent->priv;const struct sysfs_ops *ops =sysfs_file_ops (of->kn);ssize_t count;char *buf;
@@ -82,7 +82,7 @@ static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf, size_t count, loff_t pos) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->s_parent->priv; +struct kobject *kobj = of->kn->parent->priv;loff_t size =file_inode (of->file)->i_size;if (!count)
@@ -106,7 +106,7 @@ static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf, size_t count, loff_t pos) {const struct sysfs_ops *ops =sysfs_file_ops (of->kn); -struct kobject *kobj = of->kn->s_parent->priv; +struct kobject *kobj = of->kn->parent->priv;if (!count)return 0 ;
@@ -119,7 +119,7 @@ static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf, size_t count, loff_t pos) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->s_parent->priv; +struct kobject *kobj = of->kn->parent->priv;loff_t size =file_inode (of->file)->i_size;if (size) {
@@ -140,7 +140,7 @@ static int sysfs_kf_bin_mmap(struct sysfs_open_file *of, struct vm_area_struct *vma) {struct bin_attribute *battr = of->kn->priv; -struct kobject *kobj = of->kn->s_parent->priv; +struct kobject *kobj = of->kn->parent->priv;return battr->mmap (of->file, kobj, battr, vma); }
@@ -345,7 +345,7 @@ int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr,if (!kn)return -ENOENT ; - newattrs.ia_mode = (mode &S_IALLUGO ) | (kn->s_mode & ~S_IALLUGO ); + newattrs.ia_mode = (mode &S_IALLUGO ) | (kn->mode & ~S_IALLUGO ); newattrs.ia_valid =ATTR_MODE ; rc =kernfs_setattr (kn, &newattrs);
fs/sysfs/symlink.c +3 -3
@@ -129,7 +129,7 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,*/ spin_lock (&sysfs_symlink_target_lock);if (targ->sd &&kernfs_ns_enabled (kobj->sd)) - ns = targ->sd->s_ns; + ns = targ->sd->ns;spin_unlock (&sysfs_symlink_target_lock);kernfs_remove_by_name_ns (kobj->sd, name, ns); }
@@ -175,7 +175,7 @@ int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ, parent = kobj->sd;if (targ->sd) - old_ns = targ->sd->s_ns; + old_ns = targ->sd->ns; result = -ENOENT ; kn =kernfs_find_and_get_ns (parent, old, old_ns);
@@ -185,7 +185,7 @@ int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ, result = -EINVAL ;if (sysfs_type (kn) !=SYSFS_KOBJ_LINK ) goto out; -if (kn->s_symlink.target_kn->priv != targ) +if (kn->symlink.target_kn->priv != targ) goto out; result =kernfs_rename_ns (kn, parent, new, new_ns);
include/linux/kernfs.h +19 -19
@@ -49,7 +49,7 @@ enum kernfs_node_flag {/* type-specific structures for kernfs_node union members */ struct kernfs_elem_dir {unsigned long subdirs; -/* children rbtree starts here and goes through kn->s_rb */ +/* children rbtree starts here and goes through kn->rb */ struct rb_root children;/*
@@ -79,36 +79,36 @@ struct kernfs_elem_attr {* active reference. */ struct kernfs_node { -atomic_t s_count; -atomic_t s_active; +atomic_t count; +atomic_t active;#ifdef CONFIG_DEBUG_LOCK_ALLOC struct lockdep_map dep_map;#endif /* the following two fields are published */ -struct kernfs_node *s_parent; -const char *s_name; +struct kernfs_node *parent; +const char *name; -struct rb_node s_rb; +struct rb_node rb;union {struct completion *completion;struct kernfs_node *removed_list; } u; -const void *s_ns;/* namespace tag */ -unsigned int s_hash;/* ns + name hash */ +const void *ns;/* namespace tag */ +unsigned int hash;/* ns + name hash */ union { -struct kernfs_elem_dir s_dir; -struct kernfs_elem_symlink s_symlink; -struct kernfs_elem_attr s_attr; +struct kernfs_elem_dir dir; +struct kernfs_elem_symlink symlink; +struct kernfs_elem_attr attr; };void *priv; -unsigned short s_flags; -umode_t s_mode; -unsigned int s_ino; -struct sysfs_inode_attrs *s_iattr; +unsigned short flags; +umode_t mode; +unsigned int ino; +struct sysfs_inode_attrs *iattr; };struct kernfs_root {
@@ -172,7 +172,7 @@ struct kernfs_ops {static inline enum kernfs_node_type sysfs_type (struct kernfs_node *kn) { -return kn->s_flags &SYSFS_TYPE_MASK ; +return kn->flags &SYSFS_TYPE_MASK ; }/**
@@ -186,8 +186,8 @@ static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)static inline void kernfs_enable_ns (struct kernfs_node *kn) {WARN_ON_ONCE (sysfs_type (kn) !=SYSFS_DIR ); -WARN_ON_ONCE (!RB_EMPTY_ROOT (&kn->s_dir.children)); - kn->s_flags |=SYSFS_FLAG_NS ; +WARN_ON_ONCE (!RB_EMPTY_ROOT (&kn->dir.children)); + kn->flags |=SYSFS_FLAG_NS ; }/**
@@ -198,7 +198,7 @@ static inline void kernfs_enable_ns(struct kernfs_node *kn)*/ static inline bool kernfs_ns_enabled (struct kernfs_node *kn) { -return kn->s_flags &SYSFS_FLAG_NS ; +return kn->flags &SYSFS_FLAG_NS ; } struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
Signature · 1 line
1.8.4.2
Tejun Heo
maintainerPATCH 1/6 kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
In reply to Tejun Heokernfs 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.
--- drivers/gpio/gpiolib.c | 4 +- drivers/md/bitmap.c | 2 +- drivers/md/bitmap.h | 2 +- drivers/md/md.h | 10 +- drivers/misc/mic/host/mic_device.h | 2 +- fs/kernfs/dir.c | 542 ++++++++++++++++++------------------- fs/kernfs/file.c | 186 ++++++------- fs/kernfs/inode.c | 123 ++++----- fs/kernfs/kernfs-internal.h | 40 +-- fs/kernfs/mount.c | 12 +- fs/kernfs/symlink.c | 64 ++--- fs/sysfs/dir.c | 66 ++--- fs/sysfs/file.c | 122 ++++----- fs/sysfs/group.c | 96 +++---- fs/sysfs/mount.c | 4 +- fs/sysfs/symlink.c | 72 ++--- fs/sysfs/sysfs.h | 10 +- include/linux/kernfs.h | 166 ++++++------ include/linux/kobject.h | 2 +- include/linux/sysfs.h | 20 +- lib/kobject.c | 2 +- 21 files changed, 774 insertions(+), 773 deletions(-)
drivers/gpio/gpiolib.c +2 -2
@@ -393,7 +393,7 @@ static const DEVICE_ATTR(value, 0644,static irqreturn_t gpio_sysfs_irq (int irq,void *priv) { -struct sysfs_dirent *value_sd = priv; +struct kernfs_node *value_sd = priv;sysfs_notify_dirent (value_sd);return IRQ_HANDLED ;
@@ -402,7 +402,7 @@ static irqreturn_t gpio_sysfs_irq(int irq, void *priv)static int gpio_setup_irq (struct gpio_desc *desc,struct device *dev,unsigned long gpio_flags) { -struct sysfs_dirent *value_sd; +struct kernfs_node *value_sd;unsigned long irq_flags;int ret, irq, id;
drivers/md/bitmap.c +1 -1
@@ -1635,7 +1635,7 @@ int bitmap_create(struct mddev *mddev)sector_t blocks = mddev->resync_max_sectors;struct file *file = mddev->bitmap_info.file;int err; -struct sysfs_dirent *bm =NULL ; +struct kernfs_node *bm =NULL ;BUILD_BUG_ON (sizeof (bitmap_super_t) !=256 );
drivers/md/bitmap.h +1 -1
@@ -225,7 +225,7 @@ struct bitmap {wait_queue_head_t overflow_wait;wait_queue_head_t behind_wait; -struct sysfs_dirent *sysfs_can_clear; +struct kernfs_node *sysfs_can_clear; };/* the bitmap API */
drivers/md/md.h +5 -5
@@ -106,7 +106,7 @@ struct md_rdev {*/ struct work_struct del_work;/* used for delayed sysfs removal */ -struct sysfs_dirent *sysfs_state;/* handle for 'state' +struct kernfs_node *sysfs_state;/* handle for 'state' * sysfs entry */ struct badblocks {
@@ -376,10 +376,10 @@ struct mddev {sector_t resync_max;/* resync should pause * when it gets here */ -struct sysfs_dirent *sysfs_state;/* handle for 'array_state' +struct kernfs_node *sysfs_state;/* handle for 'array_state' * file in sysfs. */ -struct sysfs_dirent *sysfs_action;/* handle for 'sync_action' */ +struct kernfs_node *sysfs_action;/* handle for 'sync_action' */ struct work_struct del_work;/* used for delayed sysfs removal */
@@ -498,13 +498,13 @@ struct md_sysfs_entry { };extern struct attribute_group md_bitmap_group; -static inline struct sysfs_dirent *sysfs_get_dirent_safe (struct sysfs_dirent *sd,char *name) +static inline struct kernfs_node *sysfs_get_dirent_safe (struct kernfs_node *sd,char *name) {if (sd)return sysfs_get_dirent (sd, name);return sd; } -static inline void sysfs_notify_dirent_safe (struct sysfs_dirent *sd) +static inline void sysfs_notify_dirent_safe (struct kernfs_node *sd) {if (sd)sysfs_notify_dirent (sd);
drivers/misc/mic/host/mic_device.h +1 -1
@@ -112,7 +112,7 @@ struct mic_device {struct work_struct shutdown_work;u8 state;u8 shutdown_status; -struct sysfs_dirent *state_sysfs; +struct kernfs_node *state_sysfs;struct completion reset_wait;void *log_buf_addr;int *log_buf_len;
fs/kernfs/dir.c +271 -271
1,071 lines not on this page · raw message
fs/kernfs/file.c +93 -93
534 lines not on this page · raw message
fs/kernfs/inode.c +62 -61
317 lines not on this page · raw message
fs/kernfs/kernfs-internal.h +20 -20
@@ -31,24 +31,24 @@ struct sysfs_inode_attrs {/* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ /** -* kernfs_root - find out the kernfs_root a sysfs_dirent belongs to -* @sd: sysfs_dirent of interest +* kernfs_root - find out the kernfs_root a kernfs_node belongs to +* @kn: kernfs_node of interest * -* Return the kernfs_root @sd belongs to. +* Return the kernfs_root @kn belongs to. */ -static inline struct kernfs_root *kernfs_root (struct sysfs_dirent *sd) +static inline struct kernfs_root *kernfs_root (struct kernfs_node *kn) {/* if parent exists, it's always a dir; otherwise, @sd is a dir */ -if (sd->s_parent) - sd = sd->s_parent; -return sd->s_dir.root; +if (kn->s_parent) + kn = kn->s_parent; +return kn->s_dir.root; }/* * Context structure to be used while adding/removing nodes. */ struct sysfs_addrm_cxt { -struct sysfs_dirent *removed; +struct kernfs_node *removed; };/*
@@ -62,10 +62,10 @@ struct sysfs_super_info {struct kernfs_root *root;/* -* Each sb is associated with one namespace tag, currently the network -* namespace of the task which mounted this sysfs instance. If multiple -* tags become necessary, make the following an array and compare -* sysfs_dirent tag against every entry. +* Each sb is associated with one namespace tag, currently the +* network namespace of the task which mounted this sysfs instance. +* If multiple tags become necessary, make the following an array +* and compare kernfs_node tag against every entry. */ const void *ns; };
@@ -76,7 +76,7 @@ extern struct kmem_cache *sysfs_dir_cachep;/* * inode.c */ -struct inode *sysfs_get_inode (struct super_block *sb,struct sysfs_dirent *sd); +struct inode *sysfs_get_inode (struct super_block *sb,struct kernfs_node *kn);void sysfs_evict_inode (struct inode *inode);int sysfs_permission (struct inode *inode,int mask);int sysfs_setattr (struct dentry *dentry,struct iattr *iattr);
@@ -98,21 +98,21 @@ extern const struct dentry_operations sysfs_dentry_ops;extern const struct file_operations sysfs_dir_operations;extern const struct inode_operations sysfs_dir_inode_operations; -struct sysfs_dirent *sysfs_get_active (struct sysfs_dirent *sd); -void sysfs_put_active (struct sysfs_dirent *sd); +struct kernfs_node *sysfs_get_active (struct kernfs_node *kn); +void sysfs_put_active (struct kernfs_node *kn);void sysfs_addrm_start (struct sysfs_addrm_cxt *acxt); -int sysfs_add_one (struct sysfs_addrm_cxt *acxt,struct sysfs_dirent *sd, -struct sysfs_dirent *parent_sd); +int sysfs_add_one (struct sysfs_addrm_cxt *acxt,struct kernfs_node *kn, +struct kernfs_node *parent);void sysfs_addrm_finish (struct sysfs_addrm_cxt *acxt); -struct sysfs_dirent *sysfs_new_dirent (struct kernfs_root *root, -const char *name,umode_t mode,int type); +struct kernfs_node *sysfs_new_dirent (struct kernfs_root *root, +const char *name,umode_t mode,int type);/* * file.c */ extern const struct file_operations kernfs_file_operations; -void sysfs_unmap_bin_file (struct sysfs_dirent *sd); +void sysfs_unmap_bin_file (struct kernfs_node *kn);/* * symlink.c
fs/kernfs/mount.c +6 -6
@@ -39,7 +39,7 @@ static int sysfs_fill_super(struct super_block *sb)/* get root inode, initialize and unlock it */ mutex_lock (&sysfs_mutex); - inode =sysfs_get_inode (sb, info->root->sd); + inode =sysfs_get_inode (sb, info->root->kn);mutex_unlock (&sysfs_mutex);if (!inode) {pr_debug ("sysfs: could not get root inode\n" );
@@ -52,8 +52,8 @@ static int sysfs_fill_super(struct super_block *sb)pr_debug ("%s: could not get root dentry!\n" , __func__);return -ENOMEM ; } -kernfs_get (info->root->sd); - root->d_fsdata = info->root->sd; +kernfs_get (info->root->kn); + root->d_fsdata = info->root->kn; sb->s_root = root; sb->s_d_op = &sysfs_dentry_ops;return 0 ;
@@ -145,7 +145,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,void kernfs_kill_sb (struct super_block *sb) {struct sysfs_super_info *info =sysfs_info (sb); -struct sysfs_dirent *root_sd = sb->s_root->d_fsdata; +struct kernfs_node *root_kn = sb->s_root->d_fsdata;/* * Remove the superblock from fs_supers/s_instances
@@ -153,13 +153,13 @@ void kernfs_kill_sb(struct super_block *sb)*/ kill_anon_super (sb);kfree (info); -kernfs_put (root_sd); +kernfs_put (root_kn); }void __init kernfs_init (void ) { sysfs_dir_cachep =kmem_cache_create ("sysfs_dir_cache" , -sizeof (struct sysfs_dirent ), +sizeof (struct kernfs_node ),0 ,SLAB_PANIC ,NULL );sysfs_inode_init (); }
fs/kernfs/symlink.c +32 -32
121 lines not on this page · raw message
fs/sysfs/dir.c +33 -33
129 lines not on this page · raw message
fs/sysfs/file.c +61 -61
255 lines not on this page · raw message
fs/sysfs/group.c +48 -48
213 lines not on this page · raw message
fs/sysfs/mount.c +2 -2
@@ -20,7 +20,7 @@#include "sysfs.h" static struct kernfs_root *sysfs_root; -struct sysfs_dirent *sysfs_root_sd; +struct kernfs_node *sysfs_root_kn;static struct dentry *sysfs_mount (struct file_system_type *fs_type,int flags,const char *dev_name,void *data)
@@ -66,7 +66,7 @@ int __init sysfs_init(void)if (IS_ERR (sysfs_root))return PTR_ERR (sysfs_root); - sysfs_root_sd = sysfs_root->sd; + sysfs_root_kn = sysfs_root->kn; err =register_filesystem (&sysfs_fs_type);if (err) {
fs/sysfs/symlink.c +36 -36
146 lines not on this page · raw message
include/linux/kernfs.h +83 -83
166 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.4.2
Part of the diff is not shown here. View the raw message.
Tejun Heo
maintainerPATCH 4/6 kernfs: s/sysfs/kernfs/ in constants
In reply to Tejun Heokernfs 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_DIR/KERNFS_DIR/
* s/SYSFS_KOBJ_ATTR/KERNFS_FILE/
* s/SYSFS_KOBJ_LINK/KERNFS_LINK/
* s/SYSFS_{TYPE_FLAGS}/KERNFS_{TYPE_FLAGS}/
* s/SYSFS_FLAG_{FLAG}/KERNFS_{FLAG}/
* s/sysfs_type()/kernfs_type()/
* s/SD_DEACTIVATED_BIAS/KN_DEACTIVATED_BIAS/
This patch is strictly rename only and doesn't introduce any functional difference.
--- fs/kernfs/dir.c | 50 ++++++++++++++++++++++----------------------- fs/kernfs/file.c | 18 ++++++++-------- fs/kernfs/inode.c | 10 ++++----- fs/kernfs/kernfs-internal.h | 4 ++-- fs/kernfs/symlink.c | 2 +- fs/sysfs/dir.c | 2 +- fs/sysfs/file.c | 2 +- fs/sysfs/symlink.c | 2 +- include/linux/kernfs.h | 36 ++++++++++++++++---------------- 9 files changed, 63 insertions(+), 63 deletions(-)
fs/kernfs/dir.c +25 -25
@@ -78,7 +78,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)struct rb_node **node = &kn->parent->dir.children.rb_node;struct rb_node *parent =NULL ; -if (sysfs_type (kn) ==SYSFS_DIR ) +if (kernfs_type (kn) ==KERNFS_DIR ) kn->parent->dir.subdirs++;while (*node) {
@@ -113,7 +113,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)*/ static void sysfs_unlink_sibling (struct kernfs_node *kn) { -if (sysfs_type (kn) ==SYSFS_DIR ) +if (kernfs_type (kn) ==KERNFS_DIR ) kn->parent->dir.subdirs--;rb_erase (&kn->rb, &kn->parent->dir.children);
@@ -137,7 +137,7 @@ struct kernfs_node *sysfs_get_active(struct kernfs_node *kn)if (!atomic_inc_unless_negative (&kn->active))return NULL ; -if (kn->flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &KERNFS_LOCKDEP )rwsem_acquire_read (&kn->dep_map,0 ,1 , _RET_IP_);return kn; }
@@ -156,10 +156,10 @@ void sysfs_put_active(struct kernfs_node *kn)if (unlikely (!kn))return ; -if (kn->flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &KERNFS_LOCKDEP )rwsem_release (&kn->dep_map,1 , _RET_IP_); v =atomic_dec_return (&kn->active); -if (likely (v !=SD_DEACTIVATED_BIAS )) +if (likely (v !=KN_DEACTIVATED_BIAS ))return ;/*
@@ -180,9 +180,9 @@ static void sysfs_deactivate(struct kernfs_node *kn)DECLARE_COMPLETION_ONSTACK (wait);int v; -BUG_ON (!(kn->flags &SYSFS_FLAG_REMOVED )); +BUG_ON (!(kn->flags &KERNFS_REMOVED )); -if (!(sysfs_type (kn) &SYSFS_ACTIVE_REF )) +if (!(kernfs_type (kn) &KERNFS_ACTIVE_REF ))return ; kn->u.completion = (void *)&wait;
@@ -191,9 +191,9 @@ static void sysfs_deactivate(struct kernfs_node *kn)/* atomic_add_return() is a mb(), put_active() will always see * the updated kn->u.completion. */ - v =atomic_add_return (SD_DEACTIVATED_BIAS , &kn->active); + v =atomic_add_return (KN_DEACTIVATED_BIAS , &kn->active); -if (v !=SD_DEACTIVATED_BIAS ) { +if (v !=KN_DEACTIVATED_BIAS ) {lock_contended (&kn->dep_map, _RET_IP_);wait_for_completion (&wait); }
@@ -235,13 +235,13 @@ void kernfs_put(struct kernfs_node *kn)*/ parent = kn->parent; -WARN (!(kn->flags &SYSFS_FLAG_REMOVED ), +WARN (!(kn->flags &KERNFS_REMOVED ),"sysfs: free using entry: %s/%s\n" , parent ? parent->name :"" , kn->name); -if (sysfs_type (kn) ==SYSFS_KOBJ_LINK ) +if (kernfs_type (kn) ==KERNFS_LINK )kernfs_put (kn->symlink.target_kn); -if (sysfs_type (kn) &SYSFS_COPY_NAME ) +if (kernfs_type (kn) &KERNFS_COPY_NAME )kfree (kn->name);if (kn->iattr) {if (kn->iattr->ia_secdata)
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_GPL(kernfs_put);static int sysfs_dentry_delete (const struct dentry *dentry) {struct kernfs_node *kn = dentry->d_fsdata; -return !(kn && !(kn->flags &SYSFS_FLAG_REMOVED )); +return !(kn && !(kn->flags &KERNFS_REMOVED )); }static int sysfs_dentry_revalidate (struct dentry *dentry,unsigned int flags)
@@ -282,7 +282,7 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)mutex_lock (&sysfs_mutex);/* The sysfs dirent has been deleted */ -if (kn->flags &SYSFS_FLAG_REMOVED ) +if (kn->flags &KERNFS_REMOVED ) goto out_bad;/* The sysfs dirent has been moved? */
@@ -342,7 +342,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,struct kernfs_node *kn;int ret; -if (type &SYSFS_COPY_NAME ) { +if (type &KERNFS_COPY_NAME ) { name = dup_name =kstrdup (name,GFP_KERNEL );if (!name)return NULL ;
@@ -362,7 +362,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, kn->name = name; kn->mode = mode; - kn->flags = type |SYSFS_FLAG_REMOVED ; + kn->flags = type |KERNFS_REMOVED ;return kn;
@@ -427,7 +427,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,return -EINVAL ; } -if (sysfs_type (parent) !=SYSFS_DIR ) +if (kernfs_type (parent) !=KERNFS_DIR )return -EINVAL ; kn->hash =sysfs_name_hash (kn->name, kn->ns);
@@ -446,7 +446,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn, }/* Mark the entry added into directory tree */ - kn->flags &= ~SYSFS_FLAG_REMOVED ; + kn->flags &= ~KERNFS_REMOVED ;return 0 ; }
@@ -475,7 +475,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,* Removal can be called multiple times on the same node. Only the * first invocation is effective and puts the base ref. */ -if (kn->flags &SYSFS_FLAG_REMOVED ) +if (kn->flags &KERNFS_REMOVED )return ;if (kn->parent) {
@@ -489,7 +489,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt, } } - kn->flags |=SYSFS_FLAG_REMOVED ; + kn->flags |=KERNFS_REMOVED ; kn->u.removed_list = acxt->removed; acxt->removed = kn; }
@@ -607,14 +607,14 @@ struct kernfs_root *kernfs_create_root(void *priv)ida_init (&root->ino_ida); - kn =sysfs_new_dirent (root,"" ,S_IFDIR |S_IRUGO |S_IXUGO ,SYSFS_DIR ); + kn =sysfs_new_dirent (root,"" ,S_IFDIR |S_IRUGO |S_IXUGO ,KERNFS_DIR );if (!kn) {ida_destroy (&root->ino_ida);kfree (root);return ERR_PTR (-ENOMEM ); } - kn->flags &= ~SYSFS_FLAG_REMOVED ; + kn->flags &= ~KERNFS_REMOVED ; kn->priv = priv; kn->dir.root = root;
@@ -654,7 +654,7 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,int rc;/* allocate */ - kn =sysfs_new_dirent (kernfs_root (parent), name, mode,SYSFS_DIR ); + kn =sysfs_new_dirent (kernfs_root (parent), name, mode,KERNFS_DIR );if (!kn)return ERR_PTR (-ENOMEM );
@@ -732,7 +732,7 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos) last = pos; -if (sysfs_type (pos) !=SYSFS_DIR ) +if (kernfs_type (pos) !=KERNFS_DIR )break ; rbn =rb_first (&pos->dir.children);
@@ -914,7 +914,7 @@ static struct kernfs_node *sysfs_dir_pos(const void *ns, struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) { if (pos) { - int valid = !(pos->flags & SYSFS_FLAG_REMOVED) && + int valid = !(pos->flags & KERNFS_REMOVED) && pos->parent == parent && hash == pos->hash;kernfs_put (pos);if (!valid)
fs/kernfs/file.c +9 -9
@@ -49,7 +49,7 @@ static struct kernfs_open_file *kernfs_of(struct file *file)*/ static const struct kernfs_ops *kernfs_ops (struct kernfs_node *kn) { -if (kn->flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &KERNFS_LOCKDEP )lockdep_assert_held (kn);return kn->attr.ops; }
@@ -189,7 +189,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, {struct kernfs_open_file *of =kernfs_of (file); -if (of->kn->flags &SYSFS_FLAG_HAS_SEQ_SHOW ) +if (of->kn->flags &KERNFS_HAS_SEQ_SHOW )return seq_read (file, user_buf, count, ppos);else return kernfs_file_direct_read (of, user_buf, count, ppos);
@@ -428,7 +428,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)* without grabbing @of->mutex by testing HAS_MMAP flag. See the * comment in kernfs_file_open() for more details. */ -if (!(of->kn->flags &SYSFS_FLAG_HAS_MMAP )) +if (!(of->kn->flags &KERNFS_HAS_MMAP ))return -ENODEV ;mutex_lock (&of->mutex);
@@ -668,7 +668,7 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)struct kernfs_open_node *on;struct kernfs_open_file *of; -if (!(kn->flags &SYSFS_FLAG_HAS_MMAP )) +if (!(kn->flags &KERNFS_HAS_MMAP ))return ;spin_lock_irq (&kernfs_open_node_lock);
@@ -738,7 +738,7 @@ void kernfs_notify(struct kernfs_node *kn)spin_lock_irqsave (&kernfs_open_node_lock, flags); -if (!WARN_ON (sysfs_type (kn) !=SYSFS_KOBJ_ATTR )) { +if (!WARN_ON (kernfs_type (kn) !=KERNFS_FILE )) { on = kn->attr.open;if (on) {atomic_inc (&on->event);
@@ -785,7 +785,7 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,int rc; kn =sysfs_new_dirent (kernfs_root (parent), name, - (mode &S_IALLUGO ) |S_IFREG ,SYSFS_KOBJ_ATTR ); + (mode &S_IALLUGO ) |S_IFREG ,KERNFS_FILE );if (!kn)return ERR_PTR (-ENOMEM );
@@ -797,7 +797,7 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,#ifdef CONFIG_DEBUG_LOCK_ALLOC if (key) {lockdep_init_map (&kn->dep_map,"s_active" , key,0 ); - kn->flags |=SYSFS_FLAG_LOCKDEP ; + kn->flags |=KERNFS_LOCKDEP ; }#endif
@@ -807,9 +807,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,* ref. Cache their existence in flags. */ if (ops->seq_show) - kn->flags |=SYSFS_FLAG_HAS_SEQ_SHOW ; + kn->flags |=KERNFS_HAS_SEQ_SHOW ;if (ops->mmap) - kn->flags |=SYSFS_FLAG_HAS_MMAP ; + kn->flags |=KERNFS_HAS_MMAP ;sysfs_addrm_start (&acxt); rc =sysfs_add_one (&acxt, kn, parent);
fs/kernfs/inode.c +5 -5
@@ -269,7 +269,7 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) attrs->ia_secdata_len); } -if (sysfs_type (kn) ==SYSFS_DIR ) +if (kernfs_type (kn) ==KERNFS_DIR )set_nlink (inode, kn->dir.subdirs +2 ); }
@@ -299,16 +299,16 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)sysfs_refresh_inode (kn, inode);/* initialize inode according to type */ -switch (sysfs_type (kn)) { -case SYSFS_DIR : +switch (kernfs_type (kn)) { +case KERNFS_DIR : inode->i_op = &sysfs_dir_inode_operations; inode->i_fop = &sysfs_dir_operations;break ; -case SYSFS_KOBJ_ATTR : +case KERNFS_FILE : inode->i_size = kn->attr.size; inode->i_fop = &kernfs_file_operations;break ; -case SYSFS_KOBJ_LINK : +case KERNFS_LINK : inode->i_op = &sysfs_symlink_inode_operations;break ;default :
fs/kernfs/kernfs-internal.h +2 -2
@@ -26,9 +26,9 @@ struct kernfs_iattrs {struct simple_xattrs xattrs; }; -#define SD_DEACTIVATED_BIAS INT_MIN +#define KN_DEACTIVATED_BIAS INT_MIN -/* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ +/* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ /** * kernfs_root - find out the kernfs_root a kernfs_node belongs to
fs/kernfs/symlink.c +1 -1
@@ -31,7 +31,7 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,int error; kn =sysfs_new_dirent (kernfs_root (parent), name,S_IFLNK |S_IRWXUGO , -SYSFS_KOBJ_LINK ); +KERNFS_LINK );if (!kn)return ERR_PTR (-ENOMEM );
fs/sysfs/dir.c +1 -1
@@ -113,7 +113,7 @@ void sysfs_remove_dir(struct kobject *kobj)spin_unlock (&sysfs_symlink_target_lock);if (kn) { -WARN_ON_ONCE (sysfs_type (kn) !=SYSFS_DIR ); +WARN_ON_ONCE (kernfs_type (kn) !=KERNFS_DIR );kernfs_remove (kn); } }
fs/sysfs/file.c +1 -1
@@ -29,7 +29,7 @@ static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn) {struct kobject *kobj = kn->parent->priv; -if (kn->flags &SYSFS_FLAG_LOCKDEP ) +if (kn->flags &KERNFS_LOCKDEP )lockdep_assert_held (kn);return kobj->ktype ? kobj->ktype->sysfs_ops :NULL ; }
fs/sysfs/symlink.c +1 -1
@@ -183,7 +183,7 @@ int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ, goto out; result = -EINVAL ; -if (sysfs_type (kn) !=SYSFS_KOBJ_LINK ) +if (kernfs_type (kn) !=KERNFS_LINK ) goto out;if (kn->symlink.target_kn->priv != targ) goto out;
include/linux/kernfs.h +18 -18
@@ -28,22 +28,22 @@ struct kernfs_open_node;struct kernfs_iattrs ;enum kernfs_node_type { -SYSFS_DIR =0x0001 , -SYSFS_KOBJ_ATTR =0x0002 , -SYSFS_KOBJ_LINK =0x0004 , +KERNFS_DIR =0x0001 , +KERNFS_FILE =0x0002 , +KERNFS_LINK =0x0004 , }; -#define SYSFS_TYPE_MASK 0x000f -#define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) -#define SYSFS_ACTIVE_REF SYSFS_KOBJ_ATTR -#define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK +#define KERNFS_TYPE_MASK 0x000f +#define KERNFS_COPY_NAME (KERNFS_DIR | KERNFS_LINK) +#define KERNFS_ACTIVE_REF KERNFS_FILE +#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASKenum kernfs_node_flag { -SYSFS_FLAG_REMOVED =0x0010 , -SYSFS_FLAG_NS =0x0020 , -SYSFS_FLAG_HAS_SEQ_SHOW =0x0040 , -SYSFS_FLAG_HAS_MMAP =0x0080 , -SYSFS_FLAG_LOCKDEP =0x0100 , +KERNFS_REMOVED =0x0010 , +KERNFS_NS =0x0020 , +KERNFS_HAS_SEQ_SHOW =0x0040 , +KERNFS_HAS_MMAP =0x0080 , +KERNFS_LOCKDEP =0x0100 , };/* type-specific structures for kernfs_node union members */
@@ -170,9 +170,9 @@ struct kernfs_ops {#ifdef CONFIG_SYSFS -static inline enum kernfs_node_type sysfs_type (struct kernfs_node *kn) +static inline enum kernfs_node_type kernfs_type (struct kernfs_node *kn) { -return kn->flags &SYSFS_TYPE_MASK ; +return kn->flags &KERNFS_TYPE_MASK ; }/**
@@ -185,9 +185,9 @@ static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn)*/ static inline void kernfs_enable_ns (struct kernfs_node *kn) { -WARN_ON_ONCE (sysfs_type (kn) !=SYSFS_DIR ); +WARN_ON_ONCE (kernfs_type (kn) !=KERNFS_DIR );WARN_ON_ONCE (!RB_EMPTY_ROOT (&kn->dir.children)); - kn->flags |=SYSFS_FLAG_NS ; + kn->flags |=KERNFS_NS ; }/**
@@ -198,7 +198,7 @@ static inline void kernfs_enable_ns(struct kernfs_node *kn)*/ static inline bool kernfs_ns_enabled (struct kernfs_node *kn) { -return kn->flags &SYSFS_FLAG_NS ; +return kn->flags &KERNFS_NS ; } struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
@@ -238,7 +238,7 @@ void kernfs_init(void);#else /* CONFIG_SYSFS */ -static inline enum kernfs_node_type sysfs_type (struct kernfs_node *kn) +static inline enum kernfs_node_type kernfs_type (struct kernfs_node *kn) {return 0 ; }/* whatever */ static inline void kernfs_enable_ns (struct kernfs_node *kn) { }
Signature · 1 line
1.8.4.2
Tejun Heo
maintainerPATCH 6/6 kernfs: s/sysfs/kernfs/ in internal functions and whatever is left
In reply to Tejun Heokernfs 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_*()/kernfs_*()/ in all internal functions
* s/sysfs/kernfs/ in internal strings, comments and whatever is remaining
* Uniformly rename various vfs operations so that they're consistently named and distinguishable.
This patch is strictly rename only and doesn't introduce any functional difference.
--- fs/kernfs/dir.c | 212 ++++++++++++++++++++++---------------------- fs/kernfs/file.c | 121 ++++++++++++------------- fs/kernfs/inode.c | 66 +++++++------- fs/kernfs/kernfs-internal.h | 44 ++++----- fs/kernfs/mount.c | 18 ++-- fs/kernfs/symlink.c | 44 ++++----- 6 files changed, 254 insertions(+), 251 deletions(-)
fs/kernfs/dir.c +107 -105
@@ -22,13 +22,13 @@ DEFINE_MUTEX(kernfs_mutex);#define rb_to_kn (X ) rb_entry((X), struct kernfs_node, rb)/** -* sysfs_name_hash +* kernfs_name_hash * @name: Null terminated string to hash * @ns: Namespace tag to hash * * Returns 31 bit hash of ns + name (so it fits in an off_t ) */ -static unsigned int sysfs_name_hash (const char *name,const void *ns) +static unsigned int kernfs_name_hash (const char *name,const void *ns) {unsigned long hash =init_name_hash ();unsigned int len =strlen (name);
@@ -44,8 +44,8 @@ static unsigned int sysfs_name_hash(const char *name, const void *ns)return hash; } -static int sysfs_name_compare (unsigned int hash,const char *name, -const void *ns,const struct kernfs_node *kn) +static int kernfs_name_compare (unsigned int hash,const char *name, +const void *ns,const struct kernfs_node *kn) {if (hash != kn->hash)return hash - kn->hash;
@@ -54,14 +54,14 @@ static int sysfs_name_compare(unsigned int hash, const char *name,return strcmp (name, kn->name); } -static int sysfs_sd_compare (const struct kernfs_node *left, -const struct kernfs_node *right) +static int kernfs_sd_compare (const struct kernfs_node *left, +const struct kernfs_node *right) { -return sysfs_name_compare (left->hash, left->name, left->ns, right); +return kernfs_name_compare (left->hash, left->name, left->ns, right); }/** -* sysfs_link_sibling - link kernfs_node into sibling rbtree +* kernfs_link_sibling - link kernfs_node into sibling rbtree * @kn: kernfs_node of interest * * Link @kn into its sibling rbtree which starts from
@@ -73,7 +73,7 @@ static int sysfs_sd_compare(const struct kernfs_node *left,* RETURNS: * 0 on susccess -EEXIST on failure. */ -static int sysfs_link_sibling (struct kernfs_node *kn) +static int kernfs_link_sibling (struct kernfs_node *kn) {struct rb_node **node = &kn->parent->dir.children.rb_node;struct rb_node *parent =NULL ;
@@ -87,7 +87,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn) pos =rb_to_kn (*node); parent = *node; - result =sysfs_sd_compare (kn, pos); + result =kernfs_sd_compare (kn, pos);if (result <0 ) node = &pos->rb.rb_left;else if (result >0 )
@@ -102,7 +102,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn) }/** -* sysfs_unlink_sibling - unlink kernfs_node from sibling rbtree +* kernfs_unlink_sibling - unlink kernfs_node from sibling rbtree * @kn: kernfs_node of interest * * Unlink @kn from its sibling rbtree which starts from
@@ -111,7 +111,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)* Locking: * mutex_lock(kernfs_mutex) */ -static void sysfs_unlink_sibling (struct kernfs_node *kn) +static void kernfs_unlink_sibling (struct kernfs_node *kn) {if (kernfs_type (kn) ==KERNFS_DIR ) kn->parent->dir.subdirs--;
@@ -120,7 +120,7 @@ static void sysfs_unlink_sibling(struct kernfs_node *kn) }/** -* sysfs_get_active - get an active reference to kernfs_node +* kernfs_get_active - get an active reference to kernfs_node * @kn: kernfs_node to get an active reference to * * Get an active reference of @kn. This function is noop if @kn
@@ -129,7 +129,7 @@ static void sysfs_unlink_sibling(struct kernfs_node *kn)* RETURNS: * Pointer to @kn on success, NULL on failure. */ -struct kernfs_node *sysfs_get_active (struct kernfs_node *kn) +struct kernfs_node *kernfs_get_active (struct kernfs_node *kn) {if (unlikely (!kn))return NULL ;
@@ -143,13 +143,13 @@ struct kernfs_node *sysfs_get_active(struct kernfs_node *kn) }/** -* sysfs_put_active - put an active reference to kernfs_node +* kernfs_put_active - put an active reference to kernfs_node * @kn: kernfs_node to put an active reference to * * Put an active reference to @kn. This function is noop if @kn * is NULL. */ -void sysfs_put_active (struct kernfs_node *kn) +void kernfs_put_active (struct kernfs_node *kn) {int v;
@@ -170,12 +170,12 @@ void sysfs_put_active(struct kernfs_node *kn) }/** -* sysfs_deactivate - deactivate kernfs_node +* kernfs_deactivate - deactivate kernfs_node * @kn: kernfs_node to deactivate * * Deny new active references and drain existing ones. */ -static void sysfs_deactivate (struct kernfs_node *kn) +static void kernfs_deactivate (struct kernfs_node *kn) {DECLARE_COMPLETION_ONSTACK (wait);int v;
@@ -235,9 +235,8 @@ void kernfs_put(struct kernfs_node *kn)*/ parent = kn->parent; -WARN (!(kn->flags &KERNFS_REMOVED ), -"sysfs: free using entry: %s/%s\n" , - parent ? parent->name :"" , kn->name); +WARN (!(kn->flags &KERNFS_REMOVED ),"kernfs: free using entry: %s/%s\n" , + parent ? parent->name :"" , kn->name);if (kernfs_type (kn) ==KERNFS_LINK )kernfs_put (kn->symlink.target_kn);
@@ -265,13 +264,13 @@ void kernfs_put(struct kernfs_node *kn) }EXPORT_SYMBOL_GPL (kernfs_put); -static int sysfs_dentry_delete (const struct dentry *dentry) +static int kernfs_dop_delete (const struct dentry *dentry) {struct kernfs_node *kn = dentry->d_fsdata;return !(kn && !(kn->flags &KERNFS_REMOVED )); } -static int sysfs_dentry_revalidate (struct dentry *dentry,unsigned int flags) +static int kernfs_dop_revalidate (struct dentry *dentry,unsigned int flags) {struct kernfs_node *kn;
@@ -281,19 +280,19 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) kn = dentry->d_fsdata;mutex_lock (&kernfs_mutex); -/* The sysfs dirent has been deleted */ +/* The kernfs node has been deleted */ if (kn->flags &KERNFS_REMOVED ) goto out_bad; -/* The sysfs dirent has been moved? */ +/* The kernfs node has been moved? */ if (dentry->d_parent->d_fsdata != kn->parent) goto out_bad; -/* The sysfs dirent has been renamed */ +/* The kernfs node has been renamed */ if (strcmp (dentry->d_name.name, kn->name) !=0 ) goto out_bad; -/* The sysfs dirent has been moved to a different namespace */ +/* The kernfs node has been moved to a different namespace */ if (kn->parent &&kernfs_ns_enabled (kn->parent) &&kernfs_info (dentry->d_sb)->ns != kn->ns) goto out_bad;
@@ -302,9 +301,10 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) out_valid:return 1 ; out_bad: -/* Remove the dentry from the dcache hashes. +/* +* Remove the dentry from the dcache hashes. * If this is a deleted dentry we use d_drop instead of d_delete -* so sysfs doesn't need to cope with negative dentries. +* so kernfs doesn't need to cope with negative dentries. * * If this is a dentry that has simply been renamed we * use d_drop to remove it from the dcache lookup on its
@@ -324,19 +324,19 @@ out_bad:return 0 ; } -static void sysfs_dentry_release (struct dentry *dentry) +static void kernfs_dop_release (struct dentry *dentry) {kernfs_put (dentry->d_fsdata); }const struct dentry_operations kernfs_dops = { - .d_revalidate = sysfs_dentry_revalidate, - .d_delete = sysfs_dentry_delete, - .d_release = sysfs_dentry_release, + .d_revalidate = kernfs_dop_revalidate, + .d_delete = kernfs_dop_delete, + .d_release = kernfs_dop_release, }; -struct kernfs_node *sysfs_new_dirent (struct kernfs_root *root, -const char *name,umode_t mode,int type) +struct kernfs_node *kernfs_new_node (struct kernfs_root *root,const char *name, +umode_t mode,int type) {char *dup_name =NULL ;struct kernfs_node *kn;
@@ -374,7 +374,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, }/** -* sysfs_addrm_start - prepare for kernfs_node add/remove +* kernfs_addrm_start - prepare for kernfs_node add/remove * @acxt: pointer to kernfs_addrm_cxt to be used * * This function is called when the caller is about to add or remove
@@ -385,7 +385,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,* Kernel thread context (may sleep). kernfs_mutex is locked on * return. */ -void sysfs_addrm_start (struct kernfs_addrm_cxt *acxt) +void kernfs_addrm_start (struct kernfs_addrm_cxt *acxt)__acquires (kernfs_mutex) {memset (acxt,0 ,sizeof (*acxt));
@@ -394,7 +394,7 @@ void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt) }/** -* sysfs_add_one - add kernfs_node to parent without warning +* kernfs_add_one - add kernfs_node to parent without warning * @acxt: addrm context to use * @kn: kernfs_node to be added * @parent: the parent kernfs_node to add @kn to
@@ -404,17 +404,17 @@ void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt)* of the parent. * * This function should be called between calls to -* sysfs_addrm_start() and sysfs_addrm_finish() and should be -* passed the same @acxt as passed to sysfs_addrm_start(). +* kernfs_addrm_start() and kernfs_addrm_finish() and should be passed +* the same @acxt as passed to kernfs_addrm_start(). * * LOCKING: -* Determined by sysfs_addrm_start(). +* Determined by kernfs_addrm_start(). * * RETURNS: * 0 on success, -EEXIST if entry with the given name already * exists. */ -int sysfs_add_one (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn, +int kernfs_add_one (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn,struct kernfs_node *parent) {bool has_ns =kernfs_ns_enabled (parent);
@@ -422,7 +422,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,int ret;if (has_ns != (bool )kn->ns) { -WARN (1 ,KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n" , +WARN (1 ,KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n" , has_ns ?"required" :"invalid" , parent->name, kn->name);return -EINVAL ; }
@@ -430,11 +430,11 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,if (kernfs_type (parent) !=KERNFS_DIR )return -EINVAL ; - kn->hash =sysfs_name_hash (kn->name, kn->ns); + kn->hash =kernfs_name_hash (kn->name, kn->ns); kn->parent = parent;kernfs_get (parent); - ret =sysfs_link_sibling (kn); + ret =kernfs_link_sibling (kn);if (ret)return ret;
@@ -452,7 +452,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn, }/** -* sysfs_remove_one - remove kernfs_node from parent +* kernfs_remove_one - remove kernfs_node from parent * @acxt: addrm context to use * @kn: kernfs_node to be removed *
@@ -460,14 +460,14 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,* directory. @kn is unlinked from the children list. * * This function should be called between calls to -* sysfs_addrm_start() and sysfs_addrm_finish() and should be -* passed the same @acxt as passed to sysfs_addrm_start(). +* kernfs_addrm_start() and kernfs_addrm_finish() and should be +* passed the same @acxt as passed to kernfs_addrm_start(). * * LOCKING: -* Determined by sysfs_addrm_start(). +* Determined by kernfs_addrm_start(). */ -static void sysfs_remove_one (struct kernfs_addrm_cxt *acxt, -struct kernfs_node *kn) +static void kernfs_remove_one (struct kernfs_addrm_cxt *acxt, +struct kernfs_node *kn) {struct kernfs_iattrs *ps_iattr;
@@ -479,7 +479,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,return ;if (kn->parent) { -sysfs_unlink_sibling (kn); +kernfs_unlink_sibling (kn);/* Update timestamps on the parent */ ps_iattr = kn->parent->iattr;
@@ -495,20 +495,20 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt, }/** -* sysfs_addrm_finish - finish up kernfs_node add/remove +* kernfs_addrm_finish - finish up kernfs_node add/remove * @acxt: addrm context to finish up * * Finish up kernfs_node add/remove. Resources acquired by -* sysfs_addrm_start() are released and removed kernfs_nodes are +* kernfs_addrm_start() are released and removed kernfs_nodes are * cleaned up. * * LOCKING: * kernfs_mutex is released. */ -void sysfs_addrm_finish (struct kernfs_addrm_cxt *acxt) +void kernfs_addrm_finish (struct kernfs_addrm_cxt *acxt)__releases (kernfs_mutex) { -/* release resources acquired by sysfs_addrm_start() */ +/* release resources acquired by kernfs_addrm_start() */ mutex_unlock (&kernfs_mutex);/* kill removed kernfs_nodes */
@@ -517,8 +517,8 @@ void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt) acxt->removed = kn->u.removed_list; -sysfs_deactivate (kn); -sysfs_unmap_bin_file (kn); +kernfs_deactivate (kn); +kernfs_unmap_bin_file (kn);kernfs_put (kn); } }
@@ -543,18 +543,18 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,lockdep_assert_held (&kernfs_mutex);if (has_ns != (bool )ns) { -WARN (1 ,KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n" , +WARN (1 ,KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n" , has_ns ?"required" :"invalid" , parent->name, name);return NULL ; } - hash =sysfs_name_hash (name, ns); + hash =kernfs_name_hash (name, ns);while (node) {struct kernfs_node *kn;int result; kn =rb_to_kn (node); - result =sysfs_name_compare (hash, name, ns, kn); + result =kernfs_name_compare (hash, name, ns, kn);if (result <0 ) node = node->rb_left;else if (result >0 )
@@ -607,7 +607,7 @@ struct kernfs_root *kernfs_create_root(void *priv)ida_init (&root->ino_ida); - kn =sysfs_new_dirent (root,"" ,S_IFDIR |S_IRUGO |S_IXUGO ,KERNFS_DIR ); + kn =kernfs_new_node (root,"" ,S_IFDIR |S_IRUGO |S_IXUGO ,KERNFS_DIR );if (!kn) {ida_destroy (&root->ino_ida);kfree (root);
@@ -654,7 +654,7 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,int rc;/* allocate */ - kn =sysfs_new_dirent (kernfs_root (parent), name, mode,KERNFS_DIR ); + kn =kernfs_new_node (kernfs_root (parent), name, mode,KERNFS_DIR );if (!kn)return ERR_PTR (-ENOMEM );
@@ -663,9 +663,9 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent, kn->priv = priv;/* link in */ -sysfs_addrm_start (&acxt); - rc =sysfs_add_one (&acxt, kn, parent); -sysfs_addrm_finish (&acxt); +kernfs_addrm_start (&acxt); + rc =kernfs_add_one (&acxt, kn, parent); +kernfs_addrm_finish (&acxt);if (!rc)return kn;
@@ -674,8 +674,9 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,return ERR_PTR (rc); } -static struct dentry *sysfs_lookup (struct inode *dir,struct dentry *dentry, -unsigned int flags) +static struct dentry *kernfs_iop_lookup (struct inode *dir, +struct dentry *dentry, +unsigned int flags) {struct dentry *ret =NULL ;struct kernfs_node *parent = dentry->d_parent->d_fsdata;
@@ -699,7 +700,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry, dentry->d_fsdata = kn;/* attach dentry and inode */ - inode =sysfs_get_inode (dir->i_sb, kn); + inode =kernfs_get_inode (dir->i_sb, kn);if (!inode) { ret =ERR_PTR (-ENOMEM ); goto out_unlock;
@@ -713,17 +714,17 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry, }const struct inode_operations kernfs_dir_iops = { - .lookup = sysfs_lookup, - .permission = sysfs_permission, - .setattr = sysfs_setattr, - .getattr = sysfs_getattr, - .setxattr = sysfs_setxattr, - .removexattr = sysfs_removexattr, - .getxattr = sysfs_getxattr, - .listxattr = sysfs_listxattr, + .lookup = kernfs_iop_lookup, + .permission = kernfs_iop_permission, + .setattr = kernfs_iop_setattr, + .getattr = kernfs_iop_getattr, + .setxattr = kernfs_iop_setxattr, + .removexattr = kernfs_iop_removexattr, + .getxattr = kernfs_iop_getxattr, + .listxattr = kernfs_iop_listxattr, }; -static struct kernfs_node *sysfs_leftmost_descendant (struct kernfs_node *pos) +static struct kernfs_node *kernfs_leftmost_descendant (struct kernfs_node *pos) {struct kernfs_node *last;
@@ -746,7 +747,7 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos) }/** -* sysfs_next_descendant_post - find the next descendant for post-order walk +* kernfs_next_descendant_post - find the next descendant for post-order walk * @pos: the current position (%NULL to initiate traversal) * @root: kernfs_node whose descendants to walk *
@@ -754,8 +755,8 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos)* descendants. @root is included in the iteration and the last node to be * visited. */ -static struct kernfs_node *sysfs_next_descendant_post (struct kernfs_node *pos, -struct kernfs_node *root) +static struct kernfs_node *kernfs_next_descendant_post (struct kernfs_node *pos, +struct kernfs_node *root) {struct rb_node *rbn;
@@ -763,7 +764,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,/* if first iteration, visit leftmost descendant which may be root */ if (!pos) -return sysfs_leftmost_descendant (root); +return kernfs_leftmost_descendant (root);/* if we visited @root, we're done */ if (pos == root)
@@ -772,7 +773,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,/* if there's an unvisited sibling, visit its leftmost descendant */ rbn =rb_next (&pos->rb);if (rbn) -return sysfs_leftmost_descendant (rb_to_kn (rbn)); +return kernfs_leftmost_descendant (rb_to_kn (rbn));/* no sibling left, visit parent */ return pos->parent;
@@ -786,14 +787,14 @@ static void __kernfs_remove(struct kernfs_addrm_cxt *acxt,if (!kn)return ; -pr_debug ("sysfs %s: removing\n" , kn->name); +pr_debug ("kernfs %s: removing\n" , kn->name); next =NULL ;do { pos = next; - next =sysfs_next_descendant_post (pos, kn); + next =kernfs_next_descendant_post (pos, kn);if (pos) -sysfs_remove_one (acxt, pos); +kernfs_remove_one (acxt, pos); }while (next); }
@@ -807,9 +808,9 @@ void kernfs_remove(struct kernfs_node *kn) {struct kernfs_addrm_cxt acxt; -sysfs_addrm_start (&acxt); +kernfs_addrm_start (&acxt);__kernfs_remove (&acxt, kn); -sysfs_addrm_finish (&acxt); +kernfs_addrm_finish (&acxt); }/**
@@ -828,18 +829,18 @@ int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,struct kernfs_node *kn;if (!parent) { -WARN (1 ,KERN_WARNING "sysfs: can not remove '%s', no directory\n" , +WARN (1 ,KERN_WARNING "kernfs: can not remove '%s', no directory\n" , name);return -ENOENT ; } -sysfs_addrm_start (&acxt); +kernfs_addrm_start (&acxt); kn =kernfs_find_ns (parent, name, ns);if (kn)__kernfs_remove (&acxt, kn); -sysfs_addrm_finish (&acxt); +kernfs_addrm_finish (&acxt);if (kn)return 0 ;
@@ -884,13 +885,13 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,/* * Move to the appropriate place in the appropriate directories rbtree. */ -sysfs_unlink_sibling (kn); +kernfs_unlink_sibling (kn);kernfs_get (new_parent);kernfs_put (kn->parent); kn->ns = new_ns; - kn->hash =sysfs_name_hash (kn->name, kn->ns); + kn->hash =kernfs_name_hash (kn->name, kn->ns); kn->parent = new_parent; -sysfs_link_sibling (kn); +kernfs_link_sibling (kn); error =0 ; out:
@@ -904,13 +905,13 @@ static inline unsigned char dt_type(struct kernfs_node *kn)return (kn->mode >>12 ) &15 ; } -static int sysfs_dir_release (struct inode *inode,struct file *filp) +static int kernfs_dir_fop_release (struct inode *inode,struct file *filp) {kernfs_put (filp->private_data);return 0 ; } -static struct kernfs_node *sysfs_dir_pos (const void *ns, +static struct kernfs_node *kernfs_dir_pos (const void *ns,struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) {if (pos) {
@@ -944,10 +945,10 @@ static struct kernfs_node *sysfs_dir_pos(const void *ns,return pos; } -static struct kernfs_node *sysfs_dir_next_pos (const void *ns, +static struct kernfs_node *kernfs_dir_next_pos (const void *ns,struct kernfs_node *parent,ino_t ino,struct kernfs_node *pos) { - pos =sysfs_dir_pos (ns, parent, ino, pos); + pos =kernfs_dir_pos (ns, parent, ino, pos); if (pos) do { struct rb_node *node = rb_next(&pos->rb);
@@ -959,7 +960,7 @@ static struct kernfs_node *sysfs_dir_next_pos(const void *ns,return pos; } -static int sysfs_readdir (struct file *file,struct dir_context *ctx) +static int kernfs_fop_readdir (struct file *file,struct dir_context *ctx) {struct dentry *dentry = file->f_path.dentry;struct kernfs_node *parent = dentry->d_fsdata;
@@ -973,9 +974,9 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)if (kernfs_ns_enabled (parent)) ns =kernfs_info (dentry->d_sb)->ns; -for (pos =sysfs_dir_pos (ns, parent, ctx->pos, pos); +for (pos =kernfs_dir_pos (ns, parent, ctx->pos, pos); pos; - pos =sysfs_dir_next_pos (ns, parent, ctx->pos, pos)) { + pos =kernfs_dir_next_pos (ns, parent, ctx->pos, pos)) {const char *name = pos->name;unsigned int type =dt_type (pos);int len =strlen (name);
@@ -996,7 +997,8 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)return 0 ; } -static loff_t sysfs_dir_llseek (struct file *file,loff_t offset,int whence) +static loff_t kernfs_dir_fop_llseek (struct file *file,loff_t offset, +int whence) {struct inode *inode =file_inode (file);loff_t ret;
@@ -1010,7 +1012,7 @@ static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence)const struct file_operations kernfs_dir_fops = { .read = generic_read_dir, - .iterate = sysfs_readdir, - .release = sysfs_dir_release, - .llseek = sysfs_dir_llseek, + .iterate = kernfs_fop_readdir, + .release = kernfs_dir_fop_release, + .llseek = kernfs_dir_fop_llseek, };
fs/kernfs/file.c +61 -60
389 lines not on this page · raw message
fs/kernfs/inode.c +33 -33
182 lines not on this page · raw message
fs/kernfs/kernfs-internal.h +22 -22
62 lines not on this page · raw message
fs/kernfs/mount.c +9 -9
@@ -22,10 +22,10 @@ struct kmem_cache *kernfs_node_cache;static const struct super_operations kernfs_sops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, - .evict_inode = sysfs_evict_inode, + .evict_inode = kernfs_evict_inode, }; -static int sysfs_fill_super (struct super_block *sb) +static int kernfs_fill_super (struct super_block *sb) {struct kernfs_super_info *info =kernfs_info (sb);struct inode *inode;
@@ -39,10 +39,10 @@ static int sysfs_fill_super(struct super_block *sb)/* get root inode, initialize and unlock it */ mutex_lock (&kernfs_mutex); - inode =sysfs_get_inode (sb, info->root->kn); + inode =kernfs_get_inode (sb, info->root->kn);mutex_unlock (&kernfs_mutex);if (!inode) { -pr_debug ("sysfs: could not get root inode\n" ); +pr_debug ("kernfs: could not get root inode\n" );return -ENOMEM ; }
@@ -59,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb)return 0 ; } -static int sysfs_test_super (struct super_block *sb,void *data) +static int kernfs_test_super (struct super_block *sb,void *data) {struct kernfs_super_info *sb_info =kernfs_info (sb);struct kernfs_super_info *info = data;
@@ -67,7 +67,7 @@ static int sysfs_test_super(struct super_block *sb, void *data)return sb_info->root == info->root && sb_info->ns == info->ns; } -static int sysfs_set_super (struct super_block *sb,void *data) +static int kernfs_set_super (struct super_block *sb,void *data) {int error; error =set_anon_super (sb, data);
@@ -117,13 +117,13 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, info->root = root; info->ns = ns; - sb =sget (fs_type, sysfs_test_super, sysfs_set_super, flags, info); + sb =sget (fs_type, kernfs_test_super, kernfs_set_super, flags, info);if (IS_ERR (sb) || sb->s_fs_info != info)kfree (info);if (IS_ERR (sb))return ERR_CAST (sb);if (!sb->s_root) { - error =sysfs_fill_super (sb); + error =kernfs_fill_super (sb);if (error) {deactivate_locked_super (sb);return ERR_PTR (error);
@@ -161,5 +161,5 @@ void __init kernfs_init(void) kernfs_node_cache =kmem_cache_create ("kernfs_node_cache" ,sizeof (struct kernfs_node ),0 ,SLAB_PANIC ,NULL ); -sysfs_inode_init (); +kernfs_inode_init (); }
fs/kernfs/symlink.c +22 -22
94 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Tejun Heo
maintainerPATCH 5/6 kernfs: s/sysfs/kernfs/ in global variables
In reply to Tejun Heokernfs 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_mutex/kernfs_mutex/
* s/sysfs_dentry_ops/kernfs_dops/
* s/sysfs_dir_operations/kernfs_dir_fops/
* s/sysfs_dir_inode_operations/kernfs_dir_iops/
* s/kernfs_file_operations/kernfs_file_fops/ - renamed for consistency
* s/sysfs_symlink_inode_operations/kernfs_symlink_iops/
* s/sysfs_aops/kernfs_aops/
* s/sysfs_backing_dev_info/kernfs_bdi/
* s/sysfs_inode_operations/kernfs_iops/
* s/sysfs_dir_cachep/kernfs_node_cache/
* s/sysfs_ops/kernfs_sops/
This patch is strictly rename only and doesn't introduce any functional difference.
--- fs/kernfs/dir.c | 64 ++++++++++++++++++++++----------------------- fs/kernfs/file.c | 2 +- fs/kernfs/inode.c | 46 ++++++++++++++++---------------- fs/kernfs/kernfs-internal.h | 14 +++++----- fs/kernfs/mount.c | 14 +++++----- fs/kernfs/symlink.c | 6 ++--- 6 files changed, 73 insertions(+), 73 deletions(-)
fs/kernfs/dir.c +32 -32
@@ -17,7 +17,7 @@#include "kernfs-internal.h" -DEFINE_MUTEX (sysfs_mutex); +DEFINE_MUTEX (kernfs_mutex);#define rb_to_kn (X ) rb_entry((X), struct kernfs_node, rb)
@@ -68,7 +68,7 @@ static int sysfs_sd_compare(const struct kernfs_node *left,* @kn->parent->dir.children. * * Locking: -* mutex_lock(sysfs_mutex) +* mutex_lock(kernfs_mutex) * * RETURNS: * 0 on susccess -EEXIST on failure.
@@ -109,7 +109,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)* kn->parent->dir.children. * * Locking: -* mutex_lock(sysfs_mutex) +* mutex_lock(kernfs_mutex) */ static void sysfs_unlink_sibling (struct kernfs_node *kn) {
@@ -251,7 +251,7 @@ void kernfs_put(struct kernfs_node *kn) }kfree (kn->iattr);ida_simple_remove (&root->ino_ida, kn->ino); -kmem_cache_free (sysfs_dir_cachep, kn); +kmem_cache_free (kernfs_node_cache, kn); kn = parent;if (kn) {
@@ -279,7 +279,7 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)return -ECHILD ; kn = dentry->d_fsdata; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex);/* The sysfs dirent has been deleted */ if (kn->flags &KERNFS_REMOVED )
@@ -298,7 +298,7 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) kernfs_info(dentry->d_sb)->ns != kn->ns) goto out_bad; -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex); out_valid:return 1 ; out_bad:
@@ -312,7 +312,7 @@ out_bad:* is performed at its new name the dentry will be readded * to the dcache hashes. */ -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);/* If we have submounts we must allow the vfs caches * to lie about the state of the filesystem to prevent
@@ -329,7 +329,7 @@ static void sysfs_dentry_release(struct dentry *dentry)kernfs_put (dentry->d_fsdata); } -const struct dentry_operations sysfs_dentry_ops = { +const struct dentry_operations kernfs_dops = { .d_revalidate = sysfs_dentry_revalidate, .d_delete = sysfs_dentry_delete, .d_release = sysfs_dentry_release,
@@ -348,7 +348,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,return NULL ; } - kn =kmem_cache_zalloc (sysfs_dir_cachep,GFP_KERNEL ); + kn =kmem_cache_zalloc (kernfs_node_cache,GFP_KERNEL );if (!kn) goto err_out1;
@@ -367,7 +367,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,return kn; err_out2: -kmem_cache_free (sysfs_dir_cachep, kn); +kmem_cache_free (kernfs_node_cache, kn); err_out1:kfree (dup_name);return NULL ;
@@ -378,19 +378,19 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,* @acxt: pointer to kernfs_addrm_cxt to be used * * This function is called when the caller is about to add or remove -* kernfs_node. This function acquires sysfs_mutex. @acxt is used to -* keep and pass context to other addrm functions. +* kernfs_node. This function acquires kernfs_mutex. @acxt is used +* to keep and pass context to other addrm functions. * * LOCKING: -* Kernel thread context (may sleep). sysfs_mutex is locked on +* Kernel thread context (may sleep). kernfs_mutex is locked on * return. */ void sysfs_addrm_start (struct kernfs_addrm_cxt *acxt) -__acquires (sysfs_mutex) +__acquires (kernfs_mutex) {memset (acxt,0 ,sizeof (*acxt)); -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); }/**
@@ -503,13 +503,13 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,* cleaned up. * * LOCKING: -* sysfs_mutex is released. +* kernfs_mutex is released. */ void sysfs_addrm_finish (struct kernfs_addrm_cxt *acxt) -__releases (sysfs_mutex) +__releases (kernfs_mutex) {/* release resources acquired by sysfs_addrm_start() */ -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);/* kill removed kernfs_nodes */ while (acxt->removed) {
@@ -540,7 +540,7 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,bool has_ns =kernfs_ns_enabled (parent);unsigned int hash; -lockdep_assert_held (&sysfs_mutex); +lockdep_assert_held (&kernfs_mutex);if (has_ns != (bool )ns) { WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n",
@@ -580,10 +580,10 @@ struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent, {struct kernfs_node *kn; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); kn =kernfs_find_ns (parent, name, ns);kernfs_get (kn); -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);return kn; }
@@ -683,7 +683,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,struct inode *inode;const void *ns =NULL ; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex);if (kernfs_ns_enabled (parent)) ns =kernfs_info (dir->i_sb)->ns;
@@ -708,11 +708,11 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,/* instantiate and hash dentry */ ret =d_materialise_unique (dentry, inode); out_unlock: -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);return ret; } -const struct inode_operations sysfs_dir_inode_operations = { +const struct inode_operations kernfs_dir_iops = { .lookup = sysfs_lookup, .permission = sysfs_permission, .setattr = sysfs_setattr,
@@ -759,7 +759,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos, {struct rb_node *rbn; -lockdep_assert_held (&sysfs_mutex); +lockdep_assert_held (&kernfs_mutex);/* if first iteration, visit leftmost descendant which may be root */ if (!pos)
@@ -859,7 +859,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, {int error; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); error =0 ; if ((kn->parent == new_parent) && (kn->ns == new_ns) &&
@@ -894,7 +894,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, error =0 ; out: -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);return error; }
@@ -968,7 +968,7 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)if (!dir_emit_dots (file, ctx))return 0 ; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex);if (kernfs_ns_enabled (parent)) ns =kernfs_info (dentry->d_sb)->ns;
@@ -985,12 +985,12 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx) file->private_data = pos;kernfs_get (pos); -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);if (!dir_emit (ctx, name, len, ino, type))return 0 ; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); } -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex); file->private_data =NULL ; ctx->pos =INT_MAX ;return 0 ;
@@ -1008,7 +1008,7 @@ static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence)return ret; } -const struct file_operations sysfs_dir_operations = { +const struct file_operations kernfs_dir_fops = { .read = generic_read_dir, .iterate = sysfs_readdir, .release = sysfs_dir_release,
fs/kernfs/file.c +1 -1
@@ -750,7 +750,7 @@ void kernfs_notify(struct kernfs_node *kn) }EXPORT_SYMBOL_GPL (kernfs_notify); -const struct file_operations kernfs_file_operations = { +const struct file_operations kernfs_file_fops = { .read = kernfs_file_read, .write = kernfs_file_write, .llseek = generic_file_llseek,
fs/kernfs/inode.c +23 -23
124 lines not on this page · raw message
fs/kernfs/kernfs-internal.h +7 -7
@@ -71,7 +71,7 @@ struct kernfs_super_info { };#define kernfs_info (SB ) ((struct kernfs_super_info *)(SB->s_fs_info)) -extern struct kmem_cache *sysfs_dir_cachep; +extern struct kmem_cache *kernfs_node_cache;/* * inode.c
@@ -93,10 +93,10 @@ void sysfs_inode_init(void);/* * dir.c */ -extern struct mutex sysfs_mutex; -extern const struct dentry_operations sysfs_dentry_ops; -extern const struct file_operations sysfs_dir_operations; -extern const struct inode_operations sysfs_dir_inode_operations; +extern struct mutex kernfs_mutex; +extern const struct dentry_operations kernfs_dops; +extern const struct file_operations kernfs_dir_fops; +extern const struct inode_operations kernfs_dir_iops;struct kernfs_node *sysfs_get_active (struct kernfs_node *kn);void sysfs_put_active (struct kernfs_node *kn);
@@ -110,13 +110,13 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,/* * file.c */ -extern const struct file_operations kernfs_file_operations; +extern const struct file_operations kernfs_file_fops;void sysfs_unmap_bin_file (struct kernfs_node *kn);/* * symlink.c */ -extern const struct inode_operations sysfs_symlink_inode_operations; +extern const struct inode_operations kernfs_symlink_iops;#endif /* __KERNFS_INTERNAL_H */
fs/kernfs/mount.c +7 -7
@@ -17,9 +17,9 @@#include "kernfs-internal.h" -struct kmem_cache *sysfs_dir_cachep; +struct kmem_cache *kernfs_node_cache; -static const struct super_operations sysfs_ops = { +static const struct super_operations kernfs_sops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, .evict_inode = sysfs_evict_inode,
@@ -34,13 +34,13 @@ static int sysfs_fill_super(struct super_block *sb) sb->s_blocksize =PAGE_CACHE_SIZE ; sb->s_blocksize_bits =PAGE_CACHE_SHIFT ; sb->s_magic =SYSFS_MAGIC ; - sb->s_op = &sysfs_ops; + sb->s_op = &kernfs_sops; sb->s_time_gran =1 ;/* get root inode, initialize and unlock it */ -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); inode =sysfs_get_inode (sb, info->root->kn); -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);if (!inode) {pr_debug ("sysfs: could not get root inode\n" );return -ENOMEM ;
@@ -55,7 +55,7 @@ static int sysfs_fill_super(struct super_block *sb)kernfs_get (info->root->kn); root->d_fsdata = info->root->kn; sb->s_root = root; - sb->s_d_op = &sysfs_dentry_ops; + sb->s_d_op = &kernfs_dops;return 0 ; }
@@ -158,7 +158,7 @@ void kernfs_kill_sb(struct super_block *sb)void __init kernfs_init (void ) { - sysfs_dir_cachep =kmem_cache_create ("sysfs_dir_cache" , + kernfs_node_cache =kmem_cache_create ("kernfs_node_cache" ,sizeof (struct kernfs_node ),0 ,SLAB_PANIC ,NULL );sysfs_inode_init ();
fs/kernfs/symlink.c +3 -3
@@ -110,9 +110,9 @@ static int sysfs_getlink(struct dentry *dentry, char *path)struct kernfs_node *target = kn->symlink.target_kn;int error; -mutex_lock (&sysfs_mutex); +mutex_lock (&kernfs_mutex); error =sysfs_get_target_path (parent, target, path); -mutex_unlock (&sysfs_mutex); +mutex_unlock (&kernfs_mutex);return error; }
@@ -138,7 +138,7 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,free_page ((unsigned long )page); } -const struct inode_operations sysfs_symlink_inode_operations = { +const struct inode_operations kernfs_symlink_iops = { .setxattr = sysfs_setxattr, .removexattr = sysfs_removexattr, .getxattr = sysfs_getxattr,
Signature · 1 line
1.8.4.2
Tejun Heo
maintainerPATCH 3/6 kernfs: s/sysfs/kernfs/ in various data structures
In reply to Tejun Heokernfs 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.
--- fs/kernfs/dir.c | 28 ++++---- fs/kernfs/file.c | 172 ++++++++++++++++++++++---------------------- fs/kernfs/inode.c | 30 ++++---- fs/kernfs/kernfs-internal.h | 20 +++--- fs/kernfs/mount.c | 14 ++-- fs/kernfs/symlink.c | 2 +- fs/sysfs/file.c | 10 +-- include/linux/kernfs.h | 18 ++--- 8 files changed, 147 insertions(+), 147 deletions(-)
fs/kernfs/dir.c +14 -14
@@ -295,7 +295,7 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)/* The sysfs dirent has been moved to a different namespace */ if (kn->parent &&kernfs_ns_enabled (kn->parent) && -sysfs_info (dentry->d_sb)->ns != kn->ns) +kernfs_info (dentry->d_sb)->ns != kn->ns) goto out_bad;mutex_unlock (&sysfs_mutex);
@@ -375,7 +375,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,/** * sysfs_addrm_start - prepare for kernfs_node add/remove -* @acxt: pointer to sysfs_addrm_cxt to be used +* @acxt: pointer to kernfs_addrm_cxt to be used * * This function is called when the caller is about to add or remove * kernfs_node. This function acquires sysfs_mutex. @acxt is used to
@@ -385,7 +385,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,* Kernel thread context (may sleep). sysfs_mutex is locked on * return. */ -void sysfs_addrm_start (struct sysfs_addrm_cxt *acxt) +void sysfs_addrm_start (struct kernfs_addrm_cxt *acxt)__acquires (sysfs_mutex) {memset (acxt,0 ,sizeof (*acxt));
@@ -414,11 +414,11 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt)* 0 on success, -EEXIST if entry with the given name already * exists. */ -int sysfs_add_one (struct sysfs_addrm_cxt *acxt,struct kernfs_node *kn, +int sysfs_add_one (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn,struct kernfs_node *parent) {bool has_ns =kernfs_ns_enabled (parent); -struct sysfs_inode_attrs *ps_iattr; +struct kernfs_iattrs *ps_iattr;int ret;if (has_ns != (bool )kn->ns) {
@@ -466,10 +466,10 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct kernfs_node *kn,* LOCKING: * Determined by sysfs_addrm_start(). */ -static void sysfs_remove_one (struct sysfs_addrm_cxt *acxt, +static void sysfs_remove_one (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn) { -struct sysfs_inode_attrs *ps_iattr; +struct kernfs_iattrs *ps_iattr;/* * Removal can be called multiple times on the same node. Only the
@@ -505,7 +505,7 @@ static void sysfs_remove_one(struct sysfs_addrm_cxt *acxt,* LOCKING: * sysfs_mutex is released. */ -void sysfs_addrm_finish (struct sysfs_addrm_cxt *acxt) +void sysfs_addrm_finish (struct kernfs_addrm_cxt *acxt)__releases (sysfs_mutex) {/* release resources acquired by sysfs_addrm_start() */
@@ -649,7 +649,7 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent, const void *ns) {umode_t mode =S_IFDIR |S_IRWXU |S_IRUGO |S_IXUGO ; -struct sysfs_addrm_cxt acxt; +struct kernfs_addrm_cxt acxt;struct kernfs_node *kn;int rc;
@@ -686,7 +686,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,mutex_lock (&sysfs_mutex);if (kernfs_ns_enabled (parent)) - ns =sysfs_info (dir->i_sb)->ns; + ns =kernfs_info (dir->i_sb)->ns; kn =kernfs_find_ns (parent, dentry->d_name.name, ns);
@@ -778,7 +778,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,return pos->parent; } -static void __kernfs_remove (struct sysfs_addrm_cxt *acxt, +static void __kernfs_remove (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn) {struct kernfs_node *pos, *next;
@@ -805,7 +805,7 @@ static void __kernfs_remove(struct sysfs_addrm_cxt *acxt,*/ void kernfs_remove (struct kernfs_node *kn) { -struct sysfs_addrm_cxt acxt; +struct kernfs_addrm_cxt acxt;sysfs_addrm_start (&acxt);__kernfs_remove (&acxt, kn);
@@ -824,7 +824,7 @@ void kernfs_remove(struct kernfs_node *kn)int kernfs_remove_by_name_ns (struct kernfs_node *parent,const char *name,const void *ns) { -struct sysfs_addrm_cxt acxt; +struct kernfs_addrm_cxt acxt;struct kernfs_node *kn;if (!parent) {
@@ -971,7 +971,7 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)mutex_lock (&sysfs_mutex);if (kernfs_ns_enabled (parent)) - ns =sysfs_info (dentry->d_sb)->ns; + ns =kernfs_info (dentry->d_sb)->ns; for (pos = sysfs_dir_pos(ns, parent, ctx->pos, pos); pos;
fs/kernfs/file.c +86 -86
397 lines not on this page · raw message
fs/kernfs/inode.c +15 -15
@@ -46,14 +46,14 @@ void __init sysfs_inode_init(void)panic ("failed to init sysfs_backing_dev_info" ); } -static struct sysfs_inode_attrs *sysfs_inode_attrs (struct kernfs_node *kn) +static struct kernfs_iattrs *kernfs_iattrs (struct kernfs_node *kn) {struct iattr *iattrs;if (kn->iattr)return kn->iattr; - kn->iattr =kzalloc (sizeof (struct sysfs_inode_attrs ),GFP_KERNEL ); + kn->iattr =kzalloc (sizeof (struct kernfs_iattrs ),GFP_KERNEL );if (!kn->iattr)return NULL ; iattrs = &kn->iattr->ia_iattr;
@@ -71,11 +71,11 @@ static struct sysfs_inode_attrs *sysfs_inode_attrs(struct kernfs_node *kn)static int __kernfs_setattr (struct kernfs_node *kn,const struct iattr *iattr) { -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs;struct iattr *iattrs;unsigned int ia_valid = iattr->ia_valid; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -144,11 +144,11 @@ out:static int sysfs_sd_setsecdata (struct kernfs_node *kn,void **secdata,u32 *secdata_len) { -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs;void *old_secdata;size_t old_secdata_len; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -167,12 +167,12 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) {struct kernfs_node *kn = dentry->d_fsdata; -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs;void *secdata;int error;u32 secdata_len =0 ; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -205,9 +205,9 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,int sysfs_removexattr (struct dentry *dentry,const char *name) {struct kernfs_node *kn = dentry->d_fsdata; -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -218,9 +218,9 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, size_t size) {struct kernfs_node *kn = dentry->d_fsdata; -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -230,9 +230,9 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,ssize_t sysfs_listxattr (struct dentry *dentry,char *buf,size_t size) {struct kernfs_node *kn = dentry->d_fsdata; -struct sysfs_inode_attrs *attrs; +struct kernfs_iattrs *attrs; - attrs =sysfs_inode_attrs (kn); + attrs =kernfs_iattrs (kn);if (!attrs)return -ENOMEM ;
@@ -256,7 +256,7 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)static void sysfs_refresh_inode (struct kernfs_node *kn,struct inode *inode) { -struct sysfs_inode_attrs *attrs = kn->iattr; +struct kernfs_iattrs *attrs = kn->iattr; inode->i_mode = kn->mode;if (attrs) {
fs/kernfs/kernfs-internal.h +10 -10
@@ -18,7 +18,7 @@#include <linux/kernfs.h> -struct sysfs_inode_attrs { +struct kernfs_iattrs {struct iattr ia_iattr;void *ia_secdata;u32 ia_secdata_len;
@@ -47,14 +47,14 @@ static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)/* * Context structure to be used while adding/removing nodes. */ -struct sysfs_addrm_cxt { +struct kernfs_addrm_cxt {struct kernfs_node *removed; };/* * mount.c */ -struct sysfs_super_info { +struct kernfs_super_info {/* * The root associated with this super_block. Each super_block is * identified by the root and ns it's associated with.
@@ -63,13 +63,13 @@ struct sysfs_super_info {/* * Each sb is associated with one namespace tag, currently the -* network namespace of the task which mounted this sysfs instance. -* If multiple tags become necessary, make the following an array -* and compare kernfs_node tag against every entry. +* network namespace of the task which mounted this kernfs +* instance. If multiple tags become necessary, make the following +* an array and compare kernfs_node tag against every entry. */ const void *ns; }; -#define sysfs_info (SB ) ((struct sysfs_super_info *)(SB->s_fs_info)) +#define kernfs_info (SB ) ((struct kernfs_super_info *)(SB->s_fs_info))extern struct kmem_cache *sysfs_dir_cachep;
@@ -100,10 +100,10 @@ extern const struct inode_operations sysfs_dir_inode_operations;struct kernfs_node *sysfs_get_active (struct kernfs_node *kn);void sysfs_put_active (struct kernfs_node *kn); -void sysfs_addrm_start (struct sysfs_addrm_cxt *acxt); -int sysfs_add_one (struct sysfs_addrm_cxt *acxt,struct kernfs_node *kn, +void sysfs_addrm_start (struct kernfs_addrm_cxt *acxt); +int sysfs_add_one (struct kernfs_addrm_cxt *acxt,struct kernfs_node *kn,struct kernfs_node *parent); -void sysfs_addrm_finish (struct sysfs_addrm_cxt *acxt); +void sysfs_addrm_finish (struct kernfs_addrm_cxt *acxt);struct kernfs_node *sysfs_new_dirent (struct kernfs_root *root,const char *name,umode_t mode,int type);
fs/kernfs/mount.c +7 -7
@@ -27,7 +27,7 @@ static const struct super_operations sysfs_ops = {static int sysfs_fill_super (struct super_block *sb) { -struct sysfs_super_info *info =sysfs_info (sb); +struct kernfs_super_info *info =kernfs_info (sb);struct inode *inode;struct dentry *root;
@@ -61,8 +61,8 @@ static int sysfs_fill_super(struct super_block *sb)static int sysfs_test_super (struct super_block *sb,void *data) { -struct sysfs_super_info *sb_info =sysfs_info (sb); -struct sysfs_super_info *info = data; +struct kernfs_super_info *sb_info =kernfs_info (sb); +struct kernfs_super_info *info = data;return sb_info->root == info->root && sb_info->ns == info->ns; }
@@ -84,7 +84,7 @@ static int sysfs_set_super(struct super_block *sb, void *data)*/ const void *kernfs_super_ns (struct super_block *sb) { -struct sysfs_super_info *info =sysfs_info (sb); +struct kernfs_super_info *info =kernfs_info (sb);return info->ns; }
@@ -107,7 +107,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, struct kernfs_root *root, const void *ns) { struct super_block *sb; -struct sysfs_super_info *info; +struct kernfs_super_info *info;int error; info =kzalloc (sizeof (*info),GFP_KERNEL );
@@ -144,12 +144,12 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,*/ void kernfs_kill_sb (struct super_block *sb) { -struct sysfs_super_info *info =sysfs_info (sb); +struct kernfs_super_info *info =kernfs_info (sb);struct kernfs_node *root_kn = sb->s_root->d_fsdata;/* * Remove the superblock from fs_supers/s_instances -* so we can't find it, before freeing sysfs_super_info. +* so we can't find it, before freeing kernfs_super_info. */ kill_anon_super (sb);kfree (info);
fs/kernfs/symlink.c +1 -1
@@ -27,7 +27,7 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, struct kernfs_node *target) {struct kernfs_node *kn; -struct sysfs_addrm_cxt acxt; +struct kernfs_addrm_cxt acxt;int error; kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO,
fs/sysfs/file.c +5 -5
@@ -41,7 +41,7 @@ static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)*/ static int sysfs_kf_seq_show (struct seq_file *sf,void *v) { -struct sysfs_open_file *of = sf->private; +struct kernfs_open_file *of = sf->private;struct kobject *kobj = of->kn->parent->priv;const struct sysfs_ops *ops =sysfs_file_ops (of->kn);ssize_t count;
@@ -78,7 +78,7 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)return 0 ; } -static ssize_t sysfs_kf_bin_read (struct sysfs_open_file *of,char *buf, +static ssize_t sysfs_kf_bin_read (struct kernfs_open_file *of,char *buf,size_t count,loff_t pos) {struct bin_attribute *battr = of->kn->priv;
@@ -102,7 +102,7 @@ static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf, }/* kernfs write callback for regular sysfs files */ -static ssize_t sysfs_kf_write (struct sysfs_open_file *of,char *buf, +static ssize_t sysfs_kf_write (struct kernfs_open_file *of,char *buf,size_t count,loff_t pos) {const struct sysfs_ops *ops =sysfs_file_ops (of->kn);
@@ -115,7 +115,7 @@ static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf, }/* kernfs write callback for bin sysfs files */ -static ssize_t sysfs_kf_bin_write (struct sysfs_open_file *of,char *buf, +static ssize_t sysfs_kf_bin_write (struct kernfs_open_file *of,char *buf,size_t count,loff_t pos) {struct bin_attribute *battr = of->kn->priv;
@@ -136,7 +136,7 @@ static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf,return battr->write (of->file, kobj, battr, buf, pos, count); } -static int sysfs_kf_bin_mmap (struct sysfs_open_file *of, +static int sysfs_kf_bin_mmap (struct kernfs_open_file *of,struct vm_area_struct *vma) {struct bin_attribute *battr = of->kn->priv;
include/linux/kernfs.h +9 -9
@@ -24,8 +24,8 @@ struct vm_area_struct;struct super_block ;struct file_system_type ; -struct sysfs_open_dirent ; -struct sysfs_inode_attrs ; +struct kernfs_open_node ; +struct kernfs_iattrs ;enum kernfs_node_type {SYSFS_DIR =0x0001 ,
@@ -65,7 +65,7 @@ struct kernfs_elem_symlink {struct kernfs_elem_attr {const struct kernfs_ops *ops; -struct sysfs_open_dirent *open; +struct kernfs_open_node *open;loff_t size; };
@@ -108,7 +108,7 @@ struct kernfs_node {unsigned short flags;umode_t mode;unsigned int ino; -struct sysfs_inode_attrs *iattr; +struct kernfs_iattrs *iattr; };struct kernfs_root {
@@ -119,7 +119,7 @@ struct kernfs_root {struct ida ino_ida; }; -struct sysfs_open_file { +struct kernfs_open_file {/* published fields */ struct kernfs_node *kn;struct file *file;
@@ -140,7 +140,7 @@ struct kernfs_ops {* If seq_show() is present, seq_file path is active. Other seq * operations are optional and if not implemented, the behavior is * equivalent to single_open(). @sf->private points to the -* associated sysfs_open_file. +* associated kernfs_open_file. * * read() is bounced through kernel buffer and a read larger than * PAGE_SIZE results in partial operation of PAGE_SIZE.
@@ -151,17 +151,17 @@ struct kernfs_ops {void *(*seq_next)(struct seq_file *sf,void *v,loff_t *ppos);void (*seq_stop)(struct seq_file *sf,void *v); -ssize_t (*read)(struct sysfs_open_file *of,char *buf,size_t bytes, +ssize_t (*read)(struct kernfs_open_file *of,char *buf,size_t bytes,loff_t off);/* * write() is bounced through kernel buffer and a write larger than * PAGE_SIZE results in partial operation of PAGE_SIZE. */ -ssize_t (*write)(struct sysfs_open_file *of,char *buf,size_t bytes, +ssize_t (*write)(struct kernfs_open_file *of,char *buf,size_t bytes,loff_t off); -int (*mmap)(struct sysfs_open_file *of,struct vm_area_struct *vma); +int (*mmap)(struct kernfs_open_file *of,struct vm_area_struct *vma);#ifdef CONFIG_DEBUG_LOCK_ALLOC struct lock_class_key lockdep_key;
Signature · 1 line
1.8.4.2
Greg KH
maintainerRe: [PATCH 1/6] kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
In reply to Tejun HeoQuoted 17 lines · 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
Quoted 5 lines
Because md, mic and gpio dig into sysfs details, this patch ends up modifying them. All are
sysfs_direntrenames and trivial. While we can avoid these by introducing a dummy wrapping structsysfs_direntaroundkernfs_node, given the limited usage outside kernfs and sysfs proper, I don't think such workaround is called for.
Ugh, why are those drivers digging into sysfs core bits anyway? I'll look and see if they should be fixed up as well, as I really doubt a "normal" driver should ever care about this type of thing...
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH 1/6] kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
Quoted 24 lines · Greg KH
Quoted 17 lines · 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 aboveQuoted 5 lines
Because md, mic and gpio dig into sysfs details, this patch ends up modifying them. All are
sysfs_direntrenames and trivial. While we can avoid these by introducing a dummy wrapping structsysfs_direntaroundkernfs_node, given the limited usage outside kernfs and sysfs proper, I don't think such workaround is called for.
Quoted 3 lines
Ugh, why are those drivers digging into sysfs core bits anyway? I'll look and see if they should be fixed up as well, as I really doubt a "normal" driver should ever care about this type of thing...
Ok, to answer my own question, it looks like these drivers need to be fixed up, they just want to handle userspace doing a poll() on a sysfs file, but shouldn't need to muck around with "raw" sysfs file calls for this, the driver core should be able to handle this for them.
I'll work on fixing that up later.
thanks,
greg k-h
Re: [PATCH 1/6] kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
In reply to Tejun HeoQuoted 5 lines · 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.
for the gpiolib stuff, FWIW.
Yours,
Linus Walleij