Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Li Zhijian <lizhijian@fujitsu.com>, <nvdimm@lists.linux.dev>
Cc: <linux-cxl@vger.kernel.org>, <alison.schofield@intel.com>
Subject: Re: [ndctl PATCH v3 1/6] cxl/monitor: Enable default_log and refactor sanity check
Date: Wed, 5 Jul 2023 10:45:48 -0700	[thread overview]
Message-ID: <1b46df0a-7649-bd75-014e-02d1bfb931fa@intel.com> (raw)
In-Reply-To: <20230531021936.7366-2-lizhijian@fujitsu.com>



On 5/30/23 19:19, Li Zhijian wrote:
> The default_log(/var/log/cxl-monitor.log) should be used when no '-l'
> argument is specified in daemon mode, but it was not working at all.
> 
> Here we assigned it a default log per its arguments, and simplify the
> sanity check so that it can be consistent with the document.
> 
> Please note that i also removed following addition stuff, since we have
> added this prefix if needed during parsing the FILENAME in
> parse_options_prefix().
> if (strncmp(monitor.log, "./", 2) != 0)
>      fix_filename(prefix, (const char **)&monitor.log);
> 
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> V2: exchange order of previous patch1 and patch2 # Alison
>      a few commit log updated
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>   cxl/monitor.c | 38 ++++++++++++++++++++------------------
>   1 file changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/cxl/monitor.c b/cxl/monitor.c
> index e3469b9a4792..c6df2bad3c53 100644
> --- a/cxl/monitor.c
> +++ b/cxl/monitor.c
> @@ -164,6 +164,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx)
>   	};
>   	const char *prefix ="./";
>   	int rc = 0, i;
> +	const char *log;
>   
>   	argc = parse_options_prefix(argc, argv, prefix, options, u, 0);
>   	for (i = 0; i < argc; i++)
> @@ -171,32 +172,33 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx)
>   	if (argc)
>   		usage_with_options(u, options);
>   
> +	// sanity check
> +	if (monitor.daemon && monitor.log && !strncmp(monitor.log, "./", 2)) {
> +		error("standard or relative path for <file> will not work for daemon mode\n");
> +		return -EINVAL;
> +	}
> +
>   	log_init(&monitor.ctx, "cxl/monitor", "CXL_MONITOR_LOG");
> -	monitor.ctx.log_fn = log_standard;
> +	if (monitor.log)
> +		log = monitor.log;
> +	else
> +		log = monitor.daemon ? default_log : "./standard";
>   
>   	if (monitor.verbose)
>   		monitor.ctx.log_priority = LOG_DEBUG;
>   	else
>   		monitor.ctx.log_priority = LOG_INFO;
>   
> -	if (monitor.log) {
> -		if (strncmp(monitor.log, "./", 2) != 0)
> -			fix_filename(prefix, (const char **)&monitor.log);
> -		if (strncmp(monitor.log, "./standard", 10) == 0 && !monitor.daemon) {
> -			monitor.ctx.log_fn = log_standard;
> -		} else {
> -			const char *log = monitor.log;
> -
> -			if (!monitor.log)
> -				log = default_log;
> -			monitor.log_file = fopen(log, "a+");
> -			if (!monitor.log_file) {
> -				rc = -errno;
> -				error("open %s failed: %d\n", monitor.log, rc);
> -				goto out;
> -			}
> -			monitor.ctx.log_fn = log_file;
> +	if (strncmp(log, "./standard", 10) == 0)
> +		monitor.ctx.log_fn = log_standard;
> +	else {
> +		monitor.log_file = fopen(log, "a+");
> +		if (!monitor.log_file) {
> +			rc = -errno;
> +			error("open %s failed: %d\n", log, rc);
> +			goto out;
>   		}
> +		monitor.ctx.log_fn = log_file;
>   	}
>   
>   	if (monitor.daemon) {

  reply	other threads:[~2023-07-05 17:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31  2:19 [ndctl PATCH v3 0/6] cxl/monitor and ndctl/monitor fixes Li Zhijian
2023-05-31  2:19 ` [ndctl PATCH v3 1/6] cxl/monitor: Enable default_log and refactor sanity check Li Zhijian
2023-07-05 17:45   ` Dave Jiang [this message]
2023-07-05 20:53   ` Verma, Vishal L
2023-07-10 10:53     ` Zhijian Li (Fujitsu)
2023-07-10 16:59       ` Verma, Vishal L
2023-05-31  2:19 ` [ndctl PATCH v3 2/6] cxl/monitor: replace monitor.log_file with monitor.ctx.log_file Li Zhijian
2023-07-05 17:46   ` Dave Jiang
2023-05-31  2:19 ` [ndctl PATCH v3 3/6] cxl/monitor: use strcmp to compare the reserved word Li Zhijian
2023-07-05 18:20   ` Dave Jiang
2023-07-05 21:03   ` Verma, Vishal L
2023-07-10 12:53     ` Zhijian Li (Fujitsu)
2023-05-31  2:19 ` [ndctl PATCH v3 4/6] cxl/monitor: always log started message Li Zhijian
2023-07-05 18:21   ` Dave Jiang
2023-07-05 21:16   ` Verma, Vishal L
2023-07-10 13:05     ` Zhijian Li (Fujitsu)
2023-05-31  2:19 ` [ndctl PATCH v3 5/6] Documentation/cxl/cxl-monitor.txt: Fix inaccurate description Li Zhijian
2023-05-31  2:19 ` [ndctl PATCH v3 6/6] ndctl/monitor: use strcmp to compare the reserved word Li Zhijian
2023-07-05 18:22   ` Dave Jiang
2023-06-27 10:17 ` [ndctl PATCH v3 0/6] cxl/monitor and ndctl/monitor fixes Zhijian Li (Fujitsu)
2023-07-05 21:21   ` Verma, Vishal L
2023-07-05 23:53 ` Alison Schofield
2023-07-10 13:06   ` Zhijian Li (Fujitsu)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b46df0a-7649-bd75-014e-02d1bfb931fa@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox