Skip to contentSkip to conversation

bcache: Don't reinvent the wheel but use existing llist API

PATCH In review Byungchul Park 3 participants 6 messages Aug 11, 2017 – Sep 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 bcache: Don't reinvent the wheel but use existing llist API

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

---
 drivers/md/bcache/closure.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/md/bcache/closure.c +2 -13
index 864e673..7d5286b 100644
@@ -70,21 +70,10 @@ void __closure_wake_up(struct closure_waitlist *wait_list)
 	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(cl, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
Signature · 1 line
1.9.1
#1 lore raw
Quoted 1 line · Byungchul Park

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

Any opinions about this?

Quoted 37 lines
---
 drivers/md/bcache/closure.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/md/bcache/closure.c +2 -13
index 864e673..7d5286b 100644
@@ -70,21 +70,10 @@ void __closure_wake_up(struct closure_waitlist *wait_list)
 	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(cl, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
Signature · 1 line
1.9.1
#2 lore raw
Quoted 5 lines · Byungchul Park
Quoted 1 line · Byungchul Park

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

Any opinions about this?

The patch is good. If Eric has no time, I will take care of it later.

Thanks.

Coly

Quoted 37 lines
Quoted 37 lines
---
 drivers/md/bcache/closure.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/md/bcache/closure.c +2 -13
index 864e673..7d5286b 100644
@@ -70,21 +70,10 @@ void __closure_wake_up(struct closure_waitlist *wait_list)
 	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(cl, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
Signature · 1 line
1.9.1
#3 lore raw
Quoted 8 lines · Coly Li
Quoted 5 lines · Byungchul Park
Quoted 1 line · Byungchul Park

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

Any opinions about this?

The patch is good. If Eric has no time, I will take care of it later.

Hi, Coly

Thanks a lot. :)

#4 lore raw
In reply to Coly Li
Quoted 8 lines · Coly Li
Quoted 5 lines · Byungchul Park
Quoted 1 line · Byungchul Park

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

Any opinions about this?

The patch is good. If Eric has no time, I will take care of it later.

I would be appriciated if you take this at this window :)

Quoted 41 lines

Thanks.

Coly

Quoted 37 lines
Quoted 37 lines
---
 drivers/md/bcache/closure.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/md/bcache/closure.c +2 -13
index 864e673..7d5286b 100644
@@ -70,21 +70,10 @@ void __closure_wake_up(struct closure_waitlist *wait_list)
 	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(cl, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
Signature · 1 line
1.9.1
#5 lore raw
Quoted 11 lines · Byungchul Park
Quoted 8 lines · Coly Li
Quoted 5 lines · Byungchul Park
Quoted 1 line · Byungchul Park

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

Any opinions about this?

The patch is good. If Eric has no time, I will take care of it later.

I would be appriciated if you take this at this window :)

Sure, I am preparing a patch list to block maintainers which we are missed in last merge window, your patch is in the list.

It will be in one or two days from my side.

Coly

Quoted 42 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 drivers/md/bcache/closure.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/md/bcache/closure.c +1 -8
index 864e673..7d5286b 100644
@@ -70,21 +70,10 @@ void __closure_wake_up(struct closure_waitlist *wait_list)
 	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);
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/md/bcache/closure.c +0 -3
 	/* Then do the wakeups */
-
-	while (reverse) {
-		cl = container_of(reverse, struct closure, list);
Quoted 8 lines
Quoted 8 lines
drivers/md/bcache/closure.c +1 -2
-		reverse = llist_next(reverse);
-
+	llist_for_each_entry(cl, reverse, list) {
 		closure_set_waiting(cl, 0);
 		closure_sub(cl, CLOSURE_WAITING + 1);
 	}
Signature · 1 line
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html