[RHEL8,COMMIT] ploop: Make ploop_push_backup_read() not warn in case of two threads call it

Submitted by Konstantin Khorenko on Oct. 25, 2019, 2:24 p.m.

Details

Message ID 201910251424.x9PEOvEs005031@finist_co8.work.ct
State New
Series "ploop: Make ploop_push_backup_read() not warn in case of two threads call it"
Headers show

Commit Message

Konstantin Khorenko Oct. 25, 2019, 2:24 p.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.3
------>
commit 56b830960b730e0d0da7372dee9c10563310232e
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Oct 25 17:24:57 2019 +0300

    ploop: Make ploop_push_backup_read() not warn in case of two threads call it
    
    In case of parallel thread picked h up, the list may be empty.
    Do not warn in this case.
    
    Fixes: 9c8c97ee9860 ("ploop: Sleepable push_backup_read")
    Reported-by: Konstantin Khorenko <khorenko@virtuozzo.com>
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 145dabbac7d6..c45c2106c387 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1445,13 +1445,16 @@  static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
 		return -EINVAL;
 	if (!pb->alive)
 		return -ESTALE;
+again:
 	if (wait_event_interruptible(pb->wq, !list_empty_careful(&pb->pending)))
 		return -EINTR;
 
 	spin_lock_irq(&ploop->pb_lock);
 	h = orig_h = list_first_entry_or_null(&pb->pending, typeof(*h), list);
-	if (WARN_ON_ONCE(!h))
-		goto unlock;
+	if (unlikely(!h)) {
+		spin_unlock_irq(&ploop->pb_lock);
+		goto again;
+	}
 	list_del_init(&h->list);
 
 	left = right = h->cluster;
@@ -1473,7 +1476,6 @@  static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
 	}
 
 	DMEMIT("%u:%u", left, right - left + 1);
-unlock:
 	spin_unlock_irq(&ploop->pb_lock);
 	return ret;
 }