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.52
------>
commit 56b798c6665d66f0879dfe468d8cc851b2fecbf3
Author: Kirill Tkhai <[email protected]>
Date:   Wed Jul 7 12:00:25 2021 +0300

    push_backup: Check suspended state more clearly
    
    Signed-off-by: Kirill Tkhai <[email protected]>
---
 drivers/md/dm-push-backup.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 0c212e31d949..59622efca008 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -32,6 +32,7 @@ struct push_backup {
        u64 nr_clus;
 
        bool alive;
+       bool suspended;
        void *ppb_map;
        u64 ppb_map_bits;
 
@@ -350,7 +351,7 @@ static int push_backup_start(struct push_backup *pb,
         * But this means userspace collects wrong backup. Warn it here.
         * Since the device is suspended, we do not care about inflight bios.
         */
-       if (!dm_suspended(pb->ti))
+       if (!pb->suspended)
                return -EBUSY;
        return setup_pb(pb, mask, timeout);
 }
@@ -591,6 +592,7 @@ static int pb_ctr(struct dm_target *ti, unsigned int argc, 
char **argv)
                return -ENOMEM;
        }
 
+       pb->suspended = true;
        spin_lock_init(&pb->lock);
        init_rwsem(&pb->ctl_rwsem);
        bio_list_init(&pb->deferred_bios);
@@ -644,7 +646,6 @@ static int pb_ctr(struct dm_target *ti, unsigned int argc, 
char **argv)
        ti->num_discard_bios = 1;
        ti->discards_supported = true;
        return 0;
-
 err:
        pb_destroy(pb);
        return ret;
@@ -689,7 +690,22 @@ static void pb_status(struct dm_target *ti, status_type_t 
type,
        spin_unlock_irq(&pb->lock);
 }
 
-/*----------------------------------------------------------------*/
+static void pb_set_suspended(struct dm_target *ti, bool suspended)
+{
+       struct push_backup *pb = ti->private;
+
+       down_write(&pb->ctl_rwsem);
+       pb->suspended = suspended;
+       up_write(&pb->ctl_rwsem);
+}
+static void pb_postsuspend(struct dm_target *ti)
+{
+        pb_set_suspended(ti, true);
+}
+static void pb_resume(struct dm_target *ti)
+{
+        pb_set_suspended(ti, false);
+}
 
 static struct target_type pb_target = {
        .name = "push_backup",
@@ -701,6 +717,8 @@ static struct target_type pb_target = {
        .map = pb_map,
        .message = pb_message,
        .iterate_devices = pb_iterate_devices,
+       .postsuspend = pb_postsuspend,
+       .resume = pb_resume,
        .status = pb_status,
 };
 
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to