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

Method updateHeader

src/traffic_cache_tool/CacheTool.cc:834–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834Errata
835Span::updateHeader()
836{
837 Errata zret;
838 int n = _stripes.size();
839 CacheStripeDescriptor *sd;
840 CacheStoreBlocks hdr_size = round_up(sizeof(ts::SpanHeader) + (n - 1) * sizeof(ts::CacheStripeDescriptor));
841 void *raw = ats_memalign(512, hdr_size);
842 ts::SpanHeader *hdr = static_cast<ts::SpanHeader *>(raw);
843 std::bitset<ts::MAX_VOLUME_IDX + 1> volume_mask;
844
845 hdr->magic = ts::SpanHeader::MAGIC;
846 hdr->num_free = 0;
847 hdr->num_used = 0;
848 hdr->num_diskvol_blks = n;
849 hdr->num_blocks = _len;
850
851 sd = hdr->stripes;
852 for (auto stripe : _stripes) {
853 sd->offset = stripe->_start;
854 sd->len = stripe->_len;
855 sd->vol_idx = stripe->_vol_idx;
856 sd->type = stripe->_type;
857 volume_mask[sd->vol_idx] = true;
858 if (sd->vol_idx == 0) {
859 sd->free = true;
860 ++(hdr->num_free);
861 } else {
862 sd->free = false;
863 ++(hdr->num_used);
864 }
865
866 ++sd;
867 }
868 volume_mask[0] = false; // don't include free stripes in distinct volume count.
869 hdr->num_volumes = volume_mask.count();
870 _header.reset(hdr);
871 if (OPEN_RW_FLAG) {
872 ssize_t r = pwrite(_fd, hdr, hdr_size, ts::CacheSpan::OFFSET);
873 if (r < ts::CacheSpan::OFFSET) {
874 zret = Errata(make_errno_code(errno), "Failed to update span.");
875 }
876 } else {
877 std::cout << "Writing not enabled, no updates performed" << std::endl;
878 }
879 return zret;
880}
881
882void
883Span::clearPermanently()

Callers 2

allocateSpanMethod · 0.80
allocateForMethod · 0.80

Calls 7

round_upFunction · 0.85
ats_memalignFunction · 0.85
ErrataClass · 0.85
make_errno_codeFunction · 0.85
sizeMethod · 0.45
countMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected