mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-19 11:30:07 +02:00
More accurately store checksum in page header
This commit is contained in:
parent
89c01d20c3
commit
ad8d5b6f12
@ -276,7 +276,7 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
|
||||
* pg_checksum_page is calculating it in this way:
|
||||
* (((checksum ^ blkno) % 65535) + 1)
|
||||
*/
|
||||
: (uint16)(((*(uint16*)((PageHeader)page)->pd_linp - 1) ^ blkno) + 1);
|
||||
: (uint16)(((*PAGE_CHECKSUM(page) - 1) ^ blkno) + 1);
|
||||
/*
|
||||
* If checksum is wrong, sleep a bit and then try again
|
||||
* several times. If it didn't help, throw error
|
||||
|
@ -887,7 +887,7 @@ void fio_communicate(int in, int out)
|
||||
: 0;
|
||||
if (hdr.size == sizeof(PageHeaderData))
|
||||
/* calculate checksum without XOR-ing with block number to compare it with page CRC at master */
|
||||
*(int16*)((PageHeader)buf)->pd_linp = pg_checksum_page(buf, 0);
|
||||
*PAGE_CHECKSUM(buf) = pg_checksum_page(buf, 0);
|
||||
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
|
||||
if (hdr.size != 0)
|
||||
IO_CHECK(fio_write_all(out, buf, hdr.size), hdr.size);
|
||||
|
@ -47,6 +47,14 @@ typedef enum
|
||||
#define SYS_CHECK(cmd) do if ((cmd) < 0) { fprintf(stderr, "%s:%d: (%s) %s\n", __FILE__, __LINE__, #cmd, strerror(errno)); exit(EXIT_FAILURE); } while (0)
|
||||
#define IO_CHECK(cmd, size) do { int _rc = (cmd); if (_rc != (size)) { fprintf(stderr, "%s:%d: proceeds %d bytes instead of %d: %s\n", __FILE__, __LINE__, _rc, (int)(size), _rc < 0 ? "end of data" : strerror(errno)); exit(EXIT_FAILURE); } } while (0)
|
||||
|
||||
/*
|
||||
* Store one more checksum in page header.
|
||||
* There is free space at the ned of page header (not used for page verification)
|
||||
* While delta backup we need to calculate checksum at agent, send it to maini pg_probackup instance
|
||||
* adjust it according to the real block number and compare with checksum stored in pd_checksum
|
||||
*/
|
||||
#define PAGE_CHECKSUM(p) ((uint16*)((p) + sizeof(PageHeaderData)) - 1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned cop : 5;
|
||||
|
Loading…
x
Reference in New Issue
Block a user