[Devel] [PATCH rh7 1/2] ploop: push_backup: factor out destroy

Maxim Patlasov mpatlasov at virtuozzo.com
Tue May 10 16:15:40 PDT 2016


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 6058449..a560734 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4687,18 +4687,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 10fd55a..50b776c 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -567,3 +567,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 476ac53..cfb1138 100644
--- a/drivers/block/ploop/push_backup.h
+++ b/drivers/block/ploop/push_backup.h
@@ -17,3 +17,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