42
42
#include "utils/memutils.h"
43
43
44
44
/*
45
- * The magnetic disk storage manager keeps track of open file
46
- * descriptors in its own descriptor pool. This is done to make it
47
- * easier to support relations that are larger than the operating
48
- * system's file size limit (often 2GBytes). In order to do that,
49
- * we break relations up into "segment" files that are each shorter than
50
- * the OS file size limit. The segment size is set by the RELSEG_SIZE
51
- * configuration constant in pg_config.h.
45
+ * The magnetic disk storage manager keeps track of open file
46
+ * descriptors in its own descriptor pool. This is done to make it
47
+ * easier to support relations that are larger than the operating
48
+ * system's file size limit (often 2GBytes). In order to do that,
49
+ * we break relations up into "segment" files that are each shorter than
50
+ * the OS file size limit. The segment size is set by the RELSEG_SIZE
51
+ * configuration constant in pg_config.h.
52
52
*
53
- * On disk, a relation must consist of consecutively numbered segment
54
- * files in the pattern
55
- * -- Zero or more full segments of exactly RELSEG_SIZE blocks each
56
- * -- Exactly one partial segment of size 0 <= size < RELSEG_SIZE blocks
57
- * -- Optionally, any number of inactive segments of size 0 blocks.
58
- * The full and partial segments are collectively the "active" segments.
59
- * Inactive segments are those that once contained data but are currently
60
- * not needed because of an mdtruncate() operation. The reason for leaving
61
- * them present at size zero, rather than unlinking them, is that other
62
- * backends and/or the checkpointer might be holding open file references to
63
- * such segments. If the relation expands again after mdtruncate(), such
64
- * that a deactivated segment becomes active again, it is important that
65
- * such file references still be valid --- else data might get written
66
- * out to an unlinked old copy of a segment file that will eventually
67
- * disappear.
53
+ * On disk, a relation must consist of consecutively numbered segment
54
+ * files in the pattern
55
+ * -- Zero or more full segments of exactly RELSEG_SIZE blocks each
56
+ * -- Exactly one partial segment of size 0 <= size < RELSEG_SIZE blocks
57
+ * -- Optionally, any number of inactive segments of size 0 blocks.
58
+ * The full and partial segments are collectively the "active" segments.
59
+ * Inactive segments are those that once contained data but are currently
60
+ * not needed because of an mdtruncate() operation. The reason for leaving
61
+ * them present at size zero, rather than unlinking them, is that other
62
+ * backends and/or the checkpointer might be holding open file references to
63
+ * such segments. If the relation expands again after mdtruncate(), such
64
+ * that a deactivated segment becomes active again, it is important that
65
+ * such file references still be valid --- else data might get written
66
+ * out to an unlinked old copy of a segment file that will eventually
67
+ * disappear.
68
68
*
69
- * File descriptors are stored in the per-fork md_seg_fds arrays inside
70
- * SMgrRelation. The length of these arrays is stored in md_num_open_segs.
71
- * Note that a fork's md_num_open_segs having a specific value does not
72
- * necessarily mean the relation doesn't have additional segments; we may
73
- * just not have opened the next segment yet. (We could not have "all
74
- * segments are in the array" as an invariant anyway, since another backend
75
- * could extend the relation while we aren't looking.) We do not have
76
- * entries for inactive segments, however; as soon as we find a partial
77
- * segment, we assume that any subsequent segments are inactive.
69
+ * File descriptors are stored in the per-fork md_seg_fds arrays inside
70
+ * SMgrRelation. The length of these arrays is stored in md_num_open_segs.
71
+ * Note that a fork's md_num_open_segs having a specific value does not
72
+ * necessarily mean the relation doesn't have additional segments; we may
73
+ * just not have opened the next segment yet. (We could not have "all
74
+ * segments are in the array" as an invariant anyway, since another backend
75
+ * could extend the relation while we aren't looking.) We do not have
76
+ * entries for inactive segments, however; as soon as we find a partial
77
+ * segment, we assume that any subsequent segments are inactive.
78
78
*
79
- * The entire MdfdVec array is palloc'd in the MdCxt memory context.
79
+ * The entire MdfdVec array is palloc'd in the MdCxt memory context.
80
80
*/
81
81
82
82
typedef struct _MdfdVec
@@ -154,7 +154,7 @@ _mdfd_open_flags(void)
154
154
}
155
155
156
156
/*
157
- * mdinit() -- Initialize private state for magnetic disk storage manager.
157
+ * mdinit() -- Initialize private state for magnetic disk storage manager.
158
158
*/
159
159
void
160
160
mdinit (void )
@@ -165,7 +165,7 @@ mdinit(void)
165
165
}
166
166
167
167
/*
168
- * mdexists() -- Does the physical file exist?
168
+ * mdexists() -- Does the physical file exist?
169
169
*
170
170
* Note: this will return true for lingering files, with pending deletions
171
171
*/
@@ -184,7 +184,7 @@ mdexists(SMgrRelation reln, ForkNumber forknum)
184
184
}
185
185
186
186
/*
187
- * mdcreate() -- Create a new relation on magnetic disk.
187
+ * mdcreate() -- Create a new relation on magnetic disk.
188
188
*
189
189
* If isRedo is true, it's okay for the relation to exist already.
190
190
*/
@@ -242,7 +242,7 @@ mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
242
242
}
243
243
244
244
/*
245
- * mdunlink() -- Unlink a relation.
245
+ * mdunlink() -- Unlink a relation.
246
246
*
247
247
* Note that we're passed a RelFileLocatorBackend --- by the time this is called,
248
248
* there won't be an SMgrRelation hashtable entry anymore.
@@ -447,13 +447,13 @@ mdunlinkfork(RelFileLocatorBackend rlocator, ForkNumber forknum, bool isRedo)
447
447
}
448
448
449
449
/*
450
- * mdextend() -- Add a block to the specified relation.
450
+ * mdextend() -- Add a block to the specified relation.
451
451
*
452
- * The semantics are nearly the same as mdwrite(): write at the
453
- * specified position. However, this is to be used for the case of
454
- * extending a relation (i.e., blocknum is at or beyond the current
455
- * EOF). Note that we assume writing a block beyond current EOF
456
- * causes intervening file space to become filled with zeroes.
452
+ * The semantics are nearly the same as mdwrite(): write at the
453
+ * specified position. However, this is to be used for the case of
454
+ * extending a relation (i.e., blocknum is at or beyond the current
455
+ * EOF). Note that we assume writing a block beyond current EOF
456
+ * causes intervening file space to become filled with zeroes.
457
457
*/
458
458
void
459
459
mdextend (SMgrRelation reln , ForkNumber forknum , BlockNumber blocknum ,
@@ -515,10 +515,10 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
515
515
}
516
516
517
517
/*
518
- * mdzeroextend() -- Add new zeroed out blocks to the specified relation.
518
+ * mdzeroextend() -- Add new zeroed out blocks to the specified relation.
519
519
*
520
- * Similar to mdextend(), except the relation can be extended by multiple
521
- * blocks at once and the added blocks will be filled with zeroes.
520
+ * Similar to mdextend(), except the relation can be extended by multiple
521
+ * blocks at once and the added blocks will be filled with zeroes.
522
522
*/
523
523
void
524
524
mdzeroextend (SMgrRelation reln , ForkNumber forknum ,
@@ -623,7 +623,7 @@ mdzeroextend(SMgrRelation reln, ForkNumber forknum,
623
623
}
624
624
625
625
/*
626
- * mdopenfork() -- Open one fork of the specified relation.
626
+ * mdopenfork() -- Open one fork of the specified relation.
627
627
*
628
628
* Note we only open the first segment, when there are multiple segments.
629
629
*
@@ -673,7 +673,7 @@ mdopenfork(SMgrRelation reln, ForkNumber forknum, int behavior)
673
673
}
674
674
675
675
/*
676
- * mdopen() -- Initialize newly-opened relation.
676
+ * mdopen() -- Initialize newly-opened relation.
677
677
*/
678
678
void
679
679
mdopen (SMgrRelation reln )
@@ -684,7 +684,7 @@ mdopen(SMgrRelation reln)
684
684
}
685
685
686
686
/*
687
- * mdclose() -- Close the specified relation, if it isn't closed already.
687
+ * mdclose() -- Close the specified relation, if it isn't closed already.
688
688
*/
689
689
void
690
690
mdclose (SMgrRelation reln , ForkNumber forknum )
@@ -707,7 +707,7 @@ mdclose(SMgrRelation reln, ForkNumber forknum)
707
707
}
708
708
709
709
/*
710
- * mdprefetch() -- Initiate asynchronous read of the specified block of a relation
710
+ * mdprefetch() -- Initiate asynchronous read of the specified block of a relation
711
711
*/
712
712
bool
713
713
mdprefetch (SMgrRelation reln , ForkNumber forknum , BlockNumber blocknum )
@@ -791,7 +791,7 @@ mdwriteback(SMgrRelation reln, ForkNumber forknum,
791
791
}
792
792
793
793
/*
794
- * mdread() -- Read the specified block from a relation.
794
+ * mdread() -- Read the specified block from a relation.
795
795
*/
796
796
void
797
797
mdread (SMgrRelation reln , ForkNumber forknum , BlockNumber blocknum ,
@@ -856,11 +856,11 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
856
856
}
857
857
858
858
/*
859
- * mdwrite() -- Write the supplied block at the appropriate location.
859
+ * mdwrite() -- Write the supplied block at the appropriate location.
860
860
*
861
- * This is to be used only for updating already-existing blocks of a
862
- * relation (ie, those before the current EOF). To extend a relation,
863
- * use mdextend().
861
+ * This is to be used only for updating already-existing blocks of a
862
+ * relation (ie, those before the current EOF). To extend a relation,
863
+ * use mdextend().
864
864
*/
865
865
void
866
866
mdwrite (SMgrRelation reln , ForkNumber forknum , BlockNumber blocknum ,
@@ -924,12 +924,12 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
924
924
}
925
925
926
926
/*
927
- * mdnblocks() -- Get the number of blocks stored in a relation.
927
+ * mdnblocks() -- Get the number of blocks stored in a relation.
928
928
*
929
- * Important side effect: all active segments of the relation are opened
930
- * and added to the md_seg_fds array. If this routine has not been
931
- * called, then only segments up to the last one actually touched
932
- * are present in the array.
929
+ * Important side effect: all active segments of the relation are opened
930
+ * and added to the md_seg_fds array. If this routine has not been
931
+ * called, then only segments up to the last one actually touched
932
+ * are present in the array.
933
933
*/
934
934
BlockNumber
935
935
mdnblocks (SMgrRelation reln , ForkNumber forknum )
@@ -986,7 +986,7 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum)
986
986
}
987
987
988
988
/*
989
- * mdtruncate() -- Truncate relation to specified number of blocks.
989
+ * mdtruncate() -- Truncate relation to specified number of blocks.
990
990
*/
991
991
void
992
992
mdtruncate (SMgrRelation reln , ForkNumber forknum , BlockNumber nblocks )
@@ -1080,7 +1080,7 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
1080
1080
}
1081
1081
1082
1082
/*
1083
- * mdimmedsync() -- Immediately sync a relation to stable storage.
1083
+ * mdimmedsync() -- Immediately sync a relation to stable storage.
1084
1084
*
1085
1085
* Note that only writes already issued are synced; this routine knows
1086
1086
* nothing of dirty buffers that may exist inside the buffer manager. We
@@ -1275,7 +1275,7 @@ DropRelationFiles(RelFileLocator *delrels, int ndelrels, bool isRedo)
1275
1275
1276
1276
1277
1277
/*
1278
- * _fdvec_resize() -- Resize the fork's open segments array
1278
+ * _fdvec_resize() -- Resize the fork's open segments array
1279
1279
*/
1280
1280
static void
1281
1281
_fdvec_resize (SMgrRelation reln ,
@@ -1376,8 +1376,8 @@ _mdfd_openseg(SMgrRelation reln, ForkNumber forknum, BlockNumber segno,
1376
1376
}
1377
1377
1378
1378
/*
1379
- * _mdfd_getseg() -- Find the segment of the relation holding the
1380
- * specified block.
1379
+ * _mdfd_getseg() -- Find the segment of the relation holding the
1380
+ * specified block.
1381
1381
*
1382
1382
* If the segment doesn't exist, we ereport, return NULL, or create the
1383
1383
* segment, according to "behavior". Note: skipFsync is only used in the
0 commit comments