70
70
*/
71
71
static LIST_HEAD (rv_reactors_list );
72
72
73
- static struct rv_reactor_def * get_reactor_rdef_by_name (char * name )
73
+ static struct rv_reactor * get_reactor_rdef_by_name (char * name )
74
74
{
75
- struct rv_reactor_def * r ;
75
+ struct rv_reactor * r ;
76
76
77
77
list_for_each_entry (r , & rv_reactors_list , list ) {
78
- if (strcmp (name , r -> reactor -> name ) == 0 )
78
+ if (strcmp (name , r -> name ) == 0 )
79
79
return r ;
80
80
}
81
81
return NULL ;
@@ -86,9 +86,9 @@ static struct rv_reactor_def *get_reactor_rdef_by_name(char *name)
86
86
*/
87
87
static int reactors_show (struct seq_file * m , void * p )
88
88
{
89
- struct rv_reactor_def * rea_def = p ;
89
+ struct rv_reactor * reactor = p ;
90
90
91
- seq_printf (m , "%s\n" , rea_def -> reactor -> name );
91
+ seq_printf (m , "%s\n" , reactor -> name );
92
92
return 0 ;
93
93
}
94
94
@@ -139,12 +139,12 @@ static const struct file_operations available_reactors_ops = {
139
139
static int monitor_reactor_show (struct seq_file * m , void * p )
140
140
{
141
141
struct rv_monitor * mon = m -> private ;
142
- struct rv_reactor_def * rdef = p ;
142
+ struct rv_reactor * reactor = p ;
143
143
144
- if (mon -> rdef == rdef )
145
- seq_printf (m , "[%s]\n" , rdef -> reactor -> name );
144
+ if (mon -> reactor == reactor )
145
+ seq_printf (m , "[%s]\n" , reactor -> name );
146
146
else
147
- seq_printf (m , "%s\n" , rdef -> reactor -> name );
147
+ seq_printf (m , "%s\n" , reactor -> name );
148
148
return 0 ;
149
149
}
150
150
@@ -159,50 +159,50 @@ static const struct seq_operations monitor_reactors_seq_ops = {
159
159
};
160
160
161
161
static void monitor_swap_reactors_single (struct rv_monitor * mon ,
162
- struct rv_reactor_def * rdef ,
162
+ struct rv_reactor * reactor ,
163
163
bool reacting , bool nested )
164
164
{
165
165
bool monitor_enabled ;
166
166
167
167
/* nothing to do */
168
- if (mon -> rdef == rdef )
168
+ if (mon -> reactor == reactor )
169
169
return ;
170
170
171
171
monitor_enabled = mon -> enabled ;
172
172
if (monitor_enabled )
173
173
rv_disable_monitor (mon );
174
174
175
175
/* swap reactor's usage */
176
- mon -> rdef -> counter -- ;
177
- rdef -> counter ++ ;
176
+ mon -> reactor -> counter -- ;
177
+ reactor -> counter ++ ;
178
178
179
- mon -> rdef = rdef ;
179
+ mon -> reactor = reactor ;
180
180
mon -> reacting = reacting ;
181
- mon -> react = rdef -> reactor -> react ;
181
+ mon -> react = reactor -> react ;
182
182
183
183
/* enable only once if iterating through a container */
184
184
if (monitor_enabled && !nested )
185
185
rv_enable_monitor (mon );
186
186
}
187
187
188
188
static void monitor_swap_reactors (struct rv_monitor * mon ,
189
- struct rv_reactor_def * rdef , bool reacting )
189
+ struct rv_reactor * reactor , bool reacting )
190
190
{
191
191
struct rv_monitor * p = mon ;
192
192
193
193
if (rv_is_container_monitor (mon ))
194
194
list_for_each_entry_continue (p , & rv_monitors_list , list ) {
195
195
if (p -> parent != mon )
196
196
break ;
197
- monitor_swap_reactors_single (p , rdef , reacting , true);
197
+ monitor_swap_reactors_single (p , reactor , reacting , true);
198
198
}
199
199
/*
200
200
* This call enables and disables the monitor if they were active.
201
201
* In case of a container, we already disabled all and will enable all.
202
202
* All nested monitors are enabled also if they were off, we may refine
203
203
* this logic in the future.
204
204
*/
205
- monitor_swap_reactors_single (mon , rdef , reacting , false);
205
+ monitor_swap_reactors_single (mon , reactor , reacting , false);
206
206
}
207
207
208
208
static ssize_t
@@ -211,7 +211,7 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
211
211
{
212
212
char buff [MAX_RV_REACTOR_NAME_SIZE + 2 ];
213
213
struct rv_monitor * mon ;
214
- struct rv_reactor_def * rdef ;
214
+ struct rv_reactor * reactor ;
215
215
struct seq_file * seq_f ;
216
216
int retval = - EINVAL ;
217
217
bool enable ;
@@ -243,16 +243,16 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
243
243
244
244
retval = - EINVAL ;
245
245
246
- list_for_each_entry (rdef , & rv_reactors_list , list ) {
247
- if (strcmp (ptr , rdef -> reactor -> name ) != 0 )
246
+ list_for_each_entry (reactor , & rv_reactors_list , list ) {
247
+ if (strcmp (ptr , reactor -> name ) != 0 )
248
248
continue ;
249
249
250
- if (rdef == get_reactor_rdef_by_name ( "nop" ))
250
+ if (strcmp ( reactor -> name , "nop" ))
251
251
enable = false;
252
252
else
253
253
enable = true;
254
254
255
- monitor_swap_reactors (mon , rdef , enable );
255
+ monitor_swap_reactors (mon , reactor , enable );
256
256
257
257
retval = count ;
258
258
break ;
@@ -299,23 +299,16 @@ static const struct file_operations monitor_reactors_ops = {
299
299
300
300
static int __rv_register_reactor (struct rv_reactor * reactor )
301
301
{
302
- struct rv_reactor_def * r ;
302
+ struct rv_reactor * r ;
303
303
304
304
list_for_each_entry (r , & rv_reactors_list , list ) {
305
- if (strcmp (reactor -> name , r -> reactor -> name ) == 0 ) {
305
+ if (strcmp (reactor -> name , r -> name ) == 0 ) {
306
306
pr_info ("Reactor %s is already registered\n" , reactor -> name );
307
307
return - EINVAL ;
308
308
}
309
309
}
310
310
311
- r = kzalloc (sizeof (struct rv_reactor_def ), GFP_KERNEL );
312
- if (!r )
313
- return - ENOMEM ;
314
-
315
- r -> reactor = reactor ;
316
- r -> counter = 0 ;
317
-
318
- list_add_tail (& r -> list , & rv_reactors_list );
311
+ list_add_tail (& reactor -> list , & rv_reactors_list );
319
312
320
313
return 0 ;
321
314
}
@@ -350,26 +343,19 @@ int rv_register_reactor(struct rv_reactor *reactor)
350
343
*/
351
344
int rv_unregister_reactor (struct rv_reactor * reactor )
352
345
{
353
- struct rv_reactor_def * ptr , * next ;
354
346
int ret = 0 ;
355
347
356
348
mutex_lock (& rv_interface_lock );
357
349
358
- list_for_each_entry_safe (ptr , next , & rv_reactors_list , list ) {
359
- if (strcmp (reactor -> name , ptr -> reactor -> name ) == 0 ) {
360
-
361
- if (!ptr -> counter ) {
362
- list_del (& ptr -> list );
363
- } else {
364
- printk (KERN_WARNING
365
- "rv: the rv_reactor %s is in use by %d monitor(s)\n" ,
366
- ptr -> reactor -> name , ptr -> counter );
367
- printk (KERN_WARNING "rv: the rv_reactor %s cannot be removed\n" ,
368
- ptr -> reactor -> name );
369
- ret = - EBUSY ;
370
- break ;
371
- }
372
- }
350
+ if (!reactor -> counter ) {
351
+ list_del (& reactor -> list );
352
+ } else {
353
+ printk (KERN_WARNING
354
+ "rv: the rv_reactor %s is in use by %d monitor(s)\n" ,
355
+ reactor -> name , reactor -> counter );
356
+ printk (KERN_WARNING "rv: the rv_reactor %s cannot be removed\n" ,
357
+ reactor -> name );
358
+ ret = - EBUSY ;
373
359
}
374
360
375
361
mutex_unlock (& rv_interface_lock );
@@ -469,8 +455,8 @@ int reactor_populate_monitor(struct rv_monitor *mon)
469
455
/*
470
456
* Configure as the rv_nop reactor.
471
457
*/
472
- mon -> rdef = get_reactor_rdef_by_name ("nop" );
473
- mon -> rdef -> counter ++ ;
458
+ mon -> reactor = get_reactor_rdef_by_name ("nop" );
459
+ mon -> reactor -> counter ++ ;
474
460
mon -> reacting = false;
475
461
476
462
return 0 ;
@@ -483,8 +469,8 @@ int reactor_populate_monitor(struct rv_monitor *mon)
483
469
void reactor_cleanup_monitor (struct rv_monitor * mon )
484
470
{
485
471
lockdep_assert_held (& rv_interface_lock );
486
- mon -> rdef -> counter -- ;
487
- WARN_ON_ONCE (mon -> rdef -> counter < 0 );
472
+ mon -> reactor -> counter -- ;
473
+ WARN_ON_ONCE (mon -> reactor -> counter < 0 );
488
474
}
489
475
490
476
/*
0 commit comments