[Devel] [PATCH RHEL7 COMMIT] ploop: added into pvd header new close signatures
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jun 5 00:59:08 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.9
------>
commit 1cc44b3b48e3932802e7ad43f238ee1542ba3649
Author: Andrey Smetanin <asmetanin at virtuozzo.com>
Date: Fri Jun 5 11:59:08 2015 +0400
ploop: added into pvd header new close signatures
pvd header m_DiskInUse field extended to store additinal
SIGNATURE_DISK_CLOSED_V21 value(will be used by backup software).
Disk in use checks replaced by pvd_header_is_disk_in_use().
https://jira.sw.ru/browse/PSBM-33882
Signed-off-by: Andrey Smetanin <asmetanin at virtuozzo.com>
Acked-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
drivers/block/ploop/fmt_ploop1.c | 14 +++++++-------
drivers/block/ploop/ploop1_image.h | 21 +++++++++++++++++++++
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index e8d5a50..c4ecb51 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -88,7 +88,7 @@ static int ploop1_stop(struct ploop_delta * delta)
vh->m_Flags = cpu_to_le32(vh->m_Flags);
}
- vh->m_DiskInUse = 0;
+ pvd_header_set_disk_closed(vh);
err = delta->io.ops->sync_write(&delta->io, ph->dyn_page, 4096, 0, 0);
if (err)
@@ -147,7 +147,7 @@ ploop1_open(struct ploop_delta * delta)
ph->l1_off = le32_to_cpu(vh->m_FirstBlockOffset);
err = -EBUSY;
- if (vh->m_DiskInUse)
+ if (pvd_header_is_disk_in_use(vh))
goto out_err;
err = -EINVAL;
@@ -167,7 +167,7 @@ ploop1_open(struct ploop_delta * delta)
goto out_err;
if (!(delta->flags & PLOOP_FMT_RDONLY)) {
- vh->m_DiskInUse = cpu_to_le32(SIGNATURE_DISK_IN_USE);
+ pvd_header_set_disk_in_use(vh);
err = delta->io.ops->sync_write(&delta->io, ph->dyn_page, 4096, 0, 0);
if (err)
goto out_err;
@@ -276,7 +276,7 @@ ploop1_sync(struct ploop_delta * delta)
return err;
vh = (struct ploop_pvd_header *)page_address(ph->dyn_page);
- vh->m_DiskInUse = cpu_to_le32(SIGNATURE_DISK_IN_USE);
+ pvd_header_set_disk_in_use(vh);
if (ph->alloc_head > (ph->l1_off >> delta->plo->cluster_log)) {
vh->m_Flags = le32_to_cpu(vh->m_Flags);
@@ -329,7 +329,7 @@ ploop1_complete_snapshot(struct ploop_delta * delta, struct ploop_snapdata * sd)
vh->m_Flags = cpu_to_le32(vh->m_Flags);
}
- vh->m_DiskInUse = 0;
+ pvd_header_set_disk_closed(vh);
/*
* NB: we don't call ploop_update_map_hdr() here because top
@@ -376,7 +376,7 @@ ploop1_prepare_merge(struct ploop_delta * delta, struct ploop_snapdata * sd)
if (err)
return err;
- if (vh->m_DiskInUse)
+ if (pvd_header_is_disk_in_use(vh))
return -EBUSY;
ph->alloc_head = delta->io.ops->i_size_read(&delta->io) >>
@@ -413,7 +413,7 @@ ploop1_start_merge(struct ploop_delta * delta, struct ploop_snapdata * sd)
return err;
vh = (struct ploop_pvd_header *)page_address(ph->dyn_page);
- vh->m_DiskInUse = cpu_to_le32(SIGNATURE_DISK_IN_USE);
+ pvd_header_set_disk_in_use(vh);
/* keep hdr in ph->dyn_page and in map_node in sync */
ploop_update_map_hdr(&delta->plo->map, (u8 *)vh, sizeof(*vh));
diff --git a/drivers/block/ploop/ploop1_image.h b/drivers/block/ploop/ploop1_image.h
index c4efe87..1db8cea 100644
--- a/drivers/block/ploop/ploop1_image.h
+++ b/drivers/block/ploop/ploop1_image.h
@@ -57,6 +57,12 @@ struct ploop_pvd_header
/* Sign that the disk is in "using" state */
#define SIGNATURE_DISK_IN_USE 0x746F6E59
+/* Disk was closed by software which conformed specification 2.0 */
+#define SIGNATURE_DISK_CLOSED_V20 0x0
+
+/* Disk disk was closed by software which conformed specification 2.1 */
+#define SIGNATURE_DISK_CLOSED_V21 0x312e3276
+
/**
* Compressed disk image flags
*/
@@ -354,6 +360,21 @@ generate_pvd_header(struct ploop_pvd_header *vh, __u64 bdsize, __u32 blocksize,
return SizeToFill;
}
+static inline bool pvd_header_is_disk_in_use(struct ploop_pvd_header *vh)
+{
+ return (vh->m_DiskInUse == cpu_to_le32(SIGNATURE_DISK_IN_USE)) ?
+ true : false;
+}
+
+static inline void pvd_header_set_disk_in_use(struct ploop_pvd_header *vh)
+{
+ vh->m_DiskInUse = cpu_to_le32(SIGNATURE_DISK_IN_USE);
+}
+
+static inline void pvd_header_set_disk_closed(struct ploop_pvd_header *vh)
+{
+ vh->m_DiskInUse = cpu_to_le32(SIGNATURE_DISK_CLOSED_V20);
+}
/* Translation of sector number to offset in image */
More information about the Devel
mailing list