linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
@ 2017-05-12  0:35 Byungchul Park
  2017-06-02  2:08 ` Byungchul Park
  0 siblings, 1 reply; 12+ messages in thread
From: Byungchul Park @ 2017-05-12  0:35 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel, kernel-team

Although llist provides proper APIs, they are not used. Make them used.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 drivers/md/bcache/closure.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index 864e673..1841d03 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
 void __closure_wake_up(struct closure_waitlist *wait_list)
 {
 	struct llist_node *list;
-	struct closure *cl;
+	struct closure *cl, *t;
 	struct llist_node *reverse = NULL;
 
 	list = llist_del_all(&wait_list->list);
 
 	/* We first reverse the list to preserve FIFO ordering and fairness */
-
-	while (list) {
-		struct llist_node *t = list;
-		list = llist_next(list);
-
-		t->next = reverse;
-		reverse = t;
-	}
+	reverse = llist_reverse_order(list);
 
 	/* Then do the wakeups */
-
-	while (reverse) {
-		cl = container_of(reverse, struct closure, list);
-		reverse = llist_next(reverse);
-
+	llist_for_each_entry_safe(cl, t, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
-- 
1.9.1

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-05-12  0:35 [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API Byungchul Park
@ 2017-06-02  2:08 ` Byungchul Park
  2017-06-13  0:39   ` Byungchul Park
  0 siblings, 1 reply; 12+ messages in thread
From: Byungchul Park @ 2017-06-02  2:08 UTC (permalink / raw)
  To: axboe, axboe; +Cc: linux-kernel, kernel-team

On Fri, May 12, 2017 at 09:35:02AM +0900, Byungchul Park wrote:
> Although llist provides proper APIs, they are not used. Make them used.

+to axboe@kernel.dk

I didn't know your e-mail address has been changed.
Could you give your opinion about this patch?

> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
>  drivers/md/bcache/closure.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
> index 864e673..1841d03 100644
> --- a/drivers/md/bcache/closure.c
> +++ b/drivers/md/bcache/closure.c
> @@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
>  void __closure_wake_up(struct closure_waitlist *wait_list)
>  {
>  	struct llist_node *list;
> -	struct closure *cl;
> +	struct closure *cl, *t;
>  	struct llist_node *reverse = NULL;
>  
>  	list = llist_del_all(&wait_list->list);
>  
>  	/* We first reverse the list to preserve FIFO ordering and fairness */
> -
> -	while (list) {
> -		struct llist_node *t = list;
> -		list = llist_next(list);
> -
> -		t->next = reverse;
> -		reverse = t;
> -	}
> +	reverse = llist_reverse_order(list);
>  
>  	/* Then do the wakeups */
> -
> -	while (reverse) {
> -		cl = container_of(reverse, struct closure, list);
> -		reverse = llist_next(reverse);
> -
> +	llist_for_each_entry_safe(cl, t, reverse, list) {
>  		closure_set_waiting(cl, 0);
>  		closure_sub(cl, CLOSURE_WAITING + 1);
>  	}
> -- 
> 1.9.1

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-06-02  2:08 ` Byungchul Park
@ 2017-06-13  0:39   ` Byungchul Park
  0 siblings, 0 replies; 12+ messages in thread
From: Byungchul Park @ 2017-06-13  0:39 UTC (permalink / raw)
  To: axboe, axboe; +Cc: linux-kernel, kernel-team

On Fri, Jun 02, 2017 at 11:08:48AM +0900, Byungchul Park wrote:
> On Fri, May 12, 2017 at 09:35:02AM +0900, Byungchul Park wrote:
> > Although llist provides proper APIs, they are not used. Make them used.
> 
> +to axboe@kernel.dk
> 
> I didn't know your e-mail address has been changed.
> Could you give your opinion about this patch?

I am sorry if I sent the patch to a wrong person. But otherwise, it
would be appriciated if you give your opinions on it, or let me know
the right person.

Thank you,
Byungchul

> 
> > Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> > ---
> >  drivers/md/bcache/closure.c | 17 +++--------------
> >  1 file changed, 3 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
> > index 864e673..1841d03 100644
> > --- a/drivers/md/bcache/closure.c
> > +++ b/drivers/md/bcache/closure.c
> > @@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
> >  void __closure_wake_up(struct closure_waitlist *wait_list)
> >  {
> >  	struct llist_node *list;
> > -	struct closure *cl;
> > +	struct closure *cl, *t;
> >  	struct llist_node *reverse = NULL;
> >  
> >  	list = llist_del_all(&wait_list->list);
> >  
> >  	/* We first reverse the list to preserve FIFO ordering and fairness */
> > -
> > -	while (list) {
> > -		struct llist_node *t = list;
> > -		list = llist_next(list);
> > -
> > -		t->next = reverse;
> > -		reverse = t;
> > -	}
> > +	reverse = llist_reverse_order(list);
> >  
> >  	/* Then do the wakeups */
> > -
> > -	while (reverse) {
> > -		cl = container_of(reverse, struct closure, list);
> > -		reverse = llist_next(reverse);
> > -
> > +	llist_for_each_entry_safe(cl, t, reverse, list) {
> >  		closure_set_waiting(cl, 0);
> >  		closure_sub(cl, CLOSURE_WAITING + 1);
> >  	}
> > -- 
> > 1.9.1

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-09  6:39         ` Nikolay Borisov
@ 2017-08-09  6:42           ` Byungchul Park
  0 siblings, 0 replies; 12+ messages in thread
From: Byungchul Park @ 2017-08-09  6:42 UTC (permalink / raw)
  To: Nikolay Borisov
  Cc: Coly Li, kent.overstreet, shli, linux-bcache, linux-raid,
	linux-kernel, kernel-team

On Wed, Aug 09, 2017 at 09:39:09AM +0300, Nikolay Borisov wrote:
> 
> 
> On  8.08.2017 09:00, Byungchul Park wrote:
> > On Tue, Aug 08, 2017 at 01:28:39PM +0800, Coly Li wrote:
> >>>>> +	llist_for_each_entry_safe(cl, t, reverse, list) {
> >>>>
> >>>> Just wondering why not using llist_for_each_entry(), or you use the
> >>>> _safe version on purpose ?
> >>>
> >>> If I use llist_for_each_entry(), then it would change the original
> >>> behavior. Is it ok?
> 
> Generally, _safe versions of list primitives is used when you are going
> to perform removal in the iteration. I haven't looked at the code in
> bcache but if it's removing entries from the list then _safe version is
> required. If you are only iterating - then non-safe version is fine.

Thank you~ :)

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-08  6:00       ` Byungchul Park
  2017-08-08  6:50         ` Coly Li
@ 2017-08-09  6:39         ` Nikolay Borisov
  2017-08-09  6:42           ` Byungchul Park
  1 sibling, 1 reply; 12+ messages in thread
From: Nikolay Borisov @ 2017-08-09  6:39 UTC (permalink / raw)
  To: Byungchul Park, Coly Li
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team



On  8.08.2017 09:00, Byungchul Park wrote:
> On Tue, Aug 08, 2017 at 01:28:39PM +0800, Coly Li wrote:
>>>>> +	llist_for_each_entry_safe(cl, t, reverse, list) {
>>>>
>>>> Just wondering why not using llist_for_each_entry(), or you use the
>>>> _safe version on purpose ?
>>>
>>> If I use llist_for_each_entry(), then it would change the original
>>> behavior. Is it ok?

Generally, _safe versions of list primitives is used when you are going
to perform removal in the iteration. I haven't looked at the code in
bcache but if it's removing entries from the list then _safe version is
required. If you are only iterating - then non-safe version is fine.

>>>
>>
>> I feel llist_for_each_entry() keeps the original behavior, and variable
> 
> Ah.. I see. Then.. Can I change it into non-safe version? Is it still ok
> with non-safe one? I will change it at the next spin, if yes.
> 
>> 't' can be removed. Anyway, either llist_for_each_entry() or
>> llist_for_each_entry_safe() works correctly and well here. Any one you
>> use is OK to me, thanks for your informative reply :-)
> 
> I rather appriciate it.
> 
> Thank you,
> Byungchul
> 

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-08  6:00       ` Byungchul Park
@ 2017-08-08  6:50         ` Coly Li
  2017-08-09  6:39         ` Nikolay Borisov
  1 sibling, 0 replies; 12+ messages in thread
