Skip to content

Commit

Permalink
Version 6.2.6.7
Browse files Browse the repository at this point in the history
- Fixed bugs in the vdopreparelvm check to determine whether a device has
  already been converted.
- Fixed an issue in the vdo-by-dev tool which could result in a failure to
  start vdo devices when some devices in the vdo config file do not exist.
  • Loading branch information
corwin committed Nov 12, 2021
1 parent cc5d637 commit 229b9ec
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 43 deletions.
2 changes: 1 addition & 1 deletion utils/uds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# UDS interfaces exported from libuds.so. DISTRIBUTION_VERSION is the long
# version name used in distribution builds. We extract these values from the
# traditional location.
UDS_VERSION = 8.0.4.1
UDS_VERSION = 8.0.4.2
BUILD_VERSION = $(UDS_VERSION)
DISTRO_CODENAME := $(shell lsb_release -s -c)

Expand Down
2 changes: 1 addition & 1 deletion utils/vdo/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# $Id: //eng/vdo-releases/aluminum/src/packaging/src-dist/user/utils/vdo/base/Makefile#2 $

VDO_VERSION = 6.2.6.3
VDO_VERSION = 6.2.6.7

UDS_DIR = ../../uds

Expand Down
2 changes: 1 addition & 1 deletion utils/vdo/user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# $Id: //eng/vdo-releases/aluminum/src/packaging/src-dist/user/utils/vdo/user/Makefile#16 $

VDO_VERSION = 6.2.6.3
VDO_VERSION = 6.2.6.7

UDS_DIR = ../../uds
VDO_BASE_DIR = ../base
Expand Down
28 changes: 19 additions & 9 deletions utils/vdo/user/fileLayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/fileLayer.c#4 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/fileLayer.c#5 $
*/

