Commit adc5e8b5 authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman

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.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 324a56e1
This diff is collapsed.
......@@ -21,7 +21,7 @@
* There's one sysfs_open_file for each open file and one sysfs_open_dirent
* for each kernfs_node with one or more open files.
*
* kernfs_node->s_attr.open points to sysfs_open_dirent. s_attr.open is
* kernfs_node->attr.open points to sysfs_open_dirent. attr.open is
* protected by sysfs_open_dirent_lock.
*
* filp->private_data points to seq_file whose ->private points to
......@@ -49,9 +49,9 @@ static struct sysfs_open_file *sysfs_of(struct file *file)
*/
static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn)
{
if (kn->s_flags & SYSFS_FLAG_LOCKDEP)
if (kn->flags & SYSFS_FLAG_LOCKDEP)
lockdep_assert_held(kn);
return kn->s_attr.ops;
return kn->attr.ops;
}
static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
......@@ -112,9 +112,9 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
{
struct sysfs_open_file *of = sf->private;
of->event = atomic_read(&of->kn->s_attr.open->event);
of->event = atomic_read(&of->kn->attr.open->event);
return of->kn->s_attr.ops->seq_show(sf, v);
return of->kn->attr.ops->seq_show(sf, v);
}
static const struct seq_operations kernfs_seq_ops = {
......@@ -189,7 +189,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
{
struct sysfs_open_file *of = sysfs_of(file);
if (of->kn->s_flags & SYSFS_FLAG_HAS_SEQ_SHOW)
if (of->kn->flags & SYSFS_FLAG_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->s_flags & SYSFS_FLAG_HAS_MMAP))
if (!(of->kn->flags & SYSFS_FLAG_HAS_MMAP))
return -ENODEV;
mutex_lock(&of->mutex);
......@@ -477,8 +477,8 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
* @kn: target kernfs_node
* @of: sysfs_open_file for this instance of open
*
* If @kn->s_attr.open exists, increment its reference count;
* otherwise, create one. @of is chained to the files list.
* If @kn->attr.open exists, increment its reference count; otherwise,
* create one. @of is chained to the files list.
*
* LOCKING:
* Kernel thread context (may sleep).
......@@ -495,12 +495,12 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
mutex_lock(&sysfs_open_file_mutex);
spin_lock_irq(&sysfs_open_dirent_lock);
if (!kn->s_attr.open && new_od) {
kn->s_attr.open = new_od;
if (!kn->attr.open && new_od) {
kn->attr.open = new_od;
new_od = NULL;
}
od = kn->s_attr.open;
od = kn->attr.open;
if (od) {
atomic_inc(&od->refcnt);
list_add_tail(&of->list, &od->files);
......@@ -531,7 +531,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
* @kn: target kernfs_nodet
* @of: associated sysfs_open_file
*
* Put @kn->s_attr.open and unlink @of from the files list. If
* Put @kn->attr.open and unlink @of from the files list. If
* reference count reaches zero, disassociate and free it.
*
* LOCKING:
......@@ -540,7 +540,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
static void sysfs_put_open_dirent(struct kernfs_node *kn,
struct sysfs_open_file *of)
{
struct sysfs_open_dirent *od = kn->s_attr.open;
struct sysfs_open_dirent *od = kn->attr.open;
unsigned long flags;
mutex_lock(&sysfs_open_file_mutex);
......@@ -550,7 +550,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn,
list_del(&of->list);
if (atomic_dec_and_test(&od->refcnt))
kn->s_attr.open = NULL;
kn->attr.open = NULL;
else
od = NULL;
......@@ -668,11 +668,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
struct sysfs_open_dirent *od;
struct sysfs_open_file *of;
if (!(kn->s_flags & SYSFS_FLAG_HAS_MMAP))
if (!(kn->flags & SYSFS_FLAG_HAS_MMAP))
return;
spin_lock_irq(&sysfs_open_dirent_lock);
od = kn->s_attr.open;
od = kn->attr.open;
if (od)
atomic_inc(&od->refcnt);
spin_unlock_irq(&sysfs_open_dirent_lock);
......@@ -706,7 +706,7 @@ static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait)
{
struct sysfs_open_file *of = sysfs_of(filp);
struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
struct sysfs_open_dirent *od = kn->s_attr.open;
struct sysfs_open_dirent *od = kn->attr.open;
/* need parent for the kobj, grab both */
if (!sysfs_get_active(kn))
......@@ -739,7 +739,7 @@ void kernfs_notify(struct kernfs_node *kn)
spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
if (!WARN_ON(sysfs_type(kn) != SYSFS_KOBJ_ATTR)) {
od = kn->s_attr.open;
od = kn->attr.open;
if (od) {
atomic_inc(&od->event);
wake_up_interruptible(&od->poll);
......@@ -789,27 +789,27 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
if (!kn)
return ERR_PTR(-ENOMEM);
kn->s_attr.ops = ops;
kn->s_attr.size = size;
kn->s_ns = ns;
kn->attr.ops = ops;
kn->attr.size = size;
kn->ns = ns;
kn->priv = priv;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
if (key) {
lockdep_init_map(&kn->dep_map, "s_active", key, 0);
kn->s_flags |= SYSFS_FLAG_LOCKDEP;
kn->flags |= SYSFS_FLAG_LOCKDEP;
}
#endif
/*
* kn->s_attr.ops is accesible only while holding active ref. We
* kn->attr.ops is accesible only while holding active ref. We
* need to know whether some ops are implemented outside active
* ref. Cache their existence in flags.
*/
if (ops->seq_show)
kn->s_flags |= SYSFS_FLAG_HAS_SEQ_SHOW;
kn->flags |= SYSFS_FLAG_HAS_SEQ_SHOW;
if (ops->mmap)
kn->s_flags |= SYSFS_FLAG_HAS_MMAP;
kn->flags |= SYSFS_FLAG_HAS_MMAP;
sysfs_addrm_start(&acxt);
rc = sysfs_add_one(&acxt, kn, parent);
......
......@@ -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);
......
......@@ -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;
}
/*
......
......@@ -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);
......
......@@ -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);
}
......@@ -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);
......
......@@ -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);
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment