Skip to content

Commit

Permalink
Version 6.2.0.239
Browse files Browse the repository at this point in the history
Note: This is a pre-release version, future versions of VDO may not support
VDO devices created with this version.
- Fixed error path memory leaks in the uds and kvdo modules.
- Modified the physical and logical growth procedures to be consistent with
  other device mapper targets.
  • Loading branch information
corwin committed Oct 5, 2018
1 parent b8cf2d2 commit 45b1455
Show file tree
Hide file tree
Showing 31 changed files with 733 additions and 599 deletions.
6 changes: 3 additions & 3 deletions kvdo.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%define spec_release 1
%define kmod_name kvdo
%define kmod_driver_version 6.2.0.219
%define kmod_driver_version 6.2.0.239
%define kmod_rpm_release %{spec_release}
%define kmod_kernel_version 3.10.0-693.el7

Expand Down Expand Up @@ -85,5 +85,5 @@ rm -rf $RPM_BUILD_ROOT
%{_usr}/src/%{kmod_name}-%{version}-%{kmod_driver_version}/*

%changelog
* Fri Sep 14 2018 - J. corwin Coburn <[email protected]> - 6.2.0.219-1
HASH(0x1b30ad8)
* Fri Oct 05 2018 - J. corwin Coburn <[email protected]> - 6.2.0.239-1
HASH(0x1b8ead8)
2 changes: 1 addition & 1 deletion vdo/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VDO_VERSION = 6.2.0.219
VDO_VERSION = 6.2.0.239

VDO_VERSION_MAJOR = $(word 1,$(subst ., ,$(VDO_VERSION)))
VDO_VERSION_MINOR = $(word 2,$(subst ., ,$(VDO_VERSION)))
Expand Down
26 changes: 18 additions & 8 deletions vdo/base/extent.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/base/extent.c#1 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/extent.c#2 $
*/

#include "extent.h"
Expand Down Expand Up @@ -93,16 +93,22 @@ void freeExtent(VDOExtent **extentPtr)
* @param extent The extent
* @param startBlock The absolute physical block at which the extent should
* begin its I/O
* @param count The number of blocks to write
* @param operation The operation to perform on the extent
**/
static void launchMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock,
BlockCount count,
VIOOperation operation)
{
resetCompletion(&extent->completion);
extent->completeCount = 0;
BlockCount vioCount = extent->count;
for (BlockCount i = 0; i < vioCount; i++) {
if (count > extent->count) {
finishCompletion(&extent->completion, VDO_OUT_OF_RANGE);
return;
}

extent->completeCount = extent->count - count;
for (BlockCount i = 0; i < count; i++) {
VIO *vio = extent->vios[i];
vio->completion.callbackThreadID = extent->completion.callbackThreadID;
launchMetadataVIO(vio, startBlock++, handleVIOCompletion,
Expand All @@ -111,15 +117,19 @@ static void launchMetadataExtent(VDOExtent *extent,
}

/**********************************************************************/
void readMetadataExtent(VDOExtent *extent, PhysicalBlockNumber startBlock)
void readPartialMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock,
BlockCount count)
{
launchMetadataExtent(extent, startBlock, VIO_READ);
launchMetadataExtent(extent, startBlock, count, VIO_READ);
}

/**********************************************************************/
void writeMetadataExtent(VDOExtent *extent, PhysicalBlockNumber startBlock)
void writePartialMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock,
BlockCount count)
{
launchMetadataExtent(extent, startBlock, VIO_WRITE);
launchMetadataExtent(extent, startBlock, count, VIO_WRITE);
}

/**********************************************************************/
Expand Down
39 changes: 36 additions & 3 deletions vdo/base/extent.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/base/extent.h#1 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/extent.h#2 $
*/

#ifndef EXTENT_H
Expand Down Expand Up @@ -105,17 +105,50 @@ void freeExtent(VDOExtent **extentPtr);
* @param extent The extent to read
* @param startBlock The physical block number of the first block
* in the extent
* @param count The number of blocks to read (must be less than or
* equal to the length of the extent)
**/
void readMetadataExtent(VDOExtent *extent, PhysicalBlockNumber startBlock);
void readPartialMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock,
BlockCount count);

/**
* Read metadata from the underlying storage.
*
* @param extent The extent to read
* @param startBlock The physical block number of the first block
* in the extent
**/
static inline void readMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock)
{
readPartialMetadataExtent(extent, startBlock, extent->count);
}

