Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 48d4a13

Browse files
committed
Merge branch 'PGPROEE9_6_CFS_385' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into PGPROEE9_6_CFS_385
2 parents 22f9e7f + 1b33593 commit 48d4a13

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/backend/storage/file/cfs.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,23 +1161,34 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
11611161

11621162
if (cfs_gc_verify_file)
11631163
{
1164+
off_t soff = -1;
11641165
fd = open(file_bck_path, O_RDONLY|PG_BINARY, 0);
11651166
Assert(fd >= 0);
11661167

11671168
for (i = 0; i < n_pages; i++)
11681169
{
1169-
inode_t inode = newMap->inodes[i];
1170+
inodes[i] = &newMap->inodes[i];
1171+
}
1172+
qsort(inodes, n_pages, sizeof(inode_t*), cfs_cmp_page_offs);
1173+
1174+
for (i = 0; i < n_pages; i++)
1175+
{
1176+
inode_t inode = *inodes[i];
11701177
int size = CFS_INODE_SIZE(inode);
11711178
if (size != 0 && size < BLCKSZ)
11721179
{
11731180
char block[BLCKSZ];
11741181
char decomressedBlock[BLCKSZ];
11751182
off_t res PG_USED_FOR_ASSERTS_ONLY;
11761183
bool rc PG_USED_FOR_ASSERTS_ONLY;
1177-
res = lseek(fd, CFS_INODE_OFFS(inode), SEEK_SET);
1178-
Assert(res == (off_t)CFS_INODE_OFFS(inode));
1184+
if (soff != CFS_INODE_OFFS(inode))
1185+
{
1186+
soff = lseek(fd, CFS_INODE_OFFS(inode), SEEK_SET);
1187+
Assert(soff == (off_t)CFS_INODE_OFFS(inode));
1188+
}
11791189
rc = cfs_read_file(fd, block, size);
11801190
Assert(rc);
1191+
soff += size;
11811192
cfs_decrypt(file_bck_path, block, (off_t)i*BLCKSZ, size);
11821193
res = cfs_decompress(decomressedBlock, BLCKSZ, block, size);
11831194

@@ -1480,21 +1491,18 @@ void cfs_gc_start_bgworkers()
14801491
/* Disable garbage collection. */
14811492
void cfs_control_gc_lock(void)
14821493
{
1483-
uint32 was_disabled = pg_atomic_fetch_add_u32(&cfs_state->gc_disabled, 1);
1484-
if (!was_disabled)
1494+
pg_atomic_fetch_add_u32(&cfs_state->gc_disabled, 1);
1495+
/* Wait until there are no active GC workers */
1496+
while (pg_atomic_read_u32(&cfs_state->n_active_gc) != 0)
14851497
{
1486-
/* Wait until there are no active GC workers */
1487-
while (pg_atomic_read_u32(&cfs_state->n_active_gc) != 0)
1488-
{
1489-
int rc = WaitLatch(MyLatch,
1490-
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
1491-
CFS_DISABLE_TIMEOUT /* ms */);
1492-
if (rc & WL_POSTMASTER_DEATH)
1493-
exit(1);
1498+
int rc = WaitLatch(MyLatch,
1499+
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
1500+
CFS_DISABLE_TIMEOUT /* ms */);
1501+
if (rc & WL_POSTMASTER_DEATH)
1502+
exit(1);
14941503

1495-
ResetLatch(MyLatch);
1496-
CHECK_FOR_INTERRUPTS();
1497-
}
1504+
ResetLatch(MyLatch);
1505+
CHECK_FOR_INTERRUPTS();
14981506
}
14991507
}
15001508

src/backend/storage/smgr/md.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ mdunlink(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
477477
mdunlinkfork(rnode, forkNum, isRedo);
478478
}
479479
else
480+
{
480481
mdunlinkfork(rnode, forkNum, isRedo);
481482
}
482483
}

0 commit comments

Comments
 (0)