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

Submitted by Andrey Ryabinin on Aug. 19, 2016, 1 p.m.

Details

Message ID 1471611621-6838-2-git-send-email-aryabinin@virtuozzo.com
State New
Series "ploop: add support for dm-crypted ploops"
Headers show

Commit Message

Andrey Ryabinin Aug. 19, 2016, 1 p.m.
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@virtuozzo.com>
---
 drivers/block/ploop/dev.c   | 13 +++++++------
 include/linux/ploop/ploop.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

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;
 

Comments

Maxim Patlasov Aug. 19, 2016, 7:10 p.m.
Acked-by: Maxim Patlasov <mpatlasov@virtuozzo.com>


On 08/19/2016 06:00 AM, Andrey Ryabinin wrote:
> 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@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;
>