/**
* Write metadata to the underlying storage.
*
* @param extent The extent to write
* @param startBlock The physical block number of the first block in the
* extent
* @param count The number of blocks to read (must be less than or
* equal to the length of the extent)
**/
void writeMetadataExtent(VDOExtent *extent, PhysicalBlockNumber startBlock);
void writePartialMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock,
BlockCount count);
/**
* Write metadata to the underlying storage.
*
* @param extent The extent to write
* @param startBlock The physical block number of the first block in the
* extent
**/
static inline void writeMetadataExtent(VDOExtent *extent,
PhysicalBlockNumber startBlock)
{
writePartialMetadataExtent(extent, startBlock, extent->count);
}

/**
* Notify an extent that one of its VIOs has completed. If the signaling VIO
Expand Down
148 changes: 63 additions & 85 deletions vdo/base/partitionCopy.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/base/partitionCopy.c#1 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/partitionCopy.c#2 $
*/

#include "partitionCopy.h"
Expand All @@ -26,6 +26,7 @@
#include "completion.h"
#include "constants.h"
#include "extent.h"
#include "numUtils.h"

enum {
STRIDE_LENGTH = 2048
Expand Down Expand Up @@ -67,27 +68,65 @@ CopyCompletion *asCopyCompletion(VDOCompletion *completion)
return (CopyCompletion *) completion;
}

/**
* Free the copy completion now that we've finished copying.
*
* @param completion The copy completion
**/
static void finishCopy(VDOCompletion *completion)
/**********************************************************************/
int makeCopyCompletion(PhysicalLayer *layer, VDOCompletion **completionPtr)
{
VDOCompletion *parent = completion->parent;
int result = completion->result;
CopyCompletion *copy;
int result = ALLOCATE(1, CopyCompletion, __func__, &copy);
if (result != VDO_SUCCESS) {
return result;
}
initializeCompletion(&copy->completion, PARTITION_COPY_COMPLETION, layer);

CopyCompletion *copy = asCopyCompletion(completion);
result = ALLOCATE((VDO_BLOCK_SIZE * STRIDE_LENGTH), char,
"partition copy extent", &copy->data);
if (result != VDO_SUCCESS) {
VDOCompletion *completion = &copy->completion;
freeCopyCompletion(&completion);
return result;
}

result = createExtent(layer, VIO_TYPE_PARTITION_COPY, VIO_PRIORITY_HIGH,
STRIDE_LENGTH, copy->data, &copy->extent);
if (result != VDO_SUCCESS) {
VDOCompletion *completion = &copy->completion;
freeCopyCompletion(&completion);
return result;
}

*completionPtr = &copy->completion;
return VDO_SUCCESS;
}

/**********************************************************************/
void freeCopyCompletion(VDOCompletion **completionPtr)
{
if (*completionPtr == NULL) {
return;
}

CopyCompletion *copy = asCopyCompletion(*completionPtr);
freeExtent(&copy->extent);
FREE(copy->data);
FREE(copy);

finishCompletion(parent, result);
*completionPtr = NULL;
}

/**********************************************************************/
static void copyPartitionStride(CopyCompletion *copy);

/**
* Determine the number of blocks to copy in the current stride.
*
* @param copy The copy completion
*
* @return The number of blocks to copy in the current stride
**/
static inline BlockCount getStrideSize(CopyCompletion *copy)
{
return minBlockCount(STRIDE_LENGTH, copy->endingIndex - copy->currentIndex);
}

