Skip to content

Commit 025adbe

Browse files
ajstephensdavem330
authored andcommitted
tipc: Simplify log buffer resizing
This patch simplifies & standardizes the way TIPC's print buffer log is resized. Code to terminate use of the log buffer is eliminated by simply setting the log buffer size to 0 bytes. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f74d505 commit 025adbe

4 files changed

Lines changed: 13 additions & 25 deletions

File tree

‎net/tipc/config.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
529529
break;
530530
#endif
531531
case TIPC_CMD_SET_LOG_SIZE:
532-
rep_tlv_buf = tipc_log_resize(req_tlv_area, req_tlv_space);
532+
rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space);
533533
break;
534534
case TIPC_CMD_DUMP_LOG:
535535
rep_tlv_buf = tipc_log_dump();

‎net/tipc/core.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int __init tipc_init(void)
182182
{
183183
int res;
184184

185-
tipc_log_reinit(CONFIG_TIPC_LOG);
185+
tipc_log_resize(CONFIG_TIPC_LOG);
186186
info("Activated (version " TIPC_MOD_VER
187187
" compiled " __DATE__ " " __TIME__ ")\n");
188188

@@ -209,7 +209,7 @@ static void __exit tipc_exit(void)
209209
tipc_core_stop_net();
210210
tipc_core_stop();
211211
info("Deactivated\n");
212-
tipc_log_stop();
212+
tipc_log_resize(0);
213213
}
214214

215215
module_init(tipc_init);

‎net/tipc/dbg.c‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -350,43 +350,31 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
350350
}
351351

352352
/**
353-
* tipc_log_stop - free up TIPC log print buffer
353+
* tipc_log_resize - change the size of the TIPC log buffer
354+
* @log_size: print buffer size to use
354355
*/
355356

356-
void tipc_log_stop(void)
357+
void tipc_log_resize(int log_size)
357358
{
358359
spin_lock_bh(&print_lock);
359360
if (TIPC_LOG->buf) {
360361
kfree(TIPC_LOG->buf);
361362
TIPC_LOG->buf = NULL;
362363
}
363-
spin_unlock_bh(&print_lock);
364-
}
365-
366-
/**
367-
* tipc_log_reinit - (re)initialize TIPC log print buffer
368-
* @log_size: print buffer size to use
369-
*/
370-
371-
void tipc_log_reinit(int log_size)
372-
{
373-
tipc_log_stop();
374-
375364
if (log_size) {
376365
if (log_size < TIPC_PB_MIN_SIZE)
377366
log_size = TIPC_PB_MIN_SIZE;
378-
spin_lock_bh(&print_lock);
379367
tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
380368
log_size);
381-
spin_unlock_bh(&print_lock);
382369
}
370+
spin_unlock_bh(&print_lock);
383371
}
384372

385373
/**
386-
* tipc_log_resize - reconfigure size of TIPC log buffer
374+
* tipc_log_resize_cmd - reconfigure size of TIPC log buffer
387375
*/
388376

389-
struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
377+
struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
390378
{
391379
u32 value;
392380

@@ -397,7 +385,7 @@ struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
397385
if (value != delimit(value, 0, 32768))
398386
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
399387
" (log size must be 0-32768)");
400-
tipc_log_reinit(value);
388+
tipc_log_resize(value);
401389
return tipc_cfg_reply_none();
402390
}
403391

‎net/tipc/dbg.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ int tipc_printbuf_empty(struct print_buf *pb);
6161
int tipc_printbuf_validate(struct print_buf *pb);
6262
void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from);
6363

64-
void tipc_log_reinit(int log_size);
65-
void tipc_log_stop(void);
64+
void tipc_log_resize(int log_size);
6665

67-
struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space);
66+
struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area,
67+
int req_tlv_space);
6868
struct sk_buff *tipc_log_dump(void);
6969

7070
#endif

0 commit comments

Comments
 (0)