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

Function fillExclusiveDisks

src/iocore/cache/CacheProcessor.cc:1330–1386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1328}
1329
1330static int
1331fillExclusiveDisks(CacheVol *cp)
1332{
1333 int diskCount = 0;
1334 int volume_number = cp->vol_number;
1335
1336 Dbg(dbg_ctl_cache_init, "volume %d", volume_number);
1337 for (int i = 0; i < gndisks; i++) {
1338 if (gdisks[i]->forced_volume_num != volume_number) {
1339 continue;
1340 }
1341
1342 /* OK, this should be an "exclusive" disk (span). */
1343 diskCount++;
1344
1345 /* There should be a single "forced" volume and no other volumes should exist on this "exclusive" disk (span) */
1346 bool found_nonforced_volumes = false;
1347 for (int j = 0; j < static_cast<int>(gdisks[i]->header->num_volumes); j++) {
1348 if (volume_number != gdisks[i]->disk_stripes[j]->vol_number) {
1349 found_nonforced_volumes = true;
1350 break;
1351 }
1352 }
1353
1354 if (found_nonforced_volumes) {
1355 /* The user had created several volumes before - clear the disk and create one volume for http
1356 */
1357 Note("Clearing Disk: %s", gdisks[i]->path);
1358 gdisks[i]->delete_all_volumes();
1359 } else if (1 == gdisks[i]->header->num_volumes) {
1360 /* "Forced" volumes take the whole disk (span) hence nothing more to do for this span. */
1361 continue;
1362 }
1363
1364 /* Now, volumes have been either deleted or did not exist to begin with so we need to create them. */
1365
1366 int64_t size_diff = gdisks[i]->num_usable_blocks;
1367 DiskStripeBlock *dpb;
1368 do {
1369 dpb = gdisks[i]->create_volume(volume_number, size_diff, cp->scheme);
1370 if (dpb) {
1371 if (!cp->disk_stripes[i]) {
1372 cp->disk_stripes[i] = gdisks[i]->get_diskvol(volume_number);
1373 }
1374 size_diff -= dpb->len;
1375 cp->size += dpb->len;
1376 cp->num_vols++;
1377 } else {
1378 Dbg(dbg_ctl_cache_init, "create_volume failed");
1379 break;
1380 }
1381 } while ((size_diff > 0));
1382 }
1383
1384 /* Report back the number of disks (spans) that were assigned to volume specified by volume_number. */
1385 return diskCount;
1386}
1387

Callers 2

cplist_updateFunction · 0.85
create_volumeFunction · 0.85

Calls 3

delete_all_volumesMethod · 0.80
create_volumeMethod · 0.80
get_diskvolMethod · 0.80

Tested by

no test coverage detected