/**
* Process a completed write during a partition copy.
*
Expand All @@ -96,7 +135,7 @@ static void copyPartitionStride(CopyCompletion *copy);
static void completeWriteForCopy(VDOCompletion *completion)
{
CopyCompletion *copy = asCopyCompletion(completion->parent);
copy->currentIndex += copy->extent->count;
copy->currentIndex += getStrideSize(copy);
if (copy->currentIndex >= copy->endingIndex) {
// We're done.
finishCompletion(completion->parent, VDO_SUCCESS);
Expand All @@ -123,7 +162,8 @@ static void completeReadForCopy(VDOCompletion *completion)
}

completion->callback = completeWriteForCopy;
writeMetadataExtent(asVDOExtent(completion), layerStartBlock);
writePartialMetadataExtent(asVDOExtent(completion), layerStartBlock,
getStrideSize(copy));
}

/**
Expand All @@ -133,21 +173,6 @@ static void completeReadForCopy(VDOCompletion *completion)
**/
static void copyPartitionStride(CopyCompletion *copy)
{
PhysicalBlockNumber blocksRemaining
= (copy->endingIndex - copy->currentIndex);
if (blocksRemaining < STRIDE_LENGTH) {
// There is less than a whole stride left to copy, so the extent must be
// resized down to the remaining length.
freeExtent(&copy->extent);
int result = createExtent(copy->completion.layer, VIO_TYPE_PARTITION_COPY,
VIO_PRIORITY_HIGH, blocksRemaining, copy->data,
&copy->extent);
if (result != VDO_SUCCESS) {
finishCompletion(&copy->completion, result);
return;
}
}

PhysicalBlockNumber layerStartBlock;
int result = translateToPBN(copy->source, copy->currentIndex,
&layerStartBlock);
Expand All @@ -159,48 +184,8 @@ static void copyPartitionStride(CopyCompletion *copy)
prepareCompletion(&copy->extent->completion, completeReadForCopy,
finishParentCallback, copy->completion.callbackThreadID,
&copy->completion);
readMetadataExtent(copy->extent, layerStartBlock);
}

/**
* Initialize a copy completion.
*
* @param layer The layer in question
* @param source The partition to copy from
* @param target The partition to copy to
* @param parent The parent to finish when the copy is complete
* @param copy The copy completion to initialize
*
* @return VDO_SUCCESS or an error
**/
__attribute__((warn_unused_result))
static int initializeCopyCompletion(PhysicalLayer *layer,
Partition *source,
Partition *target,
VDOCompletion *parent,
CopyCompletion *copy)
{
initializeCompletion(&copy->completion, PARTITION_COPY_COMPLETION, layer);
prepareCompletion(&copy->completion, finishCopy, finishCopy,
parent->callbackThreadID, parent);

int result = ALLOCATE((VDO_BLOCK_SIZE * STRIDE_LENGTH), char,
"partition copy extent", &copy->data);
if (result != VDO_SUCCESS) {
return result;
}

result = createExtent(layer, VIO_TYPE_PARTITION_COPY, VIO_PRIORITY_HIGH,
STRIDE_LENGTH, copy->data, &copy->extent);
if (result != VDO_SUCCESS) {
return result;
}

copy->source = source;
copy->target = target;
copy->currentIndex = 0;
copy->endingIndex = getFixedLayoutPartitionSize(source);
return VDO_SUCCESS;
readPartialMetadataExtent(copy->extent, layerStartBlock,
getStrideSize(copy));
}

/**
Expand Down Expand Up @@ -233,7 +218,7 @@ static int validatePartitionCopy(Partition *source, Partition *target)
}

/**********************************************************************/
void copyPartitionAsync(PhysicalLayer *layer,
void copyPartitionAsync(VDOCompletion *completion,
Partition *source,
Partition *target,
VDOCompletion *parent)
Expand All @@ -244,18 +229,11 @@ void copyPartitionAsync(PhysicalLayer *layer,
return;
}

CopyCompletion *copy;
result = ALLOCATE(1, CopyCompletion, __func__, &copy);
if (result != VDO_SUCCESS) {
finishCompletion(parent, result);
return;
}

result = initializeCopyCompletion(layer, source, target, parent, copy);
if (result != VDO_SUCCESS) {
finishCompletion(&copy->completion, result);
return;
}

CopyCompletion *copy = asCopyCompletion(completion);
prepareToFinishParent(&copy->completion, parent);
copy->source = source;
copy->target = target;
copy->currentIndex = 0;
copy->endingIndex = getFixedLayoutPartitionSize(source);
copyPartitionStride(copy);
}
Loading

0 comments on commit 45b1455

Please sign in to comment.