[ofa-general] [PATCH 3/4] opensm/osm_log.c save log_max_size in subnet opt in MB

Sasha Khapyorsky sashak at voltaire.com
Mon Feb 2 12:29:04 PST 2009


Hi Eli,

On 16:33 Mon 26 Jan     , Eli Dorfman (Voltaire) wrote:
>  save log_max_size in subnet opt in MB
>  the max_size in the log object is converted to bytes.
> 
> Signed-off-by: Eli Dorfman <elid at voltaire.com>
> ---
>  opensm/opensm/main.c    |    5 ++---
>  opensm/opensm/osm_log.c |    2 +-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
> index 0f7b822..de38056 100644
> --- a/opensm/opensm/main.c
> +++ b/opensm/opensm/main.c
> @@ -778,9 +778,8 @@ int main(int argc, char *argv[])
>  			break;
>  
>  		case 'L':
> -			opt.log_max_size =
> -			    strtoul(optarg, NULL, 0) * (1024 * 1024);
> -			printf(" Log file max size is %lu bytes\n",
> +			opt.log_max_size = strtoul(optarg, NULL, 0);
> +			printf(" Log file max size is %lu MBytes\n",
>  			       opt.log_max_size);
>  			break;
>  
> diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
> index 88633ab..d5e1af6 100644
> --- a/opensm/opensm/osm_log.c
> +++ b/opensm/opensm/osm_log.c
> @@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * const p_log,
>  	p_log->level = log_flags;
>  	p_log->flush = flush;
>  	p_log->count = 0;
> -	p_log->max_size = max_size;
> +	p_log->max_size = max_size << 20; /* convert size in MB to bytes */
>  	p_log->accum_log_file = accum_log_file;
>  	p_log->log_file_name = (char *)log_file;

This is obviously not sufficient change. If you decided to store max log
file size value in MB in options structure then all places where it is
parsed/dumped should be changed. Something like this:


diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index f786192..6f0d85e 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -777,9 +777,8 @@ int main(int argc, char *argv[])
 			break;
 
 		case 'L':
-			opt.log_max_size =
-			    strtoul(optarg, NULL, 0) * (1024 * 1024);
-			printf(" Log file max size is %lu bytes\n",
+			opt.log_max_size = strtoul(optarg, NULL, 0);
+			printf(" Log file max size is %lu MBytes\n",
 			       opt.log_max_size);
 			break;
 
diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 88633ab..d5e1af6 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * const p_log,
 	p_log->level = log_flags;
 	p_log->flush = flush;
 	p_log->count = 0;
-	p_log->max_size = max_size;
+	p_log->max_size = max_size << 20; /* convert size in MB to bytes */
 	p_log->accum_log_file = accum_log_file;
 	p_log->log_file_name = (char *)log_file;
 
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index 94b6332..2141899 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -1141,7 +1141,6 @@ int osm_subn_parse_conf_file(char *file_name, osm_subn_opt_t * const p_opts)
 
 		opts_unpack_uint32("log_max_size", p_key, p_val,
 				   (void *) & p_opts->log_max_size);
-		p_opts->log_max_size *= 1024 * 1024; /* convert to MB */
 
 		opts_unpack_charp("partition_config_file",
 				  p_key, p_val, &p_opts->partition_config_file);
@@ -1620,7 +1619,7 @@ int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t *const p_opts)
 		p_opts->log_flags,
 		p_opts->force_log_flush ? "TRUE" : "FALSE",
 		p_opts->log_file,
-		p_opts->log_max_size/1024/1024,
+		p_opts->log_max_size,
 		p_opts->accum_log_file ? "TRUE" : "FALSE",
 		p_opts->dump_files_dir,
 		p_opts->enable_quirks ? "TRUE" : "FALSE",


I'm committing this with change above.

Sasha



More information about the general mailing list