Merge tag 'for-5.18/drivers-2022-04-01' of git://git.kernel.dk/linux-block
[linux-block.git] / drivers / block / drbd / drbd_main.c
index 96881d5babd9e1bb356db1890fb9af1f55e2cb8f..9676a1d214bc5d1d31b5c9fb4958c1cae406f1c3 100644 (file)
@@ -171,7 +171,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
                unsigned int set_size)
 {
        struct drbd_request *r;
-       struct drbd_request *req = NULL;
+       struct drbd_request *req = NULL, *tmp = NULL;
        int expect_epoch = 0;
        int expect_size = 0;
 
@@ -225,8 +225,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
         * to catch requests being barrier-acked "unexpectedly".
         * It usually should find the same req again, or some READ preceding it. */
        list_for_each_entry(req, &connection->transfer_log, tl_requests)
-               if (req->epoch == expect_epoch)
+               if (req->epoch == expect_epoch) {
+                       tmp = req;
                        break;
+               }
+       req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests);
        list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) {
                if (req->epoch != expect_epoch)
                        break;