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

Method Scan

src/traffic_cache_tool/CacheScan.cc:36–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34namespace ct
35{
36Errata
37CacheScan::Scan(bool search)
38{
39 int64_t guessed_size = 1048576; // 1M
40 Errata zret;
41 std::bitset<65536> dir_bitset;
42 char *stripe_buff2 = static_cast<char *>(ats_memalign(ats_pagesize(), guessed_size));
43 for (int s = 0; s < this->stripe->_segments; s++) {
44 dir_bitset.reset();
45 for (int b = 0; b < this->stripe->_buckets; b++) {
46 CacheDirEntry *seg = this->stripe->dir_segment(s);
47 CacheDirEntry *e = dir_bucket(b, seg);
48 if (dir_offset(e)) {
49 do {
50 // loop detected
51 if (dir_bitset[dir_to_offset(e, seg)]) {
52 break;
53 }
54 int64_t size = dir_approx_size(e);
55 if (size > guessed_size) {
56 ats_free(stripe_buff2);
57 stripe_buff2 = static_cast<char *>(ats_memalign(ats_pagesize(), dir_approx_size(e)));
58 }
59 int fd = this->stripe->_span->_fd;
60 int64_t offset = this->stripe->stripe_offset(e);
61 ssize_t n = pread(fd, stripe_buff2, size, offset);
62 if (n < 0) {
63 std::cout << "Failed to read content from the Stripe. " << strerror(errno) << std::endl;
64 } else {
65 Doc *doc = reinterpret_cast<Doc *>(stripe_buff2);
66 get_alternates(doc->hdr(), doc->hlen, search);
67 }
68 dir_bitset[dir_to_offset(e, seg)] = true;
69 e = next_dir(e, seg);
70 } while (e);
71 }
72 }
73 }
74 ats_free(stripe_buff2);
75
76 return zret;
77}
78
79Errata
80CacheScan::unmarshal(HTTPHdrImpl *obj, intptr_t offset)

Callers 1

scan_spanFunction · 0.80

Calls 10

ats_memalignFunction · 0.85
ats_pagesizeFunction · 0.85
ats_freeFunction · 0.85
dir_segmentMethod · 0.80
stripe_offsetMethod · 0.80
dir_bucketFunction · 0.70
dir_to_offsetFunction · 0.70
next_dirFunction · 0.70
resetMethod · 0.45
hdrMethod · 0.45

Tested by

no test coverage detected