linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Drokin <oleg.drokin@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <andreas.dilger@intel.com>, <jsimmons@infradead.org>,
	<gregkh@linuxfoundation.org>, <emoly.liu@intel.com>,
	<lustre-devel@lists.lustre.org>, <devel@driverdev.osuosl.org>,
	<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH 2/2] staging: lustre: obdclass: Add handling of error returned by lustre_cfg_new
Date: Sun, 6 Nov 2016 12:26:32 -0500	[thread overview]
Message-ID: <97207CF4-21C1-4351-92BF-6F28E7281CF6@intel.com> (raw)
In-Reply-To: <20161106171123.24929-1-christophe.jaillet@wanadoo.fr>

Hello!

On Nov 6, 2016, at 12:11 PM, Christophe JAILLET wrote:

> 'lustre_cfg_new()' can return ERR_PTR(-ENOMEM).
> Handle these errors and propagate the error code to the callers.
> 
> Error handling has been rearranged in 'lustre_process_log()' with the
> addition of a label in order to free some resources.

I wonder if we should just make it return NULL on allocation failure,
and then at least the other error handling that is there (i.e. in your other patch)
would become correct.
This would make handling in mgc_apply_recover_logs incorrect, but it's already
geared towards this sort of handling anyway, as it discards the passed error
and sets ENOMEM unconditionally (just need to revert 3092c34a in a way).

Thanks!

> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> index 59fbc29aae94..5473615cd338 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> @@ -89,11 +89,14 @@ int lustre_process_log(struct super_block *sb, char *logname,
> 	lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg));
> 	lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb));
> 	lcfg = lustre_cfg_new(LCFG_LOG_START, bufs);
> +	if (IS_ERR(lcfg)) {
> +		rc = PTR_ERR(lcfg);
> +		goto out_free;
> +	}
> +
> 	rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
> 	lustre_cfg_free(lcfg);
> 
> -	kfree(bufs);
> -
> 	if (rc == -EINVAL)
> 		LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d).  Make sure this client and the MGS are running compatible versions of Lustre.\n",
> 				   mgc->obd_name, logname, rc);
> @@ -104,6 +107,9 @@ int lustre_process_log(struct super_block *sb, char *logname,
> 				   rc);
> 
> 	/* class_obd_list(); */
> +
> +out_free:
> +	kfree(bufs);
> 	return rc;
> }
> EXPORT_SYMBOL(lustre_process_log);
> @@ -127,6 +133,9 @@ int lustre_end_log(struct super_block *sb, char *logname,
> 	if (cfg)
> 		lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg));
> 	lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs);
> +	if (IS_ERR(lcfg))
> +		return PTR_ERR(lcfg);
> +
> 	rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
> 	lustre_cfg_free(lcfg);
> 	return rc;
> @@ -159,6 +168,9 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
> 		lustre_cfg_bufs_set_string(&bufs, 4, s4);
> 
> 	lcfg = lustre_cfg_new(cmd, &bufs);
> +	if (IS_ERR(lcfg))
> +		return PTR_ERR(lcfg);
> +
> 	lcfg->lcfg_nid = nid;
> 	rc = class_process_config(lcfg);
> 	lustre_cfg_free(lcfg);
> -- 
> 2.9.3

  reply	other threads:[~2016-11-06 17:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-06 17:11 [PATCH 2/2] staging: lustre: obdclass: Add handling of error returned by lustre_cfg_new Christophe JAILLET
2016-11-06 17:26 ` Oleg Drokin [this message]
2016-11-07  4:10   ` James Simmons
2016-11-07 10:40     ` Greg KH
2016-11-07 21:33   ` Dilger, Andreas
2016-11-07 22:46     ` Oleg Drokin

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=97207CF4-21C1-4351-92BF-6F28E7281CF6@intel.com \
    --to=oleg.drokin@intel.com \
    --cc=andreas.dilger@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=devel@driverdev.osuosl.org \
    --cc=emoly.liu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    /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;
as well as URLs for NNTP newsgroup(s).