aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 14:11:56 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-11 20:39:20 -0500
commitdf23fc39bce03bb26e63bea57fc5f5bf6882d74b (patch)
tree9317af4854fd05e326a93ac736160fdc56ddbabc /fs/kernfs
parentc525aaddc366df23eb095d58a2bdf11cce62a98b (diff)
kernfs: s/sysfs/kernfs/ in constants
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_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. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs')
-rw-r--r--fs/kernfs/dir.c50
-rw-r--r--fs/kernfs/file.c18
-rw-r--r--fs/kernfs/inode.c10
-rw-r--r--fs/kernfs/kernfs-internal.h4
-rw-r--r--fs/kernfs/symlink.c2
5 files changed, 42 insertions, 42 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index d038bb204b54..bc8a3b367a8c 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -78,7 +78,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)
78 struct rb_node **node = &kn->parent->dir.children.rb_node; 78 struct rb_node **node = &kn->parent->dir.children.rb_node;
79 struct rb_node *parent = NULL; 79 struct rb_node *parent = NULL;
80 80
81 if (sysfs_type(kn) == SYSFS_DIR) 81 if (kernfs_type(kn) == KERNFS_DIR)
82 kn->parent->dir.subdirs++; 82 kn->parent->dir.subdirs++;
83 83
84 while (*node) { 84 while (*node) {
@@ -113,7 +113,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)
113 */ 113 */
114static void sysfs_unlink_sibling(struct kernfs_node *kn) 114static void sysfs_unlink_sibling(struct kernfs_node *kn)
115{ 115{
116 if (sysfs_type(kn) == SYSFS_DIR) 116 if (kernfs_type(kn) == KERNFS_DIR)
117 kn->parent->dir.subdirs--; 117 kn->parent->dir.subdirs--;
118 118
119 rb_erase(&kn->rb, &kn->parent->dir.children); 119 rb_erase(&kn->rb, &kn->parent->dir.children);
@@ -137,7 +137,7 @@ struct kernfs_node *sysfs_get_active(struct kernfs_node *kn)
137 if (!atomic_inc_unless_negative(&kn->active)) 137 if (!atomic_inc_unless_negative(&kn->active))
138 return NULL; 138 return NULL;
139 139
140 if (kn->flags & SYSFS_FLAG_LOCKDEP) 140 if (kn->flags & KERNFS_LOCKDEP)
141 rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_); 141 rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_);
142 return kn; 142 return kn;
143} 143}
@@ -156,10 +156,10 @@ void sysfs_put_active(struct kernfs_node *kn)
156 if (unlikely(!kn)) 156 if (unlikely(!kn))
157 return; 157 return;
158 158
159 if (kn->flags & SYSFS_FLAG_LOCKDEP) 159 if (kn->flags & KERNFS_LOCKDEP)
160 rwsem_release(&kn->dep_map, 1, _RET_IP_); 160 rwsem_release(&kn->dep_map, 1, _RET_IP_);
161 v = atomic_dec_return(&kn->active); 161 v = atomic_dec_return(&kn->active);
162 if (likely(v != SD_DEACTIVATED_BIAS)) 162 if (likely(v != KN_DEACTIVATED_BIAS))
163 return; 163 return;
164 164
165 /* 165 /*
@@ -180,9 +180,9 @@ static void sysfs_deactivate(struct kernfs_node *kn)
180 DECLARE_COMPLETION_ONSTACK(wait); 180 DECLARE_COMPLETION_ONSTACK(wait);
181 int v; 181 int v;
182 182
183 BUG_ON(!(kn->flags & SYSFS_FLAG_REMOVED)); 183 BUG_ON(!(kn->flags & KERNFS_REMOVED));
184 184
185 if (!(sysfs_type(kn) & SYSFS_ACTIVE_REF)) 185 if (!(kernfs_type(kn) & KERNFS_ACTIVE_REF))
186 return; 186 return;
187 187
188 kn->u.completion = (void *)&wait; 188 kn->u.completion = (void *)&wait;
@@ -191,9 +191,9 @@ static void sysfs_deactivate(struct kernfs_node *kn)
191 /* atomic_add_return() is a mb(), put_active() will always see 191 /* atomic_add_return() is a mb(), put_active() will always see
192 * the updated kn->u.completion. 192 * the updated kn->u.completion.
193 */ 193 */
194 v = atomic_add_return(SD_DEACTIVATED_BIAS, &kn->active); 194 v = atomic_add_return(KN_DEACTIVATED_BIAS, &kn->active);
195 195
196 if (v != SD_DEACTIVATED_BIAS) { 196 if (v != KN_DEACTIVATED_BIAS) {
197 lock_contended(&kn->dep_map, _RET_IP_); 197 lock_contended(&kn->dep_map, _RET_IP_);
198 wait_for_completion(&wait); 198 wait_for_completion(&wait);
199 } 199 }
@@ -235,13 +235,13 @@ void kernfs_put(struct kernfs_node *kn)
235 */ 235 */
236 parent = kn->parent; 236 parent = kn->parent;
237 237
238 WARN(!(kn->flags & SYSFS_FLAG_REMOVED), 238 WARN(!(kn->flags & KERNFS_REMOVED),
239 "sysfs: free using entry: %s/%s\n", 239 "sysfs: free using entry: %s/%s\n",
240 parent ? parent->name : "", kn->name); 240 parent ? parent->name : "", kn->name);
241 241
242 if (sysfs_type(kn) == SYSFS_KOBJ_LINK) 242 if (kernfs_type(kn) == KERNFS_LINK)
243 kernfs_put(kn->symlink.target_kn); 243 kernfs_put(kn->symlink.target_kn);
244 if (sysfs_type(kn) & SYSFS_COPY_NAME) 244 if (kernfs_type(kn) & KERNFS_COPY_NAME)
245 kfree(kn->name); 245 kfree(kn->name);
246 if (kn->iattr) { 246 if (kn->iattr) {
247 if (kn->iattr->ia_secdata) 247 if (kn->iattr->ia_secdata)
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_GPL(kernfs_put);
268static int sysfs_dentry_delete(const struct dentry *dentry) 268static int sysfs_dentry_delete(const struct dentry *dentry)
269{ 269{
270 struct kernfs_node *kn = dentry->d_fsdata; 270 struct kernfs_node *kn = dentry->d_fsdata;
271 return !(kn && !(kn->flags & SYSFS_FLAG_REMOVED)); 271 return !(kn && !(kn->flags & KERNFS_REMOVED));
272} 272}
273 273
274static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) 274static 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)
282 mutex_lock(&sysfs_mutex); 282 mutex_lock(&sysfs_mutex);
283 283
284 /* The sysfs dirent has been deleted */ 284 /* The sysfs dirent has been deleted */
285 if (kn->flags & SYSFS_FLAG_REMOVED) 285 if (kn->flags & KERNFS_REMOVED)
286 goto out_bad; 286 goto out_bad;
287 287
288 /* The sysfs dirent has been moved? */ 288 /* The sysfs dirent has been moved? */
@@ -342,7 +342,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,
342 struct kernfs_node *kn; 342 struct kernfs_node *kn;
343 int ret; 343 int ret;
344 344
345 if (type & SYSFS_COPY_NAME) { 345 if (type & KERNFS_COPY_NAME) {
346 name = dup_name = kstrdup(name, GFP_KERNEL); 346 name = dup_name = kstrdup(name, GFP_KERNEL);
347 if (!name) 347 if (!name)
348 return NULL; 348 return NULL;
@@ -362,7 +362,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,
362 362
363 kn->name = name; 363 kn->name = name;
364 kn->mode = mode; 364 kn->mode = mode;
365 kn->flags = type | SYSFS_FLAG_REMOVED; 365 kn->flags = type | KERNFS_REMOVED;
366 366
367 return kn; 367 return kn;
368 368
@@ -427,7 +427,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
427 return -EINVAL; 427 return -EINVAL;
428 } 428 }
429 429
430 if (sysfs_type(parent) != SYSFS_DIR) 430 if (kernfs_type(parent) != KERNFS_DIR)
431 return -EINVAL; 431 return -EINVAL;
432 432
433 kn->hash = sysfs_name_hash(kn->name, kn->ns); 433 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,
446 } 446 }
447 447
448 /* Mark the entry added into directory tree */ 448 /* Mark the entry added into directory tree */
449 kn->flags &= ~SYSFS_FLAG_REMOVED; 449 kn->flags &= ~KERNFS_REMOVED;
450 450
451 return 0; 451 return 0;
452} 452}
@@ -475,7 +475,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,
475 * Removal can be called multiple times on the same node. Only the 475 * Removal can be called multiple times on the same node. Only the
476 * first invocation is effective and puts the base ref. 476 * first invocation is effective and puts the base ref.
477 */ 477 */
478 if (kn->flags & SYSFS_FLAG_REMOVED) 478 if (kn->flags & KERNFS_REMOVED)
479 return; 479 return;
480 480
481 if (kn->parent) { 481 if (kn->parent) {
@@ -489,7 +489,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,
489 } 489 }
490 } 490 }
491 491
492 kn->flags |= SYSFS_FLAG_REMOVED; 492 kn->flags |= KERNFS_REMOVED;
493 kn->u.removed_list = acxt->removed; 493 kn->u.removed_list = acxt->removed;
494 acxt->removed = kn; 494 acxt->removed = kn;
495} 495}
@@ -607,14 +607,14 @@ struct kernfs_root *kernfs_create_root(void *priv)
607 607
608 ida_init(&root->ino_ida); 608 ida_init(&root->ino_ida);
609 609
610 kn = sysfs_new_dirent(root, "", S_IFDIR | S_IRUGO | S_IXUGO, SYSFS_DIR); 610 kn = sysfs_new_dirent(root, "", S_IFDIR | S_IRUGO | S_IXUGO, KERNFS_DIR);
611 if (!kn) { 611 if (!kn) {
612 ida_destroy(&root->ino_ida); 612 ida_destroy(&root->ino_ida);
613 kfree(root); 613 kfree(root);
614 return ERR_PTR(-ENOMEM); 614 return ERR_PTR(-ENOMEM);
615 } 615 }
616 616
617 kn->flags &= ~SYSFS_FLAG_REMOVED; 617 kn->flags &= ~KERNFS_REMOVED;
618 kn->priv = priv; 618 kn->priv = priv;
619 kn->dir.root = root; 619 kn->dir.root = root;
620 620
@@ -654,7 +654,7 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
654 int rc; 654 int rc;
655 655
656 /* allocate */ 656 /* allocate */
657 kn = sysfs_new_dirent(kernfs_root(parent), name, mode, SYSFS_DIR); 657 kn = sysfs_new_dirent(kernfs_root(parent), name, mode, KERNFS_DIR);
658 if (!kn) 658 if (!kn)
659 return ERR_PTR(-ENOMEM); 659 return ERR_PTR(-ENOMEM);
660 660
@@ -732,7 +732,7 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos)
732 732
733 last = pos; 733 last = pos;
734 734
735 if (sysfs_type(pos) != SYSFS_DIR) 735 if (kernfs_type(pos) != KERNFS_DIR)
736 break; 736 break;
737 737
738 rbn = rb_first(&pos->dir.children); 738 rbn = rb_first(&pos->dir.children);
@@ -914,7 +914,7 @@ static struct kernfs_node *sysfs_dir_pos(const void *ns,
914 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) 914 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos)
915{ 915{
916 if (pos) { 916 if (pos) {
917 int valid = !(pos->flags & SYSFS_FLAG_REMOVED) && 917 int valid = !(pos->flags & KERNFS_REMOVED) &&
918 pos->parent == parent && hash == pos->hash; 918 pos->parent == parent && hash == pos->hash;
919 kernfs_put(pos); 919 kernfs_put(pos);
920 if (!valid) 920 if (!valid)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 2714a394cd81..abe93e12089c 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -49,7 +49,7 @@ static struct kernfs_open_file *kernfs_of(struct file *file)
49 */ 49 */
50static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn) 50static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn)
51{ 51{
52 if (kn->flags & SYSFS_FLAG_LOCKDEP) 52 if (kn->flags & KERNFS_LOCKDEP)
53 lockdep_assert_held(kn); 53 lockdep_assert_held(kn);
54 return kn->attr.ops; 54 return kn->attr.ops;
55} 55}
@@ -189,7 +189,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
189{ 189{
190 struct kernfs_open_file *of = kernfs_of(file); 190 struct kernfs_open_file *of = kernfs_of(file);
191 191
192 if (of->kn->flags & SYSFS_FLAG_HAS_SEQ_SHOW) 192 if (of->kn->flags & KERNFS_HAS_SEQ_SHOW)
193 return seq_read(file, user_buf, count, ppos); 193 return seq_read(file, user_buf, count, ppos);
194 else 194 else
195 return kernfs_file_direct_read(of, user_buf, count, ppos); 195 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)
428 * without grabbing @of->mutex by testing HAS_MMAP flag. See the 428 * without grabbing @of->mutex by testing HAS_MMAP flag. See the
429 * comment in kernfs_file_open() for more details. 429 * comment in kernfs_file_open() for more details.
430 */ 430 */
431 if (!(of->kn->flags & SYSFS_FLAG_HAS_MMAP)) 431 if (!(of->kn->flags & KERNFS_HAS_MMAP))
432 return -ENODEV; 432 return -ENODEV;
433 433
434 mutex_lock(&of->mutex); 434 mutex_lock(&of->mutex);
@@ -668,7 +668,7 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
668 struct kernfs_open_node *on; 668 struct kernfs_open_node *on;
669 struct kernfs_open_file *of; 669 struct kernfs_open_file *of;
670 670
671 if (!(kn->flags & SYSFS_FLAG_HAS_MMAP)) 671 if (!(kn->flags & KERNFS_HAS_MMAP))
672 return; 672 return;
673 673
674 spin_lock_irq(&kernfs_open_node_lock); 674 spin_lock_irq(&kernfs_open_node_lock);
@@ -738,7 +738,7 @@ void kernfs_notify(struct kernfs_node *kn)
738 738
739 spin_lock_irqsave(&kernfs_open_node_lock, flags); 739 spin_lock_irqsave(&kernfs_open_node_lock, flags);
740 740
741 if (!WARN_ON(sysfs_type(kn) != SYSFS_KOBJ_ATTR)) { 741 if (!WARN_ON(kernfs_type(kn) != KERNFS_FILE)) {
742 on = kn->attr.open; 742 on = kn->attr.open;
743 if (on) { 743 if (on) {
744 atomic_inc(&on->event); 744 atomic_inc(&on->event);
@@ -785,7 +785,7 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
785 int rc; 785 int rc;
786 786
787 kn = sysfs_new_dirent(kernfs_root(parent), name, 787 kn = sysfs_new_dirent(kernfs_root(parent), name,
788 (mode & S_IALLUGO) | S_IFREG, SYSFS_KOBJ_ATTR); 788 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE);
789 if (!kn) 789 if (!kn)
790 return ERR_PTR(-ENOMEM); 790 return ERR_PTR(-ENOMEM);
791 791
@@ -797,7 +797,7 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
797#ifdef CONFIG_DEBUG_LOCK_ALLOC 797#ifdef CONFIG_DEBUG_LOCK_ALLOC
798 if (key) { 798 if (key) {
799 lockdep_init_map(&kn->dep_map, "s_active", key, 0); 799 lockdep_init_map(&kn->dep_map, "s_active", key, 0);
800 kn->flags |= SYSFS_FLAG_LOCKDEP; 800 kn->flags |= KERNFS_LOCKDEP;
801 } 801 }
802#endif 802#endif
803 803
@@ -807,9 +807,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
807 * ref. Cache their existence in flags. 807 * ref. Cache their existence in flags.
808 */ 808 */
809 if (ops->seq_show) 809 if (ops->seq_show)
810 kn->flags |= SYSFS_FLAG_HAS_SEQ_SHOW; 810 kn->flags |= KERNFS_HAS_SEQ_SHOW;
811 if (ops->mmap) 811 if (ops->mmap)
812 kn->flags |= SYSFS_FLAG_HAS_MMAP; 812 kn->flags |= KERNFS_HAS_MMAP;
813 813
814 sysfs_addrm_start(&acxt); 814 sysfs_addrm_start(&acxt);
815 rc = sysfs_add_one(&acxt, kn, parent); 815 rc = sysfs_add_one(&acxt, kn, parent);
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index a0e0038fd570..af92638d792b 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -269,7 +269,7 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
269 attrs->ia_secdata_len); 269 attrs->ia_secdata_len);
270 } 270 }
271 271
272 if (sysfs_type(kn) == SYSFS_DIR) 272 if (kernfs_type(kn) == KERNFS_DIR)
273 set_nlink(inode, kn->dir.subdirs + 2); 273 set_nlink(inode, kn->dir.subdirs + 2);
274} 274}
275 275
@@ -299,16 +299,16 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
299 sysfs_refresh_inode(kn, inode); 299 sysfs_refresh_inode(kn, inode);
300 300
301 /* initialize inode according to type */ 301 /* initialize inode according to type */
302 switch (sysfs_type(kn)) { 302 switch (kernfs_type(kn)) {
303 case SYSFS_DIR: 303 case KERNFS_DIR:
304 inode->i_op = &sysfs_dir_inode_operations; 304 inode->i_op = &sysfs_dir_inode_operations;
305 inode->i_fop = &sysfs_dir_operations; 305 inode->i_fop = &sysfs_dir_operations;
306 break; 306 break;
307 case SYSFS_KOBJ_ATTR: 307 case KERNFS_FILE:
308 inode->i_size = kn->attr.size; 308 inode->i_size = kn->attr.size;
309 inode->i_fop = &kernfs_file_operations; 309 inode->i_fop = &kernfs_file_operations;
310 break; 310 break;
311 case SYSFS_KOBJ_LINK: 311 case KERNFS_LINK:
312 inode->i_op = &sysfs_symlink_inode_operations; 312 inode->i_op = &sysfs_symlink_inode_operations;
313 break; 313 break;
314 default: 314 default:
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index 573f66988643..c4bf5bf72f78 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -26,9 +26,9 @@ struct kernfs_iattrs {
26 struct simple_xattrs xattrs; 26 struct simple_xattrs xattrs;
27}; 27};
28 28
29#define SD_DEACTIVATED_BIAS INT_MIN 29#define KN_DEACTIVATED_BIAS INT_MIN
30 30
31/* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ 31/* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
32 32
33/** 33/**
34 * kernfs_root - find out the kernfs_root a kernfs_node belongs to 34 * kernfs_root - find out the kernfs_root a kernfs_node belongs to
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
index f36e3f1b2477..a92284d3c73d 100644
--- a/fs/kernfs/symlink.c
+++ b/fs/kernfs/symlink.c
@@ -31,7 +31,7 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
31 int error; 31 int error;
32 32
33 kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO, 33 kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO,
34 SYSFS_KOBJ_LINK); 34 KERNFS_LINK);
35 if (!kn) 35 if (!kn)
36 return ERR_PTR(-ENOMEM); 36 return ERR_PTR(-ENOMEM);
37 37