Skip to content

Commit 901aeda

Browse files
Jakob-Koschelaxboe
authored andcommitted
drbd: remove usage of list iterator variable after loop
In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or skip the iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Link: https://lore.kernel.org/r/20220331220349.885126-1-jakobkoschel@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6d35d04 commit 901aeda

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/block/drbd/drbd_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
171171
unsigned int set_size)
172172
{
173173
struct drbd_request *r;
174-
struct drbd_request *req = NULL;
174+
struct drbd_request *req = NULL, *tmp = NULL;
175175
int expect_epoch = 0;
176176
int expect_size = 0;
177177

@@ -225,8 +225,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
225225
* to catch requests being barrier-acked "unexpectedly".
226226
* It usually should find the same req again, or some READ preceding it. */
227227
list_for_each_entry(req, &connection->transfer_log, tl_requests)
228-
if (req->epoch == expect_epoch)
228+
if (req->epoch == expect_epoch) {
229+
tmp = req;
229230
break;
231+
}
232+
req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests);
230233
list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) {
231234
if (req->epoch != expect_epoch)
232235
break;

0 commit comments

Comments
 (0)