|
|
|
@ -1299,6 +1299,7 @@ mdregistersync(SMgrRelation reln, ForkNumber forknum) |
|
|
|
|
{ |
|
|
|
|
int segno; |
|
|
|
|
int min_inactive_seg; |
|
|
|
|
MdSMgrRelation mdreln = (MdSMgrRelation) reln; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* NOTE: mdnblocks makes sure we have opened all active segments, so that |
|
|
|
@ -1306,7 +1307,7 @@ mdregistersync(SMgrRelation reln, ForkNumber forknum) |
|
|
|
|
*/ |
|
|
|
|
mdnblocks(reln, forknum); |
|
|
|
|
|
|
|
|
|
min_inactive_seg = segno = reln->md_num_open_segs[forknum]; |
|
|
|
|
min_inactive_seg = segno = mdreln->md_num_open_segs[forknum]; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Temporarily open inactive segments, then close them after sync. There |
|
|
|
@ -1314,20 +1315,20 @@ mdregistersync(SMgrRelation reln, ForkNumber forknum) |
|
|
|
|
* harmless. We don't bother to clean them up and take a risk of further |
|
|
|
|
* trouble. The next mdclose() will soon close them. |
|
|
|
|
*/ |
|
|
|
|
while (_mdfd_openseg(reln, forknum, segno, 0) != NULL) |
|
|
|
|
while (_mdfd_openseg(mdreln, forknum, segno, 0) != NULL) |
|
|
|
|
segno++; |
|
|
|
|
|
|
|
|
|
while (segno > 0) |
|
|
|
|
{ |
|
|
|
|
MdfdVec *v = &reln->md_seg_fds[forknum][segno - 1]; |
|
|
|
|
MdfdVec *v = &mdreln->md_seg_fds[forknum][segno - 1]; |
|
|
|
|
|
|
|
|
|
register_dirty_segment(reln, forknum, v); |
|
|
|
|
register_dirty_segment(mdreln, forknum, v); |
|
|
|
|
|
|
|
|
|
/* Close inactive segments immediately */ |
|
|
|
|
if (segno > min_inactive_seg) |
|
|
|
|
{ |
|
|
|
|
FileClose(v->mdfd_vfd); |
|
|
|
|
_fdvec_resize(reln, forknum, segno - 1); |
|
|
|
|
_fdvec_resize(mdreln, forknum, segno - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
segno--; |
|
|
|
|