| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From b7f71899fbdba1cac6773a62ed4ea841b7eda6b0 Mon Sep 17 00:00:00 2001 | 
|  | 2 | From: Jens Axboe <axboe@kernel.dk> | 
|  | 3 | Date: Mon, 10 Jun 2019 03:35:41 -0600 | 
|  | 4 | Subject: [PATCH] cgroup/bfq: revert bfq.weight symlink change | 
|  | 5 |  | 
|  | 6 | There's some discussion on how to do this the best, and Tejun prefers | 
|  | 7 | that BFQ just create the file itself instead of having cgroups support | 
|  | 8 | a symlink feature. | 
|  | 9 |  | 
|  | 10 | Hence revert commit 54b7b868e826 and 19e9da9e86c4 for 5.2, and this | 
|  | 11 | can be done properly for 5.3. | 
|  | 12 |  | 
|  | 13 | Signed-off-by: Jens Axboe <axboe@kernel.dk> | 
|  | 14 | (cherry picked from commit cf8929885de318c0bf73438c9e5dde59d6536f7c) | 
|  | 15 | Signed-off-by: Li Yang <leoyang.li@nxp.com> | 
|  | 16 | --- | 
|  | 17 | include/linux/cgroup-defs.h |  3 --- | 
|  | 18 | kernel/cgroup/cgroup.c      | 33 ++++----------------------------- | 
|  | 19 | 2 files changed, 4 insertions(+), 32 deletions(-) | 
|  | 20 |  | 
|  | 21 | --- a/include/linux/cgroup-defs.h | 
|  | 22 | +++ b/include/linux/cgroup-defs.h | 
|  | 23 | @@ -106,8 +106,6 @@ enum { | 
|  | 24 | CFTYPE_WORLD_WRITABLE	= (1 << 4),	/* (DON'T USE FOR NEW FILES) S_IWUGO */ | 
|  | 25 | CFTYPE_DEBUG		= (1 << 5),	/* create when cgroup_debug */ | 
|  | 26 |  | 
|  | 27 | -	CFTYPE_SYMLINKED	= (1 << 6),	/* pointed to by symlink too */ | 
|  | 28 | - | 
|  | 29 | /* internal flags, do not use outside cgroup core proper */ | 
|  | 30 | __CFTYPE_ONLY_ON_DFL	= (1 << 16),	/* only on default hierarchy */ | 
|  | 31 | __CFTYPE_NOT_ON_DFL	= (1 << 17),	/* not on default hierarchy */ | 
|  | 32 | @@ -547,7 +545,6 @@ struct cftype { | 
|  | 33 | * end of cftype array. | 
|  | 34 | */ | 
|  | 35 | char name[MAX_CFTYPE_NAME]; | 
|  | 36 | -	char link_name[MAX_CFTYPE_NAME]; | 
|  | 37 | unsigned long private; | 
|  | 38 |  | 
|  | 39 | /* | 
|  | 40 | --- a/kernel/cgroup/cgroup.c | 
|  | 41 | +++ b/kernel/cgroup/cgroup.c | 
|  | 42 | @@ -1468,8 +1468,8 @@ struct cgroup *task_cgroup_from_root(str | 
|  | 43 |  | 
|  | 44 | static struct kernfs_syscall_ops cgroup_kf_syscall_ops; | 
|  | 45 |  | 
|  | 46 | -static char *cgroup_fill_name(struct cgroup *cgrp, const struct cftype *cft, | 
|  | 47 | -			      char *buf, bool write_link_name) | 
|  | 48 | +static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, | 
|  | 49 | +			      char *buf) | 
|  | 50 | { | 
|  | 51 | struct cgroup_subsys *ss = cft->ss; | 
|  | 52 |  | 
|  | 53 | @@ -1479,26 +1479,13 @@ static char *cgroup_fill_name(struct cgr | 
|  | 54 |  | 
|  | 55 | snprintf(buf, CGROUP_FILE_NAME_MAX, "%s%s.%s", | 
|  | 56 | dbg, cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, | 
|  | 57 | -			 write_link_name ? cft->link_name : cft->name); | 
|  | 58 | +			 cft->name); | 
|  | 59 | } else { | 
|  | 60 | -		strscpy(buf, write_link_name ? cft->link_name : cft->name, | 
|  | 61 | -			CGROUP_FILE_NAME_MAX); | 
|  | 62 | +		strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX); | 
|  | 63 | } | 
|  | 64 | return buf; | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | -static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, | 
|  | 68 | -			      char *buf) | 
|  | 69 | -{ | 
|  | 70 | -	return cgroup_fill_name(cgrp, cft, buf, false); | 
|  | 71 | -} | 
|  | 72 | - | 
|  | 73 | -static char *cgroup_link_name(struct cgroup *cgrp, const struct cftype *cft, | 
|  | 74 | -			      char *buf) | 
|  | 75 | -{ | 
|  | 76 | -	return cgroup_fill_name(cgrp, cft, buf, true); | 
|  | 77 | -} | 
|  | 78 | - | 
|  | 79 | /** | 
|  | 80 | * cgroup_file_mode - deduce file mode of a control file | 
|  | 81 | * @cft: the control file in question | 
|  | 82 | @@ -1657,9 +1644,6 @@ static void cgroup_rm_file(struct cgroup | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | kernfs_remove_by_name(cgrp->kn, cgroup_file_name(cgrp, cft, name)); | 
|  | 86 | -	if (cft->flags & CFTYPE_SYMLINKED) | 
|  | 87 | -		kernfs_remove_by_name(cgrp->kn, | 
|  | 88 | -				      cgroup_link_name(cgrp, cft, name)); | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | /** | 
|  | 92 | @@ -4010,7 +3994,6 @@ static int cgroup_add_file(struct cgroup | 
|  | 93 | { | 
|  | 94 | char name[CGROUP_FILE_NAME_MAX]; | 
|  | 95 | struct kernfs_node *kn; | 
|  | 96 | -	struct kernfs_node *kn_link; | 
|  | 97 | struct lock_class_key *key = NULL; | 
|  | 98 | int ret; | 
|  | 99 |  | 
|  | 100 | @@ -4041,14 +4024,6 @@ static int cgroup_add_file(struct cgroup | 
|  | 101 | spin_unlock_irq(&cgroup_file_kn_lock); | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | -	if (cft->flags & CFTYPE_SYMLINKED) { | 
|  | 105 | -		kn_link = kernfs_create_link(cgrp->kn, | 
|  | 106 | -					     cgroup_link_name(cgrp, cft, name), | 
|  | 107 | -					     kn); | 
|  | 108 | -		if (IS_ERR(kn_link)) | 
|  | 109 | -			return PTR_ERR(kn_link); | 
|  | 110 | -	} | 
|  | 111 | - | 
|  | 112 | return 0; | 
|  | 113 | } | 
|  | 114 |  |