@ -329,10 +329,6 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
TimeLineID tli , XLogSegNo segno , int segSize )
TimeLineID tli , XLogSegNo segno , int segSize )
{
{
ssize_t readsz ;
ssize_t readsz ;
WALKeyCacheRec * keys = pg_tde_get_wal_cache_keys ( ) ;
XLogRecPtr write_key_lsn ;
WalLocation data_end = { . tli = tli } ;
WalLocation data_start = { . tli = tli } ;
# ifdef TDE_XLOG_DEBUG
# ifdef TDE_XLOG_DEBUG
elog ( DEBUG1 , " read from a WAL segment, size: %lu offset: %ld [%lX], seg: %u_%X/%X " ,
elog ( DEBUG1 , " read from a WAL segment, size: %lu offset: %ld [%lX], seg: %u_%X/%X " ,
@ -344,6 +340,23 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
if ( readsz < = 0 )
if ( readsz < = 0 )
return readsz ;
return readsz ;
TDEXLogCryptBuffer ( buf , count , offset , tli , segno , segSize ) ;
return readsz ;
}
/*
* [ De ] Crypt buffer if needed based on provided segment offset , number and TLI
*/
void
TDEXLogCryptBuffer ( void * buf , size_t count , off_t offset ,
TimeLineID tli , XLogSegNo segno , int segSize )
{
WALKeyCacheRec * keys = pg_tde_get_wal_cache_keys ( ) ;
XLogRecPtr write_key_lsn ;
WalLocation data_end = { . tli = tli } ;
WalLocation data_start = { . tli = tli } ;
if ( ! keys )
if ( ! keys )
{
{
WalLocation start = { . tli = 1 , . lsn = 0 } ;
WalLocation start = { . tli = 1 , . lsn = 0 } ;
@ -377,7 +390,7 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
}
}
XLogSegNoOffsetToRecPtr ( segno , offset , segSize , data_start . lsn ) ;
XLogSegNoOffsetToRecPtr ( segno , offset , segSize , data_start . lsn ) ;
XLogSegNoOffsetToRecPtr ( segno , offset + readsz , segSize , data_end . lsn ) ;
XLogSegNoOffsetToRecPtr ( segno , offset + count , segSize , data_end . lsn ) ;
/*
/*
* TODO : this is higly ineffective . We should get rid of linked list and
* TODO : this is higly ineffective . We should get rid of linked list and
@ -414,7 +427,7 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
/* We have reached the end of the segment */
/* We have reached the end of the segment */
if ( dec_end = = 0 )
if ( dec_end = = 0 )
{
{
dec_end = offset + readsz ;
dec_end = offset + count ;
}
}
dec_sz = dec_end - dec_off ;
dec_sz = dec_end - dec_off ;
@ -433,8 +446,6 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
}
}
}
}
}
}
return readsz ;
}
}
union u128cast
union u128cast