From: Coly Li @ 2017-08-08  6:50 UTC (permalink / raw)
  To: Byungchul Park
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team

On 2017/8/8 下午2:00, Byungchul Park wrote:
> On Tue, Aug 08, 2017 at 01:28:39PM +0800, Coly Li wrote:
>>>>> +	llist_for_each_entry_safe(cl, t, reverse, list) {
>>>>
>>>> Just wondering why not using llist_for_each_entry(), or you use the
>>>> _safe version on purpose ?
>>>
>>> If I use llist_for_each_entry(), then it would change the original
>>> behavior. Is it ok?
>>>
>>
>> I feel llist_for_each_entry() keeps the original behavior, and variable
> 
> Ah.. I see. Then.. Can I change it into non-safe version? Is it still ok
> with non-safe one? I will change it at the next spin, if yes.
> 
>> 't' can be removed. Anyway, either llist_for_each_entry() or
>> llist_for_each_entry_safe() works correctly and well here. Any one you
>> use is OK to me, thanks for your informative reply :-)
> 
> I rather appriciate it.
> 

Yes, please. And you have my Acked-by :-)


-- 
Coly Li

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-08  5:28     ` Coly Li
@ 2017-08-08  6:00       ` Byungchul Park
  2017-08-08  6:50         ` Coly Li
  2017-08-09  6:39         ` Nikolay Borisov
  0 siblings, 2 replies; 12+ messages in thread
