mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Truncate log and hpfs index file from given sequence number. (#276)
- Truncation is invoked by making truncate system call on /hpfs::index.<seq_no> file. - Updating hpfs binary. - Truncation waits until any active RW and RO sessions are finished.
This commit is contained in:
committed by
GitHub
parent
948113398c
commit
140b2f80fd
@@ -412,4 +412,22 @@ namespace hpfs
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke log file and hpfs index file starting from the given sequence number. This function is a blocking call.
|
||||
* @param seq_no Sequence number to start truncation from.
|
||||
* @return Returns -1 on error and 0 on success.
|
||||
*/
|
||||
int hpfs_mount::truncate_log_file(const uint64_t seq_no)
|
||||
{
|
||||
const std::string file_path = mount_dir + INDEX_UPDATE + "." + std::to_string(seq_no);
|
||||
// File /hpfs::index.<seq_no> is truncated to invoke log file truncation in hpfs.
|
||||
// This call waits until any running RW or RO sessions stop.
|
||||
if (truncate(file_path.c_str(), 0) == -1)
|
||||
{
|
||||
LOG_ERROR << errno << ": Error truncating log file for seq_no: " << std::to_string(seq_no);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace hpfs
|
||||
@@ -68,6 +68,7 @@ namespace hpfs
|
||||
const util::h32 get_parent_hash(const std::string &parent_vpath);
|
||||
void set_parent_hash(const std::string &parent_vpath, const util::h32 new_state);
|
||||
int update_hpfs_log_index();
|
||||
int truncate_log_file(const uint64_t seq_no);
|
||||
};
|
||||
|
||||
} // namespace hpfs
|
||||
|
||||
BIN
test/bin/hpfs
BIN
test/bin/hpfs
Binary file not shown.
Reference in New Issue
Block a user