[Devel] [PATCH RHEL8 COMMIT] ploop: Sleepable push_backup_read
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Oct 25 16:52:35 MSK 2019
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 9c8c97ee9860292e3784e065661467bf578611ca
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Oct 25 16:52:33 2019 +0300
ploop: Sleepable push_backup_read
Userspace calls this in separate thread and wants
it is sleepable.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 7 ++++---
drivers/md/dm-ploop-map.c | 6 +++++-
drivers/md/dm-ploop.h | 1 +
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 0aa643d9c9fa..d329b5d62455 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1291,6 +1291,7 @@ static struct push_backup *ploop_alloc_pb(struct ploop *ploop, char *uuid)
if (!pb)
return NULL;
snprintf(pb->uuid, sizeof(pb->uuid), "%s", uuid);
+ init_waitqueue_head(&pb->wq);
INIT_LIST_HEAD(&pb->pending);
pb->rb_root = RB_ROOT;
@@ -1444,13 +1445,13 @@ static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
return -EINVAL;
if (!pb->alive)
return -ESTALE;
+ 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 (!h) {
- result[0] = '\0';
+ if (WARN_ON_ONCE(!h))
goto unlock;
- }
list_del_init(&h->list);
left = right = h->cluster;
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 0fad19c69fa8..13cb5c9e2f04 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -963,8 +963,8 @@ static bool postpone_if_required_for_backup(struct ploop *ploop,
struct bio *bio, unsigned int cluster)
{
struct push_backup *pb = ploop->pb;
+ bool first, queue_timer = false;
struct dm_ploop_endio_hook *h;
- bool queue_timer = false;
if (likely(!pb || !pb->alive))
return false;
@@ -992,9 +992,13 @@ static bool postpone_if_required_for_backup(struct ploop *ploop,
h = bio_to_endio_hook(bio);
link_endio_hook(ploop, h, &pb->rb_root, cluster, true);
+ first = list_empty(&pb->pending);
list_add_tail(&h->list, &pb->pending);
spin_unlock_irq(&ploop->pb_lock);
+ if (first)
+ wake_up_interruptible(&pb->wq);
+
if (queue_timer)
mod_timer(&pb->deadline_timer, BACKUP_DEADLINE * HZ + 1);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 1e1ab8ba476e..fc58e1081a78 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -147,6 +147,7 @@ struct push_backup {
/* This tree is for looking for delayed bio by cluster */
struct rb_root rb_root;
+ struct wait_queue_head wq;
struct list_head pending;
};
More information about the Devel
mailing list