linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rakesh Pandit <rakesh@tuxera.com>
To: "Javier González" <jg@lightnvm.io>
Cc: mb@lightnvm.io, axboe@fb.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Javier González" <javier@cnexlabs.com>,
	"Matias Bjørling" <matias@cnexlabs.com>
Subject: Re: [PATCH 08/20] lightnvm: pblk: sched. metadata on write thread
Date: Wed, 20 Sep 2017 21:28:34 +0300	[thread overview]
Message-ID: <20170920182834.GA25232@dhcp-216.srv.tuxera.com> (raw)
In-Reply-To: <1498471049-25505-9-git-send-email-javier@cnexlabs.com>

Hi Javier,

one small issue I found for error path while going through changes:

On Mon, Jun 26, 2017 at 11:57:17AM +0200, Javier Gonz�lez wrote:
..
> +static int pblk_lines_alloc_metadata(struct pblk *pblk)
> +{
> +	struct pblk_line_mgmt *l_mg = &pblk->l_mg;
> +	struct pblk_line_meta *lm = &pblk->lm;
> +	int i;
> +
> +	/* smeta is always small enough to fit on a kmalloc memory allocation,
> +	 * emeta depends on the number of LUNs allocated to the pblk instance
> +	 */
> +	l_mg->smeta_alloc_type = PBLK_KMALLOC_META;
> +	for (i = 0; i < PBLK_DATA_LINES; i++) {
> +		l_mg->sline_meta[i] = kmalloc(lm->smeta_len, GFP_KERNEL);
> +		if (!l_mg->sline_meta[i])
> +			goto fail_free_smeta;

For this error path the the goto label at end doesn't free up
resources correctly.  It needs a

while (--index >= 0)...

logic with appropriate adjustment.

> +	}
> +
> +	/* emeta allocates three different buffers for managing metadata with
> +	 * in-memory and in-media layouts
> +	 */
> +	for (i = 0; i < PBLK_DATA_LINES; i++) {
> +		struct pblk_emeta *emeta;
> +
> +		emeta = kmalloc(sizeof(struct pblk_emeta), GFP_KERNEL);
> +		if (!emeta)
> +			goto fail_free_emeta;
> +
> +		if (lm->emeta_len[0] > KMALLOC_MAX_CACHE_SIZE) {
> +			l_mg->emeta_alloc_type = PBLK_VMALLOC_META;
> +
> +			emeta->buf = vmalloc(lm->emeta_len[0]);
> +			if (!emeta->buf) {
> +				kfree(emeta);
> +				goto fail_free_emeta;
> +			}
> +
> +			emeta->nr_entries = lm->emeta_sec[0];
> +			l_mg->eline_meta[i] = emeta;
> +		} else {
> +			l_mg->emeta_alloc_type = PBLK_KMALLOC_META;
> +
> +			emeta->buf = kmalloc(lm->emeta_len[0], GFP_KERNEL);
> +			if (!emeta->buf) {
> +				kfree(emeta);
> +				goto fail_free_emeta;
> +			}
> +
> +			emeta->nr_entries = lm->emeta_sec[0];
> +			l_mg->eline_meta[i] = emeta;
> +		}
> +	}
> +
> +	l_mg->vsc_list = kcalloc(l_mg->nr_lines, sizeof(__le32), GFP_KERNEL);
> +	if (!l_mg->vsc_list)
> +		goto fail_free_emeta;
> +
> +	for (i = 0; i < l_mg->nr_lines; i++)
> +		l_mg->vsc_list[i] = cpu_to_le32(EMPTY_ENTRY);
> +
> +	return 0;
> +
> +fail_free_emeta:
> +	while (--i >= 0) {
> +		vfree(l_mg->eline_meta[i]->buf);

This would need l_mg->emeta_alloc_type check to decide whether
allocation was done with kmalloc or vmalloc.

> +		kfree(&l_mg->eline_meta[i]);
> +	}
> +
> +fail_free_smeta:
> +	for (i = 0; i < PBLK_DATA_LINES; i++)
> +		pblk_mfree(&l_mg->sline_meta[i], l_mg->smeta_alloc_type);
> +
> +	return -ENOMEM;
> +}
> +

Thanks,

  reply	other threads:[~2017-09-20 18:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26  9:57 [PATCH 00/20] LightNVM: pblk patches for 4.13 Javier González
2017-06-26  9:57 ` [PATCH 01/20] lightnvm: re-convert ppa format on I/O failure Javier González
2017-06-26  9:57 ` [PATCH 02/20] lightnvm: propagate right error code to target Javier González
2017-06-26  9:57 ` [PATCH 03/20] lightnvm: pblk: spare double cpu_to_le64 calc Javier González
2017-06-26  9:57 ` [PATCH 04/20] lightnvm: pblk: add debug stat for read cache hits Javier González
2017-06-26  9:57 ` [PATCH 05/20] lightnvm: pblk: expose max sec per write on sysfs Javier González
2017-06-26  9:57 ` [PATCH 06/20] lightnvm: pblk: generalize erase path Javier González
2017-06-26  9:57 ` [PATCH 07/20] lightnvm: pblk: rename read request pool Javier González
2017-06-26  9:57 ` [PATCH 08/20] lightnvm: pblk: sched. metadata on write thread Javier González
2017-09-20 18:28   ` Rakesh Pandit [this message]
2017-09-20 19:25     ` Rakesh Pandit
2017-06-26  9:57 ` [PATCH 09/20] lightnvm: pblk: delete redundant debug line stat Javier González
2017-06-26  9:57 ` [PATCH 10/20] lightnvm: pblk: delete redundant buffer pointer Javier González
2017-06-26  9:57 ` [PATCH 11/20] lightnvm: pblk: issue multiplane reads if possible Javier González
2017-06-26  9:57 ` [PATCH 12/20] lightnvm: pblk: simplify meta. memory allocation Javier González
2017-06-26  9:57 ` [PATCH 13/20] lightnvm: pblk: decouple bad block from line alloc Javier González
2017-06-26  9:57 ` [PATCH 14/20] lightnvm: pblk: choose optimal victim GC line Javier González
2017-06-26  9:57 ` [PATCH 15/20] lightnvm: pblk: set metadata list for all I/Os Javier González
2017-06-26  9:57 ` [PATCH 16/20] lightnvm: pblk: cleanup unnecessary code Javier González
2017-06-26  9:57 ` [PATCH 17/20] lightnvm: pblk: add lock assertions on helpers Javier González
2017-06-26  9:57 ` [PATCH 18/20] lightnvm: pblk: redesign GC algorithm Javier González
2017-06-26  9:57 ` [PATCH 19/20] lightnvm: pblk: set mempool and workqueue params Javier González
2017-06-26  9:57 ` [PATCH 20/20] lightnvm: pblk: fail gracefully on irrec. error Javier González
2017-06-26 22:29 ` [PATCH 00/20] LightNVM: pblk patches for 4.13 Jens Axboe
2017-06-27  8:00   ` Javier González

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=20170920182834.GA25232@dhcp-216.srv.tuxera.com \
    --to=rakesh@tuxera.com \
    --cc=axboe@fb.com \
    --cc=javier@cnexlabs.com \
    --cc=jg@lightnvm.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias@cnexlabs.com \
    --cc=mb@lightnvm.io \
    /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).