@@ -985,7 +985,7 @@ LruDelete(File file)
985985{
986986if (cfs_munmap (vfdP -> map ))
987987elog (ERROR ,"could not unmap file \"%s.cfm\": %m" ,vfdP -> fileName );
988-
988+
989989if (close (vfdP -> md ))
990990elog (ERROR ,"could not close map file \"%s.cfm\": %m" ,vfdP -> fileName );
991991
@@ -1068,10 +1068,10 @@ LruInsert(File file)
10681068 * overall system file table being full. So, be prepared to release
10691069 * another FD if necessary...
10701070 */
1071- if (vfdP -> fileFlags & PG_COMPRESSION )
1071+ if (vfdP -> fileFlags & PG_COMPRESSION )
10721072{
10731073char * mapFileName = psprintf ("%s.cfm" ,vfdP -> fileName );
1074- vfdP -> md = open (mapFileName ,vfdP -> fileFlags & ~PG_COMPRESSION ,vfdP -> fileMode );
1074+ vfdP -> md = BasicOpenFile (mapFileName ,vfdP -> fileFlags & ~PG_COMPRESSION ,vfdP -> fileMode );
10751075pfree (mapFileName );
10761076if (vfdP -> md < 0 )
10771077{
@@ -1598,7 +1598,7 @@ FileClose(File file)
15981598if (unlink (vfdP -> fileName ))
15991599elog (LOG ,"could not unlink file \"%s\": %m" ,vfdP -> fileName );
16001600
1601- if (vfdP -> fileFlags & PG_COMPRESSION ) {
1601+ if (vfdP -> fileFlags & PG_COMPRESSION ) {
16021602char * mapFileName = psprintf ("%s.cfm" ,vfdP -> fileName );
16031603if (unlink (mapFileName ))
16041604elog (LOG ,"could not unlink file \"%s\": %m" ,mapFileName );
@@ -1716,7 +1716,7 @@ FileLock(File file)
17161716
17171717map_generation = vfdP -> map -> generation ;
17181718pg_read_barrier ();
1719-
1719+
17201720/* Reopen file, because it was rewritten by gc */
17211721if (vfdP -> generation != map_generation )
17221722{
@@ -1759,7 +1759,7 @@ FileRead(File file, char *buffer, int amount)
17591759if (VfdCache [file ].seekPos /BLCKSZ >=RELSEG_SIZE )
17601760return 0 ;
17611761
1762- if (!FileLock (file ))
1762+ if (!FileLock (file ))
17631763return -1 ;
17641764
17651765inode = map -> inodes [VfdCache [file ].seekPos /BLCKSZ ];
@@ -1777,7 +1777,7 @@ FileRead(File file, char *buffer, int amount)
17771777return amount ;
17781778}
17791779
1780- seekPos = lseek (VfdCache [file ].fd ,CFS_INODE_OFFS (inode ),SEEK_SET );
1780+ seekPos = lseek (VfdCache [file ].fd ,CFS_INODE_OFFS (inode ),SEEK_SET );
17811781Assert (seekPos == (off_t )CFS_INODE_OFFS (inode ));
17821782
17831783if (amount < BLCKSZ )
@@ -1798,10 +1798,10 @@ FileRead(File file, char *buffer, int amount)
17981798if (errno != EINTR )
17991799{
18001800if (returnCode == 0 )
1801- elog (LOG ,"Block %u position %u size %u is beyond end of compressed file %s" ,
1801+ elog (LOG ,"Block %u position %u size %u is beyond end of compressed file %s" ,
18021802 (uint32 )(VfdCache [file ].seekPos /BLCKSZ ), (uint32 )seekPos ,size ,VfdCache [file ].fileName );
18031803else
1804- elog (LOG ,"Failed to read block %u position %u size %u from compressed file %s: %m" ,
1804+ elog (LOG ,"Failed to read block %u position %u size %u from compressed file %s: %m" ,
18051805 (uint32 )(VfdCache [file ].seekPos /BLCKSZ ), (uint32 )seekPos ,size ,VfdCache [file ].fileName );
18061806cfs_unlock_file (map );
18071807return returnCode ;
@@ -1818,7 +1818,7 @@ FileRead(File file, char *buffer, int amount)
18181818INIT_TRADITIONAL_CRC32 (crc );
18191819COMP_TRADITIONAL_CRC32 (crc ,compressedBuffer ,amount );
18201820FIN_TRADITIONAL_CRC32 (crc );
1821- elog (LOG ,"CFS: decompress error: %d for file %s block %u position %u compressed size %u crc %x" ,
1821+ elog (LOG ,"CFS: decompress error: %d for file %s block %u position %u compressed size %u crc %x" ,
18221822returnCode ,VfdCache [file ].fileName , (uint32 )(VfdCache [file ].seekPos /BLCKSZ ), (uint32 )seekPos ,amount ,crc );
18231823VfdCache [file ].seekPos = FileUnknownPos ;
18241824returnCode = -1 ;
@@ -1835,7 +1835,7 @@ FileRead(File file, char *buffer, int amount)
18351835returnCode = read (VfdCache [file ].fd ,buffer ,amount );
18361836if (returnCode >=0 )
18371837{
1838- if (VfdCache [file ].fileFlags & PG_COMPRESSION )
1838+ if (VfdCache [file ].fileFlags & PG_COMPRESSION )
18391839{
18401840cfs_decrypt (VfdCache [file ].fileName ,buffer ,VfdCache [file ].seekPos ,amount );
18411841}
@@ -1874,7 +1874,7 @@ FileRead(File file, char *buffer, int amount)
18741874VfdCache [file ].seekPos = FileUnknownPos ;
18751875}
18761876
1877- if (VfdCache [file ].fileFlags & PG_COMPRESSION )
1877+ if (VfdCache [file ].fileFlags & PG_COMPRESSION )
18781878{
18791879cfs_unlock_file (VfdCache [file ].map );
18801880}
@@ -1884,7 +1884,7 @@ FileRead(File file, char *buffer, int amount)
18841884int
18851885FileWrite (File file ,char * buffer ,int amount )
18861886{
1887- int returnCode ;
1887+ int returnCode ;
18881888char compressedBuffer [CFS_MAX_COMPRESSED_SIZE (BLCKSZ )];
18891889inode_t inode = 0 ;
18901890/*inode_t prev_inode;*/
@@ -1943,7 +1943,7 @@ FileWrite(File file, char *buffer, int amount)
19431943}
19441944}
19451945
1946- if (VfdCache [file ].fileFlags & PG_COMPRESSION )
1946+ if (VfdCache [file ].fileFlags & PG_COMPRESSION )
19471947{
19481948FileMap * map = VfdCache [file ].map ;
19491949uint32 compressedSize ;
@@ -2019,7 +2019,7 @@ FileWrite(File file, char *buffer, int amount)
20192019if (VfdCache [file ].fileFlags & PG_COMPRESSION )
20202020{
20212021if (returnCode == amount )
2022- {
2022+ {
20232023VfdCache [file ].map -> inodes [VfdCache [file ].seekPos /BLCKSZ ]= inode ;
20242024VfdCache [file ].seekPos += BLCKSZ ;
20252025cfs_extend (VfdCache [file ].map ,VfdCache [file ].seekPos );
@@ -2083,17 +2083,17 @@ FileWrite(File file, char *buffer, int amount)
20832083vfdP -> seekPos = FileUnknownPos ;
20842084}
20852085
2086- if (VfdCache [file ].fileFlags & PG_COMPRESSION )
2086+ if (VfdCache [file ].fileFlags & PG_COMPRESSION )
20872087{
20882088cfs_unlock_file (VfdCache [file ].map );
2089- /*
2090- * If GC is disabled for a long time, thenfaile can unlimited grow.
2089+ /*
2090+ * If GC is disabled for a long time, thenfile can unlimited grow.
20912091 * To avoid wrap aound of 32-bit offsets we force GC on this file when destination position
2092- * cross 2Gb boundary.
2092+ * cross 2Gb boundary.
20932093 */
2094- if ((int32 )pos >=0 && (int32 )(pos + amount )< 0 )
2095- {
2096- elog (LOG ,"CFS: backend %d forced toperforme GC on file %s block %u because it's size exceed %u bytes" ,
2094+ if ((int32 )pos >=0 && (int32 )(pos + amount )< 0 )
2095+ {
2096+ elog (LOG ,"CFS: backend %d forced toperform GC on file %s block %u because it's size exceed %u bytes" ,
20972097MyProcPid ,VfdCache [file ].fileName , (uint32 )(VfdCache [file ].seekPos /BLCKSZ ),pos );
20982098cfs_gc_segment (VfdCache [file ].fileName );
20992099}
@@ -2261,8 +2261,8 @@ FileTruncate(File file, off_t offset)
22612261
22622262pg_atomic_write_u32 (& map -> virtSize ,offset );
22632263pg_atomic_fetch_sub_u32 (& map -> usedSize ,released );
2264-
2265- if (offset == 0 )
2264+
2265+ if (offset == 0 )
22662266{
22672267/* We can truncate compressed file only with zero offset */
22682268pg_atomic_write_u32 (& map -> physSize ,0 );