All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] null_blk: Remove null block from list in error path
@ 2015-11-27 13:26 Minfei Huang
  2015-11-27 13:26 ` [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev Minfei Huang
  2015-12-09  5:21 ` [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
  0 siblings, 2 replies; 5+ messages in thread
From: Minfei Huang @ 2015-11-27 13:26 UTC (permalink / raw)
  To: axboe, m, akinobu.mita, rusty, keith.busch, mcgrof, krinkin.m.u
  Cc: linux-kernel, mhuang, Minfei Huang

To make consistent of null block list, we should remove enqueued null
block from the list before freeing it.

Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
---
 drivers/block/null_blk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ec99568..729ecd7 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -738,7 +738,7 @@ static int null_add_dev(void)
 		rv = nvm_register(nullb->q, nullb->disk_name,
 							&null_lnvm_dev_ops);
 		if (rv)
-			goto out_cleanup_blk_queue;
+			goto out_cleanup_blk_list;
 		goto done;
 	}
 
@@ -765,6 +765,10 @@ done:
 out_cleanup_lightnvm:
 	if (use_lightnvm)
 		nvm_unregister(nullb->disk_name);
+out_cleanup_blk_list:
+	mutex_lock(&lock);
+	list_del_init(&nullb->list);
+	mutex_unlock(&lock);
 out_cleanup_blk_queue:
 	blk_cleanup_queue(nullb->q);
 out_cleanup_tags:
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev
  2015-11-27 13:26 [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
@ 2015-11-27 13:26 ` Minfei Huang
  2015-12-14 11:43   ` Minfei Huang
  2015-12-09  5:21 ` [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
  1 sibling, 1 reply; 5+ messages in thread
From: Minfei Huang @ 2015-11-27 13:26 UTC (permalink / raw)
  To: axboe, m, akinobu.mita, rusty, keith.busch, mcgrof, krinkin.m.u
  Cc: linux-kernel, mhuang, Minfei Huang

If null block is a lightnvm device, it wouldn't need to allocate the
variant disk. So it is fine to separate the code for lightnvm and normal
device to use if/else.

Thus we don't never need the flag out_cleanup_lightnvm.

Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
---
 drivers/block/null_blk.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 729ecd7..7d5d2e7 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -739,32 +739,28 @@ static int null_add_dev(void)
 							&null_lnvm_dev_ops);
 		if (rv)
 			goto out_cleanup_blk_list;
-		goto done;
-	}
-
-	disk = nullb->disk = alloc_disk_node(1, home_node);
-	if (!disk) {
-		rv = -ENOMEM;
-		goto out_cleanup_lightnvm;
+	} else {
+		disk = nullb->disk = alloc_disk_node(1, home_node);
+		if (!disk) {
+			rv = -ENOMEM;
+			goto out_cleanup_blk_list;
+		}
+		size = gb * 1024 * 1024 * 1024ULL;
+		set_capacity(disk, size >> 9);
+
+		disk->flags |=
+			GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
+		disk->major		= null_major;
+		disk->first_minor	= nullb->index;
+		disk->fops		= &null_fops;
+		disk->private_data	= nullb;
+		disk->queue		= nullb->q;
+		strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
+
+		add_disk(disk);
 	}
-	size = gb * 1024 * 1024 * 1024ULL;
-	set_capacity(disk, size >> 9);
-
-	disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
-	disk->major		= null_major;
-	disk->first_minor	= nullb->index;
-	disk->fops		= &null_fops;
-	disk->private_data	= nullb;
-	disk->queue		= nullb->q;
-	strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
-
-	add_disk(disk);
-done:
 	return 0;
 
-out_cleanup_lightnvm:
-	if (use_lightnvm)
-		nvm_unregister(nullb->disk_name);
 out_cleanup_blk_list:
 	mutex_lock(&lock);
 	list_del_init(&nullb->list);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] null_blk: Remove null block from list in error path
  2015-11-27 13:26 [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
  2015-11-27 13:26 ` [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev Minfei Huang
@ 2015-12-09  5:21 ` Minfei Huang
  2015-12-09  8:14   ` Matias Bjørling
  1 sibling, 1 reply; 5+ messages in thread
From: Minfei Huang @ 2015-12-09  5:21 UTC (permalink / raw)
  To: Minfei Huang
  Cc: axboe, m, akinobu.mita, rusty, keith.busch, mcgrof, krinkin.m.u,
	linux-kernel

Ping.

Any comment is appreciate.

Thanks
Minfei

On 11/27/15 at 09:26pm, Minfei Huang wrote:
> To make consistent of null block list, we should remove enqueued null
> block from the list before freeing it.
> 
> Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
> ---
>  drivers/block/null_blk.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
> index ec99568..729ecd7 100644
> --- a/drivers/block/null_blk.c
> +++ b/drivers/block/null_blk.c
> @@ -738,7 +738,7 @@ static int null_add_dev(void)
>  		rv = nvm_register(nullb->q, nullb->disk_name,
>  							&null_lnvm_dev_ops);
>  		if (rv)
> -			goto out_cleanup_blk_queue;
> +			goto out_cleanup_blk_list;
>  		goto done;
>  	}
>  
> @@ -765,6 +765,10 @@ done:
>  out_cleanup_lightnvm:
>  	if (use_lightnvm)
>  		nvm_unregister(nullb->disk_name);
> +out_cleanup_blk_list:
> +	mutex_lock(&lock);
> +	list_del_init(&nullb->list);
> +	mutex_unlock(&lock);
>  out_cleanup_blk_queue:
>  	blk_cleanup_queue(nullb->q);
>  out_cleanup_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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] null_blk: Remove null block from list in error path
  2015-12-09  5:21 ` [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
@ 2015-12-09  8:14   ` Matias Bjørling
  0 siblings, 0 replies; 5+ messages in thread
