aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs
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
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')
-rw-r--r--fs/kernfs/dir.c20
-rw-r--r--fs/kernfs/file.c4
2 files changed, 8 insertions, 16 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
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index ddc9f9612f16..b684e8a132e6 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -901,7 +901,6 @@ const struct file_operations kernfs_file_fops = {
901 * @ops: kernfs operations for the file 901 * @ops: kernfs operations for the file
902 * @priv: private data for the file 902 * @priv: private data for the file
903 * @ns: optional namespace tag of the file 903 * @ns: optional namespace tag of the file
904 * @name_is_static: don't copy file name
905 * @key: lockdep key for the file's active_ref, %NULL to disable lockdep 904 * @key: lockdep key for the file's active_ref, %NULL to disable lockdep
906 * 905 *
907 * Returns the created node on success, ERR_PTR() value on error. 906 * Returns the created node on success, ERR_PTR() value on error.
@@ -911,7 +910,6 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
911 umode_t mode, loff_t size, 910 umode_t mode, loff_t size,
912 const struct kernfs_ops *ops, 911 const struct kernfs_ops *ops,
913 void *priv, const void *ns, 912 void *priv, const void *ns,
914 bool name_is_static,
915 struct lock_class_key *key) 913 struct lock_class_key *key)
916{ 914{
917 struct kernfs_node *kn; 915 struct kernfs_node *kn;
@@ -919,8 +917,6 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
919 int rc; 917 int rc;
920 918
921 flags = KERNFS_FILE; 919 flags = KERNFS_FILE;
922 if (name_is_static)
923 flags |= KERNFS_STATIC_NAME;
924 920
925 kn = kernfs_new_node(parent, name, (mode & S_IALLUGO) | S_IFREG, flags); 921 kn = kernfs_new_node(parent, name, (mode & S_IALLUGO) | S_IFREG, flags);
926 if (!kn) 922 if (!kn)