You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Migrate page checksum filter to C.
This filter exactly mimics the behavior of the Perl filter so is a drop-in replacement. The filter is not integrated yet since it requires the Perl-to-C storage layer interface coming in a future commit.
This commit is contained in:
@ -69,6 +69,7 @@ minimize register spilling. For less sophisticated compilers it might be benefic
|
||||
#include "common/debug.h"
|
||||
#include "common/error.h"
|
||||
#include "common/log.h"
|
||||
#include "postgres/interface.h"
|
||||
#include "postgres/pageChecksum.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -203,6 +204,20 @@ pageChecksum(const unsigned char *page, unsigned int blockNo, unsigned int pageS
|
||||
FUNCTION_TEST_RETURN((uint16_t)(checksum % 65535 + 1));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Return the lsn for a page
|
||||
***********************************************************************************************************************************/
|
||||
uint64_t
|
||||
pageLsn(const unsigned char *page)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM_P(UCHARDATA, page);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
// Reduce to a uint16 with an offset of one. That avoids checksums of zero, which seems like a good idea.
|
||||
FUNCTION_TEST_RETURN((uint64_t)((PageHeader)page)->pd_lsn.walid << 32 | ((PageHeader)page)->pd_lsn.xrecoff);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
pageChecksumTest - test if checksum is valid for a single page
|
||||
***********************************************************************************************************************************/
|
||||
@ -225,8 +240,8 @@ pageChecksumTest(
|
||||
((PageHeader)page)->pd_upper == 0 ||
|
||||
// LSN is after the backup started so checksum is not tested because pages may be torn
|
||||
(((PageHeader)page)->pd_lsn.walid >= ignoreWalId && ((PageHeader)page)->pd_lsn.xrecoff >= ignoreWalOffset) ||
|
||||
// Checksum is valid
|
||||
((PageHeader)page)->pd_checksum == pageChecksum(page, blockNo, pageSize));
|
||||
// Checksum is valid if a full page
|
||||
(pageSize == PG_PAGE_SIZE_DEFAULT && ((PageHeader)page)->pd_checksum == pageChecksum(page, blockNo, pageSize)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user