Change in vdsm[master]: volume: Support older engine or disks with long description

nsoffer at redhat.com nsoffer at redhat.com
Sun Aug 30 20:22:58 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: volume: Support older engine or disks with long description
......................................................................

volume: Support older engine or disks with long description

New engine will limit the description field size to avoid the
MetaDataOverflowError, but we must support older engine versions and
existing disks with long description. For example, copying old disk with
long description from file to block storage.

The description field has now maximum size; if the size exceeds the
limit, it is silently truncated when creating any volume type.

Change-Id: Ie3b1d9da0084aa5db02b29295d4cd0d5d8178ca2
Backport-To: 3.6
Bug-Url: https://bugzilla.redhat.com/1258097
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/rpc/vdsmapi-schema.json
M vdsm/storage/volume.py
2 files changed, 55 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/45501/1

diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 4cac5ae..c747a55 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -8141,6 +8141,7 @@
 # @dstVolUUID:       The UUID of the destination Volume
 #
 # @desc:             Set the destination Volume description
+#                    Up to 210 bytes; longer values will be truncated
 #
 # @volType:          (Unused) The role of the destination Volume
 #
@@ -8215,6 +8216,7 @@
 # @diskType:         An advisory disk usage type
 #
 # @desc:             The Volume description
+#                    Up to 210 bytes; longer values will be truncated
 #
 # @srcImgUUID:       If specified, create a snapshot from this Image
 #
@@ -8460,7 +8462,8 @@
 #
 # @imageID:          The Image associated with the Volume
 #
-# @description:      A human-readable Volume description
+# @description:      A human-readable Volume description.
+#                    Up to 210 bytes; longer values will be truncated
 #
 # Since: 4.10.0
 ##
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index b46eab1..9300abc 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -98,6 +98,43 @@
 # it will depend on the storage domain.
 BLOCK_SIZE = 512
 
+# In block storage, metadata size is limited to BLOCK_SIZE (512), to
+# ensure that metadata is written atomically. This is big enough for the
+# actual metadata, but may not be big enough for the description field.
+# Since a disk may be created on file storage, and moved to block
+# storage, the metadata size must be limited on all types of storage.
+#
+# The desription field is limited to 500 characters in the engine side.
+# Since ovirt 3.5, the description field is using JSON format, keeping
+# both alias and description. In OVF_STORE disks, the description field
+# holds additional data such as content size and date.
+#
+# Here is the worst case metadata format:
+#
+# CTIME=1440935038                            # int(time.time())
+# DESCRIPTION=                                # text|JSON
+# DISKTYPE=2                                  # enum
+# DOMAIN=75f8a1bb-4504-4314-91ca-d9365a30692b # uuid
+# FORMAT=COW                                  # RAW|COW
+# IMAGE=75f8a1bb-4504-4314-91ca-d9365a30692b  # uuid
+# LEGALITY=ILLEGAL                            # ILLEGAL|LEGAL|FAKE
+# MTIME=0                                     # always 0
+# POOL_UUID=                                  # always empty
+# PUUID=75f8a1bb-4504-4314-91ca-d9365a30692b  # uuid
+# SIZE=2147483648                             # size in blocks
+# TYPE=PREALLOCATED                           # PREALLOCATED|UNKNOWN|SPARSE
+# VOLTYPE=INTERNAL                            # INTERNAL|SHARED|LEAF
+# EOF
+#
+# This content requires 273 bytes, leaving 239 bytes for the description
+# field. OVF_STORE JSON format needs up to 175 bytes.
+#
+# We use a limit of 210 bytes for the description field, leaving couple
+# of bytes for unexpected future changes. This should good enough for
+# ascii values, but limit non-ascii values, which are encoded by engine
+# using 4 bytes per character.
+DESCRIPTION_SIZE = 210
+
 
 def fmt2str(format):
     return FMT2STR[format]
@@ -596,6 +633,7 @@
         Set Volume Description
             'descr' - volume description
         """
+        descr = self.validateDescription(descr)
         self.log.info("volUUID = %s descr = %s ", self.volUUID, descr)
         self.setMetaParam(DESCRIPTION, descr)
 
@@ -837,7 +875,7 @@
             sd.DMDK_POOLS: "",  # obsolete
             DOMAIN: str(sdUUID),
             IMAGE: str(imgUUID),
-            DESCRIPTION: str(desc),
+            DESCRIPTION: cls.validateDescription(desc),
             PUUID: str(puuid),
             MTIME: 0,
             LEGALITY: str(legality),
@@ -846,6 +884,18 @@
         cls.createMetadata(metaId, meta)
         return meta
 
+    @classmethod
+    def validateDescription(cls, desc):
+        desc = str(desc)
+        # We cannot fail when the description is too long, since we must
+        # support older engine that may send such values, or old disks
+        # with long description.
+        if len(desc) > DESCRIPTION_SIZE:
+            cls.log.warning("Description it too long, truncating to %d bytes",
+                            DESCRIPTION_SIZE)
+            desc = desc[:DESCRIPTION_SIZE]
+        return desc
+
     def getInfo(self):
         """
         Get volume info


-- 
To view, visit https://gerrit.ovirt.org/45501
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3b1d9da0084aa5db02b29295d4cd0d5d8178ca2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list