[Devel] [PATCH rh7 4/4] ploop: add PLOOP_IOC_FREEZE and PLOOP_IOC_THAW ioctls

Vladimir Davydov vdavydov at virtuozzo.com
Tue Jul 12 03:04:39 PDT 2016


These ioctls simply freeze and thaw ploop bdev, respectively (i.e. FS
mounted over ploop device). They are required by ploop push backup for
freezing secondary ploops mounted inside containers. The point is that
these mount points are not shown in host's /proc/mounts due to mount
namespace, so there's no easy way for push backup process to get the
mount point given a device name in order to call FIFREEZE ioctl.
(Actually, there's a way - using /proc/PID/mounts and /proc/PID/root
where PID is the pid of a container's process, but it's cumbersome).

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

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
Cc: Pavel Borzenkov <pborzenkov at virtuozzo.com>
---
 drivers/block/ploop/dev.c      | 28 ++++++++++++++++++++++++++++
 include/linux/ploop/ploop_if.h |  6 ++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index e5f010b9aeba..d2b3c9fd9176 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4815,6 +4815,28 @@ static int ploop_push_backup_stop(struct ploop_device *plo, unsigned long arg)
 	return copy_to_user((void*)arg, &ctl, sizeof(ctl));
 }
 
+static int ploop_freeze(struct block_device *bdev)
+{
+	struct super_block *sb;
+
+	sb = freeze_bdev(bdev);
+	if (sb && IS_ERR(sb))
+		return PTR_ERR(sb);
+	return 0;
+}
+
+static int ploop_thaw(struct block_device *bdev)
+{
+	struct super_block *sb;
+	int err;
+
+	sb = get_active_super(bdev);
+	err = thaw_bdev(bdev, sb);
+	if (sb)
+		deactivate_super(sb);
+	return err;
+}
+
 static int ploop_ioctl(struct block_device *bdev, fmode_t fmode, unsigned int cmd,
 		       unsigned long arg)
 {
@@ -4928,6 +4950,12 @@ static int ploop_ioctl(struct block_device *bdev, fmode_t fmode, unsigned int cm
 	case PLOOP_IOC_PUSH_BACKUP_STOP:
 		err = ploop_push_backup_stop(plo, arg);
 		break;
+	case PLOOP_IOC_FREEZE:
+		err = ploop_freeze(bdev);
+		break;
+	case PLOOP_IOC_THAW:
+		err = ploop_thaw(bdev);
+		break;
 	default:
 		err = -EINVAL;
 	}
diff --git a/include/linux/ploop/ploop_if.h b/include/linux/ploop/ploop_if.h
index a098ca9d0ef0..302ace984a5a 100644
--- a/include/linux/ploop/ploop_if.h
+++ b/include/linux/ploop/ploop_if.h
@@ -352,6 +352,12 @@ struct ploop_track_extent
 /* Stop push backup */
 #define PLOOP_IOC_PUSH_BACKUP_STOP _IOR(PLOOPCTLTYPE, 31, struct ploop_push_backup_stop_ctl)
 
+/* Freeze FS mounted over ploop */
+#define PLOOP_IOC_FREEZE	_IO(PLOOPCTLTYPE, 32)
+
+/* Unfreeze FS mounted over ploop */
+#define PLOOP_IOC_THAW		_IO(PLOOPCTLTYPE, 33)
+
 /* Events exposed via /sys/block/ploopN/pstate/event */
 #define PLOOP_EVENT_ABORTED	1
 #define PLOOP_EVENT_STOPPED	2
-- 
2.1.4



More information about the Devel mailing list