MCPcopy Create free account
hub / github.com/apache/trafficserver / InitializeMeta

Method InitializeMeta

src/traffic_cache_tool/CacheDefs.cc:238–265  ·  view source on GitHub ↗

TODO: Implement the whole logic

Source from the content-addressed store, hash-verified

236
237// TODO: Implement the whole logic
238Errata
239StripeSM::InitializeMeta()
240{
241 Errata zret;
242 // memset(this->raw_dir, 0, dir_len);
243 for (auto &i : _meta) {
244 for (auto &j : i) {
245 j.magic = StripeMeta::MAGIC;
246 j.version._major = ts::CACHE_DB_MAJOR_VERSION;
247 j.version._minor = ts::CACHE_DB_MINOR_VERSION;
248 j.agg_pos = j.last_write_pos = j.write_pos = this->_content;
249 j.phase = j.cycle = j.sync_serial = j.write_serial = j.dirty = 0;
250 j.create_time = time(nullptr);
251 j.sector_size = DEFAULT_HW_SECTOR_SIZE;
252 }
253 }
254 if (!freelist) // freelist is not allocated yet
255 {
256 freelist = static_cast<uint16_t *>(malloc(_segments * sizeof(uint16_t))); // segments has already been calculated
257 }
258 if (!dir) // for new spans, this will likely be nullptr as we don't need to read the stripe meta from disk
259 {
260 char *raw_dir = static_cast<char *>(ats_memalign(ats_pagesize(), this->vol_dirlen()));
261 dir = reinterpret_cast<CacheDirEntry *>(raw_dir + this->vol_headerlen());
262 }
263 init_dir();
264 return zret;
265}
266
267// Need to be bit more robust at some point.
268bool

Callers 1

clearMethod · 0.80

Calls 4

vol_dirlenMethod · 0.95
vol_headerlenMethod · 0.95
ats_memalignFunction · 0.85
ats_pagesizeFunction · 0.85

Tested by

no test coverage detected