From: Byungchul Park @ 2017-08-08  6:00 UTC (permalink / raw)
  To: Coly Li
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team

On Tue, Aug 08, 2017 at 01:28:39PM +0800, Coly Li wrote:
> >>> +	llist_for_each_entry_safe(cl, t, reverse, list) {
> >>
> >> Just wondering why not using llist_for_each_entry(), or you use the
> >> _safe version on purpose ?
> > 
> > If I use llist_for_each_entry(), then it would change the original
> > behavior. Is it ok?
> > 
> 
> I feel llist_for_each_entry() keeps the original behavior, and variable

Ah.. I see. Then.. Can I change it into non-safe version? Is it still ok
with non-safe one? I will change it at the next spin, if yes.

> 't' can be removed. Anyway, either llist_for_each_entry() or
> llist_for_each_entry_safe() works correctly and well here. Any one you
> use is OK to me, thanks for your informative reply :-)

I rather appriciate it.

Thank you,
Byungchul

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-08  4:12   ` Byungchul Park
@ 2017-08-08  5:28     ` Coly Li
  2017-08-08  6:00       ` Byungchul Park
  0 siblings, 1 reply; 12+ messages in thread
From: Coly Li @ 2017-08-08  5:28 UTC (permalink / raw)
  To: Byungchul Park
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team

On 2017/8/8 下午12:12, Byungchul Park wrote:
> On Mon, Aug 07, 2017 at 06:18:35PM +0800, Coly Li wrote:
>> On 2017/8/7 下午4:38, Byungchul Park wrote:
>>> Although llist provides proper APIs, they are not used. Make them used.
>>>
>>> Signed-off-by: Byungchul Park <byungchul.park@lge.com
>> Only have a question about why not using llist_for_each_entry(), it's
> 
> Hello,
> 
> The reason is to keep the original logic unchanged. The logic already
> does as if it's the safe version against removal.
> 
>> still OK with llist_for_each_entry_safe(). The rested part is good to me.
>>
>> Acked-by: Coly Li <colyli@suse.de>
>>
>>> ---
>>>  drivers/md/bcache/closure.c | 17 +++--------------
>>>  1 file changed, 3 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
>>> index 864e673..1841d03 100644
>>> --- a/drivers/md/bcache/closure.c
>>> +++ b/drivers/md/bcache/closure.c
>>> @@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
>>>  void __closure_wake_up(struct closure_waitlist *wait_list)
>>>  {
>>>  	struct llist_node *list;
>>> -	struct closure *cl;
>>> +	struct closure *cl, *t;
>>>  	struct llist_node *reverse = NULL;
>>>  
>>>  	list = llist_del_all(&wait_list->list);
>>>  
>>>  	/* We first reverse the list to preserve FIFO ordering and fairness */
>>> -
>>> -	while (list) {
>>> -		struct llist_node *t = list;
>>> -		list = llist_next(list);
>>> -
>>> -		t->next = reverse;
>>> -		reverse = t;
>>> -	}
>>> +	reverse = llist_reverse_order(list);
>>>  
>>>  	/* Then do the wakeups */
>>> -
>>> -	while (reverse) {
>>> -		cl = container_of(reverse, struct closure, list);
>>> -		reverse = llist_next(reverse);
>>> -
>>> +	llist_for_each_entry_safe(cl, t, reverse, list) {
>>
>> Just wondering why not using llist_for_each_entry(), or you use the
>> _safe version on purpose ?
> 
> If I use llist_for_each_entry(), then it would change the original
> behavior. Is it ok?
> 

I feel llist_for_each_entry() keeps the original behavior, and variable
't' can be removed. Anyway, either llist_for_each_entry() or
llist_for_each_entry_safe() works correctly and well here. Any one you
use is OK to me, thanks for your informative reply :-)



-- 
Coly Li

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-07 10:18 ` Coly Li
@ 2017-08-08  4:12   ` Byungchul Park
  2017-08-08  5:28     ` Coly Li
  0 siblings, 1 reply; 12+ messages in thread
