Skip to content

Commit

Permalink
Version 6.2.9.7
Browse files Browse the repository at this point in the history
- Enhanced vdoPrepareForLVM to be able to repair misaligned conversions.
  • Loading branch information
lorelei-sakai committed May 23, 2023
1 parent 52f8e34 commit 53745c3
Show file tree
Hide file tree
Showing 11 changed files with 557 additions and 119 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.6.2
UDS_VERSION = 8.0.6.3
BUILD_VERSION = $(UDS_VERSION)
DISTRO_CODENAME := $(shell lsb_release -s -c)

Expand Down
28 changes: 27 additions & 1 deletion utils/uds/convertToLVM.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/convertToLVM.c#14 $
* $Id: //eng/uds-releases/jasper/src/uds/convertToLVM.c#15 $
*/

#include "config.h"
Expand Down Expand Up @@ -261,3 +261,29 @@ int udsConvertToLVM(const char *name,
cleanupSession(session);
return UDS_SUCCESS;
}

/**********************************************************************/
int udsRepairConvertToLVM(const char *path,
size_t indexOffset,
size_t newStartOffset)
{
int result;
IOFactory *factory = NULL;
#ifdef __KERNEL__
result = makeIOFactory(path, &factory);
#else
result = makeIOFactory(path, FU_READ_WRITE, &factory);
#endif
if (result != UDS_SUCCESS) {
logError("Failed to make I/O factory");
return result;
}

result = repairLayout(factory, indexOffset, newStartOffset);
if (result != UDS_SUCCESS) {
logError("Failed to repair layout header");
}

putIOFactory(factory);
return result;
}
18 changes: 17 additions & 1 deletion utils/uds/convertToLVM.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/convertToLVM.h#4 $
* $Id: //eng/uds-releases/jasper/src/uds/convertToLVM.h#5 $
*/

#include "uds.h"
Expand Down Expand Up @@ -51,3 +51,19 @@ int udsConvertToLVM(const char *name,
UdsConfiguration config,
off_t *chapterSize)
__attribute__((warn_unused_result));

/**
* Update the lvm offset that is stored in the layout when we repair
* a broken conversion.
*
* @param path The path to the device or file containing the index
* @param indexOffset The offset in the device to load/save the index at
* @param newStartOffset The new value for the index superblock's
* startOffset field
*
* @return UDS_SUCCESS or an error code
*/
int udsRepairConvertToLVM(const char *path,
size_t indexOffset,
size_t newStartOffset)
__attribute__((warn_unused_result));
86 changes: 83 additions & 3 deletions utils/uds/indexLayout.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/indexLayout.c#28 $
* $Id: //eng/uds-releases/jasper/src/uds/indexLayout.c#29 $
*/

#include "indexLayout.h"
Expand All @@ -25,6 +25,7 @@
#include "compiler.h"
#include "config.h"
#include "indexConfig.h"
#include "ioFactory.h"
#include "layoutRegion.h"
#include "logger.h"
#include "masterIndexOps.h"
Expand Down Expand Up @@ -1739,7 +1740,7 @@ int writeIndexConfig(IndexLayout *layout,
UdsConfiguration config,
off_t offset)
{
BufferedWriter *writer = NULL;
BufferedWriter *writer = NULL;
int result = openLayoutWriter(layout, &layout->config, offset, &writer);
if (result != UDS_SUCCESS) {
return logErrorWithStringError(result, "failed to open config region");
Expand Down Expand Up @@ -2216,7 +2217,7 @@ static int writeIndexSaveLayout(IndexLayout *layout, IndexSaveLayout *isl)
return result;
}

BufferedWriter *writer = NULL;
BufferedWriter *writer = NULL;
result = openLayoutWriter(layout, &isl->header,
-layout->super.startOffset,
&writer);
Expand Down Expand Up @@ -2515,3 +2516,82 @@ int updateLayout(IndexLayout *layout,
layout->super = super;
return result;
}

/**
* Repair the super block offset on misaligned conversions.
*
* @param layout the layout to load/save superblock with
* @param newStartOffset The new value for the index superblock's
* startOffset field
*
* @return UDS_SUCCESS or an error code
**/
__attribute__((warn_unused_result))
static int repairSuperBlock(IndexLayout *layout, size_t newStartOffset)
{
BufferedReader *reader;
int result = openBufferedReader(layout->factory, layout->offset,
UDS_BLOCK_SIZE, &reader);
if (result != UDS_SUCCESS) {
return logErrorWithStringError(result, "unable to read superblock");
}

RegionTable *table = NULL;
result = loadRegionTable(reader, &table);
if (result != UDS_SUCCESS) {
freeBufferedReader(reader);
return result;
}

if (table->header.type != RH_TYPE_SUPER) {
FREE(table);
freeBufferedReader(reader);
return logErrorWithStringError(UDS_CORRUPT_COMPONENT,
"not a superblock region table");
}

result = readSuperBlockData(reader, layout, table->header.payload);
freeBufferedReader(reader);
if (result != UDS_SUCCESS) {
FREE(table);
return logErrorWithStringError(result, "unknown superblock format");
}

// Repair the offset
layout->totalBlocks = table->header.regionBlocks;
layout->super.startOffset = newStartOffset / UDS_BLOCK_SIZE;

BufferedWriter *writer;
result = openBufferedWriter(layout->factory, layout->offset,
UDS_BLOCK_SIZE, &writer);
if (result != UDS_SUCCESS) {
FREE(table);
return logErrorWithStringError(result, "unable to write superblock");
}

result = writeSingleFileHeader(layout, table, table->header.numRegions, writer);
FREE(table);
freeBufferedWriter(writer);
return result;
}

/*****************************************************************************/
int repairLayout(IOFactory *factory,
size_t indexOffset,
size_t newStartOffset)
{
IndexLayout *layout = NULL;
int result = ALLOCATE(1, IndexLayout, __func__, &layout);
if (result != UDS_SUCCESS) {
return result;
}
layout->refCount = 1;

getIOFactory(factory);
layout->factory = factory;
layout->offset = indexOffset;

result = repairSuperBlock(layout, newStartOffset);
putIndexLayout(&layout);
return result;
}
20 changes: 18 additions & 2 deletions utils/uds/indexLayout.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/indexLayout.h#17 $
* $Id: //eng/uds-releases/jasper/src/uds/indexLayout.h#18 $
*/

#ifndef INDEX_LAYOUT_H
Expand Down Expand Up @@ -270,11 +270,27 @@ const struct index_version *getIndexVersion(IndexLayout *layout)
* @param lvmOffset The adjustment for lvm space, in bytes
* @param offset The offset in bytes to move the index
*
* @return UDS_SUCCESS or a error code
* @return UDS_SUCCESS or an error code
*/
int updateLayout(IndexLayout *layout,
UdsConfiguration config,
off_t lvmOffset,
off_t offset);

/**
* Repair startOffset and write out the uds superblock
*
* @param factory The factory to make the layout from
* @param indexOffset The offset in the device to load/save the
* index at
* @param newStartOffset The new value for the index superblock's
* startOffset field
*
* @return UDS_SUCCESS or an error code
*/
int repairLayout(IOFactory *factory,
size_t indexOffset,
size_t newStartOffset)
__attribute__((warn_unused_result));

#endif // INDEX_LAYOUT_H
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.9.1
VDO_VERSION = 6.2.9.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#17 $

VDO_VERSION = 6.2.9.1
VDO_VERSION = 6.2.9.7

UDS_DIR = ../../uds
VDO_BASE_DIR = ../base
Expand Down
Loading

0 comments on commit 53745c3

Please sign in to comment.