aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 14:11:58 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-11 20:39:20 -0500
commitc637b8acbe079edb477d887041755b489036f146 (patch)
tree7d6e856930752574bb1d56b56bea5a2bf816de72 /fs/kernfs
parenta797bfc30532388e8a11ca726df60cdd77aa8675 (diff)
kernfs: s/sysfs/kernfs/ in internal functions and whatever is left
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_*()/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. 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.c212
-rw-r--r--fs/kernfs/file.c121
-rw-r--r--fs/kernfs/inode.c66
-rw-r--r--fs/kernfs/kernfs-internal.h44
-rw-r--r--fs/kernfs/mount.c18
-rw-r--r--fs/kernfs/symlink.c44
6 files changed, 254 insertions, 251 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index d3c66237474f..6520066c49ea 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -22,13 +22,13 @@ DEFINE_MUTEX(kernfs_mutex);
22#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb) 22#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)
23 23
24/** 24/**
25 * sysfs_name_hash 25 * kernfs_name_hash
26 * @name: Null terminated string to hash 26 * @name: Null terminated string to hash
27 * @ns: Namespace tag to hash 27 * @ns: Namespace tag to hash
28 * 28 *
29 * Returns 31 bit hash of ns + name (so it fits in an off_t ) 29 * Returns 31 bit hash of ns + name (so it fits in an off_t )
30 */ 30 */
31static unsigned int sysfs_name_hash(const char *name, const void *ns) 31static unsigned int kernfs_name_hash(const char *name, const void *ns)
32{ 32{
33 unsigned long hash = init_name_hash(); 33 unsigned long hash = init_name_hash();
34 unsigned int len = strlen(name); 34 unsigned int len = strlen(name);
@@ -44,8 +44,8 @@ static unsigned int sysfs_name_hash(const char *name, const void *ns)
44 return hash; 44 return hash;
45} 45}
46 46
47static int sysfs_name_compare(unsigned int hash, const char *name, 47static int kernfs_name_compare(unsigned int hash, const char *name,
48 const void *ns, const struct kernfs_node *kn) 48 const void *ns, const struct kernfs_node *kn)
49{ 49{
50 if (hash != kn->hash) 50 if (hash != kn->hash)
51 return hash - kn->hash; 51 return hash - kn->hash;
@@ -54,14 +54,14 @@ static int sysfs_name_compare(unsigned int hash, const char *name,
54 return strcmp(name, kn->name); 54 return strcmp(name, kn->name);
55} 55}
56 56
57static int sysfs_sd_compare(const struct kernfs_node *left, 57static int kernfs_sd_compare(const struct kernfs_node *left,
58 const struct kernfs_node *right) 58 const struct kernfs_node *right)
59{ 59{
60 return sysfs_name_compare(left->hash, left->name, left->ns, right); 60 return kernfs_name_compare(left->hash, left->name, left->ns, right);
61} 61}
62 62
63/** 63/**
64 * sysfs_link_sibling - link kernfs_node into sibling rbtree 64 * kernfs_link_sibling - link kernfs_node into sibling rbtree
65 * @kn: kernfs_node of interest 65 * @kn: kernfs_node of interest
66 * 66 *
67 * Link @kn into its sibling rbtree which starts from 67 * Link @kn into its sibling rbtree which starts from
@@ -73,7 +73,7 @@ static int sysfs_sd_compare(const struct kernfs_node *left,
73 * RETURNS: 73 * RETURNS:
74 * 0 on susccess -EEXIST on failure. 74 * 0 on susccess -EEXIST on failure.
75 */ 75 */
76static int sysfs_link_sibling(struct kernfs_node *kn) 76static int kernfs_link_sibling(struct kernfs_node *kn)
77{ 77{
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;
@@ -87,7 +87,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)
87 87
88 pos = rb_to_kn(*node); 88 pos = rb_to_kn(*node);
89 parent = *node; 89 parent = *node;
90 result = sysfs_sd_compare(kn, pos); 90 result = kernfs_sd_compare(kn, pos);
91 if (result < 0) 91 if (result < 0)
92 node = &pos->rb.rb_left; 92 node = &pos->rb.rb_left;
93 else if (result > 0) 93 else if (result > 0)
@@ -102,7 +102,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)
102} 102}
103 103
104/** 104/**
105 * sysfs_unlink_sibling - unlink kernfs_node from sibling rbtree 105 * kernfs_unlink_sibling - unlink kernfs_node from sibling rbtree
106 * @kn: kernfs_node of interest 106 * @kn: kernfs_node of interest
107 * 107 *
108 * Unlink @kn from its sibling rbtree which starts from 108 * Unlink @kn from its sibling rbtree which starts from
@@ -111,7 +111,7 @@ static int sysfs_link_sibling(struct kernfs_node *kn)
111 * Locking: 111 * Locking:
112 * mutex_lock(kernfs_mutex) 112 * mutex_lock(kernfs_mutex)
113 */ 113 */
114static void sysfs_unlink_sibling(struct kernfs_node *kn) 114static void kernfs_unlink_sibling(struct kernfs_node *kn)
115{ 115{
116 if (kernfs_type(kn) == KERNFS_DIR) 116 if (kernfs_type(kn) == KERNFS_DIR)
117 kn->parent->dir.subdirs--; 117 kn->parent->dir.subdirs--;
@@ -120,7 +120,7 @@ static void sysfs_unlink_sibling(struct kernfs_node *kn)
120} 120}
121 121
122/** 122/**
123 * sysfs_get_active - get an active reference to kernfs_node 123 * kernfs_get_active - get an active reference to kernfs_node
124 * @kn: kernfs_node to get an active reference to 124 * @kn: kernfs_node to get an active reference to
125 * 125 *
126 * Get an active reference of @kn. This function is noop if @kn 126 * 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)
129 * RETURNS: 129 * RETURNS:
130 * Pointer to @kn on success, NULL on failure. 130 * Pointer to @kn on success, NULL on failure.
131 */ 131 */
132struct kernfs_node *sysfs_get_active(struct kernfs_node *kn) 132struct kernfs_node *kernfs_get_active(struct kernfs_node *kn)
133{ 133{
134 if (unlikely(!kn)) 134 if (unlikely(!kn))
135 return NULL; 135 return NULL;
@@ -143,13 +143,13 @@ struct kernfs_node *sysfs_get_active(struct kernfs_node *kn)
143} 143}
144 144
145/** 145/**
146 * sysfs_put_active - put an active reference to kernfs_node 146 * kernfs_put_active - put an active reference to kernfs_node
147 * @kn: kernfs_node to put an active reference to 147 * @kn: kernfs_node to put an active reference to
148 * 148 *
149 * Put an active reference to @kn. This function is noop if @kn 149 * Put an active reference to @kn. This function is noop if @kn
150 * is NULL. 150 * is NULL.
151 */ 151 */
152void sysfs_put_active(struct kernfs_node *kn) 152void kernfs_put_active(struct kernfs_node *kn)
153{ 153{
154 int v; 154 int v;
155 155
@@ -170,12 +170,12 @@ void sysfs_put_active(struct kernfs_node *kn)
170} 170}
171 171
172/** 172/**
173 * sysfs_deactivate - deactivate kernfs_node 173 * kernfs_deactivate - deactivate kernfs_node
174 * @kn: kernfs_node to deactivate 174 * @kn: kernfs_node to deactivate
175 * 175 *
176 * Deny new active references and drain existing ones. 176 * Deny new active references and drain existing ones.
177 */ 177 */
178static void sysfs_deactivate(struct kernfs_node *kn) 178static void kernfs_deactivate(struct kernfs_node *kn)
179{ 179{
180 DECLARE_COMPLETION_ONSTACK(wait); 180 DECLARE_COMPLETION_ONSTACK(wait);
181 int v; 181 int v;
@@ -235,9 +235,8 @@ void kernfs_put(struct kernfs_node *kn)
235 */ 235 */
236 parent = kn->parent; 236 parent = kn->parent;
237 237
238 WARN(!(kn->flags & KERNFS_REMOVED), 238 WARN(!(kn->flags & KERNFS_REMOVED), "kernfs: free using entry: %s/%s\n",
239 "sysfs: free using entry: %s/%s\n", 239 parent ? parent->name : "", kn->name);
240 parent ? parent->name : "", kn->name);
241 240
242 if (kernfs_type(kn) == KERNFS_LINK) 241 if (kernfs_type(kn) == KERNFS_LINK)
243 kernfs_put(kn->symlink.target_kn); 242 kernfs_put(kn->symlink.target_kn);
@@ -265,13 +264,13 @@ void kernfs_put(struct kernfs_node *kn)
265} 264}
266EXPORT_SYMBOL_GPL(kernfs_put); 265EXPORT_SYMBOL_GPL(kernfs_put);
267 266
268static int sysfs_dentry_delete(const struct dentry *dentry) 267static int kernfs_dop_delete(const struct dentry *dentry)
269{ 268{
270 struct kernfs_node *kn = dentry->d_fsdata; 269 struct kernfs_node *kn = dentry->d_fsdata;
271 return !(kn && !(kn->flags & KERNFS_REMOVED)); 270 return !(kn && !(kn->flags & KERNFS_REMOVED));
272} 271}
273 272
274static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) 273static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags)
275{ 274{
276 struct kernfs_node *kn; 275 struct kernfs_node *kn;
277 276
@@ -281,19 +280,19 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
281 kn = dentry->d_fsdata; 280 kn = dentry->d_fsdata;
282 mutex_lock(&kernfs_mutex); 281 mutex_lock(&kernfs_mutex);
283 282
284 /* The sysfs dirent has been deleted */ 283 /* The kernfs node has been deleted */
285 if (kn->flags & KERNFS_REMOVED) 284 if (kn->flags & KERNFS_REMOVED)
286 goto out_bad; 285 goto out_bad;
287 286
288 /* The sysfs dirent has been moved? */ 287 /* The kernfs node has been moved? */
289 if (dentry->d_parent->d_fsdata != kn->parent) 288 if (dentry->d_parent->d_fsdata != kn->parent)
290 goto out_bad; 289 goto out_bad;
291 290
292 /* The sysfs dirent has been renamed */ 291 /* The kernfs node has been renamed */
293 if (strcmp(dentry->d_name.name, kn->name) != 0) 292 if (strcmp(dentry->d_name.name, kn->name) != 0)
294 goto out_bad; 293 goto out_bad;
295 294
296 /* The sysfs dirent has been moved to a different namespace */ 295 /* The kernfs node has been moved to a different namespace */
297 if (kn->parent && kernfs_ns_enabled(kn->parent) && 296 if (kn->parent && kernfs_ns_enabled(kn->parent) &&
298 kernfs_info(dentry->d_sb)->ns != kn->ns) 297 kernfs_info(dentry->d_sb)->ns != kn->ns)
299 goto out_bad; 298 goto out_bad;
@@ -302,9 +301,10 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
302out_valid: 301out_valid:
303 return 1; 302 return 1;
304out_bad: 303out_bad:
305 /* Remove the dentry from the dcache hashes. 304 /*
305 * Remove the dentry from the dcache hashes.
306 * If this is a deleted dentry we use d_drop instead of d_delete 306 * If this is a deleted dentry we use d_drop instead of d_delete
307 * so sysfs doesn't need to cope with negative dentries. 307 * so kernfs doesn't need to cope with negative dentries.
308 * 308 *
309 * If this is a dentry that has simply been renamed we 309 * If this is a dentry that has simply been renamed we
310 * use d_drop to remove it from the dcache lookup on its 310 * use d_drop to remove it from the dcache lookup on its
@@ -324,19 +324,19 @@ out_bad:
324 return 0; 324 return 0;
325} 325}
326 326
327static void sysfs_dentry_release(struct dentry *dentry) 327static void kernfs_dop_release(struct dentry *dentry)
328{ 328{
329 kernfs_put(dentry->d_fsdata); 329 kernfs_put(dentry->d_fsdata);
330} 330}
331 331
332const struct dentry_operations kernfs_dops = { 332const struct dentry_operations kernfs_dops = {
333 .d_revalidate = sysfs_dentry_revalidate, 333 .d_revalidate = kernfs_dop_revalidate,
334 .d_delete = sysfs_dentry_delete, 334 .d_delete = kernfs_dop_delete,
335 .d_release = sysfs_dentry_release, 335 .d_release = kernfs_dop_release,
336}; 336};
337 337
338struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, 338struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
339 const char *name, umode_t mode, int type) 339 umode_t mode, int type)
340{ 340{
341 char *dup_name = NULL; 341 char *dup_name = NULL;
342 struct kernfs_node *kn; 342 struct kernfs_node *kn;
@@ -374,7 +374,7 @@ struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,
374} 374}
375 375
376/** 376/**
377 * sysfs_addrm_start - prepare for kernfs_node add/remove 377 * kernfs_addrm_start - prepare for kernfs_node add/remove
378 * @acxt: pointer to kernfs_addrm_cxt to be used 378 * @acxt: pointer to kernfs_addrm_cxt to be used
379 * 379 *
380 * This function is called when the caller is about to add or remove 380 * 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,
385 * Kernel thread context (may sleep). kernfs_mutex is locked on 385 * Kernel thread context (may sleep). kernfs_mutex is locked on
386 * return. 386 * return.
387 */ 387 */
388void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt) 388void kernfs_addrm_start(struct kernfs_addrm_cxt *acxt)
389 __acquires(kernfs_mutex) 389 __acquires(kernfs_mutex)
390{ 390{
391 memset(acxt, 0, sizeof(*acxt)); 391 memset(acxt, 0, sizeof(*acxt));
@@ -394,7 +394,7 @@ void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt)
394} 394}
395 395
396/** 396/**
397 * sysfs_add_one - add kernfs_node to parent without warning 397 * kernfs_add_one - add kernfs_node to parent without warning
398 * @acxt: addrm context to use 398 * @acxt: addrm context to use
399 * @kn: kernfs_node to be added 399 * @kn: kernfs_node to be added
400 * @parent: the parent kernfs_node to add @kn to 400 * @parent: the parent kernfs_node to add @kn to
@@ -404,17 +404,17 @@ void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt)
404 * of the parent. 404 * of the parent.
405 * 405 *
406 * This function should be called between calls to 406 * This function should be called between calls to
407 * sysfs_addrm_start() and sysfs_addrm_finish() and should be 407 * kernfs_addrm_start() and kernfs_addrm_finish() and should be passed
408 * passed the same @acxt as passed to sysfs_addrm_start(). 408 * the same @acxt as passed to kernfs_addrm_start().
409 * 409 *
410 * LOCKING: 410 * LOCKING:
411 * Determined by sysfs_addrm_start(). 411 * Determined by kernfs_addrm_start().
412 * 412 *
413 * RETURNS: 413 * RETURNS:
414 * 0 on success, -EEXIST if entry with the given name already 414 * 0 on success, -EEXIST if entry with the given name already
415 * exists. 415 * exists.
416 */ 416 */
417int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn, 417int kernfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
418 struct kernfs_node *parent) 418 struct kernfs_node *parent)
419{ 419{
420 bool has_ns = kernfs_ns_enabled(parent); 420 bool has_ns = kernfs_ns_enabled(parent);
@@ -422,7 +422,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
422 int ret; 422 int ret;
423 423
424 if (has_ns != (bool)kn->ns) { 424 if (has_ns != (bool)kn->ns) {
425 WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", 425 WARN(1, KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n",
426 has_ns ? "required" : "invalid", parent->name, kn->name); 426 has_ns ? "required" : "invalid", parent->name, kn->name);
427 return -EINVAL; 427 return -EINVAL;
428 } 428 }
@@ -430,11 +430,11 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
430 if (kernfs_type(parent) != KERNFS_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 = kernfs_name_hash(kn->name, kn->ns);
434 kn->parent = parent; 434 kn->parent = parent;
435 kernfs_get(parent); 435 kernfs_get(parent);
436 436
437 ret = sysfs_link_sibling(kn); 437 ret = kernfs_link_sibling(kn);
438 if (ret) 438 if (ret)
439 return ret; 439 return ret;
440 440
@@ -452,7 +452,7 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
452} 452}
453 453
454/** 454/**
455 * sysfs_remove_one - remove kernfs_node from parent 455 * kernfs_remove_one - remove kernfs_node from parent
456 * @acxt: addrm context to use 456 * @acxt: addrm context to use
457 * @kn: kernfs_node to be removed 457 * @kn: kernfs_node to be removed
458 * 458 *
@@ -460,14 +460,14 @@ int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
460 * directory. @kn is unlinked from the children list. 460 * directory. @kn is unlinked from the children list.
461 * 461 *
462 * This function should be called between calls to 462 * This function should be called between calls to
463 * sysfs_addrm_start() and sysfs_addrm_finish() and should be 463 * kernfs_addrm_start() and kernfs_addrm_finish() and should be
464 * passed the same @acxt as passed to sysfs_addrm_start(). 464 * passed the same @acxt as passed to kernfs_addrm_start().
465 * 465 *
466 * LOCKING: 466 * LOCKING:
467 * Determined by sysfs_addrm_start(). 467 * Determined by kernfs_addrm_start().
468 */ 468 */
469static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt, 469static void kernfs_remove_one(struct kernfs_addrm_cxt *acxt,
470 struct kernfs_node *kn) 470 struct kernfs_node *kn)
471{ 471{
472 struct kernfs_iattrs *ps_iattr; 472 struct kernfs_iattrs *ps_iattr;
473 473
@@ -479,7 +479,7 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,
479 return; 479 return;
480 480
481 if (kn->parent) { 481 if (kn->parent) {
482 sysfs_unlink_sibling(kn); 482 kernfs_unlink_sibling(kn);
483 483
484 /* Update timestamps on the parent */ 484 /* Update timestamps on the parent */
485 ps_iattr = kn->parent->iattr; 485 ps_iattr = kn->parent->iattr;
@@ -495,20 +495,20 @@ static void sysfs_remove_one(struct kernfs_addrm_cxt *acxt,
495} 495}
496 496
497/** 497/**
498 * sysfs_addrm_finish - finish up kernfs_node add/remove 498 * kernfs_addrm_finish - finish up kernfs_node add/remove
499 * @acxt: addrm context to finish up 499 * @acxt: addrm context to finish up
500 * 500 *
501 * Finish up kernfs_node add/remove. Resources acquired by 501 * Finish up kernfs_node add/remove. Resources acquired by
502 * sysfs_addrm_start() are released and removed kernfs_nodes are 502 * kernfs_addrm_start() are released and removed kernfs_nodes are
503 * cleaned up. 503 * cleaned up.
504 * 504 *
505 * LOCKING: 505 * LOCKING:
506 * kernfs_mutex is released. 506 * kernfs_mutex is released.
507 */ 507 */
508void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt) 508void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt)
509 __releases(kernfs_mutex) 509 __releases(kernfs_mutex)
510{ 510{
511 /* release resources acquired by sysfs_addrm_start() */ 511 /* release resources acquired by kernfs_addrm_start() */
512 mutex_unlock(&kernfs_mutex); 512 mutex_unlock(&kernfs_mutex);
513 513
514 /* kill removed kernfs_nodes */ 514 /* kill removed kernfs_nodes */
@@ -517,8 +517,8 @@ void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt)
517 517
518 acxt->removed = kn->u.removed_list; 518 acxt->removed = kn->u.removed_list;
519 519
520 sysfs_deactivate(kn); 520 kernfs_deactivate(kn);
521 sysfs_unmap_bin_file(kn); 521 kernfs_unmap_bin_file(kn);
522 kernfs_put(kn); 522 kernfs_put(kn);
523 } 523 }
524} 524}
@@ -543,18 +543,18 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,
543 lockdep_assert_held(&kernfs_mutex); 543 lockdep_assert_held(&kernfs_mutex);
544 544
545 if (has_ns != (bool)ns) { 545 if (has_ns != (bool)ns) {
546 WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", 546 WARN(1, KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n",
547 has_ns ? "required" : "invalid", parent->name, name); 547 has_ns ? "required" : "invalid", parent->name, name);
548 return NULL; 548 return NULL;
549 } 549 }
550 550
551 hash = sysfs_name_hash(name, ns); 551 hash = kernfs_name_hash(name, ns);
552 while (node) { 552 while (node) {
553 struct kernfs_node *kn; 553 struct kernfs_node *kn;
554 int result; 554 int result;
555 555
556 kn = rb_to_kn(node); 556 kn = rb_to_kn(node);
557 result = sysfs_name_compare(hash, name, ns, kn); 557 result = kernfs_name_compare(hash, name, ns, kn);
558 if (result < 0) 558 if (result < 0)
559 node = node->rb_left; 559 node = node->rb_left;
560 else if (result > 0) 560 else if (result > 0)
@@ -607,7 +607,7 @@ 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, KERNFS_DIR); 610 kn = kernfs_new_node(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);
@@ -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, KERNFS_DIR); 657 kn = kernfs_new_node(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
@@ -663,9 +663,9 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
663 kn->priv = priv; 663 kn->priv = priv;
664 664
665 /* link in */ 665 /* link in */
666 sysfs_addrm_start(&acxt); 666 kernfs_addrm_start(&acxt);
667 rc = sysfs_add_one(&acxt, kn, parent); 667 rc = kernfs_add_one(&acxt, kn, parent);
668 sysfs_addrm_finish(&acxt); 668 kernfs_addrm_finish(&acxt);
669 669
670 if (!rc) 670 if (!rc)
671 return kn; 671 return kn;
@@ -674,8 +674,9 @@ struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
674 return ERR_PTR(rc); 674 return ERR_PTR(rc);
675} 675}
676 676
677static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry, 677static struct dentry *kernfs_iop_lookup(struct inode *dir,
678 unsigned int flags) 678 struct dentry *dentry,
679 unsigned int flags)
679{ 680{
680 struct dentry *ret = NULL; 681 struct dentry *ret = NULL;
681 struct kernfs_node *parent = dentry->d_parent->d_fsdata; 682 struct kernfs_node *parent = dentry->d_parent->d_fsdata;
@@ -699,7 +700,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,
699 dentry->d_fsdata = kn; 700 dentry->d_fsdata = kn;
700 701
701 /* attach dentry and inode */ 702 /* attach dentry and inode */
702 inode = sysfs_get_inode(dir->i_sb, kn); 703 inode = kernfs_get_inode(dir->i_sb, kn);
703 if (!inode) { 704 if (!inode) {
704 ret = ERR_PTR(-ENOMEM); 705 ret = ERR_PTR(-ENOMEM);
705 goto out_unlock; 706 goto out_unlock;
@@ -713,17 +714,17 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,
713} 714}
714 715
715const struct inode_operations kernfs_dir_iops = { 716const struct inode_operations kernfs_dir_iops = {
716 .lookup = sysfs_lookup, 717 .lookup = kernfs_iop_lookup,
717 .permission = sysfs_permission, 718 .permission = kernfs_iop_permission,
718 .setattr = sysfs_setattr, 719 .setattr = kernfs_iop_setattr,
719 .getattr = sysfs_getattr, 720 .getattr = kernfs_iop_getattr,
720 .setxattr = sysfs_setxattr, 721 .setxattr = kernfs_iop_setxattr,
721 .removexattr = sysfs_removexattr, 722 .removexattr = kernfs_iop_removexattr,
722 .getxattr = sysfs_getxattr, 723 .getxattr = kernfs_iop_getxattr,
723 .listxattr = sysfs_listxattr, 724 .listxattr = kernfs_iop_listxattr,
724}; 725};
725 726
726static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos) 727static struct kernfs_node *kernfs_leftmost_descendant(struct kernfs_node *pos)
727{ 728{
728 struct kernfs_node *last; 729 struct kernfs_node *last;
729 730
@@ -746,7 +747,7 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos)
746} 747}
747 748
748/** 749/**
749 * sysfs_next_descendant_post - find the next descendant for post-order walk 750 * kernfs_next_descendant_post - find the next descendant for post-order walk
750 * @pos: the current position (%NULL to initiate traversal) 751 * @pos: the current position (%NULL to initiate traversal)
751 * @root: kernfs_node whose descendants to walk 752 * @root: kernfs_node whose descendants to walk
752 * 753 *
@@ -754,8 +755,8 @@ static struct kernfs_node *sysfs_leftmost_descendant(struct kernfs_node *pos)
754 * descendants. @root is included in the iteration and the last node to be 755 * descendants. @root is included in the iteration and the last node to be
755 * visited. 756 * visited.
756 */ 757 */
757static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos, 758static struct kernfs_node *kernfs_next_descendant_post(struct kernfs_node *pos,
758 struct kernfs_node *root) 759 struct kernfs_node *root)
759{ 760{
760 struct rb_node *rbn; 761 struct rb_node *rbn;
761 762
@@ -763,7 +764,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,
763 764
764 /* if first iteration, visit leftmost descendant which may be root */ 765 /* if first iteration, visit leftmost descendant which may be root */
765 if (!pos) 766 if (!pos)
766 return sysfs_leftmost_descendant(root); 767 return kernfs_leftmost_descendant(root);
767 768
768 /* if we visited @root, we're done */ 769 /* if we visited @root, we're done */
769 if (pos == root) 770 if (pos == root)
@@ -772,7 +773,7 @@ static struct kernfs_node *sysfs_next_descendant_post(struct kernfs_node *pos,
772 /* if there's an unvisited sibling, visit its leftmost descendant */ 773 /* if there's an unvisited sibling, visit its leftmost descendant */
773 rbn = rb_next(&pos->rb); 774 rbn = rb_next(&pos->rb);
774 if (rbn) 775 if (rbn)
775 return sysfs_leftmost_descendant(rb_to_kn(rbn)); 776 return kernfs_leftmost_descendant(rb_to_kn(rbn));
776 777
777 /* no sibling left, visit parent */ 778 /* no sibling left, visit parent */
778 return pos->parent; 779 return pos->parent;
@@ -786,14 +787,14 @@ static void __kernfs_remove(struct kernfs_addrm_cxt *acxt,
786 if (!kn) 787 if (!kn)
787 return; 788 return;
788 789
789 pr_debug("sysfs %s: removing\n", kn->name); 790 pr_debug("kernfs %s: removing\n", kn->name);
790 791
791 next = NULL; 792 next = NULL;
792 do { 793 do {
793 pos = next; 794 pos = next;
794 next = sysfs_next_descendant_post(pos, kn); 795 next = kernfs_next_descendant_post(pos, kn);
795 if (pos) 796 if (pos)
796 sysfs_remove_one(acxt, pos); 797 kernfs_remove_one(acxt, pos);
797 } while (next); 798 } while (next);
798} 799}
799 800
@@ -807,9 +808,9 @@ void kernfs_remove(struct kernfs_node *kn)
807{ 808{
808 struct kernfs_addrm_cxt acxt; 809 struct kernfs_addrm_cxt acxt;
809 810
810 sysfs_addrm_start(&acxt); 811 kernfs_addrm_start(&acxt);
811 __kernfs_remove(&acxt, kn); 812 __kernfs_remove(&acxt, kn);
812 sysfs_addrm_finish(&acxt); 813 kernfs_addrm_finish(&acxt);
813} 814}
814 815
815/** 816/**
@@ -828,18 +829,18 @@ int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
828 struct kernfs_node *kn; 829 struct kernfs_node *kn;
829 830
830 if (!parent) { 831 if (!parent) {
831 WARN(1, KERN_WARNING "sysfs: can not remove '%s', no directory\n", 832 WARN(1, KERN_WARNING "kernfs: can not remove '%s', no directory\n",
832 name); 833 name);
833 return -ENOENT; 834 return -ENOENT;
834 } 835 }
835 836
836 sysfs_addrm_start(&acxt); 837 kernfs_addrm_start(&acxt);
837 838
838 kn = kernfs_find_ns(parent, name, ns); 839 kn = kernfs_find_ns(parent, name, ns);
839 if (kn) 840 if (kn)
840 __kernfs_remove(&acxt, kn); 841 __kernfs_remove(&acxt, kn);
841 842
842 sysfs_addrm_finish(&acxt); 843 kernfs_addrm_finish(&acxt);
843 844
844 if (kn) 845 if (kn)
845 return 0; 846 return 0;
@@ -884,13 +885,13 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
884 /* 885 /*
885 * Move to the appropriate place in the appropriate directories rbtree. 886 * Move to the appropriate place in the appropriate directories rbtree.
886 */ 887 */
887 sysfs_unlink_sibling(kn); 888 kernfs_unlink_sibling(kn);
888 kernfs_get(new_parent); 889 kernfs_get(new_parent);
889 kernfs_put(kn->parent); 890 kernfs_put(kn->parent);
890 kn->ns = new_ns; 891 kn->ns = new_ns;
891 kn->hash = sysfs_name_hash(kn->name, kn->ns); 892 kn->hash = kernfs_name_hash(kn->name, kn->ns);
892 kn->parent = new_parent; 893 kn->parent = new_parent;
893 sysfs_link_sibling(kn); 894 kernfs_link_sibling(kn);
894 895
895 error = 0; 896 error = 0;
896 out: 897 out:
@@ -904,13 +905,13 @@ static inline unsigned char dt_type(struct kernfs_node *kn)
904 return (kn->mode >> 12) & 15; 905 return (kn->mode >> 12) & 15;
905} 906}
906 907
907static int sysfs_dir_release(struct inode *inode, struct file *filp) 908static int kernfs_dir_fop_release(struct inode *inode, struct file *filp)
908{ 909{
909 kernfs_put(filp->private_data); 910 kernfs_put(filp->private_data);
910 return 0; 911 return 0;
911} 912}
912 913
913static struct kernfs_node *sysfs_dir_pos(const void *ns, 914static struct kernfs_node *kernfs_dir_pos(const void *ns,
914 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) 915 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos)
915{ 916{
916 if (pos) { 917 if (pos) {
@@ -944,10 +945,10 @@ static struct kernfs_node *sysfs_dir_pos(const void *ns,
944 return pos; 945 return pos;
945} 946}
946 947
947static struct kernfs_node *sysfs_dir_next_pos(const void *ns, 948static struct kernfs_node *kernfs_dir_next_pos(const void *ns,
948 struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos) 949 struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos)
949{ 950{
950 pos = sysfs_dir_pos(ns, parent, ino, pos); 951 pos = kernfs_dir_pos(ns, parent, ino, pos);
951 if (pos) 952 if (pos)
952 do { 953 do {
953 struct rb_node *node = rb_next(&pos->rb); 954 struct rb_node *node = rb_next(&pos->rb);
@@ -959,7 +960,7 @@ static struct kernfs_node *sysfs_dir_next_pos(const void *ns,
959 return pos; 960 return pos;
960} 961}
961 962
962static int sysfs_readdir(struct file *file, struct dir_context *ctx) 963static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)
963{ 964{
964 struct dentry *dentry = file->f_path.dentry; 965 struct dentry *dentry = file->f_path.dentry;
965 struct kernfs_node *parent = dentry->d_fsdata; 966 struct kernfs_node *parent = dentry->d_fsdata;
@@ -973,9 +974,9 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)
973 if (kernfs_ns_enabled(parent)) 974 if (kernfs_ns_enabled(parent))
974 ns = kernfs_info(dentry->d_sb)->ns; 975 ns = kernfs_info(dentry->d_sb)->ns;
975 976
976 for (pos = sysfs_dir_pos(ns, parent, ctx->pos, pos); 977 for (pos = kernfs_dir_pos(ns, parent, ctx->pos, pos);
977 pos; 978 pos;
978 pos = sysfs_dir_next_pos(ns, parent, ctx->pos, pos)) { 979 pos = kernfs_dir_next_pos(ns, parent, ctx->pos, pos)) {
979 const char *name = pos->name; 980 const char *name = pos->name;
980 unsigned int type = dt_type(pos); 981 unsigned int type = dt_type(pos);
981 int len = strlen(name); 982 int len = strlen(name);
@@ -996,7 +997,8 @@ static int sysfs_readdir(struct file *file, struct dir_context *ctx)
996 return 0; 997 return 0;
997} 998}
998 999
999static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence) 1000static loff_t kernfs_dir_fop_llseek(struct file *file, loff_t offset,
1001 int whence)
1000{ 1002{
1001 struct inode *inode = file_inode(file); 1003 struct inode *inode = file_inode(file);
1002 loff_t ret; 1004 loff_t ret;
@@ -1010,7 +1012,7 @@ static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence)
1010 1012
1011const struct file_operations kernfs_dir_fops = { 1013const struct file_operations kernfs_dir_fops = {
1012 .read = generic_read_dir, 1014 .read = generic_read_dir,
1013 .iterate = sysfs_readdir, 1015 .iterate = kernfs_fop_readdir,
1014 .release = sysfs_dir_release, 1016 .release = kernfs_dir_fop_release,
1015 .llseek = sysfs_dir_llseek, 1017 .llseek = kernfs_dir_fop_llseek,
1016}; 1018};
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 32364ddb24de..053cfd9a6a40 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -64,7 +64,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
64 * the ops aren't called concurrently for the same open file. 64 * the ops aren't called concurrently for the same open file.
65 */ 65 */
66 mutex_lock(&of->mutex); 66 mutex_lock(&of->mutex);
67 if (!sysfs_get_active(of->kn)) 67 if (!kernfs_get_active(of->kn))
68 return ERR_PTR(-ENODEV); 68 return ERR_PTR(-ENODEV);
69 69
70 ops = kernfs_ops(of->kn); 70 ops = kernfs_ops(of->kn);
@@ -104,7 +104,7 @@ static void kernfs_seq_stop(struct seq_file *sf, void *v)
104 if (ops->seq_stop) 104 if (ops->seq_stop)
105 ops->seq_stop(sf, v); 105 ops->seq_stop(sf, v);
106 106
107 sysfs_put_active(of->kn); 107 kernfs_put_active(of->kn);
108 mutex_unlock(&of->mutex); 108 mutex_unlock(&of->mutex);
109} 109}
110 110
@@ -147,7 +147,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
147 * the ops aren't called concurrently for the same open file. 147 * the ops aren't called concurrently for the same open file.
148 */ 148 */
149 mutex_lock(&of->mutex); 149 mutex_lock(&of->mutex);
150 if (!sysfs_get_active(of->kn)) { 150 if (!kernfs_get_active(of->kn)) {
151 len = -ENODEV; 151 len = -ENODEV;
152 mutex_unlock(&of->mutex); 152 mutex_unlock(&of->mutex);
153 goto out_free; 153 goto out_free;
@@ -159,7 +159,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
159 else 159 else
160 len = -EINVAL; 160 len = -EINVAL;
161 161
162 sysfs_put_active(of->kn); 162 kernfs_put_active(of->kn);
163 mutex_unlock(&of->mutex); 163 mutex_unlock(&of->mutex);
164 164
165 if (len < 0) 165 if (len < 0)
@@ -178,14 +178,14 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
178} 178}
179 179
180/** 180/**
181 * kernfs_file_read - kernfs vfs read callback 181 * kernfs_fop_read - kernfs vfs read callback
182 * @file: file pointer 182 * @file: file pointer
183 * @user_buf: data to write 183 * @user_buf: data to write
184 * @count: number of bytes 184 * @count: number of bytes
185 * @ppos: starting offset 185 * @ppos: starting offset
186 */ 186 */
187static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, 187static ssize_t kernfs_fop_read(struct file *file, char __user *user_buf,
188 size_t count, loff_t *ppos) 188 size_t count, loff_t *ppos)
189{ 189{
190 struct kernfs_open_file *of = kernfs_of(file); 190 struct kernfs_open_file *of = kernfs_of(file);
191 191
@@ -196,7 +196,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
196} 196}
197 197
198/** 198/**
199 * kernfs_file_write - kernfs vfs write callback 199 * kernfs_fop_write - kernfs vfs write callback
200 * @file: file pointer 200 * @file: file pointer
201 * @user_buf: data to write 201 * @user_buf: data to write
202 * @count: number of bytes 202 * @count: number of bytes
@@ -211,8 +211,8 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
211 * modify only the the value you're changing, then write entire buffer 211 * modify only the the value you're changing, then write entire buffer
212 * back. 212 * back.
213 */ 213 */
214static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf, 214static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
215 size_t count, loff_t *ppos) 215 size_t count, loff_t *ppos)
216{ 216{
217 struct kernfs_open_file *of = kernfs_of(file); 217 struct kernfs_open_file *of = kernfs_of(file);
218 ssize_t len = min_t(size_t, count, PAGE_SIZE); 218 ssize_t len = min_t(size_t, count, PAGE_SIZE);
@@ -234,7 +234,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf,
234 * the ops aren't called concurrently for the same open file. 234 * the ops aren't called concurrently for the same open file.
235 */ 235 */
236 mutex_lock(&of->mutex); 236 mutex_lock(&of->mutex);
237 if (!sysfs_get_active(of->kn)) { 237 if (!kernfs_get_active(of->kn)) {
238 mutex_unlock(&of->mutex); 238 mutex_unlock(&of->mutex);
239 len = -ENODEV; 239 len = -ENODEV;
240 goto out_free; 240 goto out_free;
@@ -246,7 +246,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf,
246 else 246 else
247 len = -EINVAL; 247 len = -EINVAL;
248 248
249 sysfs_put_active(of->kn); 249 kernfs_put_active(of->kn);
250 mutex_unlock(&of->mutex); 250 mutex_unlock(&of->mutex);
251 251
252 if (len > 0) 252 if (len > 0)
@@ -264,13 +264,13 @@ static void kernfs_vma_open(struct vm_area_struct *vma)
264 if (!of->vm_ops) 264 if (!of->vm_ops)
265 return; 265 return;
266 266
267 if (!sysfs_get_active(of->kn)) 267 if (!kernfs_get_active(of->kn))
268 return; 268 return;
269 269
270 if (of->vm_ops->open) 270 if (of->vm_ops->open)
271 of->vm_ops->open(vma); 271 of->vm_ops->open(vma);
272 272
273 sysfs_put_active(of->kn); 273 kernfs_put_active(of->kn);
274} 274}
275 275
276static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 276static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
@@ -282,14 +282,14 @@ static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
282 if (!of->vm_ops) 282 if (!of->vm_ops)
283 return VM_FAULT_SIGBUS; 283 return VM_FAULT_SIGBUS;
284 284
285 if (!sysfs_get_active(of->kn)) 285 if (!kernfs_get_active(of->kn))
286 return VM_FAULT_SIGBUS; 286 return VM_FAULT_SIGBUS;
287 287
288 ret = VM_FAULT_SIGBUS; 288 ret = VM_FAULT_SIGBUS;
289 if (of->vm_ops->fault) 289 if (of->vm_ops->fault)
290 ret = of->vm_ops->fault(vma, vmf); 290 ret = of->vm_ops->fault(vma, vmf);
291 291
292 sysfs_put_active(of->kn); 292 kernfs_put_active(of->kn);
293 return ret; 293 return ret;
294} 294}
295 295
@@ -303,7 +303,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
303 if (!of->vm_ops) 303 if (!of->vm_ops)
304 return VM_FAULT_SIGBUS; 304 return VM_FAULT_SIGBUS;
305 305
306 if (!sysfs_get_active(of->kn)) 306 if (!kernfs_get_active(of->kn))
307 return VM_FAULT_SIGBUS; 307 return VM_FAULT_SIGBUS;
308 308
309 ret = 0; 309 ret = 0;
@@ -312,7 +312,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
312 else 312 else
313 file_update_time(file); 313 file_update_time(file);
314 314
315 sysfs_put_active(of->kn); 315 kernfs_put_active(of->kn);
316 return ret; 316 return ret;
317} 317}
318 318
@@ -326,14 +326,14 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
326 if (!of->vm_ops) 326 if (!of->vm_ops)
327 return -EINVAL; 327 return -EINVAL;
328 328
329 if (!sysfs_get_active(of->kn)) 329 if (!kernfs_get_active(of->kn))
330 return -EINVAL; 330 return -EINVAL;
331 331
332 ret = -EINVAL; 332 ret = -EINVAL;
333 if (of->vm_ops->access) 333 if (of->vm_ops->access)
334 ret = of->vm_ops->access(vma, addr, buf, len, write); 334 ret = of->vm_ops->access(vma, addr, buf, len, write);
335 335
336 sysfs_put_active(of->kn); 336 kernfs_put_active(of->kn);
337 return ret; 337 return ret;
338} 338}
339 339
@@ -348,14 +348,14 @@ static int kernfs_vma_set_policy(struct vm_area_struct *vma,
348 if (!of->vm_ops) 348 if (!of->vm_ops)
349 return 0; 349 return 0;
350 350
351 if (!sysfs_get_active(of->kn)) 351 if (!kernfs_get_active(of->kn))
352 return -EINVAL; 352 return -EINVAL;
353 353
354 ret = 0; 354 ret = 0;
355 if (of->vm_ops->set_policy) 355 if (of->vm_ops->set_policy)
356 ret = of->vm_ops->set_policy(vma, new); 356 ret = of->vm_ops->set_policy(vma, new);
357 357
358 sysfs_put_active(of->kn); 358 kernfs_put_active(of->kn);
359 return ret; 359 return ret;
360} 360}
361 361
@@ -369,14 +369,14 @@ static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma,
369 if (!of->vm_ops) 369 if (!of->vm_ops)
370 return vma->vm_policy; 370 return vma->vm_policy;
371 371
372 if (!sysfs_get_active(of->kn)) 372 if (!kernfs_get_active(of->kn))
373 return vma->vm_policy; 373 return vma->vm_policy;
374 374
375 pol = vma->vm_policy; 375 pol = vma->vm_policy;
376 if (of->vm_ops->get_policy) 376 if (of->vm_ops->get_policy)
377 pol = of->vm_ops->get_policy(vma, addr); 377 pol = of->vm_ops->get_policy(vma, addr);
378 378
379 sysfs_put_active(of->kn); 379 kernfs_put_active(of->kn);
380 return pol; 380 return pol;
381} 381}
382 382
@@ -391,14 +391,14 @@ static int kernfs_vma_migrate(struct vm_area_struct *vma,
391 if (!of->vm_ops) 391 if (!of->vm_ops)
392 return 0; 392 return 0;
393 393
394 if (!sysfs_get_active(of->kn)) 394 if (!kernfs_get_active(of->kn))
395 return 0; 395 return 0;
396 396
397 ret = 0; 397 ret = 0;
398 if (of->vm_ops->migrate) 398 if (of->vm_ops->migrate)
399 ret = of->vm_ops->migrate(vma, from, to, flags); 399 ret = of->vm_ops->migrate(vma, from, to, flags);
400 400
401 sysfs_put_active(of->kn); 401 kernfs_put_active(of->kn);
402 return ret; 402 return ret;
403} 403}
404#endif 404#endif
@@ -415,7 +415,7 @@ static const struct vm_operations_struct kernfs_vm_ops = {
415#endif 415#endif
416}; 416};
417 417
418static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) 418static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
419{ 419{
420 struct kernfs_open_file *of = kernfs_of(file); 420 struct kernfs_open_file *of = kernfs_of(file);
421 const struct kernfs_ops *ops; 421 const struct kernfs_ops *ops;
@@ -434,7 +434,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
434 mutex_lock(&of->mutex); 434 mutex_lock(&of->mutex);
435 435
436 rc = -ENODEV; 436 rc = -ENODEV;
437 if (!sysfs_get_active(of->kn)) 437 if (!kernfs_get_active(of->kn))
438 goto out_unlock; 438 goto out_unlock;
439 439
440 ops = kernfs_ops(of->kn); 440 ops = kernfs_ops(of->kn);
@@ -465,7 +465,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
465 of->vm_ops = vma->vm_ops; 465 of->vm_ops = vma->vm_ops;
466 vma->vm_ops = &kernfs_vm_ops; 466 vma->vm_ops = &kernfs_vm_ops;
467out_put: 467out_put:
468 sysfs_put_active(of->kn); 468 kernfs_put_active(of->kn);
469out_unlock: 469out_unlock:
470 mutex_unlock(&of->mutex); 470 mutex_unlock(&of->mutex);
471 471
@@ -473,7 +473,7 @@ out_unlock:
473} 473}
474 474
475/** 475/**
476 * sysfs_get_open_dirent - get or create kernfs_open_node 476 * kernfs_get_open_node - get or create kernfs_open_node
477 * @kn: target kernfs_node 477 * @kn: target kernfs_node
478 * @of: kernfs_open_file for this instance of open 478 * @of: kernfs_open_file for this instance of open
479 * 479 *
@@ -486,8 +486,8 @@ out_unlock:
486 * RETURNS: 486 * RETURNS:
487 * 0 on success, -errno on failure. 487 * 0 on success, -errno on failure.
488 */ 488 */
489static int sysfs_get_open_dirent(struct kernfs_node *kn, 489static int kernfs_get_open_node(struct kernfs_node *kn,
490 struct kernfs_open_file *of) 490 struct kernfs_open_file *of)
491{ 491{
492 struct kernfs_open_node *on, *new_on = NULL; 492 struct kernfs_open_node *on, *new_on = NULL;
493 493
@@ -527,7 +527,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
527} 527}
528 528
529/** 529/**
530 * sysfs_put_open_dirent - put kernfs_open_node 530 * kernfs_put_open_node - put kernfs_open_node
531 * @kn: target kernfs_nodet 531 * @kn: target kernfs_nodet
532 * @of: associated kernfs_open_file 532 * @of: associated kernfs_open_file
533 * 533 *
@@ -537,8 +537,8 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
537 * LOCKING: 537 * LOCKING:
538 * None. 538 * None.
539 */ 539 */
540static void sysfs_put_open_dirent(struct kernfs_node *kn, 540static void kernfs_put_open_node(struct kernfs_node *kn,
541 struct kernfs_open_file *of) 541 struct kernfs_open_file *of)
542{ 542{
543 struct kernfs_open_node *on = kn->attr.open; 543 struct kernfs_open_node *on = kn->attr.open;
544 unsigned long flags; 544 unsigned long flags;
@@ -560,7 +560,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn,
560 kfree(on); 560 kfree(on);
561} 561}
562 562
563static int kernfs_file_open(struct inode *inode, struct file *file) 563static int kernfs_fop_open(struct inode *inode, struct file *file)
564{ 564{
565 struct kernfs_node *kn = file->f_path.dentry->d_fsdata; 565 struct kernfs_node *kn = file->f_path.dentry->d_fsdata;
566 const struct kernfs_ops *ops; 566 const struct kernfs_ops *ops;
@@ -568,7 +568,7 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
568 bool has_read, has_write, has_mmap; 568 bool has_read, has_write, has_mmap;
569 int error = -EACCES; 569 int error = -EACCES;
570 570
571 if (!sysfs_get_active(kn)) 571 if (!kernfs_get_active(kn))
572 return -ENODEV; 572 return -ENODEV;
573 573
574 ops = kernfs_ops(kn); 574 ops = kernfs_ops(kn);
@@ -633,13 +633,13 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
633 if (file->f_mode & FMODE_WRITE) 633 if (file->f_mode & FMODE_WRITE)
634 file->f_mode |= FMODE_PWRITE; 634 file->f_mode |= FMODE_PWRITE;
635 635
636 /* make sure we have open dirent struct */ 636 /* make sure we have open node struct */
637 error = sysfs_get_open_dirent(kn, of); 637 error = kernfs_get_open_node(kn, of);
638 if (error) 638 if (error)
639 goto err_close; 639 goto err_close;
640 640
641 /* open succeeded, put active references */ 641 /* open succeeded, put active references */
642 sysfs_put_active(kn); 642 kernfs_put_active(kn);
643 return 0; 643 return 0;
644 644
645err_close: 645err_close:
@@ -647,23 +647,23 @@ err_close:
647err_free: 647err_free:
648 kfree(of); 648 kfree(of);
649err_out: 649err_out:
650 sysfs_put_active(kn); 650 kernfs_put_active(kn);
651 return error; 651 return error;
652} 652}
653 653
654static int kernfs_file_release(struct inode *inode, struct file *filp) 654static int kernfs_fop_release(struct inode *inode, struct file *filp)
655{ 655{
656 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; 656 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
657 struct kernfs_open_file *of = kernfs_of(filp); 657 struct kernfs_open_file *of = kernfs_of(filp);
658 658
659 sysfs_put_open_dirent(kn, of); 659 kernfs_put_open_node(kn, of);
660 seq_release(inode, filp); 660 seq_release(inode, filp);
661 kfree(of); 661 kfree(of);
662 662
663 return 0; 663 return 0;
664} 664}
665 665
666void sysfs_unmap_bin_file(struct kernfs_node *kn) 666void kernfs_unmap_bin_file(struct kernfs_node *kn)
667{ 667{
668 struct kernfs_open_node *on; 668 struct kernfs_open_node *on;
669 struct kernfs_open_file *of; 669 struct kernfs_open_file *of;
@@ -686,10 +686,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
686 } 686 }
687 mutex_unlock(&kernfs_open_file_mutex); 687 mutex_unlock(&kernfs_open_file_mutex);
688 688
689 sysfs_put_open_dirent(kn, NULL); 689 kernfs_put_open_node(kn, NULL);
690} 690}
691 691
692/* Sysfs attribute files are pollable. The idea is that you read 692/*
693 * Kernfs attribute files are pollable. The idea is that you read
693 * the content and then you use 'poll' or 'select' to wait for 694 * the content and then you use 'poll' or 'select' to wait for
694 * the content to change. When the content changes (assuming the 695 * the content to change. When the content changes (assuming the
695 * manager for the kobject supports notification), poll will 696 * manager for the kobject supports notification), poll will
@@ -702,19 +703,19 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
702 * to see if it supports poll (Neither 'poll' nor 'select' return 703 * to see if it supports poll (Neither 'poll' nor 'select' return
703 * an appropriate error code). When in doubt, set a suitable timeout value. 704 * an appropriate error code). When in doubt, set a suitable timeout value.
704 */ 705 */
705static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait) 706static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
706{ 707{
707 struct kernfs_open_file *of = kernfs_of(filp); 708 struct kernfs_open_file *of = kernfs_of(filp);
708 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; 709 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
709 struct kernfs_open_node *on = kn->attr.open; 710 struct kernfs_open_node *on = kn->attr.open;
710 711
711 /* need parent for the kobj, grab both */ 712 /* need parent for the kobj, grab both */
712 if (!sysfs_get_active(kn)) 713 if (!kernfs_get_active(kn))
713 goto trigger; 714 goto trigger;
714 715
715 poll_wait(filp, &on->poll, wait); 716 poll_wait(filp, &on->poll, wait);
716 717
717 sysfs_put_active(kn); 718 kernfs_put_active(kn);
718 719
719 if (of->event != atomic_read(&on->event)) 720 if (of->event != atomic_read(&on->event))
720 goto trigger; 721 goto trigger;
@@ -751,13 +752,13 @@ void kernfs_notify(struct kernfs_node *kn)
751EXPORT_SYMBOL_GPL(kernfs_notify); 752EXPORT_SYMBOL_GPL(kernfs_notify);
752 753
753const struct file_operations kernfs_file_fops = { 754const struct file_operations kernfs_file_fops = {
754 .read = kernfs_file_read, 755 .read = kernfs_fop_read,
755 .write = kernfs_file_write, 756 .write = kernfs_fop_write,
756 .llseek = generic_file_llseek, 757 .llseek = generic_file_llseek,
757 .mmap = kernfs_file_mmap, 758 .mmap = kernfs_fop_mmap,
758 .open = kernfs_file_open, 759 .open = kernfs_fop_open,
759 .release = kernfs_file_release, 760 .release = kernfs_fop_release,
760 .poll = kernfs_file_poll, 761 .poll = kernfs_fop_poll,
761}; 762};
762 763
763/** 764/**
@@ -784,8 +785,8 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
784 struct kernfs_node *kn; 785 struct kernfs_node *kn;
785 int rc; 786 int rc;
786 787
787 kn = sysfs_new_dirent(kernfs_root(parent), name, 788 kn = kernfs_new_node(kernfs_root(parent), name,
788 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE); 789 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE);
789 if (!kn) 790 if (!kn)
790 return ERR_PTR(-ENOMEM); 791 return ERR_PTR(-ENOMEM);
791 792
@@ -811,9 +812,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
811 if (ops->mmap) 812 if (ops->mmap)
812 kn->flags |= KERNFS_HAS_MMAP; 813 kn->flags |= KERNFS_HAS_MMAP;
813 814
814 sysfs_addrm_start(&acxt); 815 kernfs_addrm_start(&acxt);
815 rc = sysfs_add_one(&acxt, kn, parent); 816 rc = kernfs_add_one(&acxt, kn, parent);
816 sysfs_addrm_finish(&acxt); 817 kernfs_addrm_finish(&acxt);
817 818
818 if (rc) { 819 if (rc) {
819 kernfs_put(kn); 820 kernfs_put(kn);
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index c5f231e8d36d..e55126f85bd2 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -31,16 +31,16 @@ static struct backing_dev_info kernfs_bdi = {
31}; 31};
32 32
33static const struct inode_operations kernfs_iops = { 33static const struct inode_operations kernfs_iops = {
34 .permission = sysfs_permission, 34 .permission = kernfs_iop_permission,
35 .setattr = sysfs_setattr, 35 .setattr = kernfs_iop_setattr,
36 .getattr = sysfs_getattr, 36 .getattr = kernfs_iop_getattr,
37 .setxattr = sysfs_setxattr, 37 .setxattr = kernfs_iop_setxattr,
38 .removexattr = sysfs_removexattr, 38 .removexattr = kernfs_iop_removexattr,
39 .getxattr = sysfs_getxattr, 39 .getxattr = kernfs_iop_getxattr,
40 .listxattr = sysfs_listxattr, 40 .listxattr = kernfs_iop_listxattr,
41}; 41};
42 42
43void __init sysfs_inode_init(void) 43void __init kernfs_inode_init(void)
44{ 44{
45 if (bdi_init(&kernfs_bdi)) 45 if (bdi_init(&kernfs_bdi))
46 panic("failed to init kernfs_bdi"); 46 panic("failed to init kernfs_bdi");
@@ -115,7 +115,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
115 return ret; 115 return ret;
116} 116}
117 117
118int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) 118int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
119{ 119{
120 struct inode *inode = dentry->d_inode; 120 struct inode *inode = dentry->d_inode;
121 struct kernfs_node *kn = dentry->d_fsdata; 121 struct kernfs_node *kn = dentry->d_fsdata;
@@ -141,8 +141,8 @@ out:
141 return error; 141 return error;
142} 142}
143 143
144static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata, 144static int kernfs_node_setsecdata(struct kernfs_node *kn, void **secdata,
145 u32 *secdata_len) 145 u32 *secdata_len)
146{ 146{
147 struct kernfs_iattrs *attrs; 147 struct kernfs_iattrs *attrs;
148 void *old_secdata; 148 void *old_secdata;
@@ -163,8 +163,8 @@ static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata,
163 return 0; 163 return 0;
164} 164}
165 165
166int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, 166int kernfs_iop_setxattr(struct dentry *dentry, const char *name,
167 size_t size, int flags) 167 const void *value, size_t size, int flags)
168{ 168{
169 struct kernfs_node *kn = dentry->d_fsdata; 169 struct kernfs_node *kn = dentry->d_fsdata;
170 struct kernfs_iattrs *attrs; 170 struct kernfs_iattrs *attrs;
@@ -188,7 +188,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
188 return error; 188 return error;
189 189
190 mutex_lock(&kernfs_mutex); 190 mutex_lock(&kernfs_mutex);
191 error = sysfs_sd_setsecdata(kn, &secdata, &secdata_len); 191 error = kernfs_node_setsecdata(kn, &secdata, &secdata_len);
192 mutex_unlock(&kernfs_mutex); 192 mutex_unlock(&kernfs_mutex);
193 193
194 if (secdata) 194 if (secdata)
@@ -202,7 +202,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
202 return -EINVAL; 202 return -EINVAL;
203} 203}
204 204
205int sysfs_removexattr(struct dentry *dentry, const char *name) 205int kernfs_iop_removexattr(struct dentry *dentry, const char *name)
206{ 206{
207 struct kernfs_node *kn = dentry->d_fsdata; 207 struct kernfs_node *kn = dentry->d_fsdata;
208 struct kernfs_iattrs *attrs; 208 struct kernfs_iattrs *attrs;
@@ -214,8 +214,8 @@ int sysfs_removexattr(struct dentry *dentry, const char *name)
214 return simple_xattr_remove(&attrs->xattrs, name); 214 return simple_xattr_remove(&attrs->xattrs, name);
215} 215}
216 216
217ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, 217ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
218 size_t size) 218 size_t size)
219{ 219{
220 struct kernfs_node *kn = dentry->d_fsdata; 220 struct kernfs_node *kn = dentry->d_fsdata;
221 struct kernfs_iattrs *attrs; 221 struct kernfs_iattrs *attrs;
@@ -227,7 +227,7 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
227 return simple_xattr_get(&attrs->xattrs, name, buf, size); 227 return simple_xattr_get(&attrs->xattrs, name, buf, size);
228} 228}
229 229
230ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size) 230ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
231{ 231{
232 struct kernfs_node *kn = dentry->d_fsdata; 232 struct kernfs_node *kn = dentry->d_fsdata;
233 struct kernfs_iattrs *attrs; 233 struct kernfs_iattrs *attrs;
@@ -254,7 +254,7 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)
254 inode->i_ctime = iattr->ia_ctime; 254 inode->i_ctime = iattr->ia_ctime;
255} 255}
256 256
257static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) 257static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
258{ 258{
259 struct kernfs_iattrs *attrs = kn->iattr; 259 struct kernfs_iattrs *attrs = kn->iattr;
260 260
@@ -273,21 +273,21 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
273 set_nlink(inode, kn->dir.subdirs + 2); 273 set_nlink(inode, kn->dir.subdirs + 2);
274} 274}
275 275
276int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, 276int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
277 struct kstat *stat) 277 struct kstat *stat)
278{ 278{
279 struct kernfs_node *kn = dentry->d_fsdata; 279 struct kernfs_node *kn = dentry->d_fsdata;
280 struct inode *inode = dentry->d_inode; 280 struct inode *inode = dentry->d_inode;
281 281
282 mutex_lock(&kernfs_mutex); 282 mutex_lock(&kernfs_mutex);
283 sysfs_refresh_inode(kn, inode); 283 kernfs_refresh_inode(kn, inode);
284 mutex_unlock(&kernfs_mutex); 284 mutex_unlock(&kernfs_mutex);
285 285
286 generic_fillattr(inode, stat); 286 generic_fillattr(inode, stat);
287 return 0; 287 return 0;
288} 288}
289 289
290static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) 290static void kernfs_init_inode(struct kernfs_node *kn, struct inode *inode)
291{ 291{
292 kernfs_get(kn); 292 kernfs_get(kn);
293 inode->i_private = kn; 293 inode->i_private = kn;
@@ -296,7 +296,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
296 inode->i_op = &kernfs_iops; 296 inode->i_op = &kernfs_iops;
297 297
298 set_default_inode_attr(inode, kn->mode); 298 set_default_inode_attr(inode, kn->mode);
299 sysfs_refresh_inode(kn, inode); 299 kernfs_refresh_inode(kn, inode);
300 300
301 /* initialize inode according to type */ 301 /* initialize inode according to type */
302 switch (kernfs_type(kn)) { 302 switch (kernfs_type(kn)) {
@@ -319,7 +319,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
319} 319}
320 320
321/** 321/**
322 * sysfs_get_inode - get inode for kernfs_node 322 * kernfs_get_inode - get inode for kernfs_node
323 * @sb: super block 323 * @sb: super block
324 * @kn: kernfs_node to allocate inode for 324 * @kn: kernfs_node to allocate inode for
325 * 325 *
@@ -333,25 +333,25 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
333 * RETURNS: 333 * RETURNS:
334 * Pointer to allocated inode on success, NULL on failure. 334 * Pointer to allocated inode on success, NULL on failure.
335 */ 335 */
336struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn) 336struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
337{ 337{
338 struct inode *inode; 338 struct inode *inode;
339 339
340 inode = iget_locked(sb, kn->ino); 340 inode = iget_locked(sb, kn->ino);
341 if (inode && (inode->i_state & I_NEW)) 341 if (inode && (inode->i_state & I_NEW))
342 sysfs_init_inode(kn, inode); 342 kernfs_init_inode(kn, inode);
343 343
344 return inode; 344 return inode;
345} 345}
346 346
347/* 347/*
348 * The kernfs_node serves as both an inode and a directory entry for sysfs. 348 * The kernfs_node serves as both an inode and a directory entry for
349 * To prevent the sysfs inode numbers from being freed prematurely we take 349 * kernfs. To prevent the kernfs inode numbers from being freed
350 * a reference to kernfs_node from the sysfs inode. A 350 * prematurely we take a reference to kernfs_node from the kernfs inode. A
351 * super_operations.evict_inode() implementation is needed to drop that 351 * super_operations.evict_inode() implementation is needed to drop that
352 * reference upon inode destruction. 352 * reference upon inode destruction.
353 */ 353 */
354void sysfs_evict_inode(struct inode *inode) 354void kernfs_evict_inode(struct inode *inode)
355{ 355{
356 struct kernfs_node *kn = inode->i_private; 356 struct kernfs_node *kn = inode->i_private;
357 357
@@ -360,7 +360,7 @@ void sysfs_evict_inode(struct inode *inode)
360 kernfs_put(kn); 360 kernfs_put(kn);
361} 361}
362 362
363int sysfs_permission(struct inode *inode, int mask) 363int kernfs_iop_permission(struct inode *inode, int mask)
364{ 364{
365 struct kernfs_node *kn; 365 struct kernfs_node *kn;
366 366
@@ -370,7 +370,7 @@ int sysfs_permission(struct inode *inode, int mask)
370 kn = inode->i_private; 370 kn = inode->i_private;
371 371
372 mutex_lock(&kernfs_mutex); 372 mutex_lock(&kernfs_mutex);
373 sysfs_refresh_inode(kn, inode); 373 kernfs_refresh_inode(kn, inode);
374 mutex_unlock(&kernfs_mutex); 374 mutex_unlock(&kernfs_mutex);
375 375
376 return generic_permission(inode, mask); 376 return generic_permission(inode, mask);
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index e62e8ec15d65..a4ff491fd59c 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -76,19 +76,19 @@ extern struct kmem_cache *kernfs_node_cache;
76/* 76/*
77 * inode.c 77 * inode.c
78 */ 78 */
79struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn); 79struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
80void sysfs_evict_inode(struct inode *inode); 80void kernfs_evict_inode(struct inode *inode);
81int sysfs_permission(struct inode *inode, int mask); 81int kernfs_iop_permission(struct inode *inode, int mask);
82int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); 82int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
83int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, 83int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
84 struct kstat *stat); 84 struct kstat *stat);
85int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, 85int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
86 size_t size, int flags); 86 size_t size, int flags);
87int sysfs_removexattr(struct dentry *dentry, const char *name); 87int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
88ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, 88ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
89 size_t size); 89 size_t size);
90ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size); 90ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
91void sysfs_inode_init(void); 91void kernfs_inode_init(void);
92 92
93/* 93/*
94 * dir.c 94 * dir.c
@@ -98,21 +98,21 @@ extern const struct dentry_operations kernfs_dops;
98extern const struct file_operations kernfs_dir_fops; 98extern const struct file_operations kernfs_dir_fops;
99extern const struct inode_operations kernfs_dir_iops; 99extern const struct inode_operations kernfs_dir_iops;
100 100
101struct kernfs_node *sysfs_get_active(struct kernfs_node *kn); 101struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
102void sysfs_put_active(struct kernfs_node *kn); 102void kernfs_put_active(struct kernfs_node *kn);
103void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt); 103void kernfs_addrm_start(struct kernfs_addrm_cxt *acxt);
104int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn, 104int kernfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
105 struct kernfs_node *parent); 105 struct kernfs_node *parent);
106void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt); 106void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt);
107struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, 107struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
108 const char *name, umode_t mode, int type); 108 umode_t mode, int type);
109 109
110/* 110/*
111 * file.c 111 * file.c
112 */ 112 */
113extern const struct file_operations kernfs_file_fops; 113extern const struct file_operations kernfs_file_fops;
114 114
115void sysfs_unmap_bin_file(struct kernfs_node *kn); 115void kernfs_unmap_bin_file(struct kernfs_node *kn);
116 116
117/* 117/*
118 * symlink.c 118 * symlink.c
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 27d967ba0bb9..0d6ce895a9ee 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -22,10 +22,10 @@ struct kmem_cache *kernfs_node_cache;
22static const struct super_operations kernfs_sops = { 22static const struct super_operations kernfs_sops = {
23 .statfs = simple_statfs, 23 .statfs = simple_statfs,
24 .drop_inode = generic_delete_inode, 24 .drop_inode = generic_delete_inode,
25 .evict_inode = sysfs_evict_inode, 25 .evict_inode = kernfs_evict_inode,
26}; 26};
27 27
28static int sysfs_fill_super(struct super_block *sb) 28static int kernfs_fill_super(struct super_block *sb)
29{ 29{
30 struct kernfs_super_info *info = kernfs_info(sb); 30 struct kernfs_super_info *info = kernfs_info(sb);
31 struct inode *inode; 31 struct inode *inode;
@@ -39,10 +39,10 @@ static int sysfs_fill_super(struct super_block *sb)
39 39
40 /* get root inode, initialize and unlock it */ 40 /* get root inode, initialize and unlock it */
41 mutex_lock(&kernfs_mutex); 41 mutex_lock(&kernfs_mutex);
42 inode = sysfs_get_inode(sb, info->root->kn); 42 inode = kernfs_get_inode(sb, info->root->kn);
43 mutex_unlock(&kernfs_mutex); 43 mutex_unlock(&kernfs_mutex);
44 if (!inode) { 44 if (!inode) {
45 pr_debug("sysfs: could not get root inode\n"); 45 pr_debug("kernfs: could not get root inode\n");
46 return -ENOMEM; 46 return -ENOMEM;
47 } 47 }
48 48
@@ -59,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb)
59 return 0; 59 return 0;
60} 60}
61 61
62static int sysfs_test_super(struct super_block *sb, void *data) 62static int kernfs_test_super(struct super_block *sb, void *data)
63{ 63{
64 struct kernfs_super_info *sb_info = kernfs_info(sb); 64 struct kernfs_super_info *sb_info = kernfs_info(sb);
65 struct kernfs_super_info *info = data; 65 struct kernfs_super_info *info = data;
@@ -67,7 +67,7 @@ static int sysfs_test_super(struct super_block *sb, void *data)
67 return sb_info->root == info->root && sb_info->ns == info->ns; 67 return sb_info->root == info->root && sb_info->ns == info->ns;
68} 68}
69 69
70static int sysfs_set_super(struct super_block *sb, void *data) 70static int kernfs_set_super(struct super_block *sb, void *data)
71{ 71{
72 int error; 72 int error;
73 error = set_anon_super(sb, data); 73 error = set_anon_super(sb, data);
@@ -117,13 +117,13 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
117 info->root = root; 117 info->root = root;
118 info->ns = ns; 118 info->ns = ns;
119 119
120 sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info); 120 sb = sget(fs_type, kernfs_test_super, kernfs_set_super, flags, info);
121 if (IS_ERR(sb) || sb->s_fs_info != info) 121 if (IS_ERR(sb) || sb->s_fs_info != info)
122 kfree(info); 122 kfree(info);
123 if (IS_ERR(sb)) 123 if (IS_ERR(sb))
124 return ERR_CAST(sb); 124 return ERR_CAST(sb);
125 if (!sb->s_root) { 125 if (!sb->s_root) {
126 error = sysfs_fill_super(sb); 126 error = kernfs_fill_super(sb);
127 if (error) { 127 if (error) {
128 deactivate_locked_super(sb); 128 deactivate_locked_super(sb);
129 return ERR_PTR(error); 129 return ERR_PTR(error);
@@ -161,5 +161,5 @@ void __init kernfs_init(void)
161 kernfs_node_cache = kmem_cache_create("kernfs_node_cache", 161 kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
162 sizeof(struct kernfs_node), 162 sizeof(struct kernfs_node),
163 0, SLAB_PANIC, NULL); 163 0, SLAB_PANIC, NULL);
164 sysfs_inode_init(); 164 kernfs_inode_init();
165} 165}
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
index 4105bd04ea2f..a03e26036ef9 100644
--- a/fs/kernfs/symlink.c
+++ b/fs/kernfs/symlink.c
@@ -30,8 +30,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
30 struct kernfs_addrm_cxt acxt; 30 struct kernfs_addrm_cxt acxt;
31 int error; 31 int error;
32 32
33 kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO, 33 kn = kernfs_new_node(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO,
34 KERNFS_LINK); 34 KERNFS_LINK);
35 if (!kn) 35 if (!kn)
36 return ERR_PTR(-ENOMEM); 36 return ERR_PTR(-ENOMEM);
37 37
@@ -40,9 +40,9 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
40 kn->symlink.target_kn = target; 40 kn->symlink.target_kn = target;
41 kernfs_get(target); /* ref owned by symlink */ 41 kernfs_get(target); /* ref owned by symlink */
42 42
43 sysfs_addrm_start(&acxt); 43 kernfs_addrm_start(&acxt);
44 error = sysfs_add_one(&acxt, kn, parent); 44 error = kernfs_add_one(&acxt, kn, parent);
45 sysfs_addrm_finish(&acxt); 45 kernfs_addrm_finish(&acxt);
46 46
47 if (!error) 47 if (!error)
48 return kn; 48 return kn;
@@ -51,8 +51,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
51 return ERR_PTR(error); 51 return ERR_PTR(error);
52} 52}
53 53
54static int sysfs_get_target_path(struct kernfs_node *parent, 54static int kernfs_get_target_path(struct kernfs_node *parent,
55 struct kernfs_node *target, char *path) 55 struct kernfs_node *target, char *path)
56{ 56{
57 struct kernfs_node *base, *kn; 57 struct kernfs_node *base, *kn;
58 char *s = path; 58 char *s = path;
@@ -103,7 +103,7 @@ static int sysfs_get_target_path(struct kernfs_node *parent,
103 return 0; 103 return 0;
104} 104}
105 105
106static int sysfs_getlink(struct dentry *dentry, char *path) 106static int kernfs_getlink(struct dentry *dentry, char *path)
107{ 107{
108 struct kernfs_node *kn = dentry->d_fsdata; 108 struct kernfs_node *kn = dentry->d_fsdata;
109 struct kernfs_node *parent = kn->parent; 109 struct kernfs_node *parent = kn->parent;
@@ -111,18 +111,18 @@ static int sysfs_getlink(struct dentry *dentry, char *path)
111 int error; 111 int error;
112 112
113 mutex_lock(&kernfs_mutex); 113 mutex_lock(&kernfs_mutex);
114 error = sysfs_get_target_path(parent, target, path); 114 error = kernfs_get_target_path(parent, target, path);
115 mutex_unlock(&kernfs_mutex); 115 mutex_unlock(&kernfs_mutex);
116 116
117 return error; 117 return error;
118} 118}
119 119
120static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd) 120static void *kernfs_iop_follow_link(struct dentry *dentry, struct nameidata *nd)
121{ 121{
122 int error = -ENOMEM; 122 int error = -ENOMEM;
123 unsigned long page = get_zeroed_page(GFP_KERNEL); 123 unsigned long page = get_zeroed_page(GFP_KERNEL);
124 if (page) { 124 if (page) {
125 error = sysfs_getlink(dentry, (char *) page); 125 error = kernfs_getlink(dentry, (char *) page);
126 if (error < 0) 126 if (error < 0)
127 free_page((unsigned long)page); 127 free_page((unsigned long)page);
128 } 128 }
@@ -130,8 +130,8 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
130 return NULL; 130 return NULL;
131} 131}
132 132
133static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, 133static void kernfs_iop_put_link(struct dentry *dentry, struct nameidata *nd,
134 void *cookie) 134 void *cookie)
135{ 135{
136 char *page = nd_get_link(nd); 136 char *page = nd_get_link(nd);
137 if (!IS_ERR(page)) 137 if (!IS_ERR(page))
@@ -139,14 +139,14 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
139} 139}
140 140
141const struct inode_operations kernfs_symlink_iops = { 141const struct inode_operations kernfs_symlink_iops = {
142 .setxattr = sysfs_setxattr, 142 .setxattr = kernfs_iop_setxattr,
143 .removexattr = sysfs_removexattr, 143 .removexattr = kernfs_iop_removexattr,
144 .getxattr = sysfs_getxattr, 144 .getxattr = kernfs_iop_getxattr,
145 .listxattr = sysfs_listxattr, 145 .listxattr = kernfs_iop_listxattr,
146 .readlink = generic_readlink, 146 .readlink = generic_readlink,
147 .follow_link = sysfs_follow_link, 147 .follow_link = kernfs_iop_follow_link,
148 .put_link = sysfs_put_link, 148 .put_link = kernfs_iop_put_link,
149 .setattr = sysfs_setattr, 149 .setattr = kernfs_iop_setattr,
150 .getattr = sysfs_getattr, 150 .getattr = kernfs_iop_getattr,
151 .permission = sysfs_permission, 151 .permission = kernfs_iop_permission,
152}; 152};