[Devel] [PATCH RHEL8 COMMIT] ploop: Close race in ploop_flip_upper_deltas()
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jun 17 19:03:23 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.44
------>
commit 86f8bbf7fb0d5f4a0ef00e53a3ea137281ebbf35
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Thu Jun 17 19:03:22 2021 +0300
ploop: Close race in ploop_flip_upper_deltas()
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
ploop: Freeze WRITE on -ENOSPC on host
Suspend WRITEs in case of host's fs returns -ENOSPC.
https://jira.sw.ru/browse/PSBM-127225
Kirill Tkhai (5):
ploop: Add check of htable is empty on .dtr
ploop: Rename delayed_pios into suspended_pios
ploop: Remove unused define and comment
ploop: Close race in ploop_flip_upper_deltas()
ploop: Freeze on ENOSPC and notify userspace via dm event
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 3 +--
drivers/md/dm-ploop-target.c | 34 ++++++++++++++++++++++++++++++++++
drivers/md/dm-ploop.h | 2 ++
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 38b0ad40815e..2afe909171d8 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1153,10 +1153,9 @@ static int ploop_set_noresume(struct ploop *ploop, char *mode)
static int ploop_flip_upper_deltas(struct ploop *ploop)
{
- struct dm_target *ti = ploop->ti;
struct file *file;
- if (!dm_suspended(ti) || !ploop->noresume || ploop->maintaince)
+ if (!ploop->suspended || !ploop->noresume || ploop->maintaince)
return -EBUSY;
if (ploop_is_ro(ploop))
return -EROFS;
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 848e099d03a7..da241509af3b 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -411,6 +411,25 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
read_unlock_irq(&ploop->bat_rwlock);
}
+static void ploop_set_suspended(struct dm_target *ti, bool suspended)
+{
+ struct ploop *ploop = ti->private;
+
+ down_read(&ploop->ctl_rwsem);
+ ploop->suspended = suspended;
+ up_read(&ploop->ctl_rwsem);
+}
+
+static void ploop_presuspend(struct dm_target *ti)
+{
+}
+static void ploop_presuspend_undo(struct dm_target *ti)
+{
+}
+static void ploop_postsuspend(struct dm_target *ti)
+{
+ ploop_set_suspended(ti, true);
+}
static int ploop_preresume(struct dm_target *ti)
{
struct ploop *ploop = ti->private;
@@ -420,8 +439,19 @@ static int ploop_preresume(struct dm_target *ti)
if (ploop->noresume)
ret = -EAGAIN;
up_read(&ploop->ctl_rwsem);
+
+ if (ret == 0) {
+ /*
+ * We are singleton target. There will be
+ * no more reasons to break resume.
+ */
+ ploop_set_suspended(ti, false);
+ }
return ret;
}
+static void ploop_resume(struct dm_target *ti)
+{
+}
/*----------------------------------------------------------------*/
@@ -434,7 +464,11 @@ static struct target_type ploop_target = {
.dtr = ploop_dtr,
.message = ploop_message,
.io_hints = ploop_io_hints,
+ .presuspend = ploop_presuspend,
+ .presuspend_undo = ploop_presuspend_undo,
+ .postsuspend = ploop_postsuspend,
.preresume = ploop_preresume,
+ .resume = ploop_resume,
.clone_and_map_rq = ploop_clone_and_map,
.status = ploop_status,
};
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index d0f1493e12e6..143060d6cadf 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -185,6 +185,8 @@ struct ploop {
/* Resume is prohibited */
bool noresume;
+ /* Device is suspended */
+ bool suspended;
/* Maintaince in process */
bool maintaince;
More information about the Devel
mailing list