#include "fileLayer.h"
Expand All @@ -38,7 +38,7 @@
typedef struct fileLayer {
PhysicalLayer common;
BlockCount blockCount;
BlockCount fileOffset;
off_t blockOffset;
int fd;
char name[];
} FileLayer;
Expand Down Expand Up @@ -93,7 +93,12 @@ static int fileReader(PhysicalLayer *header,
size_t *blocksRead)
{
FileLayer *layer = asFileLayer(header);
startBlock += layer->fileOffset;

if ((((off_t) startBlock) + layer->blockOffset) < 0) {
return VDO_OUT_OF_RANGE;
}

startBlock += layer->blockOffset;

if (startBlock + blockCount > layer->blockCount) {
return VDO_OUT_OF_RANGE;
Expand Down Expand Up @@ -133,7 +138,12 @@ static int fileWriter(PhysicalLayer *header,
size_t *blocksWritten)
{
FileLayer *layer = asFileLayer(header);
startBlock += layer->fileOffset;

if ((((off_t) startBlock) + layer->blockOffset) < 0) {
return VDO_OUT_OF_RANGE;
}

startBlock += layer->blockOffset;

if (startBlock + blockCount > layer->blockCount) {
return VDO_OUT_OF_RANGE;
Expand Down Expand Up @@ -216,15 +226,15 @@ static void freeLayer(PhysicalLayer **layerPtr)
* @param [in] readOnly whether the layer is not allowed to write
* @param [in] blockCount the span of the file, in blocks (may be zero for
* read-only layers in which case it is computed)
* @param [in] fileOffset the block offset to apply to I/O operations
* @param [in] blockOffset the block offset to apply to I/O operations
* @param [out] layerPtr the pointer to hold the result
*
* @return a success or error code
**/
static int setupFileLayer(const char *name,
bool readOnly,
BlockCount blockCount,
BlockCount fileOffset,
off_t blockOffset,
PhysicalLayer **layerPtr)
{
int result = ASSERT(layerPtr != NULL, "layerPtr must not be NULL");
Expand All @@ -240,7 +250,7 @@ static int setupFileLayer(const char *name,
}

layer->blockCount = blockCount;
layer->fileOffset = fileOffset;
layer->blockOffset = blockOffset;
strcpy(layer->name, name);

bool exists = false;
Expand Down Expand Up @@ -334,8 +344,8 @@ int makeReadOnlyFileLayer(const char *name, PhysicalLayer **layerPtr)
/**********************************************************************/
int makeOffsetFileLayer(const char *name,
BlockCount blockCount,
BlockCount fileOffset,
off_t blockOffset,
PhysicalLayer **layerPtr)
{
return setupFileLayer(name, false, blockCount, fileOffset, layerPtr);
return setupFileLayer(name, false, blockCount, blockOffset, layerPtr);
}
6 changes: 3 additions & 3 deletions utils/vdo/user/fileLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/fileLayer.h#2 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/fileLayer.h#3 $
*/

#ifndef FILE_LAYER_H
Expand Down Expand Up @@ -54,14 +54,14 @@ int makeReadOnlyFileLayer(const char *name, PhysicalLayer **layerPtr)
*
* @param [in] name the name of the underlying file
* @param [in] blockCount the span of the file, in blocks
* @param [in] fileOffset the block offset to apply to I/O operations
* @param [in] blockOffset the block offset to apply to I/O operations
* @param [out] layerPtr the pointer to hold the result
*
* @return a success or error code
**/
int makeOffsetFileLayer(const char *name,
BlockCount blockCount,
BlockCount fileOffset,
off_t blockOffset,
PhysicalLayer **layerPtr)
__attribute__((warn_unused_result));

Expand Down
45 changes: 37 additions & 8 deletions utils/vdo/user/vdoprepareforlvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/vdoPrepareForLVM.c#2 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/user/vdoPrepareForLVM.c#4 $
*/

#include <err.h>
Expand Down Expand Up @@ -88,9 +88,9 @@ static struct option options[] = {
static char optionString[] = "chV";

static const char *fileName;
static bool checkPreparationState = false;
static const off_t vdoByteOffset = (1024 * 1024) * 2;
static const BlockCount vdoBlockOffset = vdoByteOffset / VDO_BLOCK_SIZE;
static bool checkPreparationState = false;
static const off_t vdoByteOffset = (1024 * 1024) * 2;
static const off_t vdoBlockOffset = vdoByteOffset / VDO_BLOCK_SIZE;

static void usage(const char *progname, const char *usageOptionsString)
{
Expand Down Expand Up @@ -342,11 +342,13 @@ static int performDeviceCheck(void)
}

/**
* If we can load the geometry the device is likely a non-converted VDO
* else the load would have failed with VDO_BAD_MAGIC.
* If we can load the geometry the device is either an lvm-created VDO, a
* non-converted VDO or a post-conversion VDO instantiated by lvm. Anything
* else would have failed the load with VDO_BAD_MAGIC.
*
* In the case of a succesful load we additionally check that the VDO
* superblock can also be loaded before claiming the device is actually a
* a non-converted VDO.
* VDO.
**/
VolumeGeometry geometry;
result = loadVolumeGeometry(layer, &geometry);
Expand All @@ -358,16 +360,43 @@ static int performDeviceCheck(void)
// Load the superblock as an additional check the device is really a vdo.
VDO *vdo;
result = loadVDOSuperblock(layer, &geometry, false, NULL, &vdo);
if (result == VDO_SUCCESS) {
cleanup(vdo, layer);
return deviceCheckResultToExitStatus(result, true);
}

/**
* The device could be a post-conversion VDO instantiated by lvm.
* These devices have a geometry from their pre-conversion existence
* which will cause the loading of the superblock to fail using a default
* file layer.
* We try to load the superblock again accounting for the conversion.
**/
PhysicalLayer *offsetLayer;
result = makeOffsetFileLayer(fileName, 0, -vdoBlockOffset, &offsetLayer);
if (result != VDO_SUCCESS) {
cleanup(NULL, layer);
return result;
}

result = loadVDOSuperblock(offsetLayer, &geometry, false, NULL, &vdo);
if (result != VDO_SUCCESS) {
vdo = NULL;
result = VDO_BAD_MAGIC; // Not a vdo.
}
offsetLayer->destroy(&offsetLayer);
cleanup(vdo, layer);
/**
* Report these devices as pre-conversion in order to present in the
* same way as lvm-created vdos.
**/
return deviceCheckResultToExitStatus(result, true);
}

/**
* Getting here the device is either a post-conversion VDO or not a VDO.
* Getting here the device is either not a VDO or is a post-conversion VDO
* specified by the pre-conversion device; i.e., not an lvm instantiated VDO.
*
* Attempt to load the geometry from its post-conversion location. If the
* device is not a VDO the load will fail with VDO_BAD_MAGIC.
*/
Expand Down
2 changes: 1 addition & 1 deletion vdo-manager/statistics/KernelStatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, name="KernelStatistics", **kwargs):
Uint32Field("releaseVersion", display = False),
# The VDO instance
Uint32Field("instance"),
StringField("fiveTwelveByteEmulation", label = "512 byte emulation", derived = "'on' if ($logicalBlockSize == 512) else 'off'"),
StringField("fiveTwelveByteEmulation", derived = "'on' if ($logicalBlockSize == 512) else 'off'", label = "512 byte emulation"),
# Current number of active VIOs
Uint32Field("currentVIOsInProgress", label = "current VDO IO requests in progress"),
# Maximum number of active VIOs
Expand Down
14 changes: 7 additions & 7 deletions vdo-manager/statistics/VDOStatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ def __init__(self, name="VDOStatistics", **kwargs):
Uint64Field("physicalBlocks"),
# number of logical blocks
Uint64Field("logicalBlocks"),
Uint64Field("oneKBlocks", label = "1K-blocks", derived = "$physicalBlocks * $blockSize // 1024"),
Uint64Field("oneKBlocks", derived = "$physicalBlocks * $blockSize // 1024", label = "1K-blocks"),
Uint64Field("oneKBlocksUsed", available = "not $inRecoveryMode", label = "1K-blocks used", derived = "($dataBlocksUsed + $overheadBlocksUsed) * $blockSize // 1024"),
Uint64Field("oneKBlocksAvailable", derived = "($physicalBlocks - $dataBlocksUsed - $overheadBlocksUsed) * $blockSize // 1024", label = "1K-blocks available", available = "not $inRecoveryMode"),
Uint8Field("usedPercent", available = "((not $inRecoveryMode) and ($mode != b'read-only'))", derived = "int((100 * ($dataBlocksUsed + $overheadBlocksUsed) // $physicalBlocks) + 0.5)"),
Uint8Field("savings", display = False, derived = "int(100 * ($logicalBlocksUsed - $dataBlocksUsed) // $logicalBlocksUsed) if ($logicalBlocksUsed > 0) else -1", available = "not $inRecoveryMode"),
Uint8Field("savingPercent", available = "((not $inRecoveryMode) and ($mode != b'read-only'))", derived = "$savings if ($savings >= 0) else NotAvailable()"),
Uint64Field("oneKBlocksAvailable", available = "not $inRecoveryMode", derived = "($physicalBlocks - $dataBlocksUsed - $overheadBlocksUsed) * $blockSize // 1024", label = "1K-blocks available"),
Uint8Field("usedPercent", derived = "int((100 * ($dataBlocksUsed + $overheadBlocksUsed) // $physicalBlocks) + 0.5)", available = "((not $inRecoveryMode) and ($mode != b'read-only'))"),
Uint8Field("savings", display = False, available = "not $inRecoveryMode", derived = "int(100 * ($logicalBlocksUsed - $dataBlocksUsed) // $logicalBlocksUsed) if ($logicalBlocksUsed > 0) else -1"),
Uint8Field("savingPercent", derived = "$savings if ($savings >= 0) else NotAvailable()", available = "((not $inRecoveryMode) and ($mode != b'read-only'))"),
# Size of the block map page cache, in bytes
Uint64Field("blockMapCacheSize"),
# String describing the active write policy of the VDO
Expand All @@ -217,11 +217,11 @@ def __init__(self, name="VDOStatistics", **kwargs):
# Number of times the VDO has recovered from read-only mode
Uint64Field("readOnlyRecoveries", label = "read-only recovery count"),
# String describing the operating mode of the VDO
StringField("mode", label = "operating mode", length = 15),
StringField("mode", length = 15, label = "operating mode"),
# Whether the VDO is in recovery mode
BoolField("inRecoveryMode", display = False),
# What percentage of recovery mode work has been completed
Uint8Field("recoveryPercentage", label = "recovery progress (%)", available = "$inRecoveryMode"),
Uint8Field("recoveryPercentage", available = "$inRecoveryMode", label = "recovery progress (%)"),
# The statistics for the compressed block packer
PackerStatistics("packer"),
# Counters for events in the block allocator
Expand Down
22 changes: 15 additions & 7 deletions vdo-manager/vdo-by-dev
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import subprocess

# Fix up the path to address layout changes
for dir in sys.path:
vdoDir = os.path.join(dir, 'vdo')
if os.path.isdir(vdoDir):
sys.path.append(vdoDir)
break
vdoDir = os.path.join(dir, 'vdo')
if os.path.isdir(vdoDir):
sys.path.append(vdoDir)
break

from vdomgmnt import *

Expand All @@ -46,8 +46,16 @@ conf = Configuration("/etc/vdoconf.yml")
rdev = os.stat('/dev/' + sys.argv[1]).st_rdev

# Loop through each VDO in the config and determine whether its backing device
# matches the one provided by the udev trigger (argv[1])
# matches the one provided by the udev trigger (argv[1]). If so, execute
# the specified operation (argv[2]) against the VDO.
for vdo in conf.getAllVdos().values():
if os.stat(vdo.device).st_rdev == rdev:
subprocess.check_call([ "vdo" ] + sys.argv[2:] + [ "--name", vdo.getName() ])
try:
stats = os.stat(vdo.device)
except FileNotFoundError:
# Tolerate that the device of a VDO from the config file may not yet
# be present in the system.
pass
else:
if stats.st_rdev == rdev:
subprocess.check_call([ "vdo" ] + sys.argv[2:] + [ "--name", vdo.getName() ])

11 changes: 6 additions & 5 deletions vdo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Summary: Management tools for Virtual Data Optimizer
Name: vdo
Version: 6.2.6.3
Version: 6.2.6.7
Release: %{spec_release}%{?dist}
License: GPLv2
Source0: %{name}-%{version}.tgz
Expand Down Expand Up @@ -182,7 +182,8 @@ This package provides the user-space support tools for VDO.
%{_mandir}/man8/vdoregenerategeometry.8.gz

%changelog
* Wed Nov 03 2021 - Red Hat VDO Team <[email protected]> - 6.2.6.3-1
- Added a check to vdopreparelvm to determine whether it has already been
converted.

* Fri Nov 12 2021 - Red Hat VDO Team <[email protected]> - 6.2.6.7-1
- Fixed bugs in the vdopreparelvm check to determine whether a device has
already been converted.
- Fixed an issue in the vdo-by-dev tool which could result in a failure to
start vdo devices when some devices in the vdo config file do not exist.

0 comments on commit 229b9ec

Please sign in to comment.