History

Merge tag 'for-linus-6.2-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux

Pull orangefs updates from Mike Marshall: - fix problems with memory leaks on exit in sysfs and debufs (Zhang) - remove an unused variable and an unneeded assignment (Colin) * tag 'for-linus-6.2-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux: orangefs: Fix kmemleak in orangefs_{kernel,client}_debug_init() orangefs: Fix kmemleak in orangefs_sysfs_init() orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() orangefs: Fix sysfs not cleanup when dev init failed orangefs: remove redundant assignment to variable buffer_index orangefs: remove variable i

Linus Torvalds committed 3 years ago

Commit 6f1f5ca2 parents cfb3162 31720a25 files · +73 −38Browse files

Unified · Split

5 files
  1. fs/orangefs/file.c +0 −1
  2. fs/orangefs/inode.c +0 −2
  3. fs/orangefs/orangefs-debugfs.c +6 −23
  4. fs/orangefs/orangefs-mod.c +4 −4
  5. fs/orangefs/orangefs-sysfs.c +63 −8
fs/orangefs/file.c+0−1
@@ -273,7 +273,6 @@ out: · 272 unmodified lines
273 gossip_debug(GOSSIP_FILE_DEBUG,273 gossip_debug(GOSSIP_FILE_DEBUG,
274 "%s(%pU): PUT buffer_index %d\n",274 "%s(%pU): PUT buffer_index %d\n",
275 __func__, handle, buffer_index);275 __func__, handle, buffer_index);
276 buffer_index = -1;
277 }276 }
278 op_release(new_op);277 op_release(new_op);
279 return ret;278 return ret;
fs/orangefs/inode.c+0−2
@@ -530,7 +530,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, · 529 unmodified lines
530 size_t count = iov_iter_count(iter);530 size_t count = iov_iter_count(iter);
531 ssize_t total_count = 0;531 ssize_t total_count = 0;
532 ssize_t ret = -EINVAL;532 ssize_t ret = -EINVAL;
533 int i = 0;
534 533
535 gossip_debug(GOSSIP_FILE_DEBUG,534 gossip_debug(GOSSIP_FILE_DEBUG,
536 "%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",535 "%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",
@@ -556,7 +555,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, · 19 unmodified lines
556 while (iov_iter_count(iter)) {555 while (iov_iter_count(iter)) {
557 size_t each_count = iov_iter_count(iter);556 size_t each_count = iov_iter_count(iter);
558 size_t amt_complete;557 size_t amt_complete;
559 i++;
560 558
561 /* how much to transfer in this loop iteration */559 /* how much to transfer in this loop iteration */
562 if (each_count > orangefs_bufmap_size_query())560 if (each_count > orangefs_bufmap_size_query())
fs/orangefs/orangefs-debugfs.c+6−23
@@ -194,15 +194,10 @@ void orangefs_debugfs_init(int debug_mask) · 193 unmodified lines
194 */194 */
195static void orangefs_kernel_debug_init(void)195static void orangefs_kernel_debug_init(void)
196{196{
197 int rc = -ENOMEM;197 static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
198 char *k_buffer = NULL;
199 198
200 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);199 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
201 200
202 k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
203 if (!k_buffer)
204 goto out;
205
206 if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {201 if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
207 strcpy(k_buffer, kernel_debug_string);202 strcpy(k_buffer, kernel_debug_string);
208 strcat(k_buffer, "\n");203 strcat(k_buffer, "\n");
@@ -213,15 +208,14 @@ static void orangefs_kernel_debug_init(void) · 4 unmodified lines
213 208
214 debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer,209 debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer,
215 &kernel_debug_fops);210 &kernel_debug_fops);
216
217out:
218 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
219}211}
220 212
221 213
222void orangefs_debugfs_cleanup(void)214void orangefs_debugfs_cleanup(void)
223{215{
224 debugfs_remove_recursive(debug_dir);216 debugfs_remove_recursive(debug_dir);
217 kfree(debug_help_string);
218 debug_help_string = NULL;
225}219}
226 220
227/* open ORANGEFS_KMOD_DEBUG_HELP_FILE */221/* open ORANGEFS_KMOD_DEBUG_HELP_FILE */
@@ -297,18 +291,13 @@ static int help_show(struct seq_file *m, void *v) · 69 unmodified lines
297/*291/*
298 * initialize the client-debug file.292 * initialize the client-debug file.
299 */293 */
300static int orangefs_client_debug_init(void)294static void orangefs_client_debug_init(void)
301{295{
302 296
303 int rc = -ENOMEM;297 static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
304 char *c_buffer = NULL;
305 298
306 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);299 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
307 300
308 c_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
309 if (!c_buffer)
310 goto out;
311
312 if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {301 if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
313 strcpy(c_buffer, client_debug_string);302 strcpy(c_buffer, client_debug_string);
314 strcat(c_buffer, "\n");303 strcat(c_buffer, "\n");
@@ -322,13 +311,6 @@ static int orangefs_client_debug_init(void) · 7 unmodified lines
322 debug_dir,311 debug_dir,
323 c_buffer,312 c_buffer,
324 &kernel_debug_fops);313 &kernel_debug_fops);
325
326 rc = 0;
327
328out:
329
330 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
331 return rc;
332}314}
333 315
334/* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/316/* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/
@@ -671,6 +653,7 @@ int orangefs_prepare_debugfs_help_string(int at_boot) · 336 unmodified lines
671 memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE);653 memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE);
672 strlcat(debug_help_string, new, string_size);654 strlcat(debug_help_string, new, string_size);
673 mutex_unlock(&orangefs_help_file_lock);655 mutex_unlock(&orangefs_help_file_lock);
656 kfree(new);
674 }657 }
675 658
676 rc = 0;659 rc = 0;
fs/orangefs/orangefs-mod.c+4−4
@@ -141,7 +141,7 @@ static int __init orangefs_init(void) · 140 unmodified lines
141 gossip_err("%s: could not initialize device subsystem %d!\n",141 gossip_err("%s: could not initialize device subsystem %d!\n",
142 __func__,142 __func__,
143 ret);143 ret);
144 goto cleanup_device;144 goto cleanup_sysfs;
145 }145 }
146 146
147 ret = register_filesystem(&orangefs_fs_type);147 ret = register_filesystem(&orangefs_fs_type);
@@ -152,11 +152,11 @@ static int __init orangefs_init(void) · 4 unmodified lines
152 goto out;152 goto out;
153 }153 }
154 154
155 orangefs_sysfs_exit();
156
157cleanup_device:
158 orangefs_dev_cleanup();155 orangefs_dev_cleanup();
159 156
157cleanup_sysfs:
158 orangefs_sysfs_exit();
159
160sysfs_init_failed:160sysfs_init_failed:
161 orangefs_debugfs_cleanup();161 orangefs_debugfs_cleanup();
162 162
fs/orangefs/orangefs-sysfs.c+63−8
@@ -896,9 +896,18 @@ static struct attribute *orangefs_default_attrs[] = { · 895 unmodified lines
896};896};
897ATTRIBUTE_GROUPS(orangefs_default);897ATTRIBUTE_GROUPS(orangefs_default);
898 898
899static struct kobject *orangefs_obj;
900
901static void orangefs_obj_release(struct kobject *kobj)
902{
903 kfree(orangefs_obj);
904 orangefs_obj = NULL;
905}
906
899static struct kobj_type orangefs_ktype = {907static struct kobj_type orangefs_ktype = {
900 .sysfs_ops = &orangefs_sysfs_ops,908 .sysfs_ops = &orangefs_sysfs_ops,
901 .default_groups = orangefs_default_groups,909 .default_groups = orangefs_default_groups,
910 .release = orangefs_obj_release,
902};911};
903 912
904static struct orangefs_attribute acache_hard_limit_attribute =913static struct orangefs_attribute acache_hard_limit_attribute =
@@ -934,9 +943,18 @@ static struct attribute *acache_orangefs_default_attrs[] = { · 29 unmodified lines
934};943};
935ATTRIBUTE_GROUPS(acache_orangefs_default);944ATTRIBUTE_GROUPS(acache_orangefs_default);
936 945
946static struct kobject *acache_orangefs_obj;
947
948static void acache_orangefs_obj_release(struct kobject *kobj)
949{
950 kfree(acache_orangefs_obj);
951 acache_orangefs_obj = NULL;
952}
953
937static struct kobj_type acache_orangefs_ktype = {954static struct kobj_type acache_orangefs_ktype = {
938 .sysfs_ops = &orangefs_sysfs_ops,955 .sysfs_ops = &orangefs_sysfs_ops,
939 .default_groups = acache_orangefs_default_groups,956 .default_groups = acache_orangefs_default_groups,
957 .release = acache_orangefs_obj_release,
940};958};
941 959
942static struct orangefs_attribute capcache_hard_limit_attribute =960static struct orangefs_attribute capcache_hard_limit_attribute =
@@ -972,9 +990,18 @@ static struct attribute *capcache_orangefs_default_attrs[] = { · 29 unmodified lines
972};990};
973ATTRIBUTE_GROUPS(capcache_orangefs_default);991ATTRIBUTE_GROUPS(capcache_orangefs_default);
974 992
993static struct kobject *capcache_orangefs_obj;
994
995static void capcache_orangefs_obj_release(struct kobject *kobj)
996{
997 kfree(capcache_orangefs_obj);
998 capcache_orangefs_obj = NULL;
999}
1000
975static struct kobj_type capcache_orangefs_ktype = {1001static struct kobj_type capcache_orangefs_ktype = {
976 .sysfs_ops = &orangefs_sysfs_ops,1002 .sysfs_ops = &orangefs_sysfs_ops,
977 .default_groups = capcache_orangefs_default_groups,1003 .default_groups = capcache_orangefs_default_groups,
1004 .release = capcache_orangefs_obj_release,
978};1005};
979 1006
980static struct orangefs_attribute ccache_hard_limit_attribute =1007static struct orangefs_attribute ccache_hard_limit_attribute =
@@ -1010,9 +1037,18 @@ static struct attribute *ccache_orangefs_default_attrs[] = { · 29 unmodified lines
1010};1037};
1011ATTRIBUTE_GROUPS(ccache_orangefs_default);1038ATTRIBUTE_GROUPS(ccache_orangefs_default);
1012 1039
1040static struct kobject *ccache_orangefs_obj;
1041
1042static void ccache_orangefs_obj_release(struct kobject *kobj)
1043{
1044 kfree(ccache_orangefs_obj);
1045 ccache_orangefs_obj = NULL;
1046}
1047
1013static struct kobj_type ccache_orangefs_ktype = {1048static struct kobj_type ccache_orangefs_ktype = {
1014 .sysfs_ops = &orangefs_sysfs_ops,1049 .sysfs_ops = &orangefs_sysfs_ops,
1015 .default_groups = ccache_orangefs_default_groups,1050 .default_groups = ccache_orangefs_default_groups,
1051 .release = ccache_orangefs_obj_release,
1016};1052};
1017 1053
1018static struct orangefs_attribute ncache_hard_limit_attribute =1054static struct orangefs_attribute ncache_hard_limit_attribute =
@@ -1048,9 +1084,18 @@ static struct attribute *ncache_orangefs_default_attrs[] = { · 29 unmodified lines
1048};1084};
1049ATTRIBUTE_GROUPS(ncache_orangefs_default);1085ATTRIBUTE_GROUPS(ncache_orangefs_default);
1050 1086
1087static struct kobject *ncache_orangefs_obj;
1088
1089static void ncache_orangefs_obj_release(struct kobject *kobj)
1090{
1091 kfree(ncache_orangefs_obj);
1092 ncache_orangefs_obj = NULL;
1093}
1094
1051static struct kobj_type ncache_orangefs_ktype = {1095static struct kobj_type ncache_orangefs_ktype = {
1052 .sysfs_ops = &orangefs_sysfs_ops,1096 .sysfs_ops = &orangefs_sysfs_ops,
1053 .default_groups = ncache_orangefs_default_groups,1097 .default_groups = ncache_orangefs_default_groups,
1098 .release = ncache_orangefs_obj_release,
1054};1099};
1055 1100
1056static struct orangefs_attribute pc_acache_attribute =1101static struct orangefs_attribute pc_acache_attribute =
@@ -1079,9 +1124,18 @@ static struct attribute *pc_orangefs_default_attrs[] = { · 22 unmodified lines
1079};1124};
1080ATTRIBUTE_GROUPS(pc_orangefs_default);1125ATTRIBUTE_GROUPS(pc_orangefs_default);
1081 1126
1127static struct kobject *pc_orangefs_obj;
1128
1129static void pc_orangefs_obj_release(struct kobject *kobj)
1130{
1131 kfree(pc_orangefs_obj);
1132 pc_orangefs_obj = NULL;
1133}
1134
1082static struct kobj_type pc_orangefs_ktype = {1135static struct kobj_type pc_orangefs_ktype = {
1083 .sysfs_ops = &orangefs_sysfs_ops,1136 .sysfs_ops = &orangefs_sysfs_ops,
1084 .default_groups = pc_orangefs_default_groups,1137 .default_groups = pc_orangefs_default_groups,
1138 .release = pc_orangefs_obj_release,
1085};1139};
1086 1140
1087static struct orangefs_attribute stats_reads_attribute =1141static struct orangefs_attribute stats_reads_attribute =
@@ -1103,19 +1157,20 @@ static struct attribute *stats_orangefs_default_attrs[] = { · 15 unmodified lines
1103};1157};
1104ATTRIBUTE_GROUPS(stats_orangefs_default);1158ATTRIBUTE_GROUPS(stats_orangefs_default);
1105 1159
1160static struct kobject *stats_orangefs_obj;
1161
1162static void stats_orangefs_obj_release(struct kobject *kobj)
1163{
1164 kfree(stats_orangefs_obj);
1165 stats_orangefs_obj = NULL;
1166}
1167
1106static struct kobj_type stats_orangefs_ktype = {1168static struct kobj_type stats_orangefs_ktype = {
1107 .sysfs_ops = &orangefs_sysfs_ops,1169 .sysfs_ops = &orangefs_sysfs_ops,
1108 .default_groups = stats_orangefs_default_groups,1170 .default_groups = stats_orangefs_default_groups,
1171 .release = stats_orangefs_obj_release,
1109};1172};
1110 1173
1111static struct kobject *orangefs_obj;
1112static struct kobject *acache_orangefs_obj;
1113static struct kobject *capcache_orangefs_obj;
1114static struct kobject *ccache_orangefs_obj;
1115static struct kobject *ncache_orangefs_obj;
1116static struct kobject *pc_orangefs_obj;
1117static struct kobject *stats_orangefs_obj;
1118
1119int orangefs_sysfs_init(void)1174int orangefs_sysfs_init(void)
1120{1175{
1121 int rc = -EINVAL;1176 int rc = -EINVAL;