Skip to content

Commit

Permalink
Version 6.2.5.41
Browse files Browse the repository at this point in the history
- Fixed bugs in reading the UDS index of a VDO volume which was converted
  to LVM.
  • Loading branch information
corwin committed May 27, 2021
1 parent 395a257 commit df68a45
Show file tree
Hide file tree
Showing 20 changed files with 235 additions and 159 deletions.
7 changes: 4 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.5.21
%define kmod_driver_version 6.2.5.41
%define kmod_rpm_release %{spec_release}
%define kmod_kernel_version 3.10.0-693.el7

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

%changelog
* Thu May 20 2021 - Red Hat VDO Team <[email protected]> - 6.2.5.21-1
- Added support for VDO volumes which have been converted to LVM.
* Thu May 27 2021 - Red Hat VDO Team <[email protected]> - 6.2.5.41-1
- Fixed bugs in reading the UDS index of a VDO volume which was converted
to LVM.
2 changes: 1 addition & 1 deletion uds/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UDS_VERSION = 8.0.3.7
UDS_VERSION = 8.0.3.21

SOURCES = $(notdir $(wildcard $(src)/*.c)) murmur/MurmurHash3.c
SOURCES += $(addprefix util/,$(notdir $(wildcard $(src)/util/*.c)))
Expand Down
2 changes: 1 addition & 1 deletion uds/chapterIndex.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/uds-releases/jasper/src/uds/chapterIndex.c#5 $
* $Id: //eng/uds-releases/jasper/src/uds/chapterIndex.c#7 $
*/

#include "chapterIndex.h"
Expand Down
2 changes: 1 addition & 1 deletion uds/chapterIndex.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/uds-releases/jasper/src/uds/chapterIndex.h#4 $
* $Id: //eng/uds-releases/jasper/src/uds/chapterIndex.h#6 $
*/

#ifndef CHAPTER_INDEX_H
Expand Down
13 changes: 5 additions & 8 deletions uds/config.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/uds-releases/jasper/src/uds/config.h#4 $
* $Id: //eng/uds-releases/jasper/src/uds/config.h#5 $
*/

#ifndef CONFIG_H
Expand Down Expand Up @@ -56,13 +56,10 @@ struct udsConfiguration {
unsigned int sparseSampleRate;
/** Index Owner's nonce */
UdsNonce nonce;
/** Virtual chapter remapped from physical chapter 0 in order
* to reduce chaptersPerVolume by one */
uint64_t remappedChapter;
/** Offset by which the remapped chapter was moved, one more
* than the post-remapping physical chapter number to which it
* was remapped */
uint64_t chapterOffset;
/** Virtual chapter remapped from physical chapter 0 */
uint64_t remappedVirtual;
/** New physical chapter which remapped chapter was moved to */
uint64_t remappedPhysical;
};

/**
Expand Down
54 changes: 43 additions & 11 deletions uds/geometry.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/uds-releases/jasper/src/uds/geometry.c#6 $
* $Id: //eng/uds-releases/jasper/src/uds/geometry.c#8 $
*/

#include "geometry.h"
Expand All @@ -35,8 +35,8 @@ static int initializeGeometry(Geometry *geometry,
unsigned int recordPagesPerChapter,
unsigned int chaptersPerVolume,
unsigned int sparseChaptersPerVolume,
uint64_t remappedChapter,
uint64_t chapterOffset)
uint64_t remappedVirtual,
uint64_t remappedPhysical)
{
int result = ASSERT_WITH_ERROR_CODE(bytesPerPage >= BYTES_PER_RECORD,
UDS_BAD_STATE,
Expand All @@ -62,8 +62,8 @@ static int initializeGeometry(Geometry *geometry,
geometry->sparseChaptersPerVolume = sparseChaptersPerVolume;
geometry->denseChaptersPerVolume =
chaptersPerVolume - sparseChaptersPerVolume;
geometry->remappedChapter = remappedChapter;
geometry->chapterOffset = chapterOffset;
geometry->remappedVirtual = remappedVirtual;
geometry->remappedPhysical = remappedPhysical;

// Calculate the number of records in a page, chapter, and volume.
geometry->recordsPerPage = bytesPerPage / BYTES_PER_RECORD;
Expand Down Expand Up @@ -111,8 +111,8 @@ int makeGeometry(size_t bytesPerPage,
unsigned int recordPagesPerChapter,
unsigned int chaptersPerVolume,
unsigned int sparseChaptersPerVolume,
uint64_t remappedChapter,
uint64_t chapterOffset,
uint64_t remappedVirtual,
uint64_t remappedPhysical,
Geometry **geometryPtr)
{
Geometry *geometry;
Expand All @@ -125,8 +125,8 @@ int makeGeometry(size_t bytesPerPage,
recordPagesPerChapter,
chaptersPerVolume,
sparseChaptersPerVolume,
remappedChapter,
chapterOffset);
remappedVirtual,
remappedPhysical);
if (result != UDS_SUCCESS) {
freeGeometry(geometry);
return result;
Expand All @@ -143,8 +143,8 @@ int copyGeometry(Geometry *source, Geometry **geometryPtr)
source->recordPagesPerChapter,
source->chaptersPerVolume,
source->sparseChaptersPerVolume,
source->remappedChapter,
source->chapterOffset,
source->remappedVirtual,
source->remappedPhysical,
geometryPtr);
}

Expand All @@ -154,6 +154,38 @@ void freeGeometry(Geometry *geometry)
FREE(geometry);
}

/**********************************************************************/
__attribute__((warn_unused_result))
unsigned int mapToPhysicalChapter(const Geometry *geometry,
uint64_t virtualChapter)
{
uint64_t delta;
if (!isReducedGeometry(geometry)) {
return (virtualChapter % geometry->chaptersPerVolume);
}

if (likely(virtualChapter > geometry->remappedVirtual)) {
delta = virtualChapter - geometry->remappedVirtual;
if (likely(delta > geometry->remappedPhysical)) {
return (delta % geometry->chaptersPerVolume);
} else {
return (delta - 1);
}
}

if (virtualChapter == geometry->remappedVirtual) {
return geometry->remappedPhysical;
}

delta = geometry->remappedVirtual - virtualChapter;
if (delta < geometry->chaptersPerVolume) {
return (geometry->chaptersPerVolume - delta);
}

// This chapter is so old the answer doesn't matter.
return 0;
}

/**********************************************************************/
bool hasSparseChapters(const Geometry *geometry,
uint64_t oldestVirtualChapter,
Expand Down
57 changes: 13 additions & 44 deletions uds/geometry.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/uds-releases/jasper/src/uds/geometry.h#6 $
* $Id: //eng/uds-releases/jasper/src/uds/geometry.h#8 $
*/

#ifndef GEOMETRY_H
Expand Down Expand Up @@ -73,11 +73,8 @@
* <p>If the number of chapters per volume has been reduced by one by
* eliminating physical chapter 0, the virtual chapter that formerly
* mapped to physical chapter 0 may be remapped to another physical
* chapter. This remapping is expressed in terms of how far the
* physical mapping was moved before chapters per volume was
* reduced. This means that a chapter offset of 0 means no chapter was
* remapped.
* XXX This representation subject to change.
* chapter. This remapping is expressed by storing which virtual
* chapter was remapped, and which physical chapter it was moved to.
**/
typedef struct geometry {
/** Length of a page in a chapter, in bytes */
Expand All @@ -90,13 +87,10 @@ typedef struct geometry {
unsigned int sparseChaptersPerVolume;
/** Number of bits used to determine delta list numbers */
unsigned int chapterDeltaListBits;
/** Virtual chapter remapped from physical chapter 0 in order
* to reduce chaptersPerVolume by one */
uint64_t remappedChapter;
/** Offset by which the remapped chapter was moved, one more
* than the post-remapping physical chapter number to which it
* was remapped */
uint64_t chapterOffset;
/** Virtual chapter remapped from physical chapter 0 */
uint64_t remappedVirtual;
/** New physical chapter which remapped chapter was moved to */
uint64_t remappedPhysical;
// These are derived properties, expressed as fields for convenience.
/** Total number of pages in a volume, excluding header */
unsigned int pagesPerVolume;
Expand Down Expand Up @@ -176,8 +170,8 @@ enum {
* @param recordPagesPerChapter The number of pages in a chapter
* @param chaptersPerVolume The number of chapters in a volume
* @param sparseChaptersPerVolume The number of sparse chapters in a volume
* @param remappedChapter The remapped chapter
* @param chapterOffset The offset to the remapped chapter
* @param remappedVirtual The remapped virtual chapter
* @param remappedPhysical The physical chapter remapped to
* @param geometryPtr A pointer to hold the new geometry
*
* @return UDS_SUCCESS or an error code
Expand All @@ -186,8 +180,8 @@ int makeGeometry(size_t bytesPerPage,
unsigned int recordPagesPerChapter,
unsigned int chaptersPerVolume,
unsigned int sparseChaptersPerVolume,
uint64_t remappedChapter,
uint64_t chapterOffset,
uint64_t remappedVirtual,
uint64_t remappedPhysical,
Geometry **geometryPtr)
__attribute__((warn_unused_result));

Expand All @@ -214,39 +208,14 @@ void freeGeometry(Geometry *geometry);
/**
* Map a virtual chapter number to a physical chapter number
*
* XXX Pull out the case of unconverted first.
*
* @param geometry The geometry
* @param virtualChapter The virtual chapter number
*
* @return the corresponding physical chapter number
**/
__attribute__((warn_unused_result))
static INLINE unsigned int mapToPhysicalChapter(const Geometry *geometry,
uint64_t virtualChapter)
{
unsigned int p;
if (geometry->chapterOffset == 0) {
p = (virtualChapter - geometry->remappedChapter) %
geometry->chaptersPerVolume;
} else if (virtualChapter < geometry->remappedChapter) {
// Roll physical chapter backward if in the valid range
if (virtualChapter >= geometry->remappedChapter -
(geometry->chaptersPerVolume - geometry->chapterOffset))
p = geometry->chaptersPerVolume -
(geometry->remappedChapter - virtualChapter);
else // Should never happen in normal operation
p = 0;
} else if (virtualChapter == geometry->remappedChapter) {
p = geometry->chapterOffset - 1;
} else if (virtualChapter <
geometry->remappedChapter + geometry->chapterOffset) {
p = virtualChapter - geometry->remappedChapter - 1;
} else
p = (virtualChapter - geometry->remappedChapter) %
geometry->chaptersPerVolume;
return p;
}
unsigned int mapToPhysicalChapter(const Geometry *geometry,
uint64_t virtualChapter);

/**
* Check whether this geometry is reduced by a chapter
Expand Down
18 changes: 9 additions & 9 deletions uds/indexConfig.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/uds-releases/jasper/src/uds/indexConfig.c#4 $
* $Id: //eng/uds-releases/jasper/src/uds/indexConfig.c#5 $
*/

#include "indexConfig.h"
Expand Down Expand Up @@ -74,8 +74,8 @@ static int decodeIndexConfig_06_02(Buffer *buffer, UdsConfiguration config)
if (result != UDS_SUCCESS) {
return result;
}
config->remappedChapter = 0;
config->chapterOffset = 0;
config->remappedVirtual = 0;
config->remappedPhysical = 0;
if (ASSERT_LOG_ONLY(contentLength(buffer) == 0,
"%zu bytes decoded of %zu expected",
bufferLength(buffer) - contentLength(buffer),
Expand Down Expand Up @@ -125,11 +125,11 @@ static int decodeIndexConfig_08_02(Buffer *buffer, UdsConfiguration config)
if (result != UDS_SUCCESS) {
return result;
}
result = getUInt64LEFromBuffer(buffer, &config->remappedChapter);
result = getUInt64LEFromBuffer(buffer, &config->remappedVirtual);
if (result != UDS_SUCCESS) {
return result;
}
result = getUInt64LEFromBuffer(buffer, &config->chapterOffset);
result = getUInt64LEFromBuffer(buffer, &config->remappedPhysical);
if (result != UDS_SUCCESS) {
return result;
}
Expand Down Expand Up @@ -300,11 +300,11 @@ static int encodeIndexConfig_08_02(Buffer *buffer, UdsConfiguration config)
if (result != UDS_SUCCESS) {
return result;
}
result = putUInt64LEIntoBuffer(buffer, config->remappedChapter);
result = putUInt64LEIntoBuffer(buffer, config->remappedVirtual);
if (result != UDS_SUCCESS) {
return result;
}
result = putUInt64LEIntoBuffer(buffer, config->chapterOffset);
result = putUInt64LEIntoBuffer(buffer, config->remappedPhysical);
if (result != UDS_SUCCESS) {
return result;
}
Expand Down Expand Up @@ -391,8 +391,8 @@ int makeConfiguration(UdsConfiguration conf, Configuration **configPtr)
conf->recordPagesPerChapter,
conf->chaptersPerVolume,
conf->sparseChaptersPerVolume,
conf->remappedChapter,
conf->chapterOffset,
conf->remappedVirtual,
conf->remappedPhysical,
&config->geometry);
if (result != UDS_SUCCESS) {
freeConfiguration(config);
Expand Down
Loading

0 comments on commit df68a45

Please sign in to comment.