From: Edward Thornber <thornber@redhat.com>
To: Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH] dm-persistent-data: free sm_metadata on failed create
Date: Thu, 1 Dec 2016 05:58:10 -0500 [thread overview]
Message-ID: <20161201105810.GD5643@roamer.bos.redhat.com> (raw)
In-Reply-To: <1480550174-8675-1-git-send-email-bmarzins@redhat.com>
ack
On Wed, Nov 30, 2016 at 05:56:14PM -0600, Benjamin Marzinski wrote:
> In dm_sm_metadata_create we temporarily change the dm_space_map
> operations from ops, whose destroy function deallocates the
> sm_metadata, to bootstrap_ops, whose destroy function doesn't. If we
> fail in dm_ll_new_metadata or sm_ll_extend, we exit back to
> dm_tm_create_internal, which calls dm_sm_destroy with the intention
> of freeing the sm_metadata, but it doesn't.
>
> This patch sets the dm_space_map operations back to ops if
> dm_sm_metadata_create fails when it is set to bootstrap_ops.
>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
> drivers/md/persistent-data/dm-space-map-metadata.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
> index 7e44005..20557e2 100644
> --- a/drivers/md/persistent-data/dm-space-map-metadata.c
> +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
> @@ -775,17 +775,15 @@ int dm_sm_metadata_create(struct dm_space_map *sm,
> memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm));
>
> r = sm_ll_new_metadata(&smm->ll, tm);
> + if (!r) {
> + if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
> + nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
> + r = sm_ll_extend(&smm->ll, nr_blocks);
> + }
> + memcpy(&smm->sm, &ops, sizeof(smm->sm));
> if (r)
> return r;
>
> - if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
> - nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
> - r = sm_ll_extend(&smm->ll, nr_blocks);
> - if (r)
> - return r;
> -
> - memcpy(&smm->sm, &ops, sizeof(smm->sm));
> -
> /*
> * Now we need to update the newly created data structures with the
> * allocated blocks that they were built from.
> --
> 2.1.0
>
next prev parent reply other threads:[~2016-12-01 10:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 23:56 [PATCH] dm-persistent-data: free sm_metadata on failed create Benjamin Marzinski
2016-12-01 10:58 ` Edward Thornber [this message]
2016-12-01 16:41 ` Mike Snitzer
2016-12-02 11:45 ` Edward Thornber
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=20161201105810.GD5643@roamer.bos.redhat.com \
--to=thornber@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.