summaryrefslogtreecommitdiffstats
path: root/fs/kernfs/inode.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 20:11:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-12 00:28:36 +0100
commit324a56e16e44baecac3ca799fd216154145c14bf (patch)
tree4fb43421bfe884cf4e245e3a4672295bae4c7bd9 /fs/kernfs/inode.c
parentDocumentation: start documenting driver design patterns (diff)
downloadlinux-324a56e16e44baecac3ca799fd216154145c14bf.tar.xz
linux-324a56e16e44baecac3ca799fd216154145c14bf.zip
kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly
kernfs has just been separated out from sysfs and we're already in full conflict mode. Nothing can make the situation any worse. Let's take the chance to name things properly. This patch performs the following renames. * s/sysfs_elem_dir/kernfs_elem_dir/ * s/sysfs_elem_symlink/kernfs_elem_symlink/ * s/sysfs_elem_attr/kernfs_elem_file/ * s/sysfs_dirent/kernfs_node/ * s/sd/kn/ in kernfs proper * s/parent_sd/parent/ * s/target_sd/target/ * s/dir_sd/parent/ * s/to_sysfs_dirent()/rb_to_kn()/ * misc renames of local vars when they conflict with the above Because md, mic and gpio dig into sysfs details, this patch ends up modifying them. All are sysfs_dirent renames and trivial. While we can avoid these by introducing a dummy wrapping struct sysfs_dirent around kernfs_node, given the limited usage outside kernfs and sysfs proper, I don't think such workaround is called for. This patch is strictly rename only and doesn't introduce any functional difference. - mic / gpio renames were missing. Spotted by kbuild test robot. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Neil Brown <neilb@suse.de> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/inode.c')
-rw-r--r--fs/kernfs/inode.c123
1 files changed, 62 insertions, 61 deletions
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 18ad431e8c2a..9e74eed63539 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -46,36 +46,36 @@ void __init sysfs_inode_init(void)
panic("failed to init sysfs_backing_dev_info");
}
-static struct sysfs_inode_attrs *sysfs_inode_attrs(struct sysfs_dirent *sd)
+static struct sysfs_inode_attrs *sysfs_inode_attrs(struct kernfs_node *kn)
{
struct iattr *iattrs;
- if (sd->s_iattr)
- return sd->s_iattr;
+ if (kn->s_iattr)
+ return kn->s_iattr;
- sd->s_iattr = kzalloc(sizeof(struct sysfs_inode_attrs), GFP_KERNEL);
- if (!sd->s_iattr)
+ kn->s_iattr = kzalloc(sizeof(struct sysfs_inode_attrs), GFP_KERNEL);
+ if (!kn->s_iattr)
return NULL;
- iattrs = &sd->s_iattr->ia_iattr;
+ iattrs = &kn->s_iattr->ia_iattr;
/* assign default attributes */
- iattrs->ia_mode = sd->s_mode;
+ iattrs->ia_mode = kn->s_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(&sd->s_iattr->xattrs);
+ simple_xattrs_init(&kn->s_iattr->xattrs);
- return sd->s_iattr;
+ return kn->s_iattr;
}
-static int __kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
+static int __kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
{
struct sysfs_inode_attrs *attrs;
struct iattr *iattrs;
unsigned int ia_valid = iattr->ia_valid;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -93,24 +93,24 @@ static int __kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
iattrs->ia_ctime = iattr->ia_ctime;
if (ia_valid & ATTR_MODE) {
umode_t mode = iattr->ia_mode;
- iattrs->ia_mode = sd->s_mode = mode;
+ iattrs->ia_mode = kn->s_mode = mode;
}
return 0;
}
/**
* kernfs_setattr - set iattr on a node
- * @sd: target node
+ * @kn: target node
* @iattr: iattr to set
*
* Returns 0 on success, -errno on failure.
*/
-int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
+int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
{
int ret;
mutex_lock(&sysfs_mutex);
- ret = __kernfs_setattr(sd, iattr);
+ ret = __kernfs_setattr(kn, iattr);
mutex_unlock(&sysfs_mutex);
return ret;
}
@@ -118,10 +118,10 @@ int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
{
struct inode *inode = dentry->d_inode;
- struct sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
int error;
- if (!sd)
+ if (!kn)
return -EINVAL;
mutex_lock(&sysfs_mutex);
@@ -129,7 +129,7 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (error)
goto out;
- error = __kernfs_setattr(sd, iattr);
+ error = __kernfs_setattr(kn, iattr);
if (error)
goto out;
@@ -141,14 +141,14 @@ out:
return error;
}
-static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata,
+static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata,
u32 *secdata_len)
{
struct sysfs_inode_attrs *attrs;
void *old_secdata;
size_t old_secdata_len;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -166,13 +166,13 @@ static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata,
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags)
{
- struct sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs;
void *secdata;
int error;
u32 secdata_len = 0;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -188,7 +188,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
return error;
mutex_lock(&sysfs_mutex);
- error = sysfs_sd_setsecdata(sd, &secdata, &secdata_len);
+ error = sysfs_sd_setsecdata(kn, &secdata, &secdata_len);
mutex_unlock(&sysfs_mutex);
if (secdata)
@@ -204,10 +204,10 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
int sysfs_removexattr(struct dentry *dentry, const char *name)
{
- struct sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -217,10 +217,10 @@ int sysfs_removexattr(struct dentry *dentry, const char *name)
ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
size_t size)
{
- struct sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -229,10 +229,10 @@ 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 sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs;
- attrs = sysfs_inode_attrs(sd);
+ attrs = sysfs_inode_attrs(kn);
if (!attrs)
return -ENOMEM;
@@ -254,57 +254,58 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)
inode->i_ctime = iattr->ia_ctime;
}
-static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode)
+static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
{
- struct sysfs_inode_attrs *attrs = sd->s_iattr;
+ struct sysfs_inode_attrs *attrs = kn->s_iattr;
- inode->i_mode = sd->s_mode;
+ inode->i_mode = kn->s_mode;
if (attrs) {
- /* sysfs_dirent has non-default attributes
- * get them from persistent copy in sysfs_dirent
+ /*
+ * kernfs_node has non-default attributes get them from
+ * persistent copy in kernfs_node.
*/
set_inode_attr(inode, &attrs->ia_iattr);
security_inode_notifysecctx(inode, attrs->ia_secdata,
attrs->ia_secdata_len);
}
- if (sysfs_type(sd) == SYSFS_DIR)
- set_nlink(inode, sd->s_dir.subdirs + 2);
+ if (sysfs_type(kn) == SYSFS_DIR)
+ set_nlink(inode, kn->s_dir.subdirs + 2);
}
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat)
{
- struct sysfs_dirent *sd = dentry->d_fsdata;
+ struct kernfs_node *kn = dentry->d_fsdata;
struct inode *inode = dentry->d_inode;
mutex_lock(&sysfs_mutex);
- sysfs_refresh_inode(sd, inode);
+ sysfs_refresh_inode(kn, inode);
mutex_unlock(&sysfs_mutex);
generic_fillattr(inode, stat);
return 0;
}
-static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
+static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
{
- kernfs_get(sd);
- inode->i_private = sd;
+ kernfs_get(kn);
+ inode->i_private = kn;
inode->i_mapping->a_ops = &sysfs_aops;
inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
inode->i_op = &sysfs_inode_operations;
- set_default_inode_attr(inode, sd->s_mode);
- sysfs_refresh_inode(sd, inode);
+ set_default_inode_attr(inode, kn->s_mode);
+ sysfs_refresh_inode(kn, inode);
/* initialize inode according to type */
- switch (sysfs_type(sd)) {
+ switch (sysfs_type(kn)) {
case SYSFS_DIR:
inode->i_op = &sysfs_dir_inode_operations;
inode->i_fop = &sysfs_dir_operations;
break;
case SYSFS_KOBJ_ATTR:
- inode->i_size = sd->s_attr.size;
+ inode->i_size = kn->s_attr.size;
inode->i_fop = &kernfs_file_operations;
break;
case SYSFS_KOBJ_LINK:
@@ -318,13 +319,13 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
}
/**
- * sysfs_get_inode - get inode for sysfs_dirent
+ * sysfs_get_inode - get inode for kernfs_node
* @sb: super block
- * @sd: sysfs_dirent to allocate inode for
+ * @kn: kernfs_node to allocate inode for
*
- * Get inode for @sd. If such inode doesn't exist, a new inode
- * is allocated and basics are initialized. New inode is
- * returned locked.
+ * Get inode for @kn. If such inode doesn't exist, a new inode is
+ * allocated and basics are initialized. New inode is returned
+ * locked.
*
* LOCKING:
* Kernel thread context (may sleep).
@@ -332,44 +333,44 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
* RETURNS:
* Pointer to allocated inode on success, NULL on failure.
*/
-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)
{
struct inode *inode;
- inode = iget_locked(sb, sd->s_ino);
+ inode = iget_locked(sb, kn->s_ino);
if (inode && (inode->i_state & I_NEW))
- sysfs_init_inode(sd, inode);
+ sysfs_init_inode(kn, inode);
return inode;
}
/*
- * The sysfs_dirent serves as both an inode and a directory entry for sysfs.
- * To prevent the sysfs inode numbers from being freed prematurely we take a
- * reference to sysfs_dirent from the sysfs inode. A
+ * The kernfs_node serves as both an inode and a directory entry for sysfs.
+ * To prevent the sysfs inode numbers from being freed prematurely we take
+ * a reference to kernfs_node from the sysfs inode. A
* super_operations.evict_inode() implementation is needed to drop that
* reference upon inode destruction.
*/
void sysfs_evict_inode(struct inode *inode)
{
- struct sysfs_dirent *sd = inode->i_private;
+ struct kernfs_node *kn = inode->i_private;
truncate_inode_pages(&inode->i_data, 0);
clear_inode(inode);
- kernfs_put(sd);
+ kernfs_put(kn);
}
int sysfs_permission(struct inode *inode, int mask)
{
- struct sysfs_dirent *sd;
+ struct kernfs_node *kn;
if (mask & MAY_NOT_BLOCK)
return -ECHILD;
- sd = inode->i_private;
+ kn = inode->i_private;
mutex_lock(&sysfs_mutex);
- sysfs_refresh_inode(sd, inode);
+ sysfs_refresh_inode(kn, inode);
mutex_unlock(&sysfs_mutex);
return generic_permission(inode, mask);