LCOV - differential code coverage report
Current view: top level - src/include/storage - smgr.h (source / functions) Coverage Total Hit GNC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 6 6 6
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 2 2 2
Baseline: 16@8cea358b128 Branches: - 0 0
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (60,120] days: 100.0 % 6 6 6
Function coverage date bins:
(60,120] days: 100.0 % 2 2 2

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * smgr.h
                                  4                 :                :  *    storage manager switch public interface declarations.
                                  5                 :                :  *
                                  6                 :                :  *
                                  7                 :                :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
                                  8                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  9                 :                :  *
                                 10                 :                :  * src/include/storage/smgr.h
                                 11                 :                :  *
                                 12                 :                :  *-------------------------------------------------------------------------
                                 13                 :                :  */
                                 14                 :                : #ifndef SMGR_H
                                 15                 :                : #define SMGR_H
                                 16                 :                : 
                                 17                 :                : #include "lib/ilist.h"
                                 18                 :                : #include "storage/block.h"
                                 19                 :                : #include "storage/relfilelocator.h"
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * smgr.c maintains a table of SMgrRelation objects, which are essentially
                                 23                 :                :  * cached file handles.  An SMgrRelation is created (if not already present)
                                 24                 :                :  * by smgropen(), and destroyed by smgrdestroy().  Note that neither of these
                                 25                 :                :  * operations imply I/O, they just create or destroy a hashtable entry.  (But
                                 26                 :                :  * smgrdestroy() may release associated resources, such as OS-level file
                                 27                 :                :  * descriptors.)
                                 28                 :                :  *
                                 29                 :                :  * An SMgrRelation may be "pinned", to prevent it from being destroyed while
                                 30                 :                :  * it's in use.  We use this to prevent pointers relcache to smgr from being
                                 31                 :                :  * invalidated.  SMgrRelations that are not pinned are deleted at end of
                                 32                 :                :  * transaction.
                                 33                 :                :  */
                                 34                 :                : typedef struct SMgrRelationData
                                 35                 :                : {
                                 36                 :                :     /* rlocator is the hashtable lookup key, so it must be first! */
                                 37                 :                :     RelFileLocatorBackend smgr_rlocator;    /* relation physical identifier */
                                 38                 :                : 
                                 39                 :                :     /*
                                 40                 :                :      * The following fields are reset to InvalidBlockNumber upon a cache flush
                                 41                 :                :      * event, and hold the last known size for each fork.  This information is
                                 42                 :                :      * currently only reliable during recovery, since there is no cache
                                 43                 :                :      * invalidation for fork extension.
                                 44                 :                :      */
                                 45                 :                :     BlockNumber smgr_targblock; /* current insertion target block */
                                 46                 :                :     BlockNumber smgr_cached_nblocks[MAX_FORKNUM + 1];   /* last known size */
                                 47                 :                : 
                                 48                 :                :     /* additional public fields may someday exist here */
                                 49                 :                : 
                                 50                 :                :     /*
                                 51                 :                :      * Fields below here are intended to be private to smgr.c and its
                                 52                 :                :      * submodules.  Do not touch them from elsewhere.
                                 53                 :                :      */
                                 54                 :                :     int         smgr_which;     /* storage manager selector */
                                 55                 :                : 
                                 56                 :                :     /*
                                 57                 :                :      * for md.c; per-fork arrays of the number of open segments
                                 58                 :                :      * (md_num_open_segs) and the segments themselves (md_seg_fds).
                                 59                 :                :      */
                                 60                 :                :     int         md_num_open_segs[MAX_FORKNUM + 1];
                                 61                 :                :     struct _MdfdVec *md_seg_fds[MAX_FORKNUM + 1];
                                 62                 :                : 
                                 63                 :                :     /*
                                 64                 :                :      * Pinning support.  If unpinned (ie. pincount == 0), 'node' is a list
                                 65                 :                :      * link in list of all unpinned SMgrRelations.
                                 66                 :                :      */
                                 67                 :                :     int         pincount;
                                 68                 :                :     dlist_node  node;
                                 69                 :                : } SMgrRelationData;
                                 70                 :                : 
                                 71                 :                : typedef SMgrRelationData *SMgrRelation;
                                 72                 :                : 
                                 73                 :                : #define SmgrIsTemp(smgr) \
                                 74                 :                :     RelFileLocatorBackendIsTemp((smgr)->smgr_rlocator)
                                 75                 :                : 
                                 76                 :                : extern void smgrinit(void);
                                 77                 :                : extern SMgrRelation smgropen(RelFileLocator rlocator, ProcNumber backend);
                                 78                 :                : extern bool smgrexists(SMgrRelation reln, ForkNumber forknum);
                                 79                 :                : extern void smgrpin(SMgrRelation reln);
                                 80                 :                : extern void smgrunpin(SMgrRelation reln);
                                 81                 :                : extern void smgrclose(SMgrRelation reln);
                                 82                 :                : extern void smgrdestroyall(void);
                                 83                 :                : extern void smgrrelease(SMgrRelation reln);
                                 84                 :                : extern void smgrreleaseall(void);
                                 85                 :                : extern void smgrreleaserellocator(RelFileLocatorBackend rlocator);
                                 86                 :                : extern void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
                                 87                 :                : extern void smgrdosyncall(SMgrRelation *rels, int nrels);
                                 88                 :                : extern void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo);
                                 89                 :                : extern void smgrextend(SMgrRelation reln, ForkNumber forknum,
                                 90                 :                :                        BlockNumber blocknum, const void *buffer, bool skipFsync);
                                 91                 :                : extern void smgrzeroextend(SMgrRelation reln, ForkNumber forknum,
                                 92                 :                :                            BlockNumber blocknum, int nblocks, bool skipFsync);
                                 93                 :                : extern bool smgrprefetch(SMgrRelation reln, ForkNumber forknum,
                                 94                 :                :                          BlockNumber blocknum, int nblocks);
                                 95                 :                : extern void smgrreadv(SMgrRelation reln, ForkNumber forknum,
                                 96                 :                :                       BlockNumber blocknum,
                                 97                 :                :                       void **buffer, BlockNumber nblocks);
                                 98                 :                : extern void smgrwritev(SMgrRelation reln, ForkNumber forknum,
                                 99                 :                :                        BlockNumber blocknum,
                                100                 :                :                        const void **buffer, BlockNumber nblocks,
                                101                 :                :                        bool skipFsync);
                                102                 :                : extern void smgrwriteback(SMgrRelation reln, ForkNumber forknum,
                                103                 :                :                           BlockNumber blocknum, BlockNumber nblocks);
                                104                 :                : extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
                                105                 :                : extern BlockNumber smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum);
                                106                 :                : extern void smgrtruncate(SMgrRelation reln, ForkNumber *forknum,
                                107                 :                :                          int nforks, BlockNumber *nblocks);
                                108                 :                : extern void smgrimmedsync(SMgrRelation reln, ForkNumber forknum);
                                109                 :                : extern void smgrregistersync(SMgrRelation reln, ForkNumber forknum);
                                110                 :                : extern void AtEOXact_SMgr(void);
                                111                 :                : extern bool ProcessBarrierSmgrRelease(void);
                                112                 :                : 
                                113                 :                : static inline void
  118 tmunro@postgresql.or      114                 :GNC         595 : smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
                                115                 :                :          void *buffer)
                                116                 :                : {
                                117                 :            595 :     smgrreadv(reln, forknum, blocknum, &buffer, 1);
                                118                 :            595 : }
                                119                 :                : 
                                120                 :                : static inline void
                                121                 :         531288 : smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
                                122                 :                :           const void *buffer, bool skipFsync)
                                123                 :                : {
                                124                 :         531288 :     smgrwritev(reln, forknum, blocknum, &buffer, 1, skipFsync);
                                125                 :         531288 : }
                                126                 :                : 
                                127                 :                : #endif                          /* SMGR_H */
        

Generated by: LCOV version 2.1-beta2-3-g6141622