aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs/dir.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-02-13 17:36:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:36 -0500
commitdfeb0750b630b72b5d4fb2461bc7179eceb54666 (patch)
tree22af2116c4b061fd8ce268f78f56696e0a21c5c1 /fs/kernfs/dir.c
parent75287a677ba1beab7ca0db948468f44eb23a709f (diff)
kernfs: remove KERNFS_STATIC_NAME
When a new kernfs node is created, KERNFS_STATIC_NAME is used to avoid making a separate copy of its name. It's currently only used for sysfs attributes whose filenames are required to stay accessible and unchanged. There are rare exceptions where these names are allocated and formatted dynamically but for the vast majority of cases they're consts in the rodata section. Now that kernfs is converted to use kstrdup_const() and kfree_const(), there's little point in keeping KERNFS_STATIC_NAME around. Remove it. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r--fs/kernfs/dir.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 35e40879860a..6acc9648f986 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -411,8 +411,9 @@ void kernfs_put(struct kernfs_node *kn)
411 411
412 if (kernfs_type(kn) == KERNFS_LINK) 412 if (kernfs_type(kn) == KERNFS_LINK)
413 kernfs_put(kn->symlink.target_kn); 413 kernfs_put(kn->symlink.target_kn);
414 if (!(kn->flags & KERNFS_STATIC_NAME)) 414
415 kfree_const(kn->name); 415 kfree_const(kn->name);
416
416 if (kn->iattr) { 417 if (kn->iattr) {
417 if (kn->iattr->ia_secdata) 418 if (kn->iattr->ia_secdata)
418 security_release_secctx(kn->iattr->ia_secdata, 419 security_release_secctx(kn->iattr->ia_secdata,
@@ -506,15 +507,12 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
506 const char *name, umode_t mode, 507 const char *name, umode_t mode,
507 unsigned flags) 508 unsigned flags)
508{ 509{
509 const char *dup_name = NULL;
510 struct kernfs_node *kn; 510 struct kernfs_node *kn;
511 int ret; 511 int ret;
512 512
513 if (!(flags & KERNFS_STATIC_NAME)) { 513 name = kstrdup_const(name, GFP_KERNEL);
514 name = dup_name = kstrdup_const(name, GFP_KERNEL); 514 if (!name)
515 if (!name) 515 return NULL;
516 return NULL;
517 }
518 516
519 kn = kmem_cache_zalloc(kernfs_node_cache, GFP_KERNEL); 517 kn = kmem_cache_zalloc(kernfs_node_cache, GFP_KERNEL);
520 if (!kn) 518 if (!kn)
@@ -538,7 +536,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
538 err_out2: 536 err_out2:
539 kmem_cache_free(kernfs_node_cache, kn); 537 kmem_cache_free(kernfs_node_cache, kn);
540 err_out1: 538 err_out1:
541 kfree_const(dup_name); 539 kfree_const(name);
542 return NULL; 540 return NULL;
543} 541}
544 542
@@ -1285,9 +1283,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
1285 1283
1286 kn->ns = new_ns; 1284 kn->ns = new_ns;
1287 if (new_name) { 1285 if (new_name) {
1288 if (!(kn->flags & KERNFS_STATIC_NAME)) 1286 old_name = kn->name;
1289 old_name = kn->name;
1290 kn->flags &= ~KERNFS_STATIC_NAME;
1291 kn->name = new_name; 1287 kn->name = new_name;
1292 } 1288 }
1293 1289