[Devel] [PATCH RHEL7 COMMIT] ploop: push_backup: factor out destroy

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 23 02:02:12 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.5
------>
commit f43eec3cb0353ae5d9ba2910eb681a5c8a4f5d40
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Mon May 23 13:02:12 2016 +0400

    ploop: push_backup: factor out destroy
    
    Patchset description:
    
    ploop: implement push_backup auto destroy
    
    If backup tool dies or is killed, we cannot continue push_backup anyway
    (because next instance of backup tool runtime won't know which blocks to
    push_backup). So, it's useless to keep in-kernel push_backup state after
    userspace part disappeared.
    
    The patch set implements auto-destroy: ploop detects when userspace goes
    away, then aborts and releases in-kernel push_backup.
    
    Maxim Patlasov (2):
          ploop: push_backup: factor out destroy
          ploop: push_backup: implement auto destroy
    
    khorenko@:
    Note1: When more than one user keeps ploop block device opened, dying backup
    tool doesn't trigger auto destroy. Read: in case the CT is running, dying
    backup tool doesn't trigger auto destroy.
    
    Note2: we don't implement detection of dying backup tool by comparing the pid
    of process starting push_backup with the pid of process closing ploop block
    device (because last __fput may happen later, asynchronously from last
    close(2), and as backup tool uses AIO, chances last close() is called from
    userspace context are really low).
    
    So we implement push backup destroy in a way when another userspace process (dispatcher?) monitors backup tool state and does appropriate cleanup if needed.
    
    This patchset - basic check and autodestroy on ploop_release() - is just an
    extra safe check: in case userspace monitoring and destroy funtionality fails
    this will help us to free resources.
    
    ===========================
    This patch description:
    
    The patch makes minor code rearrangement. No logic changed. New function
    ploop_pb_destroy() will be used by the next patch.
    
    https://jira.sw.ru/browse/PSBM-45000
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/dev.c         | 13 +------------
 drivers/block/ploop/push_backup.c | 22 ++++++++++++++++++++++
 drivers/block/ploop/push_backup.h |  2 ++
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index da35c5c..958d510 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4677,18 +4677,7 @@ static int ploop_push_backup_stop(struct ploop_device *plo, unsigned long arg)
 		return -EINVAL;
 	}
 
-	if (!test_and_clear_bit(PLOOP_S_PUSH_BACKUP, &plo->state))
-		return -EINVAL;
-
-	BUG_ON (!pbd);
-	ctl.status = ploop_pb_stop(pbd);
-
-	ploop_quiesce(plo);
-	ploop_pb_fini(plo->pbd);
-	plo->maintenance_type = PLOOP_MNTN_OFF;
-	ploop_relax(plo);
-
-	return 0;
+	return ploop_pb_destroy(plo, &ctl.status);
 }
 
 static int ploop_ioctl(struct block_device *bdev, fmode_t fmode, unsigned int cmd,
diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 90172e4..3c4a11a 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -647,3 +647,25 @@ void ploop_pb_put_reported(struct ploop_pushbackup_desc *pbd,
 		spin_unlock_irq(&plo->lock);
 	}
 }
+
+int ploop_pb_destroy(struct ploop_device *plo, __u32 *status)
+{
+	struct ploop_pushbackup_desc *pbd = plo->pbd;
+	unsigned long ret;
+
+	if (!test_and_clear_bit(PLOOP_S_PUSH_BACKUP, &plo->state))
+		return -EINVAL;
+
+	BUG_ON (!pbd);
+	ret = ploop_pb_stop(pbd);
+
+	if (status)
+		*status = ret;
+
+	ploop_quiesce(plo);
+	ploop_pb_fini(plo->pbd);
+	plo->maintenance_type = PLOOP_MNTN_OFF;
+	ploop_relax(plo);
+
+	return 0;
+}
diff --git a/drivers/block/ploop/push_backup.h b/drivers/block/ploop/push_backup.h
index cc4b16e..1a8636a 100644
--- a/drivers/block/ploop/push_backup.h
+++ b/drivers/block/ploop/push_backup.h
@@ -18,3 +18,5 @@ bool ploop_pb_check_bit(struct ploop_pushbackup_desc *pbd, cluster_t clu);
 
 int ploop_pb_preq_add_pending(struct ploop_pushbackup_desc *pbd,
 			       struct ploop_request *preq);
+
+int ploop_pb_destroy(struct ploop_device *plo, __u32 *status);


More information about the Devel mailing list