[Devel] [PATCH rh7 v3 2/4] ploop: keep frozen block device pointer instead of super_block pointer

Andrey Ryabinin aryabinin at virtuozzo.com
Fri Aug 19 06:00:19 PDT 2016


For encrypted ploop we will need to know what block_device was frozen
in ploop_freeze(), so we could thaw() it. We don't need to store super_block,
because we sould be able to get it from frozen block device.

https://jira.sw.ru/browse/PSBM-50858

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/block/ploop/dev.c   | 13 +++++++------
 include/linux/ploop/ploop.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 453d36e..8ed402f 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4918,7 +4918,7 @@ static int ploop_push_backup_stop(struct ploop_device *plo, unsigned long arg)
 
 static int ploop_freeze(struct ploop_device *plo, struct block_device *bdev)
 {
-	struct super_block *sb = plo->sb;
+	struct super_block *sb;
 
 	if (!test_bit(PLOOP_S_RUNNING, &plo->state))
 		return -EINVAL;
@@ -4933,14 +4933,15 @@ static int ploop_freeze(struct ploop_device *plo, struct block_device *bdev)
 	if (sb && IS_ERR(sb))
 		return PTR_ERR(sb);
 
-	plo->sb = sb;
+	plo->frozen_bdev = bdev;
 	plo->freeze_state = PLOOP_F_FROZEN;
 	return 0;
 }
 
-static int ploop_thaw(struct ploop_device *plo, struct block_device *bdev)
+static int ploop_thaw(struct ploop_device *plo)
 {
-	struct super_block *sb = plo->sb;
+	struct block_device *bdev = plo->frozen_bdev;
+	struct super_block *sb = bdev->bd_super;
 	int err;
 
 	if (!test_bit(PLOOP_S_RUNNING, &plo->state))
@@ -4952,7 +4953,7 @@ static int ploop_thaw(struct ploop_device *plo, struct block_device *bdev)
 	if (plo->freeze_state == PLOOP_F_THAWING)
 		return -EBUSY;
 
-	plo->sb = NULL;
+	plo->frozen_bdev = NULL;
 	plo->freeze_state = PLOOP_F_THAWING;
 
 	mutex_unlock(&plo->ctl_mutex);
@@ -5086,7 +5087,7 @@ static int ploop_ioctl(struct block_device *bdev, fmode_t fmode, unsigned int cm
 		err = ploop_freeze(plo, bdev);
 		break;
 	case PLOOP_IOC_THAW:
-		err = ploop_thaw(plo, bdev);
+		err = ploop_thaw(plo);
 		break;
 	default:
 		err = -EINVAL;
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index b2ef6bd..8262a50 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -419,7 +419,7 @@ struct ploop_device
 	struct block_device	*bdev;
 	struct request_queue	*queue;
 	struct task_struct	*thread;
-	struct super_block	*sb;
+	struct block_device	*frozen_bdev;
 	int			freeze_state;
 	struct rb_node		link;
 
-- 
2.7.3



More information about the Devel mailing list