From: Matias Bjørling @ 2015-12-09  8:14 UTC (permalink / raw)
  To: Minfei Huang, Minfei Huang
  Cc: axboe, akinobu.mita, rusty, keith.busch, mcgrof, krinkin.m.u,
	linux-kernel

On 12/09/2015 06:21 AM, Minfei Huang wrote:
> Ping.
>
> Any comment is appreciate.
>
> Thanks
> Minfei
>

That'll work. Thanks for fixing up my mistake.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev
  2015-11-27 13:26 ` [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev Minfei Huang
@ 2015-12-14 11:43   ` Minfei Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Minfei Huang @ 2015-12-14 11:43 UTC (permalink / raw)
  To: Minfei Huang
  Cc: axboe, m, akinobu.mita, rusty, keith.busch, mcgrof, krinkin.m.u,
	linux-kernel

Ping, Jens.

Could you have any idea about this cleanup patch?

Thanks
Minfei

On 11/27/15 at 09:26pm, Minfei Huang wrote:
> If null block is a lightnvm device, it wouldn't need to allocate the
> variant disk. So it is fine to separate the code for lightnvm and normal
> device to use if/else.
> 
> Thus we don't never need the flag out_cleanup_lightnvm.
> 
> Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
> ---
>  drivers/block/null_blk.c | 42 +++++++++++++++++++-----------------------
>  1 file changed, 19 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
> index 729ecd7..7d5d2e7 100644
> --- a/drivers/block/null_blk.c
> +++ b/drivers/block/null_blk.c
> @@ -739,32 +739,28 @@ static int null_add_dev(void)
>  							&null_lnvm_dev_ops);
>  		if (rv)
>  			goto out_cleanup_blk_list;
> -		goto done;
> -	}
> -
> -	disk = nullb->disk = alloc_disk_node(1, home_node);
> -	if (!disk) {
> -		rv = -ENOMEM;
> -		goto out_cleanup_lightnvm;
> +	} else {
> +		disk = nullb->disk = alloc_disk_node(1, home_node);
> +		if (!disk) {
> +			rv = -ENOMEM;
> +			goto out_cleanup_blk_list;
> +		}
> +		size = gb * 1024 * 1024 * 1024ULL;
> +		set_capacity(disk, size >> 9);
> +
> +		disk->flags |=
> +			GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
> +		disk->major		= null_major;
> +		disk->first_minor	= nullb->index;
> +		disk->fops		= &null_fops;
> +		disk->private_data	= nullb;
> +		disk->queue		= nullb->q;
> +		strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
> +
> +		add_disk(disk);
>  	}
> -	size = gb * 1024 * 1024 * 1024ULL;
> -	set_capacity(disk, size >> 9);
> -
> -	disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
> -	disk->major		= null_major;
> -	disk->first_minor	= nullb->index;
> -	disk->fops		= &null_fops;
> -	disk->private_data	= nullb;
> -	disk->queue		= nullb->q;
> -	strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
> -
> -	add_disk(disk);
> -done:
>  	return 0;
>  
> -out_cleanup_lightnvm:
> -	if (use_lightnvm)
> -		nvm_unregister(nullb->disk_name);
>  out_cleanup_blk_list:
>  	mutex_lock(&lock);
>  	list_del_init(&nullb->list);
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-14 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-27 13:26 [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
2015-11-27 13:26 ` [PATCH 2/2] null_blk: Do a cleanup for function null_add_dev Minfei Huang
2015-12-14 11:43   ` Minfei Huang
2015-12-09  5:21 ` [PATCH 1/2] null_blk: Remove null block from list in error path Minfei Huang
2015-12-09  8:14   ` Matias Bjørling

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.