diff options
| author | Allan Stephens <allan.stephens@windriver.com> | 2008-05-05 04:20:04 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2008-05-05 04:20:04 -0400 |
| commit | 025adbe8e58290798001b472aec3eb618d8fc930 (patch) | |
| tree | b9d49cd2f7be5b9e214d6e36306bceb077081256 /net/tipc | |
| parent | f74d505b58d36ceeef10e459094f0eb760681165 (diff) | |
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>
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/config.c | 2 | ||||
| -rw-r--r-- | net/tipc/core.c | 4 | ||||
| -rw-r--r-- | net/tipc/dbg.c | 26 | ||||
| -rw-r--r-- | net/tipc/dbg.h | 6 |
4 files changed, 13 insertions, 25 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index c71337a22d33..91d56f8fee9f 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -529,7 +529,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 529 | break; | 529 | break; |
| 530 | #endif | 530 | #endif |
| 531 | case TIPC_CMD_SET_LOG_SIZE: | 531 | 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); |
| 533 | break; | 533 | break; |
| 534 | case TIPC_CMD_DUMP_LOG: | 534 | case TIPC_CMD_DUMP_LOG: |
| 535 | rep_tlv_buf = tipc_log_dump(); | 535 | rep_tlv_buf = tipc_log_dump(); |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 740aac5cdfb6..862d41541615 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -182,7 +182,7 @@ static int __init tipc_init(void) | |||
| 182 | { | 182 | { |
| 183 | int res; | 183 | int res; |
| 184 | 184 | ||
| 185 | tipc_log_reinit(CONFIG_TIPC_LOG); | 185 | tipc_log_resize(CONFIG_TIPC_LOG); |
| 186 | info("Activated (version " TIPC_MOD_VER | 186 | info("Activated (version " TIPC_MOD_VER |
| 187 | " compiled " __DATE__ " " __TIME__ ")\n"); | 187 | " compiled " __DATE__ " " __TIME__ ")\n"); |
| 188 | 188 | ||
| @@ -209,7 +209,7 @@ static void __exit tipc_exit(void) | |||
| 209 | tipc_core_stop_net(); | 209 | tipc_core_stop_net(); |
| 210 | tipc_core_stop(); | 210 | tipc_core_stop(); |
| 211 | info("Deactivated\n"); | 211 | info("Deactivated\n"); |
| 212 | tipc_log_stop(); | 212 | tipc_log_resize(0); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | module_init(tipc_init); | 215 | module_init(tipc_init); |
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c index e809d2a2ce06..1a8d0a24d9e3 100644 --- a/net/tipc/dbg.c +++ b/net/tipc/dbg.c | |||
| @@ -350,43 +350,31 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...) | |||
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | /** | 352 | /** |
| 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 | ||
| 354 | */ | 355 | */ |
| 355 | 356 | ||
| 356 | void tipc_log_stop(void) | 357 | void tipc_log_resize(int log_size) |
| 357 | { | 358 | { |
| 358 | spin_lock_bh(&print_lock); | 359 | spin_lock_bh(&print_lock); |
| 359 | if (TIPC_LOG->buf) { | 360 | if (TIPC_LOG->buf) { |
| 360 | kfree(TIPC_LOG->buf); | 361 | kfree(TIPC_LOG->buf); |
| 361 | TIPC_LOG->buf = NULL; | 362 | TIPC_LOG->buf = NULL; |
| 362 | } | 363 | } |
| 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 | |||
| 375 | if (log_size) { | 364 | if (log_size) { |
| 376 | if (log_size < TIPC_PB_MIN_SIZE) | 365 | if (log_size < TIPC_PB_MIN_SIZE) |
| 377 | log_size = TIPC_PB_MIN_SIZE; | 366 | log_size = TIPC_PB_MIN_SIZE; |
| 378 | spin_lock_bh(&print_lock); | ||
| 379 | tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC), | 367 | tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC), |
| 380 | log_size); | 368 | log_size); |
| 381 | spin_unlock_bh(&print_lock); | ||
| 382 | } | 369 | } |
| 370 | spin_unlock_bh(&print_lock); | ||
| 383 | } | 371 | } |
| 384 | 372 | ||
| 385 | /** | 373 | /** |
| 386 | * tipc_log_resize - reconfigure size of TIPC log buffer | 374 | * tipc_log_resize_cmd - reconfigure size of TIPC log buffer |
| 387 | */ | 375 | */ |
| 388 | 376 | ||
| 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) |
| 390 | { | 378 | { |
| 391 | u32 value; | 379 | u32 value; |
| 392 | 380 | ||
| @@ -397,7 +385,7 @@ struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space) | |||
| 397 | if (value != delimit(value, 0, 32768)) | 385 | if (value != delimit(value, 0, 32768)) |
| 398 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 386 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
| 399 | " (log size must be 0-32768)"); | 387 | " (log size must be 0-32768)"); |
| 400 | tipc_log_reinit(value); | 388 | tipc_log_resize(value); |
| 401 | return tipc_cfg_reply_none(); | 389 | return tipc_cfg_reply_none(); |
| 402 | } | 390 | } |
| 403 | 391 | ||
diff --git a/net/tipc/dbg.h b/net/tipc/dbg.h index c01b085000e0..718a5db245b5 100644 --- a/net/tipc/dbg.h +++ b/net/tipc/dbg.h | |||
| @@ -61,10 +61,10 @@ int tipc_printbuf_empty(struct print_buf *pb); | |||
| 61 | int tipc_printbuf_validate(struct print_buf *pb); | 61 | int tipc_printbuf_validate(struct print_buf *pb); |
| 62 | void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from); | 62 | void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from); |
| 63 | 63 | ||
| 64 | void tipc_log_reinit(int log_size); | 64 | void tipc_log_resize(int log_size); |
| 65 | void tipc_log_stop(void); | ||
| 66 | 65 | ||
| 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); | ||
| 68 | struct sk_buff *tipc_log_dump(void); | 68 | struct sk_buff *tipc_log_dump(void); |
| 69 | 69 | ||
| 70 | #endif | 70 | #endif |