From: Byungchul Park @ 2017-08-08  4:12 UTC (permalink / raw)
  To: Coly Li
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team

On Mon, Aug 07, 2017 at 06:18:35PM +0800, Coly Li wrote:
> On 2017/8/7 下午4:38, Byungchul Park wrote:
> > Although llist provides proper APIs, they are not used. Make them used.
> > 
> > Signed-off-by: Byungchul Park <byungchul.park@lge.com
> Only have a question about why not using llist_for_each_entry(), it's

Hello,

The reason is to keep the original logic unchanged. The logic already
does as if it's the safe version against removal.

> still OK with llist_for_each_entry_safe(). The rested part is good to me.
> 
> Acked-by: Coly Li <colyli@suse.de>
> 
> > ---
> >  drivers/md/bcache/closure.c | 17 +++--------------
> >  1 file changed, 3 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
> > index 864e673..1841d03 100644
> > --- a/drivers/md/bcache/closure.c
> > +++ b/drivers/md/bcache/closure.c
> > @@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
> >  void __closure_wake_up(struct closure_waitlist *wait_list)
> >  {
> >  	struct llist_node *list;
> > -	struct closure *cl;
> > +	struct closure *cl, *t;
> >  	struct llist_node *reverse = NULL;
> >  
> >  	list = llist_del_all(&wait_list->list);
> >  
> >  	/* We first reverse the list to preserve FIFO ordering and fairness */
> > -
> > -	while (list) {
> > -		struct llist_node *t = list;
> > -		list = llist_next(list);
> > -
> > -		t->next = reverse;
> > -		reverse = t;
> > -	}
> > +	reverse = llist_reverse_order(list);
> >  
> >  	/* Then do the wakeups */
> > -
> > -	while (reverse) {
> > -		cl = container_of(reverse, struct closure, list);
> > -		reverse = llist_next(reverse);
> > -
> > +	llist_for_each_entry_safe(cl, t, reverse, list) {
> 
> Just wondering why not using llist_for_each_entry(), or you use the
> _safe version on purpose ?

If I use llist_for_each_entry(), then it would change the original
behavior. Is it ok?

Thank you,
Byungchul

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

* Re: [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-08-07  8:38 Byungchul Park
@ 2017-08-07 10:18 ` Coly Li
  2017-08-08  4:12   ` Byungchul Park
  0 siblings, 1 reply; 12+ messages in thread
From: Coly Li @ 2017-08-07 10:18 UTC (permalink / raw)
  To: Byungchul Park
  Cc: kent.overstreet, shli, linux-bcache, linux-raid, linux-kernel,
	kernel-team

On 2017/8/7 下午4:38, Byungchul Park wrote:
> Although llist provides proper APIs, they are not used. Make them used.
> 
> Signed-off-by: Byungchul Park <byungchul.park@lge.com
Only have a question about why not using llist_for_each_entry(), it's
still OK with llist_for_each_entry_safe(). The rested part is good to me.

Acked-by: Coly Li <colyli@suse.de>

> ---
>  drivers/md/bcache/closure.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
> index 864e673..1841d03 100644
> --- a/drivers/md/bcache/closure.c
> +++ b/drivers/md/bcache/closure.c
> @@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
>  void __closure_wake_up(struct closure_waitlist *wait_list)
>  {
>  	struct llist_node *list;
> -	struct closure *cl;
> +	struct closure *cl, *t;
>  	struct llist_node *reverse = NULL;
>  
>  	list = llist_del_all(&wait_list->list);
>  
>  	/* We first reverse the list to preserve FIFO ordering and fairness */
> -
> -	while (list) {
> -		struct llist_node *t = list;
> -		list = llist_next(list);
> -
> -		t->next = reverse;
> -		reverse = t;
> -	}
> +	reverse = llist_reverse_order(list);
>  
>  	/* Then do the wakeups */
> -
> -	while (reverse) {
> -		cl = container_of(reverse, struct closure, list);
> -		reverse = llist_next(reverse);
> -
> +	llist_for_each_entry_safe(cl, t, reverse, list) {

Just wondering why not using llist_for_each_entry(), or you use the
_safe version on purpose ?


>  		closure_set_waiting(cl, 0);
>  		closure_sub(cl, CLOSURE_WAITING + 1);
>  	}
> 


-- 
Coly Li

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

* [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
@ 2017-08-07  8:38 Byungchul Park
  2017-08-07 10:18 ` Coly Li
  0 siblings, 1 reply; 12+ messages in thread
From: Byungchul Park @ 2017-08-07  8:38 UTC (permalink / raw)
  To: kent.overstreet, shli; +Cc: linux-bcache, linux-raid, linux-kernel, kernel-team

Although llist provides proper APIs, they are not used. Make them used.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 drivers/md/bcache/closure.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index 864e673..1841d03 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
 void __closure_wake_up(struct closure_waitlist *wait_list)
 {
 	struct llist_node *list;
-	struct closure *cl;
+	struct closure *cl, *t;
 	struct llist_node *reverse = NULL;
 
 	list = llist_del_all(&wait_list->list);
 
 	/* We first reverse the list to preserve FIFO ordering and fairness */
-
-	while (list) {
-		struct llist_node *t = list;
-		list = llist_next(list);
-
-		t->next = reverse;
-		reverse = t;
-	}
+	reverse = llist_reverse_order(list);
 
 	/* Then do the wakeups */
-
-	while (reverse) {
-		cl = container_of(reverse, struct closure, list);
-		reverse = llist_next(reverse);
-
+	llist_for_each_entry_safe(cl, t, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
-- 
1.9.1

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

* [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API
  2017-07-10  2:37 [RESEND PATCH] Don't reinvent the wheel but use existing llilst API Byungchul Park
@ 2017-07-10  2:37 ` Byungchul Park
  0 siblings, 0 replies; 12+ messages in thread
From: Byungchul Park @ 2017-07-10  2:37 UTC (permalink / raw)
  To: torvalds; +Cc: axboe, viro, linux-kernel, kernel-team

Although llist provides proper APIs, they are not used. Make them used.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 drivers/md/bcache/closure.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index 864e673..1841d03 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -64,27 +64,16 @@ void closure_put(struct closure *cl)
 void __closure_wake_up(struct closure_waitlist *wait_list)
 {
 	struct llist_node *list;
-	struct closure *cl;
+	struct closure *cl, *t;
 	struct llist_node *reverse = NULL;
 
 	list = llist_del_all(&wait_list->list);
 
 	/* We first reverse the list to preserve FIFO ordering and fairness */
-
-	while (list) {
-		struct llist_node *t = list;
-		list = llist_next(list);
-
-		t->next = reverse;
-		reverse = t;
-	}
+	reverse = llist_reverse_order(list);
 
 	/* Then do the wakeups */
-
-	while (reverse) {
-		cl = container_of(reverse, struct closure, list);
-		reverse = llist_next(reverse);
-
+	llist_for_each_entry_safe(cl, t, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
-- 
1.9.1

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

end of thread, other threads:[~2017-08-09  6:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12  0:35 [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API Byungchul Park
2017-06-02  2:08 ` Byungchul Park
2017-06-13  0:39   ` Byungchul Park
2017-07-10  2:37 [RESEND PATCH] Don't reinvent the wheel but use existing llilst API Byungchul Park
2017-07-10  2:37 ` [RESEND PATCH] bcache: Don't reinvent the wheel but use existing llist API Byungchul Park
2017-08-07  8:38 Byungchul Park
2017-08-07 10:18 ` Coly Li
2017-08-08  4:12   ` Byungchul Park
2017-08-08  5:28     ` Coly Li
2017-08-08  6:00       ` Byungchul Park
2017-08-08  6:50         ` Coly Li
2017-08-09  6:39         ` Nikolay Borisov
2017-08-09  6:42           ` Byungchul Park

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