mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Minfei Huang <mhuang@redhat.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Minfei Huang <mnfhuang@gmail.com>
Subject: Re: [PATCH] blk-mg-tag: Make tag's codeflow more reasonably during initializing
Date: Tue, 8 Dec 2015 14:15:03 +0800	[thread overview]
Message-ID: <20151208061503.GA32533@dhcp-128-25.nay.redhat.com> (raw)
In-Reply-To: <1448613468-11708-1-git-send-email-mhuang@redhat.com>

Ping.

Any comment is appreciate.

Thanks
Minfei

On 11/27/15 at 04:37pm, Minfei Huang wrote:
> From: Minfei Huang <mnfhuang@gmail.com>
> 
> It might be more reasonable to cleanup all of the allocations in same
> function, if there is a fatal. Thus we can make function more
> independency to export it.
> 
> For this patch, variant tag will be allocated in blk_mq_init_tags, and
> it will be freed in same function, if there is an error during
> initializing the tag.
> 
> What the blk_mq_init_bitmap_tags does is to allocate bitmap.
> 
> Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
> ---
>  block/blk-mq-tag.c | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index a07ca34..7a1d9a8 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -596,23 +596,24 @@ static void bt_free(struct blk_mq_bitmap_tags *bt)
>  	kfree(bt->bs);
>  }
>  
> -static struct blk_mq_tags *blk_mq_init_bitmap_tags(struct blk_mq_tags *tags,
> -						   int node, int alloc_policy)
> +static int blk_mq_init_bitmap_tags(struct blk_mq_tags *tags,
> +		int node, int alloc_policy)
>  {
> +	int ret = 0;
>  	unsigned int depth = tags->nr_tags - tags->nr_reserved_tags;
>  
>  	tags->alloc_policy = alloc_policy;
>  
> -	if (bt_alloc(&tags->bitmap_tags, depth, node, false))
> -		goto enomem;
> -	if (bt_alloc(&tags->breserved_tags, tags->nr_reserved_tags, node, true))
> -		goto enomem;
> +	ret = bt_alloc(&tags->bitmap_tags, depth, node, false);
> +	if (ret)
> +		goto out;
>  
> -	return tags;
> -enomem:
> -	bt_free(&tags->bitmap_tags);
> -	kfree(tags);
> -	return NULL;
> +	ret = bt_alloc(&tags->breserved_tags,
> +			tags->nr_reserved_tags, node, true);
> +	if (ret)
> +		bt_free(&tags->bitmap_tags);
> +out:
> +	return ret;
>  }
>  
>  struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
> @@ -638,7 +639,12 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
>  	tags->nr_tags = total_tags;
>  	tags->nr_reserved_tags = reserved_tags;
>  
> -	return blk_mq_init_bitmap_tags(tags, node, alloc_policy);
> +	if (blk_mq_init_bitmap_tags(tags, node, alloc_policy)) {
> +		kfree(tags);
> +		return NULL;
> +	}
> +
> +	return tags;
>  }
>  
>  void blk_mq_free_tags(struct blk_mq_tags *tags)
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      reply	other threads:[~2015-12-08  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  8:37 Minfei Huang
2015-12-08  6:15 ` Minfei Huang [this message]

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=20151208061503.GA32533@dhcp-128-25.nay.redhat.com \
    --to=mhuang@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mnfhuang@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®