From: Kaitao Cheng <[email protected]> A later change will make list_for_each_entry() cache the next element before entering the loop body. That is the desired behaviour for the common case, but this transfer log walk temporarily drops resource->req_lock and revalidates the cursor before continuing.
Keep the loop open-coded so the next request is derived after the body has completed and after the cursor has been adjusted. This preserves the existing traversal semantics and prepares the code for the list iterator update. Signed-off-by: Kaitao Cheng <[email protected]> --- drivers/block/drbd/drbd_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c index 12460b584bcb..e90cead90e9d 100644 --- a/drivers/block/drbd/drbd_debugfs.c +++ b/drivers/block/drbd/drbd_debugfs.c @@ -308,7 +308,9 @@ static void seq_print_resource_transfer_log_summary(struct seq_file *m, seq_puts(m, "n\tdevice\tvnr\t" RQ_HDR); spin_lock_irq(&resource->req_lock); - list_for_each_entry(req, &connection->transfer_log, tl_requests) { + for (req = list_first_entry(&connection->transfer_log, typeof(*req), tl_requests); + !list_entry_is_head(req, &connection->transfer_log, tl_requests); + req = list_next_entry(req, tl_requests)) { unsigned int tmp = 0; unsigned int s; ++count; -- 2.43.0
