| 250 | } |
| 251 | |
| 252 | int |
| 253 | Cache::open(bool clear, bool /* fix ATS_UNUSED */) |
| 254 | { |
| 255 | int i; |
| 256 | off_t blocks = 0; |
| 257 | cache_read_done = 0; |
| 258 | total_initialized_vol = 0; |
| 259 | total_nvol = 0; |
| 260 | total_good_nvol = 0; |
| 261 | |
| 262 | REC_EstablishStaticConfigInt32(cache_config_min_average_object_size, "proxy.config.cache.min_average_object_size"); |
| 263 | Dbg(dbg_ctl_cache_init, "Cache::open - proxy.config.cache.min_average_object_size = %d", cache_config_min_average_object_size); |
| 264 | |
| 265 | CacheVol *cp = cp_list.head; |
| 266 | for (; cp; cp = cp->link.next) { |
| 267 | if (cp->scheme == scheme) { |
| 268 | cp->stripes = static_cast<StripeSM **>(ats_malloc(cp->num_vols * sizeof(StripeSM *))); |
| 269 | int vol_no = 0; |
| 270 | for (i = 0; i < gndisks; i++) { |
| 271 | if (cp->disk_stripes[i] && !DISK_BAD(cp->disk_stripes[i]->disk)) { |
| 272 | DiskStripeBlockQueue *q = cp->disk_stripes[i]->dpb_queue.head; |
| 273 | for (; q; q = q->link.next) { |
| 274 | blocks = q->b->len; |
| 275 | CacheDisk *d = cp->disk_stripes[i]->disk; |
| 276 | cp->stripes[vol_no] = new StripeSM(d, blocks, q->b->offset, cp->avg_obj_size, cp->fragment_size); |
| 277 | cp->stripes[vol_no]->cache = this; |
| 278 | cp->stripes[vol_no]->cache_vol = cp; |
| 279 | |
| 280 | bool vol_clear = clear || d->cleared || q->new_block; |
| 281 | cp->stripes[vol_no]->init(vol_clear); |
| 282 | vol_no++; |
| 283 | cache_size += blocks; |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | total_nvol += vol_no; |
| 288 | } |
| 289 | } |
| 290 | if (total_nvol == 0) { |
| 291 | return open_done(); |
| 292 | } |
| 293 | cache_read_done = 1; |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | int |
| 298 | Cache::close() |
no test coverage detected