linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] null_blk: add helper for deleting the nullb_list
@ 2020-07-01  4:26 Chaitanya Kulkarni
  2020-07-01  7:26 ` Johannes Thumshirn
  0 siblings, 1 reply; 7+ messages in thread
From: Chaitanya Kulkarni @ 2020-07-01  4:26 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Chaitanya Kulkarni

The nullb_list is destroyed when error occurs in the null_init() and
when removing the module in null_exit(). The identical code is repeated
in those functions which can be a part of helper function. This also
removes the extra variable struct nullb *nullb in the both functions.
---
 drivers/block/null_blk_main.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 82259242b9b5..870290f686ae 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1859,11 +1859,23 @@ static int null_add_dev(struct nullb_device *dev)
 	return rv;
 }
 
+static void null_delete_nullb_list(void)
+{
+	struct nullb_device *dev;
+	struct nullb *nullb;
+
+	while (!list_empty(&nullb_list)) {
+		nullb = list_entry(nullb_list.next, struct nullb, list);
+		dev = nullb->dev;
+		null_del_dev(nullb);
+		null_free_dev(dev);
+	}
+}
+
 static int __init null_init(void)
 {
 	int ret = 0;
 	unsigned int i;
-	struct nullb *nullb;
 	struct nullb_device *dev;
 
 	if (g_bs > PAGE_SIZE) {
@@ -1930,12 +1942,7 @@ static int __init null_init(void)
 	return 0;
 
 err_dev:
-	while (!list_empty(&nullb_list)) {
-		nullb = list_entry(nullb_list.next, struct nullb, list);
-		dev = nullb->dev;
-		null_del_dev(nullb);
-		null_free_dev(dev);
-	}
+	null_delete_nullb_list();
 	unregister_blkdev(null_major, "nullb");
 err_conf:
 	configfs_unregister_subsystem(&nullb_subsys);
@@ -1947,21 +1954,12 @@ static int __init null_init(void)
 
 static void __exit null_exit(void)
 {
-	struct nullb *nullb;
-
 	configfs_unregister_subsystem(&nullb_subsys);
 
 	unregister_blkdev(null_major, "nullb");
 
 	mutex_lock(&lock);
-	while (!list_empty(&nullb_list)) {
-		struct nullb_device *dev;
-
-		nullb = list_entry(nullb_list.next, struct nullb, list);
-		dev = nullb->dev;
-		null_del_dev(nullb);
-		null_free_dev(dev);
-	}
+	null_delete_nullb_list();
 	mutex_unlock(&lock);
 
 	if (g_queue_mode == NULL_Q_MQ && shared_tags)
-- 
2.26.0


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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01  4:26 [PATCH] null_blk: add helper for deleting the nullb_list Chaitanya Kulkarni
@ 2020-07-01  7:26 ` Johannes Thumshirn
  2020-07-01 18:45   ` Chaitanya Kulkarni
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Thumshirn @ 2020-07-01  7:26 UTC (permalink / raw)
  To: Chaitanya Kulkarni, axboe; +Cc: linux-block

Looks good
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01  7:26 ` Johannes Thumshirn
@ 2020-07-01 18:45   ` Chaitanya Kulkarni
  2020-07-01 19:08     ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Chaitanya Kulkarni @ 2020-07-01 18:45 UTC (permalink / raw)
  To: axboe; +Cc: Johannes Thumshirn, linux-block

Jens,

On 7/1/20 12:26 AM, Johannes Thumshirn wrote:
> Looks good
> Reviewed-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
> 
Can we add this ?

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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01 18:45   ` Chaitanya Kulkarni
@ 2020-07-01 19:08     ` Jens Axboe
  2020-07-01 21:38       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2020-07-01 19:08 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: Johannes Thumshirn, linux-block

On 7/1/20 12:45 PM, Chaitanya Kulkarni wrote:
> Jens,
> 
> On 7/1/20 12:26 AM, Johannes Thumshirn wrote:
>> Looks good
>> Reviewed-by: Johannes Thumshirn<johannes.thumshirn@wdc.com>
>>
> Can we add this ?

Please don't ping me for something trivial just a day after posting
it. I'll queue it up, but it's not like this is a stop everything
and get it in kind of moment.

-- 
Jens Axboe


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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01 19:08     ` Jens Axboe
@ 2020-07-01 21:38       ` Chaitanya Kulkarni
  2020-07-01 21:46         ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Chaitanya Kulkarni @ 2020-07-01 21:38 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Johannes Thumshirn, linux-block

On 7/1/20 12:08 PM, Jens Axboe wrote:
>> Can we add this ?
> Please don't ping me for something trivial just a day after posting
> it. I'll queue it up, but it's not like this is a stop everything
> and get it in kind of moment.

Okay I'll keep in mind unless it is stopping something important.

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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01 21:38       ` Chaitanya Kulkarni
@ 2020-07-01 21:46         ` Jens Axboe
  2020-07-01 23:39           ` Chaitanya Kulkarni
  0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2020-07-01 21:46 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: Johannes Thumshirn, linux-block

On 7/1/20 3:38 PM, Chaitanya Kulkarni wrote:
> On 7/1/20 12:08 PM, Jens Axboe wrote:
>>> Can we add this ?
>> Please don't ping me for something trivial just a day after posting
>> it. I'll queue it up, but it's not like this is a stop everything
>> and get it in kind of moment.
> 
> Okay I'll keep in mind unless it is stopping something important.

You also missed a signed-off-by line, so I can't commit it as-is.

-- 
Jens Axboe


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

* Re: [PATCH] null_blk: add helper for deleting the nullb_list
  2020-07-01 21:46         ` Jens Axboe
@ 2020-07-01 23:39           ` Chaitanya Kulkarni
  0 siblings, 0 replies; 7+ messages in thread
From: Chaitanya Kulkarni @ 2020-07-01 23:39 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Johannes Thumshirn, linux-block

On 7/1/20 2:46 PM, Jens Axboe wrote:
> On 7/1/20 3:38 PM, Chaitanya Kulkarni wrote:
>> On 7/1/20 12:08 PM, Jens Axboe wrote:
>>>> Can we add this ?
>>> Please don't ping me for something trivial just a day after posting
>>> it. I'll queue it up, but it's not like this is a stop everything
>>> and get it in kind of moment.
>>
>> Okay I'll keep in mind unless it is stopping something important.
> 
> You also missed a signed-off-by line, so I can't commit it as-is.
> 

Let me send V2 with reviewed-by Johannes tag and sign-off.

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

end of thread, other threads:[~2020-07-01 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  4:26 [PATCH] null_blk: add helper for deleting the nullb_list Chaitanya Kulkarni
2020-07-01  7:26 ` Johannes Thumshirn
2020-07-01 18:45   ` Chaitanya Kulkarni
2020-07-01 19:08     ` Jens Axboe
2020-07-01 21:38       ` Chaitanya Kulkarni
2020-07-01 21:46         ` Jens Axboe
2020-07-01 23:39           ` Chaitanya Kulkarni

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).