diff --git a/cov/cmdline/check.c.func-sort-c.html b/cov/cmdline/check.c.func-sort-c.html index f692495f..cf689f09 100644 --- a/cov/cmdline/check.c.func-sort-c.html +++ b/cov/cmdline/check.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -73,15 +73,15 @@ blockcmp - 473381 + 473119 repair_step - 252815 + 252549 is_hash_matching - 214888 + 214644 state_check diff --git a/cov/cmdline/check.c.func.html b/cov/cmdline/check.c.func.html index a78876cd..d1422056 100644 --- a/cov/cmdline/check.c.func.html +++ b/cov/cmdline/check.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -65,7 +65,7 @@ blockcmp - 473381 + 473119 file_post @@ -73,7 +73,7 @@ is_hash_matching - 214888 + 214644 is_parity_matching @@ -85,7 +85,7 @@ repair_step - 252815 + 252549 state_check diff --git a/cov/cmdline/check.c.gcov.html b/cov/cmdline/check.c.gcov.html index 35bb07f2..a9fbb187 100644 --- a/cov/cmdline/check.c.gcov.html +++ b/cov/cmdline/check.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -129,64 +129,64 @@ 67 : * Check if a block hash matches the specified buffer. 68 : * Return ==0 if equal 69 : */ - 70 473381 : static int blockcmp(struct snapraid_state* state, int rehash, struct snapraid_block* block, unsigned pos_size, unsigned char* buffer, unsigned char* buffer_zero) + 70 473119 : static int blockcmp(struct snapraid_state* state, int rehash, struct snapraid_block* block, unsigned pos_size, unsigned char* buffer, unsigned char* buffer_zero) 71 : { 72 : unsigned char hash[HASH_MAX]; 73 : 74 : /* now compute the hash of the valid part */ - 75 473381 : if (rehash) { + 75 473119 : if (rehash) { 76 0 : memhash(state->prevhash, state->prevhashseed, hash, buffer, pos_size); 77 : } else { - 78 473381 : memhash(state->hash, state->hashseed, hash, buffer, pos_size); + 78 473119 : memhash(state->hash, state->hashseed, hash, buffer, pos_size); 79 : } 80 : 81 : /* compare the hash */ - 82 473381 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { - 83 19034 : return -1; + 82 473119 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { + 83 19028 : return -1; 84 : } 85 : 86 : /* compare to the end of the block */ - 87 454347 : if (pos_size < state->block_size) { - 88 187568 : if (memcmp(buffer + pos_size, buffer_zero + pos_size, state->block_size - pos_size) != 0) { - 89 39 : return -1; + 87 454091 : if (pos_size < state->block_size) { + 88 187372 : if (memcmp(buffer + pos_size, buffer_zero + pos_size, state->block_size - pos_size) != 0) { + 89 54 : return -1; 90 : } 91 : } 92 : - 93 454308 : return 0; + 93 454037 : return 0; 94 : } 95 : 96 : /** 97 : * Check if the hash of all the failed block we are expecting to recover are now matching. 98 : */ - 99 214888 : static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void* buffer_zero) + 99 214644 : static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void* buffer_zero) 100 : { 101 : unsigned j; 102 : int hash_checked; 103 : - 104 214888 : hash_checked = 0; /* keep track if we check at least one block */ + 104 214644 : hash_checked = 0; /* keep track if we check at least one block */ 105 : 106 : /* check if the recovered blocks are OK */ - 107 673718 : for (j = 0; j < failed_count; ++j) { + 107 673203 : for (j = 0; j < failed_count; ++j) { 108 : /* if we are expected to recover this block */ - 109 477903 : if (!failed[failed_map[j]].is_outofdate + 109 477641 : if (!failed[failed_map[j]].is_outofdate 110 : /* if the block has a hash to check */ - 111 473381 : && block_has_updated_hash(failed[failed_map[j]].block) + 111 473119 : && block_has_updated_hash(failed[failed_map[j]].block) 112 : ) { 113 : /* if a hash doesn't match, fail the check */ - 114 473381 : unsigned pos_size = file_block_size(failed[failed_map[j]].file, failed[failed_map[j]].file_pos, state->block_size); - 115 473381 : if (blockcmp(state, rehash, failed[failed_map[j]].block, pos_size, buffer[failed[failed_map[j]].index], buffer_zero) != 0) { - 116 19073 : log_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]); - 117 19073 : return 0; + 114 473119 : unsigned pos_size = file_block_size(failed[failed_map[j]].file, failed[failed_map[j]].file_pos, state->block_size); + 115 473119 : if (blockcmp(state, rehash, failed[failed_map[j]].block, pos_size, buffer[failed[failed_map[j]].index], buffer_zero) != 0) { + 116 19082 : log_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]); + 117 19082 : return 0; 118 : } 119 : - 120 454308 : hash_checked = 1; + 120 454037 : hash_checked = 1; 121 : } 122 : } 123 : 124 : /* if nothing checked, we reject it */ 125 : /* note that we are excluding this case at upper level */ 126 : /* but checking again doesn't hurt */ - 127 195815 : if (!hash_checked) { + 127 195562 : if (!hash_checked) { 128 : /* LCOV_EXCL_START */ 129 : return 0; 130 : /* LCOV_EXCL_STOP */ @@ -194,8 +194,8 @@ 132 : 133 : /* if we checked something, and no block failed the check */ 134 : /* recompute all the redundancy information */ - 135 195815 : raid_gen(diskmax, state->level, state->block_size, buffer); - 136 195815 : return 1; + 135 195562 : raid_gen(diskmax, state->level, state->block_size, buffer); + 136 195562 : return 1; 137 : } 138 : 139 : /** @@ -221,7 +221,7 @@ 159 : * Return <0 if failure for missing strategy, >0 if data is wrong and we cannot rebuild correctly, 0 on success. 160 : * If success, the parity are computed in the buffer variable. 161 : */ - 162 252815 : static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void** buffer_recov, void* buffer_zero) + 162 252549 : static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void** buffer_recov, void* buffer_zero) 163 : { 164 : unsigned i, n; 165 : int error; @@ -230,7 +230,7 @@ 168 : int ip[LEV_MAX]; 169 : 170 : /* no fix required, already checked at higher level, but just to be sure */ - 171 252815 : if (failed_count == 0) { + 171 252549 : if (failed_count == 0) { 172 : /* LCOV_EXCL_START */ 173 : /* recompute only the parity */ 174 : raid_gen(diskmax, state->level, state->block_size, buffer); @@ -238,28 +238,28 @@ 176 : /* LCOV_EXCL_STOP */ 177 : } 178 : - 179 252815 : n = state->level; - 180 252815 : error = 0; + 179 252549 : n = state->level; + 180 252549 : error = 0; 181 : 182 : /* setup vector of failed disk indexes */ - 183 891917 : for (i = 0; i < failed_count; ++i) - 184 639102 : id[i] = failed[failed_map[i]].index; + 183 891351 : for (i = 0; i < failed_count; ++i) + 184 638802 : id[i] = failed[failed_map[i]].index; 185 : 186 : /* check if there is at least a failed block that can be checked for correctness using the hash */ 187 : /* if there isn't, we have to sacrifice a parity block to check that the result is correct */ - 188 252815 : has_hash = 0; - 189 891917 : for (i = 0; i < failed_count; ++i) { + 188 252549 : has_hash = 0; + 189 891351 : for (i = 0; i < failed_count; ++i) { 190 : /* if we are expected to recover this block */ - 191 639102 : if (!failed[failed_map[i]].is_outofdate + 191 638802 : if (!failed[failed_map[i]].is_outofdate 192 : /* if the block has a hash to check */ - 193 630058 : && block_has_updated_hash(failed[failed_map[i]].block) + 193 629758 : && block_has_updated_hash(failed[failed_map[i]].block) 194 : ) - 195 630050 : has_hash = 1; + 195 629750 : has_hash = 1; 196 : } 197 : 198 : /* if we don't have a hash, but we have an extra parity */ 199 : /* (strictly-less failures than number of parities) */ - 200 252815 : if (!has_hash && failed_count < n) { + 200 252549 : if (!has_hash && failed_count < n) { 201 : /* number of parity to use, one more to check the recovering */ 202 8 : unsigned r = failed_count + 1; 203 : @@ -299,51 +299,51 @@ 237 : 238 : /* if we have a hash, and enough parities */ 239 : /* (less-or-equal failures than number of parities) */ - 240 252807 : if (has_hash && failed_count <= n) { + 240 252541 : if (has_hash && failed_count <= n) { 241 : /* number of parities to use equal at the number of failures */ - 242 205145 : unsigned r = failed_count; + 242 204895 : unsigned r = failed_count; 243 : 244 : /* all combinations (r of n) parities */ - 245 205145 : combination_first(r, n, ip); + 245 204895 : combination_first(r, n, ip); 246 : do { 247 : /* if a parity is missing, do nothing */ - 248 692791 : for (i = 0; i < r; ++i) { - 249 477903 : if (buffer_recov[ip[i]] == 0) + 248 692285 : for (i = 0; i < r; ++i) { + 249 477641 : if (buffer_recov[ip[i]] == 0) 250 0 : break; 251 : } - 252 214888 : if (i != r) + 252 214644 : if (i != r) 253 0 : continue; 254 : 255 : /* copy the parities to use */ - 256 692791 : for (i = 0; i < r; ++i) - 257 477903 : memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size); + 256 692285 : for (i = 0; i < r; ++i) + 257 477641 : memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size); 258 : 259 : /* recover */ - 260 214888 : raid_data(r, id, ip, diskmax, state->block_size, buffer); + 260 214644 : raid_data(r, id, ip, diskmax, state->block_size, buffer); 261 : 262 : /* use the hash to check the result */ - 263 214888 : if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero)) - 264 195815 : return 0; + 263 214644 : if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero)) + 264 195562 : return 0; 265 : 266 : /* log */ - 267 19073 : log_tag("parity_error:%u:", pos); - 268 38146 : for (i = 0; i < r; ++i) { - 269 19073 : if (i != 0) + 267 19082 : log_tag("parity_error:%u:", pos); + 268 38164 : for (i = 0; i < r; ++i) { + 269 19082 : if (i != 0) 270 0 : log_tag("/"); - 271 19073 : log_tag("%s", lev_config_name(ip[i])); + 271 19082 : log_tag("%s", lev_config_name(ip[i])); 272 : } - 273 19073 : log_tag(":hash: Hash mismatch\n"); - 274 19073 : ++error; - 275 38146 : } while (combination_next(r, n, ip)); + 273 19082 : log_tag(":hash: Hash mismatch\n"); + 274 19082 : ++error; + 275 38164 : } while (combination_next(r, n, ip)); 276 : } 277 : 278 : /* return the number of failed attempts, or -1 if no strategy */ - 279 56992 : if (error) - 280 9330 : return error; + 279 56979 : if (error) + 280 9333 : return error; 281 : - 282 47662 : log_tag("strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n", + 282 47646 : log_tag("strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n", 283 : pos, failed_count, n, has_hash ? "with" : "without"); - 284 47662 : return -1; + 284 47646 : return -1; 285 : } 286 : 287 870958 : static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void** buffer_recov, void* buffer_zero) @@ -360,47 +360,47 @@ 298 : 299 : /* if nothing failed, just recompute the parity */ 300 870958 : if (failed_count == 0) { - 301 583231 : raid_gen(diskmax, state->level, state->block_size, buffer); - 302 583231 : return 0; + 301 583497 : raid_gen(diskmax, state->level, state->block_size, buffer); + 302 583497 : return 0; 303 : } 304 : 305 : /* logs the status */ - 306 1016848 : for (j = 0; j < failed_count; ++j) { + 306 1016282 : for (j = 0; j < failed_count; ++j) { 307 : const char* desc; 308 : const char* hash; 309 : const char* data; - 310 729121 : struct snapraid_block* block = failed[j].block; - 311 729121 : unsigned block_state = block_state_get(block); + 310 728821 : struct snapraid_block* block = failed[j].block; + 311 728821 : unsigned block_state = block_state_get(block); 312 : - 313 729121 : switch (block_state) { + 313 728821 : switch (block_state) { 314 18454 : case BLOCK_STATE_DELETED : desc = "delete"; break; 315 13851 : case BLOCK_STATE_CHG : desc = "change"; break; 316 62282 : case BLOCK_STATE_REP : desc = "replace"; break; - 317 634534 : case BLOCK_STATE_BLK : desc = "block"; break; + 317 634234 : case BLOCK_STATE_BLK : desc = "block"; break; 318 : /* LCOV_EXCL_START */ 319 : default : desc = "unknown"; break; 320 : /* LCOV_EXCL_STOP */ 321 : } 322 : - 323 729121 : if (hash_is_invalid(block->hash)) { + 323 728821 : if (hash_is_invalid(block->hash)) { 324 13843 : hash = "lost"; - 325 715278 : } else if (hash_is_zero(block->hash)) { + 325 714978 : } else if (hash_is_zero(block->hash)) { 326 8 : hash = "zero"; 327 : } else { - 328 715270 : hash = "known"; + 328 714970 : hash = "known"; 329 : } 330 : - 331 729121 : if (failed[j].is_bad) - 332 643396 : data = "bad"; + 331 728821 : if (failed[j].is_bad) + 332 643096 : data = "bad"; 333 : else 334 85725 : data = "good"; 335 : - 336 729121 : if (failed[j].file) { - 337 710667 : struct snapraid_disk* disk = failed[j].disk; - 338 710667 : struct snapraid_file* file = failed[j].file; - 339 710667 : block_off_t file_pos = failed[j].file_pos; + 336 728821 : if (failed[j].file) { + 337 710367 : struct snapraid_disk* disk = failed[j].disk; + 338 710367 : struct snapraid_file* file = failed[j].file; + 339 710367 : block_off_t file_pos = failed[j].file_pos; 340 : - 341 710667 : log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, desc, hash, data, disk->name, esc_tag(file->sub, esc_buffer), file_pos); + 341 710367 : log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, desc, hash, data, disk->name, esc_tag(file->sub, esc_buffer), file_pos); 342 : } else { 343 18454 : log_tag("entry:%u:%s:%s:%s:\n", j, desc, hash, data); 344 : } @@ -422,35 +422,35 @@ 360 : /* We are interested to recover BLK, REP and CHG blocks if they are marked as bad, */ 361 : /* but we are not interested in DELETED ones. */ 362 : - 363 287727 : n = 0; - 364 287727 : something_to_recover = 0; /* keep track if there is at least one block to fix */ - 365 1016848 : for (j = 0; j < failed_count; ++j) { - 366 729121 : if (failed[j].is_bad) { - 367 643396 : unsigned block_state = block_state_get(failed[j].block); + 363 287461 : n = 0; + 364 287461 : something_to_recover = 0; /* keep track if there is at least one block to fix */ + 365 1016282 : for (j = 0; j < failed_count; ++j) { + 366 728821 : if (failed[j].is_bad) { + 367 643096 : unsigned block_state = block_state_get(failed[j].block); 368 : - 369 643396 : assert(block_state != BLOCK_STATE_DELETED); /* we cannot have bad DELETED blocks */ + 369 643096 : assert(block_state != BLOCK_STATE_DELETED); /* we cannot have bad DELETED blocks */ 370 : 371 : /* if we have the hash for it */ - 372 643396 : if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP) + 372 643096 : if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP) 373 : /* try to fetch the block using the known hash */ - 374 643388 : && (state_import_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0 - 375 638916 : || state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0) + 374 643088 : && (state_import_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0 + 375 638616 : || state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0) 376 : ) { 377 : /* we already have corrected it! */ 378 22382 : log_tag("hash_import: Fixed entry %u\n", j); 379 : } else { 380 : /* otherwise try to recover it */ - 381 621014 : failed_map[n] = j; - 382 621014 : ++n; + 381 620714 : failed_map[n] = j; + 382 620714 : ++n; 383 : 384 : /* we have something to try to recover */ - 385 621014 : something_to_recover = 1; + 385 620714 : something_to_recover = 1; 386 : } 387 : } 388 : } 389 : 390 : /* if nothing to fix */ - 391 287727 : if (!something_to_recover) { + 391 287461 : if (!something_to_recover) { 392 43956 : log_tag("recover_sync:%u:%u: Skipped for already recovered\n", pos, n); 393 : 394 : /* recompute only the parity */ @@ -458,22 +458,22 @@ 396 43956 : return 0; 397 : } 398 : - 399 243771 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); - 400 243771 : if (ret == 0) { + 399 243505 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); + 400 243505 : if (ret == 0) { 401 : /* reprocess the CHG blocks, for which we don't have a hash to check */ 402 : /* if they were BAD we have to use some heuristics to ensure that we have recovered */ 403 : /* the state after the sync. If unsure, we assume the worst case */ 404 : - 405 667722 : for (j = 0; j < failed_count; ++j) { + 405 667198 : for (j = 0; j < failed_count; ++j) { 406 : /* we take care only of BAD blocks we have to write back */ - 407 476421 : if (failed[j].is_bad) { - 408 462949 : unsigned block_state = block_state_get(failed[j].block); + 407 476150 : if (failed[j].is_bad) { + 408 462678 : unsigned block_state = block_state_get(failed[j].block); 409 : 410 : /* BLK and REP blocks are always OK, because at this point */ 411 : /* we have already checked their hash */ - 412 462949 : if (block_state != BLOCK_STATE_CHG) { - 413 462941 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); - 414 462941 : continue; + 412 462678 : if (block_state != BLOCK_STATE_CHG) { + 413 462670 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); + 414 462670 : continue; 415 : } 416 : 417 : /* for CHG blocks we have to 'guess' if they are correct or not */ @@ -515,15 +515,15 @@ 453 : } 454 : } 455 : - 456 191301 : return 0; + 456 191048 : return 0; 457 : } - 458 52470 : if (ret > 0) - 459 9330 : error += ret; + 458 52457 : if (ret > 0) + 459 9333 : error += ret; 460 : - 461 52470 : if (ret < 0) - 462 43140 : log_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n); + 461 52457 : if (ret < 0) + 462 43124 : log_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n); 463 : else - 464 9330 : log_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret); + 464 9333 : log_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret); 465 : 466 : /* Now assume that the parity IS NOT updated at the current state, */ 467 : /* but still represent the state before the last 'sync' process. */ @@ -533,15 +533,15 @@ 471 : /* but we are not interested to recover CHG (new version) and REP (new version) blocks, */ 472 : /* even if marked as bad, because we don't have parity for them and it's just impossible, */ 473 : /* and we are not interested to recover DELETED ones. */ - 474 52470 : n = 0; - 475 52470 : something_to_recover = 0; /* keep track if there is at least one block to fix */ - 476 52470 : something_unsynced = 0; /* keep track if we have some unsynced info to process */ - 477 232734 : for (j = 0; j < failed_count; ++j) { - 478 180264 : unsigned block_state = block_state_get(failed[j].block); + 474 52457 : n = 0; + 475 52457 : something_to_recover = 0; /* keep track if there is at least one block to fix */ + 476 52457 : something_unsynced = 0; /* keep track if we have some unsynced info to process */ + 477 232692 : for (j = 0; j < failed_count; ++j) { + 478 180235 : unsigned block_state = block_state_get(failed[j].block); 479 : - 480 180264 : if (block_state == BLOCK_STATE_DELETED - 481 171220 : || block_state == BLOCK_STATE_CHG - 482 171220 : || block_state == BLOCK_STATE_REP + 480 180235 : if (block_state == BLOCK_STATE_DELETED + 481 171191 : || block_state == BLOCK_STATE_CHG + 482 171191 : || block_state == BLOCK_STATE_REP 483 : ) { 484 : /* If the block is CHG, REP or DELETED, we don't have the original content of block, */ 485 : /* and we must try to recover it. */ @@ -583,24 +583,24 @@ 521 : /* it also applies to CHG and DELETE blocks because we want to have */ 522 : /* a successful recovering only if a BLK one is matching */ 523 9044 : failed[j].is_outofdate = 1; - 524 171220 : } else if (failed[j].is_bad) { + 524 171191 : } else if (failed[j].is_bad) { 525 : /* If the block is bad we don't know its content, and we try to recover it */ 526 : /* At this point, we can have only BLK ones */ 527 : - 528 171220 : assert(block_state == BLOCK_STATE_BLK); + 528 171191 : assert(block_state == BLOCK_STATE_BLK); 529 : 530 : /* we have something we are interested to recover */ - 531 171220 : something_to_recover = 1; + 531 171191 : something_to_recover = 1; 532 : 533 : /* we try to recover it */ - 534 171220 : failed_map[n] = j; - 535 171220 : ++n; + 534 171191 : failed_map[n] = j; + 535 171191 : ++n; 536 : } 537 : } 538 : 539 : /* if nothing to fix, we just don't try */ 540 : /* if nothing unsynced we also don't retry, because it's the same try as before */ - 541 52470 : if (something_to_recover && something_unsynced) { + 541 52457 : if (something_to_recover && something_unsynced) { 542 9044 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); 543 9044 : if (ret == 0) { 544 : /* reprocess the REP and CHG blocks, for which we have recovered and old state */ @@ -634,17 +634,17 @@ 572 : else 573 0 : log_tag("recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret); 574 : } else { - 575 43426 : log_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n, + 575 43413 : log_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n, 576 : !something_to_recover ? " nothing to recover" : "", 577 : !something_unsynced ? " nothing unsynched" : "" 578 : ); 579 : } 580 : 581 : /* return the number of failed attempts, or -1 if no strategy */ - 582 47948 : if (error) - 583 4808 : return error; + 582 47935 : if (error) + 583 4811 : return error; 584 : else - 585 43140 : return -1; + 585 43124 : return -1; 586 : } 587 : 588 : /** @@ -718,12 +718,12 @@ 656 : /* rename it to .unrecoverable */ 657 : char path_to[PATH_MAX]; 658 : - 659 63287 : pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", disk->dir, file->sub); + 659 63275 : pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", disk->dir, file->sub); 660 : 661 : /* ensure to close the file before renaming */ - 662 63287 : if (handle[j].file == file) { - 663 63287 : ret = handle_close(&handle[j]); - 664 63287 : if (ret != 0) { + 662 63275 : if (handle[j].file == file) { + 663 63275 : ret = handle_close(&handle[j]); + 664 63275 : if (ret != 0) { 665 : /* LCOV_EXCL_START */ 666 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno)); 667 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -732,8 +732,8 @@ 670 : } 671 : } 672 : - 673 63287 : ret = rename(path, path_to); - 674 63287 : if (ret != 0) { + 673 63275 : ret = rename(path, path_to); + 674 63275 : if (ret != 0) { 675 : /* LCOV_EXCL_START */ 676 : log_fatal("Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno)); 677 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); @@ -741,22 +741,22 @@ 679 : /* LCOV_EXCL_STOP */ 680 : } 681 : - 682 63287 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 683 63287 : msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); + 682 63275 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 683 63275 : msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); 684 : 685 : /* and do not set the time if damaged */ - 686 63287 : goto close_and_continue; + 686 63275 : goto close_and_continue; 687 : } 688 : 689 : /* if the file is not fixed, meaning that it is untouched */ - 690 693947 : if (!file_flag_has(file, FILE_IS_FIXED)) { + 690 693959 : if (!file_flag_has(file, FILE_IS_FIXED)) { 691 : /* nothing to do, but close the file */ - 692 574476 : goto close_and_continue; + 692 574554 : goto close_and_continue; 693 : } 694 : 695 : /* if the file is closed or different than the one expected, reopen it */ 696 : /* a different open file could happen when filtering for bad blocks */ - 697 119471 : if (handle[j].file != file) { + 697 119405 : if (handle[j].file != file) { 698 : /* close a potential different file */ 699 0 : ret = handle_close(&handle[j]); 700 0 : if (ret != 0) { @@ -779,13 +779,13 @@ 717 : } 718 : } 719 : - 720 119471 : log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 721 119471 : msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer)); + 720 119405 : log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 721 119405 : msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer)); 722 : - 723 119471 : inode = handle[j].st.st_ino; + 723 119405 : inode = handle[j].st.st_ino; 724 : 725 : /* search for the corresponding inode */ - 726 119471 : collide_file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); + 726 119405 : collide_file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); 727 : 728 : /* if the inode is already in the database and it refers at a different file name, */ 729 : /* we can fix the file time ONLY if the time and size allow to differentiate */ @@ -795,15 +795,15 @@ 733 : /* when recreating them the inodes may be reused in a different order, */ 734 : /* and at the next sync some files may have matching inode/size/time even if different name */ 735 : /* not allowing sync to detect that the file is changed and not renamed */ - 736 119471 : if (!collide_file /* if not in the database, there is no collision */ - 737 37421 : || strcmp(collide_file->sub, file->sub) == 0 /* if the name is the same, it's the right collision */ - 738 28313 : || collide_file->size != file->size /* if the size is different, the collision is identified */ - 739 9 : || collide_file->mtime_sec != file->mtime_sec /* if the mtime is different, the collision is identified */ - 740 7 : || collide_file->mtime_nsec != file->mtime_nsec /* same for mtime_nsec */ + 736 119405 : if (!collide_file /* if not in the database, there is no collision */ + 737 31334 : || strcmp(collide_file->sub, file->sub) == 0 /* if the name is the same, it's the right collision */ + 738 22534 : || collide_file->size != file->size /* if the size is different, the collision is identified */ + 739 2 : || collide_file->mtime_sec != file->mtime_sec /* if the mtime is different, the collision is identified */ + 740 1 : || collide_file->mtime_nsec != file->mtime_nsec /* same for mtime_nsec */ 741 : ) { 742 : /* set the original modification time */ - 743 119471 : ret = handle_utime(&handle[j]); - 744 238942 : if (ret == -1) { + 743 119405 : ret = handle_utime(&handle[j]); + 744 238810 : if (ret == -1) { 745 : /* LCOV_EXCL_START */ 746 : /* mark the file as damaged */ 747 : file_flag_set(file, FILE_IS_DAMAGED); @@ -818,21 +818,21 @@ 756 : /* we are not fixing, but only checking */ 757 : /* print just the final status */ 758 1308032 : if (file_flag_has(file, FILE_IS_DAMAGED)) { - 759 9468 : if (state->opt.auditonly) { - 760 2829 : log_tag("status:damaged:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 761 2829 : msg_info("damaged %s\n", fmt_term(disk, file->sub, esc_buffer)); + 759 9420 : if (state->opt.auditonly) { + 760 2798 : log_tag("status:damaged:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 761 2798 : msg_info("damaged %s\n", fmt_term(disk, file->sub, esc_buffer)); 762 : } else { - 763 6639 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 764 6639 : msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); + 763 6622 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 764 6622 : msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); 765 : } - 766 1298564 : } else if (file_flag_has(file, FILE_IS_FIXED)) { - 767 76301 : log_tag("status:recoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 768 76301 : msg_info("recoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); + 766 1298612 : } else if (file_flag_has(file, FILE_IS_FIXED)) { + 767 76223 : log_tag("status:recoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 768 76223 : msg_info("recoverable %s\n", fmt_term(disk, file->sub, esc_buffer)); 769 : } else { 770 : /* we don't use msg_verbose() because it also goes into the log */ - 771 1222263 : if (msg_level >= MSG_VERBOSE) { - 772 23199 : log_tag("status:correct:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 773 23199 : msg_info("correct %s\n", fmt_term(disk, file->sub, esc_buffer)); + 771 1222389 : if (msg_level >= MSG_VERBOSE) { + 772 23229 : log_tag("status:correct:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 773 23229 : msg_info("correct %s\n", fmt_term(disk, file->sub, esc_buffer)); 774 : } 775 : } 776 : } @@ -844,8 +844,8 @@ 782 2162259 : if (handle[j].file == file) { 783 : /* ensure to close the file just after finishing with it */ 784 : /* to avoid to keep it open without any possible use */ - 785 1978527 : ret = handle_close(&handle[j]); - 786 1978527 : if (ret != 0) { + 785 1978605 : ret = handle_close(&handle[j]); + 786 1978605 : if (ret != 0) { 787 : /* LCOV_EXCL_START */ 788 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno)); 789 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -1013,7 +1013,7 @@ 951 5461398 : if (!disk) { 952 : /* use an empty block */ 953 14061 : memset(buffer[j], 0, state->block_size); - 954 955271 : continue; + 954 954823 : continue; 955 : } 956 : 957 : /* if the disk block is not used */ @@ -1069,8 +1069,8 @@ 1007 : /* if the file is closed or different than the current one */ 1008 5236820 : if (handle[j].file == 0 || handle[j].file != file) { 1009 : /* close the old one, if any */ - 1010 2259726 : ret = handle_close(&handle[j]); - 1011 2259726 : if (ret == -1) { + 1010 2259576 : ret = handle_close(&handle[j]); + 1011 2259576 : if (ret == -1) { 1012 : /* LCOV_EXCL_START */ 1013 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc_tag(handle[j].file->sub, esc_buffer), strerror(errno)); 1014 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -1081,10 +1081,10 @@ 1019 : } 1020 : 1021 : /* if fixing, and the file is not excluded, we must open for writing */ - 1022 2259726 : if (fix && !file_flag_has(file, FILE_IS_EXCLUDED)) { + 1022 2259576 : if (fix && !file_flag_has(file, FILE_IS_EXCLUDED)) { 1023 : /* if fixing, create the file, open for writing and resize if required */ - 1024 771305 : ret = handle_create(&handle[j], file, state->file_mode); - 1025 771305 : if (ret == -1) { + 1024 771283 : ret = handle_create(&handle[j], file, state->file_mode); + 1025 771283 : if (ret == -1) { 1026 : /* LCOV_EXCL_START */ 1027 : if (errno == EACCES) { 1028 : log_fatal("WARNING! Please give write permission to the file.\n"); @@ -1098,69 +1098,69 @@ 1036 : } 1037 : 1038 : /* check if the file was just created */ - 1039 1542610 : if (handle[j].created != 0) { + 1039 1542566 : if (handle[j].created != 0) { 1040 : /* if fragmented, it may be reopened, so remember that the file */ 1041 : /* was originally missing */ - 1042 113067 : file_flag_set(file, FILE_IS_CREATED); + 1042 113044 : file_flag_set(file, FILE_IS_CREATED); 1043 : } 1044 : } else { 1045 : /* open the file only for reading */ - 1046 1488421 : if (!file_flag_has(file, FILE_IS_MISSING)) - 1047 1372845 : ret = handle_open(&handle[j], file, state->file_mode, - 1048 1372845 : log_error, state->opt.expected_missing ? log_expected : 0); + 1046 1488293 : if (!file_flag_has(file, FILE_IS_MISSING)) + 1047 1372856 : ret = handle_open(&handle[j], file, state->file_mode, + 1048 1372856 : log_error, state->opt.expected_missing ? log_expected : 0); 1049 : else - 1050 115576 : ret = -1; /* if the file is missing, we cannot open it */ - 1051 1488421 : if (ret == -1) { + 1050 115437 : ret = -1; /* if the file is missing, we cannot open it */ + 1051 1488293 : if (ret == -1) { 1052 : /* save the failed block for the check/fix */ - 1053 194224 : failed[failed_count].is_bad = 1; - 1054 194224 : failed[failed_count].is_outofdate = 0; - 1055 194224 : failed[failed_count].index = j; - 1056 194224 : failed[failed_count].block = block; - 1057 194224 : failed[failed_count].disk = disk; - 1058 194224 : failed[failed_count].file = file; - 1059 194224 : failed[failed_count].file_pos = file_pos; - 1060 194224 : failed[failed_count].handle = &handle[j]; - 1061 194224 : ++failed_count; + 1053 194019 : failed[failed_count].is_bad = 1; + 1054 194019 : failed[failed_count].is_outofdate = 0; + 1055 194019 : failed[failed_count].index = j; + 1056 194019 : failed[failed_count].block = block; + 1057 194019 : failed[failed_count].disk = disk; + 1058 194019 : failed[failed_count].file = file; + 1059 194019 : failed[failed_count].file_pos = file_pos; + 1060 194019 : failed[failed_count].handle = &handle[j]; + 1061 194019 : ++failed_count; 1062 : - 1063 194224 : log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos); - 1064 194224 : ++error; + 1063 194019 : log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos); + 1064 194019 : ++error; 1065 : 1066 : /* mark the file as missing, to avoid to retry to open it again */ 1067 : /* note that this can be done only if we are not fixing it */ 1068 : /* otherwise, it could be recreated */ - 1069 194224 : file_flag_set(file, FILE_IS_MISSING); - 1070 194224 : continue; + 1069 194019 : file_flag_set(file, FILE_IS_MISSING); + 1070 194019 : continue; 1071 : } 1072 : } 1073 : 1074 : /* if it's the first open, and not excluded */ - 1075 2065502 : if (!file_flag_has(file, FILE_IS_OPENED) - 1076 2050149 : && !file_flag_has(file, FILE_IS_EXCLUDED)) { + 1075 2065557 : if (!file_flag_has(file, FILE_IS_OPENED) + 1076 2050191 : && !file_flag_has(file, FILE_IS_EXCLUDED)) { 1077 : 1078 : /* check if the file is changed */ - 1079 1998718 : if (handle[j].st.st_size != file->size - 1080 1805971 : || handle[j].st.st_mtime != file->mtime_sec - 1081 1781347 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec + 1079 1998760 : if (handle[j].st.st_size != file->size + 1080 1805894 : || handle[j].st.st_mtime != file->mtime_sec + 1081 1781363 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec 1082 : /* don't check the inode to support file-system without persistent inodes */ 1083 : ) { 1084 : /* report that the file is not synced */ - 1085 217371 : file_flag_set(file, FILE_IS_UNSYNCED); + 1085 217397 : file_flag_set(file, FILE_IS_UNSYNCED); 1086 : } 1087 : } 1088 : 1089 : /* if it's the first open, and not excluded and larger */ - 1090 2065502 : if (!file_flag_has(file, FILE_IS_OPENED) - 1091 2050149 : && !file_flag_has(file, FILE_IS_EXCLUDED) - 1092 1998718 : && !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED)) - 1093 1998718 : && handle[j].st.st_size > file->size + 1090 2065557 : if (!file_flag_has(file, FILE_IS_OPENED) + 1091 2050191 : && !file_flag_has(file, FILE_IS_EXCLUDED) + 1092 1998760 : && !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED)) + 1093 1998760 : && handle[j].st.st_size > file->size 1094 : ) { - 1095 8628 : log_error("File '%s' is larger than expected.\n", handle[j].path); - 1096 8628 : log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc_tag(file->sub, esc_buffer)); - 1097 8628 : ++error; + 1095 8819 : log_error("File '%s' is larger than expected.\n", handle[j].path); + 1096 8819 : log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc_tag(file->sub, esc_buffer)); + 1097 8819 : ++error; 1098 : - 1099 8628 : if (fix) { - 1100 3180 : ret = handle_truncate(&handle[j], file); - 1101 3180 : if (ret == -1) { + 1099 8819 : if (fix) { + 1100 3254 : ret = handle_truncate(&handle[j], file); + 1101 3254 : if (ret == -1) { 1102 : /* LCOV_EXCL_START */ 1103 : log_fatal("DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n"); 1104 : log_fatal("Stopping at block %u\n", i); @@ -1169,43 +1169,43 @@ 1107 : /* LCOV_EXCL_STOP */ 1108 : } 1109 : - 1110 3180 : log_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc_tag(file->sub, esc_buffer)); - 1111 3180 : ++recovered_error; + 1110 3254 : log_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc_tag(file->sub, esc_buffer)); + 1111 3254 : ++recovered_error; 1112 : } 1113 : } 1114 : 1115 : /* mark the file as opened at least one time */ 1116 : /* this is used to avoid to check the unsynced and size */ 1117 : /* more than one time, in case the file is reopened later */ - 1118 2065502 : file_flag_set(file, FILE_IS_OPENED); + 1118 2065557 : file_flag_set(file, FILE_IS_OPENED); 1119 : } 1120 : 1121 : /* read from the file */ - 1122 5042596 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, - 1123 5042596 : log_error, state->opt.expected_missing ? log_expected : 0); - 1124 5042596 : if (read_size == -1) { + 1122 5042801 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, + 1123 5042801 : log_error, state->opt.expected_missing ? log_expected : 0); + 1124 5042801 : if (read_size == -1) { 1125 : /* save the failed block for the check/fix */ - 1126 442271 : failed[failed_count].is_bad = 1; /* it's bad because we cannot read it */ - 1127 442271 : failed[failed_count].is_outofdate = 0; - 1128 442271 : failed[failed_count].index = j; - 1129 442271 : failed[failed_count].block = block; - 1130 442271 : failed[failed_count].disk = disk; - 1131 442271 : failed[failed_count].file = file; - 1132 442271 : failed[failed_count].file_pos = file_pos; - 1133 442271 : failed[failed_count].handle = &handle[j]; - 1134 442271 : ++failed_count; + 1126 442126 : failed[failed_count].is_bad = 1; /* it's bad because we cannot read it */ + 1127 442126 : failed[failed_count].is_outofdate = 0; + 1128 442126 : failed[failed_count].index = j; + 1129 442126 : failed[failed_count].block = block; + 1130 442126 : failed[failed_count].disk = disk; + 1131 442126 : failed[failed_count].file = file; + 1132 442126 : failed[failed_count].file_pos = file_pos; + 1133 442126 : failed[failed_count].handle = &handle[j]; + 1134 442126 : ++failed_count; 1135 : - 1136 442271 : log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos); - 1137 442271 : ++error; - 1138 442271 : continue; + 1136 442126 : log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos); + 1137 442126 : ++error; + 1138 442126 : continue; 1139 : } 1140 : - 1141 4600325 : countsize += read_size; + 1141 4600675 : countsize += read_size; 1142 : 1143 : /* always insert CHG blocks, the repair functions needs all of them */ 1144 : /* because the parity may be still referring at the old state */ 1145 : /* and the repair must be aware of it */ - 1146 4600325 : if (block_state == BLOCK_STATE_CHG) { + 1146 4600675 : if (block_state == BLOCK_STATE_CHG) { 1147 : /* we DO NOT mark them as bad to avoid to overwrite them with wrong data. */ 1148 : /* if we don't have a hash, we always assume the first read of the block correct. */ 1149 13843 : failed[failed_count].is_bad = 0; /* we assume the CHG block correct */ @@ -1220,39 +1220,39 @@ 1158 13843 : continue; 1159 : } 1160 : - 1161 4586482 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); + 1161 4586832 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); 1162 : 1163 : /* compute the hash of the block just read */ - 1164 4586482 : if (rehash) { + 1164 4586832 : if (rehash) { 1165 27243 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); 1166 : } else { - 1167 4559239 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); + 1167 4559589 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); 1168 : } 1169 : 1170 : /* compare the hash */ - 1171 4586482 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { - 1172 12866 : unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE); + 1171 4586832 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { + 1172 12768 : unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE); 1173 : 1174 : /* save the failed block for the check/fix */ - 1175 12866 : failed[failed_count].is_bad = 1; /* it's bad because the hash doesn't match */ - 1176 12866 : failed[failed_count].is_outofdate = 0; - 1177 12866 : failed[failed_count].index = j; - 1178 12866 : failed[failed_count].block = block; - 1179 12866 : failed[failed_count].disk = disk; - 1180 12866 : failed[failed_count].file = file; - 1181 12866 : failed[failed_count].file_pos = file_pos; - 1182 12866 : failed[failed_count].handle = &handle[j]; - 1183 12866 : ++failed_count; + 1175 12768 : failed[failed_count].is_bad = 1; /* it's bad because the hash doesn't match */ + 1176 12768 : failed[failed_count].is_outofdate = 0; + 1177 12768 : failed[failed_count].index = j; + 1178 12768 : failed[failed_count].block = block; + 1179 12768 : failed[failed_count].disk = disk; + 1180 12768 : failed[failed_count].file = file; + 1181 12768 : failed[failed_count].file_pos = file_pos; + 1182 12768 : failed[failed_count].handle = &handle[j]; + 1183 12768 : ++failed_count; 1184 : - 1185 12866 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff); - 1186 12866 : ++error; - 1187 12866 : continue; + 1185 12768 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff); + 1186 12768 : ++error; + 1187 12768 : continue; 1188 : } 1189 : 1190 : /* always insert REP blocks, the repair functions needs all of them */ 1191 : /* because the parity may be still referring at the old state */ 1192 : /* and the repair must be aware of it */ - 1193 4573616 : if (block_state == BLOCK_STATE_REP) { + 1193 4574064 : if (block_state == BLOCK_STATE_REP) { 1194 53428 : failed[failed_count].is_bad = 0; /* it's not bad */ 1195 53428 : failed[failed_count].is_outofdate = 0; 1196 53428 : failed[failed_count].index = j; @@ -1299,35 +1299,35 @@ 1237 870958 : ret = repair(state, rehash, i, diskmax, failed, failed_map, failed_count, buffer, buffer_recov, buffer_zero); 1238 870958 : if (ret != 0) { 1239 : /* increment the number of errors */ - 1240 47948 : if (ret > 0) - 1241 4808 : error += ret; - 1242 47948 : ++unrecoverable_error; + 1240 47935 : if (ret > 0) + 1241 4811 : error += ret; + 1242 47935 : ++unrecoverable_error; 1243 : 1244 : /* print a list of all the errors in files */ - 1245 219168 : for (j = 0; j < failed_count; ++j) { - 1246 171220 : if (failed[j].is_bad) - 1247 166698 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), failed[j].file_pos); + 1245 219126 : for (j = 0; j < failed_count; ++j) { + 1246 171191 : if (failed[j].is_bad) + 1247 166669 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), failed[j].file_pos); 1248 : } 1249 : 1250 : /* keep track of damaged files */ - 1251 219168 : for (j = 0; j < failed_count; ++j) { - 1252 171220 : if (failed[j].is_bad) - 1253 166698 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); + 1251 219126 : for (j = 0; j < failed_count; ++j) { + 1252 171191 : if (failed[j].is_bad) + 1253 166669 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1254 : } 1255 : } else { 1256 : /* now counts partial recovers */ 1257 : /* note that this could happen only when we have an incomplete 'sync' */ 1258 : /* and that we have recovered is the state before the 'sync' */ - 1259 823010 : int partial_recover_error = 0; + 1259 823023 : int partial_recover_error = 0; 1260 : 1261 : /* print a list of all the errors in files */ - 1262 1380911 : for (j = 0; j < failed_count; ++j) { - 1263 557901 : if (failed[j].is_bad && failed[j].is_outofdate) { + 1262 1380653 : for (j = 0; j < failed_count; ++j) { + 1263 557630 : if (failed[j].is_bad && failed[j].is_outofdate) { 1264 8 : ++partial_recover_error; 1265 8 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), failed[j].file_pos); 1266 : } 1267 : } - 1268 823010 : if (partial_recover_error != 0) { + 1268 823023 : if (partial_recover_error != 0) { 1269 8 : error += partial_recover_error; 1270 8 : ++unrecoverable_error; 1271 : } @@ -1335,36 +1335,36 @@ 1273 : /* now check parities, but only if all the blocks have it computed */ 1274 : /* if you check/fix after a partial sync, it's OK to have parity errors on the blocks with invalid parity */ 1275 : /* and doesn't make sense to try to fix it */ - 1276 823010 : if (valid_parity) { + 1276 823023 : if (valid_parity) { 1277 : /* check the parity */ - 1278 3728920 : for (l = 0; l < state->level; ++l) { - 1279 2967495 : if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) { - 1280 78683 : unsigned diff = memdiff(buffer_recov[l], buffer[diskmax + l], state->block_size); + 1278 3728946 : for (l = 0; l < state->level; ++l) { + 1279 2967508 : if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) { + 1280 78680 : unsigned diff = memdiff(buffer_recov[l], buffer[diskmax + l], state->block_size); 1281 : 1282 : /* mark that the read parity is wrong, setting ptr to 0 */ - 1283 78683 : buffer_recov[l] = 0; + 1283 78680 : buffer_recov[l] = 0; 1284 : - 1285 78683 : log_tag("parity_error:%u:%s: Data error, diff bits %u\n", i, lev_config_name(l), diff); - 1286 78683 : ++error; + 1285 78680 : log_tag("parity_error:%u:%s: Data error, diff bits %u\n", i, lev_config_name(l), diff); + 1286 78680 : ++error; 1287 : } 1288 : } 1289 : } 1290 : 1291 : /* now write recovered files */ - 1292 823010 : if (fix) { + 1292 823023 : if (fix) { 1293 : /* update the fixed files */ - 1294 652734 : for (j = 0; j < failed_count; ++j) { + 1294 652640 : for (j = 0; j < failed_count; ++j) { 1295 : /* nothing to do if it doesn't need recovering */ - 1296 338081 : if (!failed[j].is_bad) + 1296 337975 : if (!failed[j].is_bad) 1297 40318 : continue; 1298 : 1299 : /* do not fix if the file is excluded */ - 1300 297763 : if (file_flag_has(failed[j].file, FILE_IS_EXCLUDED) - 1301 288483 : || (state->opt.syncedonly && file_flag_has(failed[j].file, FILE_IS_UNSYNCED))) + 1300 297657 : if (file_flag_has(failed[j].file, FILE_IS_EXCLUDED) + 1301 288377 : || (state->opt.syncedonly && file_flag_has(failed[j].file, FILE_IS_UNSYNCED))) 1302 9280 : continue; 1303 : - 1304 288483 : ret = handle_write(failed[j].handle, failed[j].file_pos, buffer[failed[j].index], state->block_size); - 1305 288483 : if (ret == -1) { + 1304 288377 : ret = handle_write(failed[j].handle, failed[j].file_pos, buffer[failed[j].index], state->block_size); + 1305 288377 : if (ret == -1) { 1306 : /* LCOV_EXCL_START */ 1307 : /* mark the file as damaged */ 1308 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); @@ -1382,7 +1382,7 @@ 1320 : } 1321 : 1322 : /* if we are not sure that the recovered content is uptodate */ - 1323 288483 : if (failed[j].is_outofdate) { + 1323 288377 : if (failed[j].is_outofdate) { 1324 : /* mark the file as damaged */ 1325 8 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1326 8 : continue; @@ -1390,20 +1390,20 @@ 1328 : 1329 : /* mark the file as containing some fixes */ 1330 : /* note that it could be also marked as damaged in other iterations */ - 1331 288475 : file_flag_set(failed[j].file, FILE_IS_FIXED); + 1331 288369 : file_flag_set(failed[j].file, FILE_IS_FIXED); 1332 : - 1333 288475 : log_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), failed[j].file_pos); - 1334 288475 : ++recovered_error; + 1333 288369 : log_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), failed[j].file_pos); + 1334 288369 : ++recovered_error; 1335 : } 1336 : 1337 : /* update parity only if all the blocks have it computed */ 1338 : /* if you check/fix after a partial sync, you do not want to fix parity */ 1339 : /* for blocks that are going to have it computed in the sync completion */ - 1340 314653 : if (valid_parity) { + 1340 314665 : if (valid_parity) { 1341 : /* update the parity */ - 1342 964031 : for (l = 0; l < state->level; ++l) { + 1342 964055 : for (l = 0; l < state->level; ++l) { 1343 : /* if the parity on disk is wrong */ - 1344 698558 : if (buffer_recov[l] == 0 + 1344 698570 : if (buffer_recov[l] == 0 1345 : /* and we have access at the parity */ 1346 72150 : && parity[l] != 0 1347 : /* and the parity is not excluded */ @@ -1428,9 +1428,9 @@ 1366 : } else { 1367 : /* if we are not fixing, we just set the FIXED flag */ 1368 : /* meaning that we could fix this file if we try */ - 1369 728177 : for (j = 0; j < failed_count; ++j) { - 1370 219820 : if (failed[j].is_bad) { - 1371 178935 : file_flag_set(failed[j].file, FILE_IS_FIXED); + 1369 728013 : for (j = 0; j < failed_count; ++j) { + 1370 219655 : if (failed[j].is_bad) { + 1371 178770 : file_flag_set(failed[j].file, FILE_IS_FIXED); 1372 : } 1373 : } 1374 : } @@ -1438,9 +1438,9 @@ 1376 : } else { 1377 : /* if we are not checking, we just set the DAMAGED flag */ 1378 : /* to report that the file is damaged, and we don't know if we can fix it */ - 1379 45240 : for (j = 0; j < failed_count; ++j) { - 1380 5965 : if (failed[j].is_bad) { - 1381 5965 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); + 1379 45092 : for (j = 0; j < failed_count; ++j) { + 1380 5817 : if (failed[j].is_bad) { + 1381 5817 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1382 : } 1383 : } 1384 : } @@ -1500,29 +1500,29 @@ 1438 2783 : pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub); 1439 2783 : ret = stat(path, &st); 1440 2783 : if (ret == -1) { - 1441 167 : unsuccesful = 1; + 1441 179 : unsuccesful = 1; 1442 : - 1443 167 : log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno)); - 1444 167 : log_tag("error:%s:%s: Empty file stat error\n", disk->name, esc_tag(file->sub, esc_buffer)); - 1445 167 : ++error; - 1446 2616 : } else if (!S_ISREG(st.st_mode)) { + 1443 179 : log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno)); + 1444 179 : log_tag("error:%s:%s: Empty file stat error\n", disk->name, esc_tag(file->sub, esc_buffer)); + 1445 179 : ++error; + 1446 2604 : } else if (!S_ISREG(st.st_mode)) { 1447 0 : unsuccesful = 1; 1448 : 1449 0 : log_tag("error:%s:%s: Empty file error for not regular file\n", disk->name, esc_tag(file->sub, esc_buffer)); 1450 0 : ++error; - 1451 2616 : } else if (st.st_size != 0) { - 1452 3 : unsuccesful = 1; + 1451 2604 : } else if (st.st_size != 0) { + 1452 6 : unsuccesful = 1; 1453 : - 1454 3 : log_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc_tag(file->sub, esc_buffer), st.st_size); - 1455 3 : ++error; + 1454 6 : log_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc_tag(file->sub, esc_buffer), st.st_size); + 1455 6 : ++error; 1456 : } 1457 : 1458 2783 : if (fix && unsuccesful) { 1459 : int f; 1460 : 1461 : /* create the ancestor directories */ - 1462 154 : ret = mkancestor(path); - 1463 154 : if (ret != 0) { + 1462 159 : ret = mkancestor(path); + 1463 159 : if (ret != 0) { 1464 : /* LCOV_EXCL_START */ 1465 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); 1466 : log_fatal("Stopping\n"); @@ -1533,8 +1533,8 @@ 1471 : 1472 : /* create it */ 1473 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ - 1474 154 : f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600); - 1475 154 : if (f == -1) { + 1474 159 : f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600); + 1475 159 : if (f == -1) { 1476 : /* LCOV_EXCL_START */ 1477 : log_fatal("Error creating empty file '%s'. %s.\n", path, strerror(errno)); 1478 : if (errno == EACCES) { @@ -1550,8 +1550,8 @@ 1488 : } 1489 : 1490 : /* set the original modification time */ - 1491 154 : ret = fmtime(f, file->mtime_sec, file->mtime_nsec); - 1492 154 : if (ret != 0) { + 1491 159 : ret = fmtime(f, file->mtime_sec, file->mtime_nsec); + 1492 159 : if (ret != 0) { 1493 : /* LCOV_EXCL_START */ 1494 : close(f); 1495 : @@ -1564,8 +1564,8 @@ 1502 : } 1503 : 1504 : /* close it */ - 1505 154 : ret = close(f); - 1506 154 : if (ret != 0) { + 1505 159 : ret = close(f); + 1506 159 : if (ret != 0) { 1507 : /* LCOV_EXCL_START */ 1508 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); 1509 : log_fatal("Stopping\n"); @@ -1574,11 +1574,11 @@ 1512 : /* LCOV_EXCL_STOP */ 1513 : } 1514 : - 1515 154 : log_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc_tag(file->sub, esc_buffer)); - 1516 154 : ++recovered_error; + 1515 159 : log_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc_tag(file->sub, esc_buffer)); + 1516 159 : ++recovered_error; 1517 : - 1518 154 : log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); - 1519 154 : msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer)); + 1518 159 : log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); + 1519 159 : msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer)); 1520 : } 1521 : } 1522 : @@ -1660,25 +1660,25 @@ 1598 66532 : pathprint(path, sizeof(path), "%s%s", disk->dir, slink->sub); 1599 66532 : ret = readlink(path, linkto, sizeof(linkto)); 1600 66532 : if (ret < 0) { - 1601 4267 : unsuccesful = 1; + 1601 4278 : unsuccesful = 1; 1602 : - 1603 4267 : log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno)); - 1604 4267 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc_tag(slink->sub, esc_buffer)); - 1605 4267 : ++error; - 1606 62265 : } else if (ret >= PATH_MAX) { + 1603 4278 : log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno)); + 1604 4278 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc_tag(slink->sub, esc_buffer)); + 1605 4278 : ++error; + 1606 62254 : } else if (ret >= PATH_MAX) { 1607 0 : unsuccesful = 1; 1608 : 1609 0 : log_error("Error reading symlink '%s'. Symlink too long.\n", path); 1610 0 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc_tag(slink->sub, esc_buffer)); 1611 0 : ++error; 1612 : } else { - 1613 62265 : linkto[ret] = 0; + 1613 62254 : linkto[ret] = 0; 1614 : - 1615 62265 : if (strcmp(linkto, slink->linkto) != 0) { - 1616 566 : unsuccesful = 1; + 1615 62254 : if (strcmp(linkto, slink->linkto) != 0) { + 1616 555 : unsuccesful = 1; 1617 : - 1618 566 : log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc_tag(slink->sub, esc_buffer), linkto, slink->linkto); - 1619 566 : ++error; + 1618 555 : log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc_tag(slink->sub, esc_buffer), linkto, slink->linkto); + 1619 555 : ++error; 1620 : } 1621 : } 1622 : } @@ -1866,13 +1866,13 @@ 1804 : /* if the file was not created, meaning that it was already existing */ 1805 870311 : if (!file_flag_has(file, FILE_IS_CREATED)) { 1806 : /* nothing to do */ - 1807 1627555 : continue; + 1807 1627578 : continue; 1808 : } 1809 : 1810 : /* if processing was finished */ - 1811 113067 : if (file_flag_has(file, FILE_IS_FINISHED)) { + 1811 113044 : if (file_flag_has(file, FILE_IS_FINISHED)) { 1812 : /* nothing to do */ - 1813 113067 : continue; + 1813 113044 : continue; 1814 : } 1815 : 1816 : /* if the file was originally missing, and processing not yet finished */ diff --git a/cov/cmdline/device.c.func-sort-c.html b/cov/cmdline/device.c.func-sort-c.html index 1eeef9ff..4e4f2c23 100644 --- a/cov/cmdline/device.c.func-sort-c.html +++ b/cov/cmdline/device.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 diff --git a/cov/cmdline/device.c.func.html b/cov/cmdline/device.c.func.html index 51df6054..4891bbe1 100644 --- a/cov/cmdline/device.c.func.html +++ b/cov/cmdline/device.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 diff --git a/cov/cmdline/device.c.gcov.html b/cov/cmdline/device.c.gcov.html index cb4118a5..d2d91e48 100644 --- a/cov/cmdline/device.c.gcov.html +++ b/cov/cmdline/device.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 diff --git a/cov/cmdline/dry.c.func-sort-c.html b/cov/cmdline/dry.c.func-sort-c.html index 3dc0963d..aebd4849 100644 --- a/cov/cmdline/dry.c.func-sort-c.html +++ b/cov/cmdline/dry.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -60,12 +60,12 @@ Hit count Sort by hit count - dry_parity_reader + dry_data_reader 42601 - dry_data_reader - 42596 + dry_parity_reader + 42274 block_is_enabled diff --git a/cov/cmdline/dry.c.func.html b/cov/cmdline/dry.c.func.html index 6a9299f2..7a6439a5 100644 --- a/cov/cmdline/dry.c.func.html +++ b/cov/cmdline/dry.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -65,11 +65,11 @@ dry_data_reader - 42596 + 42601 dry_parity_reader - 42601 + 42274 state_dry diff --git a/cov/cmdline/dry.c.gcov.html b/cov/cmdline/dry.c.gcov.html index a360ddef..a8f0bb53 100644 --- a/cov/cmdline/dry.c.gcov.html +++ b/cov/cmdline/dry.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -101,45 +101,45 @@ 39 7102 : return 1; 40 : } 41 : - 42 42596 : static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) + 42 42601 : static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) 43 : { - 44 42596 : struct snapraid_io* io = worker->io; - 45 42596 : struct snapraid_state* state = io->state; - 46 42596 : struct snapraid_handle* handle = worker->handle; - 47 42596 : struct snapraid_disk* disk = handle->disk; - 48 42596 : block_off_t blockcur = task->position; - 49 42596 : unsigned char* buffer = task->buffer; + 44 42601 : struct snapraid_io* io = worker->io; + 45 42601 : struct snapraid_state* state = io->state; + 46 42601 : struct snapraid_handle* handle = worker->handle; + 47 42601 : struct snapraid_disk* disk = handle->disk; + 48 42601 : block_off_t blockcur = task->position; + 49 42601 : unsigned char* buffer = task->buffer; 50 : int ret; 51 : char esc_buffer[ESC_MAX]; 52 : 53 : /* if the disk position is not used */ - 54 42596 : if (!disk) { + 54 42601 : if (!disk) { 55 : /* use an empty block */ - 56 4687 : memset(buffer, 0, state->block_size); - 57 4687 : task->state = TASK_STATE_DONE; - 58 9918 : return; + 56 4686 : memset(buffer, 0, state->block_size); + 57 4686 : task->state = TASK_STATE_DONE; + 58 9917 : return; 59 : } 60 : 61 : /* get the block */ - 62 37909 : task->block = fs_par2block_find(disk, blockcur); + 62 37915 : task->block = fs_par2block_find(disk, blockcur); 63 : 64 : /* if the block is not used */ - 65 37865 : if (!block_has_file(task->block)) { + 65 37902 : if (!block_has_file(task->block)) { 66 : /* use an empty block */ - 67 544 : memset(buffer, 0, state->block_size); - 68 544 : task->state = TASK_STATE_DONE; - 69 544 : return; + 67 545 : memset(buffer, 0, state->block_size); + 68 545 : task->state = TASK_STATE_DONE; + 69 545 : return; 70 : } 71 : 72 : /* get the file of this block */ - 73 37325 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); + 73 37352 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); 74 : 75 : /* if the file is different than the current one, close it */ - 76 37355 : if (handle->file != 0 && handle->file != task->file) { + 76 37365 : if (handle->file != 0 && handle->file != task->file) { 77 : /* keep a pointer at the file we are going to close for error reporting */ - 78 15077 : struct snapraid_file* report = handle->file; - 79 15077 : ret = handle_close(handle); - 80 15079 : if (ret == -1) { + 78 15088 : struct snapraid_file* report = handle->file; + 79 15088 : ret = handle_close(handle); + 80 15084 : if (ret == -1) { 81 : /* LCOV_EXCL_START */ 82 : /* This one is really an unexpected error, because we are only reading */ 83 : /* and closing a descriptor should never fail */ @@ -162,8 +162,8 @@ 100 : } 101 : } 102 : - 103 37357 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); - 104 37369 : if (ret == -1) { + 103 37361 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); + 104 37368 : if (ret == -1) { 105 0 : if (errno == EIO) { 106 : /* LCOV_EXCL_START */ 107 : log_tag("error:%u:%s:%s: Open EIO error. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno)); @@ -180,8 +180,8 @@ 118 0 : return; 119 : } 120 : - 121 37369 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); - 122 37250 : if (task->read_size == -1) { + 121 37368 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); + 122 37305 : if (task->read_size == -1) { 123 0 : if (errno == EIO) { 124 0 : log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno)); 125 0 : log_error("Input/Output error in file '%s' at position '%u'\n", handle->path, task->file_pos); @@ -195,24 +195,24 @@ 133 : } 134 : 135 : /* store the path of the opened file */ - 136 37250 : pathcpy(task->path, sizeof(task->path), handle->path); + 136 37305 : pathcpy(task->path, sizeof(task->path), handle->path); 137 : - 138 37319 : task->state = TASK_STATE_DONE; + 138 37345 : task->state = TASK_STATE_DONE; 139 : } 140 : - 141 42601 : static void dry_parity_reader(struct snapraid_worker* worker, struct snapraid_task* task) + 141 42274 : static void dry_parity_reader(struct snapraid_worker* worker, struct snapraid_task* task) 142 : { - 143 42601 : struct snapraid_io* io = worker->io; - 144 42601 : struct snapraid_state* state = io->state; - 145 42601 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; - 146 42601 : unsigned level = parity_handle->level; - 147 42601 : block_off_t blockcur = task->position; - 148 42601 : unsigned char* buffer = task->buffer; + 143 42274 : struct snapraid_io* io = worker->io; + 144 42274 : struct snapraid_state* state = io->state; + 145 42274 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; + 146 42274 : unsigned level = parity_handle->level; + 147 42274 : block_off_t blockcur = task->position; + 148 42274 : unsigned char* buffer = task->buffer; 149 : int ret; 150 : 151 : /* read the parity */ - 152 42601 : ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error); - 153 42575 : if (ret == -1) { + 152 42274 : ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error); + 153 42574 : if (ret == -1) { 154 0 : if (errno == EIO) { 155 0 : log_tag("parity_error:%u:%s: Read EIO error. %s\n", blockcur, lev_config_name(level), strerror(errno)); 156 0 : log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(level), blockcur); @@ -225,7 +225,7 @@ 163 0 : return; 164 : } 165 : - 166 42575 : task->state = TASK_STATE_DONE; + 166 42574 : task->state = TASK_STATE_DONE; 167 : } 168 : 169 2 : static int state_dry_process(struct snapraid_state* state, struct snapraid_parity_handle* parity_handle, block_off_t blockstart, block_off_t blockmax) diff --git a/cov/cmdline/dup.c.func-sort-c.html b/cov/cmdline/dup.c.func-sort-c.html index 057b5129..dac74296 100644 --- a/cov/cmdline/dup.c.func-sort-c.html +++ b/cov/cmdline/dup.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 diff --git a/cov/cmdline/dup.c.func.html b/cov/cmdline/dup.c.func.html index d86fee1c..2517f6af 100644 --- a/cov/cmdline/dup.c.func.html +++ b/cov/cmdline/dup.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 diff --git a/cov/cmdline/dup.c.gcov.html b/cov/cmdline/dup.c.gcov.html index 605c6630..c96f63d9 100644 --- a/cov/cmdline/dup.c.gcov.html +++ b/cov/cmdline/dup.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 diff --git a/cov/cmdline/elem.c.func-sort-c.html b/cov/cmdline/elem.c.func-sort-c.html index adc5592a..90931dd5 100644 --- a/cov/cmdline/elem.c.func-sort-c.html +++ b/cov/cmdline/elem.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 67 @@ -61,71 +61,71 @@ extent_parity_inside_compare_unlock - 113835807 + 114575009 fs_lock - 53196480 + 53195526 fs_unlock - 53196096 + 53195112 extent_file_compare - 45007274 + 45005658 fs_file2block_get - 44946613 + 44945354 extent_parity_compare - 44510782 + 44509325 fs_par2extent_get_unlock - 39144459 + 39143508 fs_par2file_find - 39037806 + 39036978 fs_par2block_find - 27314040 + 27313631 extent_file_inside_compare_unlock - 21310663 + 21310995 filter_apply - 12456904 + 12457044 fs_file2extent_get_unlock - 10336351 + 10336255 fs_allocate - 9175524 + 9175178 file_block_size - 6823791 + 6823038 extent_file_check_foreach_unlock - 6584417 + 6584473 extent_parity_check_foreach_unlock - 6584417 + 6584473 filter_recurse - 6236559 + 6236629 file_block_is_last @@ -133,55 +133,55 @@ fs_file2par_find - 4869582 + 4869703 extent_alloc - 3735396 + 3735289 file_alloc - 3691126 + 3690991 extent_free - 3564840 + 3564865 file_free - 3543814 + 3543815 filter_element - 3332824 + 3332859 filter_path - 3329727 + 3329762 filter_content - 3173351 + 3173372 file_inode_compare_to_arg - 987099 + 975235 time_compare - 684203 + 691801 fmt_term - 356075 + 355906 file_path_compare - 189486 + 189475 filter_type - 125255 + 125233 link_alloc @@ -193,11 +193,11 @@ fs_deallocate - 106308 + 106232 file_path_compare_to_arg - 97531 + 97871 filter_existence @@ -205,15 +205,15 @@ extent_disk_size_compare_unlock - 50510 + 50514 file_name - 47922 + 47954 file_physical_compare - 44202 + 44212 filter_correctness @@ -225,11 +225,11 @@ file_namestamp_compare - 23961 + 23977 file_name_compare - 23961 + 23977 file_stamp_compare @@ -245,7 +245,7 @@ fs_size - 4351 + 4363 link_alpha_compare @@ -257,31 +257,31 @@ fs_check - 2982 + 2988 disk_alloc - 1585 + 1591 map_alloc - 1555 + 1561 content_alloc - 1525 + 1532 disk_free - 1453 + 1459 map_free - 1429 + 1435 content_free - 1386 + 1393 fs_is_empty @@ -297,11 +297,11 @@ filter_alloc_file - 534 + 536 filter_free - 497 + 499 dir_name_compare diff --git a/cov/cmdline/elem.c.func.html b/cov/cmdline/elem.c.func.html index 867b2c1f..63f4cf7d 100644 --- a/cov/cmdline/elem.c.func.html +++ b/cov/cmdline/elem.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 67 @@ -61,11 +61,11 @@ content_alloc - 1525 + 1532 content_free - 1386 + 1393 dir_alloc @@ -81,15 +81,15 @@ disk_alloc - 1585 + 1591 disk_free - 1453 + 1459 extent_alloc - 3735396 + 3735289 extent_disk_empty_compare_unlock @@ -97,39 +97,39 @@ extent_disk_size_compare_unlock - 50510 + 50514 extent_file_check_foreach_unlock - 6584417 + 6584473 extent_file_compare - 45007274 + 45005658 extent_file_inside_compare_unlock - 21310663 + 21310995 extent_free - 3564840 + 3564865 extent_parity_check_foreach_unlock - 6584417 + 6584473 extent_parity_compare - 44510782 + 44509325 extent_parity_inside_compare_unlock - 113835807 + 114575009 file_alloc - 3691126 + 3690991 file_block_is_last @@ -137,7 +137,7 @@ file_block_size - 6823791 + 6823038 file_copy @@ -149,7 +149,7 @@ file_free - 3543814 + 3543815 file_inode_compare @@ -157,27 +157,27 @@ file_inode_compare_to_arg - 987099 + 975235 file_name - 47922 + 47954 file_name_compare - 23961 + 23977 file_namestamp_compare - 23961 + 23977 file_path_compare - 189486 + 189475 file_path_compare_to_arg - 97531 + 97871 file_pathstamp_compare @@ -185,7 +185,7 @@ file_physical_compare - 44202 + 44212 file_rename @@ -201,15 +201,15 @@ filter_alloc_file - 534 + 536 filter_apply - 12456904 + 12457044 filter_content - 3173351 + 3173372 filter_correctness @@ -217,7 +217,7 @@ filter_element - 3332824 + 3332859 filter_emptydir @@ -229,15 +229,15 @@ filter_free - 497 + 499 filter_path - 3329727 + 3329762 filter_recurse - 6236559 + 6236629 filter_subdir @@ -245,7 +245,7 @@ filter_type - 125255 + 125233 fmt_poll @@ -253,31 +253,31 @@ fmt_term - 356075 + 355906 fs_allocate - 9175524 + 9175178 fs_check - 2982 + 2988 fs_deallocate - 106308 + 106232 fs_file2block_get - 44946613 + 44945354 fs_file2extent_get_unlock - 10336351 + 10336255 fs_file2par_find - 4869582 + 4869703 fs_is_empty @@ -285,27 +285,27 @@ fs_lock - 53196480 + 53195526 fs_par2block_find - 27314040 + 27313631 fs_par2extent_get_unlock - 39144459 + 39143508 fs_par2file_find - 39037806 + 39036978 fs_size - 4351 + 4363 fs_unlock - 53196096 + 53195112 link_alloc @@ -325,15 +325,15 @@ map_alloc - 1555 + 1561 map_free - 1429 + 1435 time_compare - 684203 + 691801
diff --git a/cov/cmdline/elem.c.gcov.html b/cov/cmdline/elem.c.gcov.html index 82da91c6..2f2b118f 100644 --- a/cov/cmdline/elem.c.gcov.html +++ b/cov/cmdline/elem.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 67 @@ -88,23 +88,23 @@ 26 : 27 : int BLOCK_HASH_SIZE = HASH_MAX; 28 : - 29 1525 : struct snapraid_content* content_alloc(const char* path, uint64_t dev) + 29 1532 : struct snapraid_content* content_alloc(const char* path, uint64_t dev) 30 : { 31 : struct snapraid_content* content; 32 : - 33 1525 : content = malloc_nofail(sizeof(struct snapraid_content)); - 34 1525 : pathimport(content->content, sizeof(content->content), path); - 35 1525 : content->device = dev; + 33 1532 : content = malloc_nofail(sizeof(struct snapraid_content)); + 34 1532 : pathimport(content->content, sizeof(content->content), path); + 35 1532 : content->device = dev; 36 : - 37 1525 : return content; + 37 1532 : return content; 38 : } 39 : - 40 1386 : void content_free(struct snapraid_content* content) + 40 1393 : void content_free(struct snapraid_content* content) 41 : { - 42 1386 : free(content); - 43 1386 : } + 42 1393 : free(content); + 43 1393 : } 44 : - 45 534 : struct snapraid_filter* filter_alloc_file(int direction, const char* pattern) + 45 536 : struct snapraid_filter* filter_alloc_file(int direction, const char* pattern) 46 : { 47 : struct snapraid_filter* filter; 48 : char* i; @@ -113,18 +113,18 @@ 51 : int token_is_valid; 52 : int token_is_filled; 53 : - 54 534 : filter = malloc_nofail(sizeof(struct snapraid_filter)); - 55 534 : pathimport(filter->pattern, sizeof(filter->pattern), pattern); - 56 534 : filter->direction = direction; + 54 536 : filter = malloc_nofail(sizeof(struct snapraid_filter)); + 55 536 : pathimport(filter->pattern, sizeof(filter->pattern), pattern); + 56 536 : filter->direction = direction; 57 : 58 : /* find first and last slash */ - 59 534 : first = 0; - 60 534 : last = 0; + 59 536 : first = 0; + 60 536 : last = 0; 61 : /* reject invalid tokens, like "<empty>", ".", ".." and more dots */ - 62 534 : token_is_valid = 0; - 63 534 : token_is_filled = 0; - 64 6622 : for (i = filter->pattern; *i; ++i) { - 65 6089 : if (*i == '/') { + 62 536 : token_is_valid = 0; + 63 536 : token_is_filled = 0; + 64 6647 : for (i = filter->pattern; *i; ++i) { + 65 6112 : if (*i == '/') { 66 : /* reject invalid tokens, but accept an empty one as first */ 67 5 : if (!token_is_valid && (first != 0 || token_is_filled)) { 68 1 : free(filter); @@ -137,27 +137,27 @@ 75 4 : if (!first) 76 3 : first = i; 77 4 : last = i; - 78 6084 : } else if (*i != '.') { - 79 5554 : token_is_valid = 1; - 80 5554 : token_is_filled = 1; + 78 6107 : } else if (*i != '.') { + 79 5575 : token_is_valid = 1; + 80 5575 : token_is_filled = 1; 81 : } else { - 82 530 : token_is_filled = 1; + 82 532 : token_is_filled = 1; 83 : } 84 : } 85 : 86 : /* reject invalid tokens, but accept an empty one as last, but not if it's the only one */ - 87 533 : if (!token_is_valid && (first == 0 || token_is_filled)) { + 87 535 : if (!token_is_valid && (first == 0 || token_is_filled)) { 88 1 : free(filter); 89 1 : return 0; 90 : } 91 : 92 : /* it's a file filter */ - 93 532 : filter->is_disk = 0; + 93 534 : filter->is_disk = 0; 94 : - 95 532 : if (first == 0) { + 95 534 : if (first == 0) { 96 : /* no slash */ - 97 529 : filter->is_path = 0; - 98 529 : filter->is_dir = 0; + 97 531 : filter->is_path = 0; + 98 531 : filter->is_dir = 0; 99 3 : } else if (first == last && last[1] == 0) { 100 : /* one slash at the end */ 101 1 : filter->is_path = 0; @@ -180,7 +180,7 @@ 118 : } 119 : } 120 : - 121 531 : return filter; + 121 533 : return filter; 122 : } 123 : 124 10 : struct snapraid_filter* filter_alloc_disk(int direction, const char* pattern) @@ -207,101 +207,101 @@ 145 10 : return filter; 146 : } 147 : - 148 497 : void filter_free(struct snapraid_filter* filter) + 148 499 : void filter_free(struct snapraid_filter* filter) 149 : { - 150 497 : free(filter); - 151 497 : } + 150 499 : free(filter); + 151 499 : } 152 : - 153 125255 : const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size) + 153 125233 : const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size) 154 : { 155 : const char* direction; 156 : - 157 125255 : if (filter->direction < 0) - 158 124991 : direction = "exclude"; + 157 125233 : if (filter->direction < 0) + 158 124968 : direction = "exclude"; 159 : else - 160 264 : direction = "include"; + 160 265 : direction = "include"; 161 : - 162 125255 : if (filter->is_disk) + 162 125233 : if (filter->is_disk) 163 0 : pathprint(out, out_size, "%s %s:", direction, filter->pattern); - 164 125255 : else if (filter->is_dir) + 164 125233 : else if (filter->is_dir) 165 0 : pathprint(out, out_size, "%s %s/", direction, filter->pattern); 166 : else - 167 125255 : pathprint(out, out_size, "%s %s", direction, filter->pattern); + 167 125233 : pathprint(out, out_size, "%s %s", direction, filter->pattern); 168 : - 169 125255 : return out; + 169 125233 : return out; 170 : } 171 : - 172 12456904 : static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* path, const char* name, int is_dir) + 172 12457044 : static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* path, const char* name, int is_dir) 173 : { - 174 12456904 : int ret = 0; + 174 12457044 : int ret = 0; 175 : 176 : /* match dirs with dirs and files with files */ - 177 12456904 : if (filter->is_dir && !is_dir) + 177 12457044 : if (filter->is_dir && !is_dir) 178 2949 : return 0; - 179 12453955 : if (!filter->is_dir && is_dir) - 180 6223514 : return 0; + 179 12454095 : if (!filter->is_dir && is_dir) + 180 6223584 : return 0; 181 : - 182 6230441 : if (filter->is_path) { + 182 6230511 : if (filter->is_path) { 183 : /* skip initial slash, as always missing from the path */ 184 2949 : if (fnmatch(filter->pattern + 1, path, FNM_PATHNAME | FNM_CASEINSENSITIVE_FOR_WIN) == 0) 185 0 : ret = filter->direction; 186 : } else { - 187 6227492 : if (fnmatch(filter->pattern, name, FNM_CASEINSENSITIVE_FOR_WIN) == 0) - 188 127717 : ret = filter->direction; + 187 6227562 : if (fnmatch(filter->pattern, name, FNM_CASEINSENSITIVE_FOR_WIN) == 0) + 188 127693 : ret = filter->direction; 189 : } 190 : - 191 6230441 : if (reason != 0 && ret < 0) - 192 124727 : *reason = filter; + 191 6230511 : if (reason != 0 && ret < 0) + 192 124703 : *reason = filter; 193 : - 194 6230441 : return ret; + 194 6230511 : return ret; 195 : } 196 : - 197 6236559 : static int filter_recurse(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* const_path, int is_dir) + 197 6236629 : static int filter_recurse(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* const_path, int is_dir) 198 : { 199 : char path[PATH_MAX]; 200 : char* name; 201 : unsigned i; 202 : - 203 6236559 : pathcpy(path, sizeof(path), const_path); + 203 6236629 : pathcpy(path, sizeof(path), const_path); 204 : 205 : /* filter for all the directories */ - 206 6236559 : name = path; - 207 89823626 : for (i = 0; path[i] != 0; ++i) { - 208 83590057 : if (path[i] == '/') { + 206 6236629 : name = path; + 207 89821180 : for (i = 0; path[i] != 0; ++i) { + 208 83587541 : if (path[i] == '/') { 209 : /* set a terminator */ - 210 6223335 : path[i] = 0; + 210 6223405 : path[i] = 0; 211 : 212 : /* filter the directory */ - 213 6223335 : if (filter_apply(filter, reason, path, name, 1) != 0) + 213 6223405 : if (filter_apply(filter, reason, path, name, 1) != 0) 214 2990 : return filter->direction; 215 : 216 : /* restore the slash */ - 217 6220345 : path[i] = '/'; + 217 6220415 : path[i] = '/'; 218 : 219 : /* next name */ - 220 6220345 : name = path + i + 1; + 220 6220415 : name = path + i + 1; 221 : } 222 : } 223 : 224 : /* filter the final file */ - 225 6233569 : if (filter_apply(filter, reason, path, name, is_dir) != 0) - 226 124727 : return filter->direction; + 225 6233639 : if (filter_apply(filter, reason, path, name, is_dir) != 0) + 226 124703 : return filter->direction; 227 : - 228 6108842 : return 0; + 228 6108936 : return 0; 229 : } 230 : - 231 3332824 : static int filter_element(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub, int is_dir, int is_def_include) + 231 3332859 : static int filter_element(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub, int is_dir, int is_def_include) 232 : { 233 : tommy_node* i; 234 : - 235 3332824 : int direction = 1; /* by default include all */ + 235 3332859 : int direction = 1; /* by default include all */ 236 : 237 : /* for each filter */ - 238 9542974 : for (i = tommy_list_head(filterlist); i != 0; i = i->next) { + 238 9543103 : for (i = tommy_list_head(filterlist); i != 0; i = i->next) { 239 : int ret; - 240 6346547 : struct snapraid_filter* filter = i->data; + 240 6346617 : struct snapraid_filter* filter = i->data; 241 : - 242 6346547 : if (filter->is_disk) { + 242 6346617 : if (filter->is_disk) { 243 109988 : if (fnmatch(filter->pattern, disk, FNM_CASEINSENSITIVE_FOR_WIN) == 0) 244 8680 : ret = filter->direction; 245 : else @@ -309,39 +309,39 @@ 247 109988 : if (reason != 0 && ret < 0) 248 0 : *reason = filter; 249 : } else { - 250 6236559 : ret = filter_recurse(filter, reason, sub, is_dir); + 250 6236629 : ret = filter_recurse(filter, reason, sub, is_dir); 251 : } 252 : - 253 6346547 : if (ret > 0) { + 253 6346617 : if (ret > 0) { 254 : /* include the file */ 255 11670 : return 0; - 256 6334877 : } else if (ret < 0) { + 256 6334947 : } else if (ret < 0) { 257 : /* exclude the file */ - 258 124727 : return -1; + 258 124703 : return -1; 259 : } else { 260 : /* default is opposite of the last filter */ - 261 6210150 : direction = -filter->direction; - 262 6210150 : if (reason != 0 && direction < 0) - 263 3110866 : *reason = filter; + 261 6210244 : direction = -filter->direction; + 262 6210244 : if (reason != 0 && direction < 0) + 263 3110901 : *reason = filter; 264 : /* continue with the next one */ 265 : } 266 : } 267 : 268 : /* directories are always included by default, otherwise we cannot apply rules */ 269 : /* to the contained files */ - 270 3196427 : if (is_def_include) + 270 3196486 : if (is_def_include) 271 3052 : return 0; 272 : 273 : /* files are excluded/included depending of the last rule processed */ - 274 3193375 : if (direction < 0) + 274 3193434 : if (direction < 0) 275 57608 : return -1; 276 : - 277 3135767 : return 0; + 277 3135826 : return 0; 278 : } 279 : - 280 3329727 : int filter_path(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) + 280 3329762 : int filter_path(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) 281 : { - 282 3329727 : return filter_element(filterlist, reason, disk, sub, 0, 0); + 282 3329762 : return filter_element(filterlist, reason, disk, sub, 0, 0); 283 : } 284 : 285 3052 : int filter_subdir(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) @@ -387,67 +387,67 @@ 325 16098 : return 0; 326 : 327 : /* check each block of the file */ - 328 60677 : for (i = 0; i < file->blockmax; ++i) { - 329 46455 : block_off_t parity_pos = fs_file2par_get(disk, file, i); - 330 46455 : snapraid_info info = info_get(infoarr, parity_pos); + 328 60692 : for (i = 0; i < file->blockmax; ++i) { + 329 46446 : block_off_t parity_pos = fs_file2par_get(disk, file, i); + 330 46446 : snapraid_info info = info_get(infoarr, parity_pos); 331 : 332 : /* if the file has a bad block, don't exclude it */ - 333 46455 : if (info_get_bad(info)) - 334 8326 : return 0; + 333 46446 : if (info_get_bad(info)) + 334 8302 : return 0; 335 : } 336 : 337 : /* the file is correct, so we filter it out */ - 338 14222 : return 1; + 338 14246 : return 1; 339 : } 340 : - 341 3173351 : int filter_content(tommy_list* contentlist, const char* path) + 341 3173372 : int filter_content(tommy_list* contentlist, const char* path) 342 : { 343 : tommy_node* i; 344 : - 345 40912970 : for (i = tommy_list_head(contentlist); i != 0; i = i->next) { - 346 17283134 : struct snapraid_content* content = i->data; + 345 40913052 : for (i = tommy_list_head(contentlist); i != 0; i = i->next) { + 346 17283154 : struct snapraid_content* content = i->data; 347 : char tmp[PATH_MAX]; 348 : - 349 17283134 : if (pathcmp(content->content, path) == 0) + 349 17283154 : if (pathcmp(content->content, path) == 0) 350 0 : return -1; 351 : 352 : /* exclude also the ".tmp" copy used to save it */ - 353 17283134 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - 354 17283134 : if (pathcmp(tmp, path) == 0) + 353 17283154 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); + 354 17283154 : if (pathcmp(tmp, path) == 0) 355 0 : return -1; 356 : 357 : /* exclude also the ".lock" file */ - 358 17283134 : pathprint(tmp, sizeof(tmp), "%s.lock", content->content); - 359 17283134 : if (pathcmp(tmp, path) == 0) + 358 17283154 : pathprint(tmp, sizeof(tmp), "%s.lock", content->content); + 359 17283154 : if (pathcmp(tmp, path) == 0) 360 0 : return -1; 361 : } 362 : - 363 3173351 : return 0; + 363 3173372 : return 0; 364 : } 365 : - 366 3691126 : struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode, uint64_t physical) + 366 3690991 : struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode, uint64_t physical) 367 : { 368 : struct snapraid_file* file; 369 : block_off_t i; 370 : - 371 3691126 : file = malloc_nofail(sizeof(struct snapraid_file)); - 372 3691126 : file->sub = strdup_nofail(sub); - 373 3691126 : file->size = size; - 374 3691126 : file->blockmax = (size + block_size - 1) / block_size; - 375 3691126 : file->mtime_sec = mtime_sec; - 376 3691126 : file->mtime_nsec = mtime_nsec; - 377 3691126 : file->inode = inode; - 378 3691126 : file->physical = physical; - 379 3691126 : file->flag = 0; - 380 3691126 : file->blockvec = malloc_nofail(file->blockmax * block_sizeof()); + 371 3690991 : file = malloc_nofail(sizeof(struct snapraid_file)); + 372 3690991 : file->sub = strdup_nofail(sub); + 373 3690991 : file->size = size; + 374 3690991 : file->blockmax = (size + block_size - 1) / block_size; + 375 3690991 : file->mtime_sec = mtime_sec; + 376 3690991 : file->mtime_nsec = mtime_nsec; + 377 3690991 : file->inode = inode; + 378 3690991 : file->physical = physical; + 379 3690991 : file->flag = 0; + 380 3690991 : file->blockvec = malloc_nofail(file->blockmax * block_sizeof()); 381 : - 382 12810682 : for (i = 0; i < file->blockmax; ++i) { - 383 9119556 : struct snapraid_block* block = file_block(file, i); - 384 9119556 : block_state_set(block, BLOCK_STATE_CHG); - 385 9119556 : hash_invalid_set(block->hash); + 382 12810201 : for (i = 0; i < file->blockmax; ++i) { + 383 9119210 : struct snapraid_block* block = file_block(file, i); + 384 9119210 : block_state_set(block, BLOCK_STATE_CHG); + 385 9119210 : hash_invalid_set(block->hash); 386 : } 387 : - 388 3691126 : return file; + 388 3690991 : return file; 389 : } 390 : 391 22687 : struct snapraid_file* file_dup(struct snapraid_file* copy) @@ -476,14 +476,14 @@ 414 22687 : return file; 415 : } 416 : - 417 3543814 : void file_free(struct snapraid_file* file) + 417 3543815 : void file_free(struct snapraid_file* file) 418 : { - 419 3543814 : free(file->sub); - 420 3543814 : file->sub = 0; - 421 3543814 : free(file->blockvec); - 422 3543814 : file->blockvec = 0; - 423 3543814 : free(file); - 424 3543814 : } + 419 3543815 : free(file->sub); + 420 3543815 : file->sub = 0; + 421 3543815 : free(file->blockvec); + 422 3543815 : file->blockvec = 0; + 423 3543815 : free(file); + 424 3543815 : } 425 : 426 155 : void file_rename(struct snapraid_file* file, const char* sub) 427 : { @@ -527,31 +527,31 @@ 465 23636 : file_flag_set(dst_file, FILE_IS_COPY); 466 23636 : } 467 : - 468 47922 : const char* file_name(const struct snapraid_file* file) + 468 47954 : const char* file_name(const struct snapraid_file* file) 469 : { - 470 47922 : const char* r = strrchr(file->sub, '/'); + 470 47954 : const char* r = strrchr(file->sub, '/'); 471 : - 472 47922 : if (!r) + 472 47954 : if (!r) 473 78 : r = file->sub; 474 : else - 475 47844 : ++r; - 476 47922 : return r; + 475 47876 : ++r; + 476 47954 : return r; 477 : } 478 : - 479 6823791 : unsigned file_block_size(struct snapraid_file* file, block_off_t file_pos, unsigned block_size) + 479 6823038 : unsigned file_block_size(struct snapraid_file* file, block_off_t file_pos, unsigned block_size) 480 : { 481 : /* if it's the last block */ - 482 6823791 : if (file_pos + 1 == file->blockmax) { + 482 6823038 : if (file_pos + 1 == file->blockmax) { 483 : unsigned block_remainder; - 484 2775528 : if (file->size == 0) + 484 2775121 : if (file->size == 0) 485 0 : return 0; - 486 2775528 : block_remainder = file->size % block_size; - 487 2775528 : if (block_remainder == 0) - 488 3039 : block_remainder = block_size; - 489 2775528 : return block_remainder; + 486 2775121 : block_remainder = file->size % block_size; + 487 2775121 : if (block_remainder == 0) + 488 3044 : block_remainder = block_size; + 489 2775121 : return block_remainder; 490 : } 491 : - 492 4048263 : return block_size; + 492 4047917 : return block_size; 493 : } 494 : 495 5329167 : int file_block_is_last(struct snapraid_file* file, block_off_t file_pos) @@ -569,16 +569,16 @@ 507 5329167 : return file_pos == file->blockmax - 1; 508 : } 509 : - 510 987099 : int file_inode_compare_to_arg(const void* void_arg, const void* void_data) + 510 975235 : int file_inode_compare_to_arg(const void* void_arg, const void* void_data) 511 : { - 512 987099 : const uint64_t* arg = void_arg; - 513 987099 : const struct snapraid_file* file = void_data; + 512 975235 : const uint64_t* arg = void_arg; + 513 975235 : const struct snapraid_file* file = void_data; 514 : - 515 987099 : if (*arg < file->inode) + 515 975235 : if (*arg < file->inode) 516 0 : return -1; - 517 987099 : if (*arg > file->inode) + 517 975235 : if (*arg > file->inode) 518 0 : return 1; - 519 987099 : return 0; + 519 975235 : return 0; 520 : } 521 : 522 0 : int file_inode_compare(const void* void_a, const void* void_b) @@ -593,42 +593,42 @@ 531 0 : return 0; 532 : } 533 : - 534 189486 : int file_path_compare(const void* void_a, const void* void_b) + 534 189475 : int file_path_compare(const void* void_a, const void* void_b) 535 : { - 536 189486 : const struct snapraid_file* file_a = void_a; - 537 189486 : const struct snapraid_file* file_b = void_b; + 536 189475 : const struct snapraid_file* file_a = void_a; + 537 189475 : const struct snapraid_file* file_b = void_b; 538 : - 539 189486 : return strcmp(file_a->sub, file_b->sub); + 539 189475 : return strcmp(file_a->sub, file_b->sub); 540 : } 541 : - 542 44202 : int file_physical_compare(const void* void_a, const void* void_b) + 542 44212 : int file_physical_compare(const void* void_a, const void* void_b) 543 : { - 544 44202 : const struct snapraid_file* file_a = void_a; - 545 44202 : const struct snapraid_file* file_b = void_b; + 544 44212 : const struct snapraid_file* file_a = void_a; + 545 44212 : const struct snapraid_file* file_b = void_b; 546 : - 547 44202 : if (file_a->physical < file_b->physical) - 548 30758 : return -1; - 549 13444 : if (file_a->physical > file_b->physical) - 550 13442 : return 1; + 547 44212 : if (file_a->physical < file_b->physical) + 548 31866 : return -1; + 549 12346 : if (file_a->physical > file_b->physical) + 550 12344 : return 1; 551 2 : return 0; 552 : } 553 : - 554 97531 : int file_path_compare_to_arg(const void* void_arg, const void* void_data) + 554 97871 : int file_path_compare_to_arg(const void* void_arg, const void* void_data) 555 : { - 556 97531 : const char* arg = void_arg; - 557 97531 : const struct snapraid_file* file = void_data; + 556 97871 : const char* arg = void_arg; + 557 97871 : const struct snapraid_file* file = void_data; 558 : - 559 97531 : return strcmp(arg, file->sub); + 559 97871 : return strcmp(arg, file->sub); 560 : } 561 : - 562 23961 : int file_name_compare(const void* void_a, const void* void_b) + 562 23977 : int file_name_compare(const void* void_a, const void* void_b) 563 : { - 564 23961 : const struct snapraid_file* file_a = void_a; - 565 23961 : const struct snapraid_file* file_b = void_b; - 566 23961 : const char* name_a = file_name(file_a); - 567 23961 : const char* name_b = file_name(file_b); + 564 23977 : const struct snapraid_file* file_a = void_a; + 565 23977 : const struct snapraid_file* file_b = void_b; + 566 23977 : const char* name_a = file_name(file_a); + 567 23977 : const char* name_b = file_name(file_b); 568 : - 569 23961 : return strcmp(name_a, name_b); + 569 23977 : return strcmp(name_a, name_b); 570 : } 571 : 572 23670 : int file_stamp_compare(const void* void_a, const void* void_b) @@ -654,13 +654,13 @@ 592 23670 : return 0; 593 : } 594 : - 595 23961 : int file_namestamp_compare(const void* void_a, const void* void_b) + 595 23977 : int file_namestamp_compare(const void* void_a, const void* void_b) 596 : { 597 : int ret; 598 : - 599 23961 : ret = file_name_compare(void_a, void_b); - 600 23961 : if (ret != 0) - 601 291 : return ret; + 599 23977 : ret = file_name_compare(void_a, void_b); + 600 23977 : if (ret != 0) + 601 307 : return ret; 602 : 603 23670 : return file_stamp_compare(void_a, void_b); 604 : } @@ -676,66 +676,66 @@ 614 0 : return file_stamp_compare(void_a, void_b); 615 : } 616 : - 617 3735396 : struct snapraid_extent* extent_alloc(block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos, block_off_t count) + 617 3735289 : struct snapraid_extent* extent_alloc(block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos, block_off_t count) 618 : { 619 : struct snapraid_extent* extent; 620 : - 621 3735396 : if (count == 0) { + 621 3735289 : if (count == 0) { 622 : /* LCOV_EXCL_START */ 623 : log_fatal("Internal inconsistency when allocating empty extent for file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax); 624 : os_abort(); 625 : /* LCOV_EXCL_STOP */ 626 : } - 627 3735396 : if (file_pos + count > file->blockmax) { + 627 3735289 : if (file_pos + count > file->blockmax) { 628 : /* LCOV_EXCL_START */ 629 : log_fatal("Internal inconsistency when allocating overflowing extent for file '%s' at position '%u:%u/%u'\n", file->sub, file_pos, count, file->blockmax); 630 : os_abort(); 631 : /* LCOV_EXCL_STOP */ 632 : } 633 : - 634 3735396 : extent = malloc_nofail(sizeof(struct snapraid_extent)); - 635 3735396 : extent->parity_pos = parity_pos; - 636 3735396 : extent->file = file; - 637 3735396 : extent->file_pos = file_pos; - 638 3735396 : extent->count = count; + 634 3735289 : extent = malloc_nofail(sizeof(struct snapraid_extent)); + 635 3735289 : extent->parity_pos = parity_pos; + 636 3735289 : extent->file = file; + 637 3735289 : extent->file_pos = file_pos; + 638 3735289 : extent->count = count; 639 : - 640 3735396 : return extent; + 640 3735289 : return extent; 641 : } 642 : - 643 3564840 : void extent_free(struct snapraid_extent* extent) + 643 3564865 : void extent_free(struct snapraid_extent* extent) 644 : { - 645 3564840 : free(extent); - 646 3564840 : } + 645 3564865 : free(extent); + 646 3564865 : } 647 : - 648 44510782 : int extent_parity_compare(const void* void_a, const void* void_b) + 648 44509325 : int extent_parity_compare(const void* void_a, const void* void_b) 649 : { - 650 44510782 : const struct snapraid_extent* arg_a = void_a; - 651 44510782 : const struct snapraid_extent* arg_b = void_b; + 650 44509325 : const struct snapraid_extent* arg_a = void_a; + 651 44509325 : const struct snapraid_extent* arg_b = void_b; 652 : - 653 44510782 : if (arg_a->parity_pos < arg_b->parity_pos) - 654 960328 : return -1; - 655 43550454 : if (arg_a->parity_pos > arg_b->parity_pos) - 656 43510787 : return 1; + 653 44509325 : if (arg_a->parity_pos < arg_b->parity_pos) + 654 960426 : return -1; + 655 43548899 : if (arg_a->parity_pos > arg_b->parity_pos) + 656 43509241 : return 1; 657 : - 658 39667 : return 0; + 658 39658 : return 0; 659 : } 660 : - 661 45007274 : int extent_file_compare(const void* void_a, const void* void_b) + 661 45005658 : int extent_file_compare(const void* void_a, const void* void_b) 662 : { - 663 45007274 : const struct snapraid_extent* arg_a = void_a; - 664 45007274 : const struct snapraid_extent* arg_b = void_b; + 663 45005658 : const struct snapraid_extent* arg_a = void_a; + 664 45005658 : const struct snapraid_extent* arg_b = void_b; 665 : - 666 45007274 : if (arg_a->file < arg_b->file) - 667 874179 : return -1; - 668 44133095 : if (arg_a->file > arg_b->file) - 669 44062303 : return 1; + 666 45005658 : if (arg_a->file < arg_b->file) + 667 875311 : return -1; + 668 44130347 : if (arg_a->file > arg_b->file) + 669 44059546 : return 1; 670 : - 671 70792 : if (arg_a->file_pos < arg_b->file_pos) + 671 70801 : if (arg_a->file_pos < arg_b->file_pos) 672 208 : return -1; - 673 70584 : if (arg_a->file_pos > arg_b->file_pos) - 674 30917 : return 1; + 673 70593 : if (arg_a->file_pos > arg_b->file_pos) + 674 30935 : return 1; 675 : - 676 39667 : return 0; + 676 39658 : return 0; 677 : } 678 : 679 119522 : struct snapraid_link* link_alloc(const char* sub, const char* linkto, unsigned link_flag) @@ -798,89 +798,89 @@ 736 249 : return strcmp(arg, dir->sub); 737 : } 738 : - 739 1585 : struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev, const char* uuid, int skip) + 739 1591 : struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev, const char* uuid, int skip) 740 : { 741 : struct snapraid_disk* disk; 742 : - 743 1585 : disk = malloc_nofail(sizeof(struct snapraid_disk)); - 744 1585 : pathcpy(disk->name, sizeof(disk->name), name); - 745 1585 : pathimport(disk->dir, sizeof(disk->dir), dir); - 746 1585 : pathcpy(disk->uuid, sizeof(disk->uuid), uuid); + 743 1591 : disk = malloc_nofail(sizeof(struct snapraid_disk)); + 744 1591 : pathcpy(disk->name, sizeof(disk->name), name); + 745 1591 : pathimport(disk->dir, sizeof(disk->dir), dir); + 746 1591 : pathcpy(disk->uuid, sizeof(disk->uuid), uuid); 747 : 748 : /* ensure that the dir terminate with "/" if it isn't empty */ - 749 1585 : pathslash(disk->dir, sizeof(disk->dir)); + 749 1591 : pathslash(disk->dir, sizeof(disk->dir)); 750 : 751 : #if HAVE_PTHREAD - 752 1585 : thread_mutex_init(&disk->fs_mutex, 0); + 752 1591 : thread_mutex_init(&disk->fs_mutex, 0); 753 : #endif 754 : - 755 1585 : disk->smartctl[0] = 0; - 756 1585 : disk->device = dev; - 757 1585 : disk->tick = 0; - 758 1585 : disk->cached = 0; - 759 1585 : disk->total_blocks = 0; - 760 1585 : disk->free_blocks = 0; - 761 1585 : disk->first_free_block = 0; - 762 1585 : disk->has_volatile_inodes = 0; - 763 1585 : disk->has_unreliable_physical = 0; - 764 1585 : disk->has_different_uuid = 0; - 765 1585 : disk->has_unsupported_uuid = *uuid == 0; /* empty UUID means unsupported */ - 766 1585 : disk->had_empty_uuid = 0; - 767 1585 : disk->mapping_idx = -1; - 768 1585 : disk->skip_access = skip; - 769 1585 : tommy_list_init(&disk->filelist); - 770 1585 : tommy_list_init(&disk->deletedlist); - 771 1585 : tommy_hashdyn_init(&disk->inodeset); - 772 1585 : tommy_hashdyn_init(&disk->pathset); - 773 1585 : tommy_hashdyn_init(&disk->stampset); - 774 1585 : tommy_list_init(&disk->linklist); - 775 1585 : tommy_hashdyn_init(&disk->linkset); - 776 1585 : tommy_list_init(&disk->dirlist); - 777 1585 : tommy_hashdyn_init(&disk->dirset); - 778 1585 : tommy_tree_init(&disk->fs_parity, extent_parity_compare); - 779 1585 : tommy_tree_init(&disk->fs_file, extent_file_compare); - 780 1585 : disk->fs_last = 0; + 755 1591 : disk->smartctl[0] = 0; + 756 1591 : disk->device = dev; + 757 1591 : disk->tick = 0; + 758 1591 : disk->cached = 0; + 759 1591 : disk->total_blocks = 0; + 760 1591 : disk->free_blocks = 0; + 761 1591 : disk->first_free_block = 0; + 762 1591 : disk->has_volatile_inodes = 0; + 763 1591 : disk->has_unreliable_physical = 0; + 764 1591 : disk->has_different_uuid = 0; + 765 1591 : disk->has_unsupported_uuid = *uuid == 0; /* empty UUID means unsupported */ + 766 1591 : disk->had_empty_uuid = 0; + 767 1591 : disk->mapping_idx = -1; + 768 1591 : disk->skip_access = skip; + 769 1591 : tommy_list_init(&disk->filelist); + 770 1591 : tommy_list_init(&disk->deletedlist); + 771 1591 : tommy_hashdyn_init(&disk->inodeset); + 772 1591 : tommy_hashdyn_init(&disk->pathset); + 773 1591 : tommy_hashdyn_init(&disk->stampset); + 774 1591 : tommy_list_init(&disk->linklist); + 775 1591 : tommy_hashdyn_init(&disk->linkset); + 776 1591 : tommy_list_init(&disk->dirlist); + 777 1591 : tommy_hashdyn_init(&disk->dirset); + 778 1591 : tommy_tree_init(&disk->fs_parity, extent_parity_compare); + 779 1591 : tommy_tree_init(&disk->fs_file, extent_file_compare); + 780 1591 : disk->fs_last = 0; 781 : - 782 1585 : return disk; + 782 1591 : return disk; 783 : } 784 : - 785 1453 : void disk_free(struct snapraid_disk* disk) + 785 1459 : void disk_free(struct snapraid_disk* disk) 786 : { - 787 1453 : tommy_list_foreach(&disk->filelist, (tommy_foreach_func*)file_free); - 788 1453 : tommy_list_foreach(&disk->deletedlist, (tommy_foreach_func*)file_free); - 789 1453 : tommy_tree_foreach(&disk->fs_file, (tommy_foreach_func*)extent_free); - 790 1453 : tommy_hashdyn_done(&disk->inodeset); - 791 1453 : tommy_hashdyn_done(&disk->pathset); - 792 1453 : tommy_hashdyn_done(&disk->stampset); - 793 1453 : tommy_list_foreach(&disk->linklist, (tommy_foreach_func*)link_free); - 794 1453 : tommy_hashdyn_done(&disk->linkset); - 795 1453 : tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free); - 796 1453 : tommy_hashdyn_done(&disk->dirset); + 787 1459 : tommy_list_foreach(&disk->filelist, (tommy_foreach_func*)file_free); + 788 1459 : tommy_list_foreach(&disk->deletedlist, (tommy_foreach_func*)file_free); + 789 1459 : tommy_tree_foreach(&disk->fs_file, (tommy_foreach_func*)extent_free); + 790 1459 : tommy_hashdyn_done(&disk->inodeset); + 791 1459 : tommy_hashdyn_done(&disk->pathset); + 792 1459 : tommy_hashdyn_done(&disk->stampset); + 793 1459 : tommy_list_foreach(&disk->linklist, (tommy_foreach_func*)link_free); + 794 1459 : tommy_hashdyn_done(&disk->linkset); + 795 1459 : tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free); + 796 1459 : tommy_hashdyn_done(&disk->dirset); 797 : 798 : #if HAVE_PTHREAD - 799 1453 : thread_mutex_destroy(&disk->fs_mutex); + 799 1459 : thread_mutex_destroy(&disk->fs_mutex); 800 : #endif 801 : - 802 1453 : free(disk); - 803 1453 : } + 802 1459 : free(disk); + 803 1459 : } 804 : - 805 53196480 : static inline void fs_lock(struct snapraid_disk* disk) + 805 53195526 : static inline void fs_lock(struct snapraid_disk* disk) 806 : { 807 : #if HAVE_PTHREAD - 808 53196480 : thread_mutex_lock(&disk->fs_mutex); + 808 53195526 : thread_mutex_lock(&disk->fs_mutex); 809 : #else 810 : (void)disk; 811 : #endif - 812 53197205 : } + 812 53196097 : } 813 : - 814 53196096 : static inline void fs_unlock(struct snapraid_disk* disk) + 814 53195112 : static inline void fs_unlock(struct snapraid_disk* disk) 815 : { 816 : #if HAVE_PTHREAD - 817 53196096 : thread_mutex_unlock(&disk->fs_mutex); + 817 53195112 : thread_mutex_unlock(&disk->fs_mutex); 818 : #else 819 : (void)disk; 820 : #endif - 821 53197239 : } + 821 53196272 : } 822 : 823 : struct extent_disk_empty { 824 : block_off_t blockmax; @@ -937,30 +937,30 @@ 875 : * 876 : * The maximum parity position is stored as size. 877 : */ - 878 50510 : static int extent_disk_size_compare_unlock(const void* void_a, const void* void_b) + 878 50514 : static int extent_disk_size_compare_unlock(const void* void_a, const void* void_b) 879 : { - 880 50510 : struct extent_disk_size* arg_a = (void*)void_a; - 881 50510 : const struct snapraid_extent* arg_b = void_b; + 880 50514 : struct extent_disk_size* arg_a = (void*)void_a; + 881 50514 : const struct snapraid_extent* arg_b = void_b; 882 : 883 : /* get the maximum size */ - 884 50510 : if (arg_a->size < arg_b->parity_pos + arg_b->count) - 885 50510 : arg_a->size = arg_b->parity_pos + arg_b->count; + 884 50514 : if (arg_a->size < arg_b->parity_pos + arg_b->count) + 885 50514 : arg_a->size = arg_b->parity_pos + arg_b->count; 886 : 887 : /* search always for a bigger one */ - 888 50510 : return 1; + 888 50514 : return 1; 889 : } 890 : - 891 4351 : block_off_t fs_size(struct snapraid_disk* disk) + 891 4363 : block_off_t fs_size(struct snapraid_disk* disk) 892 : { - 893 4351 : struct extent_disk_size arg = { 0 }; + 893 4363 : struct extent_disk_size arg = { 0 }; 894 : - 895 4351 : fs_lock(disk); + 895 4363 : fs_lock(disk); 896 : - 897 4351 : tommy_tree_search_compare(&disk->fs_parity, extent_disk_size_compare_unlock, &arg); + 897 4363 : tommy_tree_search_compare(&disk->fs_parity, extent_disk_size_compare_unlock, &arg); 898 : - 899 4351 : fs_unlock(disk); + 899 4363 : fs_unlock(disk); 900 : - 901 4351 : return arg.size; + 901 4363 : return arg.size; 902 : } 903 : 904 : struct extent_check { @@ -968,23 +968,23 @@ 906 : int result; 907 : }; 908 : - 909 6584417 : static void extent_parity_check_foreach_unlock(void* void_arg, void* void_obj) + 909 6584473 : static void extent_parity_check_foreach_unlock(void* void_arg, void* void_obj) 910 : { - 911 6584417 : struct extent_check* arg = void_arg; - 912 6584417 : const struct snapraid_extent* obj = void_obj; - 913 6584417 : const struct snapraid_extent* prev = arg->prev; + 911 6584473 : struct extent_check* arg = void_arg; + 912 6584473 : const struct snapraid_extent* obj = void_obj; + 913 6584473 : const struct snapraid_extent* prev = arg->prev; 914 : 915 : /* set the next previous block */ - 916 6584417 : arg->prev = obj; + 916 6584473 : arg->prev = obj; 917 : 918 : /* stop reporting if too many errors */ - 919 6584417 : if (arg->result > 100) { + 919 6584473 : if (arg->result > 100) { 920 : /* LCOV_EXCL_START */ 921 : return; 922 : /* LCOV_EXCL_STOP */ 923 : } 924 : - 925 6584417 : if (obj->count == 0) { + 925 6584473 : if (obj->count == 0) { 926 : /* LCOV_EXCL_START */ 927 : log_fatal("Internal inconsistency in parity count zero for file '%s' at '%u'\n", 928 : obj->file->sub, obj->parity_pos); @@ -994,11 +994,11 @@ 932 : } 933 : 934 : /* check only if there is a previous block */ - 935 6584417 : if (!prev) - 936 2718 : return; + 935 6584473 : if (!prev) + 936 2723 : return; 937 : 938 : /* check the order */ - 939 6581699 : if (prev->parity_pos >= obj->parity_pos) { + 939 6581750 : if (prev->parity_pos >= obj->parity_pos) { 940 : /* LCOV_EXCL_START */ 941 : log_fatal("Internal inconsistency in parity order for files '%s' at '%u:%u' and '%s' at '%u:%u'\n", 942 : prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count); @@ -1008,7 +1008,7 @@ 946 : } 947 : 948 : /* check that the extents don't overlap */ - 949 6581699 : if (prev->parity_pos + prev->count > obj->parity_pos) { + 949 6581750 : if (prev->parity_pos + prev->count > obj->parity_pos) { 950 : /* LCOV_EXCL_START */ 951 : log_fatal("Internal inconsistency for parity overlap for files '%s' at '%u:%u' and '%s' at '%u:%u'\n", 952 : prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count); @@ -1018,23 +1018,23 @@ 956 : } 957 : } 958 : - 959 6584417 : static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj) + 959 6584473 : static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj) 960 : { - 961 6584417 : struct extent_check* arg = void_arg; - 962 6584417 : const struct snapraid_extent* obj = void_obj; - 963 6584417 : const struct snapraid_extent* prev = arg->prev; + 961 6584473 : struct extent_check* arg = void_arg; + 962 6584473 : const struct snapraid_extent* obj = void_obj; + 963 6584473 : const struct snapraid_extent* prev = arg->prev; 964 : 965 : /* set the next previous block */ - 966 6584417 : arg->prev = obj; + 966 6584473 : arg->prev = obj; 967 : 968 : /* stop reporting if too many errors */ - 969 6584417 : if (arg->result > 100) { + 969 6584473 : if (arg->result > 100) { 970 : /* LCOV_EXCL_START */ 971 : return; 972 : /* LCOV_EXCL_STOP */ 973 : } 974 : - 975 6584417 : if (obj->count == 0) { + 975 6584473 : if (obj->count == 0) { 976 : /* LCOV_EXCL_START */ 977 : log_fatal("Internal inconsistency in file count zero for file '%s' at '%u'\n", 978 : obj->file->sub, obj->file_pos); @@ -1046,9 +1046,9 @@ 984 : /* note that for deleted files, some extents may be missing */ 985 : 986 : /* if the files are different */ - 987 6584417 : if (!prev || prev->file != obj->file) { - 988 6538257 : if (prev != 0) { - 989 6535539 : if (file_flag_has(prev->file, FILE_IS_DELETED)) { + 987 6584473 : if (!prev || prev->file != obj->file) { + 988 6538269 : if (prev != 0) { + 989 6535546 : if (file_flag_has(prev->file, FILE_IS_DELETED)) { 990 : /* check that the extent doesn't overflow the file */ 991 59759 : if (prev->file_pos + prev->count > prev->file->blockmax) { 992 : /* LCOV_EXCL_START */ @@ -1060,7 +1060,7 @@ 998 : } 999 : } else { 1000 : /* check that the extent ends the file */ - 1001 6475780 : if (prev->file_pos + prev->count != prev->file->blockmax) { + 1001 6475787 : if (prev->file_pos + prev->count != prev->file->blockmax) { 1002 : /* LCOV_EXCL_START */ 1003 : log_fatal("Internal inconsistency in file end for file '%s' at '%u:%u' instead of size '%u'\n", 1004 : prev->file->sub, prev->file_pos, prev->count, prev->file->blockmax); @@ -1071,7 +1071,7 @@ 1009 : } 1010 : } 1011 : - 1012 13076514 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { + 1012 13076538 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { 1013 : /* check that the extent doesn't overflow the file */ 1014 59842 : if (obj->file_pos + obj->count > obj->file->blockmax) { 1015 : /* LCOV_EXCL_START */ @@ -1083,7 +1083,7 @@ 1021 : } 1022 : } else { 1023 : /* check that the extent starts the file */ - 1024 6478415 : if (obj->file_pos != 0) { + 1024 6478427 : if (obj->file_pos != 0) { 1025 : /* LCOV_EXCL_START */ 1026 : log_fatal("Internal inconsistency in file start for file '%s' at '%u:%u'\n", 1027 : obj->file->sub, obj->file_pos, obj->count); @@ -1094,7 +1094,7 @@ 1032 : } 1033 : } else { 1034 : /* check the order */ - 1035 46160 : if (prev->file_pos >= obj->file_pos) { + 1035 46204 : if (prev->file_pos >= obj->file_pos) { 1036 : /* LCOV_EXCL_START */ 1037 : log_fatal("Internal inconsistency in file order for file '%s' at '%u:%u' and at '%u:%u'\n", 1038 : prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count); @@ -1103,7 +1103,7 @@ 1041 : /* LCOV_EXCL_STOP */ 1042 : } 1043 : - 1044 46160 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { + 1044 46204 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { 1045 : /* check that the extents don't overlap */ 1046 27 : if (prev->file_pos + prev->count > obj->file_pos) { 1047 : /* LCOV_EXCL_START */ @@ -1115,7 +1115,7 @@ 1053 : } 1054 : } else { 1055 : /* check that the extents are sequential */ - 1056 46133 : if (prev->file_pos + prev->count != obj->file_pos) { + 1056 46177 : if (prev->file_pos + prev->count != obj->file_pos) { 1057 : /* LCOV_EXCL_START */ 1058 : log_fatal("Internal inconsistency in file sequence for file '%s' at '%u:%u' and at '%u:%u'\n", 1059 : prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count); @@ -1127,29 +1127,29 @@ 1065 : } 1066 : } 1067 : - 1068 2982 : int fs_check(struct snapraid_disk* disk) + 1068 2988 : int fs_check(struct snapraid_disk* disk) 1069 : { 1070 : struct extent_check arg; 1071 : 1072 : /* error count starts from 0 */ - 1073 2982 : arg.result = 0; + 1073 2988 : arg.result = 0; 1074 : - 1075 2982 : fs_lock(disk); + 1075 2988 : fs_lock(disk); 1076 : 1077 : /* check parity sequence */ - 1078 2982 : arg.prev = 0; - 1079 2982 : tommy_tree_foreach_arg(&disk->fs_parity, extent_parity_check_foreach_unlock, &arg); + 1078 2988 : arg.prev = 0; + 1079 2988 : tommy_tree_foreach_arg(&disk->fs_parity, extent_parity_check_foreach_unlock, &arg); 1080 : 1081 : /* check file sequence */ - 1082 2982 : arg.prev = 0; - 1083 2982 : tommy_tree_foreach_arg(&disk->fs_file, extent_file_check_foreach_unlock, &arg); + 1082 2988 : arg.prev = 0; + 1083 2988 : tommy_tree_foreach_arg(&disk->fs_file, extent_file_check_foreach_unlock, &arg); 1084 : - 1085 2982 : fs_unlock(disk); + 1085 2988 : fs_unlock(disk); 1086 : - 1087 2982 : if (arg.result != 0) + 1087 2988 : if (arg.result != 0) 1088 0 : return -1; 1089 : - 1090 2982 : return 0; + 1090 2988 : return 0; 1091 : } 1092 : 1093 : struct extent_parity_inside { @@ -1159,17 +1159,17 @@ 1097 : /** 1098 : * Compare the extent if containing the specified parity position. 1099 : */ - 1100 113835807 : static int extent_parity_inside_compare_unlock(const void* void_a, const void* void_b) + 1100 114575009 : static int extent_parity_inside_compare_unlock(const void* void_a, const void* void_b) 1101 : { - 1102 113835807 : const struct extent_parity_inside* arg_a = void_a; - 1103 113835807 : const struct snapraid_extent* arg_b = void_b; + 1102 114575009 : const struct extent_parity_inside* arg_a = void_a; + 1103 114575009 : const struct snapraid_extent* arg_b = void_b; 1104 : - 1105 113835807 : if (arg_a->parity_pos < arg_b->parity_pos) - 1106 40242517 : return -1; - 1107 73593290 : if (arg_a->parity_pos >= arg_b->parity_pos + arg_b->count) - 1108 64881921 : return 1; + 1105 114575009 : if (arg_a->parity_pos < arg_b->parity_pos) + 1106 40547890 : return -1; + 1107 74027119 : if (arg_a->parity_pos >= arg_b->parity_pos + arg_b->count) + 1108 65245847 : return 1; 1109 : - 1110 8711369 : return 0; + 1110 8781272 : return 0; 1111 : } 1112 : 1113 : /** @@ -1177,28 +1177,28 @@ 1115 : * The search is optimized for sequential accesses. 1116 : * \return If not found return 0 1117 : */ - 1118 39144459 : static struct snapraid_extent* fs_par2extent_get_unlock(struct snapraid_disk* disk, struct snapraid_extent** fs_last, block_off_t parity_pos) + 1118 39143508 : static struct snapraid_extent* fs_par2extent_get_unlock(struct snapraid_disk* disk, struct snapraid_extent** fs_last, block_off_t parity_pos) 1119 : { 1120 : struct snapraid_extent* extent; 1121 : 1122 : /* check if the last accessed extent matches */ - 1123 39144459 : if (*fs_last - 1124 39126053 : && parity_pos >= (*fs_last)->parity_pos - 1125 38409539 : && parity_pos < (*fs_last)->parity_pos + (*fs_last)->count + 1123 39143508 : if (*fs_last + 1124 39125091 : && parity_pos >= (*fs_last)->parity_pos + 1125 38408678 : && parity_pos < (*fs_last)->parity_pos + (*fs_last)->count 1126 : ) { - 1127 28848823 : extent = *fs_last; + 1127 28777623 : extent = *fs_last; 1128 : } else { - 1129 10295636 : struct extent_parity_inside arg = { parity_pos }; - 1130 10295636 : extent = tommy_tree_search_compare(&disk->fs_parity, extent_parity_inside_compare_unlock, &arg); + 1129 10365885 : struct extent_parity_inside arg = { parity_pos }; + 1130 10365885 : extent = tommy_tree_search_compare(&disk->fs_parity, extent_parity_inside_compare_unlock, &arg); 1131 : } 1132 : - 1133 39144338 : if (!extent) - 1134 1584242 : return 0; + 1133 39143433 : if (!extent) + 1134 1584679 : return 0; 1135 : 1136 : /* store the last accessed extent */ - 1137 37560096 : *fs_last = extent; + 1137 37558754 : *fs_last = extent; 1138 : - 1139 37560096 : return extent; + 1139 37558754 : return extent; 1140 : } 1141 : 1142 : struct extent_file_inside { @@ -1209,22 +1209,22 @@ 1147 : /** 1148 : * Compare the extent if containing the specified file position. 1149 : */ - 1150 21310663 : static int extent_file_inside_compare_unlock(const void* void_a, const void* void_b) + 1150 21310995 : static int extent_file_inside_compare_unlock(const void* void_a, const void* void_b) 1151 : { - 1152 21310663 : const struct extent_file_inside* arg_a = void_a; - 1153 21310663 : const struct snapraid_extent* arg_b = void_b; + 1152 21310995 : const struct extent_file_inside* arg_a = void_a; + 1153 21310995 : const struct snapraid_extent* arg_b = void_b; 1154 : - 1155 21310663 : if (arg_a->file < arg_b->file) - 1156 8886240 : return -1; - 1157 12424423 : if (arg_a->file > arg_b->file) - 1158 10404719 : return 1; + 1155 21310995 : if (arg_a->file < arg_b->file) + 1156 8885792 : return -1; + 1157 12425203 : if (arg_a->file > arg_b->file) + 1158 10405515 : return 1; 1159 : - 1160 2019704 : if (arg_a->file_pos < arg_b->file_pos) - 1161 8320 : return -1; - 1162 2011384 : if (arg_a->file_pos >= arg_b->file_pos + arg_b->count) - 1163 7938 : return 1; + 1160 2019688 : if (arg_a->file_pos < arg_b->file_pos) + 1161 8333 : return -1; + 1162 2011355 : if (arg_a->file_pos >= arg_b->file_pos + arg_b->count) + 1163 7947 : return 1; 1164 : - 1165 2003446 : return 0; + 1165 2003408 : return 0; 1166 : } 1167 : 1168 : /** @@ -1232,88 +1232,88 @@ 1170 : * The search is optimized for sequential accesses. 1171 : * \return If not found return 0 1172 : */ - 1173 10336351 : static struct snapraid_extent* fs_file2extent_get_unlock(struct snapraid_disk* disk, struct snapraid_extent** fs_last, struct snapraid_file* file, block_off_t file_pos) + 1173 10336255 : static struct snapraid_extent* fs_file2extent_get_unlock(struct snapraid_disk* disk, struct snapraid_extent** fs_last, struct snapraid_file* file, block_off_t file_pos) 1174 : { 1175 : struct snapraid_extent* extent; 1176 : 1177 : /* check if the last accessed extent matches */ - 1178 10336351 : if (*fs_last - 1179 10312659 : && file == (*fs_last)->file - 1180 8347111 : && file_pos >= (*fs_last)->file_pos - 1181 8347111 : && file_pos < (*fs_last)->file_pos + (*fs_last)->count + 1178 10336255 : if (*fs_last + 1179 10312569 : && file == (*fs_last)->file + 1180 8347073 : && file_pos >= (*fs_last)->file_pos + 1181 8347073 : && file_pos < (*fs_last)->file_pos + (*fs_last)->count 1182 : ) { - 1183 8332897 : extent = *fs_last; + 1183 8332839 : extent = *fs_last; 1184 : } else { - 1185 2003454 : struct extent_file_inside arg = { file, file_pos }; - 1186 2003454 : extent = tommy_tree_search_compare(&disk->fs_file, extent_file_inside_compare_unlock, &arg); + 1185 2003416 : struct extent_file_inside arg = { file, file_pos }; + 1186 2003416 : extent = tommy_tree_search_compare(&disk->fs_file, extent_file_inside_compare_unlock, &arg); 1187 : } 1188 : - 1189 10336351 : if (!extent) + 1189 10336255 : if (!extent) 1190 8 : return 0; 1191 : 1192 : /* store the last accessed extent */ - 1193 10336343 : *fs_last = extent; + 1193 10336247 : *fs_last = extent; 1194 : - 1195 10336343 : return extent; + 1195 10336247 : return extent; 1196 : } 1197 : - 1198 39037806 : struct snapraid_file* fs_par2file_find(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) + 1198 39036978 : struct snapraid_file* fs_par2file_find(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) 1199 : { 1200 : struct snapraid_extent* extent; 1201 : struct snapraid_file* file; 1202 : - 1203 39037806 : fs_lock(disk); + 1203 39036978 : fs_lock(disk); 1204 : - 1205 39038558 : extent = fs_par2extent_get_unlock(disk, &disk->fs_last, parity_pos); + 1205 39037785 : extent = fs_par2extent_get_unlock(disk, &disk->fs_last, parity_pos); 1206 : - 1207 39037687 : if (!extent) { - 1208 1584243 : fs_unlock(disk); - 1209 1584263 : return 0; + 1207 39036721 : if (!extent) { + 1208 1584680 : fs_unlock(disk); + 1209 1584723 : return 0; 1210 : } 1211 : - 1212 37453444 : if (file_pos) - 1213 37108755 : *file_pos = extent->file_pos + (parity_pos - extent->parity_pos); + 1212 37452041 : if (file_pos) + 1213 37107540 : *file_pos = extent->file_pos + (parity_pos - extent->parity_pos); 1214 : - 1215 37453444 : file = extent->file; + 1215 37452041 : file = extent->file; 1216 : - 1217 37453444 : fs_unlock(disk); - 1218 37454270 : return file; + 1217 37452041 : fs_unlock(disk); + 1218 37453073 : return file; 1219 : } 1220 : - 1221 4869582 : block_off_t fs_file2par_find(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) + 1221 4869703 : block_off_t fs_file2par_find(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) 1222 : { 1223 : struct snapraid_extent* extent; 1224 : block_off_t ret; 1225 : - 1226 4869582 : fs_lock(disk); + 1226 4869703 : fs_lock(disk); 1227 : - 1228 4869582 : extent = fs_file2extent_get_unlock(disk, &disk->fs_last, file, file_pos); - 1229 4869582 : if (!extent) { + 1228 4869703 : extent = fs_file2extent_get_unlock(disk, &disk->fs_last, file, file_pos); + 1229 4869703 : if (!extent) { 1230 8 : fs_unlock(disk); 1231 8 : return POS_NULL; 1232 : } 1233 : - 1234 4869574 : ret = extent->parity_pos + (file_pos - extent->file_pos); + 1234 4869695 : ret = extent->parity_pos + (file_pos - extent->file_pos); 1235 : - 1236 4869574 : fs_unlock(disk); - 1237 4869574 : return ret; + 1236 4869695 : fs_unlock(disk); + 1237 4869695 : return ret; 1238 : } 1239 : - 1240 9175524 : void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos) + 1240 9175178 : void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos) 1241 : { 1242 : struct snapraid_extent* extent; 1243 : struct snapraid_extent* parity_extent; 1244 : struct snapraid_extent* file_extent; 1245 : - 1246 9175524 : fs_lock(disk); + 1246 9175178 : fs_lock(disk); 1247 : - 1248 9175524 : if (file_pos > 0) { + 1248 9175178 : if (file_pos > 0) { 1249 : /* search an existing extent for the previous file_pos */ - 1250 5466769 : extent = fs_file2extent_get_unlock(disk, &disk->fs_last, file, file_pos - 1); + 1250 5466552 : extent = fs_file2extent_get_unlock(disk, &disk->fs_last, file, file_pos - 1); 1251 : - 1252 5466769 : if (extent != 0 && parity_pos == extent->parity_pos + extent->count) { + 1252 5466552 : if (extent != 0 && parity_pos == extent->parity_pos + extent->count) { 1253 : /* ensure that we are extending the extent at the end */ - 1254 5440129 : if (file_pos != extent->file_pos + extent->count) { + 1254 5439890 : if (file_pos != extent->file_pos + extent->count) { 1255 : /* LCOV_EXCL_START */ 1256 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' in the middle of extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name); 1257 : os_abort(); @@ -1321,21 +1321,21 @@ 1259 : } 1260 : 1261 : /* extend the existing extent */ - 1262 5440129 : ++extent->count; + 1262 5439890 : ++extent->count; 1263 : - 1264 5440129 : fs_unlock(disk); - 1265 14615653 : return; + 1264 5439890 : fs_unlock(disk); + 1265 14615068 : return; 1266 : } 1267 : } 1268 : 1269 : /* a extent doesn't exist, and we have to create a new one */ - 1270 3735395 : extent = extent_alloc(parity_pos, file, file_pos, 1); + 1270 3735288 : extent = extent_alloc(parity_pos, file, file_pos, 1); 1271 : 1272 : /* insert the extent in the trees */ - 1273 3735395 : parity_extent = tommy_tree_insert(&disk->fs_parity, &extent->parity_node, extent); - 1274 3735395 : file_extent = tommy_tree_insert(&disk->fs_file, &extent->file_node, extent); + 1273 3735288 : parity_extent = tommy_tree_insert(&disk->fs_parity, &extent->parity_node, extent); + 1274 3735288 : file_extent = tommy_tree_insert(&disk->fs_file, &extent->file_node, extent); 1275 : - 1276 3735395 : if (parity_extent != extent || file_extent != extent) { + 1276 3735288 : if (parity_extent != extent || file_extent != extent) { 1277 : /* LCOV_EXCL_START */ 1278 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' for existing extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name); 1279 : os_abort(); @@ -1343,12 +1343,12 @@ 1281 : } 1282 : 1283 : /* store the last accessed extent */ - 1284 3735395 : disk->fs_last = extent; + 1284 3735288 : disk->fs_last = extent; 1285 : - 1286 3735395 : fs_unlock(disk); + 1286 3735288 : fs_unlock(disk); 1287 : } 1288 : - 1289 106308 : void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos) + 1289 106232 : void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos) 1290 : { 1291 : struct snapraid_extent* extent; 1292 : struct snapraid_extent* second_extent; @@ -1356,10 +1356,10 @@ 1294 : struct snapraid_extent* file_extent; 1295 : block_off_t first_count, second_count; 1296 : - 1297 106308 : fs_lock(disk); + 1297 106232 : fs_lock(disk); 1298 : - 1299 106308 : extent = fs_par2extent_get_unlock(disk, &disk->fs_last, parity_pos); - 1300 106308 : if (!extent) { + 1299 106232 : extent = fs_par2extent_get_unlock(disk, &disk->fs_last, parity_pos); + 1300 106232 : if (!extent) { 1301 : /* LCOV_EXCL_START */ 1302 : log_fatal("Internal inconsistency when deallocating parity position '%u' for not existing extent in disk '%s'\n", parity_pos, disk->name); 1303 : os_abort(); @@ -1367,29 +1367,29 @@ 1305 : } 1306 : 1307 : /* if it's the only block of the extent, delete it */ - 1308 106308 : if (extent->count == 1) { + 1308 106232 : if (extent->count == 1) { 1309 : /* remove from the trees */ - 1310 39667 : tommy_tree_remove(&disk->fs_parity, extent); - 1311 39667 : tommy_tree_remove(&disk->fs_file, extent); + 1310 39658 : tommy_tree_remove(&disk->fs_parity, extent); + 1311 39658 : tommy_tree_remove(&disk->fs_file, extent); 1312 : 1313 : /* deallocate */ - 1314 39667 : extent_free(extent); + 1314 39658 : extent_free(extent); 1315 : 1316 : /* clear the last accessed extent */ - 1317 39667 : disk->fs_last = 0; + 1317 39658 : disk->fs_last = 0; 1318 : - 1319 39667 : fs_unlock(disk); - 1320 39667 : return; + 1319 39658 : fs_unlock(disk); + 1320 39658 : return; 1321 : } 1322 : 1323 : /* if it's at the start of the extent, shrink the extent */ - 1324 66641 : if (parity_pos == extent->parity_pos) { - 1325 66639 : ++extent->parity_pos; - 1326 66639 : ++extent->file_pos; - 1327 66639 : --extent->count; + 1324 66574 : if (parity_pos == extent->parity_pos) { + 1325 66572 : ++extent->parity_pos; + 1326 66572 : ++extent->file_pos; + 1327 66572 : --extent->count; 1328 : - 1329 66639 : fs_unlock(disk); - 1330 66639 : return; + 1329 66572 : fs_unlock(disk); + 1330 66572 : return; 1331 : } 1332 : 1333 : /* if it's at the end of the extent, shrink the extent */ @@ -1427,59 +1427,59 @@ 1365 1 : fs_unlock(disk); 1366 : } 1367 : - 1368 44946613 : struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos) + 1368 44945354 : struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos) 1369 : { - 1370 44946613 : if (file_pos >= file->blockmax) { + 1370 44945354 : if (file_pos >= file->blockmax) { 1371 : /* LCOV_EXCL_START */ 1372 : log_fatal("Internal inconsistency when dereferencing file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax); 1373 : os_abort(); 1374 : /* LCOV_EXCL_STOP */ 1375 : } 1376 : - 1377 44946613 : return file_block(file, file_pos); + 1377 44945354 : return file_block(file, file_pos); 1378 : } 1379 : - 1380 27314040 : struct snapraid_block* fs_par2block_find(struct snapraid_disk* disk, block_off_t parity_pos) + 1380 27313631 : struct snapraid_block* fs_par2block_find(struct snapraid_disk* disk, block_off_t parity_pos) 1381 : { 1382 : struct snapraid_file* file; 1383 : block_off_t file_pos; 1384 : - 1385 27314040 : file = fs_par2file_find(disk, parity_pos, &file_pos); - 1386 27314201 : if (file == 0) - 1387 1584227 : return BLOCK_NULL; + 1385 27313631 : file = fs_par2file_find(disk, parity_pos, &file_pos); + 1386 27313916 : if (file == 0) + 1387 1584719 : return BLOCK_NULL; 1388 : - 1389 25729974 : return fs_file2block_get(file, file_pos); + 1389 25729197 : return fs_file2block_get(file, file_pos); 1390 : } 1391 : - 1392 1555 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid) + 1392 1561 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid) 1393 : { 1394 : struct snapraid_map* map; 1395 : - 1396 1555 : map = malloc_nofail(sizeof(struct snapraid_map)); - 1397 1555 : pathcpy(map->name, sizeof(map->name), name); - 1398 1555 : map->position = position; - 1399 1555 : map->total_blocks = total_blocks; - 1400 1555 : map->free_blocks = free_blocks; - 1401 1555 : pathcpy(map->uuid, sizeof(map->uuid), uuid); + 1396 1561 : map = malloc_nofail(sizeof(struct snapraid_map)); + 1397 1561 : pathcpy(map->name, sizeof(map->name), name); + 1398 1561 : map->position = position; + 1399 1561 : map->total_blocks = total_blocks; + 1400 1561 : map->free_blocks = free_blocks; + 1401 1561 : pathcpy(map->uuid, sizeof(map->uuid), uuid); 1402 : - 1403 1555 : return map; + 1403 1561 : return map; 1404 : } 1405 : - 1406 1429 : void map_free(struct snapraid_map* map) + 1406 1435 : void map_free(struct snapraid_map* map) 1407 : { - 1408 1429 : free(map); - 1409 1429 : } + 1408 1435 : free(map); + 1409 1435 : } 1410 : - 1411 684203 : int time_compare(const void* void_a, const void* void_b) + 1411 691801 : int time_compare(const void* void_a, const void* void_b) 1412 : { - 1413 684203 : const time_t* time_a = void_a; - 1414 684203 : const time_t* time_b = void_b; + 1413 691801 : const time_t* time_a = void_a; + 1414 691801 : const time_t* time_b = void_b; 1415 : - 1416 684203 : if (*time_a < *time_b) - 1417 16620 : return -1; - 1418 667583 : if (*time_a > *time_b) - 1419 119940 : return 1; - 1420 547643 : return 0; + 1416 691801 : if (*time_a < *time_b) + 1417 18310 : return -1; + 1418 673491 : if (*time_a > *time_b) + 1419 129297 : return 1; + 1420 544194 : return 0; 1421 : } 1422 : 1423 : /****************************************************************************/ @@ -1499,14 +1499,14 @@ 1437 : /** 1438 : * Format a path name for terminal reference 1439 : */ - 1440 356075 : const char* fmt_term(const struct snapraid_disk* disk, const char* str, char* buffer) + 1440 355906 : const char* fmt_term(const struct snapraid_disk* disk, const char* str, char* buffer) 1441 : { 1442 : const char* out[3]; 1443 : - 1444 356075 : switch (FMT_MODE) { + 1444 355906 : switch (FMT_MODE) { 1445 : case FMT_FILE : 1446 : default : - 1447 332015 : return esc_shell(str, buffer); + 1447 331846 : return esc_shell(str, buffer); 1448 : case FMT_DISK : 1449 12030 : out[0] = disk->name; 1450 12030 : out[1] = ":"; diff --git a/cov/cmdline/elem.h.func-sort-c.html b/cov/cmdline/elem.h.func-sort-c.html index 3a1b0405..b2224709 100644 --- a/cov/cmdline/elem.h.func-sort-c.html +++ b/cov/cmdline/elem.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 41 @@ -61,103 +61,103 @@ block_sizeof - 58066767 + 58065128 file_block - 54352792 + 54351316 block_state_get - 52307392 + 52304023 file_flag_has - 34094426 + 34089332 block_state_set - 19118268 + 19117096 block_has_file - 14591728 + 14591493 block_has_invalid_parity - 12320606 + 12320585 fs_par2file_get - 11723986 + 11723835 hash_invalid_set - 9234413 + 9234067 file_stamp_hash - 6275808 + 6275421 file_flag_set - 5301067 + 5295048 info_get - 5098627 + 5098669 file_inode_hash - 5047758 + 5042449 fs_file2par_get - 4755371 + 4755492 file_path_hash - 3885977 + 3886182 filter_hidden - 3173351 + 3173372 block_has_past_hash - 2542370 + 2542004 block_has_updated_hash - 2218141 + 2217099 info_get_rehash - 2046724 + 2046851 info_set - 1698098 + 1698121 info_get_time - 883015 + 883203 hash_is_zero - 760471 + 760108 hash_is_invalid - 759009 + 758645 info_get_bad - 351958 + 352076 block_has_file_and_valid_parity - 220959 + 220962 link_flag_has @@ -165,7 +165,7 @@ info_make - 194355 + 194583 link_name_hash @@ -181,24 +181,24 @@ info_get_justsynced - 68446 + 68634 hash_is_unique - 44333 + 44270 link_flag_set 39461 - - file_flag_clear - 16745 - fs_par2block_get 15867 + + file_flag_clear + 11286 + info_set_rehash 9215 diff --git a/cov/cmdline/elem.h.func.html b/cov/cmdline/elem.h.func.html index 3407ad88..36d3ea93 100644 --- a/cov/cmdline/elem.h.func.html +++ b/cov/cmdline/elem.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 41 @@ -61,35 +61,35 @@ block_has_file - 14591728 + 14591493 block_has_file_and_valid_parity - 220959 + 220962 block_has_invalid_parity - 12320606 + 12320585 block_has_past_hash - 2542370 + 2542004 block_has_updated_hash - 2218141 + 2217099 block_sizeof - 58066767 + 58065128 block_state_get - 52307392 + 52304023 block_state_set - 19118268 + 19117096 dir_flag_has @@ -105,39 +105,39 @@ file_block - 54352792 + 54351316 file_flag_clear - 16745 + 11286 file_flag_has - 34094426 + 34089332 file_flag_set - 5301067 + 5295048 file_inode_hash - 5047758 + 5042449 file_path_hash - 3885977 + 3886182 file_stamp_hash - 6275808 + 6275421 filter_hidden - 3173351 + 3173372 fs_file2par_get - 4755371 + 4755492 fs_par2block_get @@ -145,23 +145,23 @@ fs_par2file_get - 11723986 + 11723835 hash_invalid_set - 9234413 + 9234067 hash_is_invalid - 759009 + 758645 hash_is_unique - 44333 + 44270 hash_is_zero - 760471 + 760108 hash_zero_set @@ -169,31 +169,31 @@ info_get - 5098627 + 5098669 info_get_bad - 351958 + 352076 info_get_justsynced - 68446 + 68634 info_get_rehash - 2046724 + 2046851 info_get_time - 883015 + 883203 info_make - 194355 + 194583 info_set - 1698098 + 1698121 info_set_bad diff --git a/cov/cmdline/elem.h.gcov.html b/cov/cmdline/elem.h.gcov.html index d182c9e5..ddba0d94 100644 --- a/cov/cmdline/elem.h.gcov.html +++ b/cov/cmdline/elem.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 41 @@ -571,13 +571,13 @@ 509 : * Filter hidden files. 510 : * Return !=0 if it matches and it should be excluded. 511 : */ - 512 3173351 : static inline int filter_hidden(int enable, struct dirent* dd) + 512 3173372 : static inline int filter_hidden(int enable, struct dirent* dd) 513 : { - 514 3173351 : if (enable && dirent_hidden(dd)) { + 514 3173372 : if (enable && dirent_hidden(dd)) { 515 0 : return 1; /* filter out */ 516 : } 517 : - 518 3173351 : return 0; + 518 3173372 : return 0; 519 : } 520 : 521 : /** @@ -628,19 +628,19 @@ 566 : * 567 : * If working with reduced hash lengths, this function always return 0. 568 : */ - 569 759009 : static inline int hash_is_invalid(const unsigned char* hash) + 569 758645 : static inline int hash_is_invalid(const unsigned char* hash) 570 : { 571 : int i; 572 : 573 : /* if the hash is reduced, we cannot grant that it's a specific kind of hash */ - 574 759009 : if (BLOCK_HASH_SIZE != HASH_MAX) + 574 758645 : if (BLOCK_HASH_SIZE != HASH_MAX) 575 0 : return 0; 576 : - 577 1178755 : for (i = 0; i < BLOCK_HASH_SIZE; ++i) - 578 1152696 : if (hash[i] != 0x00) - 579 732950 : return 0; + 577 1178483 : for (i = 0; i < BLOCK_HASH_SIZE; ++i) + 578 1152419 : if (hash[i] != 0x00) + 579 732581 : return 0; 580 : - 581 26059 : return 1; + 581 26064 : return 1; 582 : } 583 : 584 : /** @@ -650,19 +650,19 @@ 588 : * 589 : * If working with reduced hash lengths, this function always return 0. 590 : */ - 591 760471 : static inline int hash_is_zero(const unsigned char* hash) + 591 760108 : static inline int hash_is_zero(const unsigned char* hash) 592 : { 593 : int i; 594 : 595 : /* if the hash is reduced, we cannot grant that it's a specific kind of hash */ - 596 760471 : if (BLOCK_HASH_SIZE != HASH_MAX) + 596 760108 : if (BLOCK_HASH_SIZE != HASH_MAX) 597 0 : return 0; 598 : - 599 994894 : for (i = 0; i < BLOCK_HASH_SIZE; ++i) - 600 980425 : if (hash[i] != 0xFF) - 601 746002 : return 0; + 599 994848 : for (i = 0; i < BLOCK_HASH_SIZE; ++i) + 600 980378 : if (hash[i] != 0xFF) + 601 745638 : return 0; 602 : - 603 14469 : return 1; + 603 14470 : return 1; 604 : } 605 : 606 : /** @@ -670,22 +670,22 @@ 608 : * 609 : * If working with reduced hash lengths, this function always return 0. 610 : */ - 611 44333 : static inline int hash_is_unique(const unsigned char* hash) + 611 44270 : static inline int hash_is_unique(const unsigned char* hash) 612 : { 613 : /* if the hash is reduced, we cannot grant that it's a specific kind of hash */ - 614 44333 : if (BLOCK_HASH_SIZE != HASH_MAX) + 614 44270 : if (BLOCK_HASH_SIZE != HASH_MAX) 615 0 : return 0; 616 : - 617 44333 : return !hash_is_zero(hash) && !hash_is_invalid(hash); + 617 44270 : return !hash_is_zero(hash) && !hash_is_invalid(hash); 618 : } 619 : 620 : /** 621 : * Set the hash to the special INVALID value. 622 : */ - 623 9234413 : static inline void hash_invalid_set(unsigned char* hash) + 623 9234067 : static inline void hash_invalid_set(unsigned char* hash) 624 : { - 625 9234413 : memset(hash, 0x00, BLOCK_HASH_SIZE); - 626 9234413 : } + 625 9234067 : memset(hash, 0x00, BLOCK_HASH_SIZE); + 626 9234067 : } 627 : 628 : /** 629 : * Set the hash to the special ZERO value. @@ -698,9 +698,9 @@ 636 : /** 637 : * Allocated space for block. 638 : */ - 639 58066767 : static inline size_t block_sizeof(void) + 639 58065128 : static inline size_t block_sizeof(void) 640 : { - 641 58066767 : return 1 + BLOCK_HASH_SIZE; + 641 58065128 : return 1 + BLOCK_HASH_SIZE; 642 : } 643 : 644 : /** @@ -709,32 +709,32 @@ 647 : * For this function, it's allowed to pass a NULL block 648 : * pointer than results in the BLOCK_STATE_EMPTY state. 649 : */ - 650 52307392 : static inline unsigned block_state_get(const struct snapraid_block* block) + 650 52304023 : static inline unsigned block_state_get(const struct snapraid_block* block) 651 : { - 652 52307392 : if (block == BLOCK_NULL) - 653 1721808 : return BLOCK_STATE_EMPTY; + 652 52304023 : if (block == BLOCK_NULL) + 653 1722497 : return BLOCK_STATE_EMPTY; 654 : - 655 50585584 : return block->state; + 655 50581526 : return block->state; 656 : } 657 : 658 : /** 659 : * Set the state of the block. 660 : */ - 661 19118268 : static inline void block_state_set(struct snapraid_block* block, unsigned state) + 661 19117096 : static inline void block_state_set(struct snapraid_block* block, unsigned state) 662 : { - 663 19118268 : block->state = state; - 664 19118268 : } + 663 19117096 : block->state = state; + 664 19117096 : } 665 : 666 : /** 667 : * Check if the specified block has an updated hash. 668 : * 669 : * Note that EMPTY / CHG / DELETED return 0. 670 : */ - 671 2218141 : static inline int block_has_updated_hash(const struct snapraid_block* block) + 671 2217099 : static inline int block_has_updated_hash(const struct snapraid_block* block) 672 : { - 673 2218141 : unsigned state = block_state_get(block); + 673 2217099 : unsigned state = block_state_get(block); 674 : - 675 2218141 : return state == BLOCK_STATE_BLK || state == BLOCK_STATE_REP; + 675 2217099 : return state == BLOCK_STATE_BLK || state == BLOCK_STATE_REP; 676 : } 677 : 678 : /** @@ -743,11 +743,11 @@ 681 : * 682 : * Note that EMPTY / BLK / REP return 0. 683 : */ - 684 2542370 : static inline int block_has_past_hash(const struct snapraid_block* block) + 684 2542004 : static inline int block_has_past_hash(const struct snapraid_block* block) 685 : { - 686 2542370 : unsigned state = block_state_get(block); + 686 2542004 : unsigned state = block_state_get(block); 687 : - 688 2542370 : return state == BLOCK_STATE_CHG || state == BLOCK_STATE_DELETED; + 688 2542004 : return state == BLOCK_STATE_CHG || state == BLOCK_STATE_DELETED; 689 : } 690 : 691 : /** @@ -755,12 +755,12 @@ 693 : * 694 : * Note that EMPTY / DELETED return 0. 695 : */ - 696 14591728 : static inline int block_has_file(const struct snapraid_block* block) + 696 14591493 : static inline int block_has_file(const struct snapraid_block* block) 697 : { - 698 14591728 : unsigned state = block_state_get(block); + 698 14591493 : unsigned state = block_state_get(block); 699 : - 700 14591975 : return state == BLOCK_STATE_BLK - 701 14591975 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; + 700 14591444 : return state == BLOCK_STATE_BLK + 701 14591444 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; 702 : } 703 : 704 : /** @@ -768,12 +768,12 @@ 706 : * 707 : * Note that EMPTY / BLK return 0. 708 : */ - 709 12320606 : static inline int block_has_invalid_parity(const struct snapraid_block* block) + 709 12320585 : static inline int block_has_invalid_parity(const struct snapraid_block* block) 710 : { - 711 12320606 : unsigned state = block_state_get(block); + 711 12320585 : unsigned state = block_state_get(block); 712 : - 713 12320606 : return state == BLOCK_STATE_DELETED - 714 12320606 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; + 713 12320585 : return state == BLOCK_STATE_DELETED + 714 12320585 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; 715 : } 716 : 717 : /** @@ -781,27 +781,27 @@ 719 : * 720 : * Note that anything different than BLK return 0. 721 : */ - 722 220959 : static inline int block_has_file_and_valid_parity(const struct snapraid_block* block) + 722 220962 : static inline int block_has_file_and_valid_parity(const struct snapraid_block* block) 723 : { - 724 220959 : unsigned state = block_state_get(block); + 724 220962 : unsigned state = block_state_get(block); 725 : - 726 220959 : return state == BLOCK_STATE_BLK; + 726 220962 : return state == BLOCK_STATE_BLK; 727 : } 728 : - 729 34094426 : static inline int file_flag_has(const struct snapraid_file* file, unsigned mask) + 729 34089332 : static inline int file_flag_has(const struct snapraid_file* file, unsigned mask) 730 : { - 731 34094426 : return (file->flag & mask) == mask; + 731 34089332 : return (file->flag & mask) == mask; 732 : } 733 : - 734 5301067 : static inline void file_flag_set(struct snapraid_file* file, unsigned mask) + 734 5295048 : static inline void file_flag_set(struct snapraid_file* file, unsigned mask) 735 : { - 736 5301067 : file->flag |= mask; - 737 5301067 : } + 736 5295048 : file->flag |= mask; + 737 5295048 : } 738 : - 739 16745 : static inline void file_flag_clear(struct snapraid_file* file, unsigned mask) + 739 11286 : static inline void file_flag_clear(struct snapraid_file* file, unsigned mask) 740 : { - 741 16745 : file->flag &= ~mask; - 742 16745 : } + 741 11286 : file->flag &= ~mask; + 742 11286 : } 743 : 744 : /** 745 : * Allocate a file. @@ -833,11 +833,11 @@ 771 : * 772 : * Note that the block size if a runtime value. 773 : */ - 774 54352792 : static inline struct snapraid_block* file_block(struct snapraid_file* file, size_t pos) + 774 54351316 : static inline struct snapraid_block* file_block(struct snapraid_file* file, size_t pos) 775 : { - 776 54352792 : unsigned char* ptr = (unsigned char*)file->blockvec; + 776 54351316 : unsigned char* ptr = (unsigned char*)file->blockvec; 777 : - 778 54352792 : return (struct snapraid_block*)(ptr + pos * block_sizeof()); + 778 54351316 : return (struct snapraid_block*)(ptr + pos * block_sizeof()); 779 : } 780 : 781 : /** @@ -879,9 +879,9 @@ 817 : /** 818 : * Compute the hash of a file inode. 819 : */ - 820 5047758 : static inline tommy_uint32_t file_inode_hash(uint64_t inode) + 820 5042449 : static inline tommy_uint32_t file_inode_hash(uint64_t inode) 821 : { - 822 5047758 : return (tommy_uint32_t)tommy_inthash_u64(inode); + 822 5042449 : return (tommy_uint32_t)tommy_inthash_u64(inode); 823 : } 824 : 825 : /** @@ -900,17 +900,17 @@ 838 : /** 839 : * Compute the hash of a file path. 840 : */ - 841 3885977 : static inline tommy_uint32_t file_path_hash(const char* sub) + 841 3886182 : static inline tommy_uint32_t file_path_hash(const char* sub) 842 : { - 843 3885977 : return tommy_hash_u32(0, sub, strlen(sub)); + 843 3886182 : return tommy_hash_u32(0, sub, strlen(sub)); 844 : } 845 : 846 : /** 847 : * Compute the hash of a file stamp. 848 : */ - 849 6275808 : static inline tommy_uint32_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec) + 849 6275421 : static inline tommy_uint32_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec) 850 : { - 851 6275808 : return tommy_inthash_u32((tommy_uint32_t)size ^ tommy_inthash_u32(mtime_sec ^ tommy_inthash_u32(mtime_nsec))); + 851 6275421 : return tommy_inthash_u32((tommy_uint32_t)size ^ tommy_inthash_u32(mtime_sec ^ tommy_inthash_u32(mtime_nsec))); 852 : } 853 : 854 : /** @@ -1088,19 +1088,19 @@ 1026 : /** 1027 : * Get the file position from the parity position. 1028 : */ - 1029 11723986 : static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) + 1029 11723835 : static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) 1030 : { 1031 : struct snapraid_file* ret; 1032 : - 1033 11723986 : ret = fs_par2file_find(disk, parity_pos, file_pos); - 1034 11724450 : if (ret == 0) { + 1033 11723835 : ret = fs_par2file_find(disk, parity_pos, file_pos); + 1034 11724079 : if (ret == 0) { 1035 : /* LCOV_EXCL_START */ 1036 : log_fatal("Internal inconsistency when deresolving parity to file at position '%u' in disk '%s'\n", parity_pos, disk->name); 1037 : os_abort(); 1038 : /* LCOV_EXCL_STOP */ 1039 : } 1040 : - 1041 11724450 : return ret; + 1041 11724079 : return ret; 1042 : } 1043 : 1044 : /** @@ -1112,19 +1112,19 @@ 1050 : /** 1051 : * Get the parity position from the file position. 1052 : */ - 1053 4755371 : static inline block_off_t fs_file2par_get(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) + 1053 4755492 : static inline block_off_t fs_file2par_get(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) 1054 : { 1055 : block_off_t ret; 1056 : - 1057 4755371 : ret = fs_file2par_find(disk, file, file_pos); - 1058 4755371 : if (ret == POS_NULL) { + 1057 4755492 : ret = fs_file2par_find(disk, file, file_pos); + 1058 4755492 : if (ret == POS_NULL) { 1059 : /* LCOV_EXCL_START */ 1060 : log_fatal("Internal inconsistency when resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name); 1061 : os_abort(); 1062 : /* LCOV_EXCL_STOP */ 1063 : } 1064 : - 1065 4755371 : return ret; + 1065 4755492 : return ret; 1066 : } 1067 : 1068 : /** @@ -1172,18 +1172,18 @@ 1110 : /** 1111 : * Make an info. 1112 : */ - 1113 194355 : static inline snapraid_info info_make(time_t last_access, int error, int rehash, int justsynced) + 1113 194583 : static inline snapraid_info info_make(time_t last_access, int error, int rehash, int justsynced) 1114 : { 1115 : /* clear the lowest bits as reserved for other information */ - 1116 194355 : snapraid_info info = last_access & ~INFO_MASK; + 1116 194583 : snapraid_info info = last_access & ~INFO_MASK; 1117 : - 1118 194355 : if (error != 0) - 1119 5306 : info |= 0x1; - 1120 194355 : if (rehash != 0) + 1118 194583 : if (error != 0) + 1119 5278 : info |= 0x1; + 1120 194583 : if (rehash != 0) 1121 14426 : info |= 0x2; - 1122 194355 : if (justsynced != 0) - 1123 142922 : info |= 0x4; - 1124 194355 : return info; + 1122 194583 : if (justsynced != 0) + 1123 143045 : info |= 0x4; + 1124 194583 : return info; 1125 : } 1126 : 1127 : /** @@ -1191,36 +1191,36 @@ 1129 : * This is the last time when the block was know to be correct. 1130 : * The "scrubbed" info tells if the time is referreing at the latest sync or scrub. 1131 : */ - 1132 883015 : static inline time_t info_get_time(snapraid_info info) + 1132 883203 : static inline time_t info_get_time(snapraid_info info) 1133 : { - 1134 883015 : return info & ~INFO_MASK; + 1134 883203 : return info & ~INFO_MASK; 1135 : } 1136 : 1137 : /** 1138 : * Extract the error information. 1139 : * Report if the block address had some problem. 1140 : */ - 1141 351958 : static inline int info_get_bad(snapraid_info info) + 1141 352076 : static inline int info_get_bad(snapraid_info info) 1142 : { - 1143 351958 : return (info & 0x1) != 0; + 1143 352076 : return (info & 0x1) != 0; 1144 : } 1145 : 1146 : /** 1147 : * Extract the rehash information. 1148 : * Report if the block address is using the old hash and needs to be rehashed. 1149 : */ - 1150 2046724 : static inline int info_get_rehash(snapraid_info info) + 1150 2046851 : static inline int info_get_rehash(snapraid_info info) 1151 : { - 1152 2046724 : return (info & 0x2) != 0; + 1152 2046851 : return (info & 0x2) != 0; 1153 : } 1154 : 1155 : /** 1156 : * Extract the scrubbed information. 1157 : * Report if the block address was never scrubbed. 1158 : */ - 1159 68446 : static inline int info_get_justsynced(snapraid_info info) + 1159 68634 : static inline int info_get_justsynced(snapraid_info info) 1160 : { - 1161 68446 : return (info & 0x4) != 0; + 1161 68634 : return (info & 0x4) != 0; 1162 : } 1163 : 1164 : /** @@ -1243,27 +1243,27 @@ 1181 : * Set the info at the specified position. 1182 : * The position is allocated if not yet done. 1183 : */ - 1184 1698098 : static inline void info_set(tommy_arrayblkof* array, block_off_t pos, snapraid_info info) + 1184 1698121 : static inline void info_set(tommy_arrayblkof* array, block_off_t pos, snapraid_info info) 1185 : { - 1186 1698098 : tommy_arrayblkof_grow(array, pos + 1); + 1186 1698121 : tommy_arrayblkof_grow(array, pos + 1); 1187 : - 1188 1698098 : memcpy(tommy_arrayblkof_ref(array, pos), &info, sizeof(snapraid_info)); - 1189 1698098 : } + 1188 1698121 : memcpy(tommy_arrayblkof_ref(array, pos), &info, sizeof(snapraid_info)); + 1189 1698121 : } 1190 : 1191 : /** 1192 : * Get the info at the specified position. 1193 : * For not allocated position, 0 is returned. 1194 : */ - 1195 5098627 : static inline snapraid_info info_get(tommy_arrayblkof* array, block_off_t pos) + 1195 5098669 : static inline snapraid_info info_get(tommy_arrayblkof* array, block_off_t pos) 1196 : { 1197 : snapraid_info info; 1198 : - 1199 5098627 : if (pos >= tommy_arrayblkof_size(array)) + 1199 5098669 : if (pos >= tommy_arrayblkof_size(array)) 1200 262643 : return 0; 1201 : - 1202 4835984 : memcpy(&info, tommy_arrayblkof_ref(array, pos), sizeof(snapraid_info)); + 1202 4836026 : memcpy(&info, tommy_arrayblkof_ref(array, pos), sizeof(snapraid_info)); 1203 : - 1204 4835984 : return info; + 1204 4836026 : return info; 1205 : } 1206 : 1207 : /** diff --git a/cov/cmdline/handle.c.func-sort-c.html b/cov/cmdline/handle.c.func-sort-c.html index ef921dc5..3014505f 100644 --- a/cov/cmdline/handle.c.func-sort-c.html +++ b/cov/cmdline/handle.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 @@ -61,31 +61,31 @@ handle_read - 5856319 + 5856126 handle_close - 4647370 + 4647204 handle_open - 2186388 + 2185997 handle_create - 771305 + 771283 handle_write - 288483 + 288377 handle_utime - 119471 + 119405 handle_truncate - 3180 + 3254 handle_mapping diff --git a/cov/cmdline/handle.c.func.html b/cov/cmdline/handle.c.func.html index f947889d..75b05487 100644 --- a/cov/cmdline/handle.c.func.html +++ b/cov/cmdline/handle.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 @@ -61,11 +61,11 @@ handle_close - 4647370 + 4647204 handle_create - 771305 + 771283 handle_mapping @@ -73,23 +73,23 @@ handle_open - 2186388 + 2185997 handle_read - 5856319 + 5856126 handle_truncate - 3180 + 3254 handle_utime - 119471 + 119405 handle_write - 288483 + 288377
diff --git a/cov/cmdline/handle.c.gcov.html b/cov/cmdline/handle.c.gcov.html index cbb1c184..3d2ab90a 100644 --- a/cov/cmdline/handle.c.gcov.html +++ b/cov/cmdline/handle.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 @@ -86,64 +86,64 @@ 24 : /****************************************************************************/ 25 : /* handle */ 26 : - 27 771305 : int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, int mode) + 27 771283 : int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, int mode) 28 : { 29 : int ret; 30 : int flags; 31 : 32 : /* if it's the same file, and already opened, nothing to do */ - 33 771305 : if (handle->file == file && handle->f != -1) { + 33 771283 : if (handle->file == file && handle->f != -1) { 34 0 : return 0; 35 : } 36 : - 37 771305 : advise_init(&handle->advise, mode); - 38 771305 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); + 37 771283 : advise_init(&handle->advise, mode); + 38 771283 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); 39 : - 40 771305 : ret = mkancestor(handle->path); - 41 771305 : if (ret != 0) { + 40 771283 : ret = mkancestor(handle->path); + 41 771283 : if (ret != 0) { 42 : /* LCOV_EXCL_START */ 43 : return -1; 44 : /* LCOV_EXCL_STOP */ 45 : } 46 : 47 : /* initial values, changed later if required */ - 48 771305 : handle->created = 0; + 48 771283 : handle->created = 0; 49 : 50 : /* flags for opening */ 51 : /* O_BINARY: open as binary file (Windows only) */ 52 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ - 53 771305 : flags = O_BINARY | O_NOFOLLOW | advise_flags(&handle->advise); + 53 771283 : flags = O_BINARY | O_NOFOLLOW | advise_flags(&handle->advise); 54 : 55 : /* open for read write */ - 56 771305 : handle->f = open(handle->path, flags | O_RDWR); + 56 771283 : handle->f = open(handle->path, flags | O_RDWR); 57 : 58 : /* if failed for missing write permission */ - 59 771305 : if (handle->f == -1 && (errno == EACCES || errno == EROFS)) { + 59 771283 : if (handle->f == -1 && (errno == EACCES || errno == EROFS)) { 60 : /* open for real-only */ 61 0 : handle->f = open(handle->path, flags | O_RDONLY); 62 : } 63 : 64 : /* if failed for missing file */ - 65 771305 : if (handle->f == -1 && errno == ENOENT) { + 65 771283 : if (handle->f == -1 && errno == ENOENT) { 66 : char path_from[PATH_MAX]; 67 : 68 : /* check if exists a .unrecoverable copy, and rename to the real one */ - 69 176353 : pathprint(path_from, sizeof(path_from), "%s.unrecoverable", handle->path); + 69 176318 : pathprint(path_from, sizeof(path_from), "%s.unrecoverable", handle->path); 70 : - 71 176353 : if (rename(path_from, handle->path) == 0) { + 71 176318 : if (rename(path_from, handle->path) == 0) { 72 : /* open for read write */ - 73 63286 : handle->f = open(handle->path, flags | O_RDWR); + 73 63274 : handle->f = open(handle->path, flags | O_RDWR); 74 : } else { 75 : /* create it */ - 76 113067 : handle->f = open(handle->path, flags | O_RDWR | O_CREAT, 0600); - 77 113067 : if (handle->f != -1) { + 76 113044 : handle->f = open(handle->path, flags | O_RDWR | O_CREAT, 0600); + 77 113044 : if (handle->f != -1) { 78 : /* mark it as created if really done */ - 79 113067 : handle->created = 1; + 79 113044 : handle->created = 1; 80 : } 81 : } 82 : } 83 : - 84 771305 : if (handle->f == -1) { + 84 771283 : if (handle->f == -1) { 85 : /* LCOV_EXCL_START */ 86 : /* invalidate for error */ 87 : handle->file = 0; @@ -156,11 +156,11 @@ 94 : } 95 : 96 : /* just opened */ - 97 771305 : handle->file = file; + 97 771283 : handle->file = file; 98 : 99 : /* get the stat info */ - 100 771305 : ret = fstat(handle->f, &handle->st); - 101 771305 : if (ret != 0) { + 100 771283 : ret = fstat(handle->f, &handle->st); + 101 771283 : if (ret != 0) { 102 : /* LCOV_EXCL_START */ 103 : log_fatal("Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); 104 : return -1; @@ -168,25 +168,25 @@ 106 : } 107 : 108 : /* get the size of the existing data */ - 109 771305 : handle->valid_size = handle->st.st_size; + 109 771283 : handle->valid_size = handle->st.st_size; 110 : - 111 771305 : ret = advise_open(&handle->advise, handle->f); - 112 771305 : if (ret != 0) { + 111 771283 : ret = advise_open(&handle->advise, handle->f); + 112 771283 : if (ret != 0) { 113 : /* LCOV_EXCL_START */ 114 : log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(errno)); 115 : return -1; 116 : /* LCOV_EXCL_STOP */ 117 : } 118 : - 119 771305 : return 0; + 119 771283 : return 0; 120 : } 121 : - 122 3180 : int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file) + 122 3254 : int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file) 123 : { 124 : int ret; 125 : - 126 3180 : ret = ftruncate(handle->f, file->size); - 127 3180 : if (ret != 0) { + 126 3254 : ret = ftruncate(handle->f, file->size); + 127 3254 : if (ret != 0) { 128 : /* LCOV_EXCL_START */ 129 : if (errno == EACCES) { 130 : log_fatal("Failed to truncate file '%s' for missing write permission.\n", handle->path); @@ -198,56 +198,56 @@ 136 : } 137 : 138 : /* adjust the size to the truncated size */ - 139 3180 : handle->valid_size = file->size; + 139 3254 : handle->valid_size = file->size; 140 : - 141 3180 : return 0; + 141 3254 : return 0; 142 : } 143 : - 144 2186388 : int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing) + 144 2185997 : int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing) 145 : { 146 : int ret; 147 : int flags; 148 : - 149 2186388 : if (!out_missing) - 150 2185969 : out_missing = out; + 149 2185997 : if (!out_missing) + 150 2185561 : out_missing = out; 151 : 152 : /* if already opened, nothing to do */ - 153 2186388 : if (handle->file == file && handle->file != 0 && handle->f != -1) { - 154 468756 : return 0; + 153 2185997 : if (handle->file == file && handle->file != 0 && handle->f != -1) { + 154 468413 : return 0; 155 : } 156 : - 157 1717632 : advise_init(&handle->advise, mode); - 158 1717806 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); + 157 1717584 : advise_init(&handle->advise, mode); + 158 1717759 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); 159 : 160 : /* for sure not created */ - 161 1717916 : handle->created = 0; + 161 1717867 : handle->created = 0; 162 : 163 : /* flags for opening */ 164 : /* O_BINARY: open as binary file (Windows only) */ 165 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ - 166 1717916 : flags = O_BINARY | O_NOFOLLOW | advise_flags(&handle->advise); + 166 1717867 : flags = O_BINARY | O_NOFOLLOW | advise_flags(&handle->advise); 167 : 168 : /* open for read */ - 169 1717861 : handle->f = open_noatime(handle->path, flags | O_RDONLY); - 170 1717874 : if (handle->f == -1) { + 169 1717825 : handle->f = open_noatime(handle->path, flags | O_RDONLY); + 170 1717829 : if (handle->f == -1) { 171 : /* invalidate for error */ - 172 78666 : handle->file = 0; - 173 78666 : handle->f = -1; - 174 78666 : handle->valid_size = 0; + 172 78600 : handle->file = 0; + 173 78600 : handle->f = -1; + 174 78600 : handle->valid_size = 0; 175 : - 176 78666 : if (errno == ENOENT) - 177 78654 : out_missing("Missing file '%s'.\n", handle->path); + 176 78600 : if (errno == ENOENT) + 177 78588 : out_missing("Missing file '%s'.\n", handle->path); 178 : else 179 12 : out("Error opening file '%s'. %s.\n", handle->path, strerror(errno)); - 180 78666 : return -1; + 180 78600 : return -1; 181 : } 182 : 183 : /* just opened */ - 184 1639208 : handle->file = file; + 184 1639229 : handle->file = file; 185 : 186 : /* get the stat info */ - 187 1639208 : ret = fstat(handle->f, &handle->st); - 188 1639257 : if (ret != 0) { + 187 1639229 : ret = fstat(handle->f, &handle->st); + 188 1639236 : if (ret != 0) { 189 : /* LCOV_EXCL_START */ 190 : out("Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); 191 : return -1; @@ -255,27 +255,27 @@ 193 : } 194 : 195 : /* get the size of the existing data */ - 196 1639257 : handle->valid_size = handle->st.st_size; + 196 1639236 : handle->valid_size = handle->st.st_size; 197 : - 198 1639257 : ret = advise_open(&handle->advise, handle->f); - 199 1639264 : if (ret != 0) { + 198 1639236 : ret = advise_open(&handle->advise, handle->f); + 199 1639253 : if (ret != 0) { 200 : /* LCOV_EXCL_START */ 201 : out("Error advising file '%s'. %s.\n", handle->path, strerror(errno)); 202 : return -1; 203 : /* LCOV_EXCL_STOP */ 204 : } 205 : - 206 1639264 : return 0; + 206 1639253 : return 0; 207 : } 208 : - 209 4647370 : int handle_close(struct snapraid_handle* handle) + 209 4647204 : int handle_close(struct snapraid_handle* handle) 210 : { 211 : int ret; 212 : 213 : /* close if open */ - 214 4647370 : if (handle->f != -1) { + 214 4647204 : if (handle->f != -1) { 215 2410548 : ret = close(handle->f); - 216 2410591 : if (ret != 0) { + 216 2410577 : if (ret != 0) { 217 : /* LCOV_EXCL_START */ 218 : log_fatal("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno)); 219 : @@ -289,14 +289,14 @@ 227 : } 228 : 229 : /* reset the descriptor */ - 230 4647413 : handle->file = 0; - 231 4647413 : handle->f = -1; - 232 4647413 : handle->valid_size = 0; + 230 4647233 : handle->file = 0; + 231 4647233 : handle->f = -1; + 232 4647233 : handle->valid_size = 0; 233 : - 234 4647413 : return 0; + 234 4647233 : return 0; 235 : } 236 : - 237 5856319 : int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing) + 237 5856126 : int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing) 238 : { 239 : ssize_t read_ret; 240 : data_off_t offset; @@ -304,70 +304,70 @@ 242 : unsigned count; 243 : int ret; 244 : - 245 5856319 : offset = file_pos * (data_off_t)block_size; + 245 5856126 : offset = file_pos * (data_off_t)block_size; 246 : - 247 5856319 : if (!out_missing) - 248 5843379 : out_missing = out; + 247 5856126 : if (!out_missing) + 248 5843207 : out_missing = out; 249 : 250 : /* check if we are going to read only not initialized data */ - 251 5856319 : if (offset >= handle->valid_size) { + 251 5856126 : if (offset >= handle->valid_size) { 252 : /* if the file is missing, it's at 0 size, or it's rebuilt while reading */ - 253 433352 : if (offset == handle->valid_size || handle->valid_size == 0) - 254 431991 : out_missing("Reading data from missing file '%s' at offset %" PRIu64 ".\n", handle->path, offset); + 253 433247 : if (offset == handle->valid_size || handle->valid_size == 0) + 254 431947 : out_missing("Reading data from missing file '%s' at offset %" PRIu64 ".\n", handle->path, offset); 255 : else - 256 1361 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset); - 257 433352 : return -1; + 256 1300 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset); + 257 433247 : return -1; 258 : } 259 : - 260 5422967 : read_size = file_block_size(handle->file, file_pos, block_size); + 260 5422879 : read_size = file_block_size(handle->file, file_pos, block_size); 261 : - 262 5422979 : count = 0; + 262 5422871 : count = 0; 263 : do { 264 : /* read the full block to support O_DIRECT */ - 265 5431676 : read_ret = pread(handle->f, block_buffer + count, block_size - count, offset + count); - 266 5431334 : if (read_ret < 0) { + 265 5431700 : read_ret = pread(handle->f, block_buffer + count, block_size - count, offset + count); + 266 5431360 : if (read_ret < 0) { 267 : /* LCOV_EXCL_START */ 268 : out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, block_size - count, strerror(errno)); 269 : return -1; 270 : /* LCOV_EXCL_STOP */ 271 : } - 272 5431334 : if (read_ret == 0) { - 273 8919 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno)); - 274 8919 : return -1; + 272 5431360 : if (read_ret == 0) { + 273 8879 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno)); + 274 8879 : return -1; 275 : } 276 : - 277 5422415 : count += read_ret; - 278 5422415 : } while (count < read_size); + 277 5422481 : count += read_ret; + 278 5422481 : } while (count < read_size); 279 : 280 : /* pad with 0 */ - 281 5413718 : if (read_size < block_size) { - 282 2188617 : memset(block_buffer + read_size, 0, block_size - read_size); + 281 5413652 : if (read_size < block_size) { + 282 2188671 : memset(block_buffer + read_size, 0, block_size - read_size); 283 : } 284 : - 285 5413718 : ret = advise_read(&handle->advise, handle->f, offset, block_size); - 286 5413674 : if (ret != 0) { + 285 5413652 : ret = advise_read(&handle->advise, handle->f, offset, block_size); + 286 5413607 : if (ret != 0) { 287 : /* LCOV_EXCL_START */ 288 : out("Error advising file '%s'. %s.\n", handle->path, strerror(errno)); 289 : return -1; 290 : /* LCOV_EXCL_STOP */ 291 : } 292 : - 293 5413674 : return read_size; + 293 5413607 : return read_size; 294 : } 295 : - 296 288483 : int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size) + 296 288377 : int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size) 297 : { 298 : ssize_t write_ret; 299 : data_off_t offset; 300 : unsigned write_size; 301 : int ret; 302 : - 303 288483 : offset = file_pos * (data_off_t)block_size; + 303 288377 : offset = file_pos * (data_off_t)block_size; 304 : - 305 288483 : write_size = file_block_size(handle->file, file_pos, block_size); + 305 288377 : write_size = file_block_size(handle->file, file_pos, block_size); 306 : - 307 288483 : write_ret = pwrite(handle->f, block_buffer, write_size, offset); - 308 288483 : if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */ + 307 288377 : write_ret = pwrite(handle->f, block_buffer, write_size, offset); + 308 288377 : if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */ 309 : /* LCOV_EXCL_START */ 310 : log_fatal("Error writing file '%s'. %s.\n", handle->path, strerror(errno)); 311 : return -1; @@ -375,39 +375,39 @@ 313 : } 314 : 315 : /* adjust the size of the valid data */ - 316 288483 : if (handle->valid_size < offset + write_size) { - 317 282399 : handle->valid_size = offset + write_size; + 316 288377 : if (handle->valid_size < offset + write_size) { + 317 282355 : handle->valid_size = offset + write_size; 318 : } 319 : - 320 288483 : ret = advise_write(&handle->advise, handle->f, offset, block_size); - 321 288483 : if (ret != 0) { + 320 288377 : ret = advise_write(&handle->advise, handle->f, offset, block_size); + 321 288377 : if (ret != 0) { 322 : /* LCOV_EXCL_START */ 323 : log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(errno)); 324 : return -1; 325 : /* LCOV_EXCL_STOP */ 326 : } 327 : - 328 288483 : return 0; + 328 288377 : return 0; 329 : } 330 : - 331 119471 : int handle_utime(struct snapraid_handle* handle) + 331 119405 : int handle_utime(struct snapraid_handle* handle) 332 : { 333 : int ret; 334 : 335 : /* do nothing if not opened */ - 336 119471 : if (handle->f == -1) + 336 119405 : if (handle->f == -1) 337 0 : return 0; 338 : - 339 119471 : ret = fmtime(handle->f, handle->file->mtime_sec, handle->file->mtime_nsec); + 339 119405 : ret = fmtime(handle->f, handle->file->mtime_sec, handle->file->mtime_nsec); 340 : - 341 119471 : if (ret != 0) { + 341 119405 : if (ret != 0) { 342 : /* LCOV_EXCL_START */ 343 : log_fatal("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno)); 344 : return -1; 345 : /* LCOV_EXCL_STOP */ 346 : } 347 : - 348 119471 : return 0; + 348 119405 : return 0; 349 : } 350 : 351 221 : struct snapraid_handle* handle_mapping(struct snapraid_state* state, unsigned* handlemax) diff --git a/cov/cmdline/import.c.func-sort-c.html b/cov/cmdline/import.c.func-sort-c.html index 6b8d8469..458a15a3 100644 --- a/cov/cmdline/import.c.func-sort-c.html +++ b/cov/cmdline/import.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -61,11 +61,11 @@ import_block_hash - 656904 + 656604 state_import_fetch - 652432 + 652132 import_block_hash_compare diff --git a/cov/cmdline/import.c.func.html b/cov/cmdline/import.c.func.html index 3c94845a..384ffe57 100644 --- a/cov/cmdline/import.c.func.html +++ b/cov/cmdline/import.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -61,7 +61,7 @@ import_block_hash - 656904 + 656604 import_block_hash_compare @@ -89,7 +89,7 @@ state_import_fetch - 652432 + 652132
diff --git a/cov/cmdline/import.c.gcov.html b/cov/cmdline/import.c.gcov.html index 2c5e2abe..307cb412 100644 --- a/cov/cmdline/import.c.gcov.html +++ b/cov/cmdline/import.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -108,10 +108,10 @@ 46 : * Compute the hash of the hash for an import block. 47 : * We just use the first 32 bit of the hash itself. 48 : */ - 49 656904 : static inline tommy_uint32_t import_block_hash(const unsigned char* hash) + 49 656604 : static inline tommy_uint32_t import_block_hash(const unsigned char* hash) 50 : { 51 : /* the hash data is not aligned, and we cannot access it with a direct cast */ - 52 656904 : return hash[0] | ((uint32_t)hash[1] << 8) | ((uint32_t)hash[2] << 16) | ((uint32_t)hash[3] << 24); + 52 656604 : return hash[0] | ((uint32_t)hash[1] << 8) | ((uint32_t)hash[2] << 16) | ((uint32_t)hash[3] << 24); 53 : } 54 : 55 1750 : static void import_file(struct snapraid_state* state, const char* path, uint64_t size) @@ -207,24 +207,24 @@ 145 1750 : free(file); 146 1750 : } 147 : - 148 652432 : int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid_block* missing_block, unsigned char* buffer) + 148 652132 : int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid_block* missing_block, unsigned char* buffer) 149 : { 150 : struct snapraid_import_block* block; 151 : int ret; 152 : int f; - 153 652432 : const unsigned char* hash = missing_block->hash; - 154 652432 : unsigned block_size = state->block_size; + 153 652132 : const unsigned char* hash = missing_block->hash; + 154 652132 : unsigned block_size = state->block_size; 155 : unsigned read_size; 156 : unsigned char buffer_hash[HASH_MAX]; 157 : const char* path; 158 : - 159 652432 : if (rehash) { + 159 652132 : if (rehash) { 160 0 : block = tommy_hashdyn_search(&state->previmportset, import_block_prevhash_compare, hash, import_block_hash(hash)); 161 : } else { - 162 652432 : block = tommy_hashdyn_search(&state->importset, import_block_hash_compare, hash, import_block_hash(hash)); + 162 652132 : block = tommy_hashdyn_search(&state->importset, import_block_hash_compare, hash, import_block_hash(hash)); 163 : } - 164 652432 : if (!block) - 165 647960 : return -1; + 164 652132 : if (!block) + 165 647660 : return -1; 166 : 167 4472 : path = block->file->path; 168 4472 : read_size = block->size; diff --git a/cov/cmdline/index-sort-f.html b/cov/cmdline/index-sort-f.html index 41e4f2ef..90111741 100644 --- a/cov/cmdline/index-sort-f.html +++ b/cov/cmdline/index-sort-f.html @@ -31,18 +31,18 @@ lcov.info Lines: - 8613 - 9548 - 90.2 % + 8683 + 9562 + 90.8 % Date: - 2016-11-06 + 2016-11-21 Functions: - 482 - 499 - 96.6 % + 488 + 503 + 97.0 % @@ -69,16 +69,6 @@ Line Coverage Sort by line coverage Functions Sort by function coverage - - unix.c - -
71.5%71.5%
- - 71.5 % - 316 / 442 - 87.1 % - 27 / 31 - import.c @@ -90,12 +80,12 @@ 7 / 8 - io.c + unix.c -
92.6%92.6%
+
72.4%72.4%
- 92.6 % - 386 / 417 + 72.4 % + 320 / 442 90.3 % 28 / 31 @@ -110,14 +100,14 @@ 10 / 11 - util.c + io.c -
92.7%92.7%
+
97.6%97.6%
- 92.7 % - 76 / 82 - 94.1 % - 16 / 17 + 97.6 % + 407 / 417 + 93.5 % + 29 / 31 parity.c @@ -129,6 +119,16 @@ 94.7 % 18 / 19 + + util.c + +
93.6%93.6%
+ + 93.6 % + 88 / 94 + 95.2 % + 20 / 21 + stream.c @@ -162,10 +162,10 @@ state.c -
89.9%89.9%
+
91.7%91.7%
- 89.9 % - 1449 / 1612 + 91.7 % + 1478 / 1612 97.8 % 45 / 46 @@ -272,10 +272,10 @@ status.c -
94.0%94.0%
+
95.4%95.4%
- 94.0 % - 266 / 283 + 95.4 % + 270 / 283 100.0 % 3 / 3 @@ -332,10 +332,10 @@ sync.c -
91.9%91.9%
+
91.8%91.8%
- 91.9 % - 502 / 546 + 91.8 % + 501 / 546 100.0 % 7 / 7 @@ -382,10 +382,10 @@ snapraid.c -
91.5%91.5%
+
91.4%91.4%
- 91.5 % - 496 / 542 + 91.4 % + 497 / 544 100.0 % 9 / 9 diff --git a/cov/cmdline/index-sort-l.html b/cov/cmdline/index-sort-l.html index d6502fac..7f0baa1d 100644 --- a/cov/cmdline/index-sort-l.html +++ b/cov/cmdline/index-sort-l.html @@ -31,18 +31,18 @@ lcov.info Lines: - 8613 - 9548 - 90.2 % + 8683 + 9562 + 90.8 % Date: - 2016-11-06 + 2016-11-21 Functions: - 482 - 499 - 96.6 % + 488 + 503 + 97.0 % @@ -72,12 +72,12 @@ unix.c -
71.5%71.5%
+
72.4%72.4%
- 71.5 % - 316 / 442 - 87.1 % - 27 / 31 + 72.4 % + 320 / 442 + 90.3 % + 28 / 31 dry.c @@ -119,16 +119,6 @@ 100.0 % 23 / 23 - - state.c - -
89.9%89.9%
- - 89.9 % - 1449 / 1612 - 97.8 % - 45 / 46 - stream.h @@ -169,6 +159,16 @@ 100.0 % 7 / 7 + + snapraid.c + +
91.4%91.4%
+ + 91.4 % + 497 / 544 + 100.0 % + 9 / 9 + check.c @@ -180,14 +180,24 @@ 9 / 9 - snapraid.c + state.c -
91.5%91.5%
+
91.7%91.7%
- 91.5 % - 496 / 542 + 91.7 % + 1478 / 1612 + 97.8 % + 45 / 46 + + + sync.c + +
91.8%91.8%
+ + 91.8 % + 501 / 546 100.0 % - 9 / 9 + 7 / 7 parity.c @@ -199,36 +209,6 @@ 94.7 % 18 / 19 - - sync.c - -
91.9%91.9%
- - 91.9 % - 502 / 546 - 100.0 % - 7 / 7 - - - io.c - -
92.6%92.6%
- - 92.6 % - 386 / 417 - 90.3 % - 28 / 31 - - - util.c - -
92.7%92.7%
- - 92.7 % - 76 / 82 - 94.1 % - 16 / 17 - mktest.c @@ -260,14 +240,14 @@ 5 / 5 - status.c + util.c -
94.0%94.0%
+
93.6%93.6%
- 94.0 % - 266 / 283 - 100.0 % - 3 / 3 + 93.6 % + 88 / 94 + 95.2 % + 20 / 21 pool.c @@ -309,6 +289,16 @@ 100.0 % 1 / 1 + + status.c + +
95.4%95.4%
+ + 95.4 % + 270 / 283 + 100.0 % + 3 / 3 + list.c @@ -339,6 +329,16 @@ 100.0 % 8 / 8 + + io.c + +
97.6%97.6%
+ + 97.6 % + 407 / 417 + 93.5 % + 29 / 31 + speed.c diff --git a/cov/cmdline/index.html b/cov/cmdline/index.html index b4260d2c..4531671e 100644 --- a/cov/cmdline/index.html +++ b/cov/cmdline/index.html @@ -31,18 +31,18 @@ lcov.info Lines: - 8613 - 9548 - 90.2 % + 8683 + 9562 + 90.8 % Date: - 2016-11-06 + 2016-11-21 Functions: - 482 - 499 - 96.6 % + 488 + 503 + 97.0 % @@ -152,12 +152,12 @@ io.c -
92.6%92.6%
+
97.6%97.6%
- 92.6 % - 386 / 417 - 90.3 % - 28 / 31 + 97.6 % + 407 / 417 + 93.5 % + 29 / 31 list.c @@ -282,10 +282,10 @@ snapraid.c -
91.5%91.5%
+
91.4%91.4%
- 91.5 % - 496 / 542 + 91.4 % + 497 / 544 100.0 % 9 / 9 @@ -312,20 +312,20 @@ state.c -
89.9%89.9%
+
91.7%91.7%
- 89.9 % - 1449 / 1612 + 91.7 % + 1478 / 1612 97.8 % 45 / 46 status.c -
94.0%94.0%
+
95.4%95.4%
- 94.0 % - 266 / 283 + 95.4 % + 270 / 283 100.0 % 3 / 3 @@ -372,10 +372,10 @@ sync.c -
91.9%91.9%
+
91.8%91.8%
- 91.9 % - 502 / 546 + 91.8 % + 501 / 546 100.0 % 7 / 7 @@ -392,22 +392,22 @@ unix.c -
71.5%71.5%
+
72.4%72.4%
- 71.5 % - 316 / 442 - 87.1 % - 27 / 31 + 72.4 % + 320 / 442 + 90.3 % + 28 / 31 util.c -
92.7%92.7%
+
93.6%93.6%
- 92.7 % - 76 / 82 - 94.1 % - 16 / 17 + 93.6 % + 88 / 94 + 95.2 % + 20 / 21 util.h diff --git a/cov/cmdline/io.c.func-sort-c.html b/cov/cmdline/io.c.func-sort-c.html index dde735d8..c7526147 100644 --- a/cov/cmdline/io.c.func-sort-c.html +++ b/cov/cmdline/io.c.func-sort-c.html @@ -31,18 +31,18 @@ lcov.info Lines: - 386 + 407 417 - 92.6 % + 97.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 28 + 29 31 - 90.3 % + 93.5 % @@ -61,27 +61,27 @@ io_reader_step - 1163270 + 1162708 io_task_read_thread - 1082226 + 1081860 io_reader_worker - 1082209 + 1081809 io_data_read_thread - 871422 + 871056 io_writer_step - 554398 + 554042 io_parity_write_thread - 553948 + 553582 io_parity_read_thread @@ -89,27 +89,27 @@ io_position_next - 162085 + 162024 io_reader_sched - 162085 + 162024 io_read_next_thread - 145332 + 145271 io_writer_sched - 112474 + 112438 io_write_preset_thread - 110103 + 110042 io_write_next_thread - 110103 + 110042 io_task_read_mono @@ -137,7 +137,7 @@ io_writer_sched_empty - 2316 + 2291 io_reader_thread @@ -163,6 +163,10 @@ io_stop_thread 95 + + io_refresh_thread + 1 + io_start_mono 1 @@ -175,10 +179,6 @@ io_refresh_mono 0 - - io_refresh_thread - 0 - io_parity_read_mono 0 diff --git a/cov/cmdline/io.c.func.html b/cov/cmdline/io.c.func.html index 75b86177..87d56824 100644 --- a/cov/cmdline/io.c.func.html +++ b/cov/cmdline/io.c.func.html @@ -31,18 +31,18 @@ lcov.info Lines: - 386 + 407 417 - 92.6 % + 97.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 28 + 29 31 - 90.3 % + 93.5 % @@ -65,7 +65,7 @@ io_data_read_thread - 871422 + 871056 io_done @@ -89,11 +89,11 @@ io_parity_write_thread - 553948 + 553582 io_position_next - 162085 + 162024 io_read_next_mono @@ -101,15 +101,15 @@ io_read_next_thread - 145332 + 145271 io_reader_sched - 162085 + 162024 io_reader_step - 1163270 + 1162708 io_reader_thread @@ -117,7 +117,7 @@ io_reader_worker - 1082209 + 1081809 io_refresh_mono @@ -125,7 +125,7 @@ io_refresh_thread - 0 + 1 io_start_mono @@ -149,7 +149,7 @@ io_task_read_thread - 1082226 + 1081860 io_write_next_mono @@ -157,7 +157,7 @@ io_write_next_thread - 110103 + 110042 io_write_preset_mono @@ -165,19 +165,19 @@ io_write_preset_thread - 110103 + 110042 io_writer_sched - 112474 + 112438 io_writer_sched_empty - 2316 + 2291 io_writer_step - 554398 + 554042 io_writer_thread diff --git a/cov/cmdline/io.c.gcov.html b/cov/cmdline/io.c.gcov.html index 295b5f22..c7a9d8f2 100644 --- a/cov/cmdline/io.c.gcov.html +++ b/cov/cmdline/io.c.gcov.html @@ -31,18 +31,18 @@ lcov.info Lines: - 386 + 407 417 - 92.6 % + 97.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 28 + 29 31 - 90.3 % + 93.5 % @@ -84,103 +84,103 @@ 22 : /** 23 : * Get the next block position to process. 24 : */ - 25 162085 : static block_off_t io_position_next(struct snapraid_io* io) + 25 162024 : static block_off_t io_position_next(struct snapraid_io* io) 26 : { 27 : block_off_t blockcur; 28 : 29 : /* get the next position */ - 30 647518 : while (io->block_next < io->block_max && !io->block_is_enabled(io->block_arg, io->block_next)) - 31 323348 : ++io->block_next; + 30 647457 : while (io->block_next < io->block_max && !io->block_is_enabled(io->block_arg, io->block_next)) + 31 323409 : ++io->block_next; 32 : - 33 162085 : blockcur = io->block_next; + 33 162024 : blockcur = io->block_next; 34 : 35 : /* next block for the next call */ - 36 162085 : ++io->block_next; + 36 162024 : ++io->block_next; 37 : - 38 162085 : return blockcur; + 38 162024 : return blockcur; 39 : } 40 : 41 : /** 42 : * Setup the next pending task for all readers. 43 : */ - 44 162085 : static void io_reader_sched(struct snapraid_io* io, int task_index, block_off_t blockcur) + 44 162024 : static void io_reader_sched(struct snapraid_io* io, int task_index, block_off_t blockcur) 45 : { 46 : unsigned i; 47 : - 48 1355383 : for (i = 0; i < io->reader_max; ++i) { - 49 1193298 : struct snapraid_worker* worker = &io->reader_map[i]; - 50 1193298 : struct snapraid_task* task = &worker->task_map[task_index]; + 48 1354956 : for (i = 0; i < io->reader_max; ++i) { + 49 1192932 : struct snapraid_worker* worker = &io->reader_map[i]; + 50 1192932 : struct snapraid_task* task = &worker->task_map[task_index]; 51 : 52 : /* setup the new pending task */ - 53 1193298 : if (blockcur < io->block_max) - 54 1110348 : task->state = TASK_STATE_READY; + 53 1192932 : if (blockcur < io->block_max) + 54 1109982 : task->state = TASK_STATE_READY; 55 : else 56 82950 : task->state = TASK_STATE_EMPTY; 57 : - 58 1193298 : task->path[0] = 0; - 59 1193298 : if (worker->handle) - 60 972510 : task->disk = worker->handle->disk; + 58 1192932 : task->path[0] = 0; + 59 1192932 : if (worker->handle) + 60 972144 : task->disk = worker->handle->disk; 61 : else 62 220788 : task->disk = 0; - 63 1193298 : task->buffer = io->buffer_map[task_index][worker->buffer_skew + i]; - 64 1193298 : task->position = blockcur; - 65 1193298 : task->block = 0; - 66 1193298 : task->file = 0; - 67 1193298 : task->file_pos = 0; - 68 1193298 : task->read_size = 0; - 69 1193298 : task->is_timestamp_different = 0; + 63 1192932 : task->buffer = io->buffer_map[task_index][worker->buffer_skew + i]; + 64 1192932 : task->position = blockcur; + 65 1192932 : task->block = 0; + 66 1192932 : task->file = 0; + 67 1192932 : task->file_pos = 0; + 68 1192932 : task->read_size = 0; + 69 1192932 : task->is_timestamp_different = 0; 70 : } - 71 162085 : } + 71 162024 : } 72 : 73 : /** 74 : * Setup the next pending task for all writers. 75 : */ - 76 112474 : static void io_writer_sched(struct snapraid_io* io, int task_index, block_off_t blockcur) + 76 112438 : static void io_writer_sched(struct snapraid_io* io, int task_index, block_off_t blockcur) 77 : { 78 : unsigned i; 79 : - 80 657213 : for (i = 0; i < io->writer_max; ++i) { - 81 544739 : struct snapraid_worker* worker = &io->writer_map[i]; - 82 544739 : struct snapraid_task* task = &worker->task_map[task_index]; + 80 656961 : for (i = 0; i < io->writer_max; ++i) { + 81 544523 : struct snapraid_worker* worker = &io->writer_map[i]; + 82 544523 : struct snapraid_task* task = &worker->task_map[task_index]; 83 : 84 : /* setup the new pending task */ - 85 544739 : task->state = TASK_STATE_READY; - 86 544739 : task->path[0] = 0; - 87 544739 : task->disk = 0; - 88 544739 : task->buffer = io->buffer_map[task_index][worker->buffer_skew + i]; - 89 544739 : task->position = blockcur; - 90 544739 : task->block = 0; - 91 544739 : task->file = 0; - 92 544739 : task->file_pos = 0; - 93 544739 : task->read_size = 0; - 94 544739 : task->is_timestamp_different = 0; + 85 544523 : task->state = TASK_STATE_READY; + 86 544523 : task->path[0] = 0; + 87 544523 : task->disk = 0; + 88 544523 : task->buffer = io->buffer_map[task_index][worker->buffer_skew + i]; + 89 544523 : task->position = blockcur; + 90 544523 : task->block = 0; + 91 544523 : task->file = 0; + 92 544523 : task->file_pos = 0; + 93 544523 : task->read_size = 0; + 94 544523 : task->is_timestamp_different = 0; 95 : } - 96 112474 : } + 96 112438 : } 97 : 98 : /** 99 : * Setup an empty next pending task for all writers. 100 : */ - 101 2316 : static void io_writer_sched_empty(struct snapraid_io* io, int task_index, block_off_t blockcur) + 101 2291 : static void io_writer_sched_empty(struct snapraid_io* io, int task_index, block_off_t blockcur) 102 : { 103 : unsigned i; 104 : - 105 16212 : for (i = 0; i < io->writer_max; ++i) { - 106 13896 : struct snapraid_worker* worker = &io->writer_map[i]; - 107 13896 : struct snapraid_task* task = &worker->task_map[task_index]; + 105 16037 : for (i = 0; i < io->writer_max; ++i) { + 106 13746 : struct snapraid_worker* worker = &io->writer_map[i]; + 107 13746 : struct snapraid_task* task = &worker->task_map[task_index]; 108 : 109 : /* setup the new pending task */ - 110 13896 : task->state = TASK_STATE_EMPTY; - 111 13896 : task->path[0] = 0; - 112 13896 : task->disk = 0; - 113 13896 : task->buffer = 0; - 114 13896 : task->position = blockcur; - 115 13896 : task->block = 0; - 116 13896 : task->file = 0; - 117 13896 : task->file_pos = 0; - 118 13896 : task->read_size = 0; - 119 13896 : task->is_timestamp_different = 0; + 110 13746 : task->state = TASK_STATE_EMPTY; + 111 13746 : task->path[0] = 0; + 112 13746 : task->disk = 0; + 113 13746 : task->buffer = 0; + 114 13746 : task->position = blockcur; + 115 13746 : task->block = 0; + 116 13746 : task->file = 0; + 117 13746 : task->file_pos = 0; + 118 13746 : task->read_size = 0; + 119 13746 : task->is_timestamp_different = 0; 120 : } - 121 2316 : } + 121 2291 : } 122 : 123 : /*****************************************************************************/ 124 : /* mono thread */ @@ -331,55 +331,55 @@ 269 : * 270 : * This is the synchronization point for workers with the io. 271 : */ - 272 1163270 : static struct snapraid_task* io_reader_step(struct snapraid_worker* worker) + 272 1162708 : static struct snapraid_task* io_reader_step(struct snapraid_worker* worker) 273 : { - 274 1163270 : struct snapraid_io* io = worker->io; + 274 1162708 : struct snapraid_io* io = worker->io; 275 : 276 : /* the synchronization is protected by the io mutex */ - 277 1163270 : thread_mutex_lock(&io->io_mutex); + 277 1162708 : thread_mutex_lock(&io->io_mutex); 278 : 279 : while (1) { 280 : unsigned next_index; 281 : 282 : /* check if the worker has to exit */ 283 : /* even if there is work to do */ - 284 2115537 : if (io->done) { + 284 2057573 : if (io->done) { 285 648 : thread_mutex_unlock(&io->io_mutex); 286 648 : return 0; 287 : } 288 : 289 : /* get the next pending task */ - 290 2114889 : next_index = (worker->index + 1) % io->io_max; + 290 2056925 : next_index = (worker->index + 1) % io->io_max; 291 : 292 : /* if the queue of pending tasks is not empty */ - 293 2114889 : if (next_index != io->reader_index) { + 293 2056925 : if (next_index != io->reader_index) { 294 : struct snapraid_task* task; 295 : 296 : /* the index that the IO may be waiting for */ - 297 1163467 : unsigned waiting_index = io->reader_index; + 297 1162618 : unsigned waiting_index = io->reader_index; 298 : 299 : /* the index that worker just completed */ - 300 1163467 : unsigned done_index = worker->index; + 300 1162618 : unsigned done_index = worker->index; 301 : 302 : /* get the new working task */ - 303 1163467 : worker->index = next_index; - 304 1163467 : task = &worker->task_map[worker->index]; + 303 1162618 : worker->index = next_index; + 304 1162618 : task = &worker->task_map[worker->index]; 305 : 306 : /* if the just completed task is at this index */ - 307 1163467 : if (done_index == waiting_index) { + 307 1162618 : if (done_index == waiting_index) { 308 : /* notify the IO that a new read is complete */ - 309 1460 : thread_cond_signal_and_unlock(&io->read_done, &io->io_mutex); + 309 2747 : thread_cond_signal_and_unlock(&io->read_done, &io->io_mutex); 310 : } else { - 311 1162007 : thread_mutex_unlock(&io->io_mutex); + 311 1159871 : thread_mutex_unlock(&io->io_mutex); 312 : } 313 : 314 : /* return the new task */ - 315 1163329 : return task; + 315 1162520 : return task; 316 : } 317 : 318 : /* otherwise wait for a read_sched event */ - 319 951422 : thread_cond_wait(&io->read_sched, &io->io_mutex); - 320 951422 : } + 319 894307 : thread_cond_wait(&io->read_sched, &io->io_mutex); + 320 894307 : } 321 : } 322 : 323 : /** @@ -387,61 +387,61 @@ 325 : * 326 : * This is the synchronization point for workers with the io. 327 : */ - 328 554398 : static struct snapraid_task* io_writer_step(struct snapraid_worker* worker, int state) + 328 554042 : static struct snapraid_task* io_writer_step(struct snapraid_worker* worker, int state) 329 : { - 330 554398 : struct snapraid_io* io = worker->io; + 330 554042 : struct snapraid_io* io = worker->io; 331 : int error_index; 332 : 333 : /* the synchronization is protected by the io mutex */ - 334 554398 : thread_mutex_lock(&io->io_mutex); + 334 554042 : thread_mutex_lock(&io->io_mutex); 335 : 336 : /* counts the number of errors in the global state */ - 337 554410 : error_index = state - IO_WRITER_ERROR_BASE; - 338 554410 : if (error_index >= 0 && error_index < IO_WRITER_ERROR_MAX) + 337 554044 : error_index = state - IO_WRITER_ERROR_BASE; + 338 554044 : if (error_index >= 0 && error_index < IO_WRITER_ERROR_MAX) 339 0 : ++io->writer_error[error_index]; 340 : 341 : while (1) { 342 : unsigned next_index; 343 : 344 : /* get the next pending task */ - 345 631068 : next_index = (worker->index + 1) % io->io_max; + 345 625754 : next_index = (worker->index + 1) % io->io_max; 346 : 347 : /* if the queue of pending tasks is not empty */ - 348 631068 : if (next_index != io->writer_index) { + 348 625754 : if (next_index != io->writer_index) { 349 : struct snapraid_task* task; 350 : 351 : /* the index that the IO may be waiting for */ - 352 553948 : unsigned waiting_index = (io->writer_index + 1) % io->io_max; + 352 553582 : unsigned waiting_index = (io->writer_index + 1) % io->io_max; 353 : 354 : /* the index that worker just completed */ - 355 553948 : unsigned done_index = worker->index; + 355 553582 : unsigned done_index = worker->index; 356 : 357 : /* get the new working task */ - 358 553948 : worker->index = next_index; - 359 553948 : task = &worker->task_map[worker->index]; + 358 553582 : worker->index = next_index; + 359 553582 : task = &worker->task_map[worker->index]; 360 : 361 : /* if the just completed task is at this index */ - 362 553948 : if (done_index == waiting_index) { + 362 553582 : if (done_index == waiting_index) { 363 : /* notify the IO that a new write is complete */ - 364 81705 : thread_cond_signal_and_unlock(&io->write_done, &io->io_mutex); + 364 83140 : thread_cond_signal_and_unlock(&io->write_done, &io->io_mutex); 365 : } else { - 366 472243 : thread_mutex_unlock(&io->io_mutex); + 366 470442 : thread_mutex_unlock(&io->io_mutex); 367 : } 368 : 369 : /* return the new task */ - 370 553938 : return task; + 370 553581 : return task; 371 : } 372 : 373 : /* check if the worker has to exit */ 374 : /* but only if there is no work to do */ - 375 77120 : if (io->done) { + 375 72172 : if (io->done) { 376 462 : thread_mutex_unlock(&io->io_mutex); 377 462 : return 0; 378 : } 379 : 380 : /* otherwise wait for a write_sched event */ - 381 76658 : thread_cond_wait(&io->write_sched, &io->io_mutex); - 382 76658 : } + 381 71710 : thread_cond_wait(&io->write_sched, &io->io_mutex); + 382 71710 : } 383 : } 384 : 385 : /** @@ -449,146 +449,146 @@ 387 : * 388 : * This is the synchronization point for workers with the io. 389 : */ - 390 145332 : static block_off_t io_read_next_thread(struct snapraid_io* io, void*** buffer) + 390 145271 : static block_off_t io_read_next_thread(struct snapraid_io* io, void*** buffer) 391 : { 392 : block_off_t blockcur_schedule; 393 : block_off_t blockcur_caller; 394 : unsigned i; 395 : 396 : /* get the next parity position to process */ - 397 145332 : blockcur_schedule = io_position_next(io); + 397 145271 : blockcur_schedule = io_position_next(io); 398 : 399 : /* ensure that all data/parity was read */ - 400 145332 : assert(io->reader_list[0] == io->reader_max); + 400 145271 : assert(io->reader_list[0] == io->reader_max); 401 : 402 : /* setup the list of workers to process */ - 403 1373538 : for (i = 0; i <= io->reader_max; ++i) - 404 1228206 : io->reader_list[i] = i; + 403 1373050 : for (i = 0; i <= io->reader_max; ++i) + 404 1227779 : io->reader_list[i] = i; 405 : 406 : /* the synchronization is protected by the io mutex */ - 407 145332 : thread_mutex_lock(&io->io_mutex); + 407 145271 : thread_mutex_lock(&io->io_mutex); 408 : 409 : /* schedule the next read */ - 410 145332 : io_reader_sched(io, io->reader_index, blockcur_schedule); + 410 145271 : io_reader_sched(io, io->reader_index, blockcur_schedule); 411 : 412 : /* set the index for the tasks to return to the caller */ - 413 145332 : io->reader_index = (io->reader_index + 1) % io->io_max; + 413 145271 : io->reader_index = (io->reader_index + 1) % io->io_max; 414 : 415 : /* get the position to operate at high level from one task */ - 416 145332 : blockcur_caller = io->reader_map[0].task_map[io->reader_index].position; + 416 145271 : blockcur_caller = io->reader_map[0].task_map[io->reader_index].position; 417 : 418 : /* set the buffer to use */ - 419 145332 : *buffer = io->buffer_map[io->reader_index]; + 419 145271 : *buffer = io->buffer_map[io->reader_index]; 420 : 421 : /* signal all the workers that there is a new pending task */ - 422 145332 : thread_cond_broadcast_and_unlock(&io->read_sched, &io->io_mutex); + 422 145271 : thread_cond_broadcast_and_unlock(&io->read_sched, &io->io_mutex); 423 : - 424 145332 : return blockcur_caller; + 424 145271 : return blockcur_caller; 425 : } 426 : - 427 110103 : static void io_write_preset_thread(struct snapraid_io* io, block_off_t blockcur, int skip) + 427 110042 : static void io_write_preset_thread(struct snapraid_io* io, block_off_t blockcur, int skip) 428 : { 429 : (void)io; 430 : (void)blockcur; 431 : (void)skip; - 432 110103 : } + 432 110042 : } 433 : - 434 110103 : static void io_write_next_thread(struct snapraid_io* io, block_off_t blockcur, int skip, int* writer_error) + 434 110042 : static void io_write_next_thread(struct snapraid_io* io, block_off_t blockcur, int skip, int* writer_error) 435 : { 436 : unsigned i; 437 : 438 : /* ensure that all parity was written */ - 439 110103 : assert(io->writer_list[0] == io->writer_max); + 439 110042 : assert(io->writer_list[0] == io->writer_max); 440 : 441 : /* setup the list of workers to process */ - 442 774154 : for (i = 0; i <= io->writer_max; ++i) - 443 664051 : io->writer_list[i] = i; + 442 773666 : for (i = 0; i <= io->writer_max; ++i) + 443 663624 : io->writer_list[i] = i; 444 : 445 : /* the synchronization is protected by the io mutex */ - 446 110103 : thread_mutex_lock(&io->io_mutex); + 446 110042 : thread_mutex_lock(&io->io_mutex); 447 : 448 : /* report errors */ - 449 550515 : for (i = 0; i < IO_WRITER_ERROR_MAX; ++i) { - 450 440412 : writer_error[i] = io->writer_error[i]; - 451 440412 : io->writer_error[i] = 0; + 449 550210 : for (i = 0; i < IO_WRITER_ERROR_MAX; ++i) { + 450 440168 : writer_error[i] = io->writer_error[i]; + 451 440168 : io->writer_error[i] = 0; 452 : } 453 : - 454 110103 : if (skip) { + 454 110042 : if (skip) { 455 : /* skip the next write */ - 456 2316 : io_writer_sched_empty(io, io->writer_index, blockcur); + 456 2291 : io_writer_sched_empty(io, io->writer_index, blockcur); 457 : } else { 458 : /* schedule the next write */ - 459 107787 : io_writer_sched(io, io->writer_index, blockcur); + 459 107751 : io_writer_sched(io, io->writer_index, blockcur); 460 : } 461 : 462 : /* at this point the writers must be in sync with the readers */ - 463 110103 : assert(io->writer_index == io->reader_index); + 463 110042 : assert(io->writer_index == io->reader_index); 464 : 465 : /* set the index to be used for the next write */ - 466 110103 : io->writer_index = (io->writer_index + 1) % io->io_max; + 466 110042 : io->writer_index = (io->writer_index + 1) % io->io_max; 467 : 468 : /* signal all the workers that there is a new pending task */ - 469 110103 : thread_cond_broadcast_and_unlock(&io->write_sched, &io->io_mutex); - 470 110103 : } + 469 110042 : thread_cond_broadcast_and_unlock(&io->write_sched, &io->io_mutex); + 470 110042 : } 471 : - 472 0 : static void io_refresh_thread(struct snapraid_io* io) + 472 1 : static void io_refresh_thread(struct snapraid_io* io) 473 : { 474 : unsigned i; 475 : 476 : /* the synchronization is protected by the io mutex */ - 477 0 : thread_mutex_lock(&io->io_mutex); + 477 1 : thread_mutex_lock(&io->io_mutex); 478 : 479 : /* for all readers, count the number of read blocks */ - 480 0 : for (i = 0; i < io->reader_max; ++i) { + 480 7 : for (i = 0; i < io->reader_max; ++i) { 481 : unsigned begin, end, cached; - 482 0 : struct snapraid_worker* worker = &io->reader_map[i]; + 482 6 : struct snapraid_worker* worker = &io->reader_map[i]; 483 : 484 : /* the first block read */ - 485 0 : begin = io->reader_index + 1; + 485 6 : begin = io->reader_index + 1; 486 : /* the block in reading */ - 487 0 : end = worker->index; - 488 0 : if (begin > end) - 489 0 : end += io->io_max; - 490 0 : cached = end - begin; + 487 6 : end = worker->index; + 488 6 : if (begin > end) + 489 6 : end += io->io_max; + 490 6 : cached = end - begin; 491 : - 492 0 : if (worker->parity_handle) + 492 6 : if (worker->parity_handle) 493 0 : io->state->parity[worker->parity_handle->level].cached = cached; 494 : else - 495 0 : worker->handle->disk->cached = cached; + 495 6 : worker->handle->disk->cached = cached; 496 : } 497 : 498 : /* for all writers, count the number of written blocks */ 499 : /* note that this is a kind of "opposite" of cached blocks */ - 500 0 : for (i = 0; i < io->writer_max; ++i) { + 500 2 : for (i = 0; i < io->writer_max; ++i) { 501 : unsigned begin, end, cached; - 502 0 : struct snapraid_worker* worker = &io->writer_map[i]; + 502 1 : struct snapraid_worker* worker = &io->writer_map[i]; 503 : 504 : /* the first block written */ - 505 0 : begin = io->writer_index + 1; + 505 1 : begin = io->writer_index + 1; 506 : /* the block in writing */ - 507 0 : end = worker->index; - 508 0 : if (begin > end) - 509 0 : end += io->io_max; - 510 0 : cached = end - begin; + 507 1 : end = worker->index; + 508 1 : if (begin > end) + 509 1 : end += io->io_max; + 510 1 : cached = end - begin; 511 : - 512 0 : io->state->parity[worker->parity_handle->level].cached = cached; + 512 1 : io->state->parity[worker->parity_handle->level].cached = cached; 513 : } 514 : - 515 0 : thread_mutex_unlock(&io->io_mutex); - 516 0 : } + 515 1 : thread_mutex_unlock(&io->io_mutex); + 516 1 : } 517 : - 518 1082226 : static struct snapraid_task* io_task_read_thread(struct snapraid_io* io, unsigned base, unsigned count, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) + 518 1081860 : static struct snapraid_task* io_task_read_thread(struct snapraid_io* io, unsigned base, unsigned count, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) 519 : { 520 : unsigned waiting_cycle; 521 : 522 : /* count the waiting cycle */ - 523 1082226 : waiting_cycle = 0; + 523 1081860 : waiting_cycle = 0; 524 : 525 : /* clear the waiting indexes */ - 526 1082226 : *waiting_mac = 0; + 526 1081860 : *waiting_mac = 0; 527 : 528 : /* the synchronization is protected by the io mutex */ - 529 1082226 : thread_mutex_lock(&io->io_mutex); + 529 1081860 : thread_mutex_lock(&io->io_mutex); 530 : 531 : while (1) { 532 : unsigned char* let; @@ -597,67 +597,67 @@ 535 : /* get the index the IO is using */ 536 : /* we must ensure that this index has not a read in progress */ 537 : /* to avoid a concurrent access */ - 538 1083535 : busy_index = io->reader_index; + 538 1084465 : busy_index = io->reader_index; 539 : 540 : /* search for a worker that has already finished */ - 541 1083535 : let = &io->reader_list[0]; + 541 1084465 : let = &io->reader_list[0]; 542 : while (1) { - 543 1090052 : unsigned i = *let; + 543 1097188 : unsigned i = *let; 544 : 545 : /* if we are at the end */ - 546 1090052 : if (i == io->reader_max) - 547 1309 : break; + 546 1097188 : if (i == io->reader_max) + 547 2605 : break; 548 : 549 : /* if it's in range */ - 550 1088743 : if (base <= i && i < base + count) { + 550 1094583 : if (base <= i && i < base + count) { 551 : struct snapraid_worker* worker; 552 : 553 : /* if it's the first cycle */ - 554 1087753 : if (waiting_cycle == 0) { + 554 1092105 : if (waiting_cycle == 0) { 555 : /* store the waiting indexes */ - 556 1086091 : waiting_map[(*waiting_mac)++] = i - base; + 556 1088986 : waiting_map[(*waiting_mac)++] = i - base; 557 : } 558 : - 559 1087753 : worker = &io->reader_map[i]; + 559 1092105 : worker = &io->reader_map[i]; 560 : 561 : /* if the worker has finished this index */ - 562 1087753 : if (busy_index != worker->index) { + 562 1092105 : if (busy_index != worker->index) { 563 : struct snapraid_task* task; 564 : - 565 1082226 : task = &worker->task_map[io->reader_index]; + 565 1081860 : task = &worker->task_map[io->reader_index]; 566 : - 567 1082226 : thread_mutex_unlock(&io->io_mutex); + 567 1081860 : thread_mutex_unlock(&io->io_mutex); 568 : 569 : /* mark the worker as processed */ 570 : /* setting the previous one to point at the next one */ - 571 1082226 : *let = io->reader_list[i + 1]; + 571 1081860 : *let = io->reader_list[i + 1]; 572 : 573 : /* return the position */ - 574 1082226 : *pos = i - base; + 574 1081860 : *pos = i - base; 575 : 576 : /* on the first cycle, no one is waiting */ - 577 1082226 : if (waiting_cycle == 0) - 578 1080944 : *waiting_mac = 0; + 577 1081860 : if (waiting_cycle == 0) + 578 1079288 : *waiting_mac = 0; 579 : - 580 2164452 : return task; + 580 2163720 : return task; 581 : } 582 : } 583 : 584 : /* next position to check */ - 585 6517 : let = &io->reader_list[i + 1]; - 586 6517 : } + 585 12723 : let = &io->reader_list[i + 1]; + 586 12723 : } 587 : 588 : /* if no worker is ready, wait for an event */ - 589 1309 : thread_cond_wait(&io->read_done, &io->io_mutex); + 589 2605 : thread_cond_wait(&io->read_done, &io->io_mutex); 590 : 591 : /* count the cycles */ - 592 1309 : ++waiting_cycle; - 593 1309 : } + 592 2605 : ++waiting_cycle; + 593 2605 : } 594 : } 595 : - 596 871422 : static struct snapraid_task* io_data_read_thread(struct snapraid_io* io, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) + 596 871056 : static struct snapraid_task* io_data_read_thread(struct snapraid_io* io, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) 597 : { - 598 871422 : return io_task_read_thread(io, io->data_base, io->data_count, pos, waiting_map, waiting_mac); + 598 871056 : return io_task_read_thread(io, io->data_base, io->data_count, pos, waiting_map, waiting_mac); 599 : } 600 : 601 210804 : static struct snapraid_task* io_parity_read_thread(struct snapraid_io* io, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) @@ -665,18 +665,18 @@ 603 210804 : return io_task_read_thread(io, io->parity_base, io->parity_count, pos, waiting_map, waiting_mac); 604 : } 605 : - 606 553948 : static void io_parity_write_thread(struct snapraid_io* io, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) + 606 553582 : static void io_parity_write_thread(struct snapraid_io* io, unsigned* pos, unsigned* waiting_map, unsigned* waiting_mac) 607 : { 608 : unsigned waiting_cycle; 609 : 610 : /* count the waiting cycle */ - 611 553948 : waiting_cycle = 0; + 611 553582 : waiting_cycle = 0; 612 : 613 : /* clear the waiting indexes */ - 614 553948 : *waiting_mac = 0; + 614 553582 : *waiting_mac = 0; 615 : 616 : /* the synchronization is protected by the io mutex */ - 617 553948 : thread_mutex_lock(&io->io_mutex); + 617 553582 : thread_mutex_lock(&io->io_mutex); 618 : 619 : while (1) { 620 : unsigned char* let; @@ -687,69 +687,69 @@ 625 : /* to avoid a concurrent access */ 626 : /* note that we are already sure that a write is not in progress */ 627 : /* at the index the IO is using at now */ - 628 619618 : busy_index = (io->writer_index + 1) % io->io_max; + 628 622113 : busy_index = (io->writer_index + 1) % io->io_max; 629 : 630 : /* search for a worker that has already finished */ - 631 619618 : let = &io->writer_list[0]; + 631 622113 : let = &io->writer_list[0]; 632 : while (1) { - 633 802324 : unsigned i = *let; + 633 854835 : unsigned i = *let; 634 : struct snapraid_worker* worker; 635 : 636 : /* if we are at the end */ - 637 802324 : if (i == io->writer_max) - 638 65670 : break; + 637 854835 : if (i == io->writer_max) + 638 68531 : break; 639 : 640 : /* if it's the first cycle */ - 641 736654 : if (waiting_cycle == 0) { + 641 786304 : if (waiting_cycle == 0) { 642 : /* store the waiting indexes */ - 643 670497 : waiting_map[(*waiting_mac)++] = i; + 643 717089 : waiting_map[(*waiting_mac)++] = i; 644 : } 645 : - 646 736654 : worker = &io->writer_map[i]; + 646 786304 : worker = &io->writer_map[i]; 647 : 648 : /* the two indexes cannot be equal */ - 649 736654 : assert(io->writer_index != worker->index); + 649 786304 : assert(io->writer_index != worker->index); 650 : 651 : /* if the worker has finished this index */ - 652 736654 : if (busy_index != worker->index) { - 653 553948 : thread_mutex_unlock(&io->io_mutex); + 652 786304 : if (busy_index != worker->index) { + 653 553582 : thread_mutex_unlock(&io->io_mutex); 654 : 655 : /* mark the worker as processed */ 656 : /* setting the previous one to point at the next one */ - 657 553948 : *let = io->writer_list[i + 1]; + 657 553582 : *let = io->writer_list[i + 1]; 658 : 659 : /* return the position */ - 660 553948 : *pos = i; + 660 553582 : *pos = i; 661 : 662 : /* on the first cycle, no one is waiting */ - 663 553948 : if (waiting_cycle == 0) - 664 488278 : *waiting_mac = 0; + 663 553582 : if (waiting_cycle == 0) + 664 485051 : *waiting_mac = 0; 665 : - 666 1107896 : return; + 666 1107164 : return; 667 : } 668 : 669 : /* next position to check */ - 670 182706 : let = &io->writer_list[i + 1]; - 671 182706 : } + 670 232722 : let = &io->writer_list[i + 1]; + 671 232722 : } 672 : 673 : /* if no worker is ready, wait for an event */ - 674 65670 : thread_cond_wait(&io->write_done, &io->io_mutex); + 674 68531 : thread_cond_wait(&io->write_done, &io->io_mutex); 675 : 676 : /* count the cycles */ - 677 65670 : ++waiting_cycle; - 678 65670 : } + 677 68531 : ++waiting_cycle; + 678 68531 : } 679 : } 680 : - 681 1082209 : static void io_reader_worker(struct snapraid_worker* worker, struct snapraid_task* task) + 681 1081809 : static void io_reader_worker(struct snapraid_worker* worker, struct snapraid_task* task) 682 : { 683 : /* if we reached the end */ - 684 1082209 : if (task->position >= worker->io->block_max) { + 684 1081809 : if (task->position >= worker->io->block_max) { 685 : /* complete a dummy task */ 686 120 : task->state = TASK_STATE_EMPTY; 687 : } else { - 688 1082089 : worker->func(worker, task); + 688 1081689 : worker->func(worker, task); 689 : } - 690 1081822 : } + 690 1081474 : } 691 : 692 648 : static void* io_reader_thread(void* arg) 693 : { @@ -762,23 +762,23 @@ 700 : struct snapraid_task* task; 701 : 702 : /* get the new task */ - 703 1163504 : task = io_reader_step(worker); + 703 1162742 : task = io_reader_step(worker); 704 : 705 : /* if no task, it means to exit */ - 706 1163910 : if (!task) - 707 648 : break; + 706 1163099 : if (!task) + 707 647 : break; 708 : 709 : /* nothing more to do */ - 710 1163262 : if (task->state == TASK_STATE_EMPTY) - 711 81670 : continue; + 710 1162452 : if (task->state == TASK_STATE_EMPTY) + 711 81239 : continue; 712 : - 713 1081592 : assert(task->state == TASK_STATE_READY); + 713 1081213 : assert(task->state == TASK_STATE_READY); 714 : 715 : /* work on the assigned task */ - 716 1081592 : io_reader_worker(worker, task); - 717 1162859 : } + 716 1081213 : io_reader_worker(worker, task); + 717 1162097 : } 718 : - 719 648 : return 0; + 719 647 : return 0; 720 : } 721 : 722 462 : static void* io_writer_thread(void* arg) @@ -790,26 +790,26 @@ 728 : struct snapraid_task* task; 729 : 730 : /* get the new task */ - 731 554402 : task = io_writer_step(worker, latest_state); + 731 554042 : task = io_writer_step(worker, latest_state); 732 : 733 : /* if no task, it means to exit */ - 734 554405 : if (!task) + 734 554046 : if (!task) 735 462 : break; 736 : 737 : /* nothing more to do */ - 738 553943 : if (task->state == TASK_STATE_EMPTY) { - 739 13898 : latest_state = TASK_STATE_DONE; - 740 13898 : continue; + 738 553584 : if (task->state == TASK_STATE_EMPTY) { + 739 13749 : latest_state = TASK_STATE_DONE; + 740 13749 : continue; 741 : } 742 : - 743 540045 : assert(task->state == TASK_STATE_READY); + 743 539835 : assert(task->state == TASK_STATE_READY); 744 : 745 : /* work on the assigned task */ - 746 540045 : worker->func(worker, task); + 746 539835 : worker->func(worker, task); 747 : 748 : /* save the resulting state */ - 749 540042 : latest_state = task->state; - 750 553940 : } + 749 539831 : latest_state = task->state; + 750 553580 : } 751 : 752 462 : return 0; 753 : } diff --git a/cov/cmdline/list.c.func-sort-c.html b/cov/cmdline/list.c.func-sort-c.html index 6917e0a5..2f6976a1 100644 --- a/cov/cmdline/list.c.func-sort-c.html +++ b/cov/cmdline/list.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/list.c.func.html b/cov/cmdline/list.c.func.html index 30f7b3f5..e01efb55 100644 --- a/cov/cmdline/list.c.func.html +++ b/cov/cmdline/list.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/list.c.gcov.html b/cov/cmdline/list.c.gcov.html index bcf25d51..8846cd26 100644 --- a/cov/cmdline/list.c.gcov.html +++ b/cov/cmdline/list.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/mkstream.c.func-sort-c.html b/cov/cmdline/mkstream.c.func-sort-c.html index fcbda6e6..763bb84b 100644 --- a/cov/cmdline/mkstream.c.func-sort-c.html +++ b/cov/cmdline/mkstream.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/cmdline/mkstream.c.func.html b/cov/cmdline/mkstream.c.func.html index 0ccbd0b0..3288f869 100644 --- a/cov/cmdline/mkstream.c.func.html +++ b/cov/cmdline/mkstream.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/cmdline/mkstream.c.gcov.html b/cov/cmdline/mkstream.c.gcov.html index ca3d8c3d..461671b3 100644 --- a/cov/cmdline/mkstream.c.gcov.html +++ b/cov/cmdline/mkstream.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/cmdline/mktest.c.func-sort-c.html b/cov/cmdline/mktest.c.func-sort-c.html index 50149ba0..2def4c3e 100644 --- a/cov/cmdline/mktest.c.func-sort-c.html +++ b/cov/cmdline/mktest.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -61,23 +61,23 @@ rnd - 56068924 + 56072909 rndnz - 55657385 + 55661691 file_cmp - 146572 + 146571 rndnz_range - 32675 + 32723 rnd_name - 26852 + 26849 cmd_generate @@ -93,19 +93,19 @@ cmd_write - 6254 + 6227 cmd_append - 3181 + 3256 cmd_truncate - 3162 + 3141 cmd_delete - 3155 + 3136 cmd_damage @@ -121,7 +121,7 @@ cmd_generate_symlink - 943 + 940 main diff --git a/cov/cmdline/mktest.c.func.html b/cov/cmdline/mktest.c.func.html index 8869dfc5..24136aa2 100644 --- a/cov/cmdline/mktest.c.func.html +++ b/cov/cmdline/mktest.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -61,7 +61,7 @@ cmd_append - 3181 + 3256 cmd_change @@ -73,7 +73,7 @@ cmd_delete - 3155 + 3136 cmd_generate @@ -85,15 +85,15 @@ cmd_generate_symlink - 943 + 940 cmd_truncate - 3162 + 3141 cmd_write - 6254 + 6227 fallback @@ -101,7 +101,7 @@ file_cmp - 146572 + 146571 help @@ -113,15 +113,15 @@ rnd - 56068924 + 56072909 rnd_name - 26852 + 26849 rndnz - 55657385 + 55661691 rndnz_damage @@ -129,7 +129,7 @@ rndnz_range - 32675 + 32723
diff --git a/cov/cmdline/mktest.c.gcov.html b/cov/cmdline/mktest.c.gcov.html index 9de78039..584eab4f 100644 --- a/cov/cmdline/mktest.c.gcov.html +++ b/cov/cmdline/mktest.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -89,28 +89,28 @@ 27 : */ 28 : unsigned long long seed = 0; 29 : - 30 56068924 : unsigned rnd(unsigned max) + 30 56072909 : unsigned rnd(unsigned max) 31 : { - 32 56068924 : seed = seed * 6364136223846793005LL + 1442695040888963407LL; + 32 56072909 : seed = seed * 6364136223846793005LL + 1442695040888963407LL; 33 : - 34 56068924 : return (seed >> 32) % max; + 34 56072909 : return (seed >> 32) % max; 35 : } 36 : - 37 55657385 : unsigned rndnz(unsigned max) + 37 55661691 : unsigned rndnz(unsigned max) 38 : { - 39 55657385 : if (max <= 1) + 39 55661691 : if (max <= 1) 40 2831 : return 1; 41 : else - 42 55654554 : return rnd(max - 1) + 1; + 42 55658860 : return rnd(max - 1) + 1; 43 : } 44 : - 45 32675 : void rndnz_range(unsigned char* data, int size) + 45 32723 : void rndnz_range(unsigned char* data, int size) 46 : { 47 : int i; 48 : - 49 55683297 : for (i = 0; i < size; ++i) - 50 55650622 : data[i] = rndnz(256); - 51 32675 : } + 49 55687651 : for (i = 0; i < size; ++i) + 50 55654928 : data[i] = rndnz(256); + 51 32723 : } 52 : 53 1821 : void rndnz_damage(unsigned char* data, int size) 54 : { @@ -131,23 +131,23 @@ 69 : char CHARSET[] = "qwertyuiopasdfghjklzxcvbnm1234567890 .-+"; 70 : #define CHARSET_LEN (sizeof(CHARSET) - 1) 71 : - 72 26852 : void rnd_name(char* file) + 72 26849 : void rnd_name(char* file) 73 : { - 74 26852 : int l = 1 + rnd(20); + 74 26849 : int l = 1 + rnd(20); 75 : - 76 335716 : while (l) { - 77 282012 : *file++ = CHARSET[rnd(CHARSET_LEN)]; - 78 282012 : --l; + 76 335390 : while (l) { + 77 281692 : *file++ = CHARSET[rnd(CHARSET_LEN)]; + 78 281692 : --l; 79 : } - 80 26852 : *file = 0; - 81 26852 : } + 80 26849 : *file = 0; + 81 26849 : } 82 : 83 : /****************************************************************************/ 84 : /* file */ 85 : - 86 146572 : int file_cmp(const void* a, const void* b) + 86 146571 : int file_cmp(const void* a, const void* b) 87 : { - 88 146572 : return strcmp(a, b); + 88 146571 : return strcmp(a, b); 89 : } 90 : 91 1821 : int fallback(int f, struct stat* st) @@ -259,11 +259,11 @@ 197 : * Create a symlink. 198 : * - If the file already exists, it's removed. 199 : */ - 200 943 : void cmd_generate_symlink(const char* path, const char* linkto) + 200 940 : void cmd_generate_symlink(const char* path, const char* linkto) 201 : { 202 : /* remove the existing file/symlink if any */ - 203 943 : if (remove(path) != 0) { - 204 922 : if (errno != ENOENT) { + 203 940 : if (remove(path) != 0) { + 204 919 : if (errno != ENOENT) { 205 : /* LCOV_EXCL_START */ 206 : log_fatal("Error removing file %s\n", path); 207 : exit(EXIT_FAILURE); @@ -271,13 +271,13 @@ 209 : } 210 : } 211 : - 212 943 : if (symlink(linkto, path) != 0) { + 212 940 : if (symlink(linkto, path) != 0) { 213 : /* LCOV_EXCL_START */ 214 : log_fatal("Error writing symlink %s\n", path); 215 : exit(EXIT_FAILURE); 216 : /* LCOV_EXCL_STOP */ 217 : } - 218 943 : } + 218 940 : } 219 : 220 : /** 221 : * Create a file or a symlink with a random name. @@ -350,68 +350,68 @@ 288 : * - The written data may be equal or not at the already existing one. 289 : * - If it's a symlink nothing is done. 290 : */ - 291 6254 : void cmd_write(const char* path, int size) + 291 6227 : void cmd_write(const char* path, int size) 292 : { 293 : struct stat st; 294 : - 295 6254 : if (lstat(path, &st) != 0) { + 295 6227 : if (lstat(path, &st) != 0) { 296 : /* LCOV_EXCL_START */ 297 : log_fatal("Error accessing %s\n", path); 298 : exit(EXIT_FAILURE); 299 : /* LCOV_EXCL_STOP */ 300 : } 301 : - 302 6254 : if (S_ISREG(st.st_mode)) { + 302 6227 : if (S_ISREG(st.st_mode)) { 303 : unsigned char* data; 304 : off_t off; 305 : int f; 306 : 307 : /* not over the end */ - 308 6227 : if (size > st.st_size) - 309 716 : size = st.st_size; + 308 6200 : if (size > st.st_size) + 309 695 : size = st.st_size; 310 : 311 : /* start at random position inside the file */ - 312 6227 : if (size < st.st_size) - 313 5510 : off = rnd(st.st_size - size); + 312 6200 : if (size < st.st_size) + 313 5504 : off = rnd(st.st_size - size); 314 : else - 315 717 : off = 0; + 315 696 : off = 0; 316 : - 317 6227 : data = malloc(size); + 317 6200 : data = malloc(size); 318 : - 319 6227 : rndnz_range(data, size); + 319 6200 : rndnz_range(data, size); 320 : - 321 6227 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); - 322 6227 : if (f < 0) { + 321 6200 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); + 322 6200 : if (f < 0) { 323 : /* LCOV_EXCL_START */ 324 : log_fatal("Error creating file %s\n", path); 325 : exit(EXIT_FAILURE); 326 : /* LCOV_EXCL_STOP */ 327 : } 328 : - 329 6227 : if (lseek(f, off, SEEK_SET) != off) { + 329 6200 : if (lseek(f, off, SEEK_SET) != off) { 330 : /* LCOV_EXCL_START */ 331 : log_fatal("Error seeking file %s\n", path); 332 : exit(EXIT_FAILURE); 333 : /* LCOV_EXCL_STOP */ 334 : } 335 : - 336 6227 : if (write(f, data, size) != size) { + 336 6200 : if (write(f, data, size) != size) { 337 : /* LCOV_EXCL_START */ 338 : log_fatal("Error writing file %s\n", path); 339 : exit(EXIT_FAILURE); 340 : /* LCOV_EXCL_STOP */ 341 : } 342 : - 343 6227 : if (close(f) != 0) { + 343 6200 : if (close(f) != 0) { 344 : /* LCOV_EXCL_START */ 345 : log_fatal("Error closing file %s\n", path); 346 : exit(EXIT_FAILURE); 347 : /* LCOV_EXCL_STOP */ 348 : } 349 : - 350 6227 : free(data); + 350 6200 : free(data); 351 : } - 352 6254 : } + 352 6227 : } 353 : 354 : /** 355 : * Damage a file. @@ -518,50 +518,50 @@ 456 : * - The file must exist. 457 : * - If it's a symlink nothing is done. 458 : */ - 459 3181 : void cmd_append(const char* path, int size) + 459 3256 : void cmd_append(const char* path, int size) 460 : { 461 : struct stat st; 462 : - 463 3181 : if (lstat(path, &st) != 0) { + 463 3256 : if (lstat(path, &st) != 0) { 464 : /* LCOV_EXCL_START */ 465 : log_fatal("Error accessing %s\n", path); 466 : exit(EXIT_FAILURE); 467 : /* LCOV_EXCL_STOP */ 468 : } 469 : - 470 3181 : if (S_ISREG(st.st_mode)) { + 470 3256 : if (S_ISREG(st.st_mode)) { 471 : unsigned char* data; 472 : int f; 473 : - 474 3181 : data = malloc(size); + 474 3256 : data = malloc(size); 475 : - 476 3181 : rndnz_range(data, size); + 476 3256 : rndnz_range(data, size); 477 : - 478 3181 : f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW); - 479 3181 : if (f < 0) { + 478 3256 : f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW); + 479 3256 : if (f < 0) { 480 : /* LCOV_EXCL_START */ 481 : log_fatal("Error opening file %s\n", path); 482 : exit(EXIT_FAILURE); 483 : /* LCOV_EXCL_STOP */ 484 : } 485 : - 486 3181 : if (write(f, data, size) != size) { + 486 3256 : if (write(f, data, size) != size) { 487 : /* LCOV_EXCL_START */ 488 : log_fatal("Error writing file %s\n", path); 489 : exit(EXIT_FAILURE); 490 : /* LCOV_EXCL_STOP */ 491 : } 492 : - 493 3181 : if (close(f) != 0) { + 493 3256 : if (close(f) != 0) { 494 : /* LCOV_EXCL_START */ 495 : log_fatal("Error closing file %s\n", path); 496 : exit(EXIT_FAILURE); 497 : /* LCOV_EXCL_STOP */ 498 : } 499 : - 500 3181 : free(data); + 500 3256 : free(data); 501 : } - 502 3181 : } + 502 3256 : } 503 : 504 : /** 505 : * Truncate a file. @@ -569,69 +569,69 @@ 507 : * - The file is NEVER truncated to 0. 508 : * - If it's a symlink nothing is done. 509 : */ - 510 3162 : void cmd_truncate(const char* path, int size) + 510 3141 : void cmd_truncate(const char* path, int size) 511 : { 512 : struct stat st; 513 : - 514 3162 : if (lstat(path, &st) != 0) { + 514 3141 : if (lstat(path, &st) != 0) { 515 : /* LCOV_EXCL_START */ 516 : log_fatal("Error accessing %s\n", path); 517 : exit(EXIT_FAILURE); 518 : /* LCOV_EXCL_STOP */ 519 : } 520 : - 521 3162 : if (S_ISREG(st.st_mode)) { + 521 3141 : if (S_ISREG(st.st_mode)) { 522 : off_t off; 523 : int f; 524 : 525 : /* if file is empty, just rewrite it */ - 526 3162 : if (st.st_size == 0) { - 527 4 : size = 0; + 526 3141 : if (st.st_size == 0) { + 527 1 : size = 0; 528 : } else { 529 : /* don't truncate files to 0 size to avoid ZERO file size protection */ - 530 3158 : if (size >= st.st_size) - 531 209 : size = st.st_size - 1; + 530 3140 : if (size >= st.st_size) + 531 200 : size = st.st_size - 1; 532 : } 533 : - 534 3162 : off = st.st_size - size; + 534 3141 : off = st.st_size - size; 535 : - 536 3162 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); - 537 3162 : if (f < 0) { + 536 3141 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); + 537 3141 : if (f < 0) { 538 : /* LCOV_EXCL_START */ 539 : log_fatal("Error opening file %s\n", path); 540 : exit(EXIT_FAILURE); 541 : /* LCOV_EXCL_STOP */ 542 : } 543 : - 544 3162 : if (ftruncate(f, off) != 0) { + 544 3141 : if (ftruncate(f, off) != 0) { 545 : /* LCOV_EXCL_START */ 546 : log_fatal("Error truncating file %s\n", path); 547 : exit(EXIT_FAILURE); 548 : /* LCOV_EXCL_STOP */ 549 : } 550 : - 551 3162 : if (close(f) != 0) { + 551 3141 : if (close(f) != 0) { 552 : /* LCOV_EXCL_START */ 553 : log_fatal("Error closing file %s\n", path); 554 : exit(EXIT_FAILURE); 555 : /* LCOV_EXCL_STOP */ 556 : } 557 : } - 558 3162 : } + 558 3141 : } 559 : 560 : /** 561 : * Delete a file. 562 : * - The file must exist. 563 : */ - 564 3155 : void cmd_delete(const char* path) + 564 3136 : void cmd_delete(const char* path) 565 : { - 566 3155 : if (remove(path) != 0) { + 566 3136 : if (remove(path) != 0) { 567 : /* LCOV_EXCL_START */ 568 : log_fatal("Error removing %s\n", path); 569 : exit(EXIT_FAILURE); 570 : /* LCOV_EXCL_STOP */ 571 : } - 572 3155 : } + 572 3136 : } 573 : 574 : /** 575 : * Change a file. Or deleted/truncated/append/created. @@ -642,20 +642,20 @@ 580 : struct stat st; 581 : 582 13128 : if (!size) - 583 13160 : return; + 583 13152 : return; 584 : - 585 13096 : if (lstat(path, &st) != 0) { + 585 13104 : if (lstat(path, &st) != 0) { 586 : /* LCOV_EXCL_START */ 587 : log_fatal("Error accessing %s\n", path); 588 : exit(EXIT_FAILURE); 589 : /* LCOV_EXCL_STOP */ 590 : } 591 : - 592 13096 : if (S_ISLNK(st.st_mode)) { + 592 13104 : if (S_ISLNK(st.st_mode)) { 593 : /* symlink */ 594 393 : if (rnd(2) == 0) { 595 : /* delete */ - 596 183 : if (remove(path) != 0) { + 596 186 : if (remove(path) != 0) { 597 : /* LCOV_EXCL_START */ 598 : log_fatal("Error removing %s\n", path); 599 : exit(EXIT_FAILURE); @@ -665,30 +665,30 @@ 603 : /* recreate */ 604 : char linkto[PATH_MAX]; 605 : - 606 210 : if (remove(path) != 0) { + 606 207 : if (remove(path) != 0) { 607 : /* LCOV_EXCL_START */ 608 : log_fatal("Error removing %s\n", path); 609 : exit(EXIT_FAILURE); 610 : /* LCOV_EXCL_STOP */ 611 : } 612 : - 613 210 : rnd_name(linkto); + 613 207 : rnd_name(linkto); 614 : - 615 210 : cmd_generate_symlink(path, linkto); + 615 207 : cmd_generate_symlink(path, linkto); 616 : } - 617 12703 : } else if (S_ISREG(st.st_mode)) { + 617 12711 : } else if (S_ISREG(st.st_mode)) { 618 : int r; 619 : - 620 12703 : r = rnd(4); + 620 12711 : r = rnd(4); 621 : - 622 12703 : if (r == 0) { - 623 3205 : cmd_write(path, size); - 624 9498 : } else if (r == 1) { - 625 3181 : cmd_append(path, size); - 626 6317 : } else if (r == 2) { - 627 3162 : cmd_truncate(path, size); + 622 12711 : if (r == 0) { + 623 3178 : cmd_write(path, size); + 624 9533 : } else if (r == 1) { + 625 3256 : cmd_append(path, size); + 626 6277 : } else if (r == 2) { + 627 3141 : cmd_truncate(path, size); 628 : } else { - 629 3155 : cmd_delete(path); + 629 3136 : cmd_delete(path); 630 : } 631 : } 632 : } diff --git a/cov/cmdline/murmur3.c.func-sort-c.html b/cov/cmdline/murmur3.c.func-sort-c.html index 36afb82e..b8fd330e 100644 --- a/cov/cmdline/murmur3.c.func-sort-c.html +++ b/cov/cmdline/murmur3.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ fmix32 - 8307416 + 8307408 MurmurHash3_x86_128 - 2076854 + 2076852
diff --git a/cov/cmdline/murmur3.c.func.html b/cov/cmdline/murmur3.c.func.html index 4b31437b..40d30fc9 100644 --- a/cov/cmdline/murmur3.c.func.html +++ b/cov/cmdline/murmur3.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ MurmurHash3_x86_128 - 2076854 + 2076852 fmix32 - 8307416 + 8307408
diff --git a/cov/cmdline/murmur3.c.gcov.html b/cov/cmdline/murmur3.c.gcov.html index 3d5c639f..5f7069e2 100644 --- a/cov/cmdline/murmur3.c.gcov.html +++ b/cov/cmdline/murmur3.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -91,14 +91,14 @@ 29 : // domain. The author hereby disclaims copyright to this source code. 30 : 31 : /* Finalization mix - force all bits of a hash block to avalanche */ - 32 8307416 : static inline uint32_t fmix32(uint32_t h) + 32 8307408 : static inline uint32_t fmix32(uint32_t h) 33 : { - 34 8307416 : h ^= h >> 16; - 35 8307416 : h *= 0x85ebca6b; - 36 8307416 : h ^= h >> 13; - 37 8307416 : h *= 0xc2b2ae35; - 38 8307416 : h ^= h >> 16; - 39 8307416 : return h; + 34 8307408 : h ^= h >> 16; + 35 8307408 : h *= 0x85ebca6b; + 36 8307408 : h ^= h >> 13; + 37 8307408 : h *= 0xc2b2ae35; + 38 8307408 : h ^= h >> 16; + 39 8307408 : return h; 40 : } 41 : 42 : /* @@ -137,122 +137,109 @@ 75 : uint32_t c3 = 0x38b34ae5; 76 : uint32_t c4 = 0xa1e38b93; 77 : - 78 2076854 : void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, void* digest) + 78 2076852 : void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, void* digest) 79 : { 80 : size_t nblocks; 81 : const uint32_t* blocks; 82 : const uint32_t* end; 83 : size_t size_remainder; - 84 : - 85 2076854 : uint32_t h1 = ((const uint32_t*)seed)[0]; - 86 2076854 : uint32_t h2 = ((const uint32_t*)seed)[1]; - 87 2076854 : uint32_t h3 = ((const uint32_t*)seed)[2]; - 88 2076854 : uint32_t h4 = ((const uint32_t*)seed)[3]; - 89 : - 90 : #if WORDS_BIGENDIAN - 91 : h1 = util_swap32(h1); - 92 : h2 = util_swap32(h2); - 93 : h3 = util_swap32(h3); - 94 : h4 = util_swap32(h4); - 95 : #endif - 96 : - 97 2076854 : nblocks = size / 16; - 98 2076854 : blocks = data; - 99 2076854 : end = blocks + nblocks * 4; - 100 : - 101 : /* body */ - 102 110685610 : while (blocks < end) { - 103 106531902 : uint32_t k1 = blocks[0]; - 104 106531902 : uint32_t k2 = blocks[1]; - 105 106531902 : uint32_t k3 = blocks[2]; - 106 106531902 : uint32_t k4 = blocks[3]; - 107 : - 108 : #if WORDS_BIGENDIAN - 109 : k1 = util_swap32(k1); - 110 : k2 = util_swap32(k2); - 111 : k3 = util_swap32(k3); - 112 : k4 = util_swap32(k4); - 113 : #endif + 84 : uint32_t h1, h2, h3, h4; + 85 : + 86 2076852 : h1 = util_read32(seed + 0); + 87 2076852 : h2 = util_read32(seed + 4); + 88 2076852 : h3 = util_read32(seed + 8); + 89 2076852 : h4 = util_read32(seed + 12); + 90 : + 91 2076852 : nblocks = size / 16; + 92 2076852 : blocks = data; + 93 2076852 : end = blocks + nblocks * 4; + 94 : + 95 : /* body */ + 96 110684486 : while (blocks < end) { + 97 106530782 : uint32_t k1 = blocks[0]; + 98 106530782 : uint32_t k2 = blocks[1]; + 99 106530782 : uint32_t k3 = blocks[2]; + 100 106530782 : uint32_t k4 = blocks[3]; + 101 : + 102 : #if WORDS_BIGENDIAN + 103 : k1 = util_swap32(k1); + 104 : k2 = util_swap32(k2); + 105 : k3 = util_swap32(k3); + 106 : k4 = util_swap32(k4); + 107 : #endif + 108 : + 109 106530782 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; + 110 : + 111 106530782 : h1 = util_rotl32(h1, 19); h1 += h2; h1 = h1 * 5 + 0x561ccd1b; + 112 : + 113 106530782 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; 114 : - 115 106531902 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; + 115 106530782 : h2 = util_rotl32(h2, 17); h2 += h3; h2 = h2 * 5 + 0x0bcaa747; 116 : - 117 106531902 : h1 = util_rotl32(h1, 19); h1 += h2; h1 = h1 * 5 + 0x561ccd1b; + 117 106530782 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; 118 : - 119 106531902 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; + 119 106530782 : h3 = util_rotl32(h3, 15); h3 += h4; h3 = h3 * 5 + 0x96cd1c35; 120 : - 121 106531902 : h2 = util_rotl32(h2, 17); h2 += h3; h2 = h2 * 5 + 0x0bcaa747; + 121 106530782 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; 122 : - 123 106531902 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; + 123 106530782 : h4 = util_rotl32(h4, 13); h4 += h1; h4 = h4 * 5 + 0x32ac3b17; 124 : - 125 106531902 : h3 = util_rotl32(h3, 15); h3 += h4; h3 = h3 * 5 + 0x96cd1c35; - 126 : - 127 106531902 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; - 128 : - 129 106531902 : h4 = util_rotl32(h4, 13); h4 += h1; h4 = h4 * 5 + 0x32ac3b17; - 130 : - 131 106531902 : blocks += 4; - 132 : } - 133 : - 134 : /* tail */ - 135 2076854 : size_remainder = size & 15; - 136 2076854 : if (size_remainder != 0) { - 137 779239 : const uint8_t* tail = (const uint8_t*)blocks; - 138 : - 139 779239 : uint32_t k1 = 0; - 140 779239 : uint32_t k2 = 0; - 141 779239 : uint32_t k3 = 0; - 142 779239 : uint32_t k4 = 0; - 143 : - 144 779239 : switch (size_remainder) { - 145 51287 : case 15 : k4 ^= (uint32_t)tail[14] << 16; - 146 104028 : case 14 : k4 ^= (uint32_t)tail[13] << 8; - 147 156205 : case 13 : k4 ^= (uint32_t)tail[12] << 0; - 148 156205 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; - 149 208993 : case 12 : k3 ^= (uint32_t)tail[11] << 24; - 150 261517 : case 11 : k3 ^= (uint32_t)tail[10] << 16; - 151 313718 : case 10 : k3 ^= (uint32_t)tail[ 9] << 8; - 152 367026 : case 9 : k3 ^= (uint32_t)tail[ 8] << 0; - 153 367026 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; - 154 420982 : case 8 : k2 ^= (uint32_t)tail[ 7] << 24; - 155 470474 : case 7 : k2 ^= (uint32_t)tail[ 6] << 16; - 156 523130 : case 6 : k2 ^= (uint32_t)tail[ 5] << 8; - 157 573642 : case 5 : k2 ^= (uint32_t)tail[ 4] << 0; - 158 573642 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; - 159 625581 : case 4 : k1 ^= (uint32_t)tail[ 3] << 24; - 160 675936 : case 3 : k1 ^= (uint32_t)tail[ 2] << 16; - 161 726983 : case 2 : k1 ^= (uint32_t)tail[ 1] << 8; - 162 779239 : case 1 : k1 ^= (uint32_t)tail[ 0] << 0; - 163 779239 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; - 164 : } - 165 : } + 125 106530782 : blocks += 4; + 126 : } + 127 : + 128 : /* tail */ + 129 2076852 : size_remainder = size & 15; + 130 2076852 : if (size_remainder != 0) { + 131 779223 : const uint8_t* tail = (const uint8_t*)blocks; + 132 : + 133 779223 : uint32_t k1 = 0; + 134 779223 : uint32_t k2 = 0; + 135 779223 : uint32_t k3 = 0; + 136 779223 : uint32_t k4 = 0; + 137 : + 138 779223 : switch (size_remainder) { + 139 51253 : case 15 : k4 ^= (uint32_t)tail[14] << 16; + 140 103976 : case 14 : k4 ^= (uint32_t)tail[13] << 8; + 141 156183 : case 13 : k4 ^= (uint32_t)tail[12] << 0; + 142 156183 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; + 143 208955 : case 12 : k3 ^= (uint32_t)tail[11] << 24; + 144 261477 : case 11 : k3 ^= (uint32_t)tail[10] << 16; + 145 313646 : case 10 : k3 ^= (uint32_t)tail[ 9] << 8; + 146 366950 : case 9 : k3 ^= (uint32_t)tail[ 8] << 0; + 147 366950 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; + 148 420888 : case 8 : k2 ^= (uint32_t)tail[ 7] << 24; + 149 470405 : case 7 : k2 ^= (uint32_t)tail[ 6] << 16; + 150 523044 : case 6 : k2 ^= (uint32_t)tail[ 5] << 8; + 151 573538 : case 5 : k2 ^= (uint32_t)tail[ 4] << 0; + 152 573538 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; + 153 625492 : case 4 : k1 ^= (uint32_t)tail[ 3] << 24; + 154 675841 : case 3 : k1 ^= (uint32_t)tail[ 2] << 16; + 155 726916 : case 2 : k1 ^= (uint32_t)tail[ 1] << 8; + 156 779223 : case 1 : k1 ^= (uint32_t)tail[ 0] << 0; + 157 779223 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; + 158 : } + 159 : } + 160 : + 161 : /* finalization */ + 162 2076852 : h1 ^= size; h2 ^= size; h3 ^= size; h4 ^= size; + 163 : + 164 2076852 : h1 += h2; h1 += h3; h1 += h4; + 165 2076852 : h2 += h1; h3 += h1; h4 += h1; 166 : - 167 : /* finalization */ - 168 2076854 : h1 ^= size; h2 ^= size; h3 ^= size; h4 ^= size; - 169 : - 170 2076854 : h1 += h2; h1 += h3; h1 += h4; - 171 2076854 : h2 += h1; h3 += h1; h4 += h1; - 172 : - 173 2076854 : h1 = fmix32(h1); - 174 2076854 : h2 = fmix32(h2); - 175 2076854 : h3 = fmix32(h3); - 176 2076854 : h4 = fmix32(h4); - 177 : - 178 2076854 : h1 += h2; h1 += h3; h1 += h4; - 179 2076854 : h2 += h1; h3 += h1; h4 += h1; + 167 2076852 : h1 = fmix32(h1); + 168 2076852 : h2 = fmix32(h2); + 169 2076852 : h3 = fmix32(h3); + 170 2076852 : h4 = fmix32(h4); + 171 : + 172 2076852 : h1 += h2; h1 += h3; h1 += h4; + 173 2076852 : h2 += h1; h3 += h1; h4 += h1; + 174 : + 175 2076852 : util_write32(digest + 0, h1); + 176 2076852 : util_write32(digest + 4, h2); + 177 2076852 : util_write32(digest + 8, h3); + 178 2076852 : util_write32(digest + 12, h4); + 179 2076852 : } 180 : - 181 : #if WORDS_BIGENDIAN - 182 : h1 = util_swap32(h1); - 183 : h2 = util_swap32(h2); - 184 : h3 = util_swap32(h3); - 185 : h4 = util_swap32(h4); - 186 : #endif - 187 : - 188 2076854 : ((uint32_t*)digest)[0] = h1; - 189 2076854 : ((uint32_t*)digest)[1] = h2; - 190 2076854 : ((uint32_t*)digest)[2] = h3; - 191 2076854 : ((uint32_t*)digest)[3] = h4; - 192 2076854 : } - 193 : diff --git a/cov/cmdline/parity.c.func-sort-c.html b/cov/cmdline/parity.c.func-sort-c.html index 83ea4f9a..494a1ed5 100644 --- a/cov/cmdline/parity.c.func-sort-c.html +++ b/cov/cmdline/parity.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -61,15 +61,15 @@ parity_split_find - 4114025 + 4113807 parity_read - 3501825 + 3501819 parity_write - 612195 + 611983 parity_handle_chsize @@ -93,7 +93,7 @@ parity_allocated_size - 640 + 642 parity_create diff --git a/cov/cmdline/parity.c.func.html b/cov/cmdline/parity.c.func.html index fbee8fb6..0610c73a 100644 --- a/cov/cmdline/parity.c.func.html +++ b/cov/cmdline/parity.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -65,7 +65,7 @@ parity_allocated_size - 640 + 642 parity_chsize @@ -109,7 +109,7 @@ parity_read - 3501825 + 3501819 parity_size @@ -117,7 +117,7 @@ parity_split_find - 4114025 + 4113807 parity_split_is_fixed @@ -133,7 +133,7 @@ parity_write - 612195 + 611983
diff --git a/cov/cmdline/parity.c.gcov.html b/cov/cmdline/parity.c.gcov.html index d58b31ce..b43a0239 100644 --- a/cov/cmdline/parity.c.gcov.html +++ b/cov/cmdline/parity.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 18 @@ -94,31 +94,31 @@ 32 : /****************************************************************************/ 33 : /* parity */ 34 : - 35 640 : block_off_t parity_allocated_size(struct snapraid_state* state) + 35 642 : block_off_t parity_allocated_size(struct snapraid_state* state) 36 : { 37 : block_off_t parity_block; 38 : tommy_node* i; 39 : 40 : /* compute the size of the parity file */ - 41 640 : parity_block = 0; - 42 4470 : for (i = state->disklist; i != 0; i = i->next) { - 43 3830 : struct snapraid_disk* disk = i->data; + 41 642 : parity_block = 0; + 42 4484 : for (i = state->disklist; i != 0; i = i->next) { + 43 3842 : struct snapraid_disk* disk = i->data; 44 : 45 : /* start from the declared size */ - 46 3830 : block_off_t block = fs_size(disk); + 46 3842 : block_off_t block = fs_size(disk); 47 : 48 : /* decrease the block until an allocated one, but part of a file */ 49 : /* we don't stop at deleted blocks, because we want to have them cleared */ 50 : /* if they are at the end of the parity */ - 51 190208 : while (block > parity_block && !block_has_file(fs_par2block_find(disk, block - 1))) + 51 190232 : while (block > parity_block && !block_has_file(fs_par2block_find(disk, block - 1))) 52 182548 : --block; 53 : 54 : /* get the highest value */ - 55 3830 : if (block > parity_block) - 56 2265 : parity_block = block; + 55 3842 : if (block > parity_block) + 56 2267 : parity_block = block; 57 : } 58 : - 59 640 : return parity_block; + 59 642 : return parity_block; 60 : } 61 : 62 87 : block_off_t parity_used_size(struct snapraid_state* state) @@ -135,8 +135,8 @@ 73 521 : block_off_t block = fs_size(disk); 74 : 75 : /* decrease the block until an used one */ - 76 221715 : while (block > parity_block && !block_has_file_and_valid_parity(fs_par2block_find(disk, block - 1))) - 77 220673 : --block; + 76 221718 : while (block > parity_block && !block_has_file_and_valid_parity(fs_par2block_find(disk, block - 1))) + 77 220676 : --block; 78 : 79 : /* get the highest value */ 80 521 : if (block > parity_block) @@ -826,18 +826,18 @@ 764 1022 : return f_ret; 765 : } 766 : - 767 4114025 : struct snapraid_split_handle* parity_split_find(struct snapraid_parity_handle* handle, data_off_t* offset) + 767 4113807 : struct snapraid_split_handle* parity_split_find(struct snapraid_parity_handle* handle, data_off_t* offset) 768 : { 769 : unsigned s; 770 : - 771 4114025 : if (*offset < 0) + 771 4113807 : if (*offset < 0) 772 0 : return 0; 773 : - 774 6502383 : for (s = 0;s < handle->split_mac;++s) { - 775 6491023 : struct snapraid_split_handle* split = &handle->split_map[s]; + 774 6502165 : for (s = 0;s < handle->split_mac;++s) { + 775 6490805 : struct snapraid_split_handle* split = &handle->split_map[s]; 776 : - 777 6491023 : if (*offset < split->size) - 778 4102665 : return split; + 777 6490805 : if (*offset < split->size) + 778 4102447 : return split; 779 : 780 2388358 : *offset -= split->size; 781 : } @@ -845,25 +845,25 @@ 783 11360 : return 0; 784 : } 785 : - 786 612195 : int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size) + 786 611983 : int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size) 787 : { 788 : ssize_t write_ret; 789 : data_off_t offset; 790 : struct snapraid_split_handle* split; 791 : int ret; 792 : - 793 612195 : offset = pos * (data_off_t)block_size; + 793 611983 : offset = pos * (data_off_t)block_size; 794 : - 795 612195 : split = parity_split_find(handle, &offset); - 796 612196 : if (!split) { + 795 611983 : split = parity_split_find(handle, &offset); + 796 611984 : if (!split) { 797 : /* LCOV_EXCL_START */ 798 : log_fatal("Writing parity data outside range at extra offset %" PRIu64 ".\n", offset); 799 : return -1; 800 : /* LCOV_EXCL_STOP */ 801 : } 802 : - 803 612196 : write_ret = pwrite(split->f, block_buffer, block_size, offset); - 804 612199 : if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */ + 803 611984 : write_ret = pwrite(split->f, block_buffer, block_size, offset); + 804 611983 : if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */ 805 : /* LCOV_EXCL_START */ 806 : if (errno == ENOSPC) { 807 : log_fatal("Failed to grow parity file '%s' using write due lack of space.\n", split->path); @@ -874,18 +874,18 @@ 812 : /* LCOV_EXCL_STOP */ 813 : } 814 : - 815 612199 : ret = advise_write(&split->advise, split->f, offset, block_size); - 816 612194 : if (ret != 0) { + 815 611983 : ret = advise_write(&split->advise, split->f, offset, block_size); + 816 611981 : if (ret != 0) { 817 : /* LCOV_EXCL_START */ 818 : log_fatal("Error advising parity file '%s'. %s.\n", split->path, strerror(errno)); 819 : return -1; 820 : /* LCOV_EXCL_STOP */ 821 : } 822 : - 823 612194 : return 0; + 823 611981 : return 0; 824 : } 825 : - 826 3501825 : int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out) + 826 3501819 : int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out) 827 : { 828 : ssize_t read_ret; 829 : data_off_t offset; @@ -893,44 +893,44 @@ 831 : struct snapraid_split_handle* split; 832 : int ret; 833 : - 834 3501825 : offset = pos * (data_off_t)block_size; + 834 3501819 : offset = pos * (data_off_t)block_size; 835 : - 836 3501825 : split = parity_split_find(handle, &offset); - 837 3501814 : if (!split) { + 836 3501819 : split = parity_split_find(handle, &offset); + 837 3501808 : if (!split) { 838 : /* LCOV_EXCL_START */ 839 : out("Reading parity data outside range at extra offset %" PRIu64 ".\n", offset); 840 : return -1; 841 : /* LCOV_EXCL_STOP */ 842 : } 843 : - 844 3490454 : count = 0; + 844 3490448 : count = 0; 845 : do { - 846 3490458 : read_ret = pread(split->f, block_buffer + count, block_size - count, offset + count); - 847 3490424 : if (read_ret < 0) { + 846 3490446 : read_ret = pread(split->f, block_buffer + count, block_size - count, offset + count); + 847 3490413 : if (read_ret < 0) { 848 : /* LCOV_EXCL_START */ 849 : out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", split->path, offset + count, block_size - count, strerror(errno)); 850 : return -1; 851 : /* LCOV_EXCL_STOP */ 852 : } - 853 3490424 : if (read_ret == 0) { + 853 3490413 : if (read_ret == 0) { 854 : /* LCOV_EXCL_START */ 855 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", split->path, offset, strerror(errno)); 856 : return -1; 857 : /* LCOV_EXCL_STOP */ 858 : } 859 : - 860 3490424 : count += read_ret; - 861 3490424 : } while (count < block_size); + 860 3490413 : count += read_ret; + 861 3490413 : } while (count < block_size); 862 : - 863 3490420 : ret = advise_read(&split->advise, split->f, offset, block_size); - 864 3490421 : if (ret != 0) { + 863 3490415 : ret = advise_read(&split->advise, split->f, offset, block_size); + 864 3490417 : if (ret != 0) { 865 : /* LCOV_EXCL_START */ 866 : out("Error advising parity file '%s'. %s.\n", split->path, strerror(errno)); 867 : return -1; 868 : /* LCOV_EXCL_STOP */ 869 : } 870 : - 871 3490421 : return block_size; + 871 3490417 : return block_size; 872 : } 873 : diff --git a/cov/cmdline/pool.c.func-sort-c.html b/cov/cmdline/pool.c.func-sort-c.html index b219bc10..154e338e 100644 --- a/cov/cmdline/pool.c.func-sort-c.html +++ b/cov/cmdline/pool.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/cmdline/pool.c.func.html b/cov/cmdline/pool.c.func.html index 55e42bd7..97212d32 100644 --- a/cov/cmdline/pool.c.func.html +++ b/cov/cmdline/pool.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/cmdline/pool.c.gcov.html b/cov/cmdline/pool.c.gcov.html index 630a94b2..c1a4eec7 100644 --- a/cov/cmdline/pool.c.gcov.html +++ b/cov/cmdline/pool.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/cmdline/portable.h.func-sort-c.html b/cov/cmdline/portable.h.func-sort-c.html index ffa05fb1..fb8ed345 100644 --- a/cov/cmdline/portable.h.func-sort-c.html +++ b/cov/cmdline/portable.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/portable.h.func.html b/cov/cmdline/portable.h.func.html index 72089618..6ae6ba87 100644 --- a/cov/cmdline/portable.h.func.html +++ b/cov/cmdline/portable.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/portable.h.gcov.html b/cov/cmdline/portable.h.gcov.html index eb189605..31070c84 100644 --- a/cov/cmdline/portable.h.gcov.html +++ b/cov/cmdline/portable.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/rehash.c.func-sort-c.html b/cov/cmdline/rehash.c.func-sort-c.html index 5313da82..8a66d85e 100644 --- a/cov/cmdline/rehash.c.func-sort-c.html +++ b/cov/cmdline/rehash.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/rehash.c.func.html b/cov/cmdline/rehash.c.func.html index 54a9e919..84923317 100644 --- a/cov/cmdline/rehash.c.func.html +++ b/cov/cmdline/rehash.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/rehash.c.gcov.html b/cov/cmdline/rehash.c.gcov.html index 8c917c0d..3d0d0126 100644 --- a/cov/cmdline/rehash.c.gcov.html +++ b/cov/cmdline/rehash.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/scan.c.func-sort-c.html b/cov/cmdline/scan.c.func-sort-c.html index a2a7949d..ffed18f4 100644 --- a/cov/cmdline/scan.c.func-sort-c.html +++ b/cov/cmdline/scan.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 23 @@ -73,39 +73,39 @@ scan_file_keep - 1025539 + 1025550 file_is_full_invalid_parity_and_stable - 1025539 + 1025550 dd_ino_compare - 103398 + 103390 scan_file_delayed_allocate - 101892 + 101881 scan_file_insert - 101892 + 101881 scan_file_allocate - 101892 + 101881 scan_file_refresh - 79205 + 79194 scan_file_remove - 57026 + 57015 scan_file_deallocate - 57026 + 57015 scan_link diff --git a/cov/cmdline/scan.c.func.html b/cov/cmdline/scan.c.func.html index 9105ea85..28656181 100644 --- a/cov/cmdline/scan.c.func.html +++ b/cov/cmdline/scan.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 23 @@ -61,7 +61,7 @@ dd_ino_compare - 103398 + 103390 dd_name_compare @@ -77,7 +77,7 @@ file_is_full_invalid_parity_and_stable - 1025539 + 1025550 scan_dir @@ -101,31 +101,31 @@ scan_file_allocate - 101892 + 101881 scan_file_deallocate - 57026 + 57015 scan_file_delayed_allocate - 101892 + 101881 scan_file_insert - 101892 + 101881 scan_file_keep - 1025539 + 1025550 scan_file_refresh - 79205 + 79194 scan_file_remove - 57026 + 57015 scan_link diff --git a/cov/cmdline/scan.c.gcov.html b/cov/cmdline/scan.c.gcov.html index 4e68bddc..1e9ebb3c 100644 --- a/cov/cmdline/scan.c.gcov.html +++ b/cov/cmdline/scan.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 23 @@ -220,42 +220,42 @@ 158 : /** 159 : * Insert the specified file in the parity. 160 : */ - 161 101892 : static void scan_file_allocate(struct snapraid_scan* scan, struct snapraid_file* file) + 161 101881 : static void scan_file_allocate(struct snapraid_scan* scan, struct snapraid_file* file) 162 : { - 163 101892 : struct snapraid_state* state = scan->state; - 164 101892 : struct snapraid_disk* disk = scan->disk; + 163 101881 : struct snapraid_state* state = scan->state; + 164 101881 : struct snapraid_disk* disk = scan->disk; 165 : block_off_t i; 166 : block_off_t parity_pos; 167 : 168 : /* state changed */ - 169 101892 : state->need_write = 1; + 169 101881 : state->need_write = 1; 170 : 171 : /* allocate the blocks of the file */ - 172 101892 : parity_pos = disk->first_free_block; - 173 353160 : for (i = 0; i < file->blockmax; ++i) { + 172 101881 : parity_pos = disk->first_free_block; + 173 353073 : for (i = 0; i < file->blockmax; ++i) { 174 : struct snapraid_block* block; 175 : struct snapraid_block* over_block; 176 : snapraid_info info; 177 : 178 : /* increment the position until the first really free block */ - 179 1022825 : while (block_has_file(fs_par2block_find(disk, parity_pos))) - 180 520289 : ++parity_pos; + 179 1022715 : while (block_has_file(fs_par2block_find(disk, parity_pos))) + 180 520331 : ++parity_pos; 181 : 182 : /* get block we are going to overwrite, if any */ - 183 251268 : over_block = fs_par2block_find(disk, parity_pos); + 183 251192 : over_block = fs_par2block_find(disk, parity_pos); 184 : 185 : /* deallocate it */ - 186 251268 : if (over_block != BLOCK_NULL) - 187 95355 : fs_deallocate(disk, parity_pos); + 186 251192 : if (over_block != BLOCK_NULL) + 187 95279 : fs_deallocate(disk, parity_pos); 188 : 189 : /* get block specific info */ - 190 251268 : info = info_get(&state->infoarr, parity_pos); + 190 251192 : info = info_get(&state->infoarr, parity_pos); 191 : 192 : /* get the new block we are going to write */ - 193 251268 : block = fs_file2block_get(file, i); + 193 251192 : block = fs_file2block_get(file, i); 194 : 195 : /* if the file block already has an updated hash without rehash */ - 196 251268 : if (block_has_updated_hash(block) && !info_get_rehash(info)) { + 196 251192 : if (block_has_updated_hash(block) && !info_get_rehash(info)) { 197 : /* the only possible case is for REP blocks */ 198 86215 : assert(block_state_get(block) == BLOCK_STATE_REP); 199 : @@ -267,25 +267,25 @@ 205 : unsigned over_state; 206 : 207 : /* convert to a CHG block */ - 208 165053 : block_state_set(block, BLOCK_STATE_CHG); + 208 164977 : block_state_set(block, BLOCK_STATE_CHG); 209 : 210 : /* state of the block we are going to overwrite */ - 211 165053 : over_state = block_state_get(over_block); + 211 164977 : over_state = block_state_get(over_block); 212 : 213 : /* if the block is an empty one */ - 214 165053 : if (over_state == BLOCK_STATE_EMPTY) { + 214 164977 : if (over_state == BLOCK_STATE_EMPTY) { 215 : /* the block was empty and filled with zeros */ 216 : /* set the hash to the special ZERO value */ 217 115543 : hash_zero_set(block->hash); 218 : } else { 219 : /* otherwise it's a DELETED one */ - 220 49510 : assert(over_state == BLOCK_STATE_DELETED); + 220 49434 : assert(over_state == BLOCK_STATE_DELETED); 221 : 222 : /* copy the past hash of the block */ - 223 49510 : memcpy(block->hash, over_block->hash, BLOCK_HASH_SIZE); + 223 49434 : memcpy(block->hash, over_block->hash, BLOCK_HASH_SIZE); 224 : 225 : /* if we have not already cleared the past hash */ - 226 49510 : if (!state->clear_past_hash) { + 226 49434 : if (!state->clear_past_hash) { 227 : /* in this case we don't know if the old state is still the one */ 228 : /* stored inside the parity, because after an aborted sync, the parity */ 229 : /* may be or may be not have been updated with the new data */ @@ -302,15 +302,15 @@ 240 : } 241 : 242 : /* store in the disk map, after invalidating all the other blocks */ - 243 251268 : fs_allocate(disk, parity_pos, file, i); + 243 251192 : fs_allocate(disk, parity_pos, file, i); 244 : 245 : /* set the new free position */ - 246 251268 : disk->first_free_block = parity_pos + 1; + 246 251192 : disk->first_free_block = parity_pos + 1; 247 : } 248 : 249 : /* insert in the list of contained files */ - 250 101892 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); - 251 101892 : } + 250 101881 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); + 251 101881 : } 252 : 253 : /** 254 : * Delete the specified file from the parity. @@ -319,23 +319,23 @@ 257 : * The file is then inserted in the deleted set, and it should not be deallocated, 258 : * as the parity still references it. 259 : */ - 260 57026 : static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_file* file) + 260 57015 : static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_file* file) 261 : { - 262 57026 : struct snapraid_state* state = scan->state; - 263 57026 : struct snapraid_disk* disk = scan->disk; + 262 57015 : struct snapraid_state* state = scan->state; + 263 57015 : struct snapraid_disk* disk = scan->disk; 264 : block_off_t i; 265 : 266 : /* remove from the list of contained files */ - 267 57026 : tommy_list_remove_existing(&disk->filelist, &file->nodelist); + 267 57015 : tommy_list_remove_existing(&disk->filelist, &file->nodelist); 268 : 269 : /* state changed */ - 270 57026 : state->need_write = 1; + 270 57015 : state->need_write = 1; 271 : 272 : /* here we are supposed to adjust the ::first_free_block position */ 273 : /* with the parity position we are deleting */ 274 : /* but we also know that we do only delayed insert, after all the deletion, */ 275 : /* so at this point ::first_free_block is always at 0, and we don't need to update it */ - 276 57026 : if (disk->first_free_block != 0) { + 276 57015 : if (disk->first_free_block != 0) { 277 : /* LCOV_EXCL_START */ 278 : log_fatal("Internal inconsistency for first free position at '%u' deallocating file '%s'\n", disk->first_free_block, file->sub); 279 : os_abort(); @@ -343,17 +343,17 @@ 281 : } 282 : 283 : /* free all the blocks of the file */ - 284 197679 : for (i = 0; i < file->blockmax; ++i) { - 285 140653 : struct snapraid_block* block = fs_file2block_get(file, i); + 284 197592 : for (i = 0; i < file->blockmax; ++i) { + 285 140577 : struct snapraid_block* block = fs_file2block_get(file, i); 286 : unsigned block_state; 287 : 288 : /* in case we scan after an aborted sync, */ 289 : /* we could get also intermediate states */ - 290 140653 : block_state = block_state_get(block); - 291 140653 : switch (block_state) { + 290 140577 : block_state = block_state_get(block); + 291 140577 : switch (block_state) { 292 : case BLOCK_STATE_BLK : 293 : /* we keep the hash making it an "old" hash, because the parity is still containing data for it */ - 294 35656 : break; + 294 35580 : break; 295 : case BLOCK_STATE_CHG : 296 : /* if we have not already cleared the past hash */ 297 28040 : if (!state->clear_past_hash) { @@ -383,23 +383,23 @@ 321 : } 322 : 323 : /* set the block as deleted */ - 324 140653 : block_state_set(block, BLOCK_STATE_DELETED); + 324 140577 : block_state_set(block, BLOCK_STATE_DELETED); 325 : } 326 : 327 : /* mark the file as deleted */ - 328 57026 : file_flag_set(file, FILE_IS_DELETED); + 328 57015 : file_flag_set(file, FILE_IS_DELETED); 329 : 330 : /* insert it in the list of deleted blocks */ - 331 57026 : tommy_list_insert_tail(&disk->deletedlist, &file->nodelist, file); - 332 57026 : } + 331 57015 : tommy_list_insert_tail(&disk->deletedlist, &file->nodelist, file); + 332 57015 : } 333 : - 334 101892 : static void scan_file_delayed_allocate(struct snapraid_scan* scan, struct snapraid_file* file) + 334 101881 : static void scan_file_delayed_allocate(struct snapraid_scan* scan, struct snapraid_file* file) 335 : { - 336 101892 : struct snapraid_state* state = scan->state; - 337 101892 : struct snapraid_disk* disk = scan->disk; + 336 101881 : struct snapraid_state* state = scan->state; + 337 101881 : struct snapraid_disk* disk = scan->disk; 338 : 339 : /* if we sort for physical offsets we have to read them for new files */ - 340 101892 : if (state->opt.force_order == SORT_PHYSICAL + 340 101881 : if (state->opt.force_order == SORT_PHYSICAL 341 11432 : && file->physical == FILEPHY_UNREAD_OFFSET 342 : ) { 343 : char path_next[PATH_MAX]; @@ -415,30 +415,30 @@ 353 : } 354 : 355 : /* insert in the delayed list */ - 356 101892 : tommy_list_insert_tail(&scan->file_insert_list, &file->nodelist, file); - 357 101892 : } + 356 101881 : tommy_list_insert_tail(&scan->file_insert_list, &file->nodelist, file); + 357 101881 : } 358 : 359 : /** 360 : * Check if a file is completely formed of blocks with invalid parity, 361 : * and no rehash is tagged, and if it has at least one block. 362 : */ - 363 1025539 : static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) + 363 1025550 : static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) 364 : { 365 : block_off_t i; 366 : 367 : /* with no block, it never has an invalid parity */ - 368 1025539 : if (file->blockmax == 0) - 369 1437 : return 0; + 368 1025550 : if (file->blockmax == 0) + 369 1439 : return 0; 370 : 371 : /* check all blocks */ - 372 1080070 : for (i = 0; i < file->blockmax; ++i) { + 372 1080079 : for (i = 0; i < file->blockmax; ++i) { 373 : snapraid_info info; - 374 1057383 : struct snapraid_block* block = fs_file2block_get(file, i); + 374 1057392 : struct snapraid_block* block = fs_file2block_get(file, i); 375 : block_off_t parity_pos; 376 : 377 : /* exclude blocks with parity */ - 378 1057383 : if (!block_has_invalid_parity(block)) - 379 1001415 : return 0; + 378 1057392 : if (!block_has_invalid_parity(block)) + 379 1001424 : return 0; 380 : 381 : /* 382 : * Get the parity position. @@ -525,7 +525,7 @@ 463 : * 464 : * If this happens, we read also the physical offset, to avoid to read it later. 465 : */ - 466 79205 : static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struct stat* st, uint64_t* physical) + 466 79194 : static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struct stat* st, uint64_t* physical) 467 : { 468 : #if HAVE_LSTAT_SYNC 469 : struct snapraid_state* state = scan->state; @@ -597,43 +597,43 @@ 535 : (void)st; 536 : (void)physical; 537 : #endif - 538 79205 : } + 538 79194 : } 539 : 540 : /** 541 : * Insert the file in the data set. 542 : */ - 543 101892 : static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* file) + 543 101881 : static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* file) 544 : { - 545 101892 : struct snapraid_disk* disk = scan->disk; + 545 101881 : struct snapraid_disk* disk = scan->disk; 546 : 547 : /* insert the file in the containers */ - 548 101892 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) - 549 101892 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 550 101892 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); - 551 101892 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); + 548 101881 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) + 549 101881 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 550 101881 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); + 551 101881 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); 552 : 553 : /* delayed allocation of the parity */ - 554 101892 : scan_file_delayed_allocate(scan, file); - 555 101892 : } + 554 101881 : scan_file_delayed_allocate(scan, file); + 555 101881 : } 556 : 557 : /** 558 : * Remove the file from the data set. 559 : * 560 : * File is then deleted. 561 : */ - 562 57026 : static void scan_file_remove(struct snapraid_scan* scan, struct snapraid_file* file) + 562 57015 : static void scan_file_remove(struct snapraid_scan* scan, struct snapraid_file* file) 563 : { - 564 57026 : struct snapraid_disk* disk = scan->disk; + 564 57015 : struct snapraid_disk* disk = scan->disk; 565 : 566 : /* remove the file from the containers */ - 567 57026 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) - 568 56974 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); - 569 57026 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); - 570 57026 : tommy_hashdyn_remove_existing(&disk->stampset, &file->stampset); + 567 57015 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) + 568 56941 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 569 57015 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); + 570 57015 : tommy_hashdyn_remove_existing(&disk->stampset, &file->stampset); 571 : 572 : /* deallocate the file from the parity */ - 573 57026 : scan_file_deallocate(scan, file); - 574 57026 : } + 573 57015 : scan_file_deallocate(scan, file); + 574 57015 : } 575 : 576 : /** 577 : * Keep the file as it's (or with only a name/inode modification). @@ -646,12 +646,12 @@ 584 : * This could happen after a failed sync, when some other files are deleted, 585 : * and then new ones can be moved backward to fill the hole created. 586 : */ - 587 1025539 : static void scan_file_keep(struct snapraid_scan* scan, struct snapraid_file* file) + 587 1025550 : static void scan_file_keep(struct snapraid_scan* scan, struct snapraid_file* file) 588 : { - 589 1025539 : struct snapraid_disk* disk = scan->disk; + 589 1025550 : struct snapraid_disk* disk = scan->disk; 590 : 591 : /* if the file is full invalid, schedule a reinsert at later stage */ - 592 1025539 : if (file_is_full_invalid_parity_and_stable(scan->state, disk, file)) { + 592 1025550 : if (file_is_full_invalid_parity_and_stable(scan->state, disk, file)) { 593 22687 : struct snapraid_file* copy = file_dup(file); 594 : 595 : /* remove the file */ @@ -660,7 +660,7 @@ 598 : /* reinsert the copy in the delayed list */ 599 22687 : scan_file_insert(scan, copy); 600 : } - 601 1025539 : } + 601 1025550 : } 602 : 603 : /** 604 : * Process a file. @@ -717,9 +717,9 @@ 655 : /* identify moved files with past inodes and hardlinks with the new inodes */ 656 1104939 : if (file) { 657 : /* check if the file is not changed */ - 658 949678 : if (file->size == st->st_size - 659 935913 : && file->mtime_sec == st->st_mtime - 660 932896 : && (file->mtime_nsec == STAT_NSEC(st) + 658 943901 : if (file->size == st->st_size + 659 935613 : && file->mtime_sec == st->st_mtime + 660 932556 : && (file->mtime_nsec == STAT_NSEC(st) 661 : /* always accept the stored value if it's STAT_NSEC_INVALID */ 662 : /* it happens when upgrading from an old version of SnapRAID */ 663 : /* not yet supporting the nanosecond field */ @@ -727,7 +727,7 @@ 665 : ) 666 : ) { 667 : /* check if multiple files have the same inode */ - 668 932895 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 668 932555 : if (file_flag_has(file, FILE_IS_PRESENT)) { 669 : #if HAVE_STRUCT_STAT_ST_NLINK 670 195 : if (st->st_nlink <= 1) { 671 : /* LCOV_EXCL_START */ @@ -742,11 +742,11 @@ 680 : } 681 : 682 : /* mark as present */ - 683 932700 : file_flag_set(file, FILE_IS_PRESENT); + 683 932360 : file_flag_set(file, FILE_IS_PRESENT); 684 : 685 : /* update the nanoseconds mtime only if different */ 686 : /* to avoid unneeded updates */ - 687 932700 : if (file->mtime_nsec == STAT_NSEC_INVALID + 687 932360 : if (file->mtime_nsec == STAT_NSEC_INVALID 688 0 : && STAT_NSEC(st) != file->mtime_nsec 689 : ) { 690 0 : file->mtime_nsec = STAT_NSEC(st); @@ -755,7 +755,7 @@ 693 0 : state->need_write = 1; 694 : } 695 : - 696 932700 : if (strcmp(file->sub, sub) != 0) { + 696 932360 : if (strcmp(file->sub, sub) != 0) { 697 : /* if the path is different, it means a moved file with the same inode */ 698 155 : ++scan->count_move; 699 : @@ -777,18 +777,18 @@ 715 155 : state->need_write = 1; 716 : } else { 717 : /* otherwise it's equal */ - 718 932545 : ++scan->count_equal; + 718 932205 : ++scan->count_equal; 719 : - 720 932545 : if (state->opt.gui) { + 720 932205 : if (state->opt.gui) { 721 22611 : log_tag("scan:equal:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); 722 : } 723 : } 724 : 725 : /* mark the file as kept */ - 726 932700 : scan_file_keep(scan, file); + 726 932360 : scan_file_keep(scan, file); 727 : 728 : /* nothing more to do */ - 729 932700 : return; + 729 932360 : return; 730 : } 731 : 732 : /* here the file matches the inode, but not the other info */ @@ -797,7 +797,7 @@ 735 : /* or a file-system with not persistent inodes */ 736 : 737 : /* for sure it cannot be already present */ - 738 16783 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 738 11346 : if (file_flag_has(file, FILE_IS_PRESENT)) { 739 : /* LCOV_EXCL_START */ 740 : log_fatal("Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' matching and already present but different\n", file->inode, disk->dir, sub, disk->dir, file->sub); 741 : os_abort(); @@ -810,44 +810,44 @@ 748 : /* otherwise, it will get removed */ 749 : 750 : /* remove from the inode set */ - 751 16783 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 751 11346 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); 752 : 753 : /* clear the inode */ 754 : /* this is not really needed for correct functionality */ 755 : /* because we are going to set FILE_IS_WITHOUT_INODE */ 756 : /* but it's easier for debugging to have invalid inodes set to 0 */ - 757 16783 : file->inode = 0; + 757 11346 : file->inode = 0; 758 : 759 : /* mark as missing inode */ - 760 16783 : file_flag_set(file, FILE_IS_WITHOUT_INODE); + 760 11346 : file_flag_set(file, FILE_IS_WITHOUT_INODE); 761 : 762 : /* go further to find it by name */ 763 : } 764 : 765 : /* initialize for later overwrite */ - 766 172044 : is_file_reported = 0; - 767 172044 : is_original_file_size_different_than_zero = 0; + 766 172384 : is_file_reported = 0; + 767 172384 : is_original_file_size_different_than_zero = 0; 768 : 769 : /* then try finding it by name */ - 770 172044 : file = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub, file_path_hash(sub)); + 770 172384 : file = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub, file_path_hash(sub)); 771 : 772 : /* keep track if the file already exists */ - 773 172044 : is_file_already_present = file != 0; + 773 172384 : is_file_already_present = file != 0; 774 : - 775 172044 : if (is_file_already_present) { + 775 172384 : if (is_file_already_present) { 776 : /* if the file is without an inode */ - 777 97531 : if (file_flag_has(file, FILE_IS_WITHOUT_INODE)) { + 777 97871 : if (file_flag_has(file, FILE_IS_WITHOUT_INODE)) { 778 : /* set it now */ - 779 16745 : file->inode = st->st_ino; + 779 11286 : file->inode = st->st_ino; 780 : 781 : /* insert in the set */ - 782 16745 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 782 11286 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); 783 : 784 : /* unmark as missing inode */ - 785 16745 : file_flag_clear(file, FILE_IS_WITHOUT_INODE); + 785 11286 : file_flag_clear(file, FILE_IS_WITHOUT_INODE); 786 : } else { 787 : /* here the inode has to be different, otherwise we would have found it before */ - 788 80786 : if (file->inode == st->st_ino) { + 788 86585 : if (file->inode == st->st_ino) { 789 : /* LCOV_EXCL_START */ 790 : log_fatal("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub); 791 : os_abort(); @@ -856,7 +856,7 @@ 794 : } 795 : 796 : /* for sure it cannot be already present */ - 797 97531 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 797 97871 : if (file_flag_has(file, FILE_IS_PRESENT)) { 798 : /* LCOV_EXCL_START */ 799 : log_fatal("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub); 800 : os_abort(); @@ -864,9 +864,9 @@ 802 : } 803 : 804 : /* check if the file is not changed */ - 805 97531 : if (file->size == st->st_size - 806 96935 : && file->mtime_sec == st->st_mtime - 807 92839 : && (file->mtime_nsec == STAT_NSEC(st) + 805 97871 : if (file->size == st->st_size + 806 97275 : && file->mtime_sec == st->st_mtime + 807 93190 : && (file->mtime_nsec == STAT_NSEC(st) 808 : /* always accept the stored value if it's STAT_NSEC_INVALID */ 809 : /* it happens when upgrading from an old version of SnapRAID */ 810 : /* not yet supporting the nanosecond field */ @@ -874,11 +874,11 @@ 812 : ) 813 : ) { 814 : /* mark as present */ - 815 92839 : file_flag_set(file, FILE_IS_PRESENT); + 815 93190 : file_flag_set(file, FILE_IS_PRESENT); 816 : 817 : /* update the nano seconds mtime only if different */ 818 : /* to avoid unneeded updates */ - 819 92839 : if (file->mtime_nsec == STAT_NSEC_INVALID + 819 93190 : if (file->mtime_nsec == STAT_NSEC_INVALID 820 0 : && STAT_NSEC(st) != STAT_NSEC_INVALID 821 : ) { 822 0 : file->mtime_nsec = STAT_NSEC(st); @@ -888,30 +888,30 @@ 826 : } 827 : 828 : /* if when processing the disk we used the past inodes values */ - 829 92839 : if (has_past_inodes) { + 829 93190 : if (has_past_inodes) { 830 : /* if persistent inodes are supported, we are sure that the inode number */ 831 : /* is now different, because otherwise the file would have been found */ 832 : /* when searching by inode. */ 833 : /* if the inode is different, it means a rewritten file with the same path */ 834 : /* like when restoring a backup that restores also the timestamp */ - 835 92825 : ++scan->count_restore; + 835 93176 : ++scan->count_restore; 836 : - 837 92825 : log_tag("scan:restore:%s:%s\n", disk->name, esc_tag(sub, esc_buffer)); - 838 92825 : if (is_diff) { + 837 93176 : log_tag("scan:restore:%s:%s\n", disk->name, esc_tag(sub, esc_buffer)); + 838 93176 : if (is_diff) { 839 0 : printf("restore %s\n", fmt_term(disk, sub, esc_buffer)); 840 : } 841 : 842 : /* remove from the inode set */ - 843 92825 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 843 93176 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); 844 : 845 : /* save the new inode */ - 846 92825 : file->inode = st->st_ino; + 846 93176 : file->inode = st->st_ino; 847 : 848 : /* reinsert in the inode set */ - 849 92825 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 849 93176 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); 850 : 851 : /* we have to save the new inode */ - 852 92825 : state->need_write = 1; + 852 93176 : state->need_write = 1; 853 : } else { 854 : /* otherwise it's the case of not persistent inode, where doesn't */ 855 : /* matter if the inode is different or equal, because they have no */ @@ -924,24 +924,24 @@ 862 : } 863 : 864 : /* mark the file as kept */ - 865 92839 : scan_file_keep(scan, file); + 865 93190 : scan_file_keep(scan, file); 866 : 867 : /* nothing more to do */ - 868 92839 : return; + 868 93190 : return; 869 : } 870 : 871 : /* here if the file is changed but with the correct name */ 872 : 873 : /* save the info for later printout */ - 874 4692 : file_already_present_size = file->size; - 875 4692 : file_already_present_mtime_sec = file->mtime_sec; - 876 4692 : file_already_present_mtime_nsec = file->mtime_nsec; + 874 4681 : file_already_present_size = file->size; + 875 4681 : file_already_present_mtime_sec = file->mtime_sec; + 876 4681 : file_already_present_mtime_nsec = file->mtime_nsec; 877 : 878 : /* keep track if the original file was not of zero size */ - 879 4692 : is_original_file_size_different_than_zero = file->size != 0; + 879 4681 : is_original_file_size_different_than_zero = file->size != 0; 880 : 881 : /* remove it, and continue to insert it again */ - 882 4692 : scan_file_remove(scan, file); + 882 4681 : scan_file_remove(scan, file); 883 : 884 : /* and continue to insert it again */ 885 : } else { @@ -953,13 +953,13 @@ 891 : /* refresh the info, to ensure that they are synced, */ 892 : /* note that we refresh only the info of the new or modified files */ 893 : /* because this is slow operation */ - 894 79205 : scan_file_refresh(scan, sub, st, &physical); + 894 79194 : scan_file_refresh(scan, sub, st, &physical); 895 : 896 : #ifndef _WIN32 897 : /* do a safety check to ensure that the common ext4 case of zeroing */ 898 : /* the size of a file after a crash doesn't propagate to the backup */ 899 : /* this check is specific for Linux, so we disable it on Windows */ - 900 79205 : if (is_original_file_size_different_than_zero && st->st_size == 0) { + 900 79194 : if (is_original_file_size_different_than_zero && st->st_size == 0) { 901 0 : if (!state->opt.force_zero) { 902 : /* LCOV_EXCL_START */ 903 : log_fatal("The file '%s%s' has unexpected zero size!\n", disk->dir, sub); @@ -978,33 +978,33 @@ 916 : #endif 917 : 918 : /* insert it */ - 919 79205 : file = file_alloc(state->block_size, sub, st->st_size, st->st_mtime, STAT_NSEC(st), st->st_ino, physical); + 919 79194 : file = file_alloc(state->block_size, sub, st->st_size, st->st_mtime, STAT_NSEC(st), st->st_ino, physical); 920 : 921 : /* mark it as present */ - 922 79205 : file_flag_set(file, FILE_IS_PRESENT); + 922 79194 : file_flag_set(file, FILE_IS_PRESENT); 923 : 924 : /* if copy detection is enabled */ 925 : /* note that the copy detection is tried also for updated files */ 926 : /* this makes sense because it may happen to have two different copies */ 927 : /* of the same file, and we move the right one over the wrong one */ 928 : /* in such case we have a "copy" over an "update" */ - 929 79205 : if (!state->opt.force_nocopy) { - 930 79205 : tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); + 929 79194 : if (!state->opt.force_nocopy) { + 930 79194 : tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); 931 : 932 : /* search for a file with the same name and stamp in all the disks */ - 933 423487 : for (i = state->disklist; i != 0; i = i->next) { - 934 367918 : struct snapraid_disk* other_disk = i->data; + 933 423410 : for (i = state->disklist; i != 0; i = i->next) { + 934 367852 : struct snapraid_disk* other_disk = i->data; 935 : struct snapraid_file* other_file; 936 : 937 : /* if the nanosecond part of the time stamp is valid, search */ 938 : /* for name and stamp, otherwise for path and stamp */ - 939 367918 : if (file->mtime_nsec != 0 && file->mtime_nsec != STAT_NSEC_INVALID) - 940 367810 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_namestamp_compare, file, hash); + 939 367852 : if (file->mtime_nsec != 0 && file->mtime_nsec != STAT_NSEC_INVALID) + 940 367744 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_namestamp_compare, file, hash); 941 : else 942 108 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_pathstamp_compare, file, hash); 943 : 944 : /* if found, and it's a fully hashed file */ - 945 367918 : if (other_file && file_is_full_hashed_and_stable(scan->state, other_disk, other_file)) { + 945 367852 : if (other_file && file_is_full_hashed_and_stable(scan->state, other_disk, other_file)) { 946 : /* assume that the file is a copy, and reuse the hash */ 947 23636 : file_copy(other_file, file); 948 : @@ -1027,16 +1027,16 @@ 965 : 966 : /* if not yet reported, do it now */ 967 : /* we postpone this to avoid to print two times the copied files */ - 968 79205 : if (!is_file_reported) { - 969 55569 : if (is_file_already_present) { - 970 4692 : ++scan->count_change; + 968 79194 : if (!is_file_reported) { + 969 55558 : if (is_file_already_present) { + 970 4681 : ++scan->count_change; 971 : - 972 14076 : log_tag("scan:update:%s:%s: %" PRIu64 " %" PRIu64 ".%d -> %" PRIu64 " %" PRIu64 ".%d\n", disk->name, esc_tag(sub, esc_buffer), + 972 14043 : log_tag("scan:update:%s:%s: %" PRIu64 " %" PRIu64 ".%d -> %" PRIu64 " %" PRIu64 ".%d\n", disk->name, esc_tag(sub, esc_buffer), 973 : (uint64_t)file_already_present_size, (uint64_t)file_already_present_mtime_sec, file_already_present_mtime_nsec, - 974 9384 : (uint64_t)file->size, (uint64_t)file->mtime_sec, file->mtime_nsec + 974 9362 : (uint64_t)file->size, (uint64_t)file->mtime_sec, file->mtime_nsec 975 : ); 976 : - 977 4692 : if (is_diff) { + 977 4681 : if (is_diff) { 978 118 : printf("update %s\n", fmt_term(disk, sub, esc_buffer)); 979 : } 980 : } else { @@ -1050,7 +1050,7 @@ 988 : } 989 : 990 : /* insert the file in the delayed list */ - 991 79205 : scan_file_insert(scan, file); + 991 79194 : scan_file_insert(scan, file); 992 : } 993 : 994 : /** @@ -1143,15 +1143,15 @@ 1081 : }; 1082 : 1083 : #if HAVE_STRUCT_DIRENT_D_INO - 1084 103398 : static int dd_ino_compare(const void* void_a, const void* void_b) + 1084 103390 : static int dd_ino_compare(const void* void_a, const void* void_b) 1085 : { - 1086 103398 : const struct dirent_sorted* a = void_a; - 1087 103398 : const struct dirent_sorted* b = void_b; + 1086 103390 : const struct dirent_sorted* a = void_a; + 1087 103390 : const struct dirent_sorted* b = void_b; 1088 : - 1089 103398 : if (a->d_ino < b->d_ino) - 1090 49440 : return -1; - 1091 53958 : if (a->d_ino > b->d_ino) - 1092 53958 : return 1; + 1089 103390 : if (a->d_ino < b->d_ino) + 1090 49438 : return -1; + 1091 53952 : if (a->d_ino > b->d_ino) + 1092 53952 : return 1; 1093 : 1094 0 : return 0; 1095 : } @@ -1584,14 +1584,14 @@ 1522 : 1523 : /* check for removed files */ 1524 575 : node = disk->filelist; - 1525 1033649 : while (node) { - 1526 1032499 : struct snapraid_file* file = node->data; + 1525 1033660 : while (node) { + 1526 1032510 : struct snapraid_file* file = node->data; 1527 : 1528 : /* next node */ - 1529 1032499 : node = node->next; + 1529 1032510 : node = node->next; 1530 : 1531 : /* remove if not present */ - 1532 1032499 : if (!file_flag_has(file, FILE_IS_PRESENT)) { + 1532 1032510 : if (!file_flag_has(file, FILE_IS_PRESENT)) { 1533 29647 : ++scan->count_remove; 1534 : 1535 29647 : log_tag("scan:remove:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer)); @@ -1664,11 +1664,11 @@ 1602 575 : phy_dup = 0; 1603 575 : phy_last = FILEPHY_UNREAD_OFFSET; 1604 575 : phy_file_last = 0; - 1605 103042 : while (node) { - 1606 101892 : struct snapraid_file* file = node->data; + 1605 103031 : while (node) { + 1606 101881 : struct snapraid_file* file = node->data; 1607 : 1608 : /* if the file is not empty, count duplicate physical offsets */ - 1609 101892 : if (state->opt.force_order == SORT_PHYSICAL && file->size != 0) { + 1609 101881 : if (state->opt.force_order == SORT_PHYSICAL && file->size != 0) { 1610 11418 : if (phy_file_last != 0 && file->physical == phy_last 1611 : /* files without offset are expected to have duplicates */ 1612 0 : && phy_last != FILEPHY_WITHOUT_OFFSET @@ -1686,10 +1686,10 @@ 1624 : } 1625 : 1626 : /* next node */ - 1627 101892 : node = node->next; + 1627 101881 : node = node->next; 1628 : 1629 : /* insert in the parity */ - 1630 101892 : scan_file_allocate(scan, file); + 1630 101881 : scan_file_allocate(scan, file); 1631 : } 1632 : 1633 : /* mark the disk without reliable physical offset if it has duplicates */ @@ -1805,7 +1805,7 @@ 1743 : } 1744 : } 1745 95 : if (done) { - 1746 0 : log_fatal(". Move operations won't be optimal.\n"); + 1746 0 : log_fatal(". Not using inodes to detect move operations.\n"); 1747 : } 1748 : 1749 : /* check for disks with changed UUID */ @@ -1827,7 +1827,7 @@ 1765 : } 1766 : } 1767 95 : if (done) { - 1768 2 : log_fatal(". Move operations won't be optimal.\n"); + 1768 2 : log_fatal(". Not using inodes to detect move operations.\n"); 1769 : } 1770 : 1771 : /* check for disks with unsupported UUID */ @@ -1845,7 +1845,7 @@ 1783 : } 1784 : } 1785 95 : if (done) { - 1786 0 : log_fatal(". Move operations won't be optimal.\n"); + 1786 0 : log_fatal(". Not using inodes to detect move operations.\n"); 1787 : #if defined(_linux) && !HAVE_BLKID 1788 : log_fatal("The 'blkid' library is not linked in SnapRAID!\n"); 1789 : log_fatal("Try rebuilding it after installing the libblkid-dev or libblkid-devel package.\n"); diff --git a/cov/cmdline/scrub.c.func-sort-c.html b/cov/cmdline/scrub.c.func-sort-c.html index b33d4412..2a8c6b02 100644 --- a/cov/cmdline/scrub.c.func-sort-c.html +++ b/cov/cmdline/scrub.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 @@ -61,11 +61,11 @@ scrub_parity_reader - 168187 + 168180 scrub_data_reader - 168181 + 168176 block_is_enabled diff --git a/cov/cmdline/scrub.c.func.html b/cov/cmdline/scrub.c.func.html index 1095dd1c..9e501fea 100644 --- a/cov/cmdline/scrub.c.func.html +++ b/cov/cmdline/scrub.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 @@ -69,11 +69,11 @@ scrub_data_reader - 168181 + 168176 scrub_parity_reader - 168187 + 168180 state_scrub diff --git a/cov/cmdline/scrub.c.gcov.html b/cov/cmdline/scrub.c.gcov.html index 7e95cfe0..c01a6687 100644 --- a/cov/cmdline/scrub.c.gcov.html +++ b/cov/cmdline/scrub.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 @@ -146,16 +146,16 @@ 84 56244 : blocktime = info_get_time(info); 85 56244 : if (blocktime > plan->timelimit) { 86 : /* skip it */ - 87 9574 : return 0; + 87 9582 : return 0; 88 : } 89 : 90 : /* if the time is less than the limit, always include */ 91 : /* otherwise, check if we reached the last limit count */ - 92 46670 : if (blocktime == plan->timelimit) { + 92 46662 : if (blocktime == plan->timelimit) { 93 : /* if we reached the count limit */ - 94 30132 : if (plan->countlast >= plan->lastlimit) { + 94 30124 : if (plan->countlast >= plan->lastlimit) { 95 : /* skip it */ - 96 24940 : return 0; + 96 24932 : return 0; 97 : } 98 : 99 5192 : ++plan->countlast; @@ -164,19 +164,19 @@ 102 21730 : return 1; 103 : } 104 : - 105 168181 : static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) + 105 168176 : static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) 106 : { - 107 168181 : struct snapraid_io* io = worker->io; - 108 168181 : struct snapraid_state* state = io->state; - 109 168181 : struct snapraid_handle* handle = worker->handle; - 110 168181 : struct snapraid_disk* disk = handle->disk; - 111 168181 : block_off_t blockcur = task->position; - 112 168181 : unsigned char* buffer = task->buffer; + 107 168176 : struct snapraid_io* io = worker->io; + 108 168176 : struct snapraid_state* state = io->state; + 109 168176 : struct snapraid_handle* handle = worker->handle; + 110 168176 : struct snapraid_disk* disk = handle->disk; + 111 168176 : block_off_t blockcur = task->position; + 112 168176 : unsigned char* buffer = task->buffer; 113 : int ret; 114 : char esc_buffer[ESC_MAX]; 115 : 116 : /* if the disk position is not used */ - 117 168181 : if (!disk) { + 117 168176 : if (!disk) { 118 : /* use an empty block */ 119 0 : memset(buffer, 0, state->block_size); 120 0 : task->state = TASK_STATE_DONE; @@ -184,10 +184,10 @@ 122 : } 123 : 124 : /* get the block */ - 125 168181 : task->block = fs_par2block_find(disk, blockcur); + 125 168176 : task->block = fs_par2block_find(disk, blockcur); 126 : 127 : /* if the block is not used */ - 128 168157 : if (!block_has_file(task->block)) { + 128 168151 : if (!block_has_file(task->block)) { 129 : /* use an empty block */ 130 1585 : memset(buffer, 0, state->block_size); 131 1585 : task->state = TASK_STATE_DONE; @@ -195,14 +195,14 @@ 133 : } 134 : 135 : /* get the file of this block */ - 136 166558 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); + 136 166552 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); 137 : 138 : /* if the file is different than the current one, close it */ - 139 166581 : if (handle->file != 0 && handle->file != task->file) { + 139 166584 : if (handle->file != 0 && handle->file != task->file) { 140 : /* keep a pointer at the file we are going to close for error reporting */ - 141 78085 : struct snapraid_file* report = handle->file; - 142 78085 : ret = handle_close(handle); - 143 78044 : if (ret == -1) { + 141 78061 : struct snapraid_file* report = handle->file; + 142 78061 : ret = handle_close(handle); + 143 78037 : if (ret == -1) { 144 : /* LCOV_EXCL_START */ 145 : /* This one is really an unexpected error, because we are only reading */ 146 : /* and closing a descriptor should never fail */ @@ -225,8 +225,8 @@ 163 : } 164 : } 165 : - 166 166540 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); - 167 166589 : if (ret == -1) { + 166 166560 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); + 167 166583 : if (ret == -1) { 168 0 : if (errno == EIO) { 169 : /* LCOV_EXCL_START */ 170 : log_tag("error:%u:%s:%s: Open EIO error. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno)); @@ -244,9 +244,9 @@ 182 : } 183 : 184 : /* check if the file is changed */ - 185 166589 : if (handle->st.st_size != task->file->size + 185 166583 : if (handle->st.st_size != task->file->size 186 166587 : || handle->st.st_mtime != task->file->mtime_sec - 187 160995 : || STAT_NSEC(&handle->st) != task->file->mtime_nsec + 187 160985 : || STAT_NSEC(&handle->st) != task->file->mtime_nsec 188 : /* don't check the inode to support filesystem without persistent inodes */ 189 : ) { 190 : /* report that the block and the file are not synced */ @@ -258,8 +258,8 @@ 196 : /* from the last sync, as we are expected to return errors if running */ 197 : /* in an unsynced array. This is just like the check command. */ 198 : - 199 166589 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); - 200 166506 : if (task->read_size == -1) { + 199 166583 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); + 200 166507 : if (task->read_size == -1) { 201 0 : if (errno == EIO) { 202 0 : log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno)); 203 0 : log_error("Input/Output error in file '%s' at position '%u'\n", handle->path, task->file_pos); @@ -273,24 +273,24 @@ 211 : } 212 : 213 : /* store the path of the opened file */ - 214 166506 : pathcpy(task->path, sizeof(task->path), handle->path); + 214 166507 : pathcpy(task->path, sizeof(task->path), handle->path); 215 : - 216 166569 : task->state = TASK_STATE_DONE; + 216 166554 : task->state = TASK_STATE_DONE; 217 : } 218 : - 219 168187 : static void scrub_parity_reader(struct snapraid_worker* worker, struct snapraid_task* task) + 219 168180 : static void scrub_parity_reader(struct snapraid_worker* worker, struct snapraid_task* task) 220 : { - 221 168187 : struct snapraid_io* io = worker->io; - 222 168187 : struct snapraid_state* state = io->state; - 223 168187 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; - 224 168187 : unsigned level = parity_handle->level; - 225 168187 : block_off_t blockcur = task->position; - 226 168187 : unsigned char* buffer = task->buffer; + 221 168180 : struct snapraid_io* io = worker->io; + 222 168180 : struct snapraid_state* state = io->state; + 223 168180 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; + 224 168180 : unsigned level = parity_handle->level; + 225 168180 : block_off_t blockcur = task->position; + 226 168180 : unsigned char* buffer = task->buffer; 227 : int ret; 228 : 229 : /* read the parity */ - 230 168187 : ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error); - 231 168166 : if (ret == -1) { + 230 168180 : ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error); + 231 168156 : if (ret == -1) { 232 0 : if (errno == EIO) { 233 0 : log_tag("parity_error:%u:%s: Read EIO error. %s\n", blockcur, lev_config_name(level), strerror(errno)); 234 0 : log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(level), blockcur); @@ -303,7 +303,7 @@ 241 0 : return; 242 : } 243 : - 244 168166 : task->state = TASK_STATE_DONE; + 244 168156 : task->state = TASK_STATE_DONE; 245 : } 246 : 247 11 : static int state_scrub_process(struct snapraid_state* state, struct snapraid_parity_handle* parity_handle, block_off_t blockstart, block_off_t blockmax, struct snapraid_plan* plan, time_t now) @@ -880,12 +880,12 @@ 818 : /* output the info map */ 819 11 : i = 0; 820 11 : log_tag("info_count:%u\n", count); - 821 41 : while (i < count) { - 822 19 : unsigned j = i + 1; - 823 56104 : while (j < count && timemap[i] == timemap[j]) - 824 56066 : ++j; - 825 19 : log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)timemap[i], j - i); - 826 19 : i = j; + 821 45 : while (i < count) { + 822 23 : unsigned j = i + 1; + 823 56108 : while (j < count && timemap[i] == timemap[j]) + 824 56062 : ++j; + 825 23 : log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)timemap[i], j - i); + 826 23 : i = j; 827 : } 828 : 829 : /* compute the limits from count/recentlimit */ diff --git a/cov/cmdline/search.c.func-sort-c.html b/cov/cmdline/search.c.func-sort-c.html index 80b5a3f0..031e5215 100644 --- a/cov/cmdline/search.c.func-sort-c.html +++ b/cov/cmdline/search.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -61,19 +61,19 @@ search_file - 1843909 + 1843968 search_file_free - 1843909 + 1843968 state_search_fetch - 638916 + 638616 search_file_compare - 20183 + 20133 search_dir diff --git a/cov/cmdline/search.c.func.html b/cov/cmdline/search.c.func.html index 2dfdb1be..9631a1e2 100644 --- a/cov/cmdline/search.c.func.html +++ b/cov/cmdline/search.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -65,15 +65,15 @@ search_file - 1843909 + 1843968 search_file_compare - 20183 + 20133 search_file_free - 1843909 + 1843968 state_search @@ -85,7 +85,7 @@ state_search_fetch - 638916 + 638616
diff --git a/cov/cmdline/search.c.gcov.html b/cov/cmdline/search.c.gcov.html index 86339e03..3485994f 100644 --- a/cov/cmdline/search.c.gcov.html +++ b/cov/cmdline/search.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -85,27 +85,27 @@ 23 : /****************************************************************************/ 24 : /* search */ 25 : - 26 1843909 : static void search_file(struct snapraid_state* state, const char* path, data_off_t size, int64_t mtime_sec, int mtime_nsec) + 26 1843968 : static void search_file(struct snapraid_state* state, const char* path, data_off_t size, int64_t mtime_sec, int mtime_nsec) 27 : { 28 : struct snapraid_search_file* file; 29 : tommy_uint32_t file_hash; 30 : - 31 1843909 : file = malloc_nofail(sizeof(struct snapraid_search_file)); - 32 1843909 : file->path = strdup_nofail(path); - 33 1843909 : file->size = size; - 34 1843909 : file->mtime_sec = mtime_sec; - 35 1843909 : file->mtime_nsec = mtime_nsec; + 31 1843968 : file = malloc_nofail(sizeof(struct snapraid_search_file)); + 32 1843968 : file->path = strdup_nofail(path); + 33 1843968 : file->size = size; + 34 1843968 : file->mtime_sec = mtime_sec; + 35 1843968 : file->mtime_nsec = mtime_nsec; 36 : - 37 1843909 : file_hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); + 37 1843968 : file_hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); 38 : - 39 1843909 : tommy_hashdyn_insert(&state->searchset, &file->node, file, file_hash); - 40 1843909 : } + 39 1843968 : tommy_hashdyn_insert(&state->searchset, &file->node, file, file_hash); + 40 1843968 : } 41 : - 42 1843909 : void search_file_free(struct snapraid_search_file* file) + 42 1843968 : void search_file_free(struct snapraid_search_file* file) 43 : { - 44 1843909 : free(file->path); - 45 1843909 : free(file); - 46 1843909 : } + 44 1843968 : free(file->path); + 45 1843968 : free(file); + 46 1843968 : } 47 : 48 : struct search_file_compare_arg { 49 : const struct snapraid_state* state; @@ -117,29 +117,29 @@ 55 : int prevhash; 56 : }; 57 : - 58 20183 : int search_file_compare(const void* void_arg, const void* void_data) + 58 20133 : int search_file_compare(const void* void_arg, const void* void_data) 59 : { - 60 20183 : const struct search_file_compare_arg* arg = void_arg; - 61 20183 : const struct snapraid_search_file* file = void_data; - 62 20183 : const struct snapraid_state* state = arg->state; + 60 20133 : const struct search_file_compare_arg* arg = void_arg; + 61 20133 : const struct snapraid_search_file* file = void_data; + 62 20133 : const struct snapraid_state* state = arg->state; 63 : unsigned char buffer_hash[HASH_MAX]; - 64 20183 : const char* path = file->path; + 64 20133 : const char* path = file->path; 65 : int f; 66 : ssize_t ret; 67 : 68 : /* compare file info */ - 69 20183 : if (arg->file->size != file->size) + 69 20133 : if (arg->file->size != file->size) 70 0 : return -1; 71 : - 72 20183 : if (arg->file->mtime_sec != file->mtime_sec) + 72 20133 : if (arg->file->mtime_sec != file->mtime_sec) 73 0 : return -1; 74 : - 75 20183 : if (arg->file->mtime_nsec != file->mtime_nsec) + 75 20133 : if (arg->file->mtime_nsec != file->mtime_nsec) 76 0 : return -1; 77 : 78 : /* read the block and compare the hash */ - 79 20183 : f = open(path, O_RDONLY | O_BINARY); - 80 20183 : if (f == -1) { + 79 20133 : f = open(path, O_RDONLY | O_BINARY); + 80 20133 : if (f == -1) { 81 : /* LCOV_EXCL_START */ 82 : if (errno == ENOENT) { 83 : log_fatal("DANGER! file '%s' disappeared.\n", path); @@ -151,16 +151,16 @@ 89 : /* LCOV_EXCL_STOP */ 90 : } 91 : - 92 20183 : ret = pread(f, arg->buffer, arg->read_size, arg->offset); - 93 20183 : if (ret < 0 || (unsigned)ret != arg->read_size) { + 92 20133 : ret = pread(f, arg->buffer, arg->read_size, arg->offset); + 93 20133 : if (ret < 0 || (unsigned)ret != arg->read_size) { 94 : /* LCOV_EXCL_START */ 95 : log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno)); 96 : exit(EXIT_FAILURE); 97 : /* LCOV_EXCL_STOP */ 98 : } 99 : - 100 20183 : ret = close(f); - 101 20183 : if (ret != 0) { + 100 20133 : ret = close(f); + 101 20133 : if (ret != 0) { 102 : /* LCOV_EXCL_START */ 103 : log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno)); 104 : exit(EXIT_FAILURE); @@ -168,14 +168,14 @@ 106 : } 107 : 108 : /* compute the hash */ - 109 20183 : if (arg->prevhash) + 109 20133 : if (arg->prevhash) 110 0 : memhash(state->prevhash, state->prevhashseed, buffer_hash, arg->buffer, arg->read_size); 111 : else - 112 20183 : memhash(state->hash, state->hashseed, buffer_hash, arg->buffer, arg->read_size); + 112 20133 : memhash(state->hash, state->hashseed, buffer_hash, arg->buffer, arg->read_size); 113 : 114 : /* check if the hash is matching */ - 115 20183 : if (memcmp(buffer_hash, arg->block->hash, BLOCK_HASH_SIZE) != 0) - 116 2273 : return -1; + 115 20133 : if (memcmp(buffer_hash, arg->block->hash, BLOCK_HASH_SIZE) != 0) + 116 2223 : return -1; 117 : 118 17910 : if (arg->read_size != state->block_size) { 119 : /* fill the remaining with 0 */ @@ -185,26 +185,26 @@ 123 17910 : return 0; 124 : } 125 : - 126 638916 : int state_search_fetch(struct snapraid_state* state, int prevhash, struct snapraid_file* missing_file, block_off_t missing_file_pos, struct snapraid_block* missing_block, unsigned char* buffer) + 126 638616 : int state_search_fetch(struct snapraid_state* state, int prevhash, struct snapraid_file* missing_file, block_off_t missing_file_pos, struct snapraid_block* missing_block, unsigned char* buffer) 127 : { 128 : struct snapraid_search_file* file; 129 : tommy_uint32_t file_hash; 130 : struct search_file_compare_arg arg; 131 : - 132 638916 : arg.state = state; - 133 638916 : arg.block = missing_block; - 134 638916 : arg.file = missing_file; - 135 638916 : arg.buffer = buffer; - 136 638916 : arg.offset = state->block_size * (data_off_t)missing_file_pos; - 137 638916 : arg.read_size = file_block_size(missing_file, missing_file_pos, state->block_size); - 138 638916 : arg.prevhash = prevhash; + 132 638616 : arg.state = state; + 133 638616 : arg.block = missing_block; + 134 638616 : arg.file = missing_file; + 135 638616 : arg.buffer = buffer; + 136 638616 : arg.offset = state->block_size * (data_off_t)missing_file_pos; + 137 638616 : arg.read_size = file_block_size(missing_file, missing_file_pos, state->block_size); + 138 638616 : arg.prevhash = prevhash; 139 : - 140 638916 : file_hash = file_stamp_hash(arg.file->size, arg.file->mtime_sec, arg.file->mtime_nsec); + 140 638616 : file_hash = file_stamp_hash(arg.file->size, arg.file->mtime_sec, arg.file->mtime_nsec); 141 : 142 : /* search in the hashtable, and also check if the data matches the hash */ - 143 638916 : file = tommy_hashdyn_search(&state->searchset, search_file_compare, &arg, file_hash); - 144 638916 : if (!file) - 145 621006 : return -1; + 143 638616 : file = tommy_hashdyn_search(&state->searchset, search_file_compare, &arg, file_hash); + 144 638616 : if (!file) + 145 620706 : return -1; 146 : 147 : /* if found, buffer is already set with data */ 148 17910 : return 0; @@ -226,40 +226,40 @@ 164 : char path_next[PATH_MAX]; 165 : char sub_next[PATH_MAX]; 166 : char out[PATH_MAX]; - 167 2040347 : struct snapraid_filter* reason = 0; + 167 2040368 : struct snapraid_filter* reason = 0; 168 : struct stat st; 169 : const char* name; 170 : struct dirent* dd; 171 : 172 : /* clear errno to detect erroneous conditions */ - 173 2040347 : errno = 0; - 174 2040347 : dd = readdir(d); - 175 2040347 : if (dd == 0 && errno != 0) { + 173 2040368 : errno = 0; + 174 2040368 : dd = readdir(d); + 175 2040368 : if (dd == 0 && errno != 0) { 176 : /* LCOV_EXCL_START */ 177 : log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno)); 178 : exit(EXIT_FAILURE); 179 : /* LCOV_EXCL_STOP */ 180 : } - 181 2040347 : if (dd == 0) { + 181 2040368 : if (dd == 0) { 182 2462 : break; /* finished */ 183 : } 184 : 185 : /* skip "." and ".." files */ - 186 2037885 : name = dd->d_name; - 187 2037885 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) + 186 2037906 : name = dd->d_name; + 187 2037906 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) 188 9848 : continue; 189 : - 190 2032961 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); - 191 2032961 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); + 190 2032982 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); + 191 2032982 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); 192 : 193 : /* exclude hidden files even before calling lstat() */ - 194 2032961 : if (disk != 0 && filter_hidden(state->filter_hidden, dd) != 0) { + 194 2032982 : if (disk != 0 && filter_hidden(state->filter_hidden, dd) != 0) { 195 0 : msg_verbose("Excluding hidden '%s'\n", path_next); 196 0 : continue; 197 : } 198 : 199 : /* exclude content files even before calling lstat() */ - 200 2032961 : if (disk != 0 && filter_content(&state->contentlist, path_next) != 0) { + 200 2032982 : if (disk != 0 && filter_content(&state->contentlist, path_next) != 0) { 201 0 : msg_verbose("Excluding content '%s'\n", path_next); 202 0 : continue; 203 : } @@ -283,7 +283,7 @@ 221 : } 222 : #else 223 : /* get lstat info about the file */ - 224 2032961 : if (lstat(path_next, &st) != 0) { + 224 2032982 : if (lstat(path_next, &st) != 0) { 225 : /* LCOV_EXCL_START */ 226 : log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno)); 227 : exit(EXIT_FAILURE); @@ -291,13 +291,13 @@ 229 : } 230 : #endif 231 : - 232 2032961 : if (S_ISREG(st.st_mode)) { - 233 1968636 : if (disk == 0 || filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 234 1843909 : search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st)); + 232 2032982 : if (S_ISREG(st.st_mode)) { + 233 1968671 : if (disk == 0 || filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 234 1843968 : search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st)); 235 : } else { - 236 124727 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 236 124703 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); 237 : } - 238 64325 : } else if (S_ISDIR(st.st_mode)) { + 238 64311 : } else if (S_ISDIR(st.st_mode)) { 239 1781 : if (disk == 0 || filter_subdir(&state->filterlist, &reason, disk->name, sub_next) == 0) { 240 1781 : pathslash(path_next, sizeof(path_next)); 241 1781 : pathslash(sub_next, sizeof(sub_next)); @@ -306,7 +306,7 @@ 244 0 : msg_verbose("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); 245 : } 246 : } - 247 2037885 : } + 247 2037906 : } 248 : 249 2462 : if (closedir(d) != 0) { 250 : /* LCOV_EXCL_START */ diff --git a/cov/cmdline/selftest.c.func-sort-c.html b/cov/cmdline/selftest.c.func-sort-c.html index 6e8c3643..65f3fb9d 100644 --- a/cov/cmdline/selftest.c.func-sort-c.html +++ b/cov/cmdline/selftest.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 diff --git a/cov/cmdline/selftest.c.func.html b/cov/cmdline/selftest.c.func.html index 513633b8..560f0b0f 100644 --- a/cov/cmdline/selftest.c.func.html +++ b/cov/cmdline/selftest.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 diff --git a/cov/cmdline/selftest.c.gcov.html b/cov/cmdline/selftest.c.gcov.html index 8a3bd625..0c7c4c26 100644 --- a/cov/cmdline/selftest.c.gcov.html +++ b/cov/cmdline/selftest.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 8 diff --git a/cov/cmdline/snapraid.c.func-sort-c.html b/cov/cmdline/snapraid.c.func-sort-c.html index 44738806..d95907bb 100644 --- a/cov/cmdline/snapraid.c.func-sort-c.html +++ b/cov/cmdline/snapraid.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 496 - 542 - 91.5 % + 497 + 544 + 91.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -61,30 +61,30 @@ test - 276 + 277 - main - 276 + main + 277 config - 275 + 276 log_open - 265 + 266 log_close - 242 + 243 memory - 237 + 238 - signal_init + signal_init 223 diff --git a/cov/cmdline/snapraid.c.func.html b/cov/cmdline/snapraid.c.func.html index 3ea7476c..07ec904e 100644 --- a/cov/cmdline/snapraid.c.func.html +++ b/cov/cmdline/snapraid.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 496 - 542 - 91.5 % + 497 + 544 + 91.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -61,31 +61,31 @@ config - 275 - - - log_close - 242 - - - log_open - 265 - - - main 276 - memory - 237 + log_close + 243 - signal_init + log_open + 266 + + + main + 277 + + + memory + 238 + + + signal_init 223 test - 276 + 277 usage diff --git a/cov/cmdline/snapraid.c.gcov.html b/cov/cmdline/snapraid.c.gcov.html index c470bc51..c3a2aff1 100644 --- a/cov/cmdline/snapraid.c.gcov.html +++ b/cov/cmdline/snapraid.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 496 - 542 - 91.5 % + 497 + 544 + 91.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -138,28 +138,28 @@ 76 1 : printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n"); 77 1 : } 78 : - 79 237 : void memory(void) + 79 238 : void memory(void) 80 : { - 81 237 : log_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter_get()); + 81 238 : log_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter_get()); 82 : 83 : /* size of the block */ - 84 237 : log_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block))); - 85 237 : log_tag("memory:extent:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_extent))); - 86 237 : log_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file))); - 87 237 : log_tag("memory:link:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_link))); - 88 237 : log_tag("memory:dir:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_dir))); + 84 238 : log_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block))); + 85 238 : log_tag("memory:extent:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_extent))); + 86 238 : log_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file))); + 87 238 : log_tag("memory:link:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_link))); + 88 238 : log_tag("memory:dir:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_dir))); 89 : - 90 237 : msg_progress("Using %u MiB of memory for the FileSystem.\n", (unsigned)(malloc_counter_get() / MEBI)); - 91 237 : } + 90 238 : msg_progress("Using %u MiB of memory for the FileSystem.\n", (unsigned)(malloc_counter_get() / MEBI)); + 91 238 : } 92 : - 93 276 : void test(int argc, char* argv[]) + 93 277 : void test(int argc, char* argv[]) 94 : { 95 : int i; 96 : char buffer[ESC_MAX]; 97 : 98 : /* special testing code for quoting */ - 99 276 : if (argc < 2 || strcmp(argv[1], "test") != 0) - 100 550 : return; + 99 277 : if (argc < 2 || strcmp(argv[1], "test") != 0) + 100 552 : return; 101 : 102 1 : for (i = 2; i < argc; ++i) { 103 0 : printf("argv[%d]\n", i); @@ -185,7 +185,7 @@ 123 : /****************************************************************************/ 124 : /* log */ 125 : - 126 265 : void log_open(const char* file) + 126 266 : void log_open(const char* file) 127 : { 128 : char path[PATH_MAX]; 129 : const char* mode; @@ -195,8 +195,8 @@ 133 : struct tm* tm; 134 : 135 : /* leave stdlog at 0 if not specified */ - 136 265 : if (file == 0) - 137 376 : return; + 136 266 : if (file == 0) + 137 378 : return; 138 : 139 80 : t = time(0); 140 80 : tm = localtime(&t); @@ -269,9 +269,9 @@ 207 : } 208 : } 209 : - 210 242 : void log_close(const char* file) + 210 243 : void log_close(const char* file) 211 : { - 212 242 : if (stdlog != stdout && stdlog != stderr && stdlog != 0) { + 212 243 : if (stdlog != stdout && stdlog != stderr && stdlog != 0) { 213 74 : if (fclose(stdlog) != 0) { 214 : /* LCOV_EXCL_START */ 215 : log_fatal("Error closing the log file '%s'. %s.\n", file, strerror(errno)); @@ -280,13 +280,13 @@ 218 : } 219 : } 220 : - 221 242 : stdlog = 0; - 222 242 : } + 221 243 : stdlog = 0; + 222 243 : } 223 : 224 : /****************************************************************************/ 225 : /* config */ 226 : - 227 275 : void config(char* conf, size_t conf_size, const char* argv0) + 227 276 : void config(char* conf, size_t conf_size, const char* argv0) 228 : { 229 : #ifdef _WIN32 230 : char* slash; @@ -303,1268 +303,1274 @@ 241 : #else 242 : (void)argv0; 243 : - 244 275 : pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf"); - 245 : #endif - 246 275 : } - 247 : - 248 : /****************************************************************************/ - 249 : /* main */ - 250 : - 251 : #define OPT_TEST_SKIP_SELF 256 - 252 : #define OPT_TEST_KILL_AFTER_SYNC 257 - 253 : #define OPT_TEST_EXPECT_UNRECOVERABLE 258 - 254 : #define OPT_TEST_EXPECT_RECOVERABLE 259 - 255 : #define OPT_TEST_SKIP_SIGN 260 - 256 : #define OPT_TEST_SKIP_FALLOCATE 261 - 257 : #define OPT_TEST_SKIP_DEVICE 262 - 258 : #define OPT_TEST_FORCE_MURMUR3 264 - 259 : #define OPT_TEST_FORCE_SPOOKY2 265 - 260 : #define OPT_TEST_SKIP_LOCK 266 - 261 : #define OPT_TEST_FORCE_ORDER_PHYSICAL 267 - 262 : #define OPT_TEST_FORCE_ORDER_INODE 268 - 263 : #define OPT_TEST_FORCE_ORDER_ALPHA 269 - 264 : #define OPT_TEST_FORCE_ORDER_DIR 270 - 265 : #define OPT_TEST_FORCE_SCRUB_AT 271 - 266 : #define OPT_TEST_FORCE_SCRUB_EVEN 272 - 267 : #define OPT_TEST_FORCE_CONTENT_WRITE 273 - 268 : #define OPT_TEST_SKIP_CONTENT_CHECK 275 - 269 : #define OPT_TEST_SKIP_PARITY_ACCESS 276 - 270 : #define OPT_TEST_EXPECT_FAILURE 277 - 271 : #define OPT_TEST_RUN 278 - 272 : #define OPT_TEST_FORCE_SCAN_WINFIND 279 - 273 : #define OPT_TEST_IMPORT_CONTENT 280 - 274 : #define OPT_TEST_FORCE_PROGRESS 281 - 275 : #define OPT_TEST_SKIP_DISK_ACCESS 282 - 276 : #define OPT_TEST_FORCE_AUTOSAVE_AT 283 - 277 : #define OPT_TEST_FAKE_DEVICE 284 - 278 : #define OPT_TEST_EXPECT_NEED_SYNC 285 - 279 : #define OPT_NO_WARNINGS 286 - 280 : #define OPT_TEST_FAKE_UUID 287 - 281 : #define OPT_TEST_MATCH_FIRST_UUID 288 - 282 : #define OPT_TEST_FORCE_PARITY_UPDATE 289 - 283 : #define OPT_TEST_IO_CACHE 290 - 284 : #define OPT_TEST_IO_STATS 291 - 285 : #define OPT_TEST_COND_SIGNAL_OUTSIDE 292 - 286 : #define OPT_TEST_IO_ADVISE_NONE 293 - 287 : #define OPT_TEST_IO_ADVISE_SEQUENTIAL 294 - 288 : #define OPT_TEST_IO_ADVISE_FLUSH 295 - 289 : #define OPT_TEST_IO_ADVISE_FLUSH_WINDOW 296 - 290 : #define OPT_TEST_IO_ADVISE_DISCARD 297 - 291 : #define OPT_TEST_IO_ADVISE_DISCARD_WINDOW 298 - 292 : #define OPT_TEST_IO_ADVISE_DIRECT 299 - 293 : #define OPT_TEST_PARITY_LIMIT 301 - 294 : #define OPT_TEST_SKIP_CONTENT_WRITE 302 - 295 : #define OPT_TEST_SKIP_SPACE_HOLDER 303 - 296 : #define OPT_TEST_FORMAT 304 - 297 : - 298 : #if HAVE_GETOPT_LONG - 299 : struct option long_options[] = { - 300 : { "conf", 1, 0, 'c' }, - 301 : { "filter", 1, 0, 'f' }, - 302 : { "filter-disk", 1, 0, 'd' }, - 303 : { "filter-missing", 0, 0, 'm' }, - 304 : { "filter-error", 0, 0, 'e' }, - 305 : { "percentage", 1, 0, 'p' }, /* legacy name for --plan */ - 306 : { "plan", 1, 0, 'p' }, - 307 : { "older-than", 1, 0, 'o' }, - 308 : { "start", 1, 0, 'S' }, - 309 : { "count", 1, 0, 'B' }, - 310 : { "error-limit", 1, 0, 'L' }, - 311 : { "import", 1, 0, 'i' }, - 312 : { "log", 1, 0, 'l' }, - 313 : { "force-zero", 0, 0, 'Z' }, - 314 : { "force-empty", 0, 0, 'E' }, - 315 : { "force-uuid", 0, 0, 'U' }, - 316 : { "force-device", 0, 0, 'D' }, - 317 : { "force-nocopy", 0, 0, 'N' }, - 318 : { "force-full", 0, 0, 'F' }, - 319 : { "force-realloc", 0, 0, 'R' }, - 320 : { "audit-only", 0, 0, 'a' }, - 321 : { "pre-hash", 0, 0, 'h' }, - 322 : { "speed-test", 0, 0, 'T' }, /* undocumented speed test command */ - 323 : { "gen-conf", 1, 0, 'C' }, - 324 : { "verbose", 0, 0, 'v' }, - 325 : { "quiet", 0, 0, 'q' }, /* undocumented quiet option */ - 326 : { "gui", 0, 0, 'G' }, /* undocumented GUI interface option */ - 327 : { "help", 0, 0, 'H' }, - 328 : { "version", 0, 0, 'V' }, - 329 : - 330 : /* The following are test specific options, DO NOT USE! */ - 331 : - 332 : /* After syncing, do not write the new content file */ - 333 : { "test-kill-after-sync", 0, 0, OPT_TEST_KILL_AFTER_SYNC }, - 334 : - 335 : /* Exit with failure if after check/fix there ARE NOT unrecoverable errors. */ - 336 : { "test-expect-unrecoverable", 0, 0, OPT_TEST_EXPECT_UNRECOVERABLE }, + 244 : #ifdef SYSCONFDIR + 245 : /* if it exists, give precedence at sysconfdir, usually /usr/local/etc */ + 246 276 : if (access(SYSCONFDIR "/" PACKAGE ".conf", F_OK) == 0) + 247 0 : pathcpy(conf, conf_size, SYSCONFDIR "/" PACKAGE ".conf"); + 248 : else /* otherwise fallback to plain /etc */ + 249 : #endif + 250 276 : pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf"); + 251 : #endif + 252 276 : } + 253 : + 254 : /****************************************************************************/ + 255 : /* main */ + 256 : + 257 : #define OPT_TEST_SKIP_SELF 256 + 258 : #define OPT_TEST_KILL_AFTER_SYNC 257 + 259 : #define OPT_TEST_EXPECT_UNRECOVERABLE 258 + 260 : #define OPT_TEST_EXPECT_RECOVERABLE 259 + 261 : #define OPT_TEST_SKIP_SIGN 260 + 262 : #define OPT_TEST_SKIP_FALLOCATE 261 + 263 : #define OPT_TEST_SKIP_DEVICE 262 + 264 : #define OPT_TEST_FORCE_MURMUR3 264 + 265 : #define OPT_TEST_FORCE_SPOOKY2 265 + 266 : #define OPT_TEST_SKIP_LOCK 266 + 267 : #define OPT_TEST_FORCE_ORDER_PHYSICAL 267 + 268 : #define OPT_TEST_FORCE_ORDER_INODE 268 + 269 : #define OPT_TEST_FORCE_ORDER_ALPHA 269 + 270 : #define OPT_TEST_FORCE_ORDER_DIR 270 + 271 : #define OPT_TEST_FORCE_SCRUB_AT 271 + 272 : #define OPT_TEST_FORCE_SCRUB_EVEN 272 + 273 : #define OPT_TEST_FORCE_CONTENT_WRITE 273 + 274 : #define OPT_TEST_SKIP_CONTENT_CHECK 275 + 275 : #define OPT_TEST_SKIP_PARITY_ACCESS 276 + 276 : #define OPT_TEST_EXPECT_FAILURE 277 + 277 : #define OPT_TEST_RUN 278 + 278 : #define OPT_TEST_FORCE_SCAN_WINFIND 279 + 279 : #define OPT_TEST_IMPORT_CONTENT 280 + 280 : #define OPT_TEST_FORCE_PROGRESS 281 + 281 : #define OPT_TEST_SKIP_DISK_ACCESS 282 + 282 : #define OPT_TEST_FORCE_AUTOSAVE_AT 283 + 283 : #define OPT_TEST_FAKE_DEVICE 284 + 284 : #define OPT_TEST_EXPECT_NEED_SYNC 285 + 285 : #define OPT_NO_WARNINGS 286 + 286 : #define OPT_TEST_FAKE_UUID 287 + 287 : #define OPT_TEST_MATCH_FIRST_UUID 288 + 288 : #define OPT_TEST_FORCE_PARITY_UPDATE 289 + 289 : #define OPT_TEST_IO_CACHE 290 + 290 : #define OPT_TEST_IO_STATS 291 + 291 : #define OPT_TEST_COND_SIGNAL_OUTSIDE 292 + 292 : #define OPT_TEST_IO_ADVISE_NONE 293 + 293 : #define OPT_TEST_IO_ADVISE_SEQUENTIAL 294 + 294 : #define OPT_TEST_IO_ADVISE_FLUSH 295 + 295 : #define OPT_TEST_IO_ADVISE_FLUSH_WINDOW 296 + 296 : #define OPT_TEST_IO_ADVISE_DISCARD 297 + 297 : #define OPT_TEST_IO_ADVISE_DISCARD_WINDOW 298 + 298 : #define OPT_TEST_IO_ADVISE_DIRECT 299 + 299 : #define OPT_TEST_PARITY_LIMIT 301 + 300 : #define OPT_TEST_SKIP_CONTENT_WRITE 302 + 301 : #define OPT_TEST_SKIP_SPACE_HOLDER 303 + 302 : #define OPT_TEST_FORMAT 304 + 303 : + 304 : #if HAVE_GETOPT_LONG + 305 : struct option long_options[] = { + 306 : { "conf", 1, 0, 'c' }, + 307 : { "filter", 1, 0, 'f' }, + 308 : { "filter-disk", 1, 0, 'd' }, + 309 : { "filter-missing", 0, 0, 'm' }, + 310 : { "filter-error", 0, 0, 'e' }, + 311 : { "percentage", 1, 0, 'p' }, /* legacy name for --plan */ + 312 : { "plan", 1, 0, 'p' }, + 313 : { "older-than", 1, 0, 'o' }, + 314 : { "start", 1, 0, 'S' }, + 315 : { "count", 1, 0, 'B' }, + 316 : { "error-limit", 1, 0, 'L' }, + 317 : { "import", 1, 0, 'i' }, + 318 : { "log", 1, 0, 'l' }, + 319 : { "force-zero", 0, 0, 'Z' }, + 320 : { "force-empty", 0, 0, 'E' }, + 321 : { "force-uuid", 0, 0, 'U' }, + 322 : { "force-device", 0, 0, 'D' }, + 323 : { "force-nocopy", 0, 0, 'N' }, + 324 : { "force-full", 0, 0, 'F' }, + 325 : { "force-realloc", 0, 0, 'R' }, + 326 : { "audit-only", 0, 0, 'a' }, + 327 : { "pre-hash", 0, 0, 'h' }, + 328 : { "speed-test", 0, 0, 'T' }, /* undocumented speed test command */ + 329 : { "gen-conf", 1, 0, 'C' }, + 330 : { "verbose", 0, 0, 'v' }, + 331 : { "quiet", 0, 0, 'q' }, /* undocumented quiet option */ + 332 : { "gui", 0, 0, 'G' }, /* undocumented GUI interface option */ + 333 : { "help", 0, 0, 'H' }, + 334 : { "version", 0, 0, 'V' }, + 335 : + 336 : /* The following are test specific options, DO NOT USE! */ 337 : - 338 : /* Exit with failure if after check/fix there ARE NOT recoverable errors. */ - 339 : { "test-expect-recoverable", 0, 0, OPT_TEST_EXPECT_RECOVERABLE }, + 338 : /* After syncing, do not write the new content file */ + 339 : { "test-kill-after-sync", 0, 0, OPT_TEST_KILL_AFTER_SYNC }, 340 : - 341 : /* Skip the initial self test */ - 342 : { "test-skip-self", 0, 0, OPT_TEST_SKIP_SELF }, + 341 : /* Exit with failure if after check/fix there ARE NOT unrecoverable errors. */ + 342 : { "test-expect-unrecoverable", 0, 0, OPT_TEST_EXPECT_UNRECOVERABLE }, 343 : - 344 : /* Skip the initial sign check when reading the content file */ - 345 : { "test-skip-sign", 0, 0, OPT_TEST_SKIP_SIGN }, + 344 : /* Exit with failure if after check/fix there ARE NOT recoverable errors. */ + 345 : { "test-expect-recoverable", 0, 0, OPT_TEST_EXPECT_RECOVERABLE }, 346 : - 347 : /* Skip the fallocate() when growing the parity files */ - 348 : { "test-skip-fallocate", 0, 0, OPT_TEST_SKIP_FALLOCATE }, + 347 : /* Skip the initial self test */ + 348 : { "test-skip-self", 0, 0, OPT_TEST_SKIP_SELF }, 349 : - 350 : /* Skip the device check */ - 351 : { "test-skip-device", 0, 0, OPT_TEST_SKIP_DEVICE }, + 350 : /* Skip the initial sign check when reading the content file */ + 351 : { "test-skip-sign", 0, 0, OPT_TEST_SKIP_SIGN }, 352 : - 353 : /* Force Murmur3 hash */ - 354 : { "test-force-murmur3", 0, 0, OPT_TEST_FORCE_MURMUR3 }, + 353 : /* Skip the fallocate() when growing the parity files */ + 354 : { "test-skip-fallocate", 0, 0, OPT_TEST_SKIP_FALLOCATE }, 355 : - 356 : /* Force Spooky2 hash */ - 357 : { "test-force-spooky2", 0, 0, OPT_TEST_FORCE_SPOOKY2 }, + 356 : /* Skip the device check */ + 357 : { "test-skip-device", 0, 0, OPT_TEST_SKIP_DEVICE }, 358 : - 359 : /* Skip the use of lock file */ - 360 : { "test-skip-lock", 0, 0, OPT_TEST_SKIP_LOCK }, + 359 : /* Force Murmur3 hash */ + 360 : { "test-force-murmur3", 0, 0, OPT_TEST_FORCE_MURMUR3 }, 361 : - 362 : /* Force a sort order for files */ - 363 : { "test-force-order-physical", 0, 0, OPT_TEST_FORCE_ORDER_PHYSICAL }, - 364 : { "test-force-order-inode", 0, 0, OPT_TEST_FORCE_ORDER_INODE }, - 365 : { "test-force-order-alpha", 0, 0, OPT_TEST_FORCE_ORDER_ALPHA }, - 366 : { "test-force-order-dir", 0, 0, OPT_TEST_FORCE_ORDER_DIR }, + 362 : /* Force Spooky2 hash */ + 363 : { "test-force-spooky2", 0, 0, OPT_TEST_FORCE_SPOOKY2 }, + 364 : + 365 : /* Skip the use of lock file */ + 366 : { "test-skip-lock", 0, 0, OPT_TEST_SKIP_LOCK }, 367 : - 368 : /* Force scrub of the specified number of blocks */ - 369 : { "test-force-scrub-at", 1, 0, OPT_TEST_FORCE_SCRUB_AT }, - 370 : - 371 : /* Force scrub of all the even blocks. This is really for testing, don't try it */ - 372 : { "test-force-scrub-even", 0, 0, OPT_TEST_FORCE_SCRUB_EVEN }, + 368 : /* Force a sort order for files */ + 369 : { "test-force-order-physical", 0, 0, OPT_TEST_FORCE_ORDER_PHYSICAL }, + 370 : { "test-force-order-inode", 0, 0, OPT_TEST_FORCE_ORDER_INODE }, + 371 : { "test-force-order-alpha", 0, 0, OPT_TEST_FORCE_ORDER_ALPHA }, + 372 : { "test-force-order-dir", 0, 0, OPT_TEST_FORCE_ORDER_DIR }, 373 : - 374 : /* Force write of the content file even if no modification is done */ - 375 : { "test-force-content-write", 0, 0, OPT_TEST_FORCE_CONTENT_WRITE }, + 374 : /* Force scrub of the specified number of blocks */ + 375 : { "test-force-scrub-at", 1, 0, OPT_TEST_FORCE_SCRUB_AT }, 376 : - 377 : /* Relax the checks done at the content file */ - 378 : { "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK }, + 377 : /* Force scrub of all the even blocks. This is really for testing, don't try it */ + 378 : { "test-force-scrub-even", 0, 0, OPT_TEST_FORCE_SCRUB_EVEN }, 379 : - 380 : /* Skip the parity access */ - 381 : { "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS }, + 380 : /* Force write of the content file even if no modification is done */ + 381 : { "test-force-content-write", 0, 0, OPT_TEST_FORCE_CONTENT_WRITE }, 382 : - 383 : /* Exit generic failure */ - 384 : { "test-expect-failure", 0, 0, OPT_TEST_EXPECT_FAILURE }, + 383 : /* Relax the checks done at the content file */ + 384 : { "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK }, 385 : - 386 : /* Exit generic need sync */ - 387 : { "test-expect-need-sync", 0, 0, OPT_TEST_EXPECT_NEED_SYNC }, + 386 : /* Skip the parity access */ + 387 : { "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS }, 388 : - 389 : /* Run some command after loading the state and before the command */ - 390 : { "test-run", 1, 0, OPT_TEST_RUN }, + 389 : /* Exit generic failure */ + 390 : { "test-expect-failure", 0, 0, OPT_TEST_EXPECT_FAILURE }, 391 : - 392 : /* Use the FindFirst/Next approach in Windows to list files */ - 393 : { "test-force-scan-winfind", 0, 0, OPT_TEST_FORCE_SCAN_WINFIND }, + 392 : /* Exit generic need sync */ + 393 : { "test-expect-need-sync", 0, 0, OPT_TEST_EXPECT_NEED_SYNC }, 394 : - 395 : /* Alternative import working by data */ - 396 : { "test-import-content", 1, 0, OPT_TEST_IMPORT_CONTENT }, + 395 : /* Run some command after loading the state and before the command */ + 396 : { "test-run", 1, 0, OPT_TEST_RUN }, 397 : - 398 : /* Force immediate progress state update */ - 399 : { "test-force-progress", 0, 0, OPT_TEST_FORCE_PROGRESS }, + 398 : /* Use the FindFirst/Next approach in Windows to list files */ + 399 : { "test-force-scan-winfind", 0, 0, OPT_TEST_FORCE_SCAN_WINFIND }, 400 : - 401 : /* Skip the disk access */ - 402 : { "test-skip-disk-access", 0, 0, OPT_TEST_SKIP_DISK_ACCESS }, + 401 : /* Alternative import working by data */ + 402 : { "test-import-content", 1, 0, OPT_TEST_IMPORT_CONTENT }, 403 : - 404 : /* Force autosave at the specified block */ - 405 : { "test-force-autosave-at", 1, 0, OPT_TEST_FORCE_AUTOSAVE_AT }, + 404 : /* Force immediate progress state update */ + 405 : { "test-force-progress", 0, 0, OPT_TEST_FORCE_PROGRESS }, 406 : - 407 : /* Fake device data */ - 408 : { "test-fake-device", 0, 0, OPT_TEST_FAKE_DEVICE }, + 407 : /* Skip the disk access */ + 408 : { "test-skip-disk-access", 0, 0, OPT_TEST_SKIP_DISK_ACCESS }, 409 : - 410 : /* Disable annoying warnings */ - 411 : { "no-warnings", 0, 0, OPT_NO_WARNINGS }, + 410 : /* Force autosave at the specified block */ + 411 : { "test-force-autosave-at", 1, 0, OPT_TEST_FORCE_AUTOSAVE_AT }, 412 : - 413 : /* Fake UUID */ - 414 : { "test-fake-uuid", 0, 0, OPT_TEST_FAKE_UUID }, + 413 : /* Fake device data */ + 414 : { "test-fake-device", 0, 0, OPT_TEST_FAKE_DEVICE }, 415 : - 416 : /* Match first UUID */ - 417 : { "test-match-first-uuid", 0, 0, OPT_TEST_MATCH_FIRST_UUID }, + 416 : /* Disable annoying warnings */ + 417 : { "no-warnings", 0, 0, OPT_NO_WARNINGS }, 418 : - 419 : /* Force parity update even if all the data hash is already matching */ - 420 : { "test-force-parity-update", 0, 0, OPT_TEST_FORCE_PARITY_UPDATE }, + 419 : /* Fake UUID */ + 420 : { "test-fake-uuid", 0, 0, OPT_TEST_FAKE_UUID }, 421 : - 422 : /* Number of IO buffers */ - 423 : { "test-io-cache", 1, 0, OPT_TEST_IO_CACHE }, + 422 : /* Match first UUID */ + 423 : { "test-match-first-uuid", 0, 0, OPT_TEST_MATCH_FIRST_UUID }, 424 : - 425 : /* Print IO stats */ - 426 : { "test-io-stats", 0, 0, OPT_TEST_IO_STATS }, + 425 : /* Force parity update even if all the data hash is already matching */ + 426 : { "test-force-parity-update", 0, 0, OPT_TEST_FORCE_PARITY_UPDATE }, 427 : - 428 : /* Signal condition variable outside the mutex */ - 429 : { "test-cond-signal-outside", 0, 0, OPT_TEST_COND_SIGNAL_OUTSIDE }, + 428 : /* Number of IO buffers */ + 429 : { "test-io-cache", 1, 0, OPT_TEST_IO_CACHE }, 430 : - 431 : /* Set the io advise to none */ - 432 : { "test-io-advise-none", 0, 0, OPT_TEST_IO_ADVISE_NONE }, + 431 : /* Print IO stats */ + 432 : { "test-io-stats", 0, 0, OPT_TEST_IO_STATS }, 433 : - 434 : /* Set the io advise to sequential */ - 435 : { "test-io-advise-sequential", 0, 0, OPT_TEST_IO_ADVISE_SEQUENTIAL }, + 434 : /* Signal condition variable outside the mutex */ + 435 : { "test-cond-signal-outside", 0, 0, OPT_TEST_COND_SIGNAL_OUTSIDE }, 436 : - 437 : /* Set the io advise to flush */ - 438 : { "test-io-advise-flush", 0, 0, OPT_TEST_IO_ADVISE_FLUSH }, + 437 : /* Set the io advise to none */ + 438 : { "test-io-advise-none", 0, 0, OPT_TEST_IO_ADVISE_NONE }, 439 : - 440 : /* Set the io advise to flush window */ - 441 : { "test-io-advise-flush-window", 0, 0, OPT_TEST_IO_ADVISE_FLUSH_WINDOW }, + 440 : /* Set the io advise to sequential */ + 441 : { "test-io-advise-sequential", 0, 0, OPT_TEST_IO_ADVISE_SEQUENTIAL }, 442 : - 443 : /* Set the io advise to discard */ - 444 : { "test-io-advise-discard", 0, 0, OPT_TEST_IO_ADVISE_DISCARD }, + 443 : /* Set the io advise to flush */ + 444 : { "test-io-advise-flush", 0, 0, OPT_TEST_IO_ADVISE_FLUSH }, 445 : - 446 : /* Set the io advise to discard window */ - 447 : { "test-io-advise-discard-window", 0, 0, OPT_TEST_IO_ADVISE_DISCARD_WINDOW }, + 446 : /* Set the io advise to flush window */ + 447 : { "test-io-advise-flush-window", 0, 0, OPT_TEST_IO_ADVISE_FLUSH_WINDOW }, 448 : - 449 : /* Set the io advise to direct */ - 450 : { "test-io-advise-direct", 0, 0, OPT_TEST_IO_ADVISE_DIRECT }, + 449 : /* Set the io advise to discard */ + 450 : { "test-io-advise-discard", 0, 0, OPT_TEST_IO_ADVISE_DISCARD }, 451 : - 452 : /* Set an artificial parity limit */ - 453 : { "test-parity-limit", 1, 0, OPT_TEST_PARITY_LIMIT }, + 452 : /* Set the io advise to discard window */ + 453 : { "test-io-advise-discard-window", 0, 0, OPT_TEST_IO_ADVISE_DISCARD_WINDOW }, 454 : - 455 : /* Skip content write */ - 456 : { "test-skip-content-write", 0, 0, OPT_TEST_SKIP_CONTENT_WRITE }, + 455 : /* Set the io advise to direct */ + 456 : { "test-io-advise-direct", 0, 0, OPT_TEST_IO_ADVISE_DIRECT }, 457 : - 458 : /* Skip space holder file in parity disks */ - 459 : { "test-skip-space-holder", 0, 0, OPT_TEST_SKIP_SPACE_HOLDER }, + 458 : /* Set an artificial parity limit */ + 459 : { "test-parity-limit", 1, 0, OPT_TEST_PARITY_LIMIT }, 460 : - 461 : /* Set the ourput format */ - 462 : { "test-fmt", 1, 0, OPT_TEST_FORMAT }, + 461 : /* Skip content write */ + 462 : { "test-skip-content-write", 0, 0, OPT_TEST_SKIP_CONTENT_WRITE }, 463 : - 464 : { 0, 0, 0, 0 } - 465 : }; - 466 : #endif - 467 : - 468 : #define OPTIONS "c:f:d:mep:o:S:B:L:i:l:ZEUDNFRahTC:vqHVG" + 464 : /* Skip space holder file in parity disks */ + 465 : { "test-skip-space-holder", 0, 0, OPT_TEST_SKIP_SPACE_HOLDER }, + 466 : + 467 : /* Set the ourput format */ + 468 : { "test-fmt", 1, 0, OPT_TEST_FORMAT }, 469 : - 470 : volatile int global_interrupt = 0; - 471 : - 472 : /* LCOV_EXCL_START */ - 473 : void signal_handler(int signum) - 474 : { - 475 : (void)signum; - 476 : - 477 : /* report the request of interruption */ - 478 : global_interrupt = 1; - 479 : } - 480 : /* LCOV_EXCL_STOP */ - 481 : - 482 223 : void signal_init(void) - 483 : { - 484 : #if HAVE_SIGACTION - 485 : struct sigaction sa; - 486 : - 487 223 : sa.sa_handler = signal_handler; - 488 223 : sigemptyset(&sa.sa_mask); - 489 : - 490 : /* use the SA_RESTART to automatically restart interrupted system calls */ - 491 223 : sa.sa_flags = SA_RESTART; + 470 : { 0, 0, 0, 0 } + 471 : }; + 472 : #endif + 473 : + 474 : #define OPTIONS "c:f:d:mep:o:S:B:L:i:l:ZEUDNFRahTC:vqHVG" + 475 : + 476 : volatile int global_interrupt = 0; + 477 : + 478 : /* LCOV_EXCL_START */ + 479 : void signal_handler(int signum) + 480 : { + 481 : (void)signum; + 482 : + 483 : /* report the request of interruption */ + 484 : global_interrupt = 1; + 485 : } + 486 : /* LCOV_EXCL_STOP */ + 487 : + 488 223 : void signal_init(void) + 489 : { + 490 : #if HAVE_SIGACTION + 491 : struct sigaction sa; 492 : - 493 223 : sigaction(SIGHUP, &sa, 0); - 494 223 : sigaction(SIGTERM, &sa, 0); - 495 223 : sigaction(SIGINT, &sa, 0); - 496 223 : sigaction(SIGQUIT, &sa, 0); - 497 : #else - 498 : signal(SIGINT, signal_handler); - 499 : #endif - 500 223 : } - 501 : - 502 : #define OPERATION_DIFF 0 - 503 : #define OPERATION_SYNC 1 - 504 : #define OPERATION_CHECK 2 - 505 : #define OPERATION_FIX 3 - 506 : #define OPERATION_DRY 4 - 507 : #define OPERATION_DUP 5 - 508 : #define OPERATION_LIST 6 - 509 : #define OPERATION_POOL 7 - 510 : #define OPERATION_REHASH 8 - 511 : #define OPERATION_SCRUB 9 - 512 : #define OPERATION_STATUS 10 - 513 : #define OPERATION_REWRITE 11 - 514 : #define OPERATION_READ 12 - 515 : #define OPERATION_TOUCH 13 - 516 : #define OPERATION_SPINUP 14 - 517 : #define OPERATION_SPINDOWN 15 - 518 : #define OPERATION_DEVICES 16 - 519 : #define OPERATION_SMART 17 - 520 : - 521 276 : int main(int argc, char* argv[]) - 522 : { - 523 : int c; - 524 : struct snapraid_option opt; - 525 : char conf[PATH_MAX]; - 526 : struct snapraid_state state; - 527 : int operation; - 528 : block_off_t blockstart; - 529 : block_off_t blockcount; - 530 : int ret; - 531 : tommy_list filterlist_file; - 532 : tommy_list filterlist_disk; - 533 : int filter_missing; - 534 : int filter_error; - 535 : int plan; - 536 : int olderthan; - 537 : char* e; - 538 : const char* command; - 539 : const char* import_timestamp; - 540 : const char* import_content; - 541 : const char* log_file; - 542 : int lock; - 543 : const char* gen_conf; - 544 : const char* run; - 545 : int speedtest; - 546 : int period; - 547 : time_t t; - 548 : struct tm* tm; - 549 : int i; - 550 : - 551 276 : test(argc, argv); - 552 : - 553 275 : lock_init(); - 554 : - 555 : /* defaults */ - 556 275 : config(conf, sizeof(conf), argv[0]); - 557 275 : memset(&opt, 0, sizeof(opt)); - 558 275 : opt.io_error_limit = 100; - 559 275 : blockstart = 0; - 560 275 : blockcount = 0; - 561 275 : tommy_list_init(&filterlist_file); - 562 275 : tommy_list_init(&filterlist_disk); - 563 275 : period = 1000; - 564 275 : filter_missing = 0; - 565 275 : filter_error = 0; - 566 275 : plan = SCRUB_AUTO; - 567 275 : olderthan = SCRUB_AUTO; - 568 275 : import_timestamp = 0; - 569 275 : import_content = 0; - 570 275 : log_file = 0; - 571 275 : lock = 0; - 572 275 : gen_conf = 0; - 573 275 : speedtest = 0; - 574 275 : run = 0; - 575 : - 576 275 : opterr = 0; - 577 3463 : while ((c = - 578 : #if HAVE_GETOPT_LONG - 579 : getopt_long(argc, argv, OPTIONS, long_options, 0)) - 580 : #else - 581 : getopt(argc, argv, OPTIONS)) - 582 : #endif - 583 : != EOF) { - 584 2918 : switch (c) { - 585 : case 'c' : - 586 268 : pathimport(conf, sizeof(conf), optarg); - 587 268 : break; - 588 : case 'f' : { - 589 6 : struct snapraid_filter* filter = filter_alloc_file(1, optarg); - 590 6 : if (!filter) { - 591 : /* LCOV_EXCL_START */ - 592 : log_fatal("Invalid filter specification '%s'\n", optarg); - 593 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); - 594 : exit(EXIT_FAILURE); - 595 : /* LCOV_EXCL_STOP */ - 596 : } - 597 3 : tommy_list_insert_tail(&filterlist_file, &filter->node, filter); - 598 3 : } break; - 599 : case 'd' : { - 600 10 : struct snapraid_filter* filter = filter_alloc_disk(1, optarg); - 601 10 : if (!filter) { - 602 : /* LCOV_EXCL_START */ - 603 : log_fatal("Invalid filter specification '%s'\n", optarg); - 604 : exit(EXIT_FAILURE); - 605 : /* LCOV_EXCL_STOP */ - 606 : } - 607 10 : tommy_list_insert_tail(&filterlist_disk, &filter->node, filter); - 608 10 : } break; - 609 : case 'm' : - 610 2 : filter_missing = 1; - 611 2 : opt.expected_missing = 1; - 612 2 : break; - 613 : case 'e' : - 614 : /* when processing only error, we filter both files and blocks */ - 615 : /* and we apply fixes only to synced ones */ - 616 2 : filter_error = 1; - 617 2 : opt.badonly = 1; - 618 2 : opt.syncedonly = 1; - 619 2 : break; - 620 : case 'p' : - 621 5 : if (strcmp(optarg, "bad") == 0) { - 622 1 : plan = SCRUB_BAD; - 623 4 : } else if (strcmp(optarg, "new") == 0) { - 624 1 : plan = SCRUB_NEW; - 625 3 : } else if (strcmp(optarg, "full") == 0) { - 626 2 : plan = SCRUB_FULL; - 627 : } else { - 628 1 : plan = strtoul(optarg, &e, 10); - 629 1 : if (!e || *e || plan > 100) { - 630 : /* LCOV_EXCL_START */ - 631 : log_fatal("Invalid plan/percentage '%s'\n", optarg); - 632 : exit(EXIT_FAILURE); - 633 : /* LCOV_EXCL_STOP */ - 634 : } - 635 : } - 636 5 : break; - 637 : case 'o' : - 638 1 : olderthan = strtoul(optarg, &e, 10); - 639 1 : if (!e || *e || olderthan > 1000) { - 640 : /* LCOV_EXCL_START */ - 641 : log_fatal("Invalid number of days '%s'\n", optarg); - 642 : exit(EXIT_FAILURE); - 643 : /* LCOV_EXCL_STOP */ - 644 : } - 645 1 : break; - 646 : case 'S' : - 647 2 : blockstart = strtoul(optarg, &e, 0); - 648 2 : if (!e || *e) { - 649 : /* LCOV_EXCL_START */ - 650 : log_fatal("Invalid start position '%s'\n", optarg); - 651 : exit(EXIT_FAILURE); - 652 : /* LCOV_EXCL_STOP */ - 653 : } - 654 2 : break; - 655 : case 'B' : - 656 7 : blockcount = strtoul(optarg, &e, 0); - 657 7 : if (!e || *e) { - 658 : /* LCOV_EXCL_START */ - 659 : log_fatal("Invalid count number '%s'\n", optarg); - 660 : exit(EXIT_FAILURE); - 661 : /* LCOV_EXCL_STOP */ - 662 : } - 663 7 : break; - 664 : case 'L' : - 665 0 : opt.io_error_limit = strtoul(optarg, &e, 0); - 666 0 : if (!e || *e) { - 667 : /* LCOV_EXCL_START */ - 668 : log_fatal("Invalid error limit number '%s'\n", optarg); - 669 : exit(EXIT_FAILURE); - 670 : /* LCOV_EXCL_STOP */ - 671 : } - 672 0 : break; - 673 : case 'i' : - 674 1 : if (import_timestamp) { - 675 : /* LCOV_EXCL_START */ - 676 : log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp); - 677 : exit(EXIT_FAILURE); - 678 : /* LCOV_EXCL_STOP */ - 679 : } - 680 1 : import_timestamp = optarg; - 681 1 : break; - 682 : case OPT_TEST_IMPORT_CONTENT : - 683 1 : if (import_content) { - 684 : /* LCOV_EXCL_START */ - 685 : log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_content); - 686 : exit(EXIT_FAILURE); - 687 : /* LCOV_EXCL_STOP */ - 688 : } - 689 1 : import_content = optarg; - 690 1 : break; - 691 : case 'l' : - 692 80 : if (log_file) { - 693 : /* LCOV_EXCL_START */ - 694 : log_fatal("Log file '%s' already specified as '%s'\n", optarg, log_file); - 695 : exit(EXIT_FAILURE); - 696 : /* LCOV_EXCL_STOP */ - 697 : } - 698 80 : log_file = optarg; - 699 80 : break; - 700 : case 'Z' : - 701 0 : opt.force_zero = 1; - 702 0 : break; - 703 : case 'E' : - 704 6 : opt.force_empty = 1; - 705 6 : break; - 706 : case 'U' : - 707 0 : opt.force_uuid = 1; + 493 223 : sa.sa_handler = signal_handler; + 494 223 : sigemptyset(&sa.sa_mask); + 495 : + 496 : /* use the SA_RESTART to automatically restart interrupted system calls */ + 497 223 : sa.sa_flags = SA_RESTART; + 498 : + 499 223 : sigaction(SIGHUP, &sa, 0); + 500 223 : sigaction(SIGTERM, &sa, 0); + 501 223 : sigaction(SIGINT, &sa, 0); + 502 223 : sigaction(SIGQUIT, &sa, 0); + 503 : #else + 504 : signal(SIGINT, signal_handler); + 505 : #endif + 506 223 : } + 507 : + 508 : #define OPERATION_DIFF 0 + 509 : #define OPERATION_SYNC 1 + 510 : #define OPERATION_CHECK 2 + 511 : #define OPERATION_FIX 3 + 512 : #define OPERATION_DRY 4 + 513 : #define OPERATION_DUP 5 + 514 : #define OPERATION_LIST 6 + 515 : #define OPERATION_POOL 7 + 516 : #define OPERATION_REHASH 8 + 517 : #define OPERATION_SCRUB 9 + 518 : #define OPERATION_STATUS 10 + 519 : #define OPERATION_REWRITE 11 + 520 : #define OPERATION_READ 12 + 521 : #define OPERATION_TOUCH 13 + 522 : #define OPERATION_SPINUP 14 + 523 : #define OPERATION_SPINDOWN 15 + 524 : #define OPERATION_DEVICES 16 + 525 : #define OPERATION_SMART 17 + 526 : + 527 277 : int main(int argc, char* argv[]) + 528 : { + 529 : int c; + 530 : struct snapraid_option opt; + 531 : char conf[PATH_MAX]; + 532 : struct snapraid_state state; + 533 : int operation; + 534 : block_off_t blockstart; + 535 : block_off_t blockcount; + 536 : int ret; + 537 : tommy_list filterlist_file; + 538 : tommy_list filterlist_disk; + 539 : int filter_missing; + 540 : int filter_error; + 541 : int plan; + 542 : int olderthan; + 543 : char* e; + 544 : const char* command; + 545 : const char* import_timestamp; + 546 : const char* import_content; + 547 : const char* log_file; + 548 : int lock; + 549 : const char* gen_conf; + 550 : const char* run; + 551 : int speedtest; + 552 : int period; + 553 : time_t t; + 554 : struct tm* tm; + 555 : int i; + 556 : + 557 277 : test(argc, argv); + 558 : + 559 276 : lock_init(); + 560 : + 561 : /* defaults */ + 562 276 : config(conf, sizeof(conf), argv[0]); + 563 276 : memset(&opt, 0, sizeof(opt)); + 564 276 : opt.io_error_limit = 100; + 565 276 : blockstart = 0; + 566 276 : blockcount = 0; + 567 276 : tommy_list_init(&filterlist_file); + 568 276 : tommy_list_init(&filterlist_disk); + 569 276 : period = 1000; + 570 276 : filter_missing = 0; + 571 276 : filter_error = 0; + 572 276 : plan = SCRUB_AUTO; + 573 276 : olderthan = SCRUB_AUTO; + 574 276 : import_timestamp = 0; + 575 276 : import_content = 0; + 576 276 : log_file = 0; + 577 276 : lock = 0; + 578 276 : gen_conf = 0; + 579 276 : speedtest = 0; + 580 276 : run = 0; + 581 : + 582 276 : opterr = 0; + 583 3475 : while ((c = + 584 : #if HAVE_GETOPT_LONG + 585 : getopt_long(argc, argv, OPTIONS, long_options, 0)) + 586 : #else + 587 : getopt(argc, argv, OPTIONS)) + 588 : #endif + 589 : != EOF) { + 590 2928 : switch (c) { + 591 : case 'c' : + 592 269 : pathimport(conf, sizeof(conf), optarg); + 593 269 : break; + 594 : case 'f' : { + 595 6 : struct snapraid_filter* filter = filter_alloc_file(1, optarg); + 596 6 : if (!filter) { + 597 : /* LCOV_EXCL_START */ + 598 : log_fatal("Invalid filter specification '%s'\n", optarg); + 599 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); + 600 : exit(EXIT_FAILURE); + 601 : /* LCOV_EXCL_STOP */ + 602 : } + 603 3 : tommy_list_insert_tail(&filterlist_file, &filter->node, filter); + 604 3 : } break; + 605 : case 'd' : { + 606 10 : struct snapraid_filter* filter = filter_alloc_disk(1, optarg); + 607 10 : if (!filter) { + 608 : /* LCOV_EXCL_START */ + 609 : log_fatal("Invalid filter specification '%s'\n", optarg); + 610 : exit(EXIT_FAILURE); + 611 : /* LCOV_EXCL_STOP */ + 612 : } + 613 10 : tommy_list_insert_tail(&filterlist_disk, &filter->node, filter); + 614 10 : } break; + 615 : case 'm' : + 616 2 : filter_missing = 1; + 617 2 : opt.expected_missing = 1; + 618 2 : break; + 619 : case 'e' : + 620 : /* when processing only error, we filter both files and blocks */ + 621 : /* and we apply fixes only to synced ones */ + 622 2 : filter_error = 1; + 623 2 : opt.badonly = 1; + 624 2 : opt.syncedonly = 1; + 625 2 : break; + 626 : case 'p' : + 627 5 : if (strcmp(optarg, "bad") == 0) { + 628 1 : plan = SCRUB_BAD; + 629 4 : } else if (strcmp(optarg, "new") == 0) { + 630 1 : plan = SCRUB_NEW; + 631 3 : } else if (strcmp(optarg, "full") == 0) { + 632 2 : plan = SCRUB_FULL; + 633 : } else { + 634 1 : plan = strtoul(optarg, &e, 10); + 635 1 : if (!e || *e || plan > 100) { + 636 : /* LCOV_EXCL_START */ + 637 : log_fatal("Invalid plan/percentage '%s'\n", optarg); + 638 : exit(EXIT_FAILURE); + 639 : /* LCOV_EXCL_STOP */ + 640 : } + 641 : } + 642 5 : break; + 643 : case 'o' : + 644 1 : olderthan = strtoul(optarg, &e, 10); + 645 1 : if (!e || *e || olderthan > 1000) { + 646 : /* LCOV_EXCL_START */ + 647 : log_fatal("Invalid number of days '%s'\n", optarg); + 648 : exit(EXIT_FAILURE); + 649 : /* LCOV_EXCL_STOP */ + 650 : } + 651 1 : break; + 652 : case 'S' : + 653 2 : blockstart = strtoul(optarg, &e, 0); + 654 2 : if (!e || *e) { + 655 : /* LCOV_EXCL_START */ + 656 : log_fatal("Invalid start position '%s'\n", optarg); + 657 : exit(EXIT_FAILURE); + 658 : /* LCOV_EXCL_STOP */ + 659 : } + 660 2 : break; + 661 : case 'B' : + 662 7 : blockcount = strtoul(optarg, &e, 0); + 663 7 : if (!e || *e) { + 664 : /* LCOV_EXCL_START */ + 665 : log_fatal("Invalid count number '%s'\n", optarg); + 666 : exit(EXIT_FAILURE); + 667 : /* LCOV_EXCL_STOP */ + 668 : } + 669 7 : break; + 670 : case 'L' : + 671 0 : opt.io_error_limit = strtoul(optarg, &e, 0); + 672 0 : if (!e || *e) { + 673 : /* LCOV_EXCL_START */ + 674 : log_fatal("Invalid error limit number '%s'\n", optarg); + 675 : exit(EXIT_FAILURE); + 676 : /* LCOV_EXCL_STOP */ + 677 : } + 678 0 : break; + 679 : case 'i' : + 680 1 : if (import_timestamp) { + 681 : /* LCOV_EXCL_START */ + 682 : log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp); + 683 : exit(EXIT_FAILURE); + 684 : /* LCOV_EXCL_STOP */ + 685 : } + 686 1 : import_timestamp = optarg; + 687 1 : break; + 688 : case OPT_TEST_IMPORT_CONTENT : + 689 1 : if (import_content) { + 690 : /* LCOV_EXCL_START */ + 691 : log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_content); + 692 : exit(EXIT_FAILURE); + 693 : /* LCOV_EXCL_STOP */ + 694 : } + 695 1 : import_content = optarg; + 696 1 : break; + 697 : case 'l' : + 698 80 : if (log_file) { + 699 : /* LCOV_EXCL_START */ + 700 : log_fatal("Log file '%s' already specified as '%s'\n", optarg, log_file); + 701 : exit(EXIT_FAILURE); + 702 : /* LCOV_EXCL_STOP */ + 703 : } + 704 80 : log_file = optarg; + 705 80 : break; + 706 : case 'Z' : + 707 0 : opt.force_zero = 1; 708 0 : break; - 709 : case 'D' : - 710 1 : opt.force_device = 1; - 711 1 : break; - 712 : case 'N' : - 713 1 : opt.force_nocopy = 1; - 714 1 : break; - 715 : case 'F' : - 716 6 : opt.force_full = 1; - 717 6 : break; - 718 : case 'R' : - 719 1 : opt.force_realloc = 1; + 709 : case 'E' : + 710 6 : opt.force_empty = 1; + 711 6 : break; + 712 : case 'U' : + 713 0 : opt.force_uuid = 1; + 714 0 : break; + 715 : case 'D' : + 716 1 : opt.force_device = 1; + 717 1 : break; + 718 : case 'N' : + 719 1 : opt.force_nocopy = 1; 720 1 : break; - 721 : case 'a' : - 722 6 : opt.auditonly = 1; + 721 : case 'F' : + 722 6 : opt.force_full = 1; 723 6 : break; - 724 : case 'h' : - 725 7 : opt.prehash = 1; - 726 7 : break; - 727 : case 'v' : - 728 26 : ++msg_level; - 729 26 : break; - 730 : case 'q' : - 731 726 : --msg_level; - 732 726 : break; - 733 : case 'G' : - 734 26 : opt.gui = 1; + 724 : case 'R' : + 725 1 : opt.force_realloc = 1; + 726 1 : break; + 727 : case 'a' : + 728 6 : opt.auditonly = 1; + 729 6 : break; + 730 : case 'h' : + 731 7 : opt.prehash = 1; + 732 7 : break; + 733 : case 'v' : + 734 26 : ++msg_level; 735 26 : break; - 736 : case 'H' : - 737 1 : usage(); - 738 1 : exit(EXIT_SUCCESS); - 739 : case 'V' : - 740 1 : version(); - 741 1 : exit(EXIT_SUCCESS); - 742 : case 'T' : - 743 4 : speedtest = 1; - 744 4 : break; - 745 : case 'C' : - 746 1 : gen_conf = optarg; - 747 1 : break; - 748 : case OPT_TEST_KILL_AFTER_SYNC : - 749 10 : opt.kill_after_sync = 1; - 750 10 : break; - 751 : case OPT_TEST_EXPECT_UNRECOVERABLE : - 752 13 : opt.expect_unrecoverable = 1; - 753 13 : break; - 754 : case OPT_TEST_EXPECT_RECOVERABLE : - 755 23 : opt.expect_recoverable = 1; - 756 23 : break; - 757 : case OPT_TEST_SKIP_SELF : - 758 268 : opt.skip_self = 1; - 759 268 : break; - 760 : case OPT_TEST_SKIP_SIGN : - 761 0 : opt.skip_sign = 1; - 762 0 : break; - 763 : case OPT_TEST_SKIP_FALLOCATE : - 764 1 : opt.skip_fallocate = 1; - 765 1 : break; - 766 : case OPT_TEST_SKIP_DEVICE : - 767 275 : opt.skip_device = 1; - 768 275 : period = 50; /* reduce period of the speed test */ - 769 275 : break; - 770 : case OPT_TEST_SKIP_CONTENT_CHECK : - 771 0 : opt.skip_content_check = 1; - 772 0 : break; - 773 : case OPT_TEST_SKIP_PARITY_ACCESS : - 774 0 : opt.skip_parity_access = 1; - 775 0 : break; - 776 : case OPT_TEST_SKIP_DISK_ACCESS : - 777 0 : opt.skip_disk_access = 1; + 736 : case 'q' : + 737 729 : --msg_level; + 738 729 : break; + 739 : case 'G' : + 740 26 : opt.gui = 1; + 741 26 : break; + 742 : case 'H' : + 743 1 : usage(); + 744 1 : exit(EXIT_SUCCESS); + 745 : case 'V' : + 746 1 : version(); + 747 1 : exit(EXIT_SUCCESS); + 748 : case 'T' : + 749 4 : speedtest = 1; + 750 4 : break; + 751 : case 'C' : + 752 1 : gen_conf = optarg; + 753 1 : break; + 754 : case OPT_TEST_KILL_AFTER_SYNC : + 755 10 : opt.kill_after_sync = 1; + 756 10 : break; + 757 : case OPT_TEST_EXPECT_UNRECOVERABLE : + 758 13 : opt.expect_unrecoverable = 1; + 759 13 : break; + 760 : case OPT_TEST_EXPECT_RECOVERABLE : + 761 23 : opt.expect_recoverable = 1; + 762 23 : break; + 763 : case OPT_TEST_SKIP_SELF : + 764 269 : opt.skip_self = 1; + 765 269 : break; + 766 : case OPT_TEST_SKIP_SIGN : + 767 0 : opt.skip_sign = 1; + 768 0 : break; + 769 : case OPT_TEST_SKIP_FALLOCATE : + 770 1 : opt.skip_fallocate = 1; + 771 1 : break; + 772 : case OPT_TEST_SKIP_DEVICE : + 773 276 : opt.skip_device = 1; + 774 276 : period = 50; /* reduce period of the speed test */ + 775 276 : break; + 776 : case OPT_TEST_SKIP_CONTENT_CHECK : + 777 0 : opt.skip_content_check = 1; 778 0 : break; - 779 : case OPT_TEST_FORCE_MURMUR3 : - 780 1 : opt.force_murmur3 = 1; - 781 1 : break; - 782 : case OPT_TEST_FORCE_SPOOKY2 : - 783 1 : opt.force_spooky2 = 1; - 784 1 : break; - 785 : case OPT_TEST_SKIP_LOCK : - 786 0 : opt.skip_lock = 1; - 787 0 : break; - 788 : case OPT_TEST_FORCE_ORDER_PHYSICAL : - 789 2 : opt.force_order = SORT_PHYSICAL; - 790 2 : break; - 791 : case OPT_TEST_FORCE_ORDER_INODE : - 792 0 : opt.force_order = SORT_INODE; + 779 : case OPT_TEST_SKIP_PARITY_ACCESS : + 780 0 : opt.skip_parity_access = 1; + 781 0 : break; + 782 : case OPT_TEST_SKIP_DISK_ACCESS : + 783 0 : opt.skip_disk_access = 1; + 784 0 : break; + 785 : case OPT_TEST_FORCE_MURMUR3 : + 786 1 : opt.force_murmur3 = 1; + 787 1 : break; + 788 : case OPT_TEST_FORCE_SPOOKY2 : + 789 1 : opt.force_spooky2 = 1; + 790 1 : break; + 791 : case OPT_TEST_SKIP_LOCK : + 792 0 : opt.skip_lock = 1; 793 0 : break; - 794 : case OPT_TEST_FORCE_ORDER_ALPHA : - 795 266 : opt.force_order = SORT_ALPHA; - 796 266 : break; - 797 : case OPT_TEST_FORCE_ORDER_DIR : - 798 0 : opt.force_order = SORT_DIR; + 794 : case OPT_TEST_FORCE_ORDER_PHYSICAL : + 795 2 : opt.force_order = SORT_PHYSICAL; + 796 2 : break; + 797 : case OPT_TEST_FORCE_ORDER_INODE : + 798 0 : opt.force_order = SORT_INODE; 799 0 : break; - 800 : case OPT_TEST_FORCE_SCRUB_AT : - 801 4 : opt.force_scrub_at = atoi(optarg); - 802 4 : break; - 803 : case OPT_TEST_FORCE_SCRUB_EVEN : - 804 1 : opt.force_scrub_even = 1; - 805 1 : break; - 806 : case OPT_TEST_FORCE_CONTENT_WRITE : - 807 0 : opt.force_content_write = 1; - 808 0 : break; - 809 : case OPT_TEST_EXPECT_FAILURE : - 810 : /* invert the exit codes */ - 811 19 : exit_success = 1; - 812 19 : exit_failure = 0; - 813 19 : break; - 814 : case OPT_TEST_EXPECT_NEED_SYNC : - 815 : /* invert the exit codes */ - 816 7 : exit_success = 1; - 817 7 : exit_sync_needed = 0; - 818 7 : break; - 819 : case OPT_TEST_RUN : - 820 10 : run = optarg; - 821 10 : break; - 822 : case OPT_TEST_FORCE_SCAN_WINFIND : - 823 0 : opt.force_scan_winfind = 1; - 824 0 : break; - 825 : case OPT_TEST_FORCE_PROGRESS : - 826 268 : opt.force_progress = 1; - 827 268 : break; - 828 : case OPT_TEST_FORCE_AUTOSAVE_AT : - 829 1 : opt.force_autosave_at = atoi(optarg); - 830 1 : break; - 831 : case OPT_TEST_FAKE_DEVICE : - 832 1 : opt.fake_device = 1; - 833 1 : break; - 834 : case OPT_NO_WARNINGS : - 835 269 : opt.no_warnings = 1; - 836 269 : break; - 837 : case OPT_TEST_FAKE_UUID : - 838 1 : opt.fake_uuid = 2; + 800 : case OPT_TEST_FORCE_ORDER_ALPHA : + 801 267 : opt.force_order = SORT_ALPHA; + 802 267 : break; + 803 : case OPT_TEST_FORCE_ORDER_DIR : + 804 0 : opt.force_order = SORT_DIR; + 805 0 : break; + 806 : case OPT_TEST_FORCE_SCRUB_AT : + 807 4 : opt.force_scrub_at = atoi(optarg); + 808 4 : break; + 809 : case OPT_TEST_FORCE_SCRUB_EVEN : + 810 1 : opt.force_scrub_even = 1; + 811 1 : break; + 812 : case OPT_TEST_FORCE_CONTENT_WRITE : + 813 0 : opt.force_content_write = 1; + 814 0 : break; + 815 : case OPT_TEST_EXPECT_FAILURE : + 816 : /* invert the exit codes */ + 817 19 : exit_success = 1; + 818 19 : exit_failure = 0; + 819 19 : break; + 820 : case OPT_TEST_EXPECT_NEED_SYNC : + 821 : /* invert the exit codes */ + 822 7 : exit_success = 1; + 823 7 : exit_sync_needed = 0; + 824 7 : break; + 825 : case OPT_TEST_RUN : + 826 10 : run = optarg; + 827 10 : break; + 828 : case OPT_TEST_FORCE_SCAN_WINFIND : + 829 0 : opt.force_scan_winfind = 1; + 830 0 : break; + 831 : case OPT_TEST_FORCE_PROGRESS : + 832 269 : opt.force_progress = 1; + 833 269 : break; + 834 : case OPT_TEST_FORCE_AUTOSAVE_AT : + 835 1 : opt.force_autosave_at = atoi(optarg); + 836 1 : break; + 837 : case OPT_TEST_FAKE_DEVICE : + 838 1 : opt.fake_device = 1; 839 1 : break; - 840 : case OPT_TEST_MATCH_FIRST_UUID : - 841 2 : opt.match_first_uuid = 1; - 842 2 : break; - 843 : case OPT_TEST_FORCE_PARITY_UPDATE : - 844 0 : opt.force_parity_update = 1; - 845 0 : break; - 846 : case OPT_TEST_IO_CACHE : - 847 1 : opt.io_cache = atoi(optarg); - 848 1 : if (opt.io_cache != 1 && (opt.io_cache < IO_MIN || opt.io_cache > IO_MAX)) { - 849 : /* LCOV_EXCL_START */ - 850 : log_fatal("The IO cache should be between %u and %u.\n", IO_MIN, IO_MAX); - 851 : exit(EXIT_FAILURE); - 852 : /* LCOV_EXCL_STOP */ - 853 : } - 854 1 : break; - 855 : case OPT_TEST_IO_STATS : - 856 1 : opt.force_stats = 1; - 857 1 : break; - 858 : case OPT_TEST_COND_SIGNAL_OUTSIDE : - 859 : #if HAVE_PTHREAD - 860 0 : thread_cond_signal_outside = 1; - 861 : #endif - 862 0 : break; - 863 : case OPT_TEST_IO_ADVISE_NONE : - 864 1 : opt.file_mode = ADVISE_NONE; - 865 1 : break; - 866 : case OPT_TEST_IO_ADVISE_SEQUENTIAL : - 867 1 : opt.file_mode = ADVISE_SEQUENTIAL; - 868 1 : break; - 869 : case OPT_TEST_IO_ADVISE_FLUSH : - 870 0 : opt.file_mode = ADVISE_FLUSH; - 871 0 : break; - 872 : case OPT_TEST_IO_ADVISE_FLUSH_WINDOW : - 873 1 : opt.file_mode = ADVISE_FLUSH_WINDOW; + 840 : case OPT_NO_WARNINGS : + 841 270 : opt.no_warnings = 1; + 842 270 : break; + 843 : case OPT_TEST_FAKE_UUID : + 844 1 : opt.fake_uuid = 2; + 845 1 : break; + 846 : case OPT_TEST_MATCH_FIRST_UUID : + 847 2 : opt.match_first_uuid = 1; + 848 2 : break; + 849 : case OPT_TEST_FORCE_PARITY_UPDATE : + 850 0 : opt.force_parity_update = 1; + 851 0 : break; + 852 : case OPT_TEST_IO_CACHE : + 853 1 : opt.io_cache = atoi(optarg); + 854 1 : if (opt.io_cache != 1 && (opt.io_cache < IO_MIN || opt.io_cache > IO_MAX)) { + 855 : /* LCOV_EXCL_START */ + 856 : log_fatal("The IO cache should be between %u and %u.\n", IO_MIN, IO_MAX); + 857 : exit(EXIT_FAILURE); + 858 : /* LCOV_EXCL_STOP */ + 859 : } + 860 1 : break; + 861 : case OPT_TEST_IO_STATS : + 862 1 : opt.force_stats = 1; + 863 1 : break; + 864 : case OPT_TEST_COND_SIGNAL_OUTSIDE : + 865 : #if HAVE_PTHREAD + 866 0 : thread_cond_signal_outside = 1; + 867 : #endif + 868 0 : break; + 869 : case OPT_TEST_IO_ADVISE_NONE : + 870 1 : opt.file_mode = ADVISE_NONE; + 871 1 : break; + 872 : case OPT_TEST_IO_ADVISE_SEQUENTIAL : + 873 1 : opt.file_mode = ADVISE_SEQUENTIAL; 874 1 : break; - 875 : case OPT_TEST_IO_ADVISE_DISCARD : - 876 0 : opt.file_mode = ADVISE_DISCARD; + 875 : case OPT_TEST_IO_ADVISE_FLUSH : + 876 0 : opt.file_mode = ADVISE_FLUSH; 877 0 : break; - 878 : case OPT_TEST_IO_ADVISE_DISCARD_WINDOW : - 879 1 : opt.file_mode = ADVISE_DISCARD_WINDOW; + 878 : case OPT_TEST_IO_ADVISE_FLUSH_WINDOW : + 879 1 : opt.file_mode = ADVISE_FLUSH_WINDOW; 880 1 : break; - 881 : case OPT_TEST_IO_ADVISE_DIRECT : - 882 0 : opt.file_mode = ADVISE_DIRECT; + 881 : case OPT_TEST_IO_ADVISE_DISCARD : + 882 0 : opt.file_mode = ADVISE_DISCARD; 883 0 : break; - 884 : case OPT_TEST_PARITY_LIMIT : - 885 268 : opt.parity_limit_size = atoll(optarg); - 886 268 : break; - 887 : case OPT_TEST_SKIP_CONTENT_WRITE : - 888 0 : opt.skip_content_write = 1; + 884 : case OPT_TEST_IO_ADVISE_DISCARD_WINDOW : + 885 1 : opt.file_mode = ADVISE_DISCARD_WINDOW; + 886 1 : break; + 887 : case OPT_TEST_IO_ADVISE_DIRECT : + 888 0 : opt.file_mode = ADVISE_DIRECT; 889 0 : break; - 890 : case OPT_TEST_SKIP_SPACE_HOLDER : - 891 0 : opt.skip_space_holder = 1; - 892 0 : break; - 893 : case OPT_TEST_FORMAT : - 894 3 : if (strcmp(optarg, "file") == 0) - 895 1 : FMT_MODE = FMT_FILE; - 896 2 : else if (strcmp(optarg, "disk") == 0) - 897 1 : FMT_MODE = FMT_DISK; - 898 1 : else if (strcmp(optarg, "path") == 0) - 899 1 : FMT_MODE = FMT_PATH; - 900 : else { - 901 : /* LCOV_EXCL_START */ - 902 : log_fatal("Unknown format '%s'\n", optarg); - 903 : exit(EXIT_FAILURE); - 904 : /* LCOV_EXCL_STOP */ - 905 : } - 906 3 : break; - 907 : default : - 908 : /* LCOV_EXCL_START */ - 909 : log_fatal("Unknown option '%c'\n", (char)c); - 910 : exit(EXIT_FAILURE); - 911 : /* LCOV_EXCL_STOP */ - 912 : } - 913 : } - 914 : - 915 270 : os_init(opt.force_scan_winfind); - 916 270 : raid_init(); - 917 270 : crc32c_init(); - 918 : - 919 270 : if (speedtest != 0) { - 920 4 : speed(period); - 921 4 : os_done(); - 922 4 : exit(EXIT_SUCCESS); - 923 : } + 890 : case OPT_TEST_PARITY_LIMIT : + 891 269 : opt.parity_limit_size = atoll(optarg); + 892 269 : break; + 893 : case OPT_TEST_SKIP_CONTENT_WRITE : + 894 0 : opt.skip_content_write = 1; + 895 0 : break; + 896 : case OPT_TEST_SKIP_SPACE_HOLDER : + 897 0 : opt.skip_space_holder = 1; + 898 0 : break; + 899 : case OPT_TEST_FORMAT : + 900 3 : if (strcmp(optarg, "file") == 0) + 901 1 : FMT_MODE = FMT_FILE; + 902 2 : else if (strcmp(optarg, "disk") == 0) + 903 1 : FMT_MODE = FMT_DISK; + 904 1 : else if (strcmp(optarg, "path") == 0) + 905 1 : FMT_MODE = FMT_PATH; + 906 : else { + 907 : /* LCOV_EXCL_START */ + 908 : log_fatal("Unknown format '%s'\n", optarg); + 909 : exit(EXIT_FAILURE); + 910 : /* LCOV_EXCL_STOP */ + 911 : } + 912 3 : break; + 913 : default : + 914 : /* LCOV_EXCL_START */ + 915 : log_fatal("Unknown option '%c'\n", (char)c); + 916 : exit(EXIT_FAILURE); + 917 : /* LCOV_EXCL_STOP */ + 918 : } + 919 : } + 920 : + 921 271 : os_init(opt.force_scan_winfind); + 922 271 : raid_init(); + 923 271 : crc32c_init(); 924 : - 925 266 : if (gen_conf != 0) { - 926 1 : generate_configuration(gen_conf); - 927 1 : os_done(); - 928 1 : exit(EXIT_SUCCESS); + 925 271 : if (speedtest != 0) { + 926 4 : speed(period); + 927 4 : os_done(); + 928 4 : exit(EXIT_SUCCESS); 929 : } 930 : - 931 265 : if (optind + 1 != argc) { - 932 : /* LCOV_EXCL_START */ - 933 : usage(); - 934 : exit(EXIT_FAILURE); - 935 : /* LCOV_EXCL_STOP */ - 936 : } - 937 : - 938 265 : command = argv[optind]; - 939 265 : if (strcmp(command, "diff") == 0) { - 940 8 : operation = OPERATION_DIFF; - 941 257 : } else if (strcmp(argv[optind], "sync") == 0) { - 942 89 : operation = OPERATION_SYNC; - 943 168 : } else if (strcmp(argv[optind], "check") == 0) { - 944 75 : operation = OPERATION_CHECK; - 945 93 : } else if (strcmp(argv[optind], "fix") == 0) { - 946 46 : operation = OPERATION_FIX; - 947 47 : } else if (strcmp(argv[optind], "test-dry") == 0) { - 948 2 : operation = OPERATION_DRY; - 949 45 : } else if (strcmp(argv[optind], "dup") == 0) { - 950 3 : operation = OPERATION_DUP; - 951 42 : } else if (strcmp(argv[optind], "list") == 0) { - 952 5 : operation = OPERATION_LIST; - 953 37 : } else if (strcmp(argv[optind], "pool") == 0) { - 954 3 : operation = OPERATION_POOL; - 955 34 : } else if (strcmp(argv[optind], "rehash") == 0) { - 956 1 : operation = OPERATION_REHASH; - 957 33 : } else if (strcmp(argv[optind], "scrub") == 0) { - 958 11 : operation = OPERATION_SCRUB; - 959 22 : } else if (strcmp(argv[optind], "status") == 0) { - 960 14 : operation = OPERATION_STATUS; - 961 8 : } else if (strcmp(argv[optind], "test-rewrite") == 0) { - 962 1 : operation = OPERATION_REWRITE; - 963 7 : } else if (strcmp(argv[optind], "test-read") == 0) { - 964 1 : operation = OPERATION_READ; - 965 6 : } else if (strcmp(argv[optind], "touch") == 0) { - 966 1 : operation = OPERATION_TOUCH; - 967 5 : } else if (strcmp(argv[optind], "up") == 0) { - 968 1 : operation = OPERATION_SPINUP; - 969 4 : } else if (strcmp(argv[optind], "down") == 0) { - 970 1 : operation = OPERATION_SPINDOWN; - 971 3 : } else if (strcmp(argv[optind], "devices") == 0) { - 972 1 : operation = OPERATION_DEVICES; - 973 2 : } else if (strcmp(argv[optind], "smart") == 0) { - 974 2 : operation = OPERATION_SMART; - 975 : } else { - 976 : /* LCOV_EXCL_START */ - 977 : log_fatal("Unknown command '%s'\n", argv[optind]); - 978 : exit(EXIT_FAILURE); - 979 : /* LCOV_EXCL_STOP */ - 980 : } - 981 : - 982 : /* check options compatibility */ - 983 265 : switch (operation) { - 984 : case OPERATION_CHECK : - 985 75 : break; - 986 : default : - 987 190 : if (opt.auditonly) { - 988 : /* LCOV_EXCL_START */ - 989 : log_fatal("You cannot use -a, --audit-only with the '%s' command\n", command); - 990 : exit(EXIT_FAILURE); - 991 : /* LCOV_EXCL_STOP */ - 992 : } - 993 : } - 994 : - 995 265 : switch (operation) { - 996 : case OPERATION_FIX : - 997 : case OPERATION_CHECK : - 998 121 : break; - 999 : default : - 1000 144 : if (opt.force_device) { - 1001 : /* LCOV_EXCL_START */ - 1002 : log_fatal("You cannot use -D, --force-device with the '%s' command\n", command); - 1003 : exit(EXIT_FAILURE); - 1004 : /* LCOV_EXCL_STOP */ - 1005 : } - 1006 : } - 1007 : - 1008 265 : switch (operation) { - 1009 : case OPERATION_SYNC : - 1010 : case OPERATION_CHECK : - 1011 : case OPERATION_FIX : - 1012 210 : break; - 1013 : default : - 1014 55 : if (opt.force_nocopy) { - 1015 : /* LCOV_EXCL_START */ - 1016 : log_fatal("You cannot use -N, --force-nocopy with the '%s' command\n", command); - 1017 : exit(EXIT_FAILURE); - 1018 : /* LCOV_EXCL_STOP */ - 1019 : } - 1020 : } - 1021 : - 1022 265 : switch (operation) { - 1023 : case OPERATION_SYNC : - 1024 89 : break; - 1025 : default : - 1026 176 : if (opt.prehash) { - 1027 : /* LCOV_EXCL_START */ - 1028 : log_fatal("You cannot use -h, --pre-hash with the '%s' command\n", command); - 1029 : exit(EXIT_FAILURE); - 1030 : /* LCOV_EXCL_STOP */ - 1031 : } - 1032 : - 1033 176 : if (opt.force_full) { - 1034 : /* LCOV_EXCL_START */ - 1035 : log_fatal("You cannot use -F, --force-full with the '%s' command\n", command); - 1036 : exit(EXIT_FAILURE); - 1037 : /* LCOV_EXCL_STOP */ - 1038 : } - 1039 : - 1040 176 : if (opt.force_realloc) { - 1041 : /* LCOV_EXCL_START */ - 1042 : log_fatal("You cannot use -R, --force-realloc with the '%s' command\n", command); - 1043 : exit(EXIT_FAILURE); - 1044 : /* LCOV_EXCL_STOP */ - 1045 : } - 1046 : } - 1047 : - 1048 265 : if (opt.force_full && opt.force_nocopy) { - 1049 : /* LCOV_EXCL_START */ - 1050 : log_fatal("You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n"); - 1051 : exit(EXIT_FAILURE); - 1052 : /* LCOV_EXCL_STOP */ - 1053 : } - 1054 : - 1055 265 : if (opt.force_realloc && opt.force_nocopy) { - 1056 : /* LCOV_EXCL_START */ - 1057 : log_fatal("You cannot use the -R, --force-realloc and -N, --force-nocopy options at the same time\n"); - 1058 : exit(EXIT_FAILURE); - 1059 : /* LCOV_EXCL_STOP */ - 1060 : } - 1061 : - 1062 265 : if (opt.force_realloc && opt.force_full) { - 1063 : /* LCOV_EXCL_START */ - 1064 : log_fatal("You cannot use the -R, --force-realloc and -F, --force-full options at the same time\n"); - 1065 : exit(EXIT_FAILURE); - 1066 : /* LCOV_EXCL_STOP */ - 1067 : } - 1068 : - 1069 265 : if (opt.prehash && opt.force_nocopy) { - 1070 : /* LCOV_EXCL_START */ - 1071 : log_fatal("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n"); - 1072 : exit(EXIT_FAILURE); - 1073 : /* LCOV_EXCL_STOP */ - 1074 : } - 1075 : - 1076 265 : switch (operation) { - 1077 : case OPERATION_CHECK : - 1078 : case OPERATION_FIX : - 1079 : case OPERATION_DRY : - 1080 123 : break; - 1081 : default : - 1082 140 : if (!tommy_list_empty(&filterlist_disk)) { - 1083 : /* LCOV_EXCL_START */ - 1084 : log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command); - 1085 : exit(EXIT_FAILURE); - 1086 : /* LCOV_EXCL_STOP */ - 1087 : } - 1088 : /* follow */ - 1089 : case OPERATION_SPINUP : - 1090 : case OPERATION_SPINDOWN : - 1091 142 : if (!tommy_list_empty(&filterlist_file)) { - 1092 : /* LCOV_EXCL_START */ - 1093 : log_fatal("You cannot use -f, --filter with the '%s' command\n", command); - 1094 : exit(EXIT_FAILURE); - 1095 : /* LCOV_EXCL_STOP */ - 1096 : } - 1097 142 : if (filter_missing != 0) { + 931 267 : if (gen_conf != 0) { + 932 1 : generate_configuration(gen_conf); + 933 1 : os_done(); + 934 1 : exit(EXIT_SUCCESS); + 935 : } + 936 : + 937 266 : if (optind + 1 != argc) { + 938 : /* LCOV_EXCL_START */ + 939 : usage(); + 940 : exit(EXIT_FAILURE); + 941 : /* LCOV_EXCL_STOP */ + 942 : } + 943 : + 944 266 : command = argv[optind]; + 945 266 : if (strcmp(command, "diff") == 0) { + 946 8 : operation = OPERATION_DIFF; + 947 258 : } else if (strcmp(argv[optind], "sync") == 0) { + 948 89 : operation = OPERATION_SYNC; + 949 169 : } else if (strcmp(argv[optind], "check") == 0) { + 950 75 : operation = OPERATION_CHECK; + 951 94 : } else if (strcmp(argv[optind], "fix") == 0) { + 952 46 : operation = OPERATION_FIX; + 953 48 : } else if (strcmp(argv[optind], "test-dry") == 0) { + 954 2 : operation = OPERATION_DRY; + 955 46 : } else if (strcmp(argv[optind], "dup") == 0) { + 956 3 : operation = OPERATION_DUP; + 957 43 : } else if (strcmp(argv[optind], "list") == 0) { + 958 5 : operation = OPERATION_LIST; + 959 38 : } else if (strcmp(argv[optind], "pool") == 0) { + 960 3 : operation = OPERATION_POOL; + 961 35 : } else if (strcmp(argv[optind], "rehash") == 0) { + 962 1 : operation = OPERATION_REHASH; + 963 34 : } else if (strcmp(argv[optind], "scrub") == 0) { + 964 11 : operation = OPERATION_SCRUB; + 965 23 : } else if (strcmp(argv[optind], "status") == 0) { + 966 15 : operation = OPERATION_STATUS; + 967 8 : } else if (strcmp(argv[optind], "test-rewrite") == 0) { + 968 1 : operation = OPERATION_REWRITE; + 969 7 : } else if (strcmp(argv[optind], "test-read") == 0) { + 970 1 : operation = OPERATION_READ; + 971 6 : } else if (strcmp(argv[optind], "touch") == 0) { + 972 1 : operation = OPERATION_TOUCH; + 973 5 : } else if (strcmp(argv[optind], "up") == 0) { + 974 1 : operation = OPERATION_SPINUP; + 975 4 : } else if (strcmp(argv[optind], "down") == 0) { + 976 1 : operation = OPERATION_SPINDOWN; + 977 3 : } else if (strcmp(argv[optind], "devices") == 0) { + 978 1 : operation = OPERATION_DEVICES; + 979 2 : } else if (strcmp(argv[optind], "smart") == 0) { + 980 2 : operation = OPERATION_SMART; + 981 : } else { + 982 : /* LCOV_EXCL_START */ + 983 : log_fatal("Unknown command '%s'\n", argv[optind]); + 984 : exit(EXIT_FAILURE); + 985 : /* LCOV_EXCL_STOP */ + 986 : } + 987 : + 988 : /* check options compatibility */ + 989 266 : switch (operation) { + 990 : case OPERATION_CHECK : + 991 75 : break; + 992 : default : + 993 191 : if (opt.auditonly) { + 994 : /* LCOV_EXCL_START */ + 995 : log_fatal("You cannot use -a, --audit-only with the '%s' command\n", command); + 996 : exit(EXIT_FAILURE); + 997 : /* LCOV_EXCL_STOP */ + 998 : } + 999 : } + 1000 : + 1001 266 : switch (operation) { + 1002 : case OPERATION_FIX : + 1003 : case OPERATION_CHECK : + 1004 121 : break; + 1005 : default : + 1006 145 : if (opt.force_device) { + 1007 : /* LCOV_EXCL_START */ + 1008 : log_fatal("You cannot use -D, --force-device with the '%s' command\n", command); + 1009 : exit(EXIT_FAILURE); + 1010 : /* LCOV_EXCL_STOP */ + 1011 : } + 1012 : } + 1013 : + 1014 266 : switch (operation) { + 1015 : case OPERATION_SYNC : + 1016 : case OPERATION_CHECK : + 1017 : case OPERATION_FIX : + 1018 210 : break; + 1019 : default : + 1020 56 : if (opt.force_nocopy) { + 1021 : /* LCOV_EXCL_START */ + 1022 : log_fatal("You cannot use -N, --force-nocopy with the '%s' command\n", command); + 1023 : exit(EXIT_FAILURE); + 1024 : /* LCOV_EXCL_STOP */ + 1025 : } + 1026 : } + 1027 : + 1028 266 : switch (operation) { + 1029 : case OPERATION_SYNC : + 1030 89 : break; + 1031 : default : + 1032 177 : if (opt.prehash) { + 1033 : /* LCOV_EXCL_START */ + 1034 : log_fatal("You cannot use -h, --pre-hash with the '%s' command\n", command); + 1035 : exit(EXIT_FAILURE); + 1036 : /* LCOV_EXCL_STOP */ + 1037 : } + 1038 : + 1039 177 : if (opt.force_full) { + 1040 : /* LCOV_EXCL_START */ + 1041 : log_fatal("You cannot use -F, --force-full with the '%s' command\n", command); + 1042 : exit(EXIT_FAILURE); + 1043 : /* LCOV_EXCL_STOP */ + 1044 : } + 1045 : + 1046 177 : if (opt.force_realloc) { + 1047 : /* LCOV_EXCL_START */ + 1048 : log_fatal("You cannot use -R, --force-realloc with the '%s' command\n", command); + 1049 : exit(EXIT_FAILURE); + 1050 : /* LCOV_EXCL_STOP */ + 1051 : } + 1052 : } + 1053 : + 1054 266 : if (opt.force_full && opt.force_nocopy) { + 1055 : /* LCOV_EXCL_START */ + 1056 : log_fatal("You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n"); + 1057 : exit(EXIT_FAILURE); + 1058 : /* LCOV_EXCL_STOP */ + 1059 : } + 1060 : + 1061 266 : if (opt.force_realloc && opt.force_nocopy) { + 1062 : /* LCOV_EXCL_START */ + 1063 : log_fatal("You cannot use the -R, --force-realloc and -N, --force-nocopy options at the same time\n"); + 1064 : exit(EXIT_FAILURE); + 1065 : /* LCOV_EXCL_STOP */ + 1066 : } + 1067 : + 1068 266 : if (opt.force_realloc && opt.force_full) { + 1069 : /* LCOV_EXCL_START */ + 1070 : log_fatal("You cannot use the -R, --force-realloc and -F, --force-full options at the same time\n"); + 1071 : exit(EXIT_FAILURE); + 1072 : /* LCOV_EXCL_STOP */ + 1073 : } + 1074 : + 1075 266 : if (opt.prehash && opt.force_nocopy) { + 1076 : /* LCOV_EXCL_START */ + 1077 : log_fatal("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n"); + 1078 : exit(EXIT_FAILURE); + 1079 : /* LCOV_EXCL_STOP */ + 1080 : } + 1081 : + 1082 266 : switch (operation) { + 1083 : case OPERATION_CHECK : + 1084 : case OPERATION_FIX : + 1085 : case OPERATION_DRY : + 1086 123 : break; + 1087 : default : + 1088 141 : if (!tommy_list_empty(&filterlist_disk)) { + 1089 : /* LCOV_EXCL_START */ + 1090 : log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command); + 1091 : exit(EXIT_FAILURE); + 1092 : /* LCOV_EXCL_STOP */ + 1093 : } + 1094 : /* follow */ + 1095 : case OPERATION_SPINUP : + 1096 : case OPERATION_SPINDOWN : + 1097 143 : if (!tommy_list_empty(&filterlist_file)) { 1098 : /* LCOV_EXCL_START */ - 1099 : log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command); + 1099 : log_fatal("You cannot use -f, --filter with the '%s' command\n", command); 1100 : exit(EXIT_FAILURE); 1101 : /* LCOV_EXCL_STOP */ 1102 : } - 1103 142 : if (filter_error != 0) { + 1103 143 : if (filter_missing != 0) { 1104 : /* LCOV_EXCL_START */ - 1105 : log_fatal("You cannot use -e, --filter-error with the '%s' command\n", command); + 1105 : log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command); 1106 : exit(EXIT_FAILURE); 1107 : /* LCOV_EXCL_STOP */ 1108 : } - 1109 : } - 1110 : - 1111 : /* errors must be always fixed on all disks */ - 1112 : /* because we don't keep the information on what disk is the error */ - 1113 265 : if (filter_error != 0 && !tommy_list_empty(&filterlist_disk)) { - 1114 : /* LCOV_EXCL_START */ - 1115 : log_fatal("You cannot use -e, --filter-error and -d, --filter-disk at the same time\n"); - 1116 : exit(EXIT_FAILURE); - 1117 : /* LCOV_EXCL_STOP */ - 1118 : } - 1119 : - 1120 265 : switch (operation) { - 1121 : case OPERATION_CHECK : - 1122 : case OPERATION_FIX : - 1123 121 : break; - 1124 : default : - 1125 144 : if (import_timestamp != 0 || import_content != 0) { - 1126 : /* LCOV_EXCL_START */ - 1127 : log_fatal("You cannot import with the '%s' command\n", command); - 1128 : exit(EXIT_FAILURE); - 1129 : /* LCOV_EXCL_STOP */ - 1130 : } - 1131 : } - 1132 : - 1133 265 : switch (operation) { - 1134 : case OPERATION_LIST : - 1135 : case OPERATION_DUP : - 1136 : case OPERATION_STATUS : - 1137 : case OPERATION_REWRITE : - 1138 : case OPERATION_READ : - 1139 : case OPERATION_REHASH : - 1140 : case OPERATION_SPINUP : /* we want to do it in different threads to avoid blocking */ - 1141 : /* avoid to check and access data disks if not needed */ - 1142 26 : opt.skip_disk_access = 1; - 1143 26 : break; - 1144 : } - 1145 : - 1146 265 : switch (operation) { - 1147 : case OPERATION_DIFF : - 1148 : case OPERATION_LIST : - 1149 : case OPERATION_DUP : - 1150 : case OPERATION_POOL : - 1151 : case OPERATION_STATUS : - 1152 : case OPERATION_REWRITE : - 1153 : case OPERATION_READ : - 1154 : case OPERATION_REHASH : - 1155 : case OPERATION_TOUCH : - 1156 : case OPERATION_SPINUP : /* we want to do it in different threads to avoid blocking */ - 1157 : /* avoid to check and access parity disks if not needed */ - 1158 38 : opt.skip_parity_access = 1; - 1159 38 : break; - 1160 : } - 1161 : - 1162 265 : switch (operation) { - 1163 : case OPERATION_FIX : - 1164 : case OPERATION_CHECK : - 1165 : /* avoid to stop processing if a content file is not accessible */ - 1166 121 : opt.skip_content_access = 1; - 1167 121 : break; - 1168 : } - 1169 : - 1170 265 : switch (operation) { - 1171 : case OPERATION_DIFF : - 1172 : case OPERATION_LIST : - 1173 : case OPERATION_DUP : - 1174 : case OPERATION_POOL : - 1175 : case OPERATION_TOUCH : - 1176 : case OPERATION_SPINUP : - 1177 : case OPERATION_SPINDOWN : - 1178 : case OPERATION_DEVICES : - 1179 : case OPERATION_SMART : - 1180 25 : opt.skip_self = 1; - 1181 25 : break; - 1182 : } - 1183 : - 1184 265 : switch (operation) { - 1185 : #if HAVE_DIRECT_IO - 1186 : case OPERATION_SYNC : - 1187 : case OPERATION_SCRUB : - 1188 : case OPERATION_DRY : - 1189 102 : break; - 1190 : #endif - 1191 : default: - 1192 : /* we allow direct IO only on some commands */ - 1193 163 : if (opt.file_mode == ADVISE_DIRECT) - 1194 0 : opt.file_mode = ADVISE_SEQUENTIAL; - 1195 163 : break; - 1196 : } - 1197 : - 1198 265 : switch (operation) { - 1199 : case OPERATION_DEVICES : - 1200 : case OPERATION_SMART : - 1201 : /* we may need to use these commands during operations */ - 1202 3 : opt.skip_lock = 1; - 1203 3 : break; - 1204 : } - 1205 : - 1206 265 : switch (operation) { - 1207 : case OPERATION_SMART : - 1208 : /* allow to run without configuration file */ - 1209 2 : opt.auto_conf = 1; - 1210 2 : break; - 1211 : } - 1212 : - 1213 : /* open the log file */ - 1214 265 : log_open(log_file); - 1215 : - 1216 : /* print generic info into the log */ - 1217 265 : t = time(0); - 1218 265 : tm = localtime(&t); - 1219 265 : log_tag("version:%s\n", PACKAGE_VERSION); - 1220 265 : log_tag("unixtime:%" PRIi64 "\n", (int64_t)t); - 1221 265 : if (tm) { - 1222 : char datetime[64]; - 1223 265 : strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); - 1224 265 : log_tag("time:%s\n", datetime); - 1225 : } - 1226 265 : log_tag("command:%s\n", command); - 1227 4052 : for (i = 0; i < argc; ++i) - 1228 3787 : log_tag("argv:%u:%s\n", i, argv[i]); - 1229 265 : log_flush(); - 1230 : - 1231 265 : if (!opt.skip_self) - 1232 1 : selftest(); - 1233 : - 1234 265 : state_init(&state); - 1235 : - 1236 : /* read the configuration file */ - 1237 265 : state_config(&state, conf, command, &opt, &filterlist_disk); - 1238 : - 1239 : /* set the raid mode */ - 1240 264 : raid_mode(state.raid_mode); + 1109 143 : if (filter_error != 0) { + 1110 : /* LCOV_EXCL_START */ + 1111 : log_fatal("You cannot use -e, --filter-error with the '%s' command\n", command); + 1112 : exit(EXIT_FAILURE); + 1113 : /* LCOV_EXCL_STOP */ + 1114 : } + 1115 : } + 1116 : + 1117 : /* errors must be always fixed on all disks */ + 1118 : /* because we don't keep the information on what disk is the error */ + 1119 266 : if (filter_error != 0 && !tommy_list_empty(&filterlist_disk)) { + 1120 : /* LCOV_EXCL_START */ + 1121 : log_fatal("You cannot use -e, --filter-error and -d, --filter-disk at the same time\n"); + 1122 : exit(EXIT_FAILURE); + 1123 : /* LCOV_EXCL_STOP */ + 1124 : } + 1125 : + 1126 266 : switch (operation) { + 1127 : case OPERATION_CHECK : + 1128 : case OPERATION_FIX : + 1129 121 : break; + 1130 : default : + 1131 145 : if (import_timestamp != 0 || import_content != 0) { + 1132 : /* LCOV_EXCL_START */ + 1133 : log_fatal("You cannot import with the '%s' command\n", command); + 1134 : exit(EXIT_FAILURE); + 1135 : /* LCOV_EXCL_STOP */ + 1136 : } + 1137 : } + 1138 : + 1139 266 : switch (operation) { + 1140 : case OPERATION_LIST : + 1141 : case OPERATION_DUP : + 1142 : case OPERATION_STATUS : + 1143 : case OPERATION_REWRITE : + 1144 : case OPERATION_READ : + 1145 : case OPERATION_REHASH : + 1146 : case OPERATION_SPINUP : /* we want to do it in different threads to avoid blocking */ + 1147 : /* avoid to check and access data disks if not needed */ + 1148 27 : opt.skip_disk_access = 1; + 1149 27 : break; + 1150 : } + 1151 : + 1152 266 : switch (operation) { + 1153 : case OPERATION_DIFF : + 1154 : case OPERATION_LIST : + 1155 : case OPERATION_DUP : + 1156 : case OPERATION_POOL : + 1157 : case OPERATION_STATUS : + 1158 : case OPERATION_REWRITE : + 1159 : case OPERATION_READ : + 1160 : case OPERATION_REHASH : + 1161 : case OPERATION_TOUCH : + 1162 : case OPERATION_SPINUP : /* we want to do it in different threads to avoid blocking */ + 1163 : /* avoid to check and access parity disks if not needed */ + 1164 39 : opt.skip_parity_access = 1; + 1165 39 : break; + 1166 : } + 1167 : + 1168 266 : switch (operation) { + 1169 : case OPERATION_FIX : + 1170 : case OPERATION_CHECK : + 1171 : /* avoid to stop processing if a content file is not accessible */ + 1172 121 : opt.skip_content_access = 1; + 1173 121 : break; + 1174 : } + 1175 : + 1176 266 : switch (operation) { + 1177 : case OPERATION_DIFF : + 1178 : case OPERATION_LIST : + 1179 : case OPERATION_DUP : + 1180 : case OPERATION_POOL : + 1181 : case OPERATION_TOUCH : + 1182 : case OPERATION_SPINUP : + 1183 : case OPERATION_SPINDOWN : + 1184 : case OPERATION_DEVICES : + 1185 : case OPERATION_SMART : + 1186 25 : opt.skip_self = 1; + 1187 25 : break; + 1188 : } + 1189 : + 1190 266 : switch (operation) { + 1191 : #if HAVE_DIRECT_IO + 1192 : case OPERATION_SYNC : + 1193 : case OPERATION_SCRUB : + 1194 : case OPERATION_DRY : + 1195 102 : break; + 1196 : #endif + 1197 : default: + 1198 : /* we allow direct IO only on some commands */ + 1199 164 : if (opt.file_mode == ADVISE_DIRECT) + 1200 0 : opt.file_mode = ADVISE_SEQUENTIAL; + 1201 164 : break; + 1202 : } + 1203 : + 1204 266 : switch (operation) { + 1205 : case OPERATION_DEVICES : + 1206 : case OPERATION_SMART : + 1207 : /* we may need to use these commands during operations */ + 1208 3 : opt.skip_lock = 1; + 1209 3 : break; + 1210 : } + 1211 : + 1212 266 : switch (operation) { + 1213 : case OPERATION_SMART : + 1214 : /* allow to run without configuration file */ + 1215 2 : opt.auto_conf = 1; + 1216 2 : break; + 1217 : } + 1218 : + 1219 : /* open the log file */ + 1220 266 : log_open(log_file); + 1221 : + 1222 : /* print generic info into the log */ + 1223 266 : t = time(0); + 1224 266 : tm = localtime(&t); + 1225 266 : log_tag("version:%s\n", PACKAGE_VERSION); + 1226 266 : log_tag("unixtime:%" PRIi64 "\n", (int64_t)t); + 1227 266 : if (tm) { + 1228 : char datetime[64]; + 1229 266 : strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); + 1230 266 : log_tag("time:%s\n", datetime); + 1231 : } + 1232 266 : log_tag("command:%s\n", command); + 1233 4066 : for (i = 0; i < argc; ++i) + 1234 3800 : log_tag("argv:%u:%s\n", i, argv[i]); + 1235 266 : log_flush(); + 1236 : + 1237 266 : if (!opt.skip_self) + 1238 1 : selftest(); + 1239 : + 1240 266 : state_init(&state); 1241 : - 1242 : #if HAVE_LOCKFILE - 1243 : /* create the lock file */ - 1244 264 : if (!opt.skip_lock && state.lockfile[0]) { - 1245 261 : lock = lock_lock(state.lockfile); - 1246 261 : if (lock == -1) { - 1247 : /* LCOV_EXCL_START */ - 1248 : if (errno != EWOULDBLOCK) { - 1249 : log_fatal("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); - 1250 : } else { - 1251 : log_fatal("The lock file '%s' is already locked!\n", state.lockfile); - 1252 : log_fatal("SnapRAID is already in use!\n"); - 1253 : } - 1254 : exit(EXIT_FAILURE); - 1255 : /* LCOV_EXCL_STOP */ - 1256 : } - 1257 : } - 1258 : #else - 1259 : (void)lock; - 1260 : #endif - 1261 : - 1262 264 : if (operation == OPERATION_DIFF) { - 1263 8 : state_read(&state); - 1264 : - 1265 8 : ret = state_diff(&state); - 1266 : - 1267 : /* abort if sync needed */ - 1268 8 : if (ret > 0) - 1269 7 : exit(EXIT_SYNC_NEEDED); - 1270 256 : } else if (operation == OPERATION_SYNC) { - 1271 : - 1272 : /* in the next state read ensures to clear all the past hashes in case */ - 1273 : /* we are reading from an incomplete sync */ - 1274 : /* The indeterminate hash are only for CHG/DELETED blocks for which we don't */ - 1275 : /* know if the previous interrupted sync was able to update or not the parity. */ - 1276 : /* The sync process instead needs to trust this information because it's used */ - 1277 : /* to avoid to recompute the parity if all the input are equals as before. */ - 1278 : - 1279 : /* In these cases we don't know if the old state is still the one */ - 1280 : /* stored inside the parity, because after an aborted sync, the parity */ - 1281 : /* may be or may be not have been updated with the data that may be now */ - 1282 : /* deleted. Then we reset the hash to a bogus value. */ - 1283 : - 1284 : /* An example for CHG blocks is: */ - 1285 : /* - One file is added creating a CHG block with ZERO state */ - 1286 : /* - Sync aborted after updating the parity to the new state, */ - 1287 : /* but without saving the content file representing this new BLK state. */ - 1288 : /* - File is now deleted after the aborted sync */ - 1289 : /* - Sync again, deleting the blocks over the CHG ones */ - 1290 : /* with the hash of CHG blocks not representing the real parity state */ - 1291 : - 1292 : /* An example for DELETED blocks is: */ - 1293 : /* - One file is deleted creating DELETED blocks */ - 1294 : /* - Sync aborted after, updating the parity to the new state, */ - 1295 : /* but without saving the content file representing this new EMPTY state. */ - 1296 : /* - Another file is added again over the DELETE ones */ - 1297 : /* with the hash of DELETED blocks not representing the real parity state */ - 1298 89 : state.clear_past_hash = 1; - 1299 : - 1300 89 : state_read(&state); - 1301 : - 1302 88 : state_scan(&state); - 1303 : - 1304 : /* refresh the size info before the content write */ - 1305 87 : state_refresh(&state); - 1306 : - 1307 87 : memory(); - 1308 : - 1309 : /* intercept signals while operating */ - 1310 87 : signal_init(); - 1311 : - 1312 : /* run a test command if required */ - 1313 87 : if (run != 0) { - 1314 10 : ret = system(run); /* ignore error */ - 1315 10 : if (ret != 0) { - 1316 : /* LCOV_EXCL_START */ - 1317 : log_fatal("Error in running command '%s'.\n", run); - 1318 : exit(EXIT_FAILURE); - 1319 : /* LCOV_EXCL_STOP */ - 1320 : } - 1321 : } - 1322 : - 1323 : /* waits some time to ensure that any concurrent modification done at the files, */ - 1324 : /* using the same mtime read by the scan process, will be read by sync. */ - 1325 : /* Note that any later modification done, potentially not read by sync, will have */ - 1326 : /* a different mtime, and it will be synchronized at the next sync. */ - 1327 : /* The worst case is the FAT file-system with a two seconds resolution for mtime. */ - 1328 : /* If you don't use FAT, the wait is not needed, because most file-systems have now */ - 1329 : /* at least microseconds resolution, but better to be safe. */ - 1330 87 : if (!opt.skip_self) - 1331 0 : sleep(2); - 1332 : - 1333 87 : ret = state_sync(&state, blockstart, blockcount); - 1334 : - 1335 : /* save the new state if required */ - 1336 87 : if (!opt.kill_after_sync) { - 1337 77 : if ((state.need_write || state.opt.force_content_write)) - 1338 58 : state_write(&state); - 1339 : } else { - 1340 10 : log_fatal("WARNING! Skipped state write for --test-kill-after-sync option.\n"); - 1341 : } - 1342 : - 1343 : /* abort if required */ - 1344 87 : if (ret != 0) { - 1345 : /* LCOV_EXCL_START */ - 1346 : exit(EXIT_FAILURE); - 1347 : /* LCOV_EXCL_STOP */ - 1348 : } - 1349 167 : } else if (operation == OPERATION_DRY) { - 1350 2 : state_read(&state); - 1351 : - 1352 : /* filter */ - 1353 2 : state_skip(&state); - 1354 2 : state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error); - 1355 : - 1356 2 : memory(); + 1242 : /* read the configuration file */ + 1243 266 : state_config(&state, conf, command, &opt, &filterlist_disk); + 1244 : + 1245 : /* set the raid mode */ + 1246 265 : raid_mode(state.raid_mode); + 1247 : + 1248 : #if HAVE_LOCKFILE + 1249 : /* create the lock file */ + 1250 265 : if (!opt.skip_lock && state.lockfile[0]) { + 1251 262 : lock = lock_lock(state.lockfile); + 1252 262 : if (lock == -1) { + 1253 : /* LCOV_EXCL_START */ + 1254 : if (errno != EWOULDBLOCK) { + 1255 : log_fatal("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); + 1256 : } else { + 1257 : log_fatal("The lock file '%s' is already locked!\n", state.lockfile); + 1258 : log_fatal("SnapRAID is already in use!\n"); + 1259 : } + 1260 : exit(EXIT_FAILURE); + 1261 : /* LCOV_EXCL_STOP */ + 1262 : } + 1263 : } + 1264 : #else + 1265 : (void)lock; + 1266 : #endif + 1267 : + 1268 265 : if (operation == OPERATION_DIFF) { + 1269 8 : state_read(&state); + 1270 : + 1271 8 : ret = state_diff(&state); + 1272 : + 1273 : /* abort if sync needed */ + 1274 8 : if (ret > 0) + 1275 7 : exit(EXIT_SYNC_NEEDED); + 1276 257 : } else if (operation == OPERATION_SYNC) { + 1277 : + 1278 : /* in the next state read ensures to clear all the past hashes in case */ + 1279 : /* we are reading from an incomplete sync */ + 1280 : /* The indeterminate hash are only for CHG/DELETED blocks for which we don't */ + 1281 : /* know if the previous interrupted sync was able to update or not the parity. */ + 1282 : /* The sync process instead needs to trust this information because it's used */ + 1283 : /* to avoid to recompute the parity if all the input are equals as before. */ + 1284 : + 1285 : /* In these cases we don't know if the old state is still the one */ + 1286 : /* stored inside the parity, because after an aborted sync, the parity */ + 1287 : /* may be or may be not have been updated with the data that may be now */ + 1288 : /* deleted. Then we reset the hash to a bogus value. */ + 1289 : + 1290 : /* An example for CHG blocks is: */ + 1291 : /* - One file is added creating a CHG block with ZERO state */ + 1292 : /* - Sync aborted after updating the parity to the new state, */ + 1293 : /* but without saving the content file representing this new BLK state. */ + 1294 : /* - File is now deleted after the aborted sync */ + 1295 : /* - Sync again, deleting the blocks over the CHG ones */ + 1296 : /* with the hash of CHG blocks not representing the real parity state */ + 1297 : + 1298 : /* An example for DELETED blocks is: */ + 1299 : /* - One file is deleted creating DELETED blocks */ + 1300 : /* - Sync aborted after, updating the parity to the new state, */ + 1301 : /* but without saving the content file representing this new EMPTY state. */ + 1302 : /* - Another file is added again over the DELETE ones */ + 1303 : /* with the hash of DELETED blocks not representing the real parity state */ + 1304 89 : state.clear_past_hash = 1; + 1305 : + 1306 89 : state_read(&state); + 1307 : + 1308 88 : state_scan(&state); + 1309 : + 1310 : /* refresh the size info before the content write */ + 1311 87 : state_refresh(&state); + 1312 : + 1313 87 : memory(); + 1314 : + 1315 : /* intercept signals while operating */ + 1316 87 : signal_init(); + 1317 : + 1318 : /* run a test command if required */ + 1319 87 : if (run != 0) { + 1320 10 : ret = system(run); /* ignore error */ + 1321 10 : if (ret != 0) { + 1322 : /* LCOV_EXCL_START */ + 1323 : log_fatal("Error in running command '%s'.\n", run); + 1324 : exit(EXIT_FAILURE); + 1325 : /* LCOV_EXCL_STOP */ + 1326 : } + 1327 : } + 1328 : + 1329 : /* waits some time to ensure that any concurrent modification done at the files, */ + 1330 : /* using the same mtime read by the scan process, will be read by sync. */ + 1331 : /* Note that any later modification done, potentially not read by sync, will have */ + 1332 : /* a different mtime, and it will be synchronized at the next sync. */ + 1333 : /* The worst case is the FAT file-system with a two seconds resolution for mtime. */ + 1334 : /* If you don't use FAT, the wait is not needed, because most file-systems have now */ + 1335 : /* at least microseconds resolution, but better to be safe. */ + 1336 87 : if (!opt.skip_self) + 1337 0 : sleep(2); + 1338 : + 1339 87 : ret = state_sync(&state, blockstart, blockcount); + 1340 : + 1341 : /* save the new state if required */ + 1342 87 : if (!opt.kill_after_sync) { + 1343 77 : if ((state.need_write || state.opt.force_content_write)) + 1344 58 : state_write(&state); + 1345 : } else { + 1346 10 : log_fatal("WARNING! Skipped state write for --test-kill-after-sync option.\n"); + 1347 : } + 1348 : + 1349 : /* abort if required */ + 1350 87 : if (ret != 0) { + 1351 : /* LCOV_EXCL_START */ + 1352 : exit(EXIT_FAILURE); + 1353 : /* LCOV_EXCL_STOP */ + 1354 : } + 1355 168 : } else if (operation == OPERATION_DRY) { + 1356 2 : state_read(&state); 1357 : - 1358 : /* intercept signals while operating */ - 1359 2 : signal_init(); - 1360 : - 1361 2 : state_dry(&state, blockstart, blockcount); - 1362 165 : } else if (operation == OPERATION_REHASH) { - 1363 1 : state_read(&state); - 1364 : - 1365 : /* intercept signals while operating */ - 1366 1 : signal_init(); - 1367 : - 1368 1 : state_rehash(&state); - 1369 : - 1370 : /* save the new state if required */ - 1371 1 : if (state.need_write) - 1372 1 : state_write(&state); - 1373 164 : } else if (operation == OPERATION_SCRUB) { - 1374 11 : state_read(&state); + 1358 : /* filter */ + 1359 2 : state_skip(&state); + 1360 2 : state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error); + 1361 : + 1362 2 : memory(); + 1363 : + 1364 : /* intercept signals while operating */ + 1365 2 : signal_init(); + 1366 : + 1367 2 : state_dry(&state, blockstart, blockcount); + 1368 166 : } else if (operation == OPERATION_REHASH) { + 1369 1 : state_read(&state); + 1370 : + 1371 : /* intercept signals while operating */ + 1372 1 : signal_init(); + 1373 : + 1374 1 : state_rehash(&state); 1375 : - 1376 11 : memory(); - 1377 : - 1378 : /* intercept signals while operating */ - 1379 11 : signal_init(); - 1380 : - 1381 11 : ret = state_scrub(&state, plan, olderthan); - 1382 : - 1383 : /* save the new state if required */ - 1384 11 : if (state.need_write || state.opt.force_content_write) - 1385 10 : state_write(&state); + 1376 : /* save the new state if required */ + 1377 1 : if (state.need_write) + 1378 1 : state_write(&state); + 1379 165 : } else if (operation == OPERATION_SCRUB) { + 1380 11 : state_read(&state); + 1381 : + 1382 11 : memory(); + 1383 : + 1384 : /* intercept signals while operating */ + 1385 11 : signal_init(); 1386 : - 1387 : /* abort if required */ - 1388 11 : if (ret != 0) { - 1389 : /* LCOV_EXCL_START */ - 1390 : exit(EXIT_FAILURE); - 1391 : /* LCOV_EXCL_STOP */ - 1392 : } - 1393 153 : } else if (operation == OPERATION_REWRITE) { - 1394 1 : state_read(&state); - 1395 : - 1396 : /* intercept signals while operating */ - 1397 1 : signal_init(); - 1398 : - 1399 1 : state_write(&state); - 1400 : - 1401 1 : memory(); - 1402 152 : } else if (operation == OPERATION_READ) { - 1403 1 : state_read(&state); + 1387 11 : ret = state_scrub(&state, plan, olderthan); + 1388 : + 1389 : /* save the new state if required */ + 1390 11 : if (state.need_write || state.opt.force_content_write) + 1391 10 : state_write(&state); + 1392 : + 1393 : /* abort if required */ + 1394 11 : if (ret != 0) { + 1395 : /* LCOV_EXCL_START */ + 1396 : exit(EXIT_FAILURE); + 1397 : /* LCOV_EXCL_STOP */ + 1398 : } + 1399 154 : } else if (operation == OPERATION_REWRITE) { + 1400 1 : state_read(&state); + 1401 : + 1402 : /* intercept signals while operating */ + 1403 1 : signal_init(); 1404 : - 1405 1 : memory(); - 1406 151 : } else if (operation == OPERATION_TOUCH) { - 1407 1 : state_read(&state); - 1408 : - 1409 1 : state_touch(&state); + 1405 1 : state_write(&state); + 1406 : + 1407 1 : memory(); + 1408 153 : } else if (operation == OPERATION_READ) { + 1409 1 : state_read(&state); 1410 : - 1411 : /* intercept signals while operating */ - 1412 1 : signal_init(); - 1413 : - 1414 1 : state_write(&state); - 1415 : - 1416 1 : memory(); - 1417 150 : } else if (operation == OPERATION_SPINUP) { - 1418 1 : state_device(&state, DEVICE_UP, &filterlist_disk); - 1419 149 : } else if (operation == OPERATION_SPINDOWN) { - 1420 1 : state_device(&state, DEVICE_DOWN, &filterlist_disk); - 1421 148 : } else if (operation == OPERATION_DEVICES) { - 1422 1 : state_device(&state, DEVICE_LIST, 0); - 1423 147 : } else if (operation == OPERATION_SMART) { - 1424 2 : state_device(&state, DEVICE_SMART, 0); - 1425 145 : } else if (operation == OPERATION_STATUS) { - 1426 14 : state_read(&state); - 1427 : - 1428 14 : memory(); - 1429 : - 1430 14 : state_status(&state); - 1431 131 : } else if (operation == OPERATION_DUP) { - 1432 3 : state_read(&state); + 1411 1 : memory(); + 1412 152 : } else if (operation == OPERATION_TOUCH) { + 1413 1 : state_read(&state); + 1414 : + 1415 1 : state_touch(&state); + 1416 : + 1417 : /* intercept signals while operating */ + 1418 1 : signal_init(); + 1419 : + 1420 1 : state_write(&state); + 1421 : + 1422 1 : memory(); + 1423 151 : } else if (operation == OPERATION_SPINUP) { + 1424 1 : state_device(&state, DEVICE_UP, &filterlist_disk); + 1425 150 : } else if (operation == OPERATION_SPINDOWN) { + 1426 1 : state_device(&state, DEVICE_DOWN, &filterlist_disk); + 1427 149 : } else if (operation == OPERATION_DEVICES) { + 1428 1 : state_device(&state, DEVICE_LIST, 0); + 1429 148 : } else if (operation == OPERATION_SMART) { + 1430 2 : state_device(&state, DEVICE_SMART, 0); + 1431 146 : } else if (operation == OPERATION_STATUS) { + 1432 15 : state_read(&state); 1433 : - 1434 3 : state_dup(&state); - 1435 128 : } else if (operation == OPERATION_LIST) { - 1436 5 : state_read(&state); - 1437 : - 1438 5 : state_list(&state); - 1439 123 : } else if (operation == OPERATION_POOL) { - 1440 3 : state_read(&state); - 1441 : - 1442 3 : state_pool(&state); - 1443 : } else { - 1444 120 : state_read(&state); - 1445 : - 1446 : /* if we are also trying to recover */ - 1447 120 : if (!state.opt.auditonly) { - 1448 : /* import the user specified dirs */ - 1449 114 : if (import_timestamp != 0) - 1450 1 : state_search(&state, import_timestamp); - 1451 114 : if (import_content != 0) - 1452 1 : state_import(&state, import_content); - 1453 : - 1454 : /* import from all the array */ - 1455 114 : if (!state.opt.force_nocopy) - 1456 114 : state_search_array(&state); - 1457 : } - 1458 : - 1459 : /* filter */ - 1460 120 : state_skip(&state); - 1461 120 : state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error); - 1462 : - 1463 120 : memory(); + 1434 15 : memory(); + 1435 : + 1436 15 : state_status(&state); + 1437 131 : } else if (operation == OPERATION_DUP) { + 1438 3 : state_read(&state); + 1439 : + 1440 3 : state_dup(&state); + 1441 128 : } else if (operation == OPERATION_LIST) { + 1442 5 : state_read(&state); + 1443 : + 1444 5 : state_list(&state); + 1445 123 : } else if (operation == OPERATION_POOL) { + 1446 3 : state_read(&state); + 1447 : + 1448 3 : state_pool(&state); + 1449 : } else { + 1450 120 : state_read(&state); + 1451 : + 1452 : /* if we are also trying to recover */ + 1453 120 : if (!state.opt.auditonly) { + 1454 : /* import the user specified dirs */ + 1455 114 : if (import_timestamp != 0) + 1456 1 : state_search(&state, import_timestamp); + 1457 114 : if (import_content != 0) + 1458 1 : state_import(&state, import_content); + 1459 : + 1460 : /* import from all the array */ + 1461 114 : if (!state.opt.force_nocopy) + 1462 114 : state_search_array(&state); + 1463 : } 1464 : - 1465 : /* intercept signals while operating */ - 1466 120 : signal_init(); - 1467 : - 1468 120 : if (operation == OPERATION_CHECK) { - 1469 75 : ret = state_check(&state, 0, blockstart, blockcount); - 1470 : } else { /* it's fix */ - 1471 45 : ret = state_check(&state, 1, blockstart, blockcount); - 1472 : } + 1465 : /* filter */ + 1466 120 : state_skip(&state); + 1467 120 : state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error); + 1468 : + 1469 120 : memory(); + 1470 : + 1471 : /* intercept signals while operating */ + 1472 120 : signal_init(); 1473 : - 1474 : /* abort if required */ - 1475 120 : if (ret != 0) { - 1476 : /* LCOV_EXCL_START */ - 1477 : exit(EXIT_FAILURE); - 1478 : /* LCOV_EXCL_STOP */ - 1479 : } - 1480 : } - 1481 : - 1482 : /* close log file */ - 1483 242 : log_close(log_file); - 1484 : - 1485 : #if HAVE_LOCKFILE - 1486 242 : if (!opt.skip_lock && state.lockfile[0]) { - 1487 240 : if (lock_unlock(lock) == -1) { - 1488 : /* LCOV_EXCL_START */ - 1489 : log_fatal("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); - 1490 : exit(EXIT_FAILURE); - 1491 : /* LCOV_EXCL_STOP */ - 1492 : } - 1493 : } - 1494 : #endif - 1495 : - 1496 242 : state_done(&state); - 1497 242 : tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); - 1498 242 : tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); - 1499 : - 1500 242 : os_done(); - 1501 242 : lock_done(); - 1502 : - 1503 242 : return EXIT_SUCCESS; - 1504 : } + 1474 120 : if (operation == OPERATION_CHECK) { + 1475 75 : ret = state_check(&state, 0, blockstart, blockcount); + 1476 : } else { /* it's fix */ + 1477 45 : ret = state_check(&state, 1, blockstart, blockcount); + 1478 : } + 1479 : + 1480 : /* abort if required */ + 1481 120 : if (ret != 0) { + 1482 : /* LCOV_EXCL_START */ + 1483 : exit(EXIT_FAILURE); + 1484 : /* LCOV_EXCL_STOP */ + 1485 : } + 1486 : } + 1487 : + 1488 : /* close log file */ + 1489 243 : log_close(log_file); + 1490 : + 1491 : #if HAVE_LOCKFILE + 1492 243 : if (!opt.skip_lock && state.lockfile[0]) { + 1493 241 : if (lock_unlock(lock) == -1) { + 1494 : /* LCOV_EXCL_START */ + 1495 : log_fatal("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); + 1496 : exit(EXIT_FAILURE); + 1497 : /* LCOV_EXCL_STOP */ + 1498 : } + 1499 : } + 1500 : #endif + 1501 : + 1502 243 : state_done(&state); + 1503 243 : tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); + 1504 243 : tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); 1505 : + 1506 243 : os_done(); + 1507 243 : lock_done(); + 1508 : + 1509 243 : return EXIT_SUCCESS; + 1510 : } + 1511 : diff --git a/cov/cmdline/speed.c.func-sort-c.html b/cov/cmdline/speed.c.func-sort-c.html index e9db88b7..70d26600 100644 --- a/cov/cmdline/speed.c.func-sort-c.html +++ b/cov/cmdline/speed.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,7 +61,7 @@ diffgettimeofday - 1834 + 1814 speed diff --git a/cov/cmdline/speed.c.func.html b/cov/cmdline/speed.c.func.html index dc809ae1..c6485ff8 100644 --- a/cov/cmdline/speed.c.func.html +++ b/cov/cmdline/speed.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,7 +61,7 @@ diffgettimeofday - 1834 + 1814 speed diff --git a/cov/cmdline/speed.c.gcov.html b/cov/cmdline/speed.c.gcov.html index e039e006..24c2c5d8 100644 --- a/cov/cmdline/speed.c.gcov.html +++ b/cov/cmdline/speed.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -100,14 +100,14 @@ 38 : /** 39 : * Differential us of two timeval. 40 : */ - 41 1834 : static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop) + 41 1814 : static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop) 42 : { 43 : int64_t d; 44 : - 45 1834 : d = 1000000LL * (stop->tv_sec - start->tv_sec); - 46 1834 : d += stop->tv_usec - start->tv_usec; + 45 1814 : d = 1000000LL * (stop->tv_sec - start->tv_sec); + 46 1814 : d += stop->tv_usec - start->tv_usec; 47 : - 48 1834 : return d; + 48 1814 : return d; 49 : } 50 : 51 : /** @@ -232,10 +232,10 @@ 170 4 : printf("%8s", "memset"); 171 4 : fflush(stdout); 172 : - 173 386 : SPEED_START { - 174 3438 : for (j = 0; j < nd; ++j) - 175 3056 : memset(v[j], j, size); - 176 382 : } SPEED_STOP + 173 374 : SPEED_START { + 174 3330 : for (j = 0; j < nd; ++j) + 175 2960 : memset(v[j], j, size); + 176 370 : } SPEED_STOP 177 : 178 4 : printf("%8" PRIu64, ds / dt); 179 4 : printf("\n"); @@ -247,10 +247,10 @@ 185 4 : printf("%8s", "table"); 186 4 : fflush(stdout); 187 : - 188 45 : SPEED_START { - 189 369 : for (j = 0; j < nd; ++j) - 190 328 : side_effect += crc32c_gen(0, v[j], size); - 191 41 : } SPEED_STOP + 188 44 : SPEED_START { + 189 360 : for (j = 0; j < nd; ++j) + 190 320 : side_effect += crc32c_gen(0, v[j], size); + 191 40 : } SPEED_STOP 192 : 193 4 : printf("%8" PRIu64, ds / dt); 194 4 : printf("\n"); @@ -260,10 +260,10 @@ 198 : 199 : #if HAVE_SSE42 200 4 : if (raid_cpu_has_crc32()) { - 201 59 : SPEED_START { - 202 513 : for (j = 0; j < nd; ++j) - 203 456 : side_effect += crc32c_x86(0, v[j], size); - 204 57 : } SPEED_STOP + 201 58 : SPEED_START { + 202 504 : for (j = 0; j < nd; ++j) + 203 448 : side_effect += crc32c_x86(0, v[j], size); + 204 56 : } SPEED_STOP 205 : 206 2 : printf("%8" PRIu64, ds / dt); 207 : } @@ -302,10 +302,10 @@ 240 4 : printf("%8" PRIu64, ds / dt); 241 4 : fflush(stdout); 242 : - 243 36 : SPEED_START { - 244 288 : for (j = 0; j < nd; ++j) - 245 256 : memhash(HASH_SPOOKY2, seed, digest, v[j], size); - 246 32 : } SPEED_STOP + 243 30 : SPEED_START { + 244 234 : for (j = 0; j < nd; ++j) + 245 208 : memhash(HASH_SPOOKY2, seed, digest, v[j], size); + 246 26 : } SPEED_STOP 247 : 248 4 : printf("%8" PRIu64, ds / dt); 249 4 : printf("\n"); @@ -341,16 +341,16 @@ 279 : 280 4 : printf("%8s", ""); 281 : - 282 118 : SPEED_START { - 283 114 : raid_gen1_int32(nd, size, v); - 284 114 : } SPEED_STOP + 282 114 : SPEED_START { + 283 110 : raid_gen1_int32(nd, size, v); + 284 110 : } SPEED_STOP 285 : 286 4 : printf("%8" PRIu64, ds / dt); 287 4 : fflush(stdout); 288 : - 289 183 : SPEED_START { - 290 179 : raid_gen1_int64(nd, size, v); - 291 179 : } SPEED_STOP + 289 181 : SPEED_START { + 290 177 : raid_gen1_int64(nd, size, v); + 291 177 : } SPEED_STOP 292 : 293 4 : printf("%8" PRIu64, ds / dt); 294 4 : fflush(stdout); @@ -358,9 +358,9 @@ 296 : #ifdef CONFIG_X86 297 : #ifdef CONFIG_SSE2 298 4 : if (raid_cpu_has_sse2()) { - 299 304 : SPEED_START { - 300 300 : raid_gen1_sse2(nd, size, v); - 301 300 : } SPEED_STOP + 299 305 : SPEED_START { + 300 301 : raid_gen1_sse2(nd, size, v); + 301 301 : } SPEED_STOP 302 : 303 4 : printf("%8" PRIu64, ds / dt); 304 4 : fflush(stdout); @@ -376,9 +376,9 @@ 314 : #endif 315 : #ifdef CONFIG_AVX2 316 4 : if (raid_cpu_has_avx2()) { - 317 14 : SPEED_START { - 318 13 : raid_gen1_avx2(nd, size, v); - 319 13 : } SPEED_STOP + 317 13 : SPEED_START { + 318 12 : raid_gen1_avx2(nd, size, v); + 319 12 : } SPEED_STOP 320 : 321 1 : printf("%8" PRIu64, ds / dt); 322 1 : fflush(stdout); @@ -394,16 +394,16 @@ 332 : 333 4 : printf("%8s", ""); 334 : - 335 48 : SPEED_START { - 336 44 : raid_gen2_int32(nd, size, v); - 337 44 : } SPEED_STOP + 335 47 : SPEED_START { + 336 43 : raid_gen2_int32(nd, size, v); + 337 43 : } SPEED_STOP 338 : 339 4 : printf("%8" PRIu64, ds / dt); 340 4 : fflush(stdout); 341 : - 342 46 : SPEED_START { - 343 42 : raid_gen2_int64(nd, size, v); - 344 42 : } SPEED_STOP + 342 47 : SPEED_START { + 343 43 : raid_gen2_int64(nd, size, v); + 344 43 : } SPEED_STOP 345 : 346 4 : printf("%8" PRIu64, ds / dt); 347 4 : fflush(stdout); @@ -411,9 +411,9 @@ 349 : #ifdef CONFIG_X86 350 : #ifdef CONFIG_SSE2 351 4 : if (raid_cpu_has_sse2()) { - 352 141 : SPEED_START { - 353 137 : raid_gen2_sse2(nd, size, v); - 354 137 : } SPEED_STOP + 352 143 : SPEED_START { + 353 139 : raid_gen2_sse2(nd, size, v); + 354 139 : } SPEED_STOP 355 : 356 4 : printf("%8" PRIu64, ds / dt); 357 4 : fflush(stdout); @@ -453,9 +453,9 @@ 391 : 392 4 : printf("%8s", ""); 393 : - 394 31 : SPEED_START { - 395 27 : raid_genz_int32(nd, size, v); - 396 27 : } SPEED_STOP + 394 32 : SPEED_START { + 395 28 : raid_genz_int32(nd, size, v); + 396 28 : } SPEED_STOP 397 : 398 4 : printf("%8" PRIu64, ds / dt); 399 4 : fflush(stdout); @@ -470,9 +470,9 @@ 408 : #ifdef CONFIG_X86 409 : #ifdef CONFIG_SSE2 410 4 : if (raid_cpu_has_sse2()) { - 411 85 : SPEED_START { - 412 81 : raid_genz_sse2(nd, size, v); - 413 81 : } SPEED_STOP + 411 87 : SPEED_START { + 412 83 : raid_genz_sse2(nd, size, v); + 413 83 : } SPEED_STOP 414 : 415 4 : printf("%8" PRIu64, ds / dt); 416 4 : fflush(stdout); @@ -602,9 +602,9 @@ 540 : #ifdef CONFIG_X86 541 : #ifdef CONFIG_SSSE3 542 4 : if (raid_cpu_has_ssse3()) { - 543 35 : SPEED_START { - 544 32 : raid_gen4_ssse3(nd, size, v); - 545 32 : } SPEED_STOP + 543 34 : SPEED_START { + 544 31 : raid_gen4_ssse3(nd, size, v); + 545 31 : } SPEED_STOP 546 : 547 3 : printf("%8" PRIu64, ds / dt); 548 3 : fflush(stdout); @@ -642,9 +642,9 @@ 580 4 : printf("%8s", raid_gen5_tag()); 581 4 : fflush(stdout); 582 : - 583 11 : SPEED_START { - 584 7 : raid_gen5_int8(nd, size, v); - 585 7 : } SPEED_STOP + 583 12 : SPEED_START { + 584 8 : raid_gen5_int8(nd, size, v); + 585 8 : } SPEED_STOP 586 : 587 4 : printf("%8" PRIu64, ds / dt); 588 4 : fflush(stdout); @@ -667,9 +667,9 @@ 605 : #ifdef CONFIG_X86 606 : #ifdef CONFIG_SSSE3 607 4 : if (raid_cpu_has_ssse3()) { - 608 24 : SPEED_START { - 609 21 : raid_gen5_ssse3(nd, size, v); - 610 21 : } SPEED_STOP + 608 25 : SPEED_START { + 609 22 : raid_gen5_ssse3(nd, size, v); + 610 22 : } SPEED_STOP 611 : 612 3 : printf("%8" PRIu64, ds / dt); 613 3 : fflush(stdout); diff --git a/cov/cmdline/spooky2.c.func-sort-c.html b/cov/cmdline/spooky2.c.func-sort-c.html index 41e92e89..fd355ad2 100644 --- a/cov/cmdline/spooky2.c.func-sort-c.html +++ b/cov/cmdline/spooky2.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ SpookyHash128 - 3861869 + 3861457
diff --git a/cov/cmdline/spooky2.c.func.html b/cov/cmdline/spooky2.c.func.html index 09b225e7..3dfa7070 100644 --- a/cov/cmdline/spooky2.c.func.html +++ b/cov/cmdline/spooky2.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ SpookyHash128 - 3861869 + 3861457
diff --git a/cov/cmdline/spooky2.c.gcov.html b/cov/cmdline/spooky2.c.gcov.html index 6fe692aa..34fefeb4 100644 --- a/cov/cmdline/spooky2.c.gcov.html +++ b/cov/cmdline/spooky2.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -170,7 +170,7 @@ 108 : // 109 : #define sc_const 0xdeadbeefdeadbeefLL 110 : - 111 3861869 : void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* digest) + 111 3861457 : void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* digest) 112 : { 113 : uint64_t h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11; 114 : uint64_t buf[sc_numVars]; @@ -178,62 +178,50 @@ 116 : const uint64_t* blocks; 117 : const uint64_t* end; 118 : size_t size_remainder; - 119 : - 120 : #if WORDS_BIGENDIAN - 121 : unsigned i; - 122 : #endif - 123 : - 124 3861869 : h9 = ((const uint64_t*)seed)[0]; - 125 3861869 : h10 = ((const uint64_t*)seed)[1]; - 126 : - 127 : #if WORDS_BIGENDIAN - 128 : h9 = util_swap64(h9); - 129 : h10 = util_swap64(h10); - 130 : #endif - 131 : - 132 3861869 : h0 = h3 = h6 = h9; - 133 3861869 : h1 = h4 = h7 = h10; - 134 3861869 : h2 = h5 = h8 = h11 = sc_const; - 135 : - 136 3861869 : nblocks = size / sc_blockSize; - 137 3861869 : blocks = data; - 138 3861869 : end = blocks + nblocks * sc_numVars; - 139 : - 140 : /* body */ - 141 38833261 : while (blocks < end) { - 142 : #if WORDS_BIGENDIAN - 143 : for (i = 0; i < sc_numVars; ++i) - 144 : buf[i] = util_swap64(blocks[i]); - 145 : Mix(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); - 146 : #else - 147 31109523 : Mix(blocks, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); - 148 : #endif - 149 31109523 : blocks += sc_numVars; - 150 : } + 119 : #if WORDS_BIGENDIAN + 120 : unsigned i; + 121 : #endif + 122 : + 123 3861457 : h9 = util_read64(seed + 0); + 124 3861457 : h10 = util_read64(seed + 8); + 125 : + 126 3861457 : h0 = h3 = h6 = h9; + 127 3861457 : h1 = h4 = h7 = h10; + 128 3861457 : h2 = h5 = h8 = h11 = sc_const; + 129 : + 130 3861457 : nblocks = size / sc_blockSize; + 131 3861457 : blocks = data; + 132 3861457 : end = blocks + nblocks * sc_numVars; + 133 : + 134 : /* body */ + 135 38698449 : while (blocks < end) { + 136 : #if WORDS_BIGENDIAN + 137 : for (i = 0; i < sc_numVars; ++i) + 138 : buf[i] = util_swap64(blocks[i]); + 139 : Mix(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); + 140 : #else + 141 30975535 : Mix(blocks, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); + 142 : #endif + 143 30975535 : blocks += sc_numVars; + 144 : } + 145 : + 146 : /* tail */ + 147 3861457 : size_remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); + 148 3861457 : memcpy(buf, end, size_remainder); + 149 3861457 : memset(((uint8_t*)buf) + size_remainder, 0, sc_blockSize - size_remainder); + 150 3861457 : ((uint8_t*)buf)[sc_blockSize - 1] = size_remainder; 151 : - 152 : /* tail */ - 153 3861869 : size_remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); - 154 3861869 : memcpy(buf, end, size_remainder); - 155 3861869 : memset(((uint8_t*)buf) + size_remainder, 0, sc_blockSize - size_remainder); - 156 3861869 : ((uint8_t*)buf)[sc_blockSize - 1] = size_remainder; - 157 : - 158 : /* finalization */ - 159 : #if WORDS_BIGENDIAN - 160 : for (i = 0; i < sc_numVars; ++i) - 161 : buf[i] = util_swap64(buf[i]); - 162 : #endif - 163 : - 164 3861869 : End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); - 165 : - 166 : #if WORDS_BIGENDIAN - 167 : h0 = util_swap64(h0); - 168 : h1 = util_swap64(h1); - 169 : #endif - 170 : - 171 3861869 : ((uint64_t*)digest)[0] = h0; - 172 3861869 : ((uint64_t*)digest)[1] = h1; - 173 3861869 : } - 174 : + 152 : /* finalization */ + 153 : #if WORDS_BIGENDIAN + 154 : for (i = 0; i < sc_numVars; ++i) + 155 : buf[i] = util_swap64(buf[i]); + 156 : #endif + 157 3861457 : End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); + 158 : + 159 3861457 : util_write64(digest + 0, h0); + 160 3861457 : util_write64(digest + 8, h1); + 161 3861457 : } + 162 : diff --git a/cov/cmdline/state.c.func-sort-c.html b/cov/cmdline/state.c.func-sort-c.html index a21de965..bd1dec5b 100644 --- a/cov/cmdline/state.c.func-sort-c.html +++ b/cov/cmdline/state.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 1449 + 1478 1612 - 89.9 % + 91.7 % Date: - 2016-11-06 + 2016-11-21 Functions: 45 @@ -65,27 +65,27 @@ fs_info_is_required - 1547867 + 1547923 state_progress - 1073497 + 1073436 state_usage_misc - 1063671 + 1063244 state_usage_disk - 912885 + 912519 state_usage_hash - 777357 + 776953 state_usage_parity - 774551 + 774185 fs_position_is_required @@ -93,75 +93,75 @@ lev_config_name - 186570 + 186623 state_usage_sched - 149924 + 149863 state_usage_raid - 140438 + 140402 find_disk_by_name - 7037 + 7047 lev_config_scan - 6318 + 6345 state_verify_thread 1012 - state_fscheck - 498 + state_progress_latest + 532 - state_progress_latest - 477 + state_fscheck + 499 validate_smartctl - 364 + 366 state_init - 266 + 267 state_config - 265 + 266 lev_raid_name - 264 + 265 state_config_check - 264 + 265 state_read - 260 + 261 state_map - 259 + 260 state_read_content - 253 + 254 state_content_check - 252 + 253 state_done - 243 + 244 state_progress_end @@ -216,12 +216,12 @@ 7 - find_disk_by_uuid + state_progress_graph 2 - state_progress_graph - 1 + find_disk_by_uuid + 2 state_progress_restart diff --git a/cov/cmdline/state.c.func.html b/cov/cmdline/state.c.func.html index e633e134..a2f569e6 100644 --- a/cov/cmdline/state.c.func.html +++ b/cov/cmdline/state.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 1449 + 1478 1612 - 89.9 % + 91.7 % Date: - 2016-11-06 + 2016-11-21 Functions: 45 @@ -65,7 +65,7 @@ find_disk_by_name - 7037 + 7047 find_disk_by_uuid @@ -73,7 +73,7 @@ fs_info_is_required - 1547867 + 1547923 fs_is_block_deleted @@ -93,11 +93,11 @@ lev_config_name - 186570 + 186623 lev_config_scan - 6318 + 6345 lev_name @@ -105,23 +105,23 @@ lev_raid_name - 264 - - - state_config 265 + + state_config + 266 + state_config_check - 264 + 265 state_content_check - 252 + 253 state_done - 243 + 244 state_filter @@ -129,19 +129,19 @@ state_fscheck - 498 + 499 state_init - 266 + 267 state_map - 259 + 260 state_progress - 1073497 + 1073436 state_progress_begin @@ -153,11 +153,11 @@ state_progress_graph - 1 + 2 state_progress_latest - 477 + 532 state_progress_restart @@ -169,11 +169,11 @@ state_read - 260 + 261 state_read_content - 253 + 254 state_refresh @@ -189,19 +189,19 @@ state_usage_disk - 912885 + 912519 state_usage_hash - 777357 + 776953 state_usage_misc - 1063671 + 1063244 state_usage_parity - 774551 + 774185 state_usage_print @@ -209,11 +209,11 @@ state_usage_raid - 140438 + 140402 state_usage_sched - 149924 + 149863 state_usage_waste @@ -241,7 +241,7 @@ validate_smartctl - 364 + 366
diff --git a/cov/cmdline/state.c.gcov.html b/cov/cmdline/state.c.gcov.html index b088ec7a..d4eda724 100644 --- a/cov/cmdline/state.c.gcov.html +++ b/cov/cmdline/state.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 1449 + 1478 1612 - 89.9 % + 91.7 % Date: - 2016-11-06 + 2016-11-21 Functions: 45 @@ -125,65 +125,65 @@ 63 0 : return 0; 64 : } 65 : - 66 186570 : const char* lev_config_name(unsigned l) + 66 186623 : const char* lev_config_name(unsigned l) 67 : { - 68 186570 : switch (l) { - 69 86868 : case 0 : return "parity"; - 70 60620 : case 1 : return "2-parity"; - 71 9810 : case 2 : return "3-parity"; - 72 9785 : case 3 : return "4-parity"; - 73 9760 : case 4 : return "5-parity"; - 74 9727 : case 5 : return "6-parity"; + 68 186623 : switch (l) { + 69 86887 : case 0 : return "parity"; + 70 60630 : case 1 : return "2-parity"; + 71 9816 : case 2 : return "3-parity"; + 72 9791 : case 3 : return "4-parity"; + 73 9766 : case 4 : return "5-parity"; + 74 9733 : case 5 : return "6-parity"; 75 : } 76 : 77 0 : return 0; 78 : } 79 : - 80 6318 : static int lev_config_scan(const char* s, unsigned* level, unsigned* mode) + 80 6345 : static int lev_config_scan(const char* s, unsigned* level, unsigned* mode) 81 : { - 82 6318 : if (strcmp(s, "parity") == 0 || strcmp(s, "1-parity") == 0) { - 83 447 : *level = 0; - 84 447 : return 0; + 82 6345 : if (strcmp(s, "parity") == 0 || strcmp(s, "1-parity") == 0) { + 83 449 : *level = 0; + 84 449 : return 0; 85 : } 86 : - 87 5871 : if (strcmp(s, "q-parity") == 0 || strcmp(s, "2-parity") == 0) { - 88 224 : *level = 1; - 89 224 : return 0; + 87 5896 : if (strcmp(s, "q-parity") == 0 || strcmp(s, "2-parity") == 0) { + 88 225 : *level = 1; + 89 225 : return 0; 90 : } 91 : - 92 5647 : if (strcmp(s, "r-parity") == 0 || strcmp(s, "3-parity") == 0) { - 93 199 : *level = 2; - 94 199 : return 0; + 92 5671 : if (strcmp(s, "r-parity") == 0 || strcmp(s, "3-parity") == 0) { + 93 200 : *level = 2; + 94 200 : return 0; 95 : } 96 : - 97 5448 : if (strcmp(s, "4-parity") == 0) { - 98 196 : *level = 3; - 99 196 : return 0; + 97 5471 : if (strcmp(s, "4-parity") == 0) { + 98 197 : *level = 3; + 99 197 : return 0; 100 : } 101 : - 102 5252 : if (strcmp(s, "5-parity") == 0) { - 103 193 : *level = 4; - 104 193 : return 0; + 102 5274 : if (strcmp(s, "5-parity") == 0) { + 103 194 : *level = 4; + 104 194 : return 0; 105 : } 106 : - 107 5059 : if (strcmp(s, "6-parity") == 0) { - 108 189 : *level = 5; - 109 189 : return 0; + 107 5080 : if (strcmp(s, "6-parity") == 0) { + 108 190 : *level = 5; + 109 190 : return 0; 110 : } 111 : - 112 4870 : if (strcmp(s, "z-parity") == 0) { + 112 4890 : if (strcmp(s, "z-parity") == 0) { 113 0 : *level = 2; 114 0 : if (mode) 115 0 : *mode = RAID_MODE_VANDERMONDE; 116 0 : return 0; 117 : } 118 : - 119 4870 : return -1; + 119 4890 : return -1; 120 : } 121 : - 122 264 : const char* lev_raid_name(unsigned mode, unsigned n) + 122 265 : const char* lev_raid_name(unsigned mode, unsigned n) 123 : { - 124 264 : switch (n) { + 124 265 : switch (n) { 125 41 : case 1 : return "par1"; 126 25 : case 2 : return "par2"; 127 3 : case 3 : if (mode == RAID_MODE_CAUCHY) @@ -192,89 +192,89 @@ 130 0 : return "parz"; 131 3 : case 4 : return "par4"; 132 4 : case 5 : return "par5"; - 133 188 : case 6 : return "par6"; + 133 189 : case 6 : return "par6"; 134 : } 135 : 136 0 : return 0; 137 : } 138 : - 139 266 : void state_init(struct snapraid_state* state) + 139 267 : void state_init(struct snapraid_state* state) 140 : { 141 : unsigned l, s; 142 : - 143 266 : memset(&state->opt, 0, sizeof(state->opt)); - 144 266 : state->filter_hidden = 0; - 145 266 : state->autosave = 0; - 146 266 : state->need_write = 0; - 147 266 : state->checked_read = 0; - 148 266 : state->block_size = 256 * KIBI; /* default 256 KiB */ - 149 266 : state->raid_mode = RAID_MODE_CAUCHY; - 150 266 : state->file_mode = ADVISE_DEFAULT; - 151 1862 : for (l = 0; l < LEV_MAX; ++l) { - 152 1596 : state->parity[l].split_mac = 0; - 153 14364 : for (s = 0; s < SPLIT_MAX; ++s) { - 154 12768 : state->parity[l].split_map[s].path[0] = 0; - 155 12768 : state->parity[l].split_map[s].uuid[0] = 0; - 156 12768 : state->parity[l].split_map[s].size = PARITY_SIZE_INVALID; - 157 12768 : state->parity[l].split_map[s].device = 0; + 143 267 : memset(&state->opt, 0, sizeof(state->opt)); + 144 267 : state->filter_hidden = 0; + 145 267 : state->autosave = 0; + 146 267 : state->need_write = 0; + 147 267 : state->checked_read = 0; + 148 267 : state->block_size = 256 * KIBI; /* default 256 KiB */ + 149 267 : state->raid_mode = RAID_MODE_CAUCHY; + 150 267 : state->file_mode = ADVISE_DEFAULT; + 151 1869 : for (l = 0; l < LEV_MAX; ++l) { + 152 1602 : state->parity[l].split_mac = 0; + 153 14418 : for (s = 0; s < SPLIT_MAX; ++s) { + 154 12816 : state->parity[l].split_map[s].path[0] = 0; + 155 12816 : state->parity[l].split_map[s].uuid[0] = 0; + 156 12816 : state->parity[l].split_map[s].size = PARITY_SIZE_INVALID; + 157 12816 : state->parity[l].split_map[s].device = 0; 158 : } - 159 1596 : state->parity[l].smartctl[0] = 0; - 160 1596 : state->parity[l].total_blocks = 0; - 161 1596 : state->parity[l].free_blocks = 0; - 162 1596 : state->parity[l].skip_access = 0; - 163 1596 : state->parity[l].tick = 0; - 164 1596 : state->parity[l].cached = 0; - 165 1596 : state->parity[l].is_excluded = 0; + 159 1602 : state->parity[l].smartctl[0] = 0; + 160 1602 : state->parity[l].total_blocks = 0; + 161 1602 : state->parity[l].free_blocks = 0; + 162 1602 : state->parity[l].skip_access = 0; + 163 1602 : state->parity[l].tick = 0; + 164 1602 : state->parity[l].cached = 0; + 165 1602 : state->parity[l].is_excluded = 0; 166 : } - 167 266 : state->tick_io = 0; - 168 266 : state->tick_misc = 0; - 169 266 : state->tick_sched = 0; - 170 266 : state->tick_raid = 0; - 171 266 : state->tick_hash = 0; - 172 266 : state->tick_last = tick(); - 173 266 : state->share[0] = 0; - 174 266 : state->pool[0] = 0; - 175 266 : state->pool_device = 0; - 176 266 : state->lockfile[0] = 0; - 177 266 : state->level = 1; /* default is the lowest protection */ - 178 266 : state->clear_past_hash = 0; - 179 266 : state->no_conf = 0; + 167 267 : state->tick_io = 0; + 168 267 : state->tick_misc = 0; + 169 267 : state->tick_sched = 0; + 170 267 : state->tick_raid = 0; + 171 267 : state->tick_hash = 0; + 172 267 : state->tick_last = tick(); + 173 267 : state->share[0] = 0; + 174 267 : state->pool[0] = 0; + 175 267 : state->pool_device = 0; + 176 267 : state->lockfile[0] = 0; + 177 267 : state->level = 1; /* default is the lowest protection */ + 178 267 : state->clear_past_hash = 0; + 179 267 : state->no_conf = 0; 180 : - 181 266 : tommy_list_init(&state->disklist); - 182 266 : tommy_list_init(&state->maplist); - 183 266 : tommy_list_init(&state->contentlist); - 184 266 : tommy_list_init(&state->filterlist); - 185 266 : tommy_list_init(&state->importlist); - 186 266 : tommy_hashdyn_init(&state->importset); - 187 266 : tommy_hashdyn_init(&state->previmportset); - 188 266 : tommy_hashdyn_init(&state->searchset); - 189 266 : tommy_arrayblkof_init(&state->infoarr, sizeof(snapraid_info)); - 190 266 : } + 181 267 : tommy_list_init(&state->disklist); + 182 267 : tommy_list_init(&state->maplist); + 183 267 : tommy_list_init(&state->contentlist); + 184 267 : tommy_list_init(&state->filterlist); + 185 267 : tommy_list_init(&state->importlist); + 186 267 : tommy_hashdyn_init(&state->importset); + 187 267 : tommy_hashdyn_init(&state->previmportset); + 188 267 : tommy_hashdyn_init(&state->searchset); + 189 267 : tommy_arrayblkof_init(&state->infoarr, sizeof(snapraid_info)); + 190 267 : } 191 : - 192 243 : void state_done(struct snapraid_state* state) + 192 244 : void state_done(struct snapraid_state* state) 193 : { - 194 243 : tommy_list_foreach(&state->disklist, (tommy_foreach_func*)disk_free); - 195 243 : tommy_list_foreach(&state->maplist, (tommy_foreach_func*)map_free); - 196 243 : tommy_list_foreach(&state->contentlist, (tommy_foreach_func*)content_free); - 197 243 : tommy_list_foreach(&state->filterlist, (tommy_foreach_func*)filter_free); - 198 243 : tommy_list_foreach(&state->importlist, (tommy_foreach_func*)import_file_free); - 199 243 : tommy_hashdyn_foreach(&state->searchset, (tommy_foreach_func*)search_file_free); - 200 243 : tommy_hashdyn_done(&state->importset); - 201 243 : tommy_hashdyn_done(&state->previmportset); - 202 243 : tommy_hashdyn_done(&state->searchset); - 203 243 : tommy_arrayblkof_done(&state->infoarr); - 204 243 : } + 194 244 : tommy_list_foreach(&state->disklist, (tommy_foreach_func*)disk_free); + 195 244 : tommy_list_foreach(&state->maplist, (tommy_foreach_func*)map_free); + 196 244 : tommy_list_foreach(&state->contentlist, (tommy_foreach_func*)content_free); + 197 244 : tommy_list_foreach(&state->filterlist, (tommy_foreach_func*)filter_free); + 198 244 : tommy_list_foreach(&state->importlist, (tommy_foreach_func*)import_file_free); + 199 244 : tommy_hashdyn_foreach(&state->searchset, (tommy_foreach_func*)search_file_free); + 200 244 : tommy_hashdyn_done(&state->importset); + 201 244 : tommy_hashdyn_done(&state->previmportset); + 202 244 : tommy_hashdyn_done(&state->searchset); + 203 244 : tommy_arrayblkof_done(&state->infoarr); + 204 244 : } 205 : 206 : /** 207 : * Check the configuration. 208 : */ - 209 264 : static void state_config_check(struct snapraid_state* state, const char* path, tommy_list* filterlist_disk) + 209 265 : static void state_config_check(struct snapraid_state* state, const char* path, tommy_list* filterlist_disk) 210 : { 211 : tommy_node* i; 212 : unsigned l, s; 213 : 214 : /* check for parity level */ - 215 264 : if (state->raid_mode == RAID_MODE_VANDERMONDE) { + 215 265 : if (state->raid_mode == RAID_MODE_VANDERMONDE) { 216 0 : if (state->level > 3) { 217 : /* LCOV_EXCL_START */ 218 : log_fatal("If you use the z-parity you cannot have more than 3 parities.\n"); @@ -292,7 +292,7 @@ 230 : } 231 : } 232 : - 233 264 : if (tommy_list_empty(&state->contentlist)) { + 233 265 : if (tommy_list_empty(&state->contentlist)) { 234 : /* LCOV_EXCL_START */ 235 : log_fatal("No 'content' specification in '%s'\n", path); 236 : exit(EXIT_FAILURE); @@ -300,12 +300,12 @@ 238 : } 239 : 240 : /* check for equal paths */ - 241 1788 : for (i = state->contentlist; i != 0; i = i->next) { - 242 1524 : struct snapraid_content* content = i->data; + 241 1796 : for (i = state->contentlist; i != 0; i = i->next) { + 242 1531 : struct snapraid_content* content = i->data; 243 : - 244 9868 : for (l = 0; l < state->level; ++l) { - 245 41720 : for (s = 0; s < state->parity[l].split_mac; ++s) { - 246 33376 : if (pathcmp(state->parity[l].split_map[s].path, content->content) == 0) { + 244 9917 : for (l = 0; l < state->level; ++l) { + 245 41930 : for (s = 0; s < state->parity[l].split_mac; ++s) { + 246 33544 : if (pathcmp(state->parity[l].split_map[s].path, content->content) == 0) { 247 : /* LCOV_EXCL_START */ 248 : log_fatal("Same path used for '%s' and 'content' as '%s'\n", lev_config_name(l), content->content); 249 : exit(EXIT_FAILURE); @@ -316,7 +316,7 @@ 254 : } 255 : 256 : /* check device of data disks */ - 257 264 : if (!state->opt.skip_device && !state->opt.skip_disk_access) { + 257 265 : if (!state->opt.skip_device && !state->opt.skip_disk_access) { 258 0 : for (i = state->disklist; i != 0; i = i->next) { 259 : tommy_node* j; 260 0 : struct snapraid_disk* disk = i->data; @@ -401,7 +401,7 @@ 339 : } 340 : 341 : /* check device of parity disks */ - 342 264 : if (!state->opt.skip_device && !state->opt.skip_parity_access) { + 342 265 : if (!state->opt.skip_device && !state->opt.skip_parity_access) { 343 0 : for (l = 0; l < state->level; ++l) { 344 0 : for (s = 0; s < state->parity[l].split_mac; ++s) { 345 : unsigned j,t; @@ -481,7 +481,7 @@ 419 : #endif 420 : 421 : /* count the content files */ - 422 264 : if (!state->opt.skip_device && !state->opt.skip_content_access) { + 422 265 : if (!state->opt.skip_device && !state->opt.skip_content_access) { 423 : unsigned content_count; 424 : 425 0 : content_count = 0; @@ -514,7 +514,7 @@ 452 : 453 : /* check for speed */ 454 : #ifdef CONFIG_X86 - 455 264 : if (!raid_cpu_has_ssse3()) + 455 265 : if (!raid_cpu_has_ssse3()) 456 : #endif 457 0 : if (state->raid_mode == RAID_MODE_CAUCHY && !state->opt.no_warnings) { 458 0 : if (state->level == 3) { @@ -527,7 +527,7 @@ 465 : } 466 : 467 : /* ensure that specified filter disks are valid ones */ - 468 274 : for (i = tommy_list_head(filterlist_disk); i != 0; i = i->next) { + 468 275 : for (i = tommy_list_head(filterlist_disk); i != 0; i = i->next) { 469 : tommy_node* j; 470 10 : struct snapraid_filter* filter = i->data; 471 51 : for (j = state->disklist; j != 0; j = j->next) { @@ -548,39 +548,39 @@ 486 : } 487 : } 488 : } - 489 264 : } + 489 265 : } 490 : 491 : /** 492 : * Validate the smartctl command. 493 : * 494 : * It must contains only one %s string, and not other % chars. 495 : */ - 496 364 : static int validate_smartctl(const char* custom) + 496 366 : static int validate_smartctl(const char* custom) 497 : { - 498 364 : const char* s = custom; - 499 364 : int arg = 0; + 498 366 : const char* s = custom; + 499 366 : int arg = 0; 500 : - 501 2548 : while (*s) { - 502 1820 : if (s[0] == '%' && s[1] == 's') { - 503 182 : if (arg) { + 501 2562 : while (*s) { + 502 1830 : if (s[0] == '%' && s[1] == 's') { + 503 183 : if (arg) { 504 : /* LCOV_EXCL_START */ 505 : return -1; 506 : /* LCOV_EXCL_STOP */ 507 : } - 508 182 : arg = 1; - 509 1638 : } else if (s[0] == '%') { + 508 183 : arg = 1; + 509 1647 : } else if (s[0] == '%') { 510 : /* LCOV_EXCL_START */ 511 : return -1; 512 : /* LCOV_EXCL_STOP */ 513 : } 514 : - 515 1820 : ++s; + 515 1830 : ++s; 516 : } 517 : - 518 364 : return 0; + 518 366 : return 0; 519 : } 520 : - 521 265 : void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk) + 521 266 : void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk) 522 : { 523 : STREAM* f; 524 : unsigned line; @@ -588,27 +588,27 @@ 526 : unsigned l, s; 527 : 528 : /* copy the options */ - 529 265 : state->opt = *opt; + 529 266 : state->opt = *opt; 530 : 531 : /* if unset, sort by physical order */ - 532 265 : if (!state->opt.force_order) + 532 266 : if (!state->opt.force_order) 533 1 : state->opt.force_order = SORT_PHYSICAL; 534 : 535 : /* adjust file mode */ - 536 265 : if (state->opt.file_mode != ADVISE_DEFAULT) { + 536 266 : if (state->opt.file_mode != ADVISE_DEFAULT) { 537 4 : state->file_mode = state->opt.file_mode; 538 : } else { 539 : /* default mode, if nothing is specified */ - 540 261 : state->file_mode = ADVISE_FLUSH; + 540 262 : state->file_mode = ADVISE_FLUSH; 541 : } 542 : 543 : /* store current command */ - 544 265 : state->command = command; + 544 266 : state->command = command; 545 : - 546 265 : log_tag("conf:file:%s\n", path); + 546 266 : log_tag("conf:file:%s\n", path); 547 : - 548 265 : f = sopen_read(path); - 549 265 : if (!f) { + 548 266 : f = sopen_read(path); + 549 266 : if (!f) { 550 : /* LCOV_EXCL_START */ 551 : if (errno == ENOENT) { 552 : if (state->opt.auto_conf) { @@ -629,7 +629,7 @@ 567 : /* LCOV_EXCL_STOP */ 568 : } 569 : - 570 265 : line = 1; + 570 266 : line = 1; 571 : while (1) { 572 : char tag[PATH_MAX]; 573 : char buffer[PATH_MAX]; @@ -638,11 +638,11 @@ 576 : unsigned level; 577 : 578 : /* skip initial spaces */ - 579 6219 : sgetspace(f); + 579 6245 : sgetspace(f); 580 : 581 : /* read the command */ - 582 6219 : ret = sgettok(f, tag, sizeof(tag)); - 583 6219 : if (ret < 0) { + 582 6245 : ret = sgettok(f, tag, sizeof(tag)); + 583 6245 : if (ret < 0) { 584 : /* LCOV_EXCL_START */ 585 : log_fatal("Error reading the configuration file '%s' at line %u\n", path, line); 586 : exit(EXIT_FAILURE); @@ -650,40 +650,40 @@ 588 : } 589 : 590 : /* skip spaces after the command */ - 591 6219 : sgetspace(f); + 591 6245 : sgetspace(f); 592 : - 593 6219 : if (strcmp(tag, "blocksize") == 0 + 593 6245 : if (strcmp(tag, "blocksize") == 0 594 : /* block_size is the old format of the option */ - 595 5954 : || strcmp(tag, "block_size") == 0) { + 595 5979 : || strcmp(tag, "block_size") == 0) { 596 : - 597 265 : ret = sgetu32(f, &state->block_size); - 598 265 : if (ret < 0) { + 597 266 : ret = sgetu32(f, &state->block_size); + 598 266 : if (ret < 0) { 599 : /* LCOV_EXCL_START */ 600 : log_fatal("Invalid 'blocksize' specification in '%s' at line %u\n", path, line); 601 : exit(EXIT_FAILURE); 602 : /* LCOV_EXCL_STOP */ 603 : } - 604 265 : if (state->block_size < 1) { + 604 266 : if (state->block_size < 1) { 605 : /* LCOV_EXCL_START */ 606 : log_fatal("Too small 'blocksize' specification in '%s' at line %u\n", path, line); 607 : exit(EXIT_FAILURE); 608 : /* LCOV_EXCL_STOP */ 609 : } - 610 265 : if (state->block_size > 16 * KIBI) { + 610 266 : if (state->block_size > 16 * KIBI) { 611 : /* LCOV_EXCL_START */ 612 : log_fatal("Too big 'blocksize' specification in '%s' at line %u\n", path, line); 613 : exit(EXIT_FAILURE); 614 : /* LCOV_EXCL_STOP */ 615 : } 616 : /* check if it's a power of 2 */ - 617 265 : if ((state->block_size & (state->block_size - 1)) != 0) { + 617 266 : if ((state->block_size & (state->block_size - 1)) != 0) { 618 : /* LCOV_EXCL_START */ 619 : log_fatal("Not power of 2 'blocksize' specification in '%s' at line %u\n", path, line); 620 : exit(EXIT_FAILURE); 621 : /* LCOV_EXCL_STOP */ 622 : } - 623 265 : state->block_size *= KIBI; - 624 5954 : } else if (strcmp(tag, "hash_size") == 0) { + 623 266 : state->block_size *= KIBI; + 624 5979 : } else if (strcmp(tag, "hash_size") == 0) { 625 : uint32_t hash_size; 626 : 627 0 : ret = sgetu32(f, &hash_size); @@ -714,7 +714,7 @@ 652 : } 653 : 654 0 : BLOCK_HASH_SIZE = hash_size; - 655 5954 : } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { + 655 5979 : } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { 656 : char device[PATH_MAX]; 657 : char* split_map[SPLIT_MAX+1]; 658 : unsigned split_mac; @@ -722,43 +722,43 @@ 660 : uint64_t dev; 661 : int skip_access; 662 : - 663 1266 : if (state->parity[level].split_mac != 0) { + 663 1272 : if (state->parity[level].split_mac != 0) { 664 : /* LCOV_EXCL_START */ 665 : log_fatal("Multiple '%s' specification in '%s' at line %u\n", tag, path, line); 666 : exit(EXIT_FAILURE); 667 : /* LCOV_EXCL_STOP */ 668 : } 669 : - 670 1266 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 671 1266 : if (ret < 0) { + 670 1272 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 671 1272 : if (ret < 0) { 672 : /* LCOV_EXCL_START */ 673 : log_fatal("Invalid '%s' specification in '%s' at line %u\n", tag, path, line); 674 : exit(EXIT_FAILURE); 675 : /* LCOV_EXCL_STOP */ 676 : } 677 : - 678 1266 : if (!*buffer) { + 678 1272 : if (!*buffer) { 679 : /* LCOV_EXCL_START */ 680 : log_fatal("Empty '%s' specification in '%s' at line %u\n", tag, path, line); 681 : exit(EXIT_FAILURE); 682 : /* LCOV_EXCL_STOP */ 683 : } 684 : - 685 1266 : split_mac = strsplit(split_map, SPLIT_MAX+1, buffer, ","); + 685 1272 : split_mac = strsplit(split_map, SPLIT_MAX+1, buffer, ","); 686 : - 687 1266 : if (split_mac > SPLIT_MAX) { + 687 1272 : if (split_mac > SPLIT_MAX) { 688 : /* LCOV_EXCL_START */ 689 : log_fatal("Too many files in '%s' specification in '%s' at line %u\n", tag, path, line); 690 : exit(EXIT_FAILURE); 691 : /* LCOV_EXCL_STOP */ 692 : } 693 : - 694 1266 : skip_access = 0; - 695 1266 : state->parity[level].split_mac = split_mac; - 696 6326 : for (s = 0; s < split_mac; ++s) { - 697 5061 : pathimport(state->parity[level].split_map[s].path, sizeof(state->parity[level].split_map[s].path), split_map[s]); + 694 1272 : skip_access = 0; + 695 1272 : state->parity[level].split_mac = split_mac; + 696 6356 : for (s = 0; s < split_mac; ++s) { + 697 5085 : pathimport(state->parity[level].split_map[s].path, sizeof(state->parity[level].split_map[s].path), split_map[s]); 698 : - 699 5061 : if (!state->opt.skip_parity_access) { + 699 5085 : if (!state->opt.skip_parity_access) { 700 : struct stat st; 701 : 702 : /* get the device of the directory containing the parity file */ @@ -792,19 +792,19 @@ 730 : } 731 : } else { 732 : /* use a fake device */ - 733 712 : dev = 0; + 733 736 : dev = 0; 734 : } 735 : - 736 5060 : state->parity[level].split_map[s].device = dev; + 736 5084 : state->parity[level].split_map[s].device = dev; 737 : } 738 : 739 : /* store the global parity skip_access */ - 740 1265 : state->parity[level].skip_access = skip_access; + 740 1271 : state->parity[level].skip_access = skip_access; 741 : 742 : /* adjust the level */ - 743 1265 : if (state->level < level + 1) - 744 1000 : state->level = level + 1; - 745 4688 : } else if (strcmp(tag, "share") == 0) { + 743 1271 : if (state->level < level + 1) + 744 1005 : state->level = level + 1; + 745 4707 : } else if (strcmp(tag, "share") == 0) { 746 41 : if (*state->share) { 747 : /* LCOV_EXCL_START */ 748 : log_fatal("Multiple 'share' specification in '%s' at line %u\n", path, line); @@ -828,7 +828,7 @@ 766 : } 767 : 768 41 : pathimport(state->share, sizeof(state->share), buffer); - 769 4647 : } else if (strcmp(tag, "pool") == 0) { + 769 4666 : } else if (strcmp(tag, "pool") == 0) { 770 : struct stat st; 771 : 772 41 : if (*state->pool) { @@ -864,29 +864,29 @@ 802 : } 803 : 804 41 : state->pool_device = st.st_dev; - 805 4606 : } else if (strcmp(tag, "content") == 0) { + 805 4625 : } else if (strcmp(tag, "content") == 0) { 806 : struct snapraid_content* content; 807 : char device[PATH_MAX]; 808 : char* slash; 809 : struct stat st; 810 : uint64_t dev; 811 : - 812 1524 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 813 1524 : if (ret < 0) { + 812 1531 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 813 1531 : if (ret < 0) { 814 : /* LCOV_EXCL_START */ 815 : log_fatal("Invalid 'content' specification in '%s' at line %u\n", path, line); 816 : exit(EXIT_FAILURE); 817 : /* LCOV_EXCL_STOP */ 818 : } 819 : - 820 1524 : if (pathcmp(buffer, "/dev/null") == 0 || pathcmp(buffer, "NUL") == 0) { + 820 1531 : if (pathcmp(buffer, "/dev/null") == 0 || pathcmp(buffer, "NUL") == 0) { 821 : /* LCOV_EXCL_START */ 822 : log_fatal("You cannot use the null device as 'content' specification in '%s' at line %u\n", path, line); 823 : exit(EXIT_FAILURE); 824 : /* LCOV_EXCL_STOP */ 825 : } 826 : - 827 1524 : if (!*buffer) { + 827 1531 : if (!*buffer) { 828 : /* LCOV_EXCL_START */ 829 : log_fatal("Empty 'content' specification in '%s' at line %u\n", path, line); 830 : exit(EXIT_FAILURE); @@ -894,12 +894,12 @@ 832 : } 833 : 834 : /* check if the content file is already specified */ - 835 5696 : for (i = state->contentlist; i != 0; i = i->next) { - 836 4172 : content = i->data; - 837 4172 : if (pathcmp(content->content, buffer) == 0) + 835 5724 : for (i = state->contentlist; i != 0; i = i->next) { + 836 4193 : content = i->data; + 837 4193 : if (pathcmp(content->content, buffer) == 0) 838 0 : break; 839 : } - 840 1524 : if (i) { + 840 1531 : if (i) { 841 : /* LCOV_EXCL_START */ 842 : log_fatal("Duplicate 'content' specification in '%s' at line %u\n", path, line); 843 : exit(EXIT_FAILURE); @@ -907,14 +907,14 @@ 845 : } 846 : 847 : /* get the device of the directory containing the content file */ - 848 1524 : pathimport(device, sizeof(device), buffer); - 849 1524 : slash = strrchr(device, '/'); - 850 1524 : if (slash) - 851 1524 : *slash = 0; + 848 1531 : pathimport(device, sizeof(device), buffer); + 849 1531 : slash = strrchr(device, '/'); + 850 1531 : if (slash) + 851 1531 : *slash = 0; 852 : else 853 0 : pathcpy(device, sizeof(device), "."); - 854 1524 : if (stat(device, &st) == 0) { - 855 1523 : dev = st.st_dev; + 854 1531 : if (stat(device, &st) == 0) { + 855 1530 : dev = st.st_dev; 856 : } else { 857 1 : if (state->opt.skip_content_access) { 858 : /* use a fake device */ @@ -929,15 +929,15 @@ 867 : } 868 : 869 : /* set the lock file at the first accessible content file */ - 870 1524 : if (state->lockfile[0] == 0 && dev != 0) { - 871 264 : pathcpy(state->lockfile, sizeof(state->lockfile), buffer); - 872 264 : pathcat(state->lockfile, sizeof(state->lockfile), ".lock"); + 870 1531 : if (state->lockfile[0] == 0 && dev != 0) { + 871 265 : pathcpy(state->lockfile, sizeof(state->lockfile), buffer); + 872 265 : pathcat(state->lockfile, sizeof(state->lockfile), ".lock"); 873 : } 874 : - 875 1524 : content = content_alloc(buffer, dev); + 875 1531 : content = content_alloc(buffer, dev); 876 : - 877 1524 : tommy_list_insert_tail(&state->contentlist, &content->node, content); - 878 4661 : } else if (strcmp(tag, "data") == 0 || strcmp(tag, "disk") == 0) { + 877 1531 : tommy_list_insert_tail(&state->contentlist, &content->node, content); + 878 4679 : } else if (strcmp(tag, "data") == 0 || strcmp(tag, "disk") == 0) { 879 : /* "disk" is the deprecated name up to SnapRAID 9.x */ 880 : char dir[PATH_MAX]; 881 : char device[PATH_MAX]; @@ -946,32 +946,32 @@ 884 : uint64_t dev; 885 : int skip_access; 886 : - 887 1579 : ret = sgettok(f, buffer, sizeof(buffer)); - 888 1579 : if (ret < 0) { + 887 1585 : ret = sgettok(f, buffer, sizeof(buffer)); + 888 1585 : if (ret < 0) { 889 : /* LCOV_EXCL_START */ 890 : log_fatal("Invalid 'data' name specification in '%s' at line %u\n", path, line); 891 : exit(EXIT_FAILURE); 892 : /* LCOV_EXCL_STOP */ 893 : } 894 : - 895 1579 : if (!*buffer) { + 895 1585 : if (!*buffer) { 896 : /* LCOV_EXCL_START */ 897 : log_fatal("Empty 'data' name specification in '%s' at line %u\n", path, line); 898 : exit(EXIT_FAILURE); 899 : /* LCOV_EXCL_STOP */ 900 : } 901 : - 902 1579 : sgetspace(f); + 902 1585 : sgetspace(f); 903 : - 904 1579 : ret = sgetlasttok(f, dir, sizeof(dir)); - 905 1579 : if (ret < 0) { + 904 1585 : ret = sgetlasttok(f, dir, sizeof(dir)); + 905 1585 : if (ret < 0) { 906 : /* LCOV_EXCL_START */ 907 : log_fatal("Invalid 'data' dir specification in '%s' at line %u\n", path, line); 908 : exit(EXIT_FAILURE); 909 : /* LCOV_EXCL_STOP */ 910 : } 911 : - 912 1579 : if (!*dir) { + 912 1585 : if (!*dir) { 913 : /* LCOV_EXCL_START */ 914 : log_fatal("Empty 'data' dir specification in '%s' at line %u\n", path, line); 915 : exit(EXIT_FAILURE); @@ -979,15 +979,15 @@ 917 : } 918 : 919 : /* get the device of the dir */ - 920 1579 : pathimport(device, sizeof(device), dir); + 920 1585 : pathimport(device, sizeof(device), dir); 921 : 922 : /* check if the disk name already exists */ - 923 5514 : for (i = state->disklist; i != 0; i = i->next) { - 924 3935 : disk = i->data; - 925 3935 : if (strcmp(disk->name, buffer) == 0) + 923 5535 : for (i = state->disklist; i != 0; i = i->next) { + 924 3950 : disk = i->data; + 925 3950 : if (strcmp(disk->name, buffer) == 0) 926 0 : break; 927 : } - 928 1579 : if (i) { + 928 1585 : if (i) { 929 : /* LCOV_EXCL_START */ 930 : log_fatal("Duplicate 'data' name '%s' at line %u\n", buffer, line); 931 : exit(EXIT_FAILURE); @@ -995,8 +995,8 @@ 933 : } 934 : 935 : /* if the disk has to be present */ - 936 1579 : skip_access = 0; - 937 1579 : if (!state->opt.skip_disk_access) { + 936 1585 : skip_access = 0; + 937 1585 : if (!state->opt.skip_disk_access) { 938 : struct stat st; 939 : 940 1423 : if (stat(device, &st) == 0) { @@ -1034,49 +1034,49 @@ 972 : } 973 : } else { 974 : /* use a fake device */ - 975 156 : dev = 0; - 976 156 : *uuid = 0; + 975 162 : dev = 0; + 976 162 : *uuid = 0; 977 : } 978 : - 979 1579 : disk = disk_alloc(buffer, dir, dev, uuid, skip_access); + 979 1585 : disk = disk_alloc(buffer, dir, dev, uuid, skip_access); 980 : - 981 1579 : tommy_list_insert_tail(&state->disklist, &disk->node, disk); - 982 1503 : } else if (strcmp(tag, "smartctl") == 0) { + 981 1585 : tommy_list_insert_tail(&state->disklist, &disk->node, disk); + 982 1509 : } else if (strcmp(tag, "smartctl") == 0) { 983 : char custom[PATH_MAX]; 984 : - 985 364 : ret = sgettok(f, buffer, sizeof(buffer)); - 986 364 : if (ret < 0) { + 985 366 : ret = sgettok(f, buffer, sizeof(buffer)); + 986 366 : if (ret < 0) { 987 : /* LCOV_EXCL_START */ 988 : log_fatal("Invalid 'smartctl' name specification in '%s' at line %u\n", path, line); 989 : exit(EXIT_FAILURE); 990 : /* LCOV_EXCL_STOP */ 991 : } 992 : - 993 364 : if (!*buffer) { + 993 366 : if (!*buffer) { 994 : /* LCOV_EXCL_START */ 995 : log_fatal("Empty 'smartctl' name specification in '%s' at line %u\n", path, line); 996 : exit(EXIT_FAILURE); 997 : /* LCOV_EXCL_STOP */ 998 : } 999 : - 1000 364 : sgetspace(f); + 1000 366 : sgetspace(f); 1001 : - 1002 364 : ret = sgetlasttok(f, custom, sizeof(custom)); - 1003 364 : if (ret < 0) { + 1002 366 : ret = sgetlasttok(f, custom, sizeof(custom)); + 1003 366 : if (ret < 0) { 1004 : /* LCOV_EXCL_START */ 1005 : log_fatal("Invalid 'smartctl' option specification in '%s' at line %u\n", path, line); 1006 : exit(EXIT_FAILURE); 1007 : /* LCOV_EXCL_STOP */ 1008 : } 1009 : - 1010 364 : if (!*custom) { + 1010 366 : if (!*custom) { 1011 : /* LCOV_EXCL_START */ 1012 : log_fatal("Empty 'smartctl' option specification in '%s' at line %u\n", path, line); 1013 : exit(EXIT_FAILURE); 1014 : /* LCOV_EXCL_STOP */ 1015 : } 1016 : - 1017 364 : if (validate_smartctl(custom) != 0) { + 1017 366 : if (validate_smartctl(custom) != 0) { 1018 : /* LCOV_EXCL_START */ 1019 : log_fatal("Invalid 'smartctl' option specification in '%s' at line %u\n", path, line); 1020 : exit(EXIT_FAILURE); @@ -1084,97 +1084,97 @@ 1022 : } 1023 : 1024 : /* search for parity */ - 1025 364 : if (lev_config_scan(buffer, &level, 0) == 0) { - 1026 182 : if (state->parity[level].smartctl[0] != 0) { + 1025 366 : if (lev_config_scan(buffer, &level, 0) == 0) { + 1026 183 : if (state->parity[level].smartctl[0] != 0) { 1027 : /* LCOV_EXCL_START */ 1028 : log_fatal("Duplicate parity smartctl '%s' at line %u\n", buffer, line); 1029 : exit(EXIT_FAILURE); 1030 : /* LCOV_EXCL_STOP */ 1031 : } 1032 : - 1033 182 : pathcpy(state->parity[level].smartctl, sizeof(state->parity[level].smartctl), custom); + 1033 183 : pathcpy(state->parity[level].smartctl, sizeof(state->parity[level].smartctl), custom); 1034 : } else { 1035 : struct snapraid_disk* disk; 1036 : 1037 : /* search the disk */ - 1038 182 : disk = 0; - 1039 182 : for (i = state->disklist; i != 0; i = i->next) { - 1040 182 : disk = i->data; - 1041 182 : if (strcmp(disk->name, buffer) == 0) - 1042 182 : break; + 1038 183 : disk = 0; + 1039 183 : for (i = state->disklist; i != 0; i = i->next) { + 1040 183 : disk = i->data; + 1041 183 : if (strcmp(disk->name, buffer) == 0) + 1042 183 : break; 1043 : } - 1044 182 : if (!disk) { + 1044 183 : if (!disk) { 1045 : /* LCOV_EXCL_START */ 1046 : log_fatal("Missing disk smartctl '%s' at line %u\n", buffer, line); 1047 : exit(EXIT_FAILURE); 1048 : /* LCOV_EXCL_STOP */ 1049 : } - 1050 182 : if (disk->smartctl[0] != 0) { + 1050 183 : if (disk->smartctl[0] != 0) { 1051 : /* LCOV_EXCL_START */ 1052 : log_fatal("Duplicate disk name '%s' at line %u\n", buffer, line); 1053 : exit(EXIT_FAILURE); 1054 : /* LCOV_EXCL_STOP */ 1055 : } 1056 : - 1057 182 : pathcpy(disk->smartctl, sizeof(disk->smartctl), custom); + 1057 183 : pathcpy(disk->smartctl, sizeof(disk->smartctl), custom); 1058 : } - 1059 1139 : } else if (strcmp(tag, "nohidden") == 0) { + 1059 1143 : } else if (strcmp(tag, "nohidden") == 0) { 1060 0 : state->filter_hidden = 1; - 1061 1139 : } else if (strcmp(tag, "exclude") == 0) { + 1061 1143 : } else if (strcmp(tag, "exclude") == 0) { 1062 : struct snapraid_filter* filter; 1063 : - 1064 264 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 1065 264 : if (ret < 0) { + 1064 265 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 1065 265 : if (ret < 0) { 1066 : /* LCOV_EXCL_START */ 1067 : log_fatal("Invalid 'exclude' specification in '%s' at line %u\n", path, line); 1068 : exit(EXIT_FAILURE); 1069 : /* LCOV_EXCL_STOP */ 1070 : } 1071 : - 1072 264 : if (!*buffer) { + 1072 265 : if (!*buffer) { 1073 : /* LCOV_EXCL_START */ 1074 : log_fatal("Empty 'exclude' specification in '%s' at line %u\n", path, line); 1075 : exit(EXIT_FAILURE); 1076 : /* LCOV_EXCL_STOP */ 1077 : } 1078 : - 1079 264 : filter = filter_alloc_file(-1, buffer); - 1080 264 : if (!filter) { + 1079 265 : filter = filter_alloc_file(-1, buffer); + 1080 265 : if (!filter) { 1081 : /* LCOV_EXCL_START */ 1082 : log_fatal("Invalid 'exclude' specification '%s' in '%s' at line %u\n", buffer, path, line); 1083 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); 1084 : exit(EXIT_FAILURE); 1085 : /* LCOV_EXCL_STOP */ 1086 : } - 1087 264 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); - 1088 875 : } else if (strcmp(tag, "include") == 0) { + 1087 265 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); + 1088 878 : } else if (strcmp(tag, "include") == 0) { 1089 : struct snapraid_filter* filter; 1090 : - 1091 264 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 1092 264 : if (ret < 0) { + 1091 265 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 1092 265 : if (ret < 0) { 1093 : /* LCOV_EXCL_START */ 1094 : log_fatal("Invalid 'include' specification in '%s' at line %u\n", path, line); 1095 : exit(EXIT_FAILURE); 1096 : /* LCOV_EXCL_STOP */ 1097 : } 1098 : - 1099 264 : if (!*buffer) { + 1099 265 : if (!*buffer) { 1100 : /* LCOV_EXCL_START */ 1101 : log_fatal("Empty 'include' specification in '%s' at line %u\n", path, line); 1102 : exit(EXIT_FAILURE); 1103 : /* LCOV_EXCL_STOP */ 1104 : } 1105 : - 1106 264 : filter = filter_alloc_file(1, buffer); - 1107 264 : if (!filter) { + 1106 265 : filter = filter_alloc_file(1, buffer); + 1107 265 : if (!filter) { 1108 : /* LCOV_EXCL_START */ 1109 : log_fatal("Invalid 'include' specification '%s' in '%s' at line %u\n", buffer, path, line); 1110 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); 1111 : exit(EXIT_FAILURE); 1112 : /* LCOV_EXCL_STOP */ 1113 : } - 1114 264 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); - 1115 611 : } else if (strcmp(tag, "autosave") == 0) { + 1114 265 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); + 1115 613 : } else if (strcmp(tag, "autosave") == 0) { 1116 : char* e; 1117 : 1118 41 : ret = sgetlasttok(f, buffer, sizeof(buffer)); @@ -1203,7 +1203,7 @@ 1141 : 1142 : /* convert to GB */ 1143 41 : state->autosave *= GIGA; - 1144 570 : } else if (tag[0] == 0) { + 1144 572 : } else if (tag[0] == 0) { 1145 : /* allow empty lines */ 1146 41 : } else if (tag[0] == '#') { 1147 41 : ret = sgetline(f, buffer, sizeof(buffer)); @@ -1221,42 +1221,42 @@ 1159 : } 1160 : 1161 : /* skip final spaces */ - 1162 6218 : sgetspace(f); + 1162 6244 : sgetspace(f); 1163 : 1164 : /* next line */ - 1165 6218 : c = sgeteol(f); - 1166 6218 : if (c == EOF) { - 1167 264 : break; + 1165 6244 : c = sgeteol(f); + 1166 6244 : if (c == EOF) { + 1167 265 : break; 1168 : } - 1169 5954 : if (c != '\n') { + 1169 5979 : if (c != '\n') { 1170 : /* LCOV_EXCL_START */ 1171 : log_fatal("Extra data in '%s' at line %u\n", path, line); 1172 : exit(EXIT_FAILURE); 1173 : /* LCOV_EXCL_STOP */ 1174 : } - 1175 5954 : ++line; - 1176 5954 : } + 1175 5979 : ++line; + 1176 5979 : } 1177 : - 1178 264 : if (serror(f)) { + 1178 265 : if (serror(f)) { 1179 : /* LCOV_EXCL_START */ 1180 : log_fatal("Error reading the configuration file '%s' at line %u\n", path, line); 1181 : exit(EXIT_FAILURE); 1182 : /* LCOV_EXCL_STOP */ 1183 : } 1184 : - 1185 264 : sclose(f); + 1185 265 : sclose(f); 1186 : - 1187 264 : state_config_check(state, path, filterlist_disk); + 1187 265 : state_config_check(state, path, filterlist_disk); 1188 : 1189 : /* select the default hash */ - 1190 264 : if (state->opt.force_murmur3) { + 1190 265 : if (state->opt.force_murmur3) { 1191 1 : state->besthash = HASH_MURMUR3; - 1192 263 : } else if (state->opt.force_spooky2) { + 1192 264 : } else if (state->opt.force_spooky2) { 1193 1 : state->besthash = HASH_SPOOKY2; 1194 : } else { 1195 : #ifdef CONFIG_X86 - 1196 262 : if (sizeof(void*) == 4 && !raid_cpu_has_slowmult()) - 1197 262 : state->besthash = HASH_MURMUR3; + 1196 263 : if (sizeof(void*) == 4 && !raid_cpu_has_slowmult()) + 1197 263 : state->besthash = HASH_MURMUR3; 1198 : else 1199 0 : state->besthash = HASH_SPOOKY2; 1200 : #else @@ -1268,10 +1268,10 @@ 1206 : } 1207 : 1208 : /* by default use the best hash */ - 1209 264 : state->hash = state->besthash; + 1209 265 : state->hash = state->besthash; 1210 : 1211 : /* by default use a random hash seed */ - 1212 264 : if (randomize(state->hashseed, HASH_MAX) != 0) { + 1212 265 : if (randomize(state->hashseed, HASH_MAX) != 0) { 1213 : /* LCOV_EXCL_START */ 1214 : log_fatal("Failed to get random values.\n"); 1215 : exit(EXIT_FAILURE); @@ -1279,47 +1279,47 @@ 1217 : } 1218 : 1219 : /* no previous hash by default */ - 1220 264 : state->prevhash = HASH_UNDEFINED; + 1220 265 : state->prevhash = HASH_UNDEFINED; 1221 : 1222 : /* intentionally not set the prevhashseed, if used valgrind will warn about it */ 1223 : - 1224 264 : log_tag("blocksize:%u\n", state->block_size); - 1225 1843 : for (i = state->disklist; i != 0; i = i->next) { - 1226 1579 : struct snapraid_disk* disk = i->data; - 1227 1579 : log_tag("data:%s:%s\n", disk->name, disk->dir); + 1224 265 : log_tag("blocksize:%u\n", state->block_size); + 1225 1850 : for (i = state->disklist; i != 0; i = i->next) { + 1226 1585 : struct snapraid_disk* disk = i->data; + 1227 1585 : log_tag("data:%s:%s\n", disk->name, disk->dir); 1228 : } 1229 : - 1230 264 : log_tag("mode:%s\n", lev_raid_name(state->raid_mode, state->level)); - 1231 1524 : for (l = 0; l < state->level; ++l) - 1232 6300 : for (s = 0; s < state->parity[l].split_mac; ++s) - 1233 5040 : log_tag("%s:%u:%s\n", lev_config_name(l), s, state->parity[l].split_map[s].path); - 1234 264 : if (state->pool[0] != 0) + 1230 265 : log_tag("mode:%s\n", lev_raid_name(state->raid_mode, state->level)); + 1231 1531 : for (l = 0; l < state->level; ++l) + 1232 6330 : for (s = 0; s < state->parity[l].split_mac; ++s) + 1233 5064 : log_tag("%s:%u:%s\n", lev_config_name(l), s, state->parity[l].split_map[s].path); + 1234 265 : if (state->pool[0] != 0) 1235 41 : log_tag("pool:%s\n", state->pool); - 1236 264 : if (state->share[0] != 0) + 1236 265 : if (state->share[0] != 0) 1237 41 : log_tag("share:%s\n", state->share); - 1238 264 : if (state->autosave != 0) + 1238 265 : if (state->autosave != 0) 1239 41 : log_tag("autosave:%" PRIu64 "\n", state->autosave); - 1240 792 : for (i = tommy_list_head(&state->filterlist); i != 0; i = i->next) { + 1240 795 : for (i = tommy_list_head(&state->filterlist); i != 0; i = i->next) { 1241 : char out[PATH_MAX]; - 1242 528 : struct snapraid_filter* filter = i->data; - 1243 528 : log_tag("filter:%s\n", filter_type(filter, out, sizeof(out))); + 1242 530 : struct snapraid_filter* filter = i->data; + 1243 530 : log_tag("filter:%s\n", filter_type(filter, out, sizeof(out))); 1244 : } - 1245 264 : if (state->filter_hidden) + 1245 265 : if (state->filter_hidden) 1246 0 : log_tag("filter:nohidden:\n"); - 1247 264 : log_flush(); + 1247 265 : log_flush(); 1248 : } 1249 : 1250 : /** 1251 : * Find a disk by name. 1252 : */ - 1253 7037 : static struct snapraid_disk* find_disk_by_name(struct snapraid_state* state, const char* name) + 1253 7047 : static struct snapraid_disk* find_disk_by_name(struct snapraid_state* state, const char* name) 1254 : { 1255 : tommy_node* i; 1256 : - 1257 24556 : for (i = state->disklist; i != 0; i = i->next) { - 1258 24548 : struct snapraid_disk* disk = i->data; - 1259 24548 : if (strcmp(disk->name, name) == 0) - 1260 7029 : return disk; + 1257 24588 : for (i = state->disklist; i != 0; i = i->next) { + 1258 24580 : struct snapraid_disk* disk = i->data; + 1259 24580 : if (strcmp(disk->name, name) == 0) + 1260 7039 : return disk; 1261 : } 1262 : 1263 8 : if (state->no_conf) { @@ -1372,7 +1372,7 @@ 1310 : /** 1311 : * Update the disk mapping if required. 1312 : */ - 1313 259 : static void state_map(struct snapraid_state* state) + 1313 260 : static void state_map(struct snapraid_state* state) 1314 : { 1315 : unsigned hole; 1316 : tommy_node* i; @@ -1384,16 +1384,16 @@ 1322 : /* this happens when a disk is removed from the configuration file */ 1323 : /* From SnapRAID 4.0 mappings are automatically removed if a disk is not used */ 1324 : /* when saving the content file, but we keep this code to import older content files. */ - 1325 1910 : for (i = state->maplist; i != 0; ) { - 1326 1392 : struct snapraid_map* map = i->data; + 1325 1917 : for (i = state->maplist; i != 0; ) { + 1326 1397 : struct snapraid_map* map = i->data; 1327 : struct snapraid_disk* disk; 1328 : - 1329 1392 : disk = find_disk_by_name(state, map->name); + 1329 1397 : disk = find_disk_by_name(state, map->name); 1330 : 1331 : /* go to the next mapping before removing */ - 1332 1392 : i = i->next; + 1332 1397 : i = i->next; 1333 : - 1334 1392 : if (disk == 0) { + 1334 1397 : if (disk == 0) { 1335 : /* disk not found, remove the mapping */ 1336 0 : tommy_list_remove_existing(&state->maplist, &map->node); 1337 0 : map_free(map); @@ -1402,60 +1402,60 @@ 1340 : 1341 : /* maps each unmapped disk present in the configuration file in the first available hole */ 1342 : /* this happens when you add disks for the first time in the configuration file */ - 1343 259 : hole = 0; /* first position to try */ - 1344 1808 : for (i = state->disklist; i != 0; i = i->next) { - 1345 1549 : struct snapraid_disk* disk = i->data; + 1343 260 : hole = 0; /* first position to try */ + 1344 1815 : for (i = state->disklist; i != 0; i = i->next) { + 1345 1555 : struct snapraid_disk* disk = i->data; 1346 : struct snapraid_map* map; 1347 : tommy_node* j; 1348 : 1349 : /* check if the disk is already mapped */ - 1350 5409 : for (j = state->maplist; j != 0; j = j->next) { - 1351 5252 : map = j->data; - 1352 5252 : if (strcmp(disk->name, map->name) == 0) { + 1350 5430 : for (j = state->maplist; j != 0; j = j->next) { + 1351 5272 : map = j->data; + 1352 5272 : if (strcmp(disk->name, map->name) == 0) { 1353 : /* mapping found */ - 1354 1392 : break; + 1354 1397 : break; 1355 : } 1356 : } - 1357 1549 : if (j != 0) { + 1357 1555 : if (j != 0) { 1358 : /* mapping is present, then copy the free blocks into to disk */ - 1359 1392 : disk->total_blocks = map->total_blocks; - 1360 1392 : disk->free_blocks = map->free_blocks; - 1361 1392 : continue; + 1359 1397 : disk->total_blocks = map->total_blocks; + 1360 1397 : disk->free_blocks = map->free_blocks; + 1361 1397 : continue; 1362 : } 1363 : 1364 : /* mapping not found, search for an hole */ 1365 : while (1) { - 1366 1080 : for (j = state->maplist; j != 0; j = j->next) { - 1367 923 : map = j->data; - 1368 923 : if (map->position == hole) { + 1366 1100 : for (j = state->maplist; j != 0; j = j->next) { + 1367 942 : map = j->data; + 1368 942 : if (map->position == hole) { 1369 : /* position already used */ - 1370 154 : break; + 1370 158 : break; 1371 : } 1372 : } - 1373 311 : if (j == 0) { + 1373 316 : if (j == 0) { 1374 : /* hole found */ - 1375 157 : break; + 1375 158 : break; 1376 : } 1377 : 1378 : /* try with the next one */ - 1379 154 : ++hole; - 1380 154 : } + 1379 158 : ++hole; + 1380 158 : } 1381 : 1382 : /* insert the new mapping */ - 1383 157 : map = map_alloc(disk->name, hole, 0, 0, ""); + 1383 158 : map = map_alloc(disk->name, hole, 0, 0, ""); 1384 : - 1385 157 : tommy_list_insert_tail(&state->maplist, &map->node, map); + 1385 158 : tommy_list_insert_tail(&state->maplist, &map->node, map); 1386 : } 1387 : 1388 : /* without configuration don't check for number of data disks or uuid changes */ - 1389 259 : if (state->no_conf) - 1390 260 : return; + 1389 260 : if (state->no_conf) + 1390 261 : return; 1391 : 1392 : /* counter for the number of UUID mismatches */ - 1393 258 : uuid_mismatch = 0; + 1393 259 : uuid_mismatch = 0; 1394 : 1395 : /* check if mapping match the disk uuid */ - 1396 258 : if (!state->opt.skip_disk_access) { + 1396 259 : if (!state->opt.skip_disk_access) { 1397 1626 : for (i = state->maplist; i != 0; i = i->next) { 1398 1393 : struct snapraid_map* map = i->data; 1399 : struct snapraid_disk* disk; @@ -1499,7 +1499,7 @@ 1437 : } 1438 : 1439 : /* check the parity uuid */ - 1440 258 : if (!state->opt.skip_parity_access) { + 1440 259 : if (!state->opt.skip_parity_access) { 1441 1273 : for (l = 0; l < state->level; ++l) { 1442 5260 : for (s = 0; s < state->parity[l].split_mac; ++s) { 1443 : char uuid[UUID_MAX]; @@ -1530,7 +1530,7 @@ 1468 : } 1469 : } 1470 : - 1471 258 : if (!state->opt.force_uuid && uuid_mismatch > state->level) { + 1471 259 : if (!state->opt.force_uuid && uuid_mismatch > state->level) { 1472 : /* LCOV_EXCL_START */ 1473 : log_fatal("Too many disks have UUID changed from the latest 'sync'.\n"); 1474 : log_fatal("If this happens because you really replaced them,\n"); @@ -1542,16 +1542,16 @@ 1480 : } 1481 : 1482 : /* count the number of data disks, including holes left after removing some */ - 1483 258 : diskcount = 0; - 1484 1801 : for (i = state->maplist; i != 0; i = i->next) { - 1485 1543 : struct snapraid_map* map = i->data; + 1483 259 : diskcount = 0; + 1484 1808 : for (i = state->maplist; i != 0; i = i->next) { + 1485 1549 : struct snapraid_map* map = i->data; 1486 : - 1487 1543 : if (map->position + 1 > diskcount) - 1488 1366 : diskcount = map->position + 1; + 1487 1549 : if (map->position + 1 > diskcount) + 1488 1367 : diskcount = map->position + 1; 1489 : } 1490 : 1491 : /* ensure to don't go over the limit of the RAID engine */ - 1492 258 : if (diskcount > RAID_DATA_MAX) { + 1492 259 : if (diskcount > RAID_DATA_MAX) { 1493 : /* LCOV_EXCL_START */ 1494 : log_fatal("Too many data disks. No more than %u.\n", RAID_DATA_MAX); 1495 : exit(EXIT_FAILURE); @@ -1559,10 +1559,10 @@ 1497 : } 1498 : 1499 : /* now count the real number of data disks, excluding holes left after removing some */ - 1500 258 : diskcount = tommy_list_count(&state->maplist); + 1500 259 : diskcount = tommy_list_count(&state->maplist); 1501 : 1502 : /* recommend number of parities */ - 1503 258 : if (!state->opt.no_warnings) { + 1503 259 : if (!state->opt.no_warnings) { 1504 1 : if (diskcount >= 36 && state->level < 6) { 1505 0 : log_fatal("WARNING! With %u disks it's recommended to use six parity levels.\n", diskcount); 1506 1 : } else if (diskcount >= 29 && state->level < 5) { @@ -1647,23 +1647,23 @@ 1585 : /** 1586 : * Check the content. 1587 : */ - 1588 252 : static void state_content_check(struct snapraid_state* state, const char* path) + 1588 253 : static void state_content_check(struct snapraid_state* state, const char* path) 1589 : { 1590 : tommy_node* i; 1591 : 1592 : /* check that any map has different name and position */ - 1593 1759 : for (i = state->maplist; i != 0; i = i->next) { - 1594 1507 : struct snapraid_map* map = i->data; + 1593 1766 : for (i = state->maplist; i != 0; i = i->next) { + 1594 1513 : struct snapraid_map* map = i->data; 1595 : tommy_node* j; - 1596 5262 : for (j = i->next; j != 0; j = j->next) { - 1597 3755 : struct snapraid_map* other = j->data; - 1598 3755 : if (strcmp(map->name, other->name) == 0) { + 1596 5283 : for (j = i->next; j != 0; j = j->next) { + 1597 3770 : struct snapraid_map* other = j->data; + 1598 3770 : if (strcmp(map->name, other->name) == 0) { 1599 : /* LCOV_EXCL_START */ 1600 : log_fatal("Colliding 'map' disk specification in '%s'\n", path); 1601 : exit(EXIT_FAILURE); 1602 : /* LCOV_EXCL_STOP */ 1603 : } - 1604 3755 : if (map->position == other->position) { + 1604 3770 : if (map->position == other->position) { 1605 : /* LCOV_EXCL_START */ 1606 : log_fatal("Colliding 'map' index specification in '%s'\n", path); 1607 : exit(EXIT_FAILURE); @@ -1671,7 +1671,7 @@ 1609 : } 1610 : } 1611 : } - 1612 252 : } + 1612 253 : } 1613 : 1614 : /** 1615 : * Check if the position is REQUIRED, or we can completely clear it from the state. @@ -1707,21 +1707,21 @@ 1645 : * Note also that not requiring an info block, doesn't mean that if present it 1646 : * can be discarded. 1647 : */ - 1648 1547867 : static int fs_info_is_required(struct snapraid_state* state, block_off_t pos) + 1648 1547923 : static int fs_info_is_required(struct snapraid_state* state, block_off_t pos) 1649 : { 1650 : tommy_node* i; 1651 : 1652 : /* check for each disk */ - 1653 2048240 : for (i = state->disklist; i != 0; i = i->next) { - 1654 1989507 : struct snapraid_disk* disk = i->data; - 1655 1989507 : struct snapraid_block* block = fs_par2block_find(disk, pos); + 1653 2048488 : for (i = state->disklist; i != 0; i = i->next) { + 1654 1989723 : struct snapraid_disk* disk = i->data; + 1655 1989723 : struct snapraid_block* block = fs_par2block_find(disk, pos); 1656 : 1657 : /* if we have at least one synced file, the info is required */ - 1658 1989507 : if (block_state_get(block) == BLOCK_STATE_BLK) - 1659 1489134 : return 1; + 1658 1989723 : if (block_state_get(block) == BLOCK_STATE_BLK) + 1659 1489158 : return 1; 1660 : } 1661 : - 1662 58733 : return 0; + 1662 58765 : return 0; 1663 : } 1664 : 1665 0 : static void fs_position_clear_deleted(struct snapraid_state* state, block_off_t pos) @@ -1803,7 +1803,7 @@ 1741 : } 1742 0 : } 1743 : - 1744 253 : static void state_read_content(struct snapraid_state* state, const char* path, STREAM* f) + 1744 254 : static void state_read_content(struct snapraid_state* state, const char* path, STREAM* f) 1745 : { 1746 : block_off_t blockmax; 1747 : unsigned count_file; @@ -1816,17 +1816,17 @@ 1754 : tommy_array disk_mapping; 1755 : uint32_t mapping_max; 1756 : - 1757 253 : blockmax = 0; - 1758 253 : count_file = 0; - 1759 253 : count_hardlink = 0; - 1760 253 : count_symlink = 0; - 1761 253 : count_dir = 0; - 1762 253 : crc_checked = 0; - 1763 253 : mapping_max = 0; - 1764 253 : tommy_array_init(&disk_mapping); + 1757 254 : blockmax = 0; + 1758 254 : count_file = 0; + 1759 254 : count_hardlink = 0; + 1760 254 : count_symlink = 0; + 1761 254 : count_dir = 0; + 1762 254 : crc_checked = 0; + 1763 254 : mapping_max = 0; + 1764 254 : tommy_array_init(&disk_mapping); 1765 : - 1766 253 : ret = sread(f, buffer, 12); - 1767 253 : if (ret < 0) { + 1766 254 : ret = sread(f, buffer, 12); + 1767 254 : if (ret < 0) { 1768 : /* LCOV_EXCL_START */ 1769 : decoding_error(path, f); 1770 : log_fatal("Invalid header!\n"); @@ -1844,9 +1844,9 @@ 1782 : * - SNAPCNT3/SnapRAID 11.0 Adds entry 'Q' for multi parity file. 1783 : * The previous 'P' entry is now deprecated, but supported for importing. 1784 : */ - 1785 253 : if (memcmp(buffer, "SNAPCNT1\n\3\0\0", 12) != 0 - 1786 253 : && memcmp(buffer, "SNAPCNT2\n\3\0\0", 12) != 0 - 1787 253 : && memcmp(buffer, "SNAPCNT3\n\3\0\0", 12) != 0 + 1785 254 : if (memcmp(buffer, "SNAPCNT1\n\3\0\0", 12) != 0 + 1786 254 : && memcmp(buffer, "SNAPCNT2\n\3\0\0", 12) != 0 + 1787 254 : && memcmp(buffer, "SNAPCNT3\n\3\0\0", 12) != 0 1788 : ) { 1789 : /* LCOV_EXCL_START */ 1790 : if (memcmp(buffer, "SNAPCNT", 7) != 0) { @@ -1864,12 +1864,12 @@ 1802 : int c; 1803 : 1804 : /* read the command */ - 1805 3735717 : c = sgetc(f); - 1806 3735717 : if (c == EOF) { - 1807 252 : break; + 1805 3735612 : c = sgetc(f); + 1806 3735612 : if (c == EOF) { + 1807 253 : break; 1808 : } 1809 : - 1810 3735465 : if (c == 'f') { + 1810 3735359 : if (c == 'f') { 1811 : /* file */ 1812 : char sub[PATH_MAX]; 1813 : uint64_t v_size; @@ -1881,25 +1881,25 @@ 1819 : struct snapraid_disk* disk; 1820 : uint32_t mapping; 1821 : - 1822 3611886 : ret = sgetb32(f, &mapping); - 1823 3611886 : if (ret < 0 || mapping >= mapping_max) { + 1822 3611762 : ret = sgetb32(f, &mapping); + 1823 3611762 : if (ret < 0 || mapping >= mapping_max) { 1824 : /* LCOV_EXCL_START */ 1825 : decoding_error(path, f); 1826 : log_fatal("Internal inconsistency in mapping index!\n"); 1827 : os_abort(); 1828 : /* LCOV_EXCL_STOP */ 1829 : } - 1830 3611886 : disk = tommy_array_get(&disk_mapping, mapping); + 1830 3611762 : disk = tommy_array_get(&disk_mapping, mapping); 1831 : - 1832 3611886 : ret = sgetb64(f, &v_size); - 1833 3611886 : if (ret < 0) { + 1832 3611762 : ret = sgetb64(f, &v_size); + 1833 3611762 : if (ret < 0) { 1834 : /* LCOV_EXCL_START */ 1835 : decoding_error(path, f); 1836 : os_abort(); 1837 : /* LCOV_EXCL_STOP */ 1838 : } 1839 : - 1840 3611886 : if (state->block_size == 0) { + 1840 3611762 : if (state->block_size == 0) { 1841 : /* LCOV_EXCL_START */ 1842 : decoding_error(path, f); 1843 : log_fatal("Internal incosistency due zero blocksize!\n"); @@ -1908,7 +1908,7 @@ 1846 : } 1847 : 1848 : /* check for impossible file size to avoid to crash for a too big allocation */ - 1849 3611886 : if (v_size / state->block_size > blockmax) { + 1849 3611762 : if (v_size / state->block_size > blockmax) { 1850 : /* LCOV_EXCL_START */ 1851 : decoding_error(path, f); 1852 : log_fatal("Internal inconsistency in file size too big!\n"); @@ -1916,16 +1916,16 @@ 1854 : /* LCOV_EXCL_STOP */ 1855 : } 1856 : - 1857 3611886 : ret = sgetb64(f, &v_mtime_sec); - 1858 3611886 : if (ret < 0) { + 1857 3611762 : ret = sgetb64(f, &v_mtime_sec); + 1858 3611762 : if (ret < 0) { 1859 : /* LCOV_EXCL_START */ 1860 : decoding_error(path, f); 1861 : os_abort(); 1862 : /* LCOV_EXCL_STOP */ 1863 : } 1864 : - 1865 3611886 : ret = sgetb32(f, &v_mtime_nsec); - 1866 3611886 : if (ret < 0) { + 1865 3611762 : ret = sgetb32(f, &v_mtime_nsec); + 1866 3611762 : if (ret < 0) { 1867 : /* LCOV_EXCL_START */ 1868 : decoding_error(path, f); 1869 : os_abort(); @@ -1933,27 +1933,27 @@ 1871 : } 1872 : 1873 : /* STAT_NSEC_INVALID is encoded as 0 */ - 1874 3611886 : if (v_mtime_nsec == 0) + 1874 3611762 : if (v_mtime_nsec == 0) 1875 0 : v_mtime_nsec = STAT_NSEC_INVALID; 1876 : else - 1877 3611886 : --v_mtime_nsec; + 1877 3611762 : --v_mtime_nsec; 1878 : - 1879 3611886 : ret = sgetb64(f, &v_inode); - 1880 3611886 : if (ret < 0) { + 1879 3611762 : ret = sgetb64(f, &v_inode); + 1880 3611762 : if (ret < 0) { 1881 : /* LCOV_EXCL_START */ 1882 : decoding_error(path, f); 1883 : os_abort(); 1884 : /* LCOV_EXCL_STOP */ 1885 : } 1886 : - 1887 3611886 : ret = sgetbs(f, sub, sizeof(sub)); - 1888 3611886 : if (ret < 0) { + 1887 3611762 : ret = sgetbs(f, sub, sizeof(sub)); + 1888 3611762 : if (ret < 0) { 1889 : /* LCOV_EXCL_START */ 1890 : decoding_error(path, f); 1891 : os_abort(); 1892 : /* LCOV_EXCL_STOP */ 1893 : } - 1894 3611886 : if (!*sub) { + 1894 3611762 : if (!*sub) { 1895 : /* LCOV_EXCL_START */ 1896 : decoding_error(path, f); 1897 : log_fatal("Internal inconsistency for null file!\n"); @@ -1962,40 +1962,40 @@ 1900 : } 1901 : 1902 : /* allocate the file */ - 1903 3611886 : file = file_alloc(state->block_size, sub, v_size, v_mtime_sec, v_mtime_nsec, v_inode, 0); + 1903 3611762 : file = file_alloc(state->block_size, sub, v_size, v_mtime_sec, v_mtime_nsec, v_inode, 0); 1904 : 1905 : /* insert the file in the file containers */ - 1906 3611886 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 1907 3611886 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); - 1908 3611886 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); - 1909 3611886 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); + 1906 3611762 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 1907 3611762 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); + 1908 3611762 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); + 1909 3611762 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); 1910 : 1911 : /* read all the blocks */ - 1912 3611886 : v_idx = 0; - 1913 10856319 : while (v_idx < file->blockmax) { + 1912 3611762 : v_idx = 0; + 1913 10855962 : while (v_idx < file->blockmax) { 1914 : block_off_t v_pos; 1915 : uint32_t v_count; 1916 : 1917 : /* get the "subcommand */ - 1918 3632547 : c = sgetc(f); + 1918 3632438 : c = sgetc(f); 1919 : - 1920 3632547 : ret = sgetb32(f, &v_pos); - 1921 3632547 : if (ret < 0) { + 1920 3632438 : ret = sgetb32(f, &v_pos); + 1921 3632438 : if (ret < 0) { 1922 : /* LCOV_EXCL_START */ 1923 : decoding_error(path, f); 1924 : os_abort(); 1925 : /* LCOV_EXCL_STOP */ 1926 : } 1927 : - 1928 3632547 : ret = sgetb32(f, &v_count); - 1929 3632547 : if (ret < 0) { + 1928 3632438 : ret = sgetb32(f, &v_count); + 1929 3632438 : if (ret < 0) { 1930 : /* LCOV_EXCL_START */ 1931 : decoding_error(path, f); 1932 : os_abort(); 1933 : /* LCOV_EXCL_STOP */ 1934 : } 1935 : - 1936 3632547 : if (v_idx + v_count > file->blockmax) { + 1936 3632438 : if (v_idx + v_count > file->blockmax) { 1937 : /* LCOV_EXCL_START */ 1938 : decoding_error(path, f); 1939 : log_fatal("Internal inconsistency in block number!\n"); @@ -2003,7 +2003,7 @@ 1941 : /* LCOV_EXCL_STOP */ 1942 : } 1943 : - 1944 3632547 : if (v_pos + v_count > blockmax) { + 1944 3632438 : if (v_pos + v_count > blockmax) { 1945 : /* LCOV_EXCL_START */ 1946 : decoding_error(path, f); 1947 : log_fatal("Internal inconsistency in block size %u/%u!\n", blockmax, v_pos + v_count); @@ -2038,9 +2038,9 @@ 1976 : } 1977 : 1978 : /* read the hash only for 'blk/chg/rep', and not for 'new' */ - 1979 8896370 : if (c != 'n') { - 1980 8896370 : ret = sread(f, block->hash, BLOCK_HASH_SIZE); - 1981 8896370 : if (ret < 0) { + 1979 8896100 : if (c != 'n') { + 1980 8896100 : ret = sread(f, block->hash, BLOCK_HASH_SIZE); + 1981 8896100 : if (ret < 0) { 1982 : /* LCOV_EXCL_START */ 1983 : decoding_error(path, f); 1984 : os_abort(); @@ -2053,8 +2053,8 @@ 1991 : 1992 : /* if the block contains a hash of past data */ 1993 : /* and we are clearing such indeterminate hashes */ - 1994 8896370 : if (state->clear_past_hash - 1995 2542370 : && block_has_past_hash(block) + 1994 8896100 : if (state->clear_past_hash + 1995 2542004 : && block_has_past_hash(block) 1996 : ) { 1997 : /* set the hash value to INVALID */ 1998 28006 : hash_invalid_set(block->hash); @@ -2065,8 +2065,8 @@ 2003 : /* in other sync commands */ 2004 : /* note that this is required only in sync, and we detect */ 2005 : /* this using the clear_past_hash flag */ - 2006 8896370 : if (state->clear_past_hash - 2007 2542370 : && state->opt.force_nocopy + 2006 8896100 : if (state->clear_past_hash + 2007 2542004 : && state->opt.force_nocopy 2008 14195 : && block_state_get(block) == BLOCK_STATE_REP 2009 : ) { 2010 : /* set the hash value to INVALID */ @@ -2078,40 +2078,40 @@ 2016 : /* if we want a full reallocation, marks block as invalid parity */ 2017 : /* note that we do this after the force_nocopy option */ 2018 : /* to avoid to mixup the two things */ - 2019 8896370 : if (state->opt.force_realloc + 2019 8896100 : if (state->opt.force_realloc 2020 27826 : && block_state_get(block) == BLOCK_STATE_BLK) { 2021 : /* convert from BLK to REP */ 2022 27826 : block_state_set(block, BLOCK_STATE_REP); 2023 : } 2024 : 2025 : /* set the parity association */ - 2026 8896370 : fs_allocate(disk, v_pos, file, v_idx); + 2026 8896100 : fs_allocate(disk, v_pos, file, v_idx); 2027 : 2028 : /* go to the next block */ - 2029 8896370 : ++v_idx; - 2030 8896370 : ++v_pos; - 2031 8896370 : --v_count; + 2029 8896100 : ++v_idx; + 2030 8896100 : ++v_pos; + 2031 8896100 : --v_count; 2032 : } 2033 : } 2034 : 2035 : /* stat */ - 2036 3611886 : ++count_file; - 2037 123579 : } else if (c == 'i') { + 2036 3611762 : ++count_file; + 2037 123597 : } else if (c == 'i') { 2038 : /* "inf" command */ 2039 : snapraid_info info; 2040 : uint32_t v_pos; 2041 : uint32_t v_oldest; 2042 : - 2043 252 : ret = sgetb32(f, &v_oldest); - 2044 252 : if (ret < 0) { + 2043 253 : ret = sgetb32(f, &v_oldest); + 2044 253 : if (ret < 0) { 2045 : /* LCOV_EXCL_START */ 2046 : decoding_error(path, f); 2047 : os_abort(); 2048 : /* LCOV_EXCL_STOP */ 2049 : } 2050 : - 2051 252 : v_pos = 0; - 2052 55630 : while (v_pos < blockmax) { + 2051 253 : v_pos = 0; + 2052 55893 : while (v_pos < blockmax) { 2053 : int bad; 2054 : int rehash; 2055 : int justsynced; @@ -2119,15 +2119,15 @@ 2057 : uint32_t flag; 2058 : uint32_t v_count; 2059 : - 2060 55126 : ret = sgetb32(f, &v_count); - 2061 55126 : if (ret < 0) { + 2060 55387 : ret = sgetb32(f, &v_count); + 2061 55387 : if (ret < 0) { 2062 : /* LCOV_EXCL_START */ 2063 : decoding_error(path, f); 2064 : os_abort(); 2065 : /* LCOV_EXCL_STOP */ 2066 : } 2067 : - 2068 55126 : if (v_pos + v_count > blockmax) { + 2068 55387 : if (v_pos + v_count > blockmax) { 2069 : /* LCOV_EXCL_START */ 2070 : decoding_error(path, f); 2071 : log_fatal("Internal inconsistency in info size %u/%u!\n", blockmax, v_pos + v_count); @@ -2135,8 +2135,8 @@ 2073 : /* LCOV_EXCL_STOP */ 2074 : } 2075 : - 2076 55126 : ret = sgetb32(f, &flag); - 2077 55126 : if (ret < 0) { + 2076 55387 : ret = sgetb32(f, &flag); + 2077 55387 : if (ret < 0) { 2078 : /* LCOV_EXCL_START */ 2079 : decoding_error(path, f); 2080 : os_abort(); @@ -2144,10 +2144,10 @@ 2082 : } 2083 : 2084 : /* if there is an info */ - 2085 55126 : if ((flag & 1) != 0) { + 2085 55387 : if ((flag & 1) != 0) { 2086 : /* read the time */ - 2087 55111 : ret = sgetb32(f, &t); - 2088 55111 : if (ret < 0) { + 2087 55372 : ret = sgetb32(f, &t); + 2088 55372 : if (ret < 0) { 2089 : /* LCOV_EXCL_START */ 2090 : decoding_error(path, f); 2091 : os_abort(); @@ -2155,11 +2155,11 @@ 2093 : } 2094 : 2095 : /* analyze the flags */ - 2096 55111 : bad = (flag & 2) != 0; - 2097 55111 : rehash = (flag & 4) != 0; - 2098 55111 : justsynced = (flag & 8) != 0; + 2096 55372 : bad = (flag & 2) != 0; + 2097 55372 : rehash = (flag & 4) != 0; + 2098 55372 : justsynced = (flag & 8) != 0; 2099 : - 2100 55111 : if (rehash && state->prevhash == HASH_UNDEFINED) { + 2100 55372 : if (rehash && state->prevhash == HASH_UNDEFINED) { 2101 : /* LCOV_EXCL_START */ 2102 : decoding_error(path, f); 2103 : log_fatal("Internal inconsistency for missing previous checksum!\n"); @@ -2167,18 +2167,18 @@ 2105 : /* LCOV_EXCL_STOP */ 2106 : } 2107 : - 2108 55111 : info = info_make(t + v_oldest, bad, rehash, justsynced); + 2108 55372 : info = info_make(t + v_oldest, bad, rehash, justsynced); 2109 : } else { 2110 15 : info = 0; 2111 : } 2112 : - 2113 1658119 : while (v_count) { + 2113 1658697 : while (v_count) { 2114 : /* insert the info in the array */ - 2115 1547867 : info_set(&state->infoarr, v_pos, info); + 2115 1547923 : info_set(&state->infoarr, v_pos, info); 2116 : 2117 : /* ensure that an info is present only for used positions */ - 2118 1547867 : if (fs_info_is_required(state, v_pos)) { - 2119 1489134 : if (!info) { + 2118 1547923 : if (fs_info_is_required(state, v_pos)) { + 2119 1489158 : if (!info) { 2120 : /* LCOV_EXCL_START */ 2121 : decoding_error(path, f); 2122 : log_fatal("Internal inconsistency for missing info!\n"); @@ -2191,41 +2191,41 @@ 2129 : } 2130 : 2131 : /* go to next block */ - 2132 1547867 : ++v_pos; - 2133 1547867 : --v_count; + 2132 1547923 : ++v_pos; + 2133 1547923 : --v_count; 2134 : } 2135 : } - 2136 123327 : } else if (c == 'h') { + 2136 123344 : } else if (c == 'h') { 2137 : /* hole */ 2138 : uint32_t v_pos; 2139 : struct snapraid_disk* disk; 2140 : uint32_t mapping; 2141 : - 2142 1392 : ret = sgetb32(f, &mapping); - 2143 1392 : if (ret < 0 || mapping >= mapping_max) { + 2142 1397 : ret = sgetb32(f, &mapping); + 2143 1397 : if (ret < 0 || mapping >= mapping_max) { 2144 : /* LCOV_EXCL_START */ 2145 : decoding_error(path, f); 2146 : log_fatal("Internal inconsistency in mapping index!\n"); 2147 : os_abort(); 2148 : /* LCOV_EXCL_STOP */ 2149 : } - 2150 1392 : disk = tommy_array_get(&disk_mapping, mapping); + 2150 1397 : disk = tommy_array_get(&disk_mapping, mapping); 2151 : - 2152 1392 : v_pos = 0; - 2153 4242 : while (v_pos < blockmax) { + 2152 1397 : v_pos = 0; + 2153 4257 : while (v_pos < blockmax) { 2154 : uint32_t v_idx; 2155 : uint32_t v_count; 2156 : struct snapraid_file* deleted; 2157 : - 2158 1458 : ret = sgetb32(f, &v_count); - 2159 1458 : if (ret < 0) { + 2158 1463 : ret = sgetb32(f, &v_count); + 2159 1463 : if (ret < 0) { 2160 : /* LCOV_EXCL_START */ 2161 : decoding_error(path, f); 2162 : os_abort(); 2163 : /* LCOV_EXCL_STOP */ 2164 : } 2165 : - 2166 1458 : if (v_pos + v_count > blockmax) { + 2166 1463 : if (v_pos + v_count > blockmax) { 2167 : /* LCOV_EXCL_START */ 2168 : decoding_error(path, f); 2169 : log_fatal("Internal inconsistency in hole size %u/%u!\n", blockmax, v_pos + v_count); @@ -2234,9 +2234,9 @@ 2172 : } 2173 : 2174 : /* get the sub-command */ - 2175 1458 : c = sgetc(f); + 2175 1463 : c = sgetc(f); 2176 : - 2177 1458 : switch (c) { + 2177 1463 : switch (c) { 2178 : case 'o' : 2179 : /* if it's a run of deleted blocks */ 2180 : @@ -2283,8 +2283,8 @@ 2221 35 : break; 2222 : case 'O' : 2223 : /* go to the next run */ - 2224 1423 : v_pos += v_count; - 2225 1423 : break; + 2224 1428 : v_pos += v_count; + 2225 1428 : break; 2226 : default : 2227 : /* LCOV_EXCL_START */ 2228 : decoding_error(path, f); @@ -2293,7 +2293,7 @@ 2231 : /* LCOV_EXCL_STOP */ 2232 : } 2233 : } - 2234 121935 : } else if (c == 's') { + 2234 121947 : } else if (c == 's') { 2235 : /* symlink */ 2236 : char sub[PATH_MAX]; 2237 : char linkto[PATH_MAX]; @@ -2344,7 +2344,7 @@ 2282 : 2283 : /* stat */ 2284 116468 : ++count_symlink; - 2285 5467 : } else if (c == 'a') { + 2285 5479 : } else if (c == 'a') { 2286 : /* hardlink */ 2287 : char sub[PATH_MAX]; 2288 : char linkto[PATH_MAX]; @@ -2403,7 +2403,7 @@ 2341 : 2342 : /* stat */ 2343 597 : ++count_hardlink; - 2344 4870 : } else if (c == 'r') { + 2344 4882 : } else if (c == 'r') { 2345 : /* dir */ 2346 : char sub[PATH_MAX]; 2347 : struct snapraid_dir* dir; @@ -2445,14 +2445,14 @@ 2383 : 2384 : /* stat */ 2385 790 : ++count_dir; - 2386 4080 : } else if (c == 'c') { + 2386 4092 : } else if (c == 'c') { 2387 : /* get the subcommand */ - 2388 253 : c = sgetc(f); + 2388 254 : c = sgetc(f); 2389 : - 2390 253 : switch (c) { + 2390 254 : switch (c) { 2391 : case 'u' : - 2392 165 : state->hash = HASH_MURMUR3; - 2393 165 : break; + 2392 166 : state->hash = HASH_MURMUR3; + 2393 166 : break; 2394 : case 'k' : 2395 88 : state->hash = HASH_SPOOKY2; 2396 88 : break; @@ -2465,14 +2465,14 @@ 2403 : } 2404 : 2405 : /* read the seed */ - 2406 253 : ret = sread(f, state->hashseed, HASH_MAX); - 2407 253 : if (ret < 0) { + 2406 254 : ret = sread(f, state->hashseed, HASH_MAX); + 2407 254 : if (ret < 0) { 2408 : /* LCOV_EXCL_START */ 2409 : decoding_error(path, f); 2410 : os_abort(); 2411 : /* LCOV_EXCL_STOP */ 2412 : } - 2413 3827 : } else if (c == 'C') { + 2413 3838 : } else if (c == 'C') { 2414 : /* get the sub-command */ 2415 4 : c = sgetc(f); 2416 : @@ -2499,18 +2499,18 @@ 2437 : os_abort(); 2438 : /* LCOV_EXCL_STOP */ 2439 : } - 2440 3823 : } else if (c == 'z') { + 2440 3834 : } else if (c == 'z') { 2441 : uint32_t block_size; 2442 : - 2443 253 : ret = sgetb32(f, &block_size); - 2444 253 : if (ret < 0) { + 2443 254 : ret = sgetb32(f, &block_size); + 2444 254 : if (ret < 0) { 2445 : /* LCOV_EXCL_START */ 2446 : decoding_error(path, f); 2447 : os_abort(); 2448 : /* LCOV_EXCL_STOP */ 2449 : } 2450 : - 2451 253 : if (block_size == 0) { + 2451 254 : if (block_size == 0) { 2452 : /* LCOV_EXCL_START */ 2453 : decoding_error(path, f); 2454 : log_fatal("Zero 'blocksize' specification in the content file!\n"); @@ -2519,11 +2519,11 @@ 2457 : } 2458 : 2459 : /* without configuration, auto assign the block size */ - 2460 253 : if (state->no_conf) { + 2460 254 : if (state->no_conf) { 2461 1 : state->block_size = block_size; 2462 : } 2463 : - 2464 253 : if (block_size != state->block_size) { + 2464 254 : if (block_size != state->block_size) { 2465 : /* LCOV_EXCL_START */ 2466 : decoding_error(path, f); 2467 : log_fatal("Mismatching 'blocksize' specification in the content file!\n"); @@ -2531,18 +2531,18 @@ 2469 : exit(EXIT_FAILURE); 2470 : /* LCOV_EXCL_STOP */ 2471 : } - 2472 3570 : } else if (c == 'y') { + 2472 3580 : } else if (c == 'y') { 2473 : uint32_t hash_size; 2474 : - 2475 253 : ret = sgetb32(f, &hash_size); - 2476 253 : if (ret < 0) { + 2475 254 : ret = sgetb32(f, &hash_size); + 2476 254 : if (ret < 0) { 2477 : /* LCOV_EXCL_START */ 2478 : decoding_error(path, f); 2479 : os_abort(); 2480 : /* LCOV_EXCL_STOP */ 2481 : } 2482 : - 2483 253 : if (hash_size < 2 || hash_size > HASH_MAX) { + 2483 254 : if (hash_size < 2 || hash_size > HASH_MAX) { 2484 : /* LCOV_EXCL_START */ 2485 : decoding_error(path, f); 2486 : log_fatal("Invalid 'hashsize' specification in the content file!\n"); @@ -2551,11 +2551,11 @@ 2489 : } 2490 : 2491 : /* without configuration, auto assign the block size */ - 2492 253 : if (state->no_conf) { + 2492 254 : if (state->no_conf) { 2493 1 : BLOCK_HASH_SIZE = hash_size; 2494 : } 2495 : - 2496 253 : if ((int)hash_size != BLOCK_HASH_SIZE) { + 2496 254 : if ((int)hash_size != BLOCK_HASH_SIZE) { 2497 : /* LCOV_EXCL_START */ 2498 : decoding_error(path, f); 2499 : log_fatal("Mismatching 'hashsize' specification in the content file!\n"); @@ -2563,15 +2563,15 @@ 2501 : exit(EXIT_FAILURE); 2502 : /* LCOV_EXCL_STOP */ 2503 : } - 2504 3317 : } else if (c == 'x') { - 2505 253 : ret = sgetb32(f, &blockmax); - 2506 253 : if (ret < 0) { + 2504 3326 : } else if (c == 'x') { + 2505 254 : ret = sgetb32(f, &blockmax); + 2506 254 : if (ret < 0) { 2507 : /* LCOV_EXCL_START */ 2508 : decoding_error(path, f); 2509 : os_abort(); 2510 : /* LCOV_EXCL_STOP */ 2511 : } - 2512 4462 : } else if (c == 'm' || c == 'M') { + 2512 4475 : } else if (c == 'm' || c == 'M') { 2513 : struct snapraid_map* map; 2514 : char uuid[UUID_MAX]; 2515 : uint32_t v_pos; @@ -2579,16 +2579,16 @@ 2517 : uint32_t v_free_blocks; 2518 : struct snapraid_disk* disk; 2519 : - 2520 1398 : ret = sgetbs(f, buffer, sizeof(buffer)); - 2521 1398 : if (ret < 0) { + 2520 1403 : ret = sgetbs(f, buffer, sizeof(buffer)); + 2521 1403 : if (ret < 0) { 2522 : /* LCOV_EXCL_START */ 2523 : decoding_error(path, f); 2524 : os_abort(); 2525 : /* LCOV_EXCL_STOP */ 2526 : } 2527 : - 2528 1398 : ret = sgetb32(f, &v_pos); - 2529 1398 : if (ret < 0) { + 2528 1403 : ret = sgetb32(f, &v_pos); + 2529 1403 : if (ret < 0) { 2530 : /* LCOV_EXCL_START */ 2531 : decoding_error(path, f); 2532 : os_abort(); @@ -2596,17 +2596,17 @@ 2534 : } 2535 : 2536 : /* from SnapRAID 7.0 the 'M' command includes the free space */ - 2537 1398 : if (c == 'M') { - 2538 1398 : ret = sgetb32(f, &v_total_blocks); - 2539 1398 : if (ret < 0) { + 2537 1403 : if (c == 'M') { + 2538 1403 : ret = sgetb32(f, &v_total_blocks); + 2539 1403 : if (ret < 0) { 2540 : /* LCOV_EXCL_START */ 2541 : decoding_error(path, f); 2542 : os_abort(); 2543 : /* LCOV_EXCL_STOP */ 2544 : } 2545 : - 2546 1398 : ret = sgetb32(f, &v_free_blocks); - 2547 1398 : if (ret < 0) { + 2546 1403 : ret = sgetb32(f, &v_free_blocks); + 2547 1403 : if (ret < 0) { 2548 : /* LCOV_EXCL_START */ 2549 : decoding_error(path, f); 2550 : os_abort(); @@ -2618,8 +2618,8 @@ 2556 : } 2557 : 2558 : /* read the uuid */ - 2559 1398 : ret = sgetbs(f, uuid, sizeof(uuid)); - 2560 1398 : if (ret < 0) { + 2559 1403 : ret = sgetbs(f, uuid, sizeof(uuid)); + 2560 1403 : if (ret < 0) { 2561 : /* LCOV_EXCL_START */ 2562 : decoding_error(path, f); 2563 : os_abort(); @@ -2627,8 +2627,8 @@ 2565 : } 2566 : 2567 : /* find the disk */ - 2568 1398 : disk = find_disk_by_name(state, buffer); - 2569 1398 : if (!disk) { + 2568 1403 : disk = find_disk_by_name(state, buffer); + 2569 1403 : if (!disk) { 2570 : /* search by UUID if renamed */ 2571 2 : disk = find_disk_by_uuid(state, uuid); 2572 2 : if (disk) { @@ -2638,7 +2638,7 @@ 2576 2 : state->need_write = 1; 2577 : } 2578 : } - 2579 1398 : if (!disk) { + 2579 1403 : if (!disk) { 2580 : /* LCOV_EXCL_START */ 2581 : decoding_error(path, f); 2582 : log_fatal("Disk '%s' with uuid '%s' not present in the configuration file!\n", buffer, uuid); @@ -2650,15 +2650,15 @@ 2588 : /* LCOV_EXCL_STOP */ 2589 : } 2590 : - 2591 1398 : map = map_alloc(disk->name, v_pos, v_total_blocks, v_free_blocks, uuid); + 2591 1403 : map = map_alloc(disk->name, v_pos, v_total_blocks, v_free_blocks, uuid); 2592 : - 2593 1398 : tommy_list_insert_tail(&state->maplist, &map->node, map); + 2593 1403 : tommy_list_insert_tail(&state->maplist, &map->node, map); 2594 : 2595 : /* insert in the mapping vector */ - 2596 1398 : tommy_array_grow(&disk_mapping, mapping_max + 1); - 2597 1398 : tommy_array_set(&disk_mapping, mapping_max, disk); - 2598 1398 : ++mapping_max; - 2599 1666 : } else if (c == 'P') { + 2596 1403 : tommy_array_grow(&disk_mapping, mapping_max + 1); + 2597 1403 : tommy_array_set(&disk_mapping, mapping_max, disk); + 2598 1403 : ++mapping_max; + 2599 1669 : } else if (c == 'P') { 2600 : /* from SnapRAID 7.0 the 'P' command includes the free space */ 2601 : /* from SnapRAID 11.0 the 'P' command is deprecated by 'Q' */ 2602 : char v_uuid[UUID_MAX]; @@ -2720,7 +2720,7 @@ 2658 0 : state->parity[v_level].total_blocks = v_total_blocks; 2659 0 : state->parity[v_level].free_blocks = v_free_blocks; 2660 : } - 2661 1666 : } else if (c == 'Q') { + 2661 1669 : } else if (c == 'Q') { 2662 : /* from SnapRAID 11.0 the 'Q' command include size info and multi file support */ 2663 : uint32_t v_level; 2664 : uint32_t v_total_blocks; @@ -2728,39 +2728,39 @@ 2666 : uint32_t v_split_mac; 2667 : unsigned s; 2668 : - 2669 1414 : ret = sgetb32(f, &v_level); - 2670 1414 : if (ret < 0) { + 2669 1415 : ret = sgetb32(f, &v_level); + 2670 1415 : if (ret < 0) { 2671 : /* LCOV_EXCL_START */ 2672 : decoding_error(path, f); 2673 : os_abort(); 2674 : /* LCOV_EXCL_STOP */ 2675 : } 2676 : - 2677 1414 : ret = sgetb32(f, &v_total_blocks); - 2678 1414 : if (ret < 0) { + 2677 1415 : ret = sgetb32(f, &v_total_blocks); + 2678 1415 : if (ret < 0) { 2679 : /* LCOV_EXCL_START */ 2680 : decoding_error(path, f); 2681 : os_abort(); 2682 : /* LCOV_EXCL_STOP */ 2683 : } 2684 : - 2685 1414 : ret = sgetb32(f, &v_free_blocks); - 2686 1414 : if (ret < 0) { + 2685 1415 : ret = sgetb32(f, &v_free_blocks); + 2686 1415 : if (ret < 0) { 2687 : /* LCOV_EXCL_START */ 2688 : decoding_error(path, f); 2689 : os_abort(); 2690 : /* LCOV_EXCL_STOP */ 2691 : } 2692 : - 2693 1414 : ret = sgetb32(f, &v_split_mac); - 2694 1414 : if (ret < 0) { + 2693 1415 : ret = sgetb32(f, &v_split_mac); + 2694 1415 : if (ret < 0) { 2695 : /* LCOV_EXCL_START */ 2696 : decoding_error(path, f); 2697 : os_abort(); 2698 : /* LCOV_EXCL_STOP */ 2699 : } 2700 : - 2701 1414 : if (v_level >= LEV_MAX) { + 2701 1415 : if (v_level >= LEV_MAX) { 2702 : /* LCOV_EXCL_START */ 2703 : decoding_error(path, f); 2704 : log_fatal("Invalid parity level '%u' in the configuration file!\n", v_level); @@ -2769,7 +2769,7 @@ 2707 : } 2708 : 2709 : /* auto configure if configuration is missing */ - 2710 1414 : if (state->no_conf) { + 2710 1415 : if (state->no_conf) { 2711 6 : if (v_level >= state->level) 2712 5 : state->level = v_level + 1; 2713 6 : if (state->parity[v_level].split_mac < v_split_mac) @@ -2777,35 +2777,35 @@ 2715 : } 2716 : 2717 : /* if we use this parity entry */ - 2718 1414 : if (v_level < state->level) { + 2718 1415 : if (v_level < state->level) { 2719 : /* set the parity info */ - 2720 1155 : state->parity[v_level].total_blocks = v_total_blocks; - 2721 1155 : state->parity[v_level].free_blocks = v_free_blocks; + 2720 1156 : state->parity[v_level].total_blocks = v_total_blocks; + 2721 1156 : state->parity[v_level].free_blocks = v_free_blocks; 2722 : } 2723 : - 2724 7066 : for (s = 0; s < v_split_mac; ++s) { + 2724 7075 : for (s = 0; s < v_split_mac; ++s) { 2725 : char v_path[PATH_MAX]; 2726 : char v_uuid[UUID_MAX]; 2727 : uint64_t v_size; 2728 : - 2729 5653 : ret = sgetbs(f, v_path, sizeof(v_path)); - 2730 5653 : if (ret < 0) { + 2729 5660 : ret = sgetbs(f, v_path, sizeof(v_path)); + 2730 5660 : if (ret < 0) { 2731 : /* LCOV_EXCL_START */ 2732 : decoding_error(path, f); 2733 : os_abort(); 2734 : /* LCOV_EXCL_STOP */ 2735 : } 2736 : - 2737 5652 : ret = sgetbs(f, v_uuid, sizeof(v_uuid)); - 2738 5652 : if (ret < 0) { + 2737 5660 : ret = sgetbs(f, v_uuid, sizeof(v_uuid)); + 2738 5660 : if (ret < 0) { 2739 : /* LCOV_EXCL_START */ 2740 : decoding_error(path, f); 2741 : os_abort(); 2742 : /* LCOV_EXCL_STOP */ 2743 : } 2744 : - 2745 5652 : ret = sgetb64(f, &v_size); - 2746 5652 : if (ret < 0) { + 2745 5660 : ret = sgetb64(f, &v_size); + 2746 5660 : if (ret < 0) { 2747 : /* LCOV_EXCL_START */ 2748 : decoding_error(path, f); 2749 : os_abort(); @@ -2813,9 +2813,9 @@ 2751 : } 2752 : 2753 : /* if we use this parity entry */ - 2754 5652 : if (v_level < state->level) { + 2754 5660 : if (v_level < state->level) { 2755 : /* if this split was removed from the configuration */ - 2756 4616 : if (s >= state->parity[v_level].split_mac) { + 2756 4624 : if (s >= state->parity[v_level].split_mac) { 2757 : /* if the file is used, we really need it */ 2758 0 : if (v_size != 0) { 2759 : /* LCOV_EXCL_START */ @@ -2830,30 +2830,30 @@ 2768 0 : log_fatal("WARNING! Dropping from '%s' unused split '%u'\n", lev_config_name(v_level), s); 2769 : } else { 2770 : /* we copy the path only if without configuration file */ - 2771 4616 : if (state->no_conf) + 2771 4624 : if (state->no_conf) 2772 24 : pathcpy(state->parity[v_level].split_map[s].path, sizeof(state->parity[v_level].split_map[s].path), v_path); 2773 : 2774 : /* set the split info */ - 2775 4616 : pathcpy(state->parity[v_level].split_map[s].uuid, sizeof(state->parity[v_level].split_map[s].uuid), v_uuid); - 2776 4616 : state->parity[v_level].split_map[s].size = v_size; + 2775 4624 : pathcpy(state->parity[v_level].split_map[s].uuid, sizeof(state->parity[v_level].split_map[s].uuid), v_uuid); + 2776 4624 : state->parity[v_level].split_map[s].size = v_size; 2777 : 2778 : /* log the info read from the content file */ - 2779 9232 : log_tag("content:%s:%u:%s:%s:%" PRIi64 "\n", lev_config_name(v_level), s, - 2780 4616 : state->parity[v_level].split_map[s].path, - 2781 4616 : state->parity[v_level].split_map[s].uuid, + 2779 9248 : log_tag("content:%s:%u:%s:%s:%" PRIi64 "\n", lev_config_name(v_level), s, + 2780 4624 : state->parity[v_level].split_map[s].path, + 2781 4624 : state->parity[v_level].split_map[s].uuid, 2782 : state->parity[v_level].split_map[s].size); 2783 : } 2784 : } 2785 : } - 2786 252 : } else if (c == 'N') { + 2786 254 : } else if (c == 'N') { 2787 : uint32_t crc_stored; 2788 : uint32_t crc_computed; 2789 : 2790 : /* get the crc before reading it from the file */ - 2791 252 : crc_computed = scrc(f); + 2791 253 : crc_computed = scrc(f); 2792 : - 2793 252 : ret = sgetble32(f, &crc_stored); - 2794 252 : if (ret < 0) { + 2793 253 : ret = sgetble32(f, &crc_stored); + 2794 253 : if (ret < 0) { 2795 : /* LCOV_EXCL_START */ 2796 : /* here don't call decoding_error() because it's too late to get the crc */ 2797 : log_fatal("Error reading the CRC in '%s' at offset %" PRIi64 "\n", path, stell(f)); @@ -2862,7 +2862,7 @@ 2800 : /* LCOV_EXCL_STOP */ 2801 : } 2802 : - 2803 252 : if (crc_stored != crc_computed) { + 2803 253 : if (crc_stored != crc_computed) { 2804 : /* LCOV_EXCL_START */ 2805 : /* here don't call decoding_error() because it's too late to get the crc */ 2806 : log_fatal("Mismatching CRC in '%s'\n", path); @@ -2871,7 +2871,7 @@ 2809 : /* LCOV_EXCL_STOP */ 2810 : } 2811 : - 2812 252 : crc_checked = 1; + 2812 253 : crc_checked = 1; 2813 : } else { 2814 : /* LCOV_EXCL_START */ 2815 : decoding_error(path, f); @@ -2879,18 +2879,18 @@ 2817 : os_abort(); 2818 : /* LCOV_EXCL_STOP */ 2819 : } - 2820 3735464 : } + 2820 3735358 : } 2821 : - 2822 252 : tommy_array_done(&disk_mapping); + 2822 253 : tommy_array_done(&disk_mapping); 2823 : - 2824 252 : if (serror(f)) { + 2824 253 : if (serror(f)) { 2825 : /* LCOV_EXCL_START */ 2826 : log_fatal("Error reading the content file '%s' at offset %" PRIi64 "\n", path, stell(f)); 2827 : exit(EXIT_FAILURE); 2828 : /* LCOV_EXCL_STOP */ 2829 : } 2830 : - 2831 252 : if (!crc_checked) { + 2831 253 : if (!crc_checked) { 2832 : /* LCOV_EXCL_START */ 2833 : log_fatal("Finished reading '%s' without finding the CRC\n", path); 2834 : log_fatal("This content file is truncated or damaged! Use an alternate copy.\n"); @@ -2899,10 +2899,10 @@ 2837 : } 2838 : 2839 : /* check the file-system on all disks */ - 2840 252 : state_fscheck(state, "after read"); + 2840 253 : state_fscheck(state, "after read"); 2841 : 2842 : /* check that the stored parity size matches the loaded state */ - 2843 252 : if (blockmax != parity_allocated_size(state)) { + 2843 253 : if (blockmax != parity_allocated_size(state)) { 2844 : /* LCOV_EXCL_START */ 2845 : log_fatal("Internal inconsistency in parity size %u/%u in '%s' at offset %" PRIi64 "\n", blockmax, parity_allocated_size(state), path, stell(f)); 2846 : if (state->opt.skip_content_check) { @@ -2914,11 +2914,11 @@ 2852 : /* LCOV_EXCL_STOP */ 2853 : } 2854 : - 2855 252 : msg_verbose("%8u files\n", count_file); - 2856 252 : msg_verbose("%8u hardlinks\n", count_hardlink); - 2857 252 : msg_verbose("%8u symlinks\n", count_symlink); - 2858 252 : msg_verbose("%8u empty dirs\n", count_dir); - 2859 252 : } + 2855 253 : msg_verbose("%8u files\n", count_file); + 2856 253 : msg_verbose("%8u hardlinks\n", count_hardlink); + 2857 253 : msg_verbose("%8u symlinks\n", count_symlink); + 2858 253 : msg_verbose("%8u empty dirs\n", count_dir); + 2859 253 : } 2860 : 2861 : struct state_write_thread_context { 2862 : struct snapraid_state* state; @@ -3141,30 +3141,30 @@ 3079 : 3080 : /* for all the blocks of the file */ 3081 1770884 : begin = 0; - 3082 5322945 : while (begin < file->blockmax) { - 3083 1781177 : unsigned v_state = block_state_get(fs_file2block_get(file, begin)); - 3084 1781177 : block_off_t v_pos = fs_file2par_get(disk, file, begin); + 3082 5322967 : while (begin < file->blockmax) { + 3083 1781199 : unsigned v_state = block_state_get(fs_file2block_get(file, begin)); + 3084 1781199 : block_off_t v_pos = fs_file2par_get(disk, file, begin); 3085 : uint32_t v_count; 3086 : 3087 : block_off_t end; 3088 : 3089 : /* find the end of run of blocks */ - 3090 1781177 : end = begin + 1; - 3091 6146317 : while (end < file->blockmax) { + 3090 1781199 : end = begin + 1; + 3091 6146339 : while (end < file->blockmax) { 3092 2596728 : if (v_state != block_state_get(fs_file2block_get(file, end))) 3093 12 : break; 3094 2596716 : if (v_pos + (end - begin) != fs_file2par_get(disk, file, end)) - 3095 12753 : break; - 3096 2583963 : ++end; + 3095 12775 : break; + 3096 2583941 : ++end; 3097 : } 3098 : - 3099 1781177 : switch (v_state) { + 3099 1781199 : switch (v_state) { 3100 : case BLOCK_STATE_BLK : - 3101 1678520 : sputc('b', f); - 3102 1678520 : break; + 3101 1678540 : sputc('b', f); + 3102 1678540 : break; 3103 : case BLOCK_STATE_CHG : - 3104 67739 : sputc('g', f); - 3105 67739 : break; + 3104 67741 : sputc('g', f); + 3105 67741 : break; 3106 : case BLOCK_STATE_REP : 3107 34918 : sputc('p', f); 3108 34918 : break; @@ -3175,19 +3175,19 @@ 3113 : /* LCOV_EXCL_STOP */ 3114 : } 3115 : - 3116 1781177 : sputb32(v_pos, f); + 3116 1781199 : sputb32(v_pos, f); 3117 : - 3118 1781177 : v_count = end - begin; - 3119 1781177 : sputb32(v_count, f); + 3118 1781199 : v_count = end - begin; + 3119 1781199 : sputb32(v_count, f); 3120 : 3121 : /* write hashes */ - 3122 6146317 : for (idx = begin; idx < end; ++idx) { + 3122 6146339 : for (idx = begin; idx < end; ++idx) { 3123 4365140 : struct snapraid_block* block = fs_file2block_get(file, idx); 3124 : 3125 4365140 : swrite(block->hash, BLOCK_HASH_SIZE, f); 3126 : } 3127 : - 3128 1781177 : if (serror(f)) { + 3128 1781199 : if (serror(f)) { 3129 : /* LCOV_EXCL_START */ 3130 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 3131 : return context; @@ -3195,7 +3195,7 @@ 3133 : } 3134 : 3135 : /* next begin position */ - 3136 1781177 : begin = end; + 3136 1781199 : begin = end; 3137 : } 3138 : 3139 1770884 : ++count_file; @@ -3304,44 +3304,44 @@ 3242 151 : sputc('i', f); 3243 151 : sputb32(info_oldest, f); 3244 151 : begin = 0; - 3245 19645 : while (begin < blockmax) { + 3245 19777 : while (begin < blockmax) { 3246 : snapraid_info info; 3247 : block_off_t end; 3248 : time_t t; 3249 : unsigned flag; 3250 : - 3251 19343 : info = info_get(&state->infoarr, begin); + 3251 19475 : info = info_get(&state->infoarr, begin); 3252 : 3253 : /* find the end of run of blocks */ - 3254 19343 : end = begin + 1; - 3255 775442 : while (end < blockmax + 3254 19475 : end = begin + 1; + 3255 775574 : while (end < blockmax 3256 755951 : && info == info_get(&state->infoarr, end) 3257 : ) { - 3258 736756 : ++end; + 3258 736624 : ++end; 3259 : } 3260 : - 3261 19343 : sputb32(end - begin, f); + 3261 19475 : sputb32(end - begin, f); 3262 : 3263 : /* if there is info */ - 3264 19343 : if (info) { + 3264 19475 : if (info) { 3265 : /* other flags */ - 3266 19320 : flag = 1; /* info is present */ - 3267 19320 : if (info_get_bad(info)) - 3268 1340 : flag |= 2; - 3269 19320 : if (info_get_rehash(info)) + 3266 19452 : flag = 1; /* info is present */ + 3267 19452 : if (info_get_bad(info)) + 3268 1330 : flag |= 2; + 3269 19452 : if (info_get_rehash(info)) 3270 5212 : flag |= 4; - 3271 19320 : if (info_get_justsynced(info)) - 3272 12001 : flag |= 8; - 3273 19320 : sputb32(flag, f); + 3271 19452 : if (info_get_justsynced(info)) + 3272 12082 : flag |= 8; + 3273 19452 : sputb32(flag, f); 3274 : - 3275 19320 : t = info_get_time(info) - info_oldest; - 3276 19320 : sputb32(t, f); + 3275 19452 : t = info_get_time(info) - info_oldest; + 3276 19452 : sputb32(t, f); 3277 : } else { 3278 : /* write a special 0 flag to mark missing info */ 3279 23 : sputb32(0, f); 3280 : } 3281 : - 3282 19343 : if (serror(f)) { + 3282 19475 : if (serror(f)) { 3283 : /* LCOV_EXCL_START */ 3284 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 3285 : return context; @@ -3349,7 +3349,7 @@ 3287 : } 3288 : 3289 : /* next begin position */ - 3290 19343 : begin = end; + 3290 19475 : begin = end; 3291 : } 3292 : 3293 151 : sputc('N', f); @@ -3438,7 +3438,7 @@ 3376 711614 : time_t info_time = info_get_time(info); 3377 : 3378 711614 : if (!info_oldest || info_time < info_oldest) - 3379 151 : info_oldest = info_time; + 3379 154 : info_oldest = info_time; 3380 : 3381 711614 : if (info_get_rehash(info)) 3382 13822 : info_has_rehash = 1; @@ -3689,7 +3689,7 @@ 3627 151 : *out_crc = crc; 3628 151 : } 3629 : - 3630 260 : void state_read(struct snapraid_state* state) + 3630 261 : void state_read(struct snapraid_state* state) 3631 : { 3632 : STREAM* f; 3633 : char path[PATH_MAX]; @@ -3699,22 +3699,22 @@ 3637 : int c; 3638 : 3639 : /* iterate over all the available content files and load the first one present */ - 3640 260 : f = 0; - 3641 260 : node = tommy_list_head(&state->contentlist); - 3642 570 : while (node) { - 3643 303 : struct snapraid_content* content = node->data; - 3644 303 : pathcpy(path, sizeof(path), content->content); + 3640 261 : f = 0; + 3641 261 : node = tommy_list_head(&state->contentlist); + 3642 572 : while (node) { + 3643 304 : struct snapraid_content* content = node->data; + 3644 304 : pathcpy(path, sizeof(path), content->content); 3645 : - 3646 303 : if (!state->no_conf) { - 3647 302 : log_tag("content:%s\n", path); - 3648 302 : log_flush(); + 3646 304 : if (!state->no_conf) { + 3647 303 : log_tag("content:%s\n", path); + 3648 303 : log_flush(); 3649 : } - 3650 303 : msg_progress("Loading state from %s...\n", path); + 3650 304 : msg_progress("Loading state from %s...\n", path); 3651 : - 3652 303 : f = sopen_read(path); - 3653 303 : if (f != 0) { + 3652 304 : f = sopen_read(path); + 3653 304 : if (f != 0) { 3654 : /* if opened stop the search */ - 3655 253 : break; + 3655 254 : break; 3656 : } else { 3657 : /* if it's real error of an existing file, abort */ 3658 50 : if (errno != ENOENT) { @@ -3738,17 +3738,17 @@ 3676 : } 3677 : 3678 : /* if not found, assume empty */ - 3679 260 : if (!f) { + 3679 261 : if (!f) { 3680 7 : log_fatal("No content file found. Assuming empty.\n"); 3681 : 3682 : /* create the initial mapping */ 3683 7 : state_map(state); - 3684 266 : return; + 3684 267 : return; 3685 : } 3686 : 3687 : /* get the stat of the content file */ - 3688 253 : ret = fstat(shandle(f), &st); - 3689 253 : if (ret != 0) { + 3688 254 : ret = fstat(shandle(f), &st); + 3689 254 : if (ret != 0) { 3690 : /* LCOV_EXCL_START */ 3691 : log_fatal("Error stating the content file '%s'. %s.\n", path, strerror(errno)); 3692 : exit(EXIT_FAILURE); @@ -3756,14 +3756,14 @@ 3694 : } 3695 : 3696 : /* go further to check other content files */ - 3697 1946 : while (node) { + 3697 1955 : while (node) { 3698 : char other_path[PATH_MAX]; 3699 : struct stat other_st; - 3700 1440 : struct snapraid_content* content = node->data; - 3701 1440 : pathcpy(other_path, sizeof(other_path), content->content); + 3700 1447 : struct snapraid_content* content = node->data; + 3701 1447 : pathcpy(other_path, sizeof(other_path), content->content); 3702 : - 3703 1440 : ret = stat(other_path, &other_st); - 3704 1440 : if (ret != 0) { + 3703 1447 : ret = stat(other_path, &other_st); + 3704 1447 : if (ret != 0) { 3705 : /* allow missing content files, but not any other kind of error */ 3706 1 : if (errno != ENOENT) { 3707 : /* LCOV_EXCL_START */ @@ -3776,7 +3776,7 @@ 3714 1 : state->need_write = 1; 3715 : } else { 3716 : /* if the size is different */ - 3717 1439 : if (other_st.st_size != st.st_size) { + 3717 1446 : if (other_st.st_size != st.st_size) { 3718 39 : log_fatal("WARNING! Content files '%s' and '%s' have a different size!\n", path, other_path); 3719 39 : log_fatal("Likely one of the two is broken!\n"); 3720 : @@ -3786,28 +3786,28 @@ 3724 : } 3725 : 3726 : /* next content file */ - 3727 1440 : node = node->next; + 3727 1447 : node = node->next; 3728 : } 3729 : 3730 : /* start with a undefined default. */ 3731 : /* it's for compatibility with version 1.0 where MD5 was implicit. */ - 3732 253 : state->hash = HASH_UNDEFINED; + 3732 254 : state->hash = HASH_UNDEFINED; 3733 : 3734 : /* start with a zero seed, it was the default in old versions */ - 3735 253 : memset(state->hashseed, 0, HASH_MAX); + 3735 254 : memset(state->hashseed, 0, HASH_MAX); 3736 : 3737 : /* previous hash, start with an undefined value */ - 3738 253 : state->prevhash = HASH_UNDEFINED; + 3738 254 : state->prevhash = HASH_UNDEFINED; 3739 : 3740 : /* intentionally not set the prevhashseed, if used valgrind will warn about it */ 3741 : 3742 : /* get the first char to detect the file type */ - 3743 253 : c = sgetc(f); - 3744 253 : sungetc(c, f); + 3743 254 : c = sgetc(f); + 3744 254 : sungetc(c, f); 3745 : 3746 : /* guess the file type from the first char */ - 3747 253 : if (c == 'S') { - 3748 253 : state_read_content(state, path, f); + 3747 254 : if (c == 'S') { + 3748 254 : state_read_content(state, path, f); 3749 : } else { 3750 : /* LCOV_EXCL_START */ 3751 : log_fatal("From SnapRAID v9.0 the text content file is not supported anymore.\n"); @@ -3816,9 +3816,9 @@ 3754 : /* LCOV_EXCL_STOP */ 3755 : } 3756 : - 3757 252 : sclose(f); + 3757 253 : sclose(f); 3758 : - 3759 252 : if (state->hash == HASH_UNDEFINED) { + 3759 253 : if (state->hash == HASH_UNDEFINED) { 3760 : /* LCOV_EXCL_START */ 3761 : log_fatal("The checksum to use is not specified.\n"); 3762 : log_fatal("This happens because you are likely upgrading from SnapRAID 1.0.\n"); @@ -3829,12 +3829,12 @@ 3767 : } 3768 : 3769 : /* update the mapping */ - 3770 252 : state_map(state); + 3770 253 : state_map(state); 3771 : - 3772 252 : state_content_check(state, path); + 3772 253 : state_content_check(state, path); 3773 : 3774 : /* mark that we read the content file, and it passed all the checks */ - 3775 252 : state->checked_read = 1; + 3775 253 : state->checked_read = 1; 3776 : } 3777 : 3778 : struct state_verify_thread_context { @@ -3866,9 +3866,9 @@ 3804 : } 3805 : 3806 : /* get the stored crc from the last four bytes */ - 3807 1010 : crc_stored = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; + 3807 1012 : crc_stored = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; 3808 : - 3809 1010 : if (crc_stored != context->crc) { + 3809 1012 : if (crc_stored != context->crc) { 3810 : /* LCOV_EXCL_START */ 3811 : log_fatal("DANGER! Wrong stored CRC in '%s'\n", serrorfile(f)); 3812 : return context; @@ -3876,7 +3876,7 @@ 3814 : } 3815 : 3816 : /* get the computed crc */ - 3817 1010 : crc_computed = scrc(f); + 3817 1012 : crc_computed = scrc(f); 3818 : 3819 : /* adjust the stored crc to include itself */ 3820 1012 : crc_stored = crc32c(crc_stored, buf, 4); @@ -4089,7 +4089,7 @@ 4027 78138 : || filter_existence(filter_missing, disk->dir, file->sub) != 0 4028 38646 : || filter_correctness(filter_error, &state->infoarr, disk, file) != 0 4029 : ) { - 4030 109466 : file_flag_set(file, FILE_IS_EXCLUDED); + 4030 109490 : file_flag_set(file, FILE_IS_EXCLUDED); 4031 : } 4032 : } 4033 : @@ -4229,23 +4229,23 @@ 4167 : /** 4168 : * Set the latest tick data in the progress vector. 4169 : */ - 4170 477 : static void state_progress_latest(struct snapraid_state* state) + 4170 532 : static void state_progress_latest(struct snapraid_state* state) 4171 : { 4172 : tommy_node* i; 4173 : unsigned l; 4174 : - 4175 477 : state->progress_tick_misc[state->progress_ptr] = state->tick_misc; - 4176 477 : state->progress_tick_sched[state->progress_ptr] = state->tick_sched; - 4177 477 : state->progress_tick_raid[state->progress_ptr] = state->tick_raid; - 4178 477 : state->progress_tick_hash[state->progress_ptr] = state->tick_hash; - 4179 477 : state->progress_tick_io[state->progress_ptr] = state->tick_io; - 4180 3331 : for (i = state->disklist; i != 0; i = i->next) { - 4181 2854 : struct snapraid_disk* disk = i->data; - 4182 2854 : disk->progress_tick[state->progress_ptr] = disk->tick; + 4175 532 : state->progress_tick_misc[state->progress_ptr] = state->tick_misc; + 4176 532 : state->progress_tick_sched[state->progress_ptr] = state->tick_sched; + 4177 532 : state->progress_tick_raid[state->progress_ptr] = state->tick_raid; + 4178 532 : state->progress_tick_hash[state->progress_ptr] = state->tick_hash; + 4179 532 : state->progress_tick_io[state->progress_ptr] = state->tick_io; + 4180 3716 : for (i = state->disklist; i != 0; i = i->next) { + 4181 3184 : struct snapraid_disk* disk = i->data; + 4182 3184 : disk->progress_tick[state->progress_ptr] = disk->tick; 4183 : } - 4184 2740 : for (l = 0; l < state->level; ++l) - 4185 2263 : state->parity[l].progress_tick[state->progress_ptr] = state->parity[l].tick; - 4186 477 : } + 4184 2946 : for (l = 0; l < state->level; ++l) + 4185 2414 : state->parity[l].progress_tick[state->progress_ptr] = state->parity[l].tick; + 4186 532 : } 4187 : 4188 : /** 4189 : * Number of columns @@ -4257,7 +4257,7 @@ 4195 : */ 4196 : #define ref(map, index) (index < PROGRESS_MAX ? map[index] : 0) 4197 : - 4198 1 : static void state_progress_graph(struct snapraid_state* state, struct snapraid_io* io, unsigned current, unsigned oldest) + 4198 2 : static void state_progress_graph(struct snapraid_state* state, struct snapraid_io* io, unsigned current, unsigned oldest) 4199 : { 4200 : uint64_t v; 4201 : uint64_t tick_total; @@ -4266,174 +4266,174 @@ 4204 : unsigned l; 4205 : size_t pad; 4206 : - 4207 1 : tick_total = 0; + 4207 2 : tick_total = 0; 4208 : - 4209 1 : tick_total += state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest); - 4210 1 : tick_total += state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest); - 4211 1 : tick_total += state->progress_tick_raid[current] - ref(state->progress_tick_raid, oldest); - 4212 1 : tick_total += state->progress_tick_hash[current] - ref(state->progress_tick_hash, oldest); - 4213 1 : tick_total += state->progress_tick_io[current] - ref(state->progress_tick_io, oldest); - 4214 1 : if (!tick_total) - 4215 1 : return; + 4209 2 : tick_total += state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest); + 4210 2 : tick_total += state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest); + 4211 2 : tick_total += state->progress_tick_raid[current] - ref(state->progress_tick_raid, oldest); + 4212 2 : tick_total += state->progress_tick_hash[current] - ref(state->progress_tick_hash, oldest); + 4213 2 : tick_total += state->progress_tick_io[current] - ref(state->progress_tick_io, oldest); + 4214 2 : if (!tick_total) + 4215 2 : return; 4216 : - 4217 1 : pad = 4; - 4218 7 : for (i = state->disklist; i != 0; i = i->next) { - 4219 6 : struct snapraid_disk* disk = i->data; - 4220 6 : size_t len = strlen(disk->name); - 4221 6 : if (pad < len) - 4222 1 : pad = len; + 4217 2 : pad = 4; + 4218 14 : for (i = state->disklist; i != 0; i = i->next) { + 4219 12 : struct snapraid_disk* disk = i->data; + 4220 12 : size_t len = strlen(disk->name); + 4221 12 : if (pad < len) + 4222 2 : pad = len; 4223 : } - 4224 7 : for (l = 0; l < state->level; ++l) { - 4225 6 : size_t len = strlen(lev_config_name(l)); - 4226 6 : if (pad < len) - 4227 2 : pad = len; + 4224 9 : for (l = 0; l < state->level; ++l) { + 4225 7 : size_t len = strlen(lev_config_name(l)); + 4226 7 : if (pad < len) + 4227 3 : pad = len; 4228 : } 4229 : 4230 : /* extra space */ - 4231 1 : pad += 1; + 4231 2 : pad += 1; 4232 : - 4233 1 : if (pad + 30 < GRAPH_COLUMN) - 4234 1 : bar = GRAPH_COLUMN - pad; + 4233 2 : if (pad + 30 < GRAPH_COLUMN) + 4234 2 : bar = GRAPH_COLUMN - pad; 4235 : else 4236 0 : bar = 30; 4237 : - 4238 1 : if (io) { - 4239 0 : const char* legend = "cached blocks (instant, more is better)"; + 4238 2 : if (io) { + 4239 1 : const char* legend = "cached blocks (instant, more is better)"; 4240 : 4241 : /* refresh the cached blocks info */ - 4242 0 : io_refresh(io); + 4242 1 : io_refresh(io); 4243 : - 4244 0 : printf("\n"); + 4244 1 : printf("\n"); 4245 : - 4246 0 : for (i = state->disklist; i != 0; i = i->next) { - 4247 0 : struct snapraid_disk* disk = i->data; - 4248 0 : v = disk->cached; - 4249 0 : printr(disk->name, pad); - 4250 0 : printf("%4" PRIu64 " | ", v); - 4251 0 : printc('o', v * bar / io->io_max); - 4252 0 : printf("\n"); + 4246 7 : for (i = state->disklist; i != 0; i = i->next) { + 4247 6 : struct snapraid_disk* disk = i->data; + 4248 6 : v = disk->cached; + 4249 6 : printr(disk->name, pad); + 4250 6 : printf("%4" PRIu64 " | ", v); + 4251 6 : printc('o', v * bar / io->io_max); + 4252 6 : printf("\n"); 4253 : } 4254 : - 4255 0 : for (l = 0; l < state->level; ++l) { - 4256 0 : v = state->parity[l].cached; - 4257 0 : printr(lev_config_name(l), pad); - 4258 0 : printf("%4" PRIu64 " | ", v); - 4259 0 : printc('o', v * bar / io->io_max); - 4260 0 : printf("\n"); + 4255 2 : for (l = 0; l < state->level; ++l) { + 4256 1 : v = state->parity[l].cached; + 4257 1 : printr(lev_config_name(l), pad); + 4258 1 : printf("%4" PRIu64 " | ", v); + 4259 1 : printc('o', v * bar / io->io_max); + 4260 1 : printf("\n"); 4261 : } 4262 : - 4263 0 : printc(' ', pad); - 4264 0 : printf(" |_"); - 4265 0 : printc('_', bar); - 4266 0 : printf("\n"); + 4263 1 : printc(' ', pad); + 4264 1 : printf(" |_"); + 4265 1 : printc('_', bar); + 4266 1 : printf("\n"); 4267 : - 4268 0 : printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend) / 2); - 4269 0 : printf("%s", legend); - 4270 0 : printf("\n"); + 4268 1 : printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend) / 2); + 4269 1 : printf("%s", legend); + 4270 1 : printf("\n"); 4271 : } 4272 : - 4273 1 : printf("\n"); + 4273 2 : printf("\n"); 4274 : - 4275 7 : for (i = state->disklist; i != 0; i = i->next) { - 4276 6 : struct snapraid_disk* disk = i->data; - 4277 6 : v = disk->progress_tick[current] - ref(disk->progress_tick, oldest); - 4278 6 : printr(disk->name, pad); - 4279 6 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4280 6 : printc('*', v * bar / tick_total); - 4281 6 : printf("\n"); + 4275 14 : for (i = state->disklist; i != 0; i = i->next) { + 4276 12 : struct snapraid_disk* disk = i->data; + 4277 12 : v = disk->progress_tick[current] - ref(disk->progress_tick, oldest); + 4278 12 : printr(disk->name, pad); + 4279 12 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4280 12 : printc('*', v * bar / tick_total); + 4281 12 : printf("\n"); 4282 : } 4283 : - 4284 7 : for (l = 0; l < state->level; ++l) { - 4285 6 : v = state->parity[l].progress_tick[current] - ref(state->parity[l].progress_tick, oldest); - 4286 6 : printr(lev_config_name(l), pad); - 4287 6 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4288 6 : printc('*', v * bar / tick_total); - 4289 6 : printf("\n"); + 4284 9 : for (l = 0; l < state->level; ++l) { + 4285 7 : v = state->parity[l].progress_tick[current] - ref(state->parity[l].progress_tick, oldest); + 4286 7 : printr(lev_config_name(l), pad); + 4287 7 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4288 7 : printc('*', v * bar / tick_total); + 4289 7 : printf("\n"); 4290 : } 4291 : - 4292 1 : v = state->progress_tick_raid[current] - ref(state->progress_tick_raid, oldest); - 4293 1 : printr("raid", pad); - 4294 1 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4295 1 : printc('*', v * bar / tick_total); - 4296 1 : printf("\n"); + 4292 2 : v = state->progress_tick_raid[current] - ref(state->progress_tick_raid, oldest); + 4293 2 : printr("raid", pad); + 4294 2 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4295 2 : printc('*', v * bar / tick_total); + 4296 2 : printf("\n"); 4297 : - 4298 1 : v = state->progress_tick_hash[current] - ref(state->progress_tick_hash, oldest); - 4299 1 : printr("hash", pad); - 4300 1 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4301 1 : printc('*', v * bar / tick_total); - 4302 1 : printf("\n"); + 4298 2 : v = state->progress_tick_hash[current] - ref(state->progress_tick_hash, oldest); + 4299 2 : printr("hash", pad); + 4300 2 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4301 2 : printc('*', v * bar / tick_total); + 4302 2 : printf("\n"); 4303 : - 4304 1 : v = state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest); - 4305 1 : printr("sched", pad); - 4306 1 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4307 1 : printc('*', v * bar / tick_total); - 4308 1 : printf("\n"); + 4304 2 : v = state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest); + 4305 2 : printr("sched", pad); + 4306 2 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4307 2 : printc('*', v * bar / tick_total); + 4308 2 : printf("\n"); 4309 : - 4310 1 : v = state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest); - 4311 1 : printr("misc", pad); - 4312 1 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); - 4313 1 : printc('*', v * bar / tick_total); - 4314 1 : printf("\n"); + 4310 2 : v = state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest); + 4311 2 : printr("misc", pad); + 4312 2 : printf("%3" PRIu64 "%% | ", v * 100 / tick_total); + 4313 2 : printc('*', v * bar / tick_total); + 4314 2 : printf("\n"); 4315 : - 4316 1 : printc(' ', pad); - 4317 1 : printf(" |_"); - 4318 1 : printc('_', bar); - 4319 1 : printf("\n"); + 4316 2 : printc(' ', pad); + 4317 2 : printf(" |_"); + 4318 2 : printc('_', bar); + 4319 2 : printf("\n"); 4320 : - 4321 1 : if (oldest == PROGRESS_MAX) { + 4321 2 : if (oldest == PROGRESS_MAX) { 4322 1 : const char* legend = "wait time (total, less is better)"; 4323 1 : printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend) / 2); 4324 1 : printf("%s", legend); 4325 1 : printf("\n"); 4326 : } else { - 4327 0 : const char* legend_d = "wait time (last %d secs, less is better)"; - 4328 0 : printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend_d) / 2); - 4329 0 : printf(legend_d, PROGRESS_MAX); - 4330 0 : printf("\n"); + 4327 1 : const char* legend_d = "wait time (last %d secs, less is better)"; + 4328 1 : printc(' ', 5 + pad + 1 + bar / 2 - strlen(legend_d) / 2); + 4329 1 : printf(legend_d, PROGRESS_MAX); + 4330 1 : printf("\n"); 4331 : } 4332 : - 4333 1 : printf("\n"); + 4333 2 : printf("\n"); 4334 : } 4335 : - 4336 1073497 : int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) + 4336 1073436 : int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) 4337 : { 4338 : time_t now; 4339 : int pred; 4340 : - 4341 1073497 : now = time(0); + 4341 1073436 : now = time(0); 4342 : 4343 : /* previous position */ - 4344 1073497 : pred = state->progress_ptr + PROGRESS_MAX - 1; - 4345 1073497 : if (pred >= PROGRESS_MAX) - 4346 1073298 : pred -= PROGRESS_MAX; + 4344 1073436 : pred = state->progress_ptr + PROGRESS_MAX - 1; + 4345 1073436 : if (pred >= PROGRESS_MAX) + 4346 1073237 : pred -= PROGRESS_MAX; 4347 : 4348 : /* if the previous measure is different */ - 4349 1073497 : if (state->progress_tick == 0 - 4350 1073298 : || state->progress_time[pred] != now + 4349 1073436 : if (state->progress_tick == 0 + 4350 1073237 : || state->progress_time[pred] != now 4351 : ) { 4352 : time_t elapsed; - 4353 381 : unsigned out_perc = 0; - 4354 381 : unsigned out_speed = 0; - 4355 381 : unsigned out_cpu = 0; - 4356 381 : unsigned out_eta = 0; - 4357 381 : int out_computed = 0; + 4353 436 : unsigned out_perc = 0; + 4354 436 : unsigned out_speed = 0; + 4355 436 : unsigned out_cpu = 0; + 4356 436 : unsigned out_eta = 0; + 4357 436 : int out_computed = 0; 4358 : 4359 : /* store the new measure */ - 4360 381 : state->progress_time[state->progress_ptr] = now; - 4361 381 : state->progress_pos[state->progress_ptr] = countpos; - 4362 381 : state->progress_size[state->progress_ptr] = countsize; - 4363 381 : state_progress_latest(state); + 4360 436 : state->progress_time[state->progress_ptr] = now; + 4361 436 : state->progress_pos[state->progress_ptr] = countpos; + 4362 436 : state->progress_size[state->progress_ptr] = countsize; + 4363 436 : state_progress_latest(state); 4364 : - 4365 381 : elapsed = now - state->progress_whole_start - state->progress_wasted; + 4365 436 : elapsed = now - state->progress_whole_start - state->progress_wasted; 4366 : 4367 : /* completion percentage */ - 4368 381 : if (countmax) - 4369 381 : out_perc = countpos * 100 / countmax; + 4368 436 : if (countmax) + 4369 436 : out_perc = countpos * 100 / countmax; 4370 : 4371 : /* if we have at least 5 measures */ - 4372 381 : if (state->progress_tick >= 5 + 4372 436 : if (state->progress_tick >= 5 4373 : /* or if we are running in test mode, with at least one measure */ - 4374 365 : || (state->opt.force_progress && state->progress_tick >= 1) + 4374 397 : || (state->opt.force_progress && state->progress_tick >= 1) 4375 : ) { 4376 : int oldest; 4377 : int past; @@ -4448,88 +4448,88 @@ 4386 : uint64_t oldest_tick_total; 4387 : 4388 : /* number of past measures */ - 4389 182 : past = state->progress_tick; + 4389 237 : past = state->progress_tick; 4390 : 4391 : /* drop the oldest ones, to promptly */ 4392 : /* skip the startup phase */ - 4393 182 : past -= past / 5; + 4393 237 : past -= past / 5; 4394 : 4395 : /* check how much we can go in the past */ - 4396 182 : if (past >= PROGRESS_MAX - 1) { + 4396 237 : if (past >= PROGRESS_MAX - 1) { 4397 : /* the vector is filled, so we are already in position */ 4398 : /* to get the possible oldest one */ 4399 0 : oldest = state->progress_ptr + 1; 4400 : } else { 4401 : /* go backward the number of positions selected */ - 4402 182 : oldest = state->progress_ptr + PROGRESS_MAX - past; + 4402 237 : oldest = state->progress_ptr + PROGRESS_MAX - past; 4403 : } - 4404 182 : if (oldest >= PROGRESS_MAX) - 4405 182 : oldest -= PROGRESS_MAX; + 4404 237 : if (oldest >= PROGRESS_MAX) + 4405 237 : oldest -= PROGRESS_MAX; 4406 : - 4407 364 : tick_cpu = state->progress_tick_misc[state->progress_ptr] - 4408 182 : + state->progress_tick_sched[state->progress_ptr] - 4409 182 : + state->progress_tick_raid[state->progress_ptr] - 4410 182 : + state->progress_tick_hash[state->progress_ptr]; - 4411 182 : tick_total = tick_cpu + state->progress_tick_io[state->progress_ptr]; + 4407 474 : tick_cpu = state->progress_tick_misc[state->progress_ptr] + 4408 237 : + state->progress_tick_sched[state->progress_ptr] + 4409 237 : + state->progress_tick_raid[state->progress_ptr] + 4410 237 : + state->progress_tick_hash[state->progress_ptr]; + 4411 237 : tick_total = tick_cpu + state->progress_tick_io[state->progress_ptr]; 4412 : - 4413 364 : oldest_tick_cpu = state->progress_tick_misc[oldest] - 4414 182 : + state->progress_tick_sched[oldest] - 4415 182 : + state->progress_tick_raid[oldest] - 4416 182 : + state->progress_tick_hash[oldest]; - 4417 182 : oldest_tick_total = oldest_tick_cpu + state->progress_tick_io[oldest]; + 4413 474 : oldest_tick_cpu = state->progress_tick_misc[oldest] + 4414 237 : + state->progress_tick_sched[oldest] + 4415 237 : + state->progress_tick_raid[oldest] + 4416 237 : + state->progress_tick_hash[oldest]; + 4417 237 : oldest_tick_total = oldest_tick_cpu + state->progress_tick_io[oldest]; 4418 : - 4419 182 : delta_time = now - state->progress_time[oldest]; - 4420 182 : delta_pos = countpos - state->progress_pos[oldest]; - 4421 182 : delta_size = countsize - state->progress_size[oldest]; - 4422 182 : delta_tick_cpu = tick_cpu - oldest_tick_cpu; - 4423 182 : delta_tick_total = tick_total - oldest_tick_total; + 4419 237 : delta_time = now - state->progress_time[oldest]; + 4420 237 : delta_pos = countpos - state->progress_pos[oldest]; + 4421 237 : delta_size = countsize - state->progress_size[oldest]; + 4422 237 : delta_tick_cpu = tick_cpu - oldest_tick_cpu; + 4423 237 : delta_tick_total = tick_total - oldest_tick_total; 4424 : 4425 : /* estimate the speed in MB/s */ - 4426 182 : if (delta_time != 0) - 4427 182 : out_speed = (unsigned)(delta_size / MEGA / delta_time); + 4426 237 : if (delta_time != 0) + 4427 237 : out_speed = (unsigned)(delta_size / MEGA / delta_time); 4428 : 4429 : /* estimate the cpu usage percentage */ - 4430 182 : if (delta_tick_total != 0) - 4431 77 : out_cpu = (unsigned)(delta_tick_cpu * 100U / delta_tick_total); + 4430 237 : if (delta_tick_total != 0) + 4431 95 : out_cpu = (unsigned)(delta_tick_cpu * 100U / delta_tick_total); 4432 : 4433 : /* estimate the remaining time in minutes */ - 4434 182 : if (delta_pos != 0) - 4435 182 : out_eta = (countmax - countpos) * delta_time / (60 * delta_pos); + 4434 237 : if (delta_pos != 0) + 4435 237 : out_eta = (countmax - countpos) * delta_time / (60 * delta_pos); 4436 : - 4437 182 : if (state->opt.force_stats) { - 4438 0 : os_clear(); - 4439 0 : state_progress_graph(state, io, state->progress_ptr, oldest); + 4437 237 : if (state->opt.force_stats) { + 4438 1 : os_clear(); + 4439 1 : state_progress_graph(state, io, state->progress_ptr, oldest); 4440 : } 4441 : 4442 : /* we have the output value */ - 4443 182 : out_computed = 1; + 4443 237 : out_computed = 1; 4444 : } 4445 : - 4446 381 : if (state->opt.gui) { - 4447 8 : log_tag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu, (uint64_t)elapsed); - 4448 8 : log_flush(); + 4446 436 : if (state->opt.gui) { + 4447 7 : log_tag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu, (uint64_t)elapsed); + 4448 7 : log_flush(); 4449 : } else { - 4450 373 : msg_bar("%u%%, %u MB", out_perc, (unsigned)(countsize / MEGA)); - 4451 373 : if (out_computed) { - 4452 179 : msg_bar(", %u MB/s", out_speed); - 4453 179 : msg_bar(", CPU %u%%", out_cpu); - 4454 179 : msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); + 4450 429 : msg_bar("%u%%, %u MB", out_perc, (unsigned)(countsize / MEGA)); + 4451 429 : if (out_computed) { + 4452 235 : msg_bar(", %u MB/s", out_speed); + 4453 235 : msg_bar(", CPU %u%%", out_cpu); + 4454 235 : msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); 4455 : } - 4456 373 : msg_bar("%s\r", PROGRESS_CLEAR); - 4457 373 : msg_flush(); + 4456 429 : msg_bar("%s\r", PROGRESS_CLEAR); + 4457 429 : msg_flush(); 4458 : } 4459 : 4460 : /* next position to fill */ - 4461 381 : ++state->progress_ptr; - 4462 381 : if (state->progress_ptr >= PROGRESS_MAX) + 4461 436 : ++state->progress_ptr; + 4462 436 : if (state->progress_ptr >= PROGRESS_MAX) 4463 0 : state->progress_ptr -= PROGRESS_MAX; 4464 : 4465 : /* one more measure */ - 4466 381 : ++state->progress_tick; + 4466 436 : ++state->progress_tick; 4467 : } 4468 : 4469 : /* stop if requested */ - 4470 1073497 : if (global_interrupt) { + 4470 1073436 : if (global_interrupt) { 4471 : /* LCOV_EXCL_START */ 4472 : if (!state->opt.gui) { 4473 : log_fatal("\n"); @@ -4541,7 +4541,7 @@ 4479 : /* LCOV_EXCL_STOP */ 4480 : } 4481 : - 4482 1073497 : return 0; + 4482 1073436 : return 0; 4483 : } 4484 : 4485 104 : void state_usage_waste(struct snapraid_state* state) @@ -4551,83 +4551,83 @@ 4489 104 : state->tick_last = now; 4490 104 : } 4491 : - 4492 1063671 : void state_usage_misc(struct snapraid_state* state) + 4492 1063244 : void state_usage_misc(struct snapraid_state* state) 4493 : { - 4494 1063671 : uint64_t now = tick(); - 4495 1063671 : uint64_t delta = now - state->tick_last; + 4494 1063244 : uint64_t now = tick(); + 4495 1063244 : uint64_t delta = now - state->tick_last; 4496 : 4497 : /* increment the time spent in computations */ - 4498 1063671 : state->tick_misc += delta; + 4498 1063244 : state->tick_misc += delta; 4499 : - 4500 1063671 : state->tick_last = now; - 4501 1063671 : } + 4500 1063244 : state->tick_last = now; + 4501 1063244 : } 4502 : - 4503 149924 : void state_usage_sched(struct snapraid_state* state) + 4503 149863 : void state_usage_sched(struct snapraid_state* state) 4504 : { - 4505 149924 : uint64_t now = tick(); - 4506 149924 : uint64_t delta = now - state->tick_last; + 4505 149863 : uint64_t now = tick(); + 4506 149863 : uint64_t delta = now - state->tick_last; 4507 : 4508 : /* increment the time spent in computations */ - 4509 149924 : state->tick_sched += delta; + 4509 149863 : state->tick_sched += delta; 4510 : - 4511 149924 : state->tick_last = now; - 4512 149924 : } + 4511 149863 : state->tick_last = now; + 4512 149863 : } 4513 : - 4514 140438 : void state_usage_raid(struct snapraid_state* state) + 4514 140402 : void state_usage_raid(struct snapraid_state* state) 4515 : { - 4516 140438 : uint64_t now = tick(); - 4517 140438 : uint64_t delta = now - state->tick_last; + 4516 140402 : uint64_t now = tick(); + 4517 140402 : uint64_t delta = now - state->tick_last; 4518 : 4519 : /* increment the time spent in computations */ - 4520 140438 : state->tick_raid += delta; + 4520 140402 : state->tick_raid += delta; 4521 : - 4522 140438 : state->tick_last = now; - 4523 140438 : } + 4522 140402 : state->tick_last = now; + 4523 140402 : } 4524 : - 4525 777357 : void state_usage_hash(struct snapraid_state* state) + 4525 776953 : void state_usage_hash(struct snapraid_state* state) 4526 : { - 4527 777357 : uint64_t now = tick(); - 4528 777357 : uint64_t delta = now - state->tick_last; + 4527 776953 : uint64_t now = tick(); + 4528 776953 : uint64_t delta = now - state->tick_last; 4529 : 4530 : /* increment the time spent in computations */ - 4531 777357 : state->tick_hash += delta; + 4531 776953 : state->tick_hash += delta; 4532 : - 4533 777357 : state->tick_last = now; - 4534 777357 : } + 4533 776953 : state->tick_last = now; + 4534 776953 : } 4535 : - 4536 912885 : void state_usage_disk(struct snapraid_state* state, struct snapraid_handle* handle_map, unsigned* waiting_map, unsigned waiting_mac) + 4536 912519 : void state_usage_disk(struct snapraid_state* state, struct snapraid_handle* handle_map, unsigned* waiting_map, unsigned waiting_mac) 4537 : { - 4538 912885 : uint64_t now = tick(); - 4539 912885 : uint64_t delta = now - state->tick_last; + 4538 912519 : uint64_t now = tick(); + 4539 912519 : uint64_t delta = now - state->tick_last; 4540 : unsigned i; 4541 : 4542 : /* increment the time spent in the data disks */ - 4543 955948 : for (i = 0; i < waiting_mac; ++i) { - 4544 43063 : struct snapraid_disk* disk = handle_map[waiting_map[i]].disk; + 4543 957179 : for (i = 0; i < waiting_mac; ++i) { + 4544 44660 : struct snapraid_disk* disk = handle_map[waiting_map[i]].disk; 4545 : - 4546 43063 : if (!disk) - 4547 16 : continue; + 4546 44660 : if (!disk) + 4547 10 : continue; 4548 : - 4549 43047 : disk->tick += delta; + 4549 44650 : disk->tick += delta; 4550 : } - 4551 912885 : state->tick_io += delta; + 4551 912519 : state->tick_io += delta; 4552 : - 4553 912885 : state->tick_last = now; - 4554 912885 : } + 4553 912519 : state->tick_last = now; + 4554 912519 : } 4555 : - 4556 774551 : void state_usage_parity(struct snapraid_state* state, unsigned* waiting_map, unsigned waiting_mac) + 4556 774185 : void state_usage_parity(struct snapraid_state* state, unsigned* waiting_map, unsigned waiting_mac) 4557 : { - 4558 774551 : uint64_t now = tick(); - 4559 774551 : uint64_t delta = now - state->tick_last; + 4558 774185 : uint64_t now = tick(); + 4559 774185 : uint64_t delta = now - state->tick_last; 4560 : unsigned i; 4561 : 4562 : /* increment the time spent in the parity disk */ - 4563 851244 : for (i = 0; i < waiting_mac; ++i) - 4564 76693 : state->parity[waiting_map[i]].tick += delta; - 4565 774551 : state->tick_io += delta; + 4563 854258 : for (i = 0; i < waiting_mac; ++i) + 4564 80073 : state->parity[waiting_map[i]].tick += delta; + 4565 774185 : state->tick_io += delta; 4566 : - 4567 774551 : state->tick_last = now; - 4568 774551 : } + 4567 774185 : state->tick_last = now; + 4568 774185 : } 4569 : 4570 96 : void state_usage_print(struct snapraid_state* state) 4571 : { @@ -4641,22 +4641,22 @@ 4579 1 : state_progress_graph(state, 0, state->progress_ptr, PROGRESS_MAX); 4580 : } 4581 : - 4582 498 : void state_fscheck(struct snapraid_state* state, const char* ope) + 4582 499 : void state_fscheck(struct snapraid_state* state, const char* ope) 4583 : { 4584 : tommy_node* i; 4585 : 4586 : /* check the file-system on all disks */ - 4587 3480 : for (i = state->disklist; i != 0; i = i->next) { - 4588 2982 : struct snapraid_disk* disk = i->data; + 4587 3487 : for (i = state->disklist; i != 0; i = i->next) { + 4588 2988 : struct snapraid_disk* disk = i->data; 4589 : - 4590 2982 : if (fs_check(disk) != 0) { + 4590 2988 : if (fs_check(disk) != 0) { 4591 : /* LCOV_EXCL_START */ 4592 : log_fatal("Internal inconsistency in file-system for disk '%s' %s\n", disk->name, ope); 4593 : os_abort(); 4594 : /* LCOV_EXCL_STOP */ 4595 : } 4596 : } - 4597 498 : } + 4597 499 : } 4598 : 4599 1 : void generate_configuration(const char* path) 4600 : { diff --git a/cov/cmdline/status.c.func-sort-c.html b/cov/cmdline/status.c.func-sort-c.html index 7df3af32..e86aad6d 100644 --- a/cov/cmdline/status.c.func-sort-c.html +++ b/cov/cmdline/status.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 266 + 270 283 - 94.0 % + 95.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -61,15 +61,15 @@ perc - 62 + 68 day_ago - 24 + 27 state_status - 14 + 15
diff --git a/cov/cmdline/status.c.func.html b/cov/cmdline/status.c.func.html index 1f239e18..7976d962 100644 --- a/cov/cmdline/status.c.func.html +++ b/cov/cmdline/status.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 266 + 270 283 - 94.0 % + 95.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -61,15 +61,15 @@ day_ago - 24 + 27 perc - 62 + 68 state_status - 14 + 15
diff --git a/cov/cmdline/status.c.gcov.html b/cov/cmdline/status.c.gcov.html index 1d1e972c..689bae52 100644 --- a/cov/cmdline/status.c.gcov.html +++ b/cov/cmdline/status.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 266 + 270 283 - 94.0 % + 95.4 % Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -89,20 +89,20 @@ 27 : /****************************************************************************/ 28 : /* status */ 29 : - 30 24 : unsigned day_ago(time_t ref, time_t now) + 30 27 : unsigned day_ago(time_t ref, time_t now) 31 : { - 32 24 : return (now - ref) / (24 * 3600); + 32 27 : return (now - ref) / (24 * 3600); 33 : } 34 : 35 : #define GRAPH_COLUMN 70 36 : #define GRAPH_ROW 15 37 : - 38 62 : static unsigned perc(uint64_t part, uint64_t total) + 38 68 : static unsigned perc(uint64_t part, uint64_t total) 39 : { - 40 62 : if (!total) + 40 68 : if (!total) 41 6 : return 0; 42 : - 43 56 : return (unsigned)(part * 100 / total); + 43 62 : return (unsigned)(part * 100 / total); 44 : } 45 : 46 : /** @@ -110,7 +110,7 @@ 48 : */ 49 : #define TIME_NEW 1 50 : - 51 14 : int state_status(struct snapraid_state* state) + 51 15 : int state_status(struct snapraid_state* state) 52 : { 53 : block_off_t blockmax; 54 : block_off_t i; @@ -144,68 +144,68 @@ 82 : int free_not_zero; 83 : 84 : /* get the present time */ - 85 14 : now = time(0); + 85 15 : now = time(0); 86 : 87 : /* keep track if at least a free info is available */ - 88 14 : free_not_zero = 0; + 88 15 : free_not_zero = 0; 89 : - 90 14 : blockmax = parity_allocated_size(state); + 90 15 : blockmax = parity_allocated_size(state); 91 : - 92 14 : log_tag("summary:block_size:%u\n", state->block_size); - 93 14 : log_tag("summary:parity_block_count:%u\n", blockmax); + 92 15 : log_tag("summary:block_size:%u\n", state->block_size); + 93 15 : log_tag("summary:parity_block_count:%u\n", blockmax); 94 : 95 : /* get the minimum parity free space */ - 96 14 : parity_block_free = state->parity[0].free_blocks; - 97 98 : for (l = 0; l < state->level; ++l) { - 98 84 : log_tag("summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks); - 99 84 : log_tag("summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks); - 100 84 : if (state->parity[l].free_blocks < parity_block_free) + 96 15 : parity_block_free = state->parity[0].free_blocks; + 97 105 : for (l = 0; l < state->level; ++l) { + 98 90 : log_tag("summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks); + 99 90 : log_tag("summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks); + 100 90 : if (state->parity[l].free_blocks < parity_block_free) 101 1 : parity_block_free = state->parity[l].free_blocks; - 102 84 : if (state->parity[l].free_blocks != 0) - 103 73 : free_not_zero = 1; + 102 90 : if (state->parity[l].free_blocks != 0) + 103 79 : free_not_zero = 1; 104 : } - 105 14 : log_tag("summary:parity_block_free_min:%u\n", parity_block_free); + 105 15 : log_tag("summary:parity_block_free_min:%u\n", parity_block_free); 106 : - 107 14 : printf("SnapRAID status report:\n"); - 108 14 : printf("\n"); - 109 14 : printf(" Files Fragmented Excess Wasted Used Free Use Name\n"); - 110 14 : printf(" Files Fragments GB GB GB\n"); + 107 15 : printf("SnapRAID status report:\n"); + 108 15 : printf("\n"); + 109 15 : printf(" Files Fragmented Excess Wasted Used Free Use Name\n"); + 110 15 : printf(" Files Fragments GB GB GB\n"); 111 : 112 : /* count fragments */ - 113 14 : file_count = 0; - 114 14 : file_size = 0; - 115 14 : file_block_count = 0; - 116 14 : file_block_free = 0; - 117 14 : file_fragmented = 0; - 118 14 : extra_fragment = 0; - 119 14 : file_zerosubsecond = 0; - 120 14 : all_wasted = 0; - 121 98 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { - 122 84 : struct snapraid_disk* disk = node_disk->data; + 113 15 : file_count = 0; + 114 15 : file_size = 0; + 115 15 : file_block_count = 0; + 116 15 : file_block_free = 0; + 117 15 : file_fragmented = 0; + 118 15 : extra_fragment = 0; + 119 15 : file_zerosubsecond = 0; + 120 15 : all_wasted = 0; + 121 105 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { + 122 90 : struct snapraid_disk* disk = node_disk->data; 123 : tommy_node* node; 124 : block_off_t j; - 125 84 : unsigned disk_file_count = 0; - 126 84 : unsigned disk_file_fragmented = 0; - 127 84 : unsigned disk_extra_fragment = 0; - 128 84 : unsigned disk_file_zerosubsecond = 0; - 129 84 : block_off_t disk_block_count = 0; - 130 84 : uint64_t disk_file_size = 0; - 131 84 : block_off_t disk_block_latest_used = 0; + 125 90 : unsigned disk_file_count = 0; + 126 90 : unsigned disk_file_fragmented = 0; + 127 90 : unsigned disk_extra_fragment = 0; + 128 90 : unsigned disk_file_zerosubsecond = 0; + 129 90 : block_off_t disk_block_count = 0; + 130 90 : uint64_t disk_file_size = 0; + 131 90 : block_off_t disk_block_latest_used = 0; 132 : block_off_t disk_block_max_by_space; 133 : block_off_t disk_block_max_by_parity; 134 : block_off_t disk_block_max; 135 : int64_t wasted; 136 : 137 : /* for each file in the disk */ - 138 84 : node = disk->filelist; - 139 95690 : while (node) { + 138 90 : node = disk->filelist; + 139 95714 : while (node) { 140 : struct snapraid_file* file; 141 : - 142 95522 : file = node->data; - 143 95522 : node = node->next; /* next node */ + 142 95534 : file = node->data; + 143 95534 : node = node->next; /* next node */ 144 : - 145 95522 : if (file->mtime_nsec == STAT_NSEC_INVALID - 146 95522 : || file->mtime_nsec == 0 + 145 95534 : if (file->mtime_nsec == STAT_NSEC_INVALID + 146 95534 : || file->mtime_nsec == 0 147 : ) { 148 0 : ++file_zerosubsecond; 149 0 : ++disk_file_zerosubsecond; @@ -216,195 +216,195 @@ 154 : } 155 : 156 : /* check fragmentation */ - 157 95522 : if (file->blockmax != 0) { + 157 95534 : if (file->blockmax != 0) { 158 : block_off_t prev_pos; 159 : block_off_t last_pos; 160 : int fragmented; 161 : - 162 95384 : fragmented = 0; - 163 95384 : prev_pos = fs_file2par_get(disk, file, 0); - 164 235639 : for (j = 1; j < file->blockmax; ++j) { - 165 140255 : block_off_t parity_pos = fs_file2par_get(disk, file, j); - 166 140255 : if (prev_pos + 1 != parity_pos) { + 162 95396 : fragmented = 0; + 163 95396 : prev_pos = fs_file2par_get(disk, file, 0); + 164 235735 : for (j = 1; j < file->blockmax; ++j) { + 165 140339 : block_off_t parity_pos = fs_file2par_get(disk, file, j); + 166 140339 : if (prev_pos + 1 != parity_pos) { 167 698 : fragmented = 1; 168 698 : ++extra_fragment; 169 698 : ++disk_extra_fragment; 170 : } - 171 140255 : prev_pos = parity_pos; + 171 140339 : prev_pos = parity_pos; 172 : } 173 : 174 : /* keep track of latest block used */ - 175 95384 : last_pos = fs_file2par_get(disk, file, file->blockmax - 1); - 176 95384 : if (last_pos > disk_block_latest_used) { - 177 92527 : disk_block_latest_used = last_pos; + 175 95396 : last_pos = fs_file2par_get(disk, file, file->blockmax - 1); + 176 95396 : if (last_pos > disk_block_latest_used) { + 177 92537 : disk_block_latest_used = last_pos; 178 : } 179 : - 180 95384 : if (fragmented) { + 180 95396 : if (fragmented) { 181 582 : ++file_fragmented; 182 582 : ++disk_file_fragmented; 183 : } 184 : - 185 95384 : disk_block_count += file->blockmax; + 185 95396 : disk_block_count += file->blockmax; 186 : } 187 : 188 : /* count files */ - 189 95522 : ++file_count; - 190 95522 : ++disk_file_count; - 191 95522 : file_size += file->size; - 192 95522 : file_block_count += file->blockmax; - 193 95522 : disk_file_size += file->size; + 189 95534 : ++file_count; + 190 95534 : ++disk_file_count; + 191 95534 : file_size += file->size; + 192 95534 : file_block_count += file->blockmax; + 193 95534 : disk_file_size += file->size; 194 : } 195 : - 196 84 : if (disk->free_blocks != 0) - 197 48 : free_not_zero = 1; + 196 90 : if (disk->free_blocks != 0) + 197 53 : free_not_zero = 1; 198 : 199 : /* get the free block info */ - 200 84 : disk_block_max_by_space = disk_block_count + disk->free_blocks; - 201 84 : disk_block_max_by_parity = blockmax + parity_block_free; + 200 90 : disk_block_max_by_space = disk_block_count + disk->free_blocks; + 201 90 : disk_block_max_by_parity = blockmax + parity_block_free; 202 : 203 : /* the maximum usable space in a disk is limited by the smallest */ 204 : /* of the disk size and the parity size */ 205 : /* the wasted space is the space that we have to leave */ 206 : /* free on the data disk, when the parity is filled up */ - 207 84 : if (disk_block_max_by_space < disk_block_max_by_parity) { - 208 72 : disk_block_max = disk_block_max_by_space; + 207 90 : if (disk_block_max_by_space < disk_block_max_by_parity) { + 208 78 : disk_block_max = disk_block_max_by_space; 209 : } else { 210 12 : disk_block_max = disk_block_max_by_parity; 211 : } 212 : 213 : /* wasted space is the difference of the two maximum size */ 214 : /* if negative, it's extra space available in parity */ - 215 84 : wasted = (int64_t)disk_block_max_by_space - (int64_t)disk_block_max_by_parity; - 216 84 : wasted *= state->block_size; + 215 90 : wasted = (int64_t)disk_block_max_by_space - (int64_t)disk_block_max_by_parity; + 216 90 : wasted *= state->block_size; 217 : - 218 84 : if (wasted > 0) + 218 90 : if (wasted > 0) 219 6 : all_wasted += wasted; - 220 84 : file_block_free += disk_block_max - disk_block_count; + 220 90 : file_block_free += disk_block_max - disk_block_count; 221 : - 222 84 : printf("%8u", disk_file_count); - 223 84 : printf("%8u", disk_file_fragmented); - 224 84 : printf("%8u", disk_extra_fragment); - 225 84 : if (wasted < -100LL * GIGA) { - 226 72 : printf(" -"); + 222 90 : printf("%8u", disk_file_count); + 223 90 : printf("%8u", disk_file_fragmented); + 224 90 : printf("%8u", disk_extra_fragment); + 225 90 : if (wasted < -100LL * GIGA) { + 226 78 : printf(" -"); 227 : } else { 228 12 : printf("%8.1f", (double)wasted / GIGA); 229 : } - 230 84 : printf("%8" PRIu64, disk_file_size / GIGA); + 230 90 : printf("%8" PRIu64, disk_file_size / GIGA); 231 : - 232 84 : if (disk_block_max == 0 && disk_block_count == 0) { + 232 90 : if (disk_block_max == 0 && disk_block_count == 0) { 233 : /* if the disk is empty and we don't have the free space info */ - 234 36 : printf(" -"); - 235 36 : printf(" - "); + 234 37 : printf(" -"); + 235 37 : printf(" - "); 236 : } else { - 237 48 : printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / GIGA); - 238 48 : printf(" %3u%%", perc(disk_block_count, disk_block_max)); + 237 53 : printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / GIGA); + 238 53 : printf(" %3u%%", perc(disk_block_count, disk_block_max)); 239 : } - 240 84 : printf(" %s\n", disk->name); + 240 90 : printf(" %s\n", disk->name); 241 : - 242 84 : log_tag("summary:disk_file_count:%s:%u\n", disk->name, disk_file_count); - 243 84 : log_tag("summary:disk_block_count:%s:%u\n", disk->name, disk_block_count); - 244 84 : log_tag("summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented); - 245 84 : log_tag("summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment); - 246 84 : log_tag("summary:disk_zerosubsecond_file_count:%s:%u\n", disk->name, disk_file_zerosubsecond); - 247 84 : log_tag("summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size); - 248 84 : log_tag("summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1); - 249 84 : log_tag("summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks); - 250 84 : log_tag("summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks); - 251 84 : log_tag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space); - 252 84 : log_tag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity); - 253 84 : log_tag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max); - 254 84 : log_tag("summary:disk_space_wasted:%s:%" PRId64 "\n", disk->name, wasted); + 242 90 : log_tag("summary:disk_file_count:%s:%u\n", disk->name, disk_file_count); + 243 90 : log_tag("summary:disk_block_count:%s:%u\n", disk->name, disk_block_count); + 244 90 : log_tag("summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented); + 245 90 : log_tag("summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment); + 246 90 : log_tag("summary:disk_zerosubsecond_file_count:%s:%u\n", disk->name, disk_file_zerosubsecond); + 247 90 : log_tag("summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size); + 248 90 : log_tag("summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1); + 249 90 : log_tag("summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks); + 250 90 : log_tag("summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks); + 251 90 : log_tag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space); + 252 90 : log_tag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity); + 253 90 : log_tag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max); + 254 90 : log_tag("summary:disk_space_wasted:%s:%" PRId64 "\n", disk->name, wasted); 255 : } 256 : 257 : /* totals */ - 258 14 : printf(" --------------------------------------------------------------------------\n"); - 259 14 : printf("%8u", file_count); - 260 14 : printf("%8u", file_fragmented); - 261 14 : printf("%8u", extra_fragment); - 262 14 : printf("%8.1f", (double)all_wasted / GIGA); - 263 14 : printf("%8" PRIu64, file_size / GIGA); - 264 14 : printf("%8" PRIu64, file_block_free * state->block_size / GIGA); - 265 14 : printf(" %3u%%", perc(file_block_count, file_block_count + file_block_free)); - 266 14 : printf("\n"); + 258 15 : printf(" --------------------------------------------------------------------------\n"); + 259 15 : printf("%8u", file_count); + 260 15 : printf("%8u", file_fragmented); + 261 15 : printf("%8u", extra_fragment); + 262 15 : printf("%8.1f", (double)all_wasted / GIGA); + 263 15 : printf("%8" PRIu64, file_size / GIGA); + 264 15 : printf("%8" PRIu64, file_block_free * state->block_size / GIGA); + 265 15 : printf(" %3u%%", perc(file_block_count, file_block_count + file_block_free)); + 266 15 : printf("\n"); 267 : 268 : /* warn about invalid data free info */ - 269 14 : if (!free_not_zero) + 269 15 : if (!free_not_zero) 270 1 : printf("\nWARNING! Free space info will be valid after the first sync.\n"); 271 : - 272 14 : log_tag("summary:file_count:%u\n", file_count); - 273 14 : log_tag("summary:file_block_count:%" PRIu64 "\n", file_block_count); - 274 14 : log_tag("summary:fragmented_file_count:%u\n", file_fragmented); - 275 14 : log_tag("summary:excess_fragment_count:%u\n", extra_fragment); - 276 14 : log_tag("summary:zerosubsecond_file_count:%u\n", file_zerosubsecond); - 277 14 : log_tag("summary:file_size:%" PRIu64 "\n", file_size); - 278 14 : log_tag("summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size); - 279 14 : log_tag("summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size); - 280 14 : log_tag("summary:hash:%s\n", hash_config_name(state->hash)); - 281 14 : log_tag("summary:prev_hash:%s\n", hash_config_name(state->prevhash)); - 282 14 : log_tag("summary:best_hash:%s\n", hash_config_name(state->besthash)); - 283 14 : log_flush(); + 272 15 : log_tag("summary:file_count:%u\n", file_count); + 273 15 : log_tag("summary:file_block_count:%" PRIu64 "\n", file_block_count); + 274 15 : log_tag("summary:fragmented_file_count:%u\n", file_fragmented); + 275 15 : log_tag("summary:excess_fragment_count:%u\n", extra_fragment); + 276 15 : log_tag("summary:zerosubsecond_file_count:%u\n", file_zerosubsecond); + 277 15 : log_tag("summary:file_size:%" PRIu64 "\n", file_size); + 278 15 : log_tag("summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size); + 279 15 : log_tag("summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size); + 280 15 : log_tag("summary:hash:%s\n", hash_config_name(state->hash)); + 281 15 : log_tag("summary:prev_hash:%s\n", hash_config_name(state->prevhash)); + 282 15 : log_tag("summary:best_hash:%s\n", hash_config_name(state->besthash)); + 283 15 : log_flush(); 284 : 285 : /* copy the info a temp vector, and count bad/rehash/unsynced blocks */ - 286 14 : timemap = malloc_nofail(blockmax * sizeof(time_t)); - 287 14 : bad = 0; - 288 14 : bad_first = 0; - 289 14 : bad_last = 0; - 290 14 : count = 0; - 291 14 : rehash = 0; - 292 14 : unsynced_blocks = 0; - 293 14 : unscrubbed_blocks = 0; - 294 14 : log_tag("block_count:%u\n", blockmax); - 295 39766 : for (i = 0; i < blockmax; ++i) { + 286 15 : timemap = malloc_nofail(blockmax * sizeof(time_t)); + 287 15 : bad = 0; + 288 15 : bad_first = 0; + 289 15 : bad_last = 0; + 290 15 : count = 0; + 291 15 : rehash = 0; + 292 15 : unsynced_blocks = 0; + 293 15 : unscrubbed_blocks = 0; + 294 15 : log_tag("block_count:%u\n", blockmax); + 295 39823 : for (i = 0; i < blockmax; ++i) { 296 : int one_invalid; 297 : int one_valid; 298 : - 299 39752 : snapraid_info info = info_get(&state->infoarr, i); + 299 39808 : snapraid_info info = info_get(&state->infoarr, i); 300 : 301 : /* for each disk */ - 302 39752 : one_invalid = 0; - 303 39752 : one_valid = 0; - 304 278264 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { - 305 238512 : struct snapraid_disk* disk = node_disk->data; - 306 238512 : struct snapraid_block* block = fs_par2block_find(disk, i); + 302 39808 : one_invalid = 0; + 303 39808 : one_valid = 0; + 304 278656 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { + 305 238848 : struct snapraid_disk* disk = node_disk->data; + 306 238848 : struct snapraid_block* block = fs_par2block_find(disk, i); 307 : - 308 238512 : if (block_has_file(block)) - 309 235639 : one_valid = 1; - 310 238512 : if (block_has_invalid_parity(block)) - 311 0 : one_invalid = 1; + 308 238848 : if (block_has_file(block)) + 309 235735 : one_valid = 1; + 310 238848 : if (block_has_invalid_parity(block)) + 311 56 : one_invalid = 1; 312 : } 313 : 314 : /* if both valid and invalid, we need to update */ - 315 39752 : if (one_invalid && one_valid) { - 316 0 : ++unsynced_blocks; + 315 39808 : if (one_invalid && one_valid) { + 316 40 : ++unsynced_blocks; 317 : } 318 : 319 : /* skip unused blocks */ - 320 39752 : if (info != 0) { + 320 39808 : if (info != 0) { 321 : time_t scrub_time; 322 : - 323 39752 : if (info_get_bad(info)) { + 323 39808 : if (info_get_bad(info)) { 324 1772 : if (bad == 0) 325 2 : bad_first = i; 326 1772 : bad_last = i; 327 1772 : ++bad; 328 : } 329 : - 330 39752 : if (info_get_rehash(info)) + 330 39808 : if (info_get_rehash(info)) 331 4607 : ++rehash; 332 : - 333 39752 : scrub_time = info_get_time(info); + 333 39808 : scrub_time = info_get_time(info); 334 : - 335 39752 : if (info_get_justsynced(info)) { - 336 20456 : ++unscrubbed_blocks; + 335 39808 : if (info_get_justsynced(info)) { + 336 20516 : ++unscrubbed_blocks; 337 : 338 : /* mark the time as not scrubbed */ - 339 20456 : scrub_time |= TIME_NEW; + 339 20516 : scrub_time |= TIME_NEW; 340 : } 341 : - 342 39752 : timemap[count++] = scrub_time; + 342 39808 : timemap[count++] = scrub_time; 343 : } 344 : - 345 39752 : if (state->opt.gui) { + 345 39808 : if (state->opt.gui) { 346 0 : if (info != 0) 347 0 : log_tag("block:%u:%" PRIu64 ":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used" : "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : ""); 348 : else @@ -412,145 +412,145 @@ 350 : } 351 : } 352 : - 353 14 : log_tag("summary:has_unsynced:%u\n", unsynced_blocks); - 354 14 : log_tag("summary:has_unscrubbed:%u\n", unscrubbed_blocks); - 355 14 : log_tag("summary:has_rehash:%u\n", rehash); - 356 14 : log_tag("summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last); - 357 14 : log_flush(); + 353 15 : log_tag("summary:has_unsynced:%u\n", unsynced_blocks); + 354 15 : log_tag("summary:has_unscrubbed:%u\n", unscrubbed_blocks); + 355 15 : log_tag("summary:has_rehash:%u\n", rehash); + 356 15 : log_tag("summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last); + 357 15 : log_flush(); 358 : - 359 14 : if (!count) { + 359 15 : if (!count) { 360 6 : log_fatal("The array is empty.\n"); 361 6 : free(timemap); 362 6 : return 0; 363 : } 364 : 365 : /* sort the info to get the time info */ - 366 8 : qsort(timemap, count, sizeof(time_t), time_compare); + 366 9 : qsort(timemap, count, sizeof(time_t), time_compare); 367 : 368 : /* output the info map */ - 369 8 : i = 0; - 370 8 : log_tag("info_count:%u\n", count); - 371 33 : while (i < count) { - 372 17 : unsigned j = i + 1; - 373 39769 : while (j < count && timemap[i] == timemap[j]) - 374 39735 : ++j; - 375 17 : if ((timemap[i] & TIME_NEW) == 0) { - 376 7 : log_tag("info_time:%" PRIu64 ":%u:scrubbed\n", (uint64_t)timemap[i], j - i); + 369 9 : i = 0; + 370 9 : log_tag("info_count:%u\n", count); + 371 40 : while (i < count) { + 372 22 : unsigned j = i + 1; + 373 39830 : while (j < count && timemap[i] == timemap[j]) + 374 39786 : ++j; + 375 22 : if ((timemap[i] & TIME_NEW) == 0) { + 376 8 : log_tag("info_time:%" PRIu64 ":%u:scrubbed\n", (uint64_t)timemap[i], j - i); 377 : } else { - 378 10 : log_tag("info_time:%" PRIu64 ":%u:new\n", (uint64_t)(timemap[i] & ~TIME_NEW), j - i); + 378 14 : log_tag("info_time:%" PRIu64 ":%u:new\n", (uint64_t)(timemap[i] & ~TIME_NEW), j - i); 379 : } - 380 17 : i = j; + 380 22 : i = j; 381 : } 382 : - 383 8 : oldest = timemap[0]; - 384 8 : median = timemap[count / 2]; - 385 8 : newest = timemap[count - 1]; - 386 8 : dayoldest = day_ago(oldest, now); - 387 8 : daymedian = day_ago(median, now); - 388 8 : daynewest = day_ago(newest, now); + 383 9 : oldest = timemap[0]; + 384 9 : median = timemap[count / 2]; + 385 9 : newest = timemap[count - 1]; + 386 9 : dayoldest = day_ago(oldest, now); + 387 9 : daymedian = day_ago(median, now); + 388 9 : daynewest = day_ago(newest, now); 389 : 390 : /* compute graph limits */ - 391 8 : barpos = 0; - 392 8 : barmax = 0; - 393 568 : for (i = 0; i < GRAPH_COLUMN; ++i) { + 391 9 : barpos = 0; + 392 9 : barmax = 0; + 393 639 : for (i = 0; i < GRAPH_COLUMN; ++i) { 394 : time_t limit; 395 : unsigned step_scrubbed, step_new; 396 : - 397 560 : limit = oldest + (newest - oldest) * (i + 1) / GRAPH_COLUMN; + 397 630 : limit = oldest + (newest - oldest) * (i + 1) / GRAPH_COLUMN; 398 : - 399 560 : step_scrubbed = 0; - 400 560 : step_new = 0; - 401 40872 : while (barpos < count && timemap[barpos] <= limit) { - 402 39752 : if ((timemap[barpos] & TIME_NEW) != 0) - 403 20456 : ++step_new; + 399 630 : step_scrubbed = 0; + 400 630 : step_new = 0; + 401 41068 : while (barpos < count && timemap[barpos] <= limit) { + 402 39808 : if ((timemap[barpos] & TIME_NEW) != 0) + 403 20516 : ++step_new; 404 : else - 405 19296 : ++step_scrubbed; - 406 39752 : ++barpos; + 405 19292 : ++step_scrubbed; + 406 39808 : ++barpos; 407 : } 408 : - 409 560 : if (step_new + step_scrubbed > barmax) - 410 11 : barmax = step_new + step_scrubbed; + 409 630 : if (step_new + step_scrubbed > barmax) + 410 12 : barmax = step_new + step_scrubbed; 411 : - 412 560 : bar_scrubbed[i] = step_scrubbed; - 413 560 : bar_new[i] = step_new; + 412 630 : bar_scrubbed[i] = step_scrubbed; + 413 630 : bar_new[i] = step_new; 414 : } 415 : - 416 8 : printf("\n\n"); + 416 9 : printf("\n\n"); 417 : 418 : /* print the graph */ - 419 128 : for (y = 0; y < GRAPH_ROW; ++y) { - 420 120 : if (y == 0) - 421 8 : printf("%3u%%|", barmax * 100 / count); - 422 112 : else if (y == GRAPH_ROW - 1) - 423 8 : printf(" 0%%|"); - 424 104 : else if (y == GRAPH_ROW / 2) - 425 8 : printf("%3u%%|", barmax * 50 / count); + 419 144 : for (y = 0; y < GRAPH_ROW; ++y) { + 420 135 : if (y == 0) + 421 9 : printf("%3u%%|", barmax * 100 / count); + 422 126 : else if (y == GRAPH_ROW - 1) + 423 9 : printf(" 0%%|"); + 424 117 : else if (y == GRAPH_ROW / 2) + 425 9 : printf("%3u%%|", barmax * 50 / count); 426 : else - 427 96 : printf(" |"); - 428 8520 : for (x = 0; x < GRAPH_COLUMN; ++x) { - 429 8400 : unsigned pivot_upper = barmax * (GRAPH_ROW - y) / GRAPH_ROW; - 430 8400 : unsigned pivot_lower = barmax * (GRAPH_ROW - 1 - y) / GRAPH_ROW; - 431 8400 : unsigned both = bar_scrubbed[x] + bar_new[x]; - 432 8400 : unsigned scrubbed = bar_scrubbed[x]; + 427 108 : printf(" |"); + 428 9585 : for (x = 0; x < GRAPH_COLUMN; ++x) { + 429 9450 : unsigned pivot_upper = barmax * (GRAPH_ROW - y) / GRAPH_ROW; + 430 9450 : unsigned pivot_lower = barmax * (GRAPH_ROW - 1 - y) / GRAPH_ROW; + 431 9450 : unsigned both = bar_scrubbed[x] + bar_new[x]; + 432 9450 : unsigned scrubbed = bar_scrubbed[x]; 433 : - 434 8400 : if (both > pivot_upper) { - 435 144 : if (scrubbed > pivot_lower) - 436 63 : printf("*"); + 434 9450 : if (both > pivot_upper) { + 435 162 : if (scrubbed > pivot_lower) + 436 71 : printf("*"); 437 : else - 438 81 : printf("o"); - 439 8256 : } else if (both > pivot_lower) { - 440 17 : if (scrubbed == both) + 438 91 : printf("o"); + 439 9288 : } else if (both > pivot_lower) { + 440 21 : if (scrubbed == both) 441 7 : printf("*"); 442 : else - 443 10 : printf("o"); + 443 14 : printf("o"); 444 : } else { - 445 8239 : if (y == GRAPH_ROW - 1) - 446 543 : printf("_"); + 445 9267 : if (y == GRAPH_ROW - 1) + 446 609 : printf("_"); 447 : else - 448 7696 : printf(" "); + 448 8658 : printf(" "); 449 : } 450 : } - 451 120 : printf("\n"); + 451 135 : printf("\n"); 452 : } - 453 8 : printf(" %3u days ago of the last scrub/sync %3u\n", dayoldest, daynewest); + 453 9 : printf(" %3u days ago of the last scrub/sync %3u\n", dayoldest, daynewest); 454 : - 455 8 : printf("\n"); + 455 9 : printf("\n"); 456 : - 457 8 : printf("The oldest block was scrubbed %u days ago, the median %u, the newest %u.\n", dayoldest, daymedian, daynewest); + 457 9 : printf("The oldest block was scrubbed %u days ago, the median %u, the newest %u.\n", dayoldest, daymedian, daynewest); 458 : - 459 8 : printf("\n"); + 459 9 : printf("\n"); 460 : - 461 8 : if (unsynced_blocks) { - 462 0 : printf("WARNING! The array is NOT fully synced.\n"); - 463 0 : printf("You have a sync in progress at %u%%.\n", (blockmax - unsynced_blocks) * 100 / blockmax); + 461 9 : if (unsynced_blocks) { + 462 1 : printf("WARNING! The array is NOT fully synced.\n"); + 463 1 : printf("You have a sync in progress at %u%%.\n", (blockmax - unsynced_blocks) * 100 / blockmax); 464 : } else { 465 8 : printf("No sync is in progress.\n"); 466 : } 467 : - 468 8 : if (unscrubbed_blocks) { - 469 6 : printf("The %u%% of the array is not scrubbed.\n", (unscrubbed_blocks * 100 + blockmax - 1) / blockmax); + 468 9 : if (unscrubbed_blocks) { + 469 7 : printf("The %u%% of the array is not scrubbed.\n", (unscrubbed_blocks * 100 + blockmax - 1) / blockmax); 470 : } else { 471 2 : printf("The full array was scrubbed at least one time.\n"); 472 : } 473 : - 474 8 : if (file_zerosubsecond) { + 474 9 : if (file_zerosubsecond) { 475 0 : printf("You have %u files with zero sub-second timestamp.\n", file_zerosubsecond); 476 0 : printf("Run the 'touch' command to set it to a not zero value.\n"); 477 : } else { - 478 8 : printf("No file has a zero sub-second timestamp.\n"); + 478 9 : printf("No file has a zero sub-second timestamp.\n"); 479 : } 480 : - 481 8 : if (rehash) { + 481 9 : if (rehash) { 482 1 : printf("You have a rehash in progress at %u%%.\n", (count - rehash) * 100 / count); 483 : } else { - 484 7 : if (state->besthash != state->hash) { + 484 8 : if (state->besthash != state->hash) { 485 0 : printf("No rehash is in progress, but for optimal performance one is recommended.\n"); 486 : } else { - 487 7 : printf("No rehash is in progress or needed.\n"); + 487 8 : printf("No rehash is in progress or needed.\n"); 488 : } 489 : } 490 : - 491 8 : if (bad) { + 491 9 : if (bad) { 492 : block_off_t bad_print; 493 : 494 2 : printf("DANGER! In the array there are %u errors!\n\n", bad); @@ -582,13 +582,13 @@ 520 2 : printf("To fix them use the command 'snapraid -e fix'.\n"); 521 2 : printf("The errors will disappear from the 'status' at the next 'scrub' command.\n"); 522 : } else { - 523 6 : printf("No error detected.\n"); + 523 7 : printf("No error detected.\n"); 524 : } 525 : 526 : /* free the temp vector */ - 527 8 : free(timemap); + 527 9 : free(timemap); 528 : - 529 8 : return 0; + 529 9 : return 0; 530 : } 531 : diff --git a/cov/cmdline/stream.c.func-sort-c.html b/cov/cmdline/stream.c.func-sort-c.html index 4f39cf2c..1cce3c59 100644 --- a/cov/cmdline/stream.c.func-sort-c.html +++ b/cov/cmdline/stream.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 27 @@ -61,23 +61,23 @@ swrite - 20724964 + 20725404 sgetb32 - 18667054 + 18667305 sread - 12810372 + 12810007 sgetb64 - 10849502 + 10849138 sputb32 - 9127337 + 9127777 sputb64 @@ -85,7 +85,7 @@ sgetbs - 3877163 + 3877064 sputbs @@ -93,11 +93,11 @@ sfill - 607122 + 607129 sgetc_uncached - 298855 + 298863 sflush @@ -105,31 +105,31 @@ sgettok - 8162 + 8196 sgetline - 5425 + 5448 sgetlasttok - 5384 + 5407 sclose - 1951 + 1953 sopen_read - 1836 + 1838 scrc - 1688 + 1689 sdeplete - 1144 + 1142 sopen_multi_file @@ -137,15 +137,15 @@ sgetble32 - 380 + 381 sgetu32 - 265 + 266 shandle - 253 + 254 scrc_stream diff --git a/cov/cmdline/stream.c.func.html b/cov/cmdline/stream.c.func.html index 4739e4bf..c096336a 100644 --- a/cov/cmdline/stream.c.func.html +++ b/cov/cmdline/stream.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 27 @@ -61,11 +61,11 @@ sclose - 1951 + 1953 scrc - 1688 + 1689 scrc_stream @@ -73,11 +73,11 @@ sdeplete - 1144 + 1142 sfill - 607122 + 607129 sflush @@ -85,43 +85,43 @@ sgetb32 - 18667054 + 18667305 sgetb64 - 10849502 + 10849138 sgetble32 - 380 + 381 sgetbs - 3877163 + 3877064 sgetc_uncached - 298855 + 298863 sgetlasttok - 5384 + 5407 sgetline - 5425 + 5448 sgettok - 8162 + 8196 sgetu32 - 265 + 266 shandle - 253 + 254 sopen_multi_file @@ -133,7 +133,7 @@ sopen_read - 1836 + 1838 sopen_write @@ -141,7 +141,7 @@ sputb32 - 9127337 + 9127777 sputb64 @@ -157,7 +157,7 @@ sread - 12810372 + 12810007 ssync @@ -169,7 +169,7 @@ swrite - 20724964 + 20725404
diff --git a/cov/cmdline/stream.c.gcov.html b/cov/cmdline/stream.c.gcov.html index bec8536c..8a1438fc 100644 --- a/cov/cmdline/stream.c.gcov.html +++ b/cov/cmdline/stream.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 27 @@ -88,19 +88,19 @@ 26 : 27 : unsigned STREAM_SIZE = 64 * 1024; 28 : - 29 1836 : STREAM* sopen_read(const char* file) + 29 1838 : STREAM* sopen_read(const char* file) 30 : { 31 : #if HAVE_POSIX_FADVISE 32 : int ret; 33 : #endif - 34 1836 : STREAM* s = malloc_nofail(sizeof(STREAM)); + 34 1838 : STREAM* s = malloc_nofail(sizeof(STREAM)); 35 : - 36 1836 : s->handle_size = 1; - 37 1836 : s->handle = malloc_nofail(sizeof(struct stream_handle)); + 36 1838 : s->handle_size = 1; + 37 1838 : s->handle = malloc_nofail(sizeof(struct stream_handle)); 38 : - 39 1836 : pathcpy(s->handle[0].path, sizeof(s->handle[0].path), file); - 40 1836 : s->handle[0].f = open(file, O_RDONLY | O_BINARY | O_SEQUENTIAL); - 41 1836 : if (s->handle[0].f == -1) { + 39 1838 : pathcpy(s->handle[0].path, sizeof(s->handle[0].path), file); + 40 1838 : s->handle[0].f = open(file, O_RDONLY | O_BINARY | O_SEQUENTIAL); + 41 1838 : if (s->handle[0].f == -1) { 42 50 : free(s->handle); 43 50 : free(s); 44 50 : return 0; @@ -108,13 +108,13 @@ 46 : 47 : #if HAVE_POSIX_FADVISE 48 : /* advise sequential access */ - 49 1786 : ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL); - 50 1786 : if (ret == ENOSYS) { + 49 1788 : ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL); + 50 1788 : if (ret == ENOSYS) { 51 0 : log_fatal("WARNING! fadvise() is not supported in this platform. Performance may not be optimal!\n"); 52 : /* call is not supported, like in armhf, see posix_fadvise manpage */ 53 0 : ret = 0; 54 : } - 55 1786 : if (ret != 0) { + 55 1788 : if (ret != 0) { 56 : /* LCOV_EXCL_START */ 57 : close(s->handle[0].f); 58 : free(s->handle); @@ -125,18 +125,18 @@ 63 : } 64 : #endif 65 : - 66 1786 : s->buffer = malloc_nofail_test(STREAM_SIZE); - 67 1786 : s->pos = s->buffer; - 68 1786 : s->end = s->buffer; - 69 1786 : s->state = STREAM_STATE_READ; - 70 1786 : s->state_index = 0; - 71 1786 : s->offset = 0; - 72 1786 : s->offset_uncached = 0; - 73 1786 : s->crc = 0; - 74 1786 : s->crc_uncached = 0; - 75 1786 : s->crc_stream = CRC_IV; + 66 1788 : s->buffer = malloc_nofail_test(STREAM_SIZE); + 67 1788 : s->pos = s->buffer; + 68 1788 : s->end = s->buffer; + 69 1788 : s->state = STREAM_STATE_READ; + 70 1788 : s->state_index = 0; + 71 1788 : s->offset = 0; + 72 1788 : s->offset_uncached = 0; + 73 1788 : s->crc = 0; + 74 1788 : s->crc_uncached = 0; + 75 1788 : s->crc_stream = CRC_IV; 76 : - 77 1786 : return s; + 77 1788 : return s; 78 : } 79 : 80 167 : STREAM* sopen_multi_write(unsigned count) @@ -214,12 +214,12 @@ 152 0 : return s; 153 : } 154 : - 155 1951 : int sclose(STREAM* s) + 155 1953 : int sclose(STREAM* s) 156 : { - 157 1951 : int fail = 0; + 157 1953 : int fail = 0; 158 : unsigned i; 159 : - 160 1951 : if (s->state == STREAM_STATE_WRITE) { + 160 1953 : if (s->state == STREAM_STATE_WRITE) { 161 167 : if (sflush(s) != 0) { 162 : /* LCOV_EXCL_START */ 163 : fail = 1; @@ -227,102 +227,102 @@ 165 : } 166 : } 167 : - 168 4875 : for (i = 0; i < s->handle_size; ++i) { - 169 2924 : if (close(s->handle[i].f) != 0) { + 168 4879 : for (i = 0; i < s->handle_size; ++i) { + 169 2926 : if (close(s->handle[i].f) != 0) { 170 : /* LCOV_EXCL_START */ 171 : fail = 1; 172 : /* LCOV_EXCL_STOP */ 173 : } 174 : } 175 : - 176 1951 : free(s->handle); - 177 1951 : free(s->buffer); - 178 1951 : free(s); + 176 1953 : free(s->handle); + 177 1953 : free(s->buffer); + 178 1953 : free(s); 179 : - 180 1951 : if (fail) { + 180 1953 : if (fail) { 181 : /* LCOV_EXCL_START */ 182 : return -1; 183 : /* LCOV_EXCL_STOP */ 184 : } 185 : - 186 1951 : return 0; + 186 1953 : return 0; 187 : } 188 : - 189 253 : int shandle(STREAM* s) + 189 254 : int shandle(STREAM* s) 190 : { - 191 253 : if (!s->handle_size) { + 191 254 : if (!s->handle_size) { 192 : /* LCOV_EXCL_START */ 193 : return -1; 194 : /* LCOV_EXCL_STOP */ 195 : } 196 : - 197 253 : return s->handle[0].f; + 197 254 : return s->handle[0].f; 198 : } 199 : 200 : /** 201 : * Fill the read stream buffer. 202 : * \return 0 if at least on char is read, or EOF on error. 203 : */ - 204 607122 : static int sfill(STREAM* s) + 204 607129 : static int sfill(STREAM* s) 205 : { 206 : ssize_t ret; 207 : - 208 607122 : if (s->state != STREAM_STATE_READ) { + 208 607129 : if (s->state != STREAM_STATE_READ) { 209 : /* LCOV_EXCL_START */ 210 : return EOF; 211 : /* LCOV_EXCL_STOP */ 212 : } 213 : - 214 606066 : ret = read(s->handle[0].f, s->buffer, STREAM_SIZE); + 214 606069 : ret = read(s->handle[0].f, s->buffer, STREAM_SIZE); 215 : - 216 606066 : if (ret < 0) { + 216 606069 : if (ret < 0) { 217 : /* LCOV_EXCL_START */ 218 : s->state = STREAM_STATE_ERROR; 219 : return EOF; 220 : /* LCOV_EXCL_STOP */ 221 : } - 222 606066 : if (ret == 0) { - 223 1657 : s->state = STREAM_STATE_EOF; - 224 1657 : return EOF; + 222 606069 : if (ret == 0) { + 223 1659 : s->state = STREAM_STATE_EOF; + 224 1659 : return EOF; 225 : } 226 : 227 : /* update the crc */ - 228 604409 : s->crc_uncached = s->crc; - 229 604409 : s->crc = crc32c(s->crc, s->buffer, ret); + 228 604410 : s->crc_uncached = s->crc; + 229 604410 : s->crc = crc32c(s->crc, s->buffer, ret); 230 : 231 : /* update the offset */ - 232 604407 : s->offset_uncached = s->offset; - 233 604407 : s->offset += ret; + 232 604409 : s->offset_uncached = s->offset; + 233 604409 : s->offset += ret; 234 : - 235 604407 : s->pos = s->buffer; - 236 604407 : s->end = s->buffer + ret; + 235 604409 : s->pos = s->buffer; + 236 604409 : s->end = s->buffer + ret; 237 : - 238 604407 : return 0; + 238 604409 : return 0; 239 : } 240 : - 241 1144 : int sdeplete(STREAM* s, unsigned char* last) + 241 1142 : int sdeplete(STREAM* s, unsigned char* last) 242 : { 243 : /* last four bytes */ - 244 1144 : last[0] = 0; - 245 1144 : last[1] = 0; - 246 1144 : last[2] = 0; - 247 1144 : last[3] = 0; + 244 1142 : last[0] = 0; + 245 1142 : last[1] = 0; + 246 1142 : last[2] = 0; + 247 1142 : last[3] = 0; 248 : 249 : while (1) { 250 : /* increase the position up to 4 bytes before the end */ - 251 308267 : if (s->pos + 4 <= s->end) - 252 148388 : s->pos = s->end - 4; + 251 308266 : if (s->pos + 4 <= s->end) + 252 148389 : s->pos = s->end - 4; 253 : 254 : /* insert the last 4 bytes */ - 255 1469851 : while (s->pos < s->end) { - 256 853317 : last[0] = last[1]; - 257 853317 : last[1] = last[2]; - 258 853317 : last[2] = last[3]; - 259 853317 : last[3] = *s->pos++; + 255 1469855 : while (s->pos < s->end) { + 256 853323 : last[0] = last[1]; + 257 853323 : last[1] = last[2]; + 258 853323 : last[2] = last[3]; + 259 853323 : last[3] = *s->pos++; 260 : } 261 : 262 : /* fill again the buffer until the end of the file */ - 263 308267 : if (sfill(s) != 0) { + 263 308266 : if (sfill(s) != 0) { 264 : /* on error fail */ 265 1141 : if (serror(s)) { 266 : /* LCOV_EXCL_START */ @@ -331,11 +331,11 @@ 269 : } 270 : 271 : /* on EOF terminate */ - 272 1140 : break; + 272 1141 : break; 273 : } - 274 307123 : } + 274 307124 : } 275 : - 276 1140 : return 0; + 276 1141 : return 0; 277 : } 278 : 279 39049 : int sflush(STREAM* s) @@ -390,9 +390,9 @@ 328 1 : return s->offset_uncached + (s->pos - s->buffer); 329 : } 330 : - 331 1688 : uint32_t scrc(STREAM*s) + 331 1689 : uint32_t scrc(STREAM*s) 332 : { - 333 1688 : return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer); + 333 1689 : return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer); 334 : } 335 : 336 167 : uint32_t scrc_stream(STREAM*s) @@ -400,90 +400,90 @@ 338 167 : return s->crc_stream ^ CRC_IV; 339 : } 340 : - 341 298855 : int sgetc_uncached(STREAM* s) + 341 298863 : int sgetc_uncached(STREAM* s) 342 : { 343 : /* if at the end of the buffer, fill it */ - 344 298855 : if (s->pos == s->end && sfill(s) != 0) - 345 1572 : return EOF; - 346 297283 : return *s->pos++; + 344 298863 : if (s->pos == s->end && sfill(s) != 0) + 345 1578 : return EOF; + 346 297285 : return *s->pos++; 347 : } 348 : - 349 8162 : int sgettok(STREAM* f, char* str, int size) + 349 8196 : int sgettok(STREAM* f, char* str, int size) 350 : { - 351 8162 : char* i = str; - 352 8162 : char* send = str + size; + 351 8196 : char* i = str; + 352 8196 : char* send = str + size; 353 : int c; 354 : 355 : while (1) { - 356 54379 : c = sgetc(f); - 357 54379 : if (c == EOF) { - 358 264 : break; + 356 54612 : c = sgetc(f); + 357 54612 : if (c == EOF) { + 358 265 : break; 359 : } - 360 54115 : if (c == ' ' || c == '\t') { - 361 7633 : sungetc(c, f); - 362 7633 : break; + 360 54347 : if (c == ' ' || c == '\t') { + 361 7665 : sungetc(c, f); + 362 7665 : break; 363 : } - 364 46482 : if (c == '\n') { + 364 46682 : if (c == '\n') { 365 : /* remove ending carrige return to support the Windows CR+LF format */ - 366 265 : if (i != str && i[-1] == '\r') + 366 266 : if (i != str && i[-1] == '\r') 367 0 : --i; - 368 265 : sungetc(c, f); - 369 265 : break; + 368 266 : sungetc(c, f); + 369 266 : break; 370 : } 371 : - 372 46217 : *i++ = c; + 372 46416 : *i++ = c; 373 : - 374 46217 : if (i == send) { + 374 46416 : if (i == send) { 375 : /* LCOV_EXCL_START */ 376 : return -1; 377 : /* LCOV_EXCL_STOP */ 378 : } - 379 46217 : } + 379 46416 : } 380 : - 381 8162 : *i = 0; + 381 8196 : *i = 0; 382 : - 383 8162 : return i - str; + 383 8196 : return i - str; 384 : } 385 : - 386 12810372 : int sread(STREAM* f, void* void_data, unsigned size) + 386 12810007 : int sread(STREAM* f, void* void_data, unsigned size) 387 : { - 388 12810372 : unsigned char* data = void_data; + 388 12810007 : unsigned char* data = void_data; 389 : 390 : /* if there is enough space in memory */ - 391 12810372 : if (sptrlookup(f, size)) { + 391 12810007 : if (sptrlookup(f, size)) { 392 : /* optimized version with all the data in memory */ - 393 12784238 : unsigned char* pos = sptrget(f); + 393 12783678 : unsigned char* pos = sptrget(f); 394 : 395 : /* copy it */ - 396 217725604 : while (size--) - 397 192157128 : *data++ = *pos++; + 396 217717015 : while (size--) + 397 192149659 : *data++ = *pos++; 398 : - 399 12784238 : sptrset(f, pos); + 399 12783678 : sptrset(f, pos); 400 : } else { 401 : /* standard version using sgetc() */ - 402 1375577 : while (size--) { - 403 1323309 : int c = sgetc(f); - 404 1323309 : if (c == EOF) { + 402 1378240 : while (size--) { + 403 1325582 : int c = sgetc(f); + 404 1325582 : if (c == EOF) { 405 : /* LCOV_EXCL_START */ 406 : return -1; 407 : /* LCOV_EXCL_STOP */ 408 : } 409 : - 410 1323309 : *data++ = c; + 410 1325582 : *data++ = c; 411 : } 412 : } 413 : - 414 12810372 : return 0; + 414 12810007 : return 0; 415 : } 416 : - 417 5425 : int sgetline(STREAM* f, char* str, int size) + 417 5448 : int sgetline(STREAM* f, char* str, int size) 418 : { - 419 5425 : char* i = str; - 420 5425 : char* send = str + size; + 419 5448 : char* i = str; + 420 5448 : char* send = str + size; 421 : int c; 422 : 423 : /* if there is enough data in memory */ - 424 5425 : if (sptrlookup(f, size)) { + 424 5448 : if (sptrlookup(f, size)) { 425 : /* optimized version with all the data in memory */ 426 0 : unsigned char* pos = sptrget(f); 427 : @@ -509,75 +509,75 @@ 447 0 : sptrset(f, pos); 448 : } else { 449 : while (1) { - 450 139326 : c = sgetc(f); - 451 139326 : if (c == EOF) { + 450 139951 : c = sgetc(f); + 451 139951 : if (c == EOF) { 452 : /* LCOV_EXCL_START */ 453 : break; 454 : /* LCOV_EXCL_STOP */ 455 : } - 456 139326 : if (c == '\n') { + 456 139951 : if (c == '\n') { 457 : /* remove ending carrige return to support the Windows CR+LF format */ - 458 5425 : if (i != str && i[-1] == '\r') + 458 5448 : if (i != str && i[-1] == '\r') 459 0 : --i; - 460 5425 : sungetc(c, f); - 461 5425 : break; + 460 5448 : sungetc(c, f); + 461 5448 : break; 462 : } 463 : - 464 133901 : *i++ = c; + 464 134503 : *i++ = c; 465 : - 466 133901 : if (i == send) { + 466 134503 : if (i == send) { 467 : /* LCOV_EXCL_START */ 468 : return -1; 469 : /* LCOV_EXCL_STOP */ 470 : } - 471 133901 : } + 471 134503 : } 472 : } 473 : - 474 5425 : *i = 0; + 474 5448 : *i = 0; 475 : - 476 5425 : return i - str; + 476 5448 : return i - str; 477 : } 478 : - 479 5384 : int sgetlasttok(STREAM* f, char* str, int size) + 479 5407 : int sgetlasttok(STREAM* f, char* str, int size) 480 : { 481 : int ret; 482 : - 483 5384 : ret = sgetline(f, str, size); - 484 5384 : if (ret < 0) { + 483 5407 : ret = sgetline(f, str, size); + 484 5407 : if (ret < 0) { 485 : /* LCOV_EXCL_START */ 486 : return ret; 487 : /* LCOV_EXCL_STOP */ 488 : } 489 : - 490 10768 : while (ret > 0 && (str[ret - 1] == ' ' || str[ret - 1] == '\t')) + 490 10814 : while (ret > 0 && (str[ret - 1] == ' ' || str[ret - 1] == '\t')) 491 0 : --ret; 492 : - 493 5384 : str[ret] = 0; + 493 5407 : str[ret] = 0; 494 : - 495 5384 : return ret; + 495 5407 : return ret; 496 : } 497 : - 498 265 : int sgetu32(STREAM* f, uint32_t* value) + 498 266 : int sgetu32(STREAM* f, uint32_t* value) 499 : { 500 : int c; 501 : - 502 265 : c = sgetc(f); - 503 265 : if (c >= '0' && c <= '9') { + 502 266 : c = sgetc(f); + 503 266 : if (c >= '0' && c <= '9') { 504 : uint32_t v; 505 : - 506 265 : v = c - '0'; + 506 266 : v = c - '0'; 507 : - 508 265 : c = sgetc(f); - 509 530 : while (c >= '0' && c <= '9') { + 508 266 : c = sgetc(f); + 509 532 : while (c >= '0' && c <= '9') { 510 0 : v *= 10; 511 0 : v += c - '0'; 512 0 : c = sgetc(f); 513 : } 514 : - 515 265 : *value = v; + 515 266 : *value = v; 516 : - 517 265 : sungetc(c, f); - 518 265 : return 0; + 517 266 : sungetc(c, f); + 518 266 : return 0; 519 : } else { 520 : /* LCOV_EXCL_START */ 521 : /* nothing read */ @@ -586,122 +586,122 @@ 524 : } 525 : } 526 : - 527 18667054 : int sgetb32(STREAM* f, uint32_t* value) + 527 18667305 : int sgetb32(STREAM* f, uint32_t* value) 528 : { 529 : uint32_t v; 530 : unsigned char b; 531 : unsigned char s; 532 : int c; 533 : - 534 18667054 : v = 0; - 535 18667054 : s = 0; + 534 18667305 : v = 0; + 535 18667305 : s = 0; 536 : loop: - 537 35516819 : c = sgetc(f); - 538 35516819 : if (c == EOF) { + 537 36513909 : c = sgetc(f); + 538 36513909 : if (c == EOF) { 539 : /* LCOV_EXCL_START */ 540 : return -1; 541 : /* LCOV_EXCL_STOP */ 542 : } 543 : - 544 35516819 : b = (unsigned char)c; - 545 35516819 : if ((b & 0x80) == 0) { - 546 16849766 : v |= (uint32_t)b << s; - 547 16849766 : s += 7; - 548 16849766 : if (s >= 32) { + 544 36513909 : b = (unsigned char)c; + 545 36513909 : if ((b & 0x80) == 0) { + 546 17846604 : v |= (uint32_t)b << s; + 547 17846604 : s += 7; + 548 17846604 : if (s >= 32) { 549 : /* LCOV_EXCL_START */ 550 : return -1; 551 : /* LCOV_EXCL_STOP */ 552 : } - 553 16849765 : goto loop; + 553 17846604 : goto loop; 554 : } 555 : - 556 18667053 : v |= (uint32_t)(b & 0x7f) << s; + 556 18667305 : v |= (uint32_t)(b & 0x7f) << s; 557 : - 558 18667053 : *value = v; + 558 18667305 : *value = v; 559 : - 560 18667053 : return 0; + 560 18667305 : return 0; 561 : } 562 : - 563 10849502 : int sgetb64(STREAM* f, uint64_t* value) + 563 10849138 : int sgetb64(STREAM* f, uint64_t* value) 564 : { 565 : uint64_t v; 566 : unsigned char b; 567 : unsigned char s; 568 : int c; 569 : - 570 10849502 : v = 0; - 571 10849502 : s = 0; + 570 10849138 : v = 0; + 571 10849138 : s = 0; 572 : loop: - 573 39666625 : c = sgetc(f); - 574 39666625 : if (c == EOF) { + 573 39665269 : c = sgetc(f); + 574 39665269 : if (c == EOF) { 575 : /* LCOV_EXCL_START */ 576 : return -1; 577 : /* LCOV_EXCL_STOP */ 578 : } 579 : - 580 39666625 : b = (unsigned char)c; - 581 39666625 : if ((b & 0x80) == 0) { - 582 28817123 : v |= (uint64_t)b << s; - 583 28817123 : s += 7; - 584 28817123 : if (s >= 64) { + 580 39665269 : b = (unsigned char)c; + 581 39665269 : if ((b & 0x80) == 0) { + 582 28816131 : v |= (uint64_t)b << s; + 583 28816131 : s += 7; + 584 28816131 : if (s >= 64) { 585 : /* LCOV_EXCL_START */ 586 : return -1; 587 : /* LCOV_EXCL_STOP */ 588 : } - 589 28817123 : goto loop; + 589 28816131 : goto loop; 590 : } 591 : - 592 10849502 : v |= (uint64_t)(b & 0x7f) << s; + 592 10849138 : v |= (uint64_t)(b & 0x7f) << s; 593 : - 594 10849502 : *value = v; + 594 10849138 : *value = v; 595 : - 596 10849502 : return 0; + 596 10849138 : return 0; 597 : } 598 : - 599 380 : int sgetble32(STREAM* f, uint32_t* value) + 599 381 : int sgetble32(STREAM* f, uint32_t* value) 600 : { 601 : unsigned char buf[4]; 602 : - 603 380 : if (sread(f, buf, 4) != 0) { + 603 381 : if (sread(f, buf, 4) != 0) { 604 : /* LCOV_EXCL_START */ 605 : return -1; 606 : /* LCOV_EXCL_STOP */ 607 : } 608 : - 609 380 : *value = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; + 609 381 : *value = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; 610 : - 611 380 : return 0; + 611 381 : return 0; 612 : } 613 : - 614 3877163 : int sgetbs(STREAM* f, char* str, int size) + 614 3877064 : int sgetbs(STREAM* f, char* str, int size) 615 : { 616 : uint32_t len; 617 : - 618 3877163 : if (sgetb32(f, &len) < 0) { + 618 3877064 : if (sgetb32(f, &len) < 0) { 619 : /* LCOV_EXCL_START */ 620 : return -1; 621 : /* LCOV_EXCL_STOP */ 622 : } 623 : - 624 3877162 : if (len + 1 > (uint32_t)size) { + 624 3877064 : if (len + 1 > (uint32_t)size) { 625 : /* LCOV_EXCL_START */ 626 : return -1; 627 : /* LCOV_EXCL_STOP */ 628 : } 629 : - 630 3877162 : str[len] = 0; + 630 3877064 : str[len] = 0; 631 : - 632 3877162 : return sread(f, str, (int)len); + 632 3877064 : return sread(f, str, (int)len); 633 : } 634 : - 635 20724964 : int swrite(const void* void_data, unsigned size, STREAM* f) + 635 20725404 : int swrite(const void* void_data, unsigned size, STREAM* f) 636 : { - 637 20724964 : const unsigned char* data = void_data; + 637 20725404 : const unsigned char* data = void_data; 638 : 639 : /* if there is enough space in memory */ - 640 20724964 : if (sptrlookup(f, size)) { + 640 20725404 : if (sptrlookup(f, size)) { 641 : /* optimized version with all the data in memory */ - 642 20718802 : unsigned char* pos = sptrget(f); + 642 20719227 : unsigned char* pos = sptrget(f); 643 : 644 : /** 645 : * Update the crc *before* writing the data in the buffer @@ -710,17 +710,17 @@ 648 : * to be able to detect memory errors on the buffer, 649 : * happening before we write it on the file. 650 : */ - 651 20718802 : f->crc_stream = crc32c_plain(f->crc_stream, data, size); + 651 20719227 : f->crc_stream = crc32c_plain(f->crc_stream, data, size); 652 : 653 : /* copy it */ - 654 172634823 : while (size--) - 655 131197219 : *pos++ = *data++; + 654 173052917 : while (size--) + 655 131614463 : *pos++ = *data++; 656 : - 657 20718802 : sptrset(f, pos); + 657 20719227 : sptrset(f, pos); 658 : } else { 659 : /* standard version using sputc() */ - 660 201254 : while (size--) { - 661 188930 : if (sputc(*data++, f) != 0) { + 660 201663 : while (size--) { + 661 189309 : if (sputc(*data++, f) != 0) { 662 : /* LCOV_EXCL_START */ 663 : return -1; 664 : /* LCOV_EXCL_STOP */ @@ -728,28 +728,28 @@ 666 : } 667 : } 668 : - 669 20724964 : return 0; + 669 20725404 : return 0; 670 : } 671 : - 672 9127337 : int sputb32(uint32_t value, STREAM* s) + 672 9127777 : int sputb32(uint32_t value, STREAM* s) 673 : { 674 : unsigned char b; 675 : unsigned char buf[16]; 676 : unsigned i; 677 : - 678 9127337 : i = 0; + 678 9127777 : i = 0; 679 : loop: - 680 17477413 : b = value & 0x7f; - 681 17477413 : value >>= 7; + 680 17895036 : b = value & 0x7f; + 681 17895036 : value >>= 7; 682 : - 683 17477413 : if (value) { - 684 8350076 : buf[i++] = b; - 685 8350076 : goto loop; + 683 17895036 : if (value) { + 684 8767259 : buf[i++] = b; + 685 8767259 : goto loop; 686 : } 687 : - 688 9127337 : buf[i++] = b | 0x80; + 688 9127777 : buf[i++] = b | 0x80; 689 : - 690 9127337 : return swrite(buf, i, s); + 690 9127777 : return swrite(buf, i, s); 691 : } 692 : 693 5317120 : int sputb64(uint64_t value, STREAM* s) diff --git a/cov/cmdline/stream.h.func-sort-c.html b/cov/cmdline/stream.h.func-sort-c.html index 48c4ad62..5cdb940a 100644 --- a/cov/cmdline/stream.h.func-sort-c.html +++ b/cov/cmdline/stream.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 10 @@ -61,39 +61,39 @@ sgetc - 84138438 + 85137242 sptrlookup - 33540761 + 33540859 sptrset - 33503040 + 33502905 sptrget - 33503040 + 33502905 sputc - 3808025 + 3808426 serror - 3635393 + 3635550 sungetc - 34440 + 34584 sgetspace - 20599 + 20685 sgeteol - 6218 + 6244 seof diff --git a/cov/cmdline/stream.h.func.html b/cov/cmdline/stream.h.func.html index fe9477a4..73c97b0d 100644 --- a/cov/cmdline/stream.h.func.html +++ b/cov/cmdline/stream.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 10 @@ -65,7 +65,7 @@ serror - 3635393 + 3635550 serrorfile @@ -73,35 +73,35 @@ sgetc - 84138438 + 85137242 sgeteol - 6218 + 6244 sgetspace - 20599 + 20685 sptrget - 33503040 + 33502905 sptrlookup - 33540761 + 33540859 sptrset - 33503040 + 33502905 sputc - 3808025 + 3808426 sungetc - 34440 + 34584
diff --git a/cov/cmdline/stream.h.gcov.html b/cov/cmdline/stream.h.gcov.html index ecdcc42c..0d7947f7 100644 --- a/cov/cmdline/stream.h.gcov.html +++ b/cov/cmdline/stream.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 10 @@ -221,33 +221,33 @@ 159 : /** 160 : * Check if the buffer has enough data loaded. 161 : */ - 162 33540761 : static inline int sptrlookup(STREAM* s, int size) + 162 33540859 : static inline int sptrlookup(STREAM* s, int size) 163 : { - 164 33540761 : return s->pos + size <= s->end; + 164 33540859 : return s->pos + size <= s->end; 165 : } 166 : 167 : /** 168 : * Get the current stream ptr. 169 : */ - 170 33503040 : static inline unsigned char* sptrget(STREAM* s) + 170 33502905 : static inline unsigned char* sptrget(STREAM* s) 171 : { - 172 33503040 : return s->pos; + 172 33502905 : return s->pos; 173 : } 174 : 175 : /** 176 : * Set the current stream ptr. 177 : */ - 178 33503040 : static inline void sptrset(STREAM* s, unsigned char* ptr) + 178 33502905 : static inline void sptrset(STREAM* s, unsigned char* ptr) 179 : { - 180 33503040 : s->pos = ptr; - 181 33503040 : } + 180 33502905 : s->pos = ptr; + 181 33502905 : } 182 : 183 : /** 184 : * Check the error status. Like ferror(). 185 : */ - 186 3635393 : static inline int serror(STREAM* s) + 186 3635550 : static inline int serror(STREAM* s) 187 : { - 188 3635393 : return s->state == STREAM_STATE_ERROR; + 188 3635550 : return s->state == STREAM_STATE_ERROR; 189 : } 190 : 191 : /** @@ -291,22 +291,22 @@ 229 : /** 230 : * Read a char. Like fgetc(). 231 : */ - 232 84138438 : static inline int sgetc(STREAM* s) + 232 85137242 : static inline int sgetc(STREAM* s) 233 : { - 234 84138438 : if (tommy_unlikely(s->pos == s->end)) - 235 298855 : return sgetc_uncached(s); - 236 83839583 : return *s->pos++; + 234 85137242 : if (tommy_unlikely(s->pos == s->end)) + 235 298863 : return sgetc_uncached(s); + 236 84838379 : return *s->pos++; 237 : } 238 : 239 : /** 240 : * Unread a char. 241 : * Like ungetc() but you have to unget the same char read. 242 : */ - 243 34440 : static inline void sungetc(int c, STREAM* s) + 243 34584 : static inline void sungetc(int c, STREAM* s) 244 : { - 245 34440 : if (c != EOF) - 246 33648 : --s->pos; - 247 34440 : } + 245 34584 : if (c != EOF) + 246 33789 : --s->pos; + 247 34584 : } 248 : 249 : /** 250 : * Read a fixed amount of chars. @@ -317,34 +317,34 @@ 255 : /** 256 : * Get a char from a stream, ignoring one '\r'. 257 : */ - 258 6218 : static inline int sgeteol(STREAM* f) + 258 6244 : static inline int sgeteol(STREAM* f) 259 : { 260 : int c; 261 : - 262 6218 : c = sgetc(f); - 263 6218 : if (c == '\r') + 262 6244 : c = sgetc(f); + 263 6244 : if (c == '\r') 264 0 : c = sgetc(f); 265 : - 266 6218 : return c; + 266 6244 : return c; 267 : } 268 : 269 : /** 270 : * Read all the spaces and tabs. 271 : * Return the number of spaces and tabs read. 272 : */ - 273 20599 : static inline int sgetspace(STREAM* f) + 273 20685 : static inline int sgetspace(STREAM* f) 274 : { - 275 20599 : int count = 0; + 275 20685 : int count = 0; 276 : int c; 277 : - 278 20599 : c = sgetc(f); - 279 48831 : while (c == ' ' || c == '\t') { - 280 7633 : ++count; - 281 7633 : c = sgetc(f); + 278 20685 : c = sgetc(f); + 279 49035 : while (c == ' ' || c == '\t') { + 280 7665 : ++count; + 281 7665 : c = sgetc(f); 282 : } 283 : - 284 20599 : sungetc(c, f); - 285 20599 : return count; + 284 20685 : sungetc(c, f); + 285 20685 : return count; 286 : } 287 : 288 : /** @@ -407,9 +407,9 @@ 345 : * Write a char. Like fputc(). 346 : * Return 0 on success or -1 on error. 347 : */ - 348 3808025 : static inline int sputc(int c, STREAM* s) + 348 3808426 : static inline int sputc(int c, STREAM* s) 349 : { - 350 3808025 : if (s->pos == s->end) { + 350 3808426 : if (s->pos == s->end) { 351 38580 : if (sflush(s) != 0) 352 0 : return -1; 353 : } @@ -421,11 +421,11 @@ 359 : * to be able to detect memory errors on the buffer, 360 : * happening before we write it on the file. 361 : */ - 362 3808025 : s->crc_stream = crc32c_plain_char(s->crc_stream, c); + 362 3808426 : s->crc_stream = crc32c_plain_char(s->crc_stream, c); 363 : - 364 3808025 : *s->pos++ = c; + 364 3808426 : *s->pos++ = c; 365 : - 366 3808025 : return 0; + 366 3808426 : return 0; 367 : } 368 : 369 : /** diff --git a/cov/cmdline/support.c.func-sort-c.html b/cov/cmdline/support.c.func-sort-c.html index a64cfac2..cf4f03cd 100644 --- a/cov/cmdline/support.c.func-sort-c.html +++ b/cov/cmdline/support.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 60 @@ -61,123 +61,123 @@ thread_mutex_unlock - 80862235 + 80858701 thread_mutex_lock - 80858327 + 80857668 pathcmp - 51889998 + 51890261 pathprint - 51564205 + 51564160 unlock_memory - 20174230 + 20173887 lock_memory - 20174230 + 20173887 malloc_counter_inc - 20173756 + 20173411 malloc_nofail - 14364226 + 14363921 advise_read - 8903872 + 8903631 pathcpy - 7892425 + 7892123 strdup_nofail - 5799477 + 5799401 lock_msg - 3887429 + 3887334 unlock_msg - 3887429 + 3887334 log_tag - 2907978 + 2907727 advise_flags - 2495042 + 2494965 advise_init - 2494967 + 2494910 esc_tag - 2428739 + 2428312 advise_open - 2416234 + 2416366 thread_cond_wait - 1095059 + 1037153 advise_write - 900676 + 900358 mkancestor - 793090 + 793073 log_error - 536045 + 536048 esc_shell_multi - 356083 + 355914 msg_info - 295858 + 295689 thread_cond_broadcast - 255625 + 255503 thread_cond_broadcast_and_unlock - 255435 + 255313 msg_verbose - 126963 + 126943 fmtime - 119641 + 119580 thread_cond_signal - 83165 + 85887 thread_cond_signal_and_unlock - 83165 + 85887 pathexport @@ -185,7 +185,7 @@ pathimport - 16519 + 16572 log_expected @@ -193,19 +193,19 @@ calloc_nofail - 10053 + 10089 pathslash - 7699 + 7705 msg_progress - 4447 + 4449 thread_mutex_init - 2276 + 2284 thread_create @@ -217,19 +217,19 @@ thread_mutex_destroy - 2074 + 2082 msg_bar - 1678 + 1958 strsplit - 1466 + 1472 log_flush - 1196 + 1200 log_fatal @@ -239,17 +239,17 @@ pathcatc 788 + + msg_flush + 627 + msg_status 625 - - msg_flush - 571 - malloc_counter_get - 474 + 476 thread_cond_init @@ -261,24 +261,24 @@ lock_init - 298 + 299 pathcat - 266 + 267 lock_done - 263 + 264 + + + printc + 106 pathcut 100 - - printc - 64 - printl 52 @@ -288,12 +288,12 @@ 43 - printp - 18 + printr + 34 - printr - 16 + printp + 18 smartctl_flush diff --git a/cov/cmdline/support.c.func.html b/cov/cmdline/support.c.func.html index d22e86c9..883dd715 100644 --- a/cov/cmdline/support.c.func.html +++ b/cov/cmdline/support.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 60 @@ -61,59 +61,59 @@ advise_flags - 2495042 + 2494965 advise_init - 2494967 + 2494910 advise_open - 2416234 + 2416366 advise_read - 8903872 + 8903631 advise_write - 900676 + 900358 calloc_nofail - 10053 + 10089 esc_shell_multi - 356083 + 355914 esc_tag - 2428739 + 2428312 fmtime - 119641 + 119580 lock_done - 263 + 264 lock_init - 298 + 299 lock_memory - 20174230 + 20173887 lock_msg - 3887429 + 3887334 log_error - 536045 + 536048 log_expected @@ -125,43 +125,43 @@ log_flush - 1196 + 1200 log_tag - 2907978 + 2907727 malloc_counter_get - 474 + 476 malloc_counter_inc - 20173756 + 20173411 malloc_nofail - 14364226 + 14363921 mkancestor - 793090 + 793073 msg_bar - 1678 + 1958 msg_flush - 571 + 627 msg_info - 295858 + 295689 msg_progress - 4447 + 4449 msg_status @@ -169,11 +169,11 @@ msg_verbose - 126963 + 126943 pathcat - 266 + 267 pathcatc @@ -181,11 +181,11 @@ pathcmp - 51889998 + 51890261 pathcpy - 7892425 + 7892123 pathcut @@ -197,19 +197,19 @@ pathimport - 16519 + 16572 pathprint - 51564205 + 51564160 pathslash - 7699 + 7705 printc - 64 + 106 printl @@ -221,7 +221,7 @@ printr - 16 + 34 smartctl_attribute @@ -237,7 +237,7 @@ strdup_nofail - 5799477 + 5799401 strpolish @@ -245,15 +245,15 @@ strsplit - 1466 + 1472 thread_cond_broadcast - 255625 + 255503 thread_cond_broadcast_and_unlock - 255435 + 255313 thread_cond_destroy @@ -265,15 +265,15 @@ thread_cond_signal - 83165 + 85887 thread_cond_signal_and_unlock - 83165 + 85887 thread_cond_wait - 1095059 + 1037153 thread_create @@ -285,27 +285,27 @@ thread_mutex_destroy - 2074 + 2082 thread_mutex_init - 2276 + 2284 thread_mutex_lock - 80858327 + 80857668 thread_mutex_unlock - 80862235 + 80858701 unlock_memory - 20174230 + 20173887 unlock_msg - 3887429 + 3887334
diff --git a/cov/cmdline/support.c.gcov.html b/cov/cmdline/support.c.gcov.html index 96cd8100..d72968c8 100644 --- a/cov/cmdline/support.c.gcov.html +++ b/cov/cmdline/support.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 60 @@ -92,50 +92,50 @@ 30 : static pthread_mutex_t memory_lock; 31 : #endif 32 : - 33 3887429 : void lock_msg(void) + 33 3887334 : void lock_msg(void) 34 : { 35 : #if HAVE_PTHREAD - 36 3887429 : thread_mutex_lock(&msg_lock); + 36 3887334 : thread_mutex_lock(&msg_lock); 37 : #endif - 38 3887429 : } + 38 3887334 : } 39 : - 40 3887429 : void unlock_msg(void) + 40 3887334 : void unlock_msg(void) 41 : { 42 : #if HAVE_PTHREAD - 43 3887429 : thread_mutex_unlock(&msg_lock); + 43 3887334 : thread_mutex_unlock(&msg_lock); 44 : #endif - 45 3887429 : } + 45 3887334 : } 46 : - 47 20174230 : void lock_memory(void) + 47 20173887 : void lock_memory(void) 48 : { 49 : #if HAVE_PTHREAD - 50 20174230 : thread_mutex_lock(&memory_lock); + 50 20173887 : thread_mutex_lock(&memory_lock); 51 : #endif - 52 20174230 : } + 52 20173887 : } 53 : - 54 20174230 : void unlock_memory(void) + 54 20173887 : void unlock_memory(void) 55 : { 56 : #if HAVE_PTHREAD - 57 20174230 : thread_mutex_unlock(&memory_lock); + 57 20173887 : thread_mutex_unlock(&memory_lock); 58 : #endif - 59 20174230 : } + 59 20173887 : } 60 : - 61 298 : void lock_init(void) + 61 299 : void lock_init(void) 62 : { 63 : #if HAVE_PTHREAD 64 : /* initialize the locks as first operation as log_fatal depends on them */ - 65 298 : thread_mutex_init(&msg_lock, 0); - 66 298 : thread_mutex_init(&memory_lock, 0); + 65 299 : thread_mutex_init(&msg_lock, 0); + 66 299 : thread_mutex_init(&memory_lock, 0); 67 : #endif - 68 298 : } + 68 299 : } 69 : - 70 263 : void lock_done(void) + 70 264 : void lock_done(void) 71 : { 72 : #if HAVE_PTHREAD - 73 263 : thread_mutex_destroy(&msg_lock); - 74 263 : thread_mutex_destroy(&memory_lock); + 73 264 : thread_mutex_destroy(&msg_lock); + 74 264 : thread_mutex_destroy(&memory_lock); 75 : #endif - 76 263 : } + 76 264 : } 77 : 78 : /****************************************************************************/ 79 : /* print */ @@ -176,18 +176,18 @@ 114 809 : unlock_msg(); 115 809 : } 116 : - 117 536045 : void log_error(const char* format, ...) + 117 536048 : void log_error(const char* format, ...) 118 : { 119 : va_list ap; 120 : - 121 536045 : lock_msg(); + 121 536048 : lock_msg(); 122 : - 123 536045 : if (stdlog) { - 124 534165 : va_start(ap, format); - 125 534165 : fprintf(stdlog, "msg:error: "); - 126 534165 : vfprintf(stdlog, format, ap); - 127 534165 : fflush(stdlog); - 128 534165 : va_end(ap); + 123 536048 : if (stdlog) { + 124 534168 : va_start(ap, format); + 125 534168 : fprintf(stdlog, "msg:error: "); + 126 534168 : vfprintf(stdlog, format, ap); + 127 534168 : fflush(stdlog); + 128 534168 : va_end(ap); 129 : } else { 130 1880 : va_start(ap, format); 131 1880 : vfprintf(stderr, format, ap); @@ -195,8 +195,8 @@ 133 1880 : va_end(ap); 134 : } 135 : - 136 536045 : unlock_msg(); - 137 536045 : } + 136 536048 : unlock_msg(); + 137 536048 : } 138 : 139 11259 : void log_expected(const char* format, ...) 140 : { @@ -215,34 +215,34 @@ 153 11259 : unlock_msg(); 154 11259 : } 155 : - 156 2907978 : void log_tag(const char* format, ...) + 156 2907727 : void log_tag(const char* format, ...) 157 : { 158 : va_list ap; 159 : - 160 2907978 : lock_msg(); + 160 2907727 : lock_msg(); 161 : - 162 2907978 : if (stdlog) { - 163 2572493 : va_start(ap, format); - 164 2572493 : vfprintf(stdlog, format, ap); + 162 2907727 : if (stdlog) { + 163 2571717 : va_start(ap, format); + 164 2571717 : vfprintf(stdlog, format, ap); 165 : /* here we intentionally don't flush */ 166 : /* to make the output faster */ - 167 2572493 : va_end(ap); + 167 2571717 : va_end(ap); 168 : } 169 : - 170 2907978 : unlock_msg(); - 171 2907978 : } + 170 2907727 : unlock_msg(); + 171 2907727 : } 172 : - 173 1196 : void log_flush(void) + 173 1200 : void log_flush(void) 174 : { - 175 1196 : lock_msg(); + 175 1200 : lock_msg(); 176 : - 177 1196 : if (stdlog) + 177 1200 : if (stdlog) 178 339 : fflush(stdlog); - 179 1196 : fflush(stdout); - 180 1196 : fflush(stderr); + 179 1200 : fflush(stdout); + 180 1200 : fflush(stderr); 181 : - 182 1196 : unlock_msg(); - 183 1196 : } + 182 1200 : unlock_msg(); + 183 1200 : } 184 : 185 625 : void msg_status(const char* format, ...) 186 : { @@ -268,32 +268,32 @@ 206 625 : unlock_msg(); 207 625 : } 208 : - 209 295858 : void msg_info(const char* format, ...) + 209 295689 : void msg_info(const char* format, ...) 210 : { 211 : va_list ap; 212 : - 213 295858 : lock_msg(); + 213 295689 : lock_msg(); 214 : 215 : /* don't output in stdlog as these messages */ 216 : /* are always paired with a msg_tag() call */ 217 : - 218 295858 : if (msg_level >= MSG_INFO) { - 219 28841 : va_start(ap, format); - 220 28841 : vfprintf(stdout, format, ap); - 221 28841 : fflush(stdout); - 222 28841 : va_end(ap); + 218 295689 : if (msg_level >= MSG_INFO) { + 219 28811 : va_start(ap, format); + 220 28811 : vfprintf(stdout, format, ap); + 221 28811 : fflush(stdout); + 222 28811 : va_end(ap); 223 : } 224 : - 225 295858 : unlock_msg(); - 226 295858 : } + 225 295689 : unlock_msg(); + 226 295689 : } 227 : - 228 4447 : void msg_progress(const char* format, ...) + 228 4449 : void msg_progress(const char* format, ...) 229 : { 230 : va_list ap; 231 : - 232 4447 : lock_msg(); + 232 4449 : lock_msg(); 233 : - 234 4447 : if (stdlog) { + 234 4449 : if (stdlog) { 235 819 : va_start(ap, format); 236 819 : fprintf(stdlog, "msg:progress: "); 237 819 : vfprintf(stdlog, format, ap); @@ -301,99 +301,99 @@ 239 819 : va_end(ap); 240 : } 241 : - 242 4447 : if (msg_level >= MSG_PROGRESS) { + 242 4449 : if (msg_level >= MSG_PROGRESS) { 243 161 : va_start(ap, format); 244 161 : vfprintf(stdout, format, ap); 245 161 : fflush(stdout); 246 161 : va_end(ap); 247 : } 248 : - 249 4447 : unlock_msg(); - 250 4447 : } + 249 4449 : unlock_msg(); + 250 4449 : } 251 : - 252 1678 : void msg_bar(const char* format, ...) + 252 1958 : void msg_bar(const char* format, ...) 253 : { 254 : va_list ap; 255 : - 256 1678 : lock_msg(); + 256 1958 : lock_msg(); 257 : 258 : /* don't output in stdlog as these messages */ 259 : /* are intended for screen only */ 260 : /* also don't flush stdout as they are intended to be partial messages */ 261 : - 262 1678 : if (msg_level >= MSG_BAR) { + 262 1958 : if (msg_level >= MSG_BAR) { 263 0 : va_start(ap, format); 264 0 : vfprintf(stdout, format, ap); 265 0 : va_end(ap); 266 : } 267 : - 268 1678 : unlock_msg(); - 269 1678 : } + 268 1958 : unlock_msg(); + 269 1958 : } 270 : - 271 126963 : void msg_verbose(const char* format, ...) + 271 126943 : void msg_verbose(const char* format, ...) 272 : { 273 : va_list ap; 274 : - 275 126963 : lock_msg(); + 275 126943 : lock_msg(); 276 : - 277 126963 : if (stdlog) { - 278 125101 : va_start(ap, format); - 279 125101 : fprintf(stdlog, "msg:verbose: "); - 280 125101 : vfprintf(stdlog, format, ap); - 281 125101 : fflush(stdlog); - 282 125101 : va_end(ap); + 277 126943 : if (stdlog) { + 278 125077 : va_start(ap, format); + 279 125077 : fprintf(stdlog, "msg:verbose: "); + 280 125077 : vfprintf(stdlog, format, ap); + 281 125077 : fflush(stdlog); + 282 125077 : va_end(ap); 283 : } 284 : - 285 126963 : if (msg_level >= MSG_VERBOSE) { + 285 126943 : if (msg_level >= MSG_VERBOSE) { 286 91 : va_start(ap, format); 287 91 : vfprintf(stdout, format, ap); 288 91 : fflush(stdout); 289 91 : va_end(ap); 290 : } 291 : - 292 126963 : unlock_msg(); - 293 126963 : } + 292 126943 : unlock_msg(); + 293 126943 : } 294 : - 295 571 : void msg_flush(void) + 295 627 : void msg_flush(void) 296 : { - 297 571 : lock_msg(); + 297 627 : lock_msg(); 298 : - 299 571 : fflush(stdout); - 300 571 : fflush(stderr); + 299 627 : fflush(stdout); + 300 627 : fflush(stderr); 301 : - 302 571 : unlock_msg(); - 303 571 : } + 302 627 : unlock_msg(); + 303 627 : } 304 : - 305 64 : void printc(char c, size_t pad) + 305 106 : void printc(char c, size_t pad) 306 : { - 307 181 : while (pad) { + 307 304 : while (pad) { 308 : /* group writes in long pieces */ 309 : char buf[128]; - 310 53 : size_t len = pad; + 310 92 : size_t len = pad; 311 : - 312 53 : if (len >= sizeof(buf)) + 312 92 : if (len >= sizeof(buf)) 313 0 : len = sizeof(buf) - 1; 314 : - 315 53 : memset(buf, c, len); - 316 53 : buf[len] = 0; + 315 92 : memset(buf, c, len); + 316 92 : buf[len] = 0; 317 : - 318 53 : fputs(buf, stdout); + 318 92 : fputs(buf, stdout); 319 : - 320 53 : pad -= len; + 320 92 : pad -= len; 321 : } - 322 64 : } + 322 106 : } 323 : - 324 16 : void printr(const char* str, size_t pad) + 324 34 : void printr(const char* str, size_t pad) 325 : { 326 : size_t len; 327 : - 328 16 : len = strlen(str); + 328 34 : len = strlen(str); 329 : - 330 16 : if (len < pad) - 331 16 : printc(' ', pad - len); + 330 34 : if (len < pad) + 331 34 : printc(' ', pad - len); 332 : - 333 16 : fputs(str, stdout); - 334 16 : } + 333 34 : fputs(str, stdout); + 334 34 : } 335 : 336 52 : void printl(const char* str, size_t pad) 337 : { @@ -451,17 +451,17 @@ 389 : *p++ = to; \ 390 : break 391 : - 392 2428739 : const char* esc_tag(const char* str, char* buffer) + 392 2428312 : const char* esc_tag(const char* str, char* buffer) 393 : { - 394 2428739 : char* begin = buffer; - 395 2428739 : char* end = begin + ESC_MAX; - 396 2428739 : char* p = begin; + 394 2428312 : char* begin = buffer; + 395 2428312 : char* end = begin + ESC_MAX; + 396 2428312 : char* p = begin; 397 : 398 : /* copy string with escaping */ - 399 36388202 : while (*str) { - 400 31530724 : char c = *str; + 399 36387237 : while (*str) { + 400 31530613 : char c = *str; 401 : - 402 31530724 : switch (c) { + 402 31530613 : switch (c) { 403 : 404 0 : ESCAPE('\n', '\\', 'n'); 405 0 : ESCAPE('\r', '\\', 'r'); @@ -469,21 +469,21 @@ 407 0 : ESCAPE('\\', '\\', '\\'); 408 : 409 : default: - 410 31530724 : if (p == end) + 410 31530613 : if (p == end) 411 0 : goto bail; - 412 31530724 : *p++ = c; - 413 31530724 : break; + 412 31530613 : *p++ = c; + 413 31530613 : break; 414 : } 415 : - 416 31530724 : ++str; + 416 31530613 : ++str; 417 : } 418 : 419 : /* put final 0 */ - 420 2428739 : if (p == end) + 420 2428312 : if (p == end) 421 0 : goto bail; - 422 2428739 : *p = 0; + 422 2428312 : *p = 0; 423 : - 424 4857478 : return begin; + 424 4856624 : return begin; 425 : 426 : bail: 427 : /* LCOV_EXCL_START */ @@ -492,11 +492,11 @@ 430 : /* LCOV_EXCL_STOP */ 431 : } 432 : - 433 356083 : const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer) + 433 355914 : const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer) 434 : { - 435 356083 : char* begin = buffer; - 436 356083 : char* end = begin + ESC_MAX; - 437 356083 : char* p = begin; + 435 355914 : char* begin = buffer; + 436 355914 : char* end = begin + ESC_MAX; + 437 355914 : char* p = begin; 438 : unsigned str_mac; 439 : const char* str; 440 : @@ -517,24 +517,24 @@ 455 : #endif 456 : 457 : /* copy string with escaping */ - 458 356083 : str_mac = 0; - 459 356083 : str = str_map[str_mac]; + 458 355914 : str_mac = 0; + 459 355914 : str = str_map[str_mac]; 460 : while (1) { 461 : /* get the next char */ - 462 5126024 : char c = *str; + 462 5122618 : char c = *str; 463 : 464 : /* if one string is finished, go to the next */ - 465 10288138 : while (c == 0 && str_mac + 1 < str_max) { + 465 10281326 : while (c == 0 && str_mac + 1 < str_max) { 466 36090 : ++str_mac; 467 36090 : str = str_map[str_mac]; 468 36090 : c = *str; 469 : } 470 : 471 : /* if we read all the strings, stop */ - 472 5126024 : if (!c) - 473 356083 : break; + 472 5122618 : if (!c) + 473 355914 : break; 474 : - 475 4769941 : switch (c) { + 475 4766704 : switch (c) { 476 : #ifdef _WIN32 477 : /* 478 : * Windows shell escape @@ -609,24 +609,24 @@ 547 : case '/' : 548 : case '-' : 549 : /* safe chars for all shells, unquoted */ - 550 4690836 : if (p == end) + 550 4687726 : if (p == end) 551 0 : goto bail; - 552 4690836 : *p++ = c; - 553 4690836 : break; + 552 4687726 : *p++ = c; + 553 4687726 : break; 554 : default : 555 : /* all the others are quoted with \ */ - 556 79105 : if (p == end) + 556 78978 : if (p == end) 557 0 : goto bail; - 558 79105 : *p++ = '\\'; - 559 79105 : if (p == end) + 558 78978 : *p++ = '\\'; + 559 78978 : if (p == end) 560 0 : goto bail; - 561 79105 : *p++ = c; - 562 79105 : break; + 561 78978 : *p++ = c; + 562 78978 : break; 563 : #endif 564 : } 565 : - 566 4769941 : ++str; - 567 4769941 : } + 566 4766704 : ++str; + 567 4766704 : } 568 : 569 : #ifdef _WIN32 570 : if (has_quote) { @@ -637,11 +637,11 @@ 575 : #endif 576 : 577 : /* put final 0 */ - 578 356083 : if (p == end) + 578 355914 : if (p == end) 579 0 : goto bail; - 580 356083 : *p = 0; + 580 355914 : *p = 0; 581 : - 582 712166 : return begin; + 582 711828 : return begin; 583 : 584 : bail: 585 : /* LCOV_EXCL_START */ @@ -663,63 +663,63 @@ 601 0 : return s; 602 : } 603 : - 604 1466 : unsigned strsplit(char** split_map, unsigned split_max, char* str, const char* delimiters) + 604 1472 : unsigned strsplit(char** split_map, unsigned split_max, char* str, const char* delimiters) 605 : { - 606 1466 : unsigned mac = 0; + 606 1472 : unsigned mac = 0; 607 : 608 : /* skip initial delimiters */ - 609 1466 : str += strspn(str, delimiters); + 609 1472 : str += strspn(str, delimiters); 610 : - 611 8896 : while (*str != 0 || mac == split_max) { + 611 8932 : while (*str != 0 || mac == split_max) { 612 : /* start of the token */ - 613 5964 : split_map[mac] = str; - 614 5964 : ++mac; + 613 5988 : split_map[mac] = str; + 614 5988 : ++mac; 615 : 616 : /* find the first delimiter or the end of the string */ - 617 5964 : str += strcspn(str, delimiters); + 617 5988 : str += strcspn(str, delimiters); 618 : 619 : /* put the final terminator if missing */ - 620 5964 : if (*str != 0) - 621 4598 : *str++ = 0; + 620 5988 : if (*str != 0) + 621 4616 : *str++ = 0; 622 : 623 : /* skip trailing delimiters */ - 624 5964 : str += strspn(str, delimiters); + 624 5988 : str += strspn(str, delimiters); 625 : } 626 : - 627 1466 : return mac; + 627 1472 : return mac; 628 : } 629 : 630 : /****************************************************************************/ 631 : /* path */ 632 : - 633 7892425 : void pathcpy(char* dst, size_t size, const char* src) + 633 7892123 : void pathcpy(char* dst, size_t size, const char* src) 634 : { - 635 7892425 : size_t len = strlen(src); + 635 7892123 : size_t len = strlen(src); 636 : - 637 7892425 : if (len + 1 > size) { + 637 7892123 : if (len + 1 > size) { 638 : /* LCOV_EXCL_START */ 639 : log_fatal("Path too long '%s'\n", src); 640 : os_abort(); 641 : /* LCOV_EXCL_STOP */ 642 : } 643 : - 644 7892425 : memcpy(dst, src, len + 1); - 645 7892425 : } + 644 7892123 : memcpy(dst, src, len + 1); + 645 7892123 : } 646 : - 647 266 : void pathcat(char* dst, size_t size, const char* src) + 647 267 : void pathcat(char* dst, size_t size, const char* src) 648 : { - 649 266 : size_t dst_len = strlen(dst); - 650 266 : size_t src_len = strlen(src); + 649 267 : size_t dst_len = strlen(dst); + 650 267 : size_t src_len = strlen(src); 651 : - 652 266 : if (dst_len + src_len + 1 > size) { + 652 267 : if (dst_len + src_len + 1 > size) { 653 : /* LCOV_EXCL_START */ 654 : log_fatal("Path too long '%s%s'\n", dst, src); 655 : os_abort(); 656 : /* LCOV_EXCL_STOP */ 657 : } 658 : - 659 266 : memcpy(dst + dst_len, src, src_len + 1); - 660 266 : } + 659 267 : memcpy(dst + dst_len, src, src_len + 1); + 660 267 : } 661 : 662 788 : void pathcatc(char* dst, size_t size, char c) 663 : { @@ -736,9 +736,9 @@ 674 788 : dst[dst_len + 1] = 0; 675 788 : } 676 : - 677 16519 : void pathimport(char* dst, size_t size, const char* src) + 677 16572 : void pathimport(char* dst, size_t size, const char* src) 678 : { - 679 16519 : pathcpy(dst, size, src); + 679 16572 : pathcpy(dst, size, src); 680 : 681 : #ifdef _WIN32 682 : /* convert the Windows dir separator '\' to C '/', */ @@ -755,7 +755,7 @@ 693 : ++dst; 694 : } 695 : #endif - 696 16519 : } + 696 16572 : } 697 : 698 17589 : void pathexport(char* dst, size_t size, const char* src) 699 : { @@ -777,16 +777,16 @@ 715 : #endif 716 17589 : } 717 : - 718 51564205 : void pathprint(char* dst, size_t size, const char* format, ...) + 718 51564160 : void pathprint(char* dst, size_t size, const char* format, ...) 719 : { 720 : size_t len; 721 : va_list ap; 722 : - 723 51564205 : va_start(ap, format); - 724 51564205 : len = vsnprintf(dst, size, format, ap); - 725 51564205 : va_end(ap); + 723 51564160 : va_start(ap, format); + 724 51564160 : len = vsnprintf(dst, size, format, ap); + 725 51564160 : va_end(ap); 726 : - 727 51564205 : if (len >= size) { + 727 51564160 : if (len >= size) { 728 : /* LCOV_EXCL_START */ 729 : if (size > 0) { 730 : dst[size - 1] = 0; @@ -797,13 +797,13 @@ 735 : os_abort(); 736 : /* LCOV_EXCL_STOP */ 737 : } - 738 51564205 : } + 738 51564160 : } 739 : - 740 7699 : void pathslash(char* dst, size_t size) + 740 7705 : void pathslash(char* dst, size_t size) 741 : { - 742 7699 : size_t len = strlen(dst); + 742 7705 : size_t len = strlen(dst); 743 : - 744 7699 : if (len > 0 && dst[len - 1] != '/') { + 744 7705 : if (len > 0 && dst[len - 1] != '/') { 745 6114 : if (len + 2 >= size) { 746 : /* LCOV_EXCL_START */ 747 : log_fatal("Path too long '%s/'\n", dst); @@ -814,7 +814,7 @@ 752 6114 : dst[len] = '/'; 753 6114 : dst[len + 1] = 0; 754 : } - 755 7699 : } + 755 7705 : } 756 : 757 100 : void pathcut(char* dst) 758 : { @@ -826,7 +826,7 @@ 764 0 : dst[0] = 0; 765 100 : } 766 : - 767 51889998 : int pathcmp(const char* a, const char* b) + 767 51890261 : int pathcmp(const char* a, const char* b) 768 : { 769 : #ifdef _WIN32 770 : char ai[PATH_MAX]; @@ -839,32 +839,32 @@ 777 : /* case insensitive compare in Windows */ 778 : return stricmp(ai, bi); 779 : #else - 780 51889998 : return strcmp(a, b); + 780 51890261 : return strcmp(a, b); 781 : #endif 782 : } 783 : 784 : /****************************************************************************/ 785 : /* file-system */ 786 : - 787 793090 : int mkancestor(const char* file) + 787 793073 : int mkancestor(const char* file) 788 : { 789 : char dir[PATH_MAX]; 790 : struct stat st; 791 : char* c; 792 : - 793 793090 : pathcpy(dir, sizeof(dir), file); + 793 793073 : pathcpy(dir, sizeof(dir), file); 794 : - 795 793090 : c = strrchr(dir, '/'); - 796 793090 : if (!c) { + 795 793073 : c = strrchr(dir, '/'); + 796 793073 : if (!c) { 797 : /* no ancestor */ 798 0 : return 0; 799 : } 800 : 801 : /* clear the file */ - 802 793090 : *c = 0; + 802 793073 : *c = 0; 803 : 804 : /* if it's the root dir */ - 805 793090 : if (*dir == 0) { + 805 793073 : if (*dir == 0) { 806 : /* nothing more to do */ 807 0 : return 0; 808 : } @@ -887,9 +887,9 @@ 825 : * Also in Windows it's better to use lstat() than stat() because it 826 : * doesn't need to open the dir with CreateFile(). 827 : */ - 828 793090 : if (lstat(dir, &st) == 0) { + 828 793073 : if (lstat(dir, &st) == 0) { 829 : /* it already exists */ - 830 793010 : return 0; + 830 792993 : return 0; 831 : } 832 : 833 : /* recursively create them all */ @@ -910,7 +910,7 @@ 848 80 : return 0; 849 : } 850 : - 851 119641 : int fmtime(int f, int64_t mtime_sec, int mtime_nsec) + 851 119580 : int fmtime(int f, int64_t mtime_sec, int mtime_nsec) 852 : { 853 : #if HAVE_FUTIMENS 854 : struct timespec tv[2]; @@ -920,15 +920,15 @@ 858 : int ret; 859 : 860 : #if HAVE_FUTIMENS /* futimens() is preferred because it gives nanosecond precision */ - 861 119641 : tv[0].tv_sec = mtime_sec; - 862 119641 : if (mtime_nsec != STAT_NSEC_INVALID) - 863 119641 : tv[0].tv_nsec = mtime_nsec; + 861 119580 : tv[0].tv_sec = mtime_sec; + 862 119580 : if (mtime_nsec != STAT_NSEC_INVALID) + 863 119580 : tv[0].tv_nsec = mtime_nsec; 864 : else 865 0 : tv[0].tv_nsec = 0; - 866 119641 : tv[1].tv_sec = tv[0].tv_sec; - 867 119641 : tv[1].tv_nsec = tv[0].tv_nsec; + 866 119580 : tv[1].tv_sec = tv[0].tv_sec; + 867 119580 : tv[1].tv_nsec = tv[0].tv_nsec; 868 : - 869 119641 : ret = futimens(f, tv); + 869 119580 : ret = futimens(f, tv); 870 : #elif HAVE_FUTIMES /* fallback to futimes() if nanosecond precision is not available */ 871 : tv[0].tv_sec = mtime_sec; 872 : if (mtime_nsec != STAT_NSEC_INVALID) @@ -953,60 +953,60 @@ 891 : #error No function available to set file timestamps with sub-second precision 892 : #endif 893 : - 894 119641 : return ret; + 894 119580 : return ret; 895 : } 896 : 897 : /****************************************************************************/ 898 : /* advise */ 899 : - 900 2494967 : void advise_init(struct advise_struct* advise, int mode) + 900 2494910 : void advise_init(struct advise_struct* advise, int mode) 901 : { - 902 2494967 : advise->mode = mode; - 903 2494967 : advise->dirty_begin = 0; - 904 2494967 : advise->dirty_end = 0; - 905 2494967 : } + 902 2494910 : advise->mode = mode; + 903 2494910 : advise->dirty_begin = 0; + 904 2494910 : advise->dirty_end = 0; + 905 2494910 : } 906 : - 907 2495042 : int advise_flags(struct advise_struct* advise) + 907 2494965 : int advise_flags(struct advise_struct* advise) 908 : { - 909 2495042 : int flags = 0; + 909 2494965 : int flags = 0; 910 : - 911 2495042 : if (advise->mode == ADVISE_SEQUENTIAL - 912 2483696 : || advise->mode == ADVISE_FLUSH - 913 34023 : || advise->mode == ADVISE_FLUSH_WINDOW - 914 22683 : || advise->mode == ADVISE_DISCARD - 915 22683 : || advise->mode == ADVISE_DISCARD_WINDOW + 911 2494965 : if (advise->mode == ADVISE_SEQUENTIAL + 912 2483621 : || advise->mode == ADVISE_FLUSH + 913 34020 : || advise->mode == ADVISE_FLUSH_WINDOW + 914 22682 : || advise->mode == ADVISE_DISCARD + 915 22682 : || advise->mode == ADVISE_DISCARD_WINDOW 916 : ) - 917 2483698 : flags |= O_SEQUENTIAL; + 917 2483614 : flags |= O_SEQUENTIAL; 918 : 919 : #if HAVE_DIRECT_IO - 920 2495042 : if (advise->mode == ADVISE_DIRECT) + 920 2494965 : if (advise->mode == ADVISE_DIRECT) 921 0 : flags |= O_DIRECT; 922 : #endif 923 : - 924 2495042 : return flags; + 924 2494965 : return flags; 925 : } 926 : - 927 2416234 : int advise_open(struct advise_struct* advise, int f) + 927 2416366 : int advise_open(struct advise_struct* advise, int f) 928 : { 929 : (void)advise; 930 : (void)f; 931 : 932 : #if HAVE_POSIX_FADVISE - 933 2416234 : if (advise->mode == ADVISE_SEQUENTIAL - 934 2405052 : || advise->mode == ADVISE_FLUSH - 935 34025 : || advise->mode == ADVISE_FLUSH_WINDOW - 936 22684 : || advise->mode == ADVISE_DISCARD - 937 22684 : || advise->mode == ADVISE_DISCARD_WINDOW + 933 2416366 : if (advise->mode == ADVISE_SEQUENTIAL + 934 2405026 : || advise->mode == ADVISE_FLUSH + 935 34021 : || advise->mode == ADVISE_FLUSH_WINDOW + 936 22682 : || advise->mode == ADVISE_DISCARD + 937 22682 : || advise->mode == ADVISE_DISCARD_WINDOW 938 : ) { 939 : int ret; 940 : 941 : /* advise sequential access */ - 942 2404908 : ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL); - 943 2405073 : if (ret == ENOSYS) { + 942 2405029 : ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL); + 943 2405059 : if (ret == ENOSYS) { 944 : /* call is not supported, like in armhf, see posix_fadvise manpage */ 945 0 : ret = 0; 946 : } - 947 2405073 : if (ret != 0) { + 947 2405059 : if (ret != 0) { 948 : /* LCOV_EXCL_START */ 949 : errno = ret; /* posix_fadvise return the error code */ 950 : return -1; @@ -1015,10 +1015,10 @@ 953 : } 954 : #endif 955 : - 956 2416399 : return 0; + 956 2416396 : return 0; 957 : } 958 : - 959 900676 : int advise_write(struct advise_struct* advise, int f, data_off_t offset, data_off_t size) + 959 900358 : int advise_write(struct advise_struct* advise, int f, data_off_t offset, data_off_t size) 960 : { 961 : data_off_t flush_offset; 962 : data_off_t flush_size; @@ -1031,10 +1031,10 @@ 969 : (void)discard_offset; 970 : (void)discard_size; 971 : - 972 900676 : flush_offset = 0; - 973 900676 : flush_size = 0; - 974 900676 : discard_offset = 0; - 975 900676 : discard_size = 0; + 972 900358 : flush_offset = 0; + 973 900358 : flush_size = 0; + 974 900358 : discard_offset = 0; + 975 900358 : discard_size = 0; 976 : 977 : /* 978 : * Follow Linus recommendations about fast writes. @@ -1089,11 +1089,11 @@ 1027 : * --- 1028 : */ 1029 : - 1030 900676 : switch (advise->mode) { + 1030 900358 : switch (advise->mode) { 1031 : case ADVISE_FLUSH : - 1032 881928 : flush_offset = offset; - 1033 881928 : flush_size = size; - 1034 881928 : break; + 1032 881613 : flush_offset = offset; + 1033 881613 : flush_size = size; + 1034 881613 : break; 1035 : case ADVISE_DISCARD : 1036 0 : discard_offset = offset; 1037 0 : discard_size = size; @@ -1155,12 +1155,12 @@ 1093 : } 1094 : 1095 : #if HAVE_SYNC_FILE_RANGE - 1096 900676 : if (flush_size != 0) { + 1096 900358 : if (flush_size != 0) { 1097 : int ret; 1098 : 1099 : /* start writing immediately */ - 1100 881932 : ret = sync_file_range(f, flush_offset, flush_size, SYNC_FILE_RANGE_WRITE); - 1101 881933 : if (ret != 0) { + 1100 881612 : ret = sync_file_range(f, flush_offset, flush_size, SYNC_FILE_RANGE_WRITE); + 1101 881612 : if (ret != 0) { 1102 : /* LCOV_EXCL_START */ 1103 : return -1; 1104 : /* LCOV_EXCL_STOP */ @@ -1169,7 +1169,7 @@ 1107 : #endif 1108 : 1109 : #if HAVE_SYNC_FILE_RANGE && HAVE_POSIX_FADVISE - 1110 900677 : if (discard_size != 0) { + 1110 900358 : if (discard_size != 0) { 1111 : int ret; 1112 : 1113 : /* send the data to the disk and wait until it's written */ @@ -1192,10 +1192,10 @@ 1130 : } 1131 : #endif 1132 : - 1133 900677 : return 0; + 1133 900358 : return 0; 1134 : } 1135 : - 1136 8903872 : int advise_read(struct advise_struct* advise, int f, data_off_t offset, data_off_t size) + 1136 8903631 : int advise_read(struct advise_struct* advise, int f, data_off_t offset, data_off_t size) 1137 : { 1138 : (void)advise; 1139 : (void)f; @@ -1203,13 +1203,13 @@ 1141 : (void)size; 1142 : 1143 : #if HAVE_POSIX_FADVISE - 1144 8903872 : if (advise->mode == ADVISE_DISCARD - 1145 8904012 : || advise->mode == ADVISE_DISCARD_WINDOW + 1144 8903631 : if (advise->mode == ADVISE_DISCARD + 1145 8903983 : || advise->mode == ADVISE_DISCARD_WINDOW 1146 : ) { 1147 : int ret; 1148 : 1149 : /* flush the data from the cache */ - 1150 27735 : ret = posix_fadvise(f, offset, size, POSIX_FADV_DONTNEED); + 1150 27482 : ret = posix_fadvise(f, offset, size, POSIX_FADV_DONTNEED); 1151 : /* for POSIX_FADV_DONTNEED we don't allow failure with ENOSYS */ 1152 27825 : if (ret != 0) { 1153 : /* LCOV_EXCL_START */ @@ -1258,7 +1258,7 @@ 1196 : * --- 1197 : */ 1198 : - 1199 8903962 : return 0; + 1199 8903974 : return 0; 1200 : } 1201 : 1202 : /****************************************************************************/ @@ -1269,27 +1269,27 @@ 1207 : */ 1208 : static size_t mcounter; 1209 : - 1210 474 : size_t malloc_counter_get(void) + 1210 476 : size_t malloc_counter_get(void) 1211 : { 1212 : size_t ret; 1213 : - 1214 474 : lock_memory(); + 1214 476 : lock_memory(); 1215 : - 1216 474 : ret = mcounter; + 1216 476 : ret = mcounter; 1217 : - 1218 474 : unlock_memory(); + 1218 476 : unlock_memory(); 1219 : - 1220 474 : return ret; + 1220 476 : return ret; 1221 : } 1222 : - 1223 20173756 : void malloc_counter_inc(size_t inc) + 1223 20173411 : void malloc_counter_inc(size_t inc) 1224 : { - 1225 20173756 : lock_memory(); + 1225 20173411 : lock_memory(); 1226 : - 1227 20173756 : mcounter += inc; + 1227 20173411 : mcounter += inc; 1228 : - 1229 20173756 : unlock_memory(); - 1230 20173756 : } + 1229 20173411 : unlock_memory(); + 1230 20173411 : } 1231 : 1232 : /* LCOV_EXCL_START */ 1233 : static ssize_t malloc_print(int f, const char* str) @@ -1341,11 +1341,11 @@ 1279 : } 1280 : /* LCOV_EXCL_STOP */ 1281 : - 1282 14364226 : void* malloc_nofail(size_t size) + 1282 14363921 : void* malloc_nofail(size_t size) 1283 : { - 1284 14364226 : void* ptr = malloc(size); + 1284 14363921 : void* ptr = malloc(size); 1285 : - 1286 14364226 : if (!ptr) { + 1286 14363921 : if (!ptr) { 1287 : /* LCOV_EXCL_START */ 1288 : malloc_fail(size); 1289 : exit(EXIT_FAILURE); @@ -1359,58 +1359,58 @@ 1297 : /* Filling the memory doesn't ensure to disable OOM, but it increase a lot the chances to */ 1298 : /* get a real error from malloc() instead than a process killed. */ 1299 : /* Note that calloc() doesn't have the same effect. */ - 1300 14364226 : memset(ptr, 0xA5, size); + 1300 14363921 : memset(ptr, 0xA5, size); 1301 : #endif 1302 : - 1303 14364226 : malloc_counter_inc(size); + 1303 14363921 : malloc_counter_inc(size); 1304 : - 1305 14364226 : return ptr; + 1305 14363921 : return ptr; 1306 : } 1307 : - 1308 10053 : void* calloc_nofail(size_t count, size_t size) + 1308 10089 : void* calloc_nofail(size_t count, size_t size) 1309 : { 1310 : void* ptr; 1311 : - 1312 10053 : size *= count; + 1312 10089 : size *= count; 1313 : 1314 : /* see the note in malloc_nofail() of why we don't use calloc() */ - 1315 10053 : ptr = malloc(size); + 1315 10089 : ptr = malloc(size); 1316 : - 1317 10053 : if (!ptr) { + 1317 10089 : if (!ptr) { 1318 : /* LCOV_EXCL_START */ 1319 : malloc_fail(size); 1320 : exit(EXIT_FAILURE); 1321 : /* LCOV_EXCL_STOP */ 1322 : } 1323 : - 1324 10053 : memset(ptr, 0, size); + 1324 10089 : memset(ptr, 0, size); 1325 : - 1326 10053 : malloc_counter_inc(size); + 1326 10089 : malloc_counter_inc(size); 1327 : - 1328 10053 : return ptr; + 1328 10089 : return ptr; 1329 : } 1330 : - 1331 5799477 : char* strdup_nofail(const char* str) + 1331 5799401 : char* strdup_nofail(const char* str) 1332 : { 1333 : size_t size; 1334 : char* ptr; 1335 : - 1336 5799477 : size = strlen(str) + 1; + 1336 5799401 : size = strlen(str) + 1; 1337 : - 1338 5799477 : ptr = malloc(size); + 1338 5799401 : ptr = malloc(size); 1339 : - 1340 5799477 : if (!ptr) { + 1340 5799401 : if (!ptr) { 1341 : /* LCOV_EXCL_START */ 1342 : malloc_fail(size); 1343 : exit(EXIT_FAILURE); 1344 : /* LCOV_EXCL_STOP */ 1345 : } 1346 : - 1347 5799477 : memcpy(ptr, str, size); + 1347 5799401 : memcpy(ptr, str, size); 1348 : - 1349 5799477 : malloc_counter_inc(size); + 1349 5799401 : malloc_counter_inc(size); 1350 : - 1351 5799477 : return ptr; + 1351 5799401 : return ptr; 1352 : } 1353 : 1354 : /****************************************************************************/ @@ -1552,45 +1552,45 @@ 1490 : /* thread */ 1491 : 1492 : #if HAVE_PTHREAD - 1493 2276 : void thread_mutex_init(pthread_mutex_t* mutex, pthread_mutexattr_t* attr) + 1493 2284 : void thread_mutex_init(pthread_mutex_t* mutex, pthread_mutexattr_t* attr) 1494 : { - 1495 2276 : if (pthread_mutex_init(mutex, attr) != 0) { + 1495 2284 : if (pthread_mutex_init(mutex, attr) != 0) { 1496 : /* LCOV_EXCL_START */ 1497 : log_fatal("Failed call to pthread_mutex_init().\n"); 1498 : os_abort(); 1499 : /* LCOV_EXCL_STOP */ 1500 : } - 1501 2276 : } + 1501 2284 : } 1502 : - 1503 2074 : void thread_mutex_destroy(pthread_mutex_t* mutex) + 1503 2082 : void thread_mutex_destroy(pthread_mutex_t* mutex) 1504 : { - 1505 2074 : if (pthread_mutex_destroy(mutex) != 0) { + 1505 2082 : if (pthread_mutex_destroy(mutex) != 0) { 1506 : /* LCOV_EXCL_START */ 1507 : log_fatal("Failed call to pthread_mutex_destroy().\n"); 1508 : os_abort(); 1509 : /* LCOV_EXCL_STOP */ 1510 : } - 1511 2074 : } + 1511 2082 : } 1512 : - 1513 80858327 : void thread_mutex_lock(pthread_mutex_t* mutex) + 1513 80857668 : void thread_mutex_lock(pthread_mutex_t* mutex) 1514 : { - 1515 80858327 : if (pthread_mutex_lock(mutex) != 0) { + 1515 80857668 : if (pthread_mutex_lock(mutex) != 0) { 1516 : /* LCOV_EXCL_START */ 1517 : log_fatal("Failed call to pthread_mutex_lock().\n"); 1518 : os_abort(); 1519 : /* LCOV_EXCL_STOP */ 1520 : } - 1521 80863166 : } + 1521 80860507 : } 1522 : - 1523 80862235 : void thread_mutex_unlock(pthread_mutex_t* mutex) + 1523 80858701 : void thread_mutex_unlock(pthread_mutex_t* mutex) 1524 : { - 1525 80862235 : if (pthread_mutex_unlock(mutex) != 0) { + 1525 80858701 : if (pthread_mutex_unlock(mutex) != 0) { 1526 : /* LCOV_EXCL_START */ 1527 : log_fatal("Failed call to pthread_mutex_unlock().\n"); 1528 : os_abort(); 1529 : /* LCOV_EXCL_STOP */ 1530 : } - 1531 80864541 : } + 1531 80861909 : } 1532 : 1533 380 : void thread_cond_init(pthread_cond_t* cond, pthread_condattr_t* attr) 1534 : { @@ -1612,35 +1612,35 @@ 1550 : } 1551 380 : } 1552 : - 1553 83165 : void thread_cond_signal(pthread_cond_t* cond) + 1553 85887 : void thread_cond_signal(pthread_cond_t* cond) 1554 : { - 1555 83165 : if (pthread_cond_signal(cond) != 0) { + 1555 85887 : if (pthread_cond_signal(cond) != 0) { 1556 : /* LCOV_EXCL_START */ 1557 : log_fatal("Failed call to pthread_cond_signal().\n"); 1558 : os_abort(); 1559 : /* LCOV_EXCL_STOP */ 1560 : } - 1561 83165 : } + 1561 85887 : } 1562 : - 1563 255625 : void thread_cond_broadcast(pthread_cond_t* cond) + 1563 255503 : void thread_cond_broadcast(pthread_cond_t* cond) 1564 : { - 1565 255625 : if (pthread_cond_broadcast(cond) != 0) { + 1565 255503 : if (pthread_cond_broadcast(cond) != 0) { 1566 : /* LCOV_EXCL_START */ 1567 : log_fatal("Failed call to pthread_cond_broadcast().\n"); 1568 : os_abort(); 1569 : /* LCOV_EXCL_STOP */ 1570 : } - 1571 255625 : } + 1571 255503 : } 1572 : - 1573 1095059 : void thread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) + 1573 1037153 : void thread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) 1574 : { - 1575 1095059 : if (pthread_cond_wait(cond, mutex) != 0) { + 1575 1037153 : if (pthread_cond_wait(cond, mutex) != 0) { 1576 : /* LCOV_EXCL_START */ 1577 : log_fatal("Failed call to pthread_cond_wait().\n"); 1578 : os_abort(); 1579 : /* LCOV_EXCL_STOP */ 1580 : } - 1581 1095059 : } + 1581 1037153 : } 1582 : 1583 : /** 1584 : * Implementation note about conditional variables. @@ -1671,39 +1671,39 @@ 1609 : */ 1610 : int thread_cond_signal_outside = 0; 1611 : - 1612 83165 : void thread_cond_signal_and_unlock(pthread_cond_t* cond, pthread_mutex_t* mutex) + 1612 85887 : void thread_cond_signal_and_unlock(pthread_cond_t* cond, pthread_mutex_t* mutex) 1613 : { - 1614 83165 : if (thread_cond_signal_outside) { + 1614 85887 : if (thread_cond_signal_outside) { 1615 : /* without the thread checker unlock before signaling, */ 1616 : /* this reduces the number of context switches */ 1617 0 : thread_mutex_unlock(mutex); 1618 : } 1619 : - 1620 83165 : thread_cond_signal(cond); + 1620 85887 : thread_cond_signal(cond); 1621 : - 1622 83165 : if (!thread_cond_signal_outside) { + 1622 85887 : if (!thread_cond_signal_outside) { 1623 : /* with the thread checker unlock after signaling */ 1624 : /* to make explicit the condition and mutex relation */ - 1625 83165 : thread_mutex_unlock(mutex); + 1625 85887 : thread_mutex_unlock(mutex); 1626 : } - 1627 83165 : } + 1627 85887 : } 1628 : - 1629 255435 : void thread_cond_broadcast_and_unlock(pthread_cond_t* cond, pthread_mutex_t* mutex) + 1629 255313 : void thread_cond_broadcast_and_unlock(pthread_cond_t* cond, pthread_mutex_t* mutex) 1630 : { - 1631 255435 : if (thread_cond_signal_outside) { + 1631 255313 : if (thread_cond_signal_outside) { 1632 : /* without the thread checker unlock before signaling, */ 1633 : /* this reduces the number of context switches */ 1634 0 : thread_mutex_unlock(mutex); 1635 : } 1636 : - 1637 255435 : thread_cond_broadcast(cond); + 1637 255313 : thread_cond_broadcast(cond); 1638 : - 1639 255435 : if (!thread_cond_signal_outside) { + 1639 255313 : if (!thread_cond_signal_outside) { 1640 : /* with the thread checker unlock after signaling */ 1641 : /* to make explicit the condition and mutex relation */ - 1642 255435 : thread_mutex_unlock(mutex); + 1642 255313 : thread_mutex_unlock(mutex); 1643 : } - 1644 255435 : } + 1644 255313 : } 1645 : 1646 2200 : void thread_create(pthread_t* thread, pthread_attr_t* attr, void *(* func)(void *), void *arg) 1647 : { diff --git a/cov/cmdline/support.h.func-sort-c.html b/cov/cmdline/support.h.func-sort-c.html index cc007315..72186336 100644 --- a/cov/cmdline/support.h.func-sort-c.html +++ b/cov/cmdline/support.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ esc_shell - 332023 + 331854
diff --git a/cov/cmdline/support.h.func.html b/cov/cmdline/support.h.func.html index 64a447e5..4d39d629 100644 --- a/cov/cmdline/support.h.func.html +++ b/cov/cmdline/support.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ esc_shell - 332023 + 331854
diff --git a/cov/cmdline/support.h.gcov.html b/cov/cmdline/support.h.gcov.html index b31be071..48fbc42d 100644 --- a/cov/cmdline/support.h.gcov.html +++ b/cov/cmdline/support.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -291,9 +291,9 @@ 229 : * \param buffer Preallocated buffer of ESC_MAX size. 230 : */ 231 : const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer); - 232 332023 : static inline const char* esc_shell(const char* str, char* buffer) + 232 331854 : static inline const char* esc_shell(const char* str, char* buffer) 233 : { - 234 332023 : return esc_shell_multi(&str, 1, buffer); + 234 331854 : return esc_shell_multi(&str, 1, buffer); 235 : } 236 : 237 : /** diff --git a/cov/cmdline/sync.c.func-sort-c.html b/cov/cmdline/sync.c.func-sort-c.html index c9708a58..ed4b5461 100644 --- a/cov/cmdline/sync.c.func-sort-c.html +++ b/cov/cmdline/sync.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 502 + 501 546 - 91.9 % + 91.8 % Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -65,11 +65,11 @@ sync_data_reader - 688658 + 688232 sync_parity_writer - 544725 + 544522 failed_compare_by_index diff --git a/cov/cmdline/sync.c.func.html b/cov/cmdline/sync.c.func.html index 78e40ea7..0c8a6dfb 100644 --- a/cov/cmdline/sync.c.func.html +++ b/cov/cmdline/sync.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 502 + 501 546 - 91.9 % + 91.8 % Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -81,11 +81,11 @@ sync_data_reader - 688658 + 688232 sync_parity_writer - 544725 + 544522
diff --git a/cov/cmdline/sync.c.gcov.html b/cov/cmdline/sync.c.gcov.html index 2387de92..465c441c 100644 --- a/cov/cmdline/sync.c.gcov.html +++ b/cov/cmdline/sync.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 502 + 501 546 - 91.9 % + 91.8 % Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -524,56 +524,56 @@ 462 4688742 : one_valid = 1; 463 : 464 4911646 : if (block_has_invalid_parity(block) || plan->force_full) - 465 753392 : one_invalid = 1; + 465 753240 : one_invalid = 1; 466 : } 467 : 468 : /* if none valid or none invalid, we don't need to update */ 469 820170 : if (!one_invalid || !one_valid) - 470 590590 : return 0; + 470 590712 : return 0; 471 : - 472 229580 : return 1; + 472 229458 : return 1; 473 : } 474 : - 475 688658 : static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) + 475 688232 : static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_task* task) 476 : { - 477 688658 : struct snapraid_io* io = worker->io; - 478 688658 : struct snapraid_state* state = io->state; - 479 688658 : struct snapraid_handle* handle = worker->handle; - 480 688658 : struct snapraid_disk* disk = handle->disk; - 481 688658 : block_off_t blockcur = task->position; - 482 688658 : unsigned char* buffer = task->buffer; + 477 688232 : struct snapraid_io* io = worker->io; + 478 688232 : struct snapraid_state* state = io->state; + 479 688232 : struct snapraid_handle* handle = worker->handle; + 480 688232 : struct snapraid_disk* disk = handle->disk; + 481 688232 : block_off_t blockcur = task->position; + 482 688232 : unsigned char* buffer = task->buffer; 483 : int ret; 484 : char esc_buffer[ESC_MAX]; 485 : 486 : /* if the disk position is not used */ - 487 688658 : if (!disk) { + 487 688232 : if (!disk) { 488 : /* use an empty block */ 489 0 : memset(buffer, 0, state->block_size); 490 0 : task->state = TASK_STATE_DONE; - 491 92152 : return; + 491 92183 : return; 492 : } 493 : 494 : /* get the block */ - 495 688660 : task->block = fs_par2block_find(disk, blockcur); + 495 688237 : task->block = fs_par2block_find(disk, blockcur); 496 : 497 : /* if the block has no file, meaning that it's EMPTY or DELETED, */ 498 : /* it doesn't participate in the new parity computation */ - 499 688584 : if (!block_has_file(task->block)) { + 499 688177 : if (!block_has_file(task->block)) { 500 : /* use an empty block */ - 501 92138 : memset(buffer, 0, state->block_size); - 502 92138 : task->state = TASK_STATE_DONE; - 503 92138 : return; + 501 92175 : memset(buffer, 0, state->block_size); + 502 92175 : task->state = TASK_STATE_DONE; + 503 92175 : return; 504 : } 505 : 506 : /* get the file of this block */ - 507 596414 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); + 507 595953 : task->file = fs_par2file_get(disk, blockcur, &task->file_pos); 508 : 509 : /* if the file is different than the current one, close it */ - 510 596497 : if (handle->file != 0 && handle->file != task->file) { + 510 596099 : if (handle->file != 0 && handle->file != task->file) { 511 : /* keep a pointer at the file we are going to close for error reporting */ - 512 246140 : struct snapraid_file* report = handle->file; - 513 246140 : ret = handle_close(handle); - 514 246086 : if (ret == -1) { + 512 246100 : struct snapraid_file* report = handle->file; + 513 246100 : ret = handle_close(handle); + 514 246014 : if (ret == -1) { 515 : /* LCOV_EXCL_START */ 516 : /* This one is really an unexpected error, because we are only reading */ 517 : /* and closing a descriptor should never fail */ @@ -596,8 +596,8 @@ 534 : } 535 : } 536 : - 537 596443 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); - 538 596385 : if (ret == -1) { + 537 596013 : ret = handle_open(handle, task->file, state->file_mode, log_error, 0); + 538 596027 : if (ret == -1) { 539 12 : if (errno == EIO) { 540 : /* LCOV_EXCL_START */ 541 : log_tag("error:%u:%s:%s: Open EIO error. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno)); @@ -641,12 +641,12 @@ 579 : } 580 : 581 : /* check if the file is changed */ - 582 596373 : if (handle->st.st_size != task->file->size - 583 596414 : || handle->st.st_mtime != task->file->mtime_sec - 584 596446 : || STAT_NSEC(&handle->st) != task->file->mtime_nsec - 585 596437 : || handle->st.st_ino != task->file->inode + 582 596015 : if (handle->st.st_size != task->file->size + 583 596023 : || handle->st.st_mtime != task->file->mtime_sec + 584 596052 : || STAT_NSEC(&handle->st) != task->file->mtime_nsec + 585 596047 : || handle->st.st_ino != task->file->inode 586 : ) { - 587 50 : log_tag("error:%u:%s:%s: Unexpected attribute change\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer)); + 587 0 : log_tag("error:%u:%s:%s: Unexpected attribute change\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer)); 588 6 : if (handle->st.st_size != task->file->size) { 589 2 : log_error("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle->path, task->file->size, handle->st.st_size); 590 4 : } else if (handle->st.st_mtime != task->file->mtime_sec @@ -663,8 +663,8 @@ 601 6 : return; 602 : } 603 : - 604 596323 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); - 605 596119 : if (task->read_size == -1) { + 604 596041 : task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0); + 605 595681 : if (task->read_size == -1) { 606 : /* LCOV_EXCL_START */ 607 : if (errno == EIO) { 608 : log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno)); @@ -683,24 +683,24 @@ 621 : } 622 : 623 : /* store the path of the opened file */ - 624 596119 : pathcpy(task->path, sizeof(task->path), handle->path); + 624 595681 : pathcpy(task->path, sizeof(task->path), handle->path); 625 : - 626 596393 : task->state = TASK_STATE_DONE; + 626 595979 : task->state = TASK_STATE_DONE; 627 : } 628 : - 629 544725 : static void sync_parity_writer(struct snapraid_worker* worker, struct snapraid_task* task) + 629 544522 : static void sync_parity_writer(struct snapraid_worker* worker, struct snapraid_task* task) 630 : { - 631 544725 : struct snapraid_io* io = worker->io; - 632 544725 : struct snapraid_state* state = io->state; - 633 544725 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; - 634 544725 : unsigned level = parity_handle->level; - 635 544725 : block_off_t blockcur = task->position; - 636 544725 : unsigned char* buffer = task->buffer; + 631 544522 : struct snapraid_io* io = worker->io; + 632 544522 : struct snapraid_state* state = io->state; + 633 544522 : struct snapraid_parity_handle* parity_handle = worker->parity_handle; + 634 544522 : unsigned level = parity_handle->level; + 635 544522 : block_off_t blockcur = task->position; + 636 544522 : unsigned char* buffer = task->buffer; 637 : int ret; 638 : 639 : /* write parity */ - 640 544725 : ret = parity_write(parity_handle, blockcur, buffer, state->block_size); - 641 544729 : if (ret == -1) { + 640 544522 : ret = parity_write(parity_handle, blockcur, buffer, state->block_size); + 641 544519 : if (ret == -1) { 642 : /* LCOV_EXCL_START */ 643 : if (errno == EIO) { 644 : log_tag("parity_error:%u:%s: Write EIO error. %s\n", blockcur, lev_config_name(level), strerror(errno)); @@ -718,7 +718,7 @@ 656 : /* LCOV_EXCL_STOP */ 657 : } 658 : - 659 544729 : task->state = TASK_STATE_DONE; + 659 544519 : task->state = TASK_STATE_DONE; 660 : } 661 : 662 83 : static int state_sync_process(struct snapraid_state* state, struct snapraid_parity_handle* parity_handle, block_off_t blockstart, block_off_t blockmax) @@ -799,8 +799,8 @@ 737 83 : plan.force_full = state->opt.force_full; 738 410168 : for (blockcur = blockstart; blockcur < blockmax; ++blockcur) { 739 410085 : if (!block_is_enabled(&plan, blockcur)) - 740 295295 : continue; - 741 114790 : ++countmax; + 740 295356 : continue; + 741 114729 : ++countmax; 742 : } 743 : 744 : /* compute the autosave size for all disk, even if not read */ @@ -836,31 +836,31 @@ 774 : int writer_error[IO_WRITER_ERROR_MAX]; 775 : 776 : /* go to the next block */ - 777 114873 : blockcur = io_read_next(&io, &buffer); - 778 114873 : if (blockcur >= blockmax) + 777 114812 : blockcur = io_read_next(&io, &buffer); + 778 114812 : if (blockcur >= blockmax) 779 166 : break; 780 : 781 : /* until now is scheduling */ - 782 114790 : state_usage_sched(state); + 782 114729 : state_usage_sched(state); 783 : 784 : /* one more block processed for autosave */ - 785 114790 : ++autosavedone; - 786 114790 : --autosavemissing; + 785 114729 : ++autosavedone; + 786 114729 : --autosavemissing; 787 : 788 : /* by default process the block, and skip it if something goes wrong */ - 789 114790 : error_on_this_block = 0; - 790 114790 : silent_error_on_this_block = 0; - 791 114790 : io_error_on_this_block = 0; - 792 114790 : fixed_error_on_this_block = 0; + 789 114729 : error_on_this_block = 0; + 790 114729 : silent_error_on_this_block = 0; + 791 114729 : io_error_on_this_block = 0; + 792 114729 : fixed_error_on_this_block = 0; 793 : 794 : /* keep track of the number of failed blocks */ - 795 114790 : failed_count = 0; + 795 114729 : failed_count = 0; 796 : 797 : /* get block specific info */ - 798 114790 : info = info_get(&state->infoarr, blockcur); + 798 114729 : info = info_get(&state->infoarr, blockcur); 799 : 800 : /* if we have to use the old hash */ - 801 114790 : rehash = info_get_rehash(info); + 801 114729 : rehash = info_get_rehash(info); 802 : 803 : /* if the parity requires to be updated */ 804 : /* It could happens that all the blocks are EMPTY/BLK and CHG but with the hash */ @@ -869,18 +869,18 @@ 807 : /* Note that CHG/DELETED blocks already present in the content file loaded */ 808 : /* have the hash cleared (::clear_past_hash flag), and then they won't never match the hash. */ 809 : /* We are treating only CHG blocks created at runtime. */ - 810 114790 : parity_needs_to_be_updated = state->opt.force_full || state->opt.force_parity_update; + 810 114729 : parity_needs_to_be_updated = state->opt.force_full || state->opt.force_parity_update; 811 : 812 : /* if the parity is going to be updated */ - 813 114790 : parity_going_to_be_updated = 0; + 813 114729 : parity_going_to_be_updated = 0; 814 : 815 : /* if the block is marked as bad, we force the parity update */ 816 : /* because the bad block may be the result of a wrong parity */ - 817 114790 : if (info_get_bad(info)) + 817 114729 : if (info_get_bad(info)) 818 0 : parity_needs_to_be_updated = 1; 819 : 820 : /* for each disk, process the block */ - 821 803530 : for (j = 0; j < diskmax; ++j) { + 821 803103 : for (j = 0; j < diskmax; ++j) { 822 : struct snapraid_task* task; 823 : int read_size; 824 : unsigned char hash[HASH_MAX]; @@ -892,45 +892,45 @@ 830 : unsigned diskcur; 831 : 832 : /* until now is misc */ - 833 688740 : state_usage_misc(state); + 833 688374 : state_usage_misc(state); 834 : - 835 688740 : task = io_data_read(&io, &diskcur, waiting_map, &waiting_mac); + 835 688374 : task = io_data_read(&io, &diskcur, waiting_map, &waiting_mac); 836 : 837 : /* until now is disk */ - 838 688740 : state_usage_disk(state, handle, waiting_map, waiting_mac); + 838 688374 : state_usage_disk(state, handle, waiting_map, waiting_mac); 839 : 840 : /* get the results */ - 841 688740 : disk = task->disk; - 842 688740 : block = task->block; - 843 688740 : file = task->file; - 844 688740 : file_pos = task->file_pos; - 845 688740 : read_size = task->read_size; + 841 688374 : disk = task->disk; + 842 688374 : block = task->block; + 843 688374 : file = task->file; + 844 688374 : file_pos = task->file_pos; + 845 688374 : read_size = task->read_size; 846 : 847 : /* by default no rehash in case of "continue" */ - 848 688740 : rehandle[diskcur].block = 0; + 848 688374 : rehandle[diskcur].block = 0; 849 : 850 : /* if the disk position is not used */ - 851 688740 : if (!disk) - 852 93036 : continue; + 851 688374 : if (!disk) + 852 93074 : continue; 853 : 854 : /* get the state of the block */ - 855 688740 : block_state = block_state_get(block); + 855 688374 : block_state = block_state_get(block); 856 : 857 : /* if the block has invalid parity, */ 858 : /* we have to take care of it in case of recover */ - 859 688740 : if (block_has_invalid_parity(block)) { + 859 688374 : if (block_has_invalid_parity(block)) { 860 : /* store it in the failed set, because */ 861 : /* the parity may be still computed with the previous content */ - 862 182898 : failed[failed_count].index = diskcur; - 863 182898 : failed[failed_count].size = state->block_size; - 864 182898 : failed[failed_count].block = block; - 865 182898 : ++failed_count; + 862 182822 : failed[failed_count].index = diskcur; + 863 182822 : failed[failed_count].size = state->block_size; + 864 182822 : failed[failed_count].block = block; + 865 182822 : ++failed_count; 866 : 867 : /* if the block has invalid parity, we have to update the parity */ 868 : /* to include this block change */ 869 : /* This also apply to CHG blocks, but we are going to handle */ 870 : /* later this case to do the updates only if really needed */ - 871 182898 : if (block_state != BLOCK_STATE_CHG) + 871 182822 : if (block_state != BLOCK_STATE_CHG) 872 88225 : parity_needs_to_be_updated = 1; 873 : 874 : /* note that DELETE blocks are skipped in the next check */ @@ -941,28 +941,28 @@ 879 : } 880 : 881 : /* if the block is not used */ - 882 688740 : if (!block_has_file(block)) - 883 92165 : continue; + 882 688374 : if (!block_has_file(block)) + 883 92203 : continue; 884 : 885 : /* handle error conditions */ - 886 596575 : if (task->state == TASK_STATE_IOERROR) { + 886 596171 : if (task->state == TASK_STATE_IOERROR) { 887 : /* LCOV_EXCL_START */ 888 : ++io_error; 889 : goto bail; 890 : /* LCOV_EXCL_STOP */ 891 : } - 892 596575 : if (task->state == TASK_STATE_ERROR) { + 892 596171 : if (task->state == TASK_STATE_ERROR) { 893 : /* LCOV_EXCL_START */ 894 : ++error; 895 : goto bail; 896 : /* LCOV_EXCL_STOP */ 897 : } - 898 596575 : if (task->state == TASK_STATE_ERROR_CONTINUE) { + 898 596171 : if (task->state == TASK_STATE_ERROR_CONTINUE) { 899 18 : ++error; 900 18 : error_on_this_block = 1; 901 18 : continue; 902 : } - 903 596557 : if (task->state == TASK_STATE_IOERROR_CONTINUE) { + 903 596153 : if (task->state == TASK_STATE_IOERROR_CONTINUE) { 904 0 : ++io_error; 905 0 : if (io_error >= state->opt.io_error_limit) { 906 : /* LCOV_EXCL_START */ @@ -977,32 +977,32 @@ 915 0 : io_error_on_this_block = 1; 916 0 : continue; 917 : } - 918 596557 : if (task->state != TASK_STATE_DONE) { + 918 596153 : if (task->state != TASK_STATE_DONE) { 919 : /* LCOV_EXCL_START */ 920 : log_fatal("Internal inconsistency in task state\n"); 921 : os_abort(); 922 : /* LCOV_EXCL_STOP */ 923 : } 924 : - 925 596557 : countsize += read_size; + 925 596153 : countsize += read_size; 926 : 927 : /* now compute the hash */ - 928 596557 : if (rehash) { + 928 596153 : if (rehash) { 929 27243 : memhash(state->prevhash, state->prevhashseed, hash, buffer[diskcur], read_size); 930 : 931 : /* compute the new hash, and store it */ 932 27243 : rehandle[diskcur].block = block; 933 27243 : memhash(state->hash, state->hashseed, rehandle[diskcur].hash, buffer[diskcur], read_size); 934 : } else { - 935 569314 : memhash(state->hash, state->hashseed, hash, buffer[diskcur], read_size); + 935 568910 : memhash(state->hash, state->hashseed, hash, buffer[diskcur], read_size); 936 : } 937 : 938 : /* until now is hash */ - 939 596557 : state_usage_hash(state); + 939 596153 : state_usage_hash(state); 940 : - 941 596557 : if (block_has_updated_hash(block)) { + 941 596153 : if (block_has_updated_hash(block)) { 942 : /* compare the hash */ - 943 501902 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { + 943 501574 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { 944 : /* if the file has invalid parity, it's a REP changed during the sync */ 945 853 : if (block_has_invalid_parity(block)) { 946 1 : log_tag("error:%u:%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer)); @@ -1045,28 +1045,28 @@ 983 : } 984 : } else { 985 : /* if until now the parity doesn't need to be updated */ - 986 94655 : if (!parity_needs_to_be_updated) { + 986 94579 : if (!parity_needs_to_be_updated) { 987 : /* for sure it's a CHG block, because EMPTY are processed before with "continue" */ 988 : /* and BLK and REP have "block_has_updated_hash()" as 1, and all the others */ 989 : /* have "parity_needs_to_be_updated" already at 1 */ - 990 35289 : assert(block_state_get(block) == BLOCK_STATE_CHG); + 990 35226 : assert(block_state_get(block) == BLOCK_STATE_CHG); 991 : 992 : /* if the hash represents the data unequivocally */ - 993 35289 : if (hash_is_unique(block->hash)) { + 993 35226 : if (hash_is_unique(block->hash)) { 994 : /* check if the hash is changed */ - 995 8620 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { + 995 8551 : if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { 996 : /* the block is different, and we must update parity */ - 997 6075 : parity_needs_to_be_updated = 1; + 997 6039 : parity_needs_to_be_updated = 1; 998 : } 999 : } else { 1000 : /* if the hash is already invalid, we update parity */ - 1001 26669 : parity_needs_to_be_updated = 1; + 1001 26675 : parity_needs_to_be_updated = 1; 1002 : } 1003 : } 1004 : 1005 : /* copy the hash in the block, but doesn't mark the block as hashed */ 1006 : /* this allow in case of skipped block to do not save the failed computation */ - 1007 94655 : memcpy(block->hash, hash, BLOCK_HASH_SIZE); + 1007 94579 : memcpy(block->hash, hash, BLOCK_HASH_SIZE); 1008 : 1009 : /* note that in case of rehash, this is the wrong hash, */ 1010 : /* but it will be overwritten later */ @@ -1076,7 +1076,7 @@ 1014 : /* if we have only silent errors we can try to fix them on-the-fly */ 1015 : /* note the the fix is not written to disk, but used only to */ 1016 : /* compute the new parity */ - 1017 114790 : if (!error_on_this_block && !io_error_on_this_block && silent_error_on_this_block) { + 1017 114729 : if (!error_on_this_block && !io_error_on_this_block && silent_error_on_this_block) { 1018 : unsigned failed_mac; 1019 852 : int something_to_recover = 0; 1020 : @@ -1213,44 +1213,44 @@ 1151 : } 1152 : 1153 : /* if we have read all the data required and it's correct, proceed with the parity */ - 1154 114790 : if (!error_on_this_block && !io_error_on_this_block - 1155 114771 : && (!silent_error_on_this_block || fixed_error_on_this_block) + 1154 114729 : if (!error_on_this_block && !io_error_on_this_block + 1155 114710 : && (!silent_error_on_this_block || fixed_error_on_this_block) 1156 : ) { 1157 : /* update the parity only if really needed */ - 1158 114771 : if (parity_needs_to_be_updated) { + 1158 114710 : if (parity_needs_to_be_updated) { 1159 : /* compute the parity */ - 1160 112474 : raid_gen(diskmax, state->level, state->block_size, buffer); + 1160 112438 : raid_gen(diskmax, state->level, state->block_size, buffer); 1161 : 1162 : /* until now is raid */ - 1163 112474 : state_usage_raid(state); + 1163 112438 : state_usage_raid(state); 1164 : 1165 : /* mark that the parity is going to be written */ - 1166 112474 : parity_going_to_be_updated = 1; + 1166 112438 : parity_going_to_be_updated = 1; 1167 : } 1168 : 1169 : /* for each disk, mark the blocks as processed */ - 1170 803397 : for (j = 0; j < diskmax; ++j) { + 1170 802970 : for (j = 0; j < diskmax; ++j) { 1171 : struct snapraid_block* block; 1172 : - 1173 688626 : if (!handle[j].disk) + 1173 688260 : if (!handle[j].disk) 1174 0 : continue; 1175 : - 1176 688626 : block = fs_par2block_find(handle[j].disk, blockcur); + 1176 688260 : block = fs_par2block_find(handle[j].disk, blockcur); 1177 : - 1178 688626 : if (block == BLOCK_NULL) { + 1178 688260 : if (block == BLOCK_NULL) { 1179 : /* nothing to do */ - 1180 81210 : continue; + 1180 81248 : continue; 1181 : } 1182 : 1183 : /* if it's a deleted block */ - 1184 607416 : if (block_state_get(block) == BLOCK_STATE_DELETED) { + 1184 607012 : if (block_state_get(block) == BLOCK_STATE_DELETED) { 1185 : /* the parity is now updated without this block, so it's now empty */ 1186 10953 : fs_deallocate(handle[j].disk, blockcur); 1187 10953 : continue; 1188 : } 1189 : 1190 : /* now all the blocks have the hash and the parity computed */ - 1191 596463 : block_state_set(block, BLOCK_STATE_BLK); + 1191 596059 : block_state_set(block, BLOCK_STATE_BLK); 1192 : } 1193 : 1194 : /* we update the info block only if we really have updated the parity */ @@ -1258,11 +1258,11 @@ 1196 : /* wrote the parity at this time */ 1197 : /* we also update the info block only if no silent error was found */ 1198 : /* because has no sense to refresh the time for data that we know bad */ - 1199 114771 : if (parity_needs_to_be_updated - 1200 112474 : && !silent_error_on_this_block + 1199 114710 : if (parity_needs_to_be_updated + 1200 112438 : && !silent_error_on_this_block 1201 : ) { 1202 : /* if rehash is needed */ - 1203 112132 : if (rehash) { + 1203 112099 : if (rehash) { 1204 : /* store all the new hash already computed */ 1205 32249 : for (j = 0; j < diskmax; ++j) { 1206 27642 : if (rehandle[j].block) @@ -1272,14 +1272,14 @@ 1210 : 1211 : /* update the time info of the block */ 1212 : /* we are also clearing any previous bad and rehash flag */ - 1213 112132 : info_set(&state->infoarr, blockcur, info_make(now, 0, 0, 1)); + 1213 112099 : info_set(&state->infoarr, blockcur, info_make(now, 0, 0, 1)); 1214 : } 1215 : } 1216 : 1217 : /* if a silent (even if corrected) or input/output error was found */ 1218 : /* mark the block as bad to have check/fix to handle it */ 1219 : /* because our correction is in memory only and not yet written */ - 1220 114790 : if (silent_error_on_this_block || io_error_on_this_block) { + 1220 114729 : if (silent_error_on_this_block || io_error_on_this_block) { 1221 : /* set the error status keeping the other info */ 1222 852 : info_set(&state->infoarr, blockcur, info_set_bad(info)); 1223 : } @@ -1288,27 +1288,27 @@ 1226 : /* Note that the calls to io_parity_write() are mandatory */ 1227 : /* even if the parity doesn't need to be updated */ 1228 : /* This because we want to keep track of the time usage */ - 1229 114790 : state_usage_misc(state); + 1229 114729 : state_usage_misc(state); 1230 : 1231 : /* write start */ - 1232 114790 : io_write_preset(&io, blockcur, !parity_going_to_be_updated); + 1232 114729 : io_write_preset(&io, blockcur, !parity_going_to_be_updated); 1233 : 1234 : /* write the parity */ - 1235 673425 : for (l = 0; l < state->level; ++l) { + 1235 672998 : for (l = 0; l < state->level; ++l) { 1236 : unsigned levcur; 1237 : - 1238 558635 : io_parity_write(&io, &levcur, waiting_map, &waiting_mac); + 1238 558269 : io_parity_write(&io, &levcur, waiting_map, &waiting_mac); 1239 : 1240 : /* until now is parity */ - 1241 558635 : state_usage_parity(state, waiting_map, waiting_mac); + 1241 558269 : state_usage_parity(state, waiting_map, waiting_mac); 1242 : } 1243 : 1244 : /* write finished */ - 1245 114790 : io_write_next(&io, blockcur, !parity_going_to_be_updated, writer_error); + 1245 114729 : io_write_next(&io, blockcur, !parity_going_to_be_updated, writer_error); 1246 : 1247 : /* handle errors reported */ - 1248 573950 : for (j = 0; j < IO_WRITER_ERROR_MAX; ++j) { - 1249 459160 : if (writer_error[j]) { + 1248 573645 : for (j = 0; j < IO_WRITER_ERROR_MAX; ++j) { + 1249 458916 : if (writer_error[j]) { 1250 0 : switch (j + IO_WRITER_ERROR_BASE) { 1251 : case TASK_STATE_IOERROR_CONTINUE : 1252 0 : ++io_error; @@ -1338,24 +1338,24 @@ 1276 : } 1277 : 1278 : /* mark the state as needing write */ - 1279 114790 : state->need_write = 1; + 1279 114729 : state->need_write = 1; 1280 : 1281 : /* count the number of processed block */ - 1282 114790 : ++countpos; + 1282 114729 : ++countpos; 1283 : 1284 : /* progress */ - 1285 114790 : if (state_progress(state, &io, blockcur, countpos, countmax, countsize)) { + 1285 114729 : if (state_progress(state, &io, blockcur, countpos, countmax, countsize)) { 1286 : /* LCOV_EXCL_START */ 1287 : break; 1288 : /* LCOV_EXCL_STOP */ 1289 : } 1290 : 1291 : /* autosave */ - 1292 114790 : if ((state->autosave != 0 + 1292 114729 : if ((state->autosave != 0 1293 26021 : && autosavedone >= autosavelimit /* if we have reached the limit */ 1294 0 : && autosavemissing >= autosavelimit) /* if we have at least a full step to do */ 1295 : /* or if we have a forced autosave at the specified block */ - 1296 114790 : || (state->opt.force_autosave_at != 0 && state->opt.force_autosave_at == blockcur) + 1296 114729 : || (state->opt.force_autosave_at != 0 && state->opt.force_autosave_at == blockcur) 1297 : ) { 1298 1 : autosavedone = 0; /* restart the counter */ 1299 : @@ -1390,7 +1390,7 @@ 1328 : /* drop until now */ 1329 1 : state_usage_waste(state); 1330 : } - 1331 114790 : } + 1331 114729 : } 1332 : 1333 : end: 1334 83 : state_progress_end(state, countpos, countmax, countsize); diff --git a/cov/cmdline/touch.c.func-sort-c.html b/cov/cmdline/touch.c.func-sort-c.html index c4d38e13..29e46e34 100644 --- a/cov/cmdline/touch.c.func-sort-c.html +++ b/cov/cmdline/touch.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/touch.c.func.html b/cov/cmdline/touch.c.func.html index d5fd59ae..7ca70d61 100644 --- a/cov/cmdline/touch.c.func.html +++ b/cov/cmdline/touch.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/touch.c.gcov.html b/cov/cmdline/touch.c.gcov.html index 1e6840e3..8d7eeb65 100644 --- a/cov/cmdline/touch.c.gcov.html +++ b/cov/cmdline/touch.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/cmdline/unix.c.func-sort-c.html b/cov/cmdline/unix.c.func-sort-c.html index d6c41af0..470599c4 100644 --- a/cov/cmdline/unix.c.func-sort-c.html +++ b/cov/cmdline/unix.c.func-sort-c.html @@ -31,18 +31,18 @@ lcov.info Lines: - 316 + 320 442 - 71.5 % + 72.4 % Date: - 2016-11-06 + 2016-11-21 Functions: - 27 + 28 31 - 87.1 % + 90.3 % @@ -61,11 +61,11 @@ tick - 3819196 + 3817537 open_noatime - 1719485 + 1719437 filephy @@ -85,27 +85,27 @@ randomize - 281 + 282 os_init - 270 + 271 os_done - 247 + 248 tagread 191 - devresolve_sys + devresolve 191 - devresolve - 172 + devresolve_sys + 191 devread @@ -167,6 +167,10 @@ devscan 1 + + os_clear + 1 + devuuid_blkid 0 @@ -175,10 +179,6 @@ dirent_hidden 0 - - os_clear - 0 - stat_desc 0 diff --git a/cov/cmdline/unix.c.func.html b/cov/cmdline/unix.c.func.html index 6f1fae44..e5db4a7b 100644 --- a/cov/cmdline/unix.c.func.html +++ b/cov/cmdline/unix.c.func.html @@ -31,18 +31,18 @@ lcov.info Lines: - 316 + 320 442 - 71.5 % + 72.4 % Date: - 2016-11-06 + 2016-11-21 Functions: - 27 + 28 31 - 87.1 % + 90.3 % @@ -81,7 +81,7 @@ devresolve - 172 + 191 devresolve_proc @@ -137,23 +137,23 @@ open_noatime - 1719485 + 1719437 os_clear - 0 + 1 os_done - 247 + 248 os_init - 270 + 271 randomize - 281 + 282 stat_desc @@ -177,7 +177,7 @@ tick - 3819196 + 3817537 tick_ms diff --git a/cov/cmdline/unix.c.gcov.html b/cov/cmdline/unix.c.gcov.html index 8cf5fd09..1299a964 100644 --- a/cov/cmdline/unix.c.gcov.html +++ b/cov/cmdline/unix.c.gcov.html @@ -31,18 +31,18 @@ lcov.info Lines: - 316 + 320 442 - 71.5 % + 72.4 % Date: - 2016-11-06 + 2016-11-21 Functions: - 27 + 28 31 - 87.1 % + 90.3 % @@ -90,15 +90,15 @@ 28 : int exit_failure = 1; 29 : int exit_sync_needed = 2; 30 : - 31 1719485 : int open_noatime(const char* file, int flags) + 31 1719437 : int open_noatime(const char* file, int flags) 32 : { 33 : #ifdef O_NOATIME - 34 1719485 : int f = open(file, flags | O_NOATIME); + 34 1719437 : int f = open(file, flags | O_NOATIME); 35 : 36 : /* only root is allowed to use O_NOATIME, in case retry without it */ - 37 1719550 : if (f == -1 && errno == EPERM) + 37 1719500 : if (f == -1 && errno == EPERM) 38 0 : f = open(file, flags); - 39 1719558 : return f; + 39 1719484 : return f; 40 : #else 41 : return open(file, flags); 42 : #endif @@ -433,9 +433,9 @@ 371 : * Get the device file from the device number. 372 : */ 373 : #if HAVE_LINUX_DEVICE - 374 172 : static int devresolve(uint64_t device, char* path, size_t path_size) + 374 191 : static int devresolve(uint64_t device, char* path, size_t path_size) 375 : { - 376 172 : if (devresolve_sys(device, path, path_size) == 0) + 376 191 : if (devresolve_sys(device, path, path_size) == 0) 377 191 : return 0; 378 : 379 0 : return -1; @@ -791,7 +791,7 @@ 729 5483 : return 0; 730 : } 731 : - 732 3819196 : uint64_t tick(void) + 732 3817537 : uint64_t tick(void) 733 : { 734 : #if HAVE_MACH_ABSOLUTE_TIME 735 : /* for Mac OS X */ @@ -802,14 +802,14 @@ 740 : 741 : /* nanosecond precision with clock_gettime() */ 742 : #if defined(CLOCK_MONOTONIC_RAW) - 743 3819196 : if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) != 0) { + 743 3817537 : if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) != 0) { 744 : #else 745 : if (clock_gettime(CLOCK_MONOTONIC, &tv) != 0) { 746 : #endif 747 0 : return 0; 748 : } 749 : - 750 3819196 : return tv.tv_sec * 1000000000ULL + tv.tv_nsec; + 750 3817537 : return tv.tv_sec * 1000000000ULL + tv.tv_nsec; 751 : #else 752 : /* other platforms */ 753 : struct timeval tv; @@ -833,25 +833,25 @@ 771 65 : return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; 772 : } 773 : - 774 281 : int randomize(void* ptr, size_t size) + 774 282 : int randomize(void* ptr, size_t size) 775 : { 776 : int f; 777 : ssize_t ret; 778 : - 779 281 : f = open("/dev/urandom", O_RDONLY); - 780 281 : if (f == -1) + 779 282 : f = open("/dev/urandom", O_RDONLY); + 780 282 : if (f == -1) 781 0 : return -1; 782 : - 783 281 : ret = read(f, ptr, size); - 784 281 : if (ret < 0 || (size_t)ret != size) { + 783 282 : ret = read(f, ptr, size); + 784 282 : if (ret < 0 || (size_t)ret != size) { 785 0 : close(f); 786 0 : return -1; 787 : } 788 : - 789 281 : if (close(f) != 0) + 789 282 : if (close(f) != 0) 790 0 : return -1; 791 : - 792 281 : return 0; + 792 282 : return 0; 793 : } 794 : 795 : /** @@ -1477,12 +1477,12 @@ 1415 3 : return device_thread(low, func); 1416 : } 1417 : - 1418 270 : void os_init(int opt) + 1418 271 : void os_init(int opt) 1419 : { 1420 : #if HAVE_BLKID 1421 : int ret; - 1422 270 : ret = blkid_get_cache(&cache, NULL); - 1423 270 : if (ret != 0) { + 1422 271 : ret = blkid_get_cache(&cache, NULL); + 1423 271 : if (ret != 0) { 1424 : /* LCOV_EXCL_START */ 1425 : log_fatal("WARNING Failed to get blkid cache\n"); 1426 : /* LCOV_EXCL_STOP */ @@ -1490,15 +1490,15 @@ 1428 : #endif 1429 : 1430 : (void)opt; - 1431 270 : } + 1431 271 : } 1432 : - 1433 247 : void os_done(void) + 1433 248 : void os_done(void) 1434 : { 1435 : #if HAVE_BLKID - 1436 247 : if (cache != 0) - 1437 247 : blkid_put_cache(cache); + 1436 248 : if (cache != 0) + 1437 248 : blkid_put_cache(cache); 1438 : #endif - 1439 247 : } + 1439 248 : } 1440 : 1441 : /* LCOV_EXCL_START */ 1442 : void os_abort(void) @@ -1561,12 +1561,12 @@ 1499 : } 1500 : /* LCOV_EXCL_STOP */ 1501 : - 1502 0 : void os_clear(void) + 1502 1 : void os_clear(void) 1503 : { 1504 : /* ANSI codes */ - 1505 0 : printf("\033[H"); /* cursor at topleft */ - 1506 0 : printf("\033[2J"); /* clear screen */ - 1507 0 : } + 1505 1 : printf("\033[H"); /* cursor at topleft */ + 1506 1 : printf("\033[2J"); /* clear screen */ + 1507 1 : } 1508 : 1509 7 : size_t direct_size(void) 1510 : { diff --git a/cov/cmdline/util.c.func-sort-c.html b/cov/cmdline/util.c.func-sort-c.html index 9b60f2aa..6587372f 100644 --- a/cov/cmdline/util.c.func-sort-c.html +++ b/cov/cmdline/util.c.func-sort-c.html @@ -31,18 +31,18 @@ lcov.info Lines: - 76 - 82 - 92.7 % + 88 + 94 + 93.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 16 - 17 - 94.1 % + 20 + 21 + 95.2 % @@ -61,23 +61,39 @@ util_rotl32 - 854131328 + 854122150 util_rotl64 - 512341560 + 510718872 - memhash - 5938723 + util_read32 + 8307408 + + + util_write32 + 8307408 + + + util_write64 + 7722914 + + + util_read64 + 7722914 + + + memhash + 5938309 crc32c_x86 - 646609 + 646603 - memdiff - 93321 + memdiff + 93220 malloc_nofail_vector_align @@ -85,39 +101,39 @@ mtest_vector - 1953 + 1955 malloc_nofail_test - 1953 + 1955 fast_mtest_vector - 1953 + 1955 crc32c_gen - 345 + 337 crc32c_init - 286 + 287 - lock_lock - 261 + lock_lock + 262 - lock_unlock - 240 + lock_unlock + 241 malloc_nofail_align 179 - hash_config_name - 42 + hash_config_name + 45 malloc_nofail_direct diff --git a/cov/cmdline/util.c.func.html b/cov/cmdline/util.c.func.html index f2fb5161..34c06e88 100644 --- a/cov/cmdline/util.c.func.html +++ b/cov/cmdline/util.c.func.html @@ -31,18 +31,18 @@ lcov.info Lines: - 76 - 82 - 92.7 % + 88 + 94 + 93.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 16 - 17 - 94.1 % + 20 + 21 + 95.2 % @@ -61,31 +61,31 @@ crc32c_gen - 345 + 337 crc32c_init - 286 + 287 crc32c_x86 - 646609 + 646603 fast_mtest_vector - 1953 + 1955 - hash_config_name - 42 + hash_config_name + 45 - lock_lock - 261 + lock_lock + 262 - lock_unlock - 240 + lock_unlock + 241 malloc_nofail_align @@ -97,7 +97,7 @@ malloc_nofail_test - 1953 + 1955 malloc_nofail_vector_align @@ -108,24 +108,40 @@ 0 - memdiff - 93321 + memdiff + 93220 - memhash - 5938723 + memhash + 5938309 mtest_vector - 1953 + 1955 + + + util_read32 + 8307408 + + + util_read64 + 7722914 util_rotl32 - 854131328 + 854122150 util_rotl64 - 512341560 + 510718872 + + + util_write32 + 8307408 + + + util_write64 + 7722914
diff --git a/cov/cmdline/util.c.gcov.html b/cov/cmdline/util.c.gcov.html index 467c0b8d..e731c931 100644 --- a/cov/cmdline/util.c.gcov.html +++ b/cov/cmdline/util.c.gcov.html @@ -31,18 +31,18 @@ lcov.info Lines: - 76 - 82 - 92.7 % + 88 + 94 + 93.6 % Date: - 2016-11-06 + 2016-11-21 Functions: - 16 - 17 - 94.1 % + 20 + 21 + 95.2 % @@ -151,15 +151,15 @@ 89 0 : return ptr; 90 : } 91 : - 92 1953 : void* malloc_nofail_test(size_t size) + 92 1955 : void* malloc_nofail_test(size_t size) 93 : { 94 : void* ptr; 95 : - 96 1953 : ptr = malloc_nofail(size); + 96 1955 : ptr = malloc_nofail(size); 97 : - 98 1953 : mtest_vector(1, size, &ptr); + 98 1955 : mtest_vector(1, size, &ptr); 99 : - 100 1953 : return ptr; + 100 1955 : return ptr; 101 : } 102 : 103 : /** @@ -168,40 +168,40 @@ 106 : * It's similar at raid_mtest_vector() but faster because 107 : * we have a lot of buffers to verify. 108 : */ - 109 1953 : static int fast_mtest_vector(int n, size_t size, void** vv) + 109 1955 : static int fast_mtest_vector(int n, size_t size, void** vv) 110 : { 111 : int i, j; 112 : 113 : /* test with all the bits */ - 114 17577 : for (i = 0; i < 8; ++i) { - 115 15624 : unsigned char value = 1 << i; + 114 17595 : for (i = 0; i < 8; ++i) { + 115 15640 : unsigned char value = 1 << i; 116 : 117 : /* fill first */ - 118 15624 : memset(vv[0], value, size); + 118 15640 : memset(vv[0], value, size); 119 : 120 : /* copy to the next */ - 121 15624 : for (j = 1; j < n; ++j) + 121 15640 : for (j = 1; j < n; ++j) 122 0 : memcpy(vv[j], vv[j - 1], size); 123 : 124 : /* compare with the previous */ - 125 31248 : for (j = 1; j <= n; ++j) - 126 15624 : if (memcmp(vv[j % n], vv[j - 1], size) != 0) + 125 31280 : for (j = 1; j <= n; ++j) + 126 15640 : if (memcmp(vv[j % n], vv[j - 1], size) != 0) 127 0 : return -1; 128 : } 129 : - 130 1953 : return 0; + 130 1955 : return 0; 131 : } 132 : - 133 1953 : void mtest_vector(int n, size_t size, void** vv) + 133 1955 : void mtest_vector(int n, size_t size, void** vv) 134 : { - 135 1953 : if (fast_mtest_vector(n, size, vv) != 0) { + 135 1955 : if (fast_mtest_vector(n, size, vv) != 0) { 136 : /* LCOV_EXCL_START */ 137 : log_fatal("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); 138 : log_fatal("Try running a memory test like http://www.memtest86.com/\n"); 139 : exit(EXIT_FAILURE); 140 : /* LCOV_EXCL_STOP */ 141 : } - 142 1953 : } + 142 1955 : } 143 : 144 : /****************************************************************************/ 145 : /* crc */ @@ -478,42 +478,42 @@ 416 : int crc_x86; 417 : #endif 418 : - 419 345 : uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, unsigned size) + 419 337 : uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, unsigned size) 420 : { - 421 345 : crc ^= CRC_IV; + 421 337 : crc ^= CRC_IV; 422 : - 423 345 : crc = crc32c_gen_plain(crc, ptr, size); + 423 337 : crc = crc32c_gen_plain(crc, ptr, size); 424 : - 425 345 : crc ^= CRC_IV; + 425 337 : crc ^= CRC_IV; 426 : - 427 345 : return crc; + 427 337 : return crc; 428 : } 429 : 430 : #if HAVE_SSE42 - 431 646609 : uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size) + 431 646603 : uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size) 432 : { - 433 646609 : crc ^= CRC_IV; + 433 646603 : crc ^= CRC_IV; 434 : - 435 646609 : crc = crc32c_x86_plain(crc, ptr, size); + 435 646603 : crc = crc32c_x86_plain(crc, ptr, size); 436 : - 437 646607 : crc ^= CRC_IV; + 437 646602 : crc ^= CRC_IV; 438 : - 439 646607 : return crc; + 439 646602 : return crc; 440 : } 441 : #endif 442 : 443 : uint32_t (*crc32c)(uint32_t crc, const unsigned char* ptr, unsigned size); 444 : - 445 286 : void crc32c_init(void) + 445 287 : void crc32c_init(void) 446 : { - 447 286 : crc32c = crc32c_gen; + 447 287 : crc32c = crc32c_gen; 448 : #if HAVE_SSE42 - 449 286 : if (raid_cpu_has_crc32()) { - 450 284 : crc_x86 = 1; - 451 284 : crc32c = crc32c_x86; + 449 287 : if (raid_cpu_has_crc32()) { + 450 285 : crc_x86 = 1; + 451 285 : crc32c = crc32c_x86; 452 : } 453 : #endif - 454 286 : } + 454 287 : } 455 : 456 : /****************************************************************************/ 457 : /* byte operations */ @@ -522,14 +522,14 @@ 460 : * Rotate left. 461 : * In x86/x64 they are optimized with a single assembler instruction. 462 : */ - 463 854131328 : static inline uint32_t util_rotl32(uint32_t x, int8_t r) + 463 854122150 : static inline uint32_t util_rotl32(uint32_t x, int8_t r) 464 : { - 465 854131328 : return (x << r) | (x >> (32 - r)); + 465 854122150 : return (x << r) | (x >> (32 - r)); 466 : } 467 : - 468 512341560 : static inline uint64_t util_rotl64(uint64_t x, int8_t r) + 468 510718872 : static inline uint64_t util_rotl64(uint64_t x, int8_t r) 469 : { - 470 512341560 : return (x << r) | (x >> (64 - r)); + 470 510718872 : return (x << r) | (x >> (64 - r)); 471 : } 472 : 473 : /** @@ -562,109 +562,145 @@ 500 : | (util_rotl64(v, 40) & 0x00ff000000ff0000ULL) 501 : | (util_rotl64(v, 56) & 0xff000000ff000000ULL); 502 : } - 503 : #endif + 503 : #endif 504 : - 505 : /****************************************************************************/ - 506 : /* hash */ - 507 : - 508 : #include "murmur3.c" - 509 : #include "spooky2.c" - 510 : - 511 5938723 : void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t size) - 512 : { - 513 5938723 : switch (kind) { - 514 : case HASH_MURMUR3 : - 515 2076854 : MurmurHash3_x86_128(src, size, seed, digest); - 516 2076854 : break; - 517 : case HASH_SPOOKY2 : - 518 3861869 : SpookyHash128(src, size, seed, digest); - 519 3861869 : break; - 520 : default : - 521 : /* LCOV_EXCL_START */ - 522 : log_fatal("Internal inconsistency in hash function %u\n", kind); - 523 : exit(EXIT_FAILURE); - 524 : break; - 525 : /* LCOV_EXCL_STOP */ - 526 : } - 527 5938723 : } - 528 : - 529 42 : const char* hash_config_name(unsigned kind) - 530 : { - 531 42 : switch (kind) { - 532 13 : case HASH_UNDEFINED : return "undefined"; - 533 28 : case HASH_MURMUR3 : return "murmur3"; - 534 1 : case HASH_SPOOKY2 : return "spooky2"; - 535 : default : - 536 : /* LCOV_EXCL_START */ - 537 : return "unknown"; - 538 : /* LCOV_EXCL_STOP */ - 539 : } - 540 : } - 541 : - 542 93321 : unsigned memdiff(const unsigned char* data1, const unsigned char* data2, size_t size) - 543 : { - 544 : size_t i; - 545 : unsigned count; + 505 8307408 : static inline uint32_t util_read32(const void* ptr) + 506 : { + 507 : uint32_t v; + 508 8307408 : memcpy(&v, ptr, sizeof(v)); + 509 : #if WORDS_BIGENDIAN + 510 : v = util_swap32(v); + 511 : #endif + 512 8307408 : return v; + 513 : } + 514 : + 515 7722914 : static inline uint64_t util_read64(const void* ptr) + 516 : { + 517 : uint64_t v; + 518 7722914 : memcpy(&v, ptr, sizeof(v)); + 519 : #if WORDS_BIGENDIAN + 520 : v = util_swap64(v); + 521 : #endif + 522 7722914 : return v; + 523 : } + 524 : + 525 8307408 : static inline void util_write32(void* ptr, uint32_t v) + 526 : { + 527 : #if WORDS_BIGENDIAN + 528 : v = util_swap32(v); + 529 : #endif + 530 8307408 : memcpy(ptr, &v, sizeof(v)); + 531 8307408 : } + 532 : + 533 7722914 : static inline void util_write64(void* ptr, uint64_t v) + 534 : { + 535 : #if WORDS_BIGENDIAN + 536 : v = util_swap64(v); + 537 : #endif + 538 7722914 : memcpy(ptr, &v, sizeof(v)); + 539 7722914 : } + 540 : + 541 : /****************************************************************************/ + 542 : /* hash */ + 543 : + 544 : #include "murmur3.c" + 545 : #include "spooky2.c" 546 : - 547 93321 : count = 0; - 548 80898921 : for (i = 0; i < size; ++i) { - 549 : unsigned j; - 550 80805600 : unsigned char diff = data1[i] ^ data2[i]; - 551 727250400 : for (j = 0; j < 8; ++j) { - 552 646444800 : if ((diff & 1) != 0) - 553 311410136 : ++count; - 554 646444800 : diff >>= 1; - 555 : } - 556 : } - 557 : - 558 93321 : return count; - 559 : } - 560 : - 561 : /****************************************************************************/ - 562 : /* lock */ - 563 : - 564 : #if HAVE_LOCKFILE - 565 261 : int lock_lock(const char* file) + 547 5938309 : void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t size) + 548 : { + 549 5938309 : switch (kind) { + 550 : case HASH_MURMUR3 : + 551 2076852 : MurmurHash3_x86_128(src, size, seed, digest); + 552 2076852 : break; + 553 : case HASH_SPOOKY2 : + 554 3861457 : SpookyHash128(src, size, seed, digest); + 555 3861457 : break; + 556 : default : + 557 : /* LCOV_EXCL_START */ + 558 : log_fatal("Internal inconsistency in hash function %u\n", kind); + 559 : exit(EXIT_FAILURE); + 560 : break; + 561 : /* LCOV_EXCL_STOP */ + 562 : } + 563 5938309 : } + 564 : + 565 45 : const char* hash_config_name(unsigned kind) 566 : { - 567 : int f; - 568 : - 569 261 : f = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600); - 570 261 : if (f == -1) { - 571 : /* LCOV_EXCL_START */ - 572 : return -1; - 573 : /* LCOV_EXCL_STOP */ - 574 : } - 575 : - 576 : /* exclusive lock, not blocking */ - 577 261 : if (flock(f, LOCK_EX | LOCK_NB) == -1) { - 578 : /* LCOV_EXCL_START */ - 579 : close(f); - 580 : return -1; - 581 : /* LCOV_EXCL_STOP */ - 582 : } - 583 : - 584 261 : return f; - 585 : } - 586 : #endif - 587 : - 588 : #if HAVE_LOCKFILE - 589 240 : int lock_unlock(int f) - 590 : { - 591 : /* - 592 : * Intentionally don't remove the lock file. - 593 : * Removing it just introduces race course with other process - 594 : * that could have already opened it. - 595 : */ - 596 240 : if (close(f) == -1) { - 597 : /* LCOV_EXCL_START */ - 598 : return -1; - 599 : /* LCOV_EXCL_STOP */ - 600 : } - 601 : - 602 240 : return 0; - 603 : } - 604 : #endif - 605 : + 567 45 : switch (kind) { + 568 14 : case HASH_UNDEFINED : return "undefined"; + 569 30 : case HASH_MURMUR3 : return "murmur3"; + 570 1 : case HASH_SPOOKY2 : return "spooky2"; + 571 : default : + 572 : /* LCOV_EXCL_START */ + 573 : return "unknown"; + 574 : /* LCOV_EXCL_STOP */ + 575 : } + 576 : } + 577 : + 578 93220 : unsigned memdiff(const unsigned char* data1, const unsigned char* data2, size_t size) + 579 : { + 580 : size_t i; + 581 : unsigned count; + 582 : + 583 93220 : count = 0; + 584 80894180 : for (i = 0; i < size; ++i) { + 585 : unsigned j; + 586 80800960 : unsigned char diff = data1[i] ^ data2[i]; + 587 727208640 : for (j = 0; j < 8; ++j) { + 588 646407680 : if ((diff & 1) != 0) + 589 311424980 : ++count; + 590 646407680 : diff >>= 1; + 591 : } + 592 : } + 593 : + 594 93220 : return count; + 595 : } + 596 : + 597 : /****************************************************************************/ + 598 : /* lock */ + 599 : + 600 : #if HAVE_LOCKFILE + 601 262 : int lock_lock(const char* file) + 602 : { + 603 : int f; + 604 : + 605 262 : f = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600); + 606 262 : if (f == -1) { + 607 : /* LCOV_EXCL_START */ + 608 : return -1; + 609 : /* LCOV_EXCL_STOP */ + 610 : } + 611 : + 612 : /* exclusive lock, not blocking */ + 613 262 : if (flock(f, LOCK_EX | LOCK_NB) == -1) { + 614 : /* LCOV_EXCL_START */ + 615 : close(f); + 616 : return -1; + 617 : /* LCOV_EXCL_STOP */ + 618 : } + 619 : + 620 262 : return f; + 621 : } + 622 : #endif + 623 : + 624 : #if HAVE_LOCKFILE + 625 241 : int lock_unlock(int f) + 626 : { + 627 : /* + 628 : * Intentionally don't remove the lock file. + 629 : * Removing it just introduces race course with other process + 630 : * that could have already opened it. + 631 : */ + 632 241 : if (close(f) == -1) { + 633 : /* LCOV_EXCL_START */ + 634 : return -1; + 635 : /* LCOV_EXCL_STOP */ + 636 : } + 637 : + 638 241 : return 0; + 639 : } + 640 : #endif + 641 : diff --git a/cov/cmdline/util.h.func-sort-c.html b/cov/cmdline/util.h.func-sort-c.html index 0fdb5fd3..be791415 100644 --- a/cov/cmdline/util.h.func-sort-c.html +++ b/cov/cmdline/util.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,19 +61,19 @@ crc32c_x86_plain - 21365408 + 21365830 crc32c_plain - 20718802 + 20719227 crc32c_plain_char - 3808025 + 3808426 crc32c_gen_plain - 345 + 337
diff --git a/cov/cmdline/util.h.func.html b/cov/cmdline/util.h.func.html index 2da812ac..bb76f47b 100644 --- a/cov/cmdline/util.h.func.html +++ b/cov/cmdline/util.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,19 +61,19 @@ crc32c_gen_plain - 345 + 337 crc32c_plain - 20718802 + 20719227 crc32c_plain_char - 3808025 + 3808426 crc32c_x86_plain - 21365408 + 21365830
diff --git a/cov/cmdline/util.h.gcov.html b/cov/cmdline/util.h.gcov.html index ec697472..1d87b293 100644 --- a/cov/cmdline/util.h.gcov.html +++ b/cov/cmdline/util.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -144,12 +144,12 @@ 82 : /** 83 : * Compute CRC-32 (Castagnoli) for a single byte without the IV. 84 : */ - 85 3808025 : static inline uint32_t crc32c_plain_char(uint32_t crc, unsigned char c) + 85 3808426 : static inline uint32_t crc32c_plain_char(uint32_t crc, unsigned char c) 86 : { 87 : #if HAVE_SSE42 - 88 3808025 : if (tommy_likely(crc_x86)) { - 89 3808025 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); - 90 3808025 : return crc; + 88 3808426 : if (tommy_likely(crc_x86)) { + 89 3808426 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); + 90 3808426 : return crc; 91 : } 92 : #endif 93 0 : return CRC32C_0[(crc ^ c) & 0xff] ^ (crc >> 8); @@ -158,29 +158,29 @@ 96 : /** 97 : * Compute the CRC-32 (Castagnoli) without the IV. 98 : */ - 99 345 : static inline uint32_t crc32c_gen_plain(uint32_t crc, const unsigned char* ptr, unsigned size) + 99 337 : static inline uint32_t crc32c_gen_plain(uint32_t crc, const unsigned char* ptr, unsigned size) 100 : { - 101 21496665 : while (size >= 4) { - 102 21495975 : crc ^= ptr[0] | (uint32_t)ptr[1] << 8 | (uint32_t)ptr[2] << 16 | (uint32_t)ptr[3] << 24; - 103 21495975 : crc = CRC32C_3[crc & 0xff] ^ CRC32C_2[(crc >> 8) & 0xff] ^ CRC32C_1[(crc >> 16) & 0xff] ^ CRC32C_0[crc >> 24]; - 104 21495975 : ptr += 4; - 105 21495975 : size -= 4; + 101 20972361 : while (size >= 4) { + 102 20971687 : crc ^= ptr[0] | (uint32_t)ptr[1] << 8 | (uint32_t)ptr[2] << 16 | (uint32_t)ptr[3] << 24; + 103 20971687 : crc = CRC32C_3[crc & 0xff] ^ CRC32C_2[(crc >> 8) & 0xff] ^ CRC32C_1[(crc >> 16) & 0xff] ^ CRC32C_0[crc >> 24]; + 104 20971687 : ptr += 4; + 105 20971687 : size -= 4; 106 : } 107 : - 108 699 : while (size) { + 108 683 : while (size) { 109 9 : crc = CRC32C_0[(crc ^ *ptr) & 0xff] ^ (crc >> 8); 110 9 : ++ptr; 111 9 : --size; 112 : } 113 : - 114 345 : return crc; + 114 337 : return crc; 115 : } 116 : 117 : /** 118 : * Compute the CRC-32 (Castagnoli) without the IV. 119 : */ 120 : #if HAVE_SSE42 - 121 21365408 : static inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, unsigned size) + 121 21365830 : static inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, unsigned size) 122 : { 123 : #ifdef CONFIG_X86_64 124 : uint64_t crc64 = crc; @@ -191,30 +191,30 @@ 129 : } 130 : crc = crc64; 131 : #else - 132 381730335 : while (size >= 4) { - 133 338999519 : asm("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); - 134 338999519 : ptr += 4; - 135 338999519 : size -= 4; + 132 392452749 : while (size >= 4) { + 133 349721089 : asm("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); + 134 349721089 : ptr += 4; + 135 349721089 : size -= 4; 136 : } 137 : #endif - 138 62071545 : while (size) { - 139 19340729 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); - 140 19340729 : ++ptr; - 141 19340729 : --size; + 138 62466405 : while (size) { + 139 19734745 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); + 140 19734745 : ++ptr; + 141 19734745 : --size; 142 : } 143 : - 144 21365408 : return crc; + 144 21365830 : return crc; 145 : } 146 : #endif 147 : 148 : /** 149 : * Compute CRC-32 (Castagnoli) without the IV. 150 : */ - 151 20718802 : static inline uint32_t crc32c_plain(uint32_t crc, const unsigned char* ptr, unsigned size) + 151 20719227 : static inline uint32_t crc32c_plain(uint32_t crc, const unsigned char* ptr, unsigned size) 152 : { 153 : #if HAVE_SSE42 - 154 20718802 : if (tommy_likely(crc_x86)) { - 155 20718802 : return crc32c_x86_plain(crc, ptr, size); + 154 20719227 : if (tommy_likely(crc_x86)) { + 155 20719227 : return crc32c_x86_plain(crc, ptr, size); 156 : } 157 : #endif 158 0 : return crc32c_gen_plain(crc, ptr, size); diff --git a/cov/index-sort-f.html b/cov/index-sort-f.html index dc826957..ba99cdd3 100644 --- a/cov/index-sort-f.html +++ b/cov/index-sort-f.html @@ -31,18 +31,18 @@ lcov.info Lines: - 10944 - 11891 - 92.0 % + 11014 + 11905 + 92.5 % Date: - 2016-11-06 + 2016-11-21 Functions: - 643 - 660 - 97.4 % + 649 + 664 + 97.7 % @@ -72,12 +72,12 @@ cmdline -
90.2%90.2%
+
90.8%90.8%
- 90.2 % - 8613 / 9548 - 96.6 % - 482 / 499 + 90.8 % + 8683 / 9562 + 97.0 % + 488 / 503 tommyds diff --git a/cov/index-sort-l.html b/cov/index-sort-l.html index 593255cc..6732e9e4 100644 --- a/cov/index-sort-l.html +++ b/cov/index-sort-l.html @@ -31,18 +31,18 @@ lcov.info Lines: - 10944 - 11891 - 92.0 % + 11014 + 11905 + 92.5 % Date: - 2016-11-06 + 2016-11-21 Functions: - 643 - 660 - 97.4 % + 649 + 664 + 97.7 % @@ -72,12 +72,12 @@ cmdline -
90.2%90.2%
+
90.8%90.8%
- 90.2 % - 8613 / 9548 - 96.6 % - 482 / 499 + 90.8 % + 8683 / 9562 + 97.0 % + 488 / 503 raid diff --git a/cov/index.html b/cov/index.html index e06fe00f..d8000377 100644 --- a/cov/index.html +++ b/cov/index.html @@ -31,18 +31,18 @@ lcov.info Lines: - 10944 - 11891 - 92.0 % + 11014 + 11905 + 92.5 % Date: - 2016-11-06 + 2016-11-21 Functions: - 643 - 660 - 97.4 % + 649 + 664 + 97.7 % @@ -72,12 +72,12 @@ cmdline -
90.2%90.2%
+
90.8%90.8%
- 90.2 % - 8613 / 9548 - 96.6 % - 482 / 499 + 90.8 % + 8683 / 9562 + 97.0 % + 488 / 503 raid diff --git a/cov/raid/check.c.func-sort-c.html b/cov/raid/check.c.func-sort-c.html index c9ed8430..359f4f99 100644 --- a/cov/raid/check.c.func-sort-c.html +++ b/cov/raid/check.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/raid/check.c.func.html b/cov/raid/check.c.func.html index d719dc0c..a3e6f425 100644 --- a/cov/raid/check.c.func.html +++ b/cov/raid/check.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/raid/check.c.gcov.html b/cov/raid/check.c.gcov.html index bcf7a6a6..3e42bb82 100644 --- a/cov/raid/check.c.gcov.html +++ b/cov/raid/check.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 diff --git a/cov/raid/combo.h.func-sort-c.html b/cov/raid/combo.h.func-sort-c.html index 32b4f576..8f7c071c 100644 --- a/cov/raid/combo.h.func-sort-c.html +++ b/cov/raid/combo.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/combo.h.func.html b/cov/raid/combo.h.func.html index b7efc478..e0b37946 100644 --- a/cov/raid/combo.h.func.html +++ b/cov/raid/combo.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/combo.h.gcov.html b/cov/raid/combo.h.gcov.html index d55520f8..c9aec85c 100644 --- a/cov/raid/combo.h.gcov.html +++ b/cov/raid/combo.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 @@ -170,10 +170,10 @@ 108 : int i; 109 : 110 : (void)n; /* unused, but kept for clarity */ - 111 207990 : assert(0 < r && r <= n); + 111 207740 : assert(0 < r && r <= n); 112 : - 113 689341 : for (i = 0; i < r; ++i) - 114 481351 : c[i] = i; + 113 688823 : for (i = 0; i < r; ++i) + 114 481083 : c[i] = i; 115 : } 116 : 117 : /** @@ -182,19 +182,19 @@ 120 : */ 121 : static __always_inline int combination_next(int r, int n, int *c) 122 : { - 123 52204 : int i = r - 1; /* present position */ - 124 52204 : int h = n; /* high limit for this position */ + 123 52213 : int i = r - 1; /* present position */ + 124 52213 : int h = n; /* high limit for this position */ 125 : 126 : recurse: 127 : /* next element at position i */ - 128 85077 : ++c[i]; + 128 85086 : ++c[i]; 129 : 130 : /* if the position has reached the max */ - 131 85077 : if (c[i] >= h) { + 131 85086 : if (c[i] >= h) { 132 : 133 : /* if we are at the first level, we have finished */ - 134 45035 : if (i == 0) - 135 12162 : return 0; + 134 45038 : if (i == 0) + 135 12165 : return 0; 136 : 137 : /* increase the previous position */ 138 32873 : --i; @@ -202,16 +202,16 @@ 140 : goto recurse; 141 : } 142 : - 143 40042 : ++i; + 143 40048 : ++i; 144 : 145 : /* initialize all the next positions, if any */ - 146 62587 : while (i < r) { + 146 62593 : while (i < r) { 147 : /* each position start at the next value of the previous one */ 148 22545 : c[i] = c[i - 1] + 1; 149 22545 : ++i; 150 : } 151 : - 152 40042 : return 1; + 152 40048 : return 1; 153 : } 154 : #endif 155 : diff --git a/cov/raid/cpu.h.func-sort-c.html b/cov/raid/cpu.h.func-sort-c.html index a6582f10..1ff1626d 100644 --- a/cov/raid/cpu.h.func-sort-c.html +++ b/cov/raid/cpu.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 12 @@ -61,43 +61,43 @@ raid_cpuid - 2086 + 2093 raid_cpu_match_sse - 1189 + 1193 raid_cpu_has_ssse3 - 589 + 591 raid_cpu_match_avx - 318 + 319 raid_cpu_has_avx2 - 318 + 319 raid_cpu_has_sse2 - 306 + 307 raid_cpu_has_crc32 - 294 + 295 raid_cpu_info - 278 + 279 raid_cpu_is_atom - 274 + 275 raid_cpu_has_slowmult - 270 + 271 raid_xgetbv diff --git a/cov/raid/cpu.h.func.html b/cov/raid/cpu.h.func.html index 70b343e1..72ccd3b3 100644 --- a/cov/raid/cpu.h.func.html +++ b/cov/raid/cpu.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 12 @@ -61,11 +61,11 @@ raid_cpu_has_avx2 - 318 + 319 raid_cpu_has_crc32 - 294 + 295 raid_cpu_has_slowextendedreg @@ -73,35 +73,35 @@ raid_cpu_has_slowmult - 270 + 271 raid_cpu_has_sse2 - 306 + 307 raid_cpu_has_ssse3 - 589 + 591 raid_cpu_info - 278 + 279 raid_cpu_is_atom - 274 + 275 raid_cpu_match_avx - 318 + 319 raid_cpu_match_sse - 1189 + 1193 raid_cpuid - 2086 + 2093 raid_xgetbv diff --git a/cov/raid/cpu.h.gcov.html b/cov/raid/cpu.h.gcov.html index 27729847..f5a1e826 100644 --- a/cov/raid/cpu.h.gcov.html +++ b/cov/raid/cpu.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 12 @@ -79,9 +79,9 @@ 17 : 18 : #ifdef CONFIG_X86 19 : - 20 2086 : static inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t *reg) + 20 2093 : static inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t *reg) 21 : { - 22 2086 : asm volatile ( + 22 2093 : asm volatile ( 23 : #if defined(__i386__) && defined(__PIC__) 24 : /* allow compilation in PIC mode saving ebx */ 25 : "xchgl %%ebx, %1\n" @@ -91,11 +91,11 @@ 29 : : "0" (func_eax), "2" (sub_ecx) 30 : #else 31 : "cpuid\n" - 32 2086 : : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) + 32 2093 : : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) 33 : : "0" (func_eax), "2" (sub_ecx) 34 : #endif 35 : ); - 36 2086 : } + 36 2093 : } 37 : 38 23 : static inline void raid_xgetbv(uint32_t* reg) 39 : { @@ -112,26 +112,26 @@ 50 : 51 : #define CPU_VENDOR_MAX 13 52 : - 53 278 : static inline void raid_cpu_info(char *vendor, unsigned *family, unsigned *model) + 53 279 : static inline void raid_cpu_info(char *vendor, unsigned *family, unsigned *model) 54 : { 55 : uint32_t reg[4]; 56 : unsigned f, ef, m, em; 57 : - 58 278 : raid_cpuid(0, 0, reg); + 58 279 : raid_cpuid(0, 0, reg); 59 : - 60 278 : ((uint32_t*)vendor)[0] = reg[1]; - 61 278 : ((uint32_t*)vendor)[1] = reg[3]; - 62 278 : ((uint32_t*)vendor)[2] = reg[2]; - 63 278 : vendor[12] = 0; + 60 279 : ((uint32_t*)vendor)[0] = reg[1]; + 61 279 : ((uint32_t*)vendor)[1] = reg[3]; + 62 279 : ((uint32_t*)vendor)[2] = reg[2]; + 63 279 : vendor[12] = 0; 64 : - 65 278 : raid_cpuid(1, 0, reg); + 65 279 : raid_cpuid(1, 0, reg); 66 : - 67 278 : f = (reg[0] >> 8) & 0xF; - 68 278 : ef = (reg[0] >> 20) & 0xFF; - 69 278 : m = (reg[0] >> 4) & 0xF; - 70 278 : em = (reg[0] >> 16) & 0xF; + 67 279 : f = (reg[0] >> 8) & 0xF; + 68 279 : ef = (reg[0] >> 20) & 0xFF; + 69 279 : m = (reg[0] >> 4) & 0xF; + 70 279 : em = (reg[0] >> 16) & 0xF; 71 : - 72 278 : if (strcmp(vendor, "AuthenticAMD") == 0) { + 72 279 : if (strcmp(vendor, "AuthenticAMD") == 0) { 73 0 : if (f < 15) { 74 0 : *family = f; 75 0 : *model = m; @@ -140,31 +140,31 @@ 78 0 : *model = m + (em << 4); 79 : } 80 : } else { - 81 278 : *family = f + ef; - 82 278 : *model = m + (em << 4); + 81 279 : *family = f + ef; + 82 279 : *model = m + (em << 4); 83 : } - 84 278 : } + 84 279 : } 85 : - 86 1189 : static inline int raid_cpu_match_sse(uint32_t cpuid_1_ecx, uint32_t cpuid_1_edx) + 86 1193 : static inline int raid_cpu_match_sse(uint32_t cpuid_1_ecx, uint32_t cpuid_1_edx) 87 : { 88 : uint32_t reg[4]; 89 : - 90 1189 : raid_cpuid(1, 0, reg); - 91 1189 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) + 90 1193 : raid_cpuid(1, 0, reg); + 91 1193 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) 92 18 : return 0; - 93 1171 : if ((reg[3] & cpuid_1_edx) != cpuid_1_edx) + 93 1175 : if ((reg[3] & cpuid_1_edx) != cpuid_1_edx) 94 0 : return 0; 95 : - 96 1171 : return 1; + 96 1175 : return 1; 97 : } 98 : - 99 318 : static inline int raid_cpu_match_avx(uint32_t cpuid_1_ecx, uint32_t cpuid_7_ebx, uint32_t xcr0) + 99 319 : static inline int raid_cpu_match_avx(uint32_t cpuid_1_ecx, uint32_t cpuid_7_ebx, uint32_t xcr0) 100 : { 101 : uint32_t reg[4]; 102 : - 103 318 : raid_cpuid(1, 0, reg); - 104 318 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) - 105 295 : return 0; + 103 319 : raid_cpuid(1, 0, reg); + 104 319 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) + 105 296 : return 0; 106 : 107 23 : raid_xgetbv(reg); 108 23 : if ((reg[0] & xcr0) != xcr0) @@ -177,7 +177,7 @@ 115 23 : return 1; 116 : } 117 : - 118 306 : static inline int raid_cpu_has_sse2(void) + 118 307 : static inline int raid_cpu_has_sse2(void) 119 : { 120 : /* 121 : * Intel® 64 and IA-32 Architectures Software Developer's Manual @@ -191,12 +191,12 @@ 129 : * 2. Check that the processor supports the SSE and/or SSE2 extensions (true if 130 : * CPUID.01H:EDX.SSE[bit 25] = 1 and/or CPUID.01H:EDX.SSE2[bit 26] = 1). 131 : */ - 132 306 : return raid_cpu_match_sse( + 132 307 : return raid_cpu_match_sse( 133 : 0, 134 : 1 << 26); /* SSE2 */ 135 : } 136 : - 137 589 : static inline int raid_cpu_has_ssse3(void) + 137 591 : static inline int raid_cpu_has_ssse3(void) 138 : { 139 : /* 140 : * Intel® 64 and IA-32 Architectures Software Developer's Manual @@ -208,12 +208,12 @@ 146 : * Next, use the additional step provided below: 147 : * Check that the processor supports SSSE3 (if CPUID.01H:ECX.SSSE3[bit 9] = 1). 148 : */ - 149 589 : return raid_cpu_match_sse( + 149 591 : return raid_cpu_match_sse( 150 : 1 << 9, /* SSSE3 */ 151 : 1 << 26); /* SSE2 */ 152 : } 153 : - 154 294 : static inline int raid_cpu_has_crc32(void) + 154 295 : static inline int raid_cpu_has_crc32(void) 155 : { 156 : /* 157 : * Intel® 64 and IA-32 Architectures Software Developer's Manual @@ -224,12 +224,12 @@ 162 : * Before an application attempts to use the CRC32 instruction, it must check 163 : * that the processor supports SSE4.2 (if CPUID.01H:ECX.SSE4_2[bit 20] = 1). 164 : */ - 165 294 : return raid_cpu_match_sse( + 165 295 : return raid_cpu_match_sse( 166 : 1 << 20, /* CRC32 */ 167 : 0); 168 : } 169 : - 170 318 : static inline int raid_cpu_has_avx2(void) + 170 319 : static inline int raid_cpu_has_avx2(void) 171 : { 172 : /* 173 : * Intel Architecture Instruction Set Extensions Programming Reference @@ -246,7 +246,7 @@ 184 : * Application Software must identify that hardware supports AVX, after that it must 185 : * also detect support for AVX2 by checking CPUID.(EAX=07H, ECX=0H):EBX.AVX2[bit 5]. 186 : */ - 187 318 : return raid_cpu_match_avx( + 187 319 : return raid_cpu_match_avx( 188 : (1 << 27) | (1 << 28), /* OSXSAVE and AVX */ 189 : 1 << 5, /* AVX2 */ 190 : 3 << 1); /* OS saves XMM and YMM registers */ @@ -277,9 +277,9 @@ 215 : /** 216 : * Check if it's an Intel Atom CPU. 217 : */ - 218 274 : static inline int raid_cpu_is_atom(unsigned family, unsigned model) + 218 275 : static inline int raid_cpu_is_atom(unsigned family, unsigned model) 219 : { - 220 274 : if (family != 6) + 220 275 : if (family != 6) 221 3 : return 0; 222 : 223 : /* @@ -300,17 +300,17 @@ 238 : * 4D (77) Atom 8C (22 nm) 4 MB L2 (AVN) 239 : * ?? Atom ?C (14 nm) ? MB L2 (DVN) 240 : */ - 241 542 : return model == 28 || model == 38 || model == 54 - 242 271 : || model == 39 || model == 53 || model == 74 - 243 271 : || model == 90 || model == 55 || model == 76 - 244 542 : || model == 93 || model == 77; + 241 544 : return model == 28 || model == 38 || model == 54 + 242 272 : || model == 39 || model == 53 || model == 74 + 243 272 : || model == 90 || model == 55 || model == 76 + 244 544 : || model == 93 || model == 77; 245 : } 246 : 247 : /** 248 : * Check if the processor has a slow MULT implementation. 249 : * If yes, it's better to use a hash not based on multiplication. 250 : */ - 251 270 : static inline int raid_cpu_has_slowmult(void) + 251 271 : static inline int raid_cpu_has_slowmult(void) 252 : { 253 : char vendor[CPU_VENDOR_MAX]; 254 : unsigned family; @@ -320,9 +320,9 @@ 258 : * In some cases Murmur3 based on MUL instruction, 259 : * is a LOT slower than Spooky2 based on SHIFTs. 260 : */ - 261 270 : raid_cpu_info(vendor, &family, &model); + 261 271 : raid_cpu_info(vendor, &family, &model); 262 : - 263 270 : if (strcmp(vendor, "GenuineIntel") == 0) { + 263 271 : if (strcmp(vendor, "GenuineIntel") == 0) { 264 : /* 265 : * Intel Atom (Model 28) 266 : * murmur3:378 MB/s, spooky2:3413 MB/s (x86) @@ -330,11 +330,11 @@ 268 : * Intel Atom (Model 77) 269 : * murmur3:1311 MB/s, spooky2:4056 MB/s (x64) 270 : */ - 271 270 : if (raid_cpu_is_atom(family, model)) + 271 271 : if (raid_cpu_is_atom(family, model)) 272 0 : return 1; 273 : } 274 : - 275 270 : return 0; + 275 271 : return 0; 276 : } 277 : 278 : /** diff --git a/cov/raid/gf.h.func-sort-c.html b/cov/raid/gf.h.func-sort-c.html index 39199255..87a1b765 100644 --- a/cov/raid/gf.h.func-sort-c.html +++ b/cov/raid/gf.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/gf.h.func.html b/cov/raid/gf.h.func.html index f1dfa8e8..fa1b1d4c 100644 --- a/cov/raid/gf.h.func.html +++ b/cov/raid/gf.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/gf.h.gcov.html b/cov/raid/gf.h.gcov.html index 4eb56dc0..51d692be 100644 --- a/cov/raid/gf.h.gcov.html +++ b/cov/raid/gf.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 @@ -88,7 +88,7 @@ 26 : */ 27 : static __always_inline uint8_t mul(uint8_t a, uint8_t b) 28 : { - 29 23792058 : return gfmul[a][b]; + 29 23791770 : return gfmul[a][b]; 30 : } 31 : 32 : /* @@ -97,9 +97,9 @@ 35 : */ 36 : static __always_inline uint8_t inv(uint8_t v) 37 : { - 38 635454 : BUG_ON(v == 0); /* division by zero */ + 38 635424 : BUG_ON(v == 0); /* division by zero */ 39 : - 40 635454 : return gfinv[v]; + 40 635424 : return gfinv[v]; 41 : } 42 : 43 : /* @@ -125,7 +125,7 @@ 63 : */ 64 : static __always_inline uint8_t A(int p, int d) 65 : { - 66 2604488 : return gfgen[p][d]; + 66 2604422 : return gfgen[p][d]; 67 : } 68 : 69 : /* @@ -161,12 +161,12 @@ 99 : */ 100 : static __always_inline uint64_t x2_64(uint64_t v) 101 : { - 102 16059296 : uint64_t mask = v & 0x8080808080808080ULL; + 102 16288672 : uint64_t mask = v & 0x8080808080808080ULL; 103 : - 104 16059296 : mask = (mask << 1) - (mask >> 7); - 105 16059296 : v = (v << 1) & 0xfefefefefefefefeULL; - 106 16059296 : v ^= mask & 0x1d1d1d1d1d1d1d1dULL; - 107 16059296 : return v; + 104 16288672 : mask = (mask << 1) - (mask >> 7); + 105 16288672 : v = (v << 1) & 0xfefefefefefefefeULL; + 106 16288672 : v ^= mask & 0x1d1d1d1d1d1d1d1dULL; + 107 16288672 : return v; 108 : } 109 : 110 : /* @@ -174,12 +174,12 @@ 112 : */ 113 : static __always_inline uint32_t d2_32(uint32_t v) 114 : { - 115 12388288 : uint32_t mask = v & 0x01010101U; + 115 12847040 : uint32_t mask = v & 0x01010101U; 116 : - 117 12388288 : mask = (mask << 8) - mask; - 118 12388288 : v = (v >> 1) & 0x7f7f7f7fU; - 119 12388288 : v ^= mask & 0x8e8e8e8eU; - 120 12388288 : return v; + 117 12847040 : mask = (mask << 8) - mask; + 118 12847040 : v = (v >> 1) & 0x7f7f7f7fU; + 119 12847040 : v ^= mask & 0x8e8e8e8eU; + 120 12847040 : return v; 121 : } 122 : 123 : /* diff --git a/cov/raid/helper.c.func-sort-c.html b/cov/raid/helper.c.func-sort-c.html index da620c0b..5f219c44 100644 --- a/cov/raid/helper.c.func-sort-c.html +++ b/cov/raid/helper.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/raid/helper.c.func.html b/cov/raid/helper.c.func.html index 30df53d6..4f2ba325 100644 --- a/cov/raid/helper.c.func.html +++ b/cov/raid/helper.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/raid/helper.c.gcov.html b/cov/raid/helper.c.gcov.html index 8815c970..7807e32c 100644 --- a/cov/raid/helper.c.gcov.html +++ b/cov/raid/helper.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/raid/index-sort-f.html b/cov/raid/index-sort-f.html index 414d4725..f76853ec 100644 --- a/cov/raid/index-sort-f.html +++ b/cov/raid/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 85 diff --git a/cov/raid/index-sort-l.html b/cov/raid/index-sort-l.html index 20edac5d..b0f2e8de 100644 --- a/cov/raid/index-sort-l.html +++ b/cov/raid/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 85 diff --git a/cov/raid/index.html b/cov/raid/index.html index 7b6cf792..05eee1e7 100644 --- a/cov/raid/index.html +++ b/cov/raid/index.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 85 diff --git a/cov/raid/int.c.func-sort-c.html b/cov/raid/int.c.func-sort-c.html index ae0ae4fb..3f2b190f 100644 --- a/cov/raid/int.c.func-sort-c.html +++ b/cov/raid/int.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -69,7 +69,7 @@ raid_gen1_int64 - 182 + 180 raid_rec1_int8 @@ -77,15 +77,15 @@ raid_gen1_int32 - 117 - - - raid_gen2_int32 - 47 + 113 raid_gen2_int64 - 45 + 46 + + + raid_gen2_int32 + 46 raid_gen3_int8 @@ -97,7 +97,7 @@ raid_gen5_int8 - 17 + 18 raid_gen6_int8 diff --git a/cov/raid/int.c.func.html b/cov/raid/int.c.func.html index 1fff2bee..9510bc38 100644 --- a/cov/raid/int.c.func.html +++ b/cov/raid/int.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -61,19 +61,19 @@ raid_gen1_int32 - 117 + 113 raid_gen1_int64 - 182 + 180 raid_gen2_int32 - 47 + 46 raid_gen2_int64 - 45 + 46 raid_gen3_int8 @@ -85,7 +85,7 @@ raid_gen5_int8 - 17 + 18 raid_gen6_int8 diff --git a/cov/raid/int.c.gcov.html b/cov/raid/int.c.gcov.html index 0dbb07c5..3ef0c5f6 100644 --- a/cov/raid/int.c.gcov.html +++ b/cov/raid/int.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -80,9 +80,9 @@ 18 : /* 19 : * GEN1 (RAID5 with xor) 32bit C implementation 20 : */ - 21 117 : void raid_gen1_int32(int nd, size_t size, void **vv) + 21 113 : void raid_gen1_int32(int nd, size_t size, void **vv) 22 : { - 23 117 : uint8_t **v = (uint8_t **)vv; + 23 113 : uint8_t **v = (uint8_t **)vv; 24 : uint8_t *p; 25 : int d, l; 26 : size_t i; @@ -90,27 +90,27 @@ 28 : uint32_t p0; 29 : uint32_t p1; 30 : - 31 117 : l = nd - 1; - 32 117 : p = v[nd]; + 31 113 : l = nd - 1; + 32 113 : p = v[nd]; 33 : - 34 3735765 : for (i = 0; i < size; i += 8) { - 35 3735648 : p0 = v_32(v[l][i]); - 36 3735648 : p1 = v_32(v[l][i + 4]); - 37 29886496 : for (d = l - 1; d >= 0; --d) { - 38 26150848 : p0 ^= v_32(v[d][i]); - 39 26150848 : p1 ^= v_32(v[d][i + 4]); + 34 3604689 : for (i = 0; i < size; i += 8) { + 35 3604576 : p0 = v_32(v[l][i]); + 36 3604576 : p1 = v_32(v[l][i + 4]); + 37 28837920 : for (d = l - 1; d >= 0; --d) { + 38 25233344 : p0 ^= v_32(v[d][i]); + 39 25233344 : p1 ^= v_32(v[d][i + 4]); 40 : } - 41 3735648 : v_32(p[i]) = p0; - 42 3735648 : v_32(p[i + 4]) = p1; + 41 3604576 : v_32(p[i]) = p0; + 42 3604576 : v_32(p[i + 4]) = p1; 43 : } - 44 117 : } + 44 113 : } 45 : 46 : /* 47 : * GEN1 (RAID5 with xor) 64bit C implementation 48 : */ - 49 182 : void raid_gen1_int64(int nd, size_t size, void **vv) + 49 180 : void raid_gen1_int64(int nd, size_t size, void **vv) 50 : { - 51 182 : uint8_t **v = (uint8_t **)vv; + 51 180 : uint8_t **v = (uint8_t **)vv; 52 : uint8_t *p; 53 : int d, l; 54 : size_t i; @@ -118,27 +118,27 @@ 56 : uint64_t p0; 57 : uint64_t p1; 58 : - 59 182 : l = nd - 1; - 60 182 : p = v[nd]; + 59 180 : l = nd - 1; + 60 180 : p = v[nd]; 61 : - 62 2932966 : for (i = 0; i < size; i += 16) { - 63 2932784 : p0 = v_64(v[l][i]); - 64 2932784 : p1 = v_64(v[l][i + 8]); - 65 23462928 : for (d = l - 1; d >= 0; --d) { - 66 20530144 : p0 ^= v_64(v[d][i]); - 67 20530144 : p1 ^= v_64(v[d][i + 8]); + 62 2900196 : for (i = 0; i < size; i += 16) { + 63 2900016 : p0 = v_64(v[l][i]); + 64 2900016 : p1 = v_64(v[l][i + 8]); + 65 23200784 : for (d = l - 1; d >= 0; --d) { + 66 20300768 : p0 ^= v_64(v[d][i]); + 67 20300768 : p1 ^= v_64(v[d][i + 8]); 68 : } - 69 2932784 : v_64(p[i]) = p0; - 70 2932784 : v_64(p[i + 8]) = p1; + 69 2900016 : v_64(p[i]) = p0; + 70 2900016 : v_64(p[i + 8]) = p1; 71 : } - 72 182 : } + 72 180 : } 73 : 74 : /* 75 : * GEN2 (RAID6 with powers of 2) 32bit C implementation 76 : */ - 77 47 : void raid_gen2_int32(int nd, size_t size, void **vv) + 77 46 : void raid_gen2_int32(int nd, size_t size, void **vv) 78 : { - 79 47 : uint8_t **v = (uint8_t **)vv; + 79 46 : uint8_t **v = (uint8_t **)vv; 80 : uint8_t *p; 81 : uint8_t *q; 82 : int d, l; @@ -147,39 +147,39 @@ 85 : uint32_t d0, q0, p0; 86 : uint32_t d1, q1, p1; 87 : - 88 47 : l = nd - 1; - 89 47 : p = v[nd]; - 90 47 : q = v[nd + 1]; + 88 46 : l = nd - 1; + 89 46 : p = v[nd]; + 90 46 : q = v[nd + 1]; 91 : - 92 1441935 : for (i = 0; i < size; i += 8) { - 93 1441888 : q0 = p0 = v_32(v[l][i]); - 94 1441888 : q1 = p1 = v_32(v[l][i + 4]); - 95 11536416 : for (d = l - 1; d >= 0; --d) { - 96 10094528 : d0 = v_32(v[d][i]); - 97 10094528 : d1 = v_32(v[d][i + 4]); + 92 1409166 : for (i = 0; i < size; i += 8) { + 93 1409120 : q0 = p0 = v_32(v[l][i]); + 94 1409120 : q1 = p1 = v_32(v[l][i + 4]); + 95 11274272 : for (d = l - 1; d >= 0; --d) { + 96 9865152 : d0 = v_32(v[d][i]); + 97 9865152 : d1 = v_32(v[d][i + 4]); 98 : - 99 10094528 : p0 ^= d0; - 100 10094528 : p1 ^= d1; + 99 9865152 : p0 ^= d0; + 100 9865152 : p1 ^= d1; 101 : - 102 10094528 : q0 = x2_32(q0); - 103 10094528 : q1 = x2_32(q1); + 102 9865152 : q0 = x2_32(q0); + 103 9865152 : q1 = x2_32(q1); 104 : - 105 10094528 : q0 ^= d0; - 106 10094528 : q1 ^= d1; + 105 9865152 : q0 ^= d0; + 106 9865152 : q1 ^= d1; 107 : } - 108 1441888 : v_32(p[i]) = p0; - 109 1441888 : v_32(p[i + 4]) = p1; - 110 1441888 : v_32(q[i]) = q0; - 111 1441888 : v_32(q[i + 4]) = q1; + 108 1409120 : v_32(p[i]) = p0; + 109 1409120 : v_32(p[i + 4]) = p1; + 110 1409120 : v_32(q[i]) = q0; + 111 1409120 : v_32(q[i + 4]) = q1; 112 : } - 113 47 : } + 113 46 : } 114 : 115 : /* 116 : * GEN2 (RAID6 with powers of 2) 64bit C implementation 117 : */ - 118 45 : void raid_gen2_int64(int nd, size_t size, void **vv) + 118 46 : void raid_gen2_int64(int nd, size_t size, void **vv) 119 : { - 120 45 : uint8_t **v = (uint8_t **)vv; + 120 46 : uint8_t **v = (uint8_t **)vv; 121 : uint8_t *p; 122 : uint8_t *q; 123 : int d, l; @@ -188,32 +188,32 @@ 126 : uint64_t d0, q0, p0; 127 : uint64_t d1, q1, p1; 128 : - 129 45 : l = nd - 1; - 130 45 : p = v[nd]; - 131 45 : q = v[nd + 1]; + 129 46 : l = nd - 1; + 130 46 : p = v[nd]; + 131 46 : q = v[nd + 1]; 132 : - 133 688221 : for (i = 0; i < size; i += 16) { - 134 688176 : q0 = p0 = v_64(v[l][i]); - 135 688176 : q1 = p1 = v_64(v[l][i + 8]); - 136 5506064 : for (d = l - 1; d >= 0; --d) { - 137 4817888 : d0 = v_64(v[d][i]); - 138 4817888 : d1 = v_64(v[d][i + 8]); + 133 704606 : for (i = 0; i < size; i += 16) { + 134 704560 : q0 = p0 = v_64(v[l][i]); + 135 704560 : q1 = p1 = v_64(v[l][i + 8]); + 136 5637136 : for (d = l - 1; d >= 0; --d) { + 137 4932576 : d0 = v_64(v[d][i]); + 138 4932576 : d1 = v_64(v[d][i + 8]); 139 : - 140 4817888 : p0 ^= d0; - 141 4817888 : p1 ^= d1; + 140 4932576 : p0 ^= d0; + 141 4932576 : p1 ^= d1; 142 : - 143 4817888 : q0 = x2_64(q0); - 144 4817888 : q1 = x2_64(q1); + 143 4932576 : q0 = x2_64(q0); + 144 4932576 : q1 = x2_64(q1); 145 : - 146 4817888 : q0 ^= d0; - 147 4817888 : q1 ^= d1; + 146 4932576 : q0 ^= d0; + 147 4932576 : q1 ^= d1; 148 : } - 149 688176 : v_64(p[i]) = p0; - 150 688176 : v_64(p[i + 8]) = p1; - 151 688176 : v_64(q[i]) = q0; - 152 688176 : v_64(q[i + 8]) = q1; + 149 704560 : v_64(p[i]) = p0; + 150 704560 : v_64(p[i + 8]) = p1; + 151 704560 : v_64(q[i]) = q0; + 152 704560 : v_64(q[i + 8]) = q1; 153 : } - 154 45 : } + 154 46 : } 155 : 156 : /* 157 : * GEN3 (triple parity with Cauchy matrix) 8bit C implementation @@ -322,9 +322,9 @@ 260 : * But this is only a kind of reference function, and we are not really 261 : * interested in speed. 262 : */ - 263 17 : void raid_gen5_int8(int nd, size_t size, void **vv) + 263 18 : void raid_gen5_int8(int nd, size_t size, void **vv) 264 : { - 265 17 : uint8_t **v = (uint8_t **)vv; + 265 18 : uint8_t **v = (uint8_t **)vv; 266 : uint8_t *p; 267 : uint8_t *q; 268 : uint8_t *r; @@ -335,41 +335,41 @@ 273 : 274 : uint8_t d0, t0, s0, r0, q0, p0; 275 : - 276 17 : l = nd - 1; - 277 17 : p = v[nd]; - 278 17 : q = v[nd + 1]; - 279 17 : r = v[nd + 2]; - 280 17 : s = v[nd + 3]; - 281 17 : t = v[nd + 4]; + 276 18 : l = nd - 1; + 277 18 : p = v[nd]; + 278 18 : q = v[nd + 1]; + 279 18 : r = v[nd + 2]; + 280 18 : s = v[nd + 3]; + 281 18 : t = v[nd + 4]; 282 : - 283 3932689 : for (i = 0; i < size; i += 1) { - 284 3932672 : p0 = q0 = r0 = s0 = t0 = 0; - 285 31465728 : for (d = l; d > 0; --d) { - 286 27533056 : d0 = v_8(v[d][i]); + 283 4194834 : for (i = 0; i < size; i += 1) { + 284 4194816 : p0 = q0 = r0 = s0 = t0 = 0; + 285 33562880 : for (d = l; d > 0; --d) { + 286 29368064 : d0 = v_8(v[d][i]); 287 : - 288 27533056 : p0 ^= d0; - 289 27533056 : q0 ^= gfmul[d0][gfgen[1][d]]; - 290 27533056 : r0 ^= gfmul[d0][gfgen[2][d]]; - 291 27533056 : s0 ^= gfmul[d0][gfgen[3][d]]; - 292 27533056 : t0 ^= gfmul[d0][gfgen[4][d]]; + 288 29368064 : p0 ^= d0; + 289 29368064 : q0 ^= gfmul[d0][gfgen[1][d]]; + 290 29368064 : r0 ^= gfmul[d0][gfgen[2][d]]; + 291 29368064 : s0 ^= gfmul[d0][gfgen[3][d]]; + 292 29368064 : t0 ^= gfmul[d0][gfgen[4][d]]; 293 : } 294 : 295 : /* first disk with all coefficients at 1 */ - 296 3932672 : d0 = v_8(v[0][i]); + 296 4194816 : d0 = v_8(v[0][i]); 297 : - 298 3932672 : p0 ^= d0; - 299 3932672 : q0 ^= d0; - 300 3932672 : r0 ^= d0; - 301 3932672 : s0 ^= d0; - 302 3932672 : t0 ^= d0; + 298 4194816 : p0 ^= d0; + 299 4194816 : q0 ^= d0; + 300 4194816 : r0 ^= d0; + 301 4194816 : s0 ^= d0; + 302 4194816 : t0 ^= d0; 303 : - 304 3932672 : v_8(p[i]) = p0; - 305 3932672 : v_8(q[i]) = q0; - 306 3932672 : v_8(r[i]) = r0; - 307 3932672 : v_8(s[i]) = s0; - 308 3932672 : v_8(t[i]) = t0; + 304 4194816 : v_8(p[i]) = p0; + 305 4194816 : v_8(q[i]) = q0; + 306 4194816 : v_8(r[i]) = r0; + 307 4194816 : v_8(s[i]) = s0; + 308 4194816 : v_8(t[i]) = t0; 309 : } - 310 17 : } + 310 18 : } 311 : 312 : /* 313 : * GEN6 (hexa parity with Cauchy matrix) 8bit C implementation diff --git a/cov/raid/internal.h.func-sort-c.html b/cov/raid/internal.h.func-sort-c.html index 15b7beef..52c3bb25 100644 --- a/cov/raid/internal.h.func-sort-c.html +++ b/cov/raid/internal.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/internal.h.func.html b/cov/raid/internal.h.func.html index 9a7d4543..45ac5440 100644 --- a/cov/raid/internal.h.func.html +++ b/cov/raid/internal.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 diff --git a/cov/raid/internal.h.gcov.html b/cov/raid/internal.h.gcov.html index afad0a9c..8958d14c 100644 --- a/cov/raid/internal.h.gcov.html +++ b/cov/raid/internal.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 0 @@ -169,11 +169,11 @@ 107 : */ 108 : static __always_inline void *__align_ptr(void *ptr, uintptr_t size) 109 : { - 110 711919 : uintptr_t offset = (uintptr_t)ptr; + 110 711884 : uintptr_t offset = (uintptr_t)ptr; 111 : - 112 711919 : offset = (offset + size - 1U) & ~(size - 1U); + 112 711884 : offset = (offset + size - 1U) & ~(size - 1U); 113 : - 114 711919 : return (void *)offset; + 114 711884 : return (void *)offset; 115 : } 116 : 117 : /* @@ -294,7 +294,7 @@ 232 : /* that use a weak memory model. To ensure that other processors */ 233 : /* see correctly the data written, we use a store-store memory */ 234 : /* barrier at the end of the asm code */ - 235 1388842 : asm volatile ("sfence" : : : "memory"); + 235 1388567 : asm volatile ("sfence" : : : "memory"); 236 : 237 : /* clobbers registers used in the asm code */ 238 : /* this is required because in the Windows ABI, */ @@ -327,7 +327,7 @@ 265 : /* reset the upper part of the ymm registers */ 266 : /* to avoid the 70 clocks penality on the next */ 267 : /* xmm register use */ - 268 19675 : asm volatile ("vzeroupper" : : : "memory"); + 268 19674 : asm volatile ("vzeroupper" : : : "memory"); 269 : } 270 : #endif 271 : #endif /* CONFIG_X86 */ diff --git a/cov/raid/intz.c.func-sort-c.html b/cov/raid/intz.c.func-sort-c.html index ffbcc252..18ef6699 100644 --- a/cov/raid/intz.c.func-sort-c.html +++ b/cov/raid/intz.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -65,7 +65,7 @@ raid_genz_int32 - 28 + 29
diff --git a/cov/raid/intz.c.func.html b/cov/raid/intz.c.func.html index 6d2291be..55de5b7d 100644 --- a/cov/raid/intz.c.func.html +++ b/cov/raid/intz.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,7 +61,7 @@ raid_genz_int32 - 28 + 29 raid_genz_int64 diff --git a/cov/raid/intz.c.gcov.html b/cov/raid/intz.c.gcov.html index 635e0eb1..cde048b4 100644 --- a/cov/raid/intz.c.gcov.html +++ b/cov/raid/intz.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -80,9 +80,9 @@ 18 : /* 19 : * GENz (triple parity with powers of 2^-1) 32bit C implementation 20 : */ - 21 28 : void raid_genz_int32(int nd, size_t size, void **vv) + 21 29 : void raid_genz_int32(int nd, size_t size, void **vv) 22 : { - 23 28 : uint8_t **v = (uint8_t**)vv; + 23 29 : uint8_t **v = (uint8_t**)vv; 24 : uint8_t *p; 25 : uint8_t *q; 26 : uint8_t *r; @@ -92,41 +92,41 @@ 30 : uint32_t d0, r0, q0, p0; 31 : uint32_t d1, r1, q1, p1; 32 : - 33 28 : l = nd - 1; - 34 28 : p = v[nd]; - 35 28 : q = v[nd + 1]; - 36 28 : r = v[nd + 2]; + 33 29 : l = nd - 1; + 34 29 : p = v[nd]; + 35 29 : q = v[nd + 1]; + 36 29 : r = v[nd + 2]; 37 : - 38 884796 : for (i = 0; i < size; i += 8) { - 39 884768 : r0 = q0 = p0 = v_32(v[l][i]); - 40 884768 : r1 = q1 = p1 = v_32(v[l][i + 4]); - 41 7078912 : for (d = l - 1; d >= 0; --d) { - 42 6194144 : d0 = v_32(v[d][i]); - 43 6194144 : d1 = v_32(v[d][i + 4]); + 38 917565 : for (i = 0; i < size; i += 8) { + 39 917536 : r0 = q0 = p0 = v_32(v[l][i]); + 40 917536 : r1 = q1 = p1 = v_32(v[l][i + 4]); + 41 7341056 : for (d = l - 1; d >= 0; --d) { + 42 6423520 : d0 = v_32(v[d][i]); + 43 6423520 : d1 = v_32(v[d][i + 4]); 44 : - 45 6194144 : p0 ^= d0; - 46 6194144 : p1 ^= d1; + 45 6423520 : p0 ^= d0; + 46 6423520 : p1 ^= d1; 47 : - 48 6194144 : q0 = x2_32(q0); - 49 6194144 : q1 = x2_32(q1); + 48 6423520 : q0 = x2_32(q0); + 49 6423520 : q1 = x2_32(q1); 50 : - 51 6194144 : q0 ^= d0; - 52 6194144 : q1 ^= d1; + 51 6423520 : q0 ^= d0; + 52 6423520 : q1 ^= d1; 53 : - 54 6194144 : r0 = d2_32(r0); - 55 6194144 : r1 = d2_32(r1); + 54 6423520 : r0 = d2_32(r0); + 55 6423520 : r1 = d2_32(r1); 56 : - 57 6194144 : r0 ^= d0; - 58 6194144 : r1 ^= d1; + 57 6423520 : r0 ^= d0; + 58 6423520 : r1 ^= d1; 59 : } - 60 884768 : v_32(p[i]) = p0; - 61 884768 : v_32(p[i + 4]) = p1; - 62 884768 : v_32(q[i]) = q0; - 63 884768 : v_32(q[i + 4]) = q1; - 64 884768 : v_32(r[i]) = r0; - 65 884768 : v_32(r[i + 4]) = r1; + 60 917536 : v_32(p[i]) = p0; + 61 917536 : v_32(p[i + 4]) = p1; + 62 917536 : v_32(q[i]) = q0; + 63 917536 : v_32(q[i + 4]) = q1; + 64 917536 : v_32(r[i]) = r0; + 65 917536 : v_32(r[i + 4]) = r1; 66 : } - 67 28 : } + 67 29 : } 68 : 69 : /* 70 : * GENz (triple parity with powers of 2^-1) 64bit C implementation diff --git a/cov/raid/memory.c.func-sort-c.html b/cov/raid/memory.c.func-sort-c.html index 400cab45..e5414239 100644 --- a/cov/raid/memory.c.func-sort-c.html +++ b/cov/raid/memory.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 diff --git a/cov/raid/memory.c.func.html b/cov/raid/memory.c.func.html index ed9cc46b..c41407b0 100644 --- a/cov/raid/memory.c.func.html +++ b/cov/raid/memory.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 diff --git a/cov/raid/memory.c.gcov.html b/cov/raid/memory.c.gcov.html index c141cae2..f256592a 100644 --- a/cov/raid/memory.c.gcov.html +++ b/cov/raid/memory.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 6 @@ -94,7 +94,7 @@ 32 12558 : offset = ((uintptr_t)ptr) % align_size; 33 : 34 12558 : if (offset != 0) - 35 12171 : ptr += align_size - offset; + 35 12172 : ptr += align_size - offset; 36 : 37 12558 : return ptr; 38 : } diff --git a/cov/raid/module.c.func-sort-c.html b/cov/raid/module.c.func-sort-c.html index 185903de..ec79fad3 100644 --- a/cov/raid/module.c.func-sort-c.html +++ b/cov/raid/module.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -61,7 +61,7 @@ raid_init - 270 + 271 raid_test_rec diff --git a/cov/raid/module.c.func.html b/cov/raid/module.c.func.html index 7d71c214..dea2069a 100644 --- a/cov/raid/module.c.func.html +++ b/cov/raid/module.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -65,7 +65,7 @@ raid_init - 270 + 271 raid_selftest diff --git a/cov/raid/module.c.gcov.html b/cov/raid/module.c.gcov.html index 4b69d7ae..5da7dd67 100644 --- a/cov/raid/module.c.gcov.html +++ b/cov/raid/module.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 @@ -81,34 +81,34 @@ 19 : /* 20 : * Initializes and selects the best algorithm. 21 : */ - 22 270 : void raid_init(void) + 22 271 : void raid_init(void) 23 : { - 24 270 : raid_gen3_ptr = raid_gen3_int8; - 25 270 : raid_gen_ptr[3] = raid_gen4_int8; - 26 270 : raid_gen_ptr[4] = raid_gen5_int8; - 27 270 : raid_gen_ptr[5] = raid_gen6_int8; + 24 271 : raid_gen3_ptr = raid_gen3_int8; + 25 271 : raid_gen_ptr[3] = raid_gen4_int8; + 26 271 : raid_gen_ptr[4] = raid_gen5_int8; + 27 271 : raid_gen_ptr[5] = raid_gen6_int8; 28 : 29 : if (sizeof(void *) == 4) { - 30 270 : raid_gen_ptr[0] = raid_gen1_int32; - 31 270 : raid_gen_ptr[1] = raid_gen2_int32; - 32 270 : raid_genz_ptr = raid_genz_int32; + 30 271 : raid_gen_ptr[0] = raid_gen1_int32; + 31 271 : raid_gen_ptr[1] = raid_gen2_int32; + 32 271 : raid_genz_ptr = raid_genz_int32; 33 : } else { 34 : raid_gen_ptr[0] = raid_gen1_int64; 35 : raid_gen_ptr[1] = raid_gen2_int64; 36 : raid_genz_ptr = raid_genz_int64; 37 : } 38 : - 39 270 : raid_rec_ptr[0] = raid_rec1_int8; - 40 270 : raid_rec_ptr[1] = raid_rec2_int8; - 41 270 : raid_rec_ptr[2] = raid_recX_int8; - 42 270 : raid_rec_ptr[3] = raid_recX_int8; - 43 270 : raid_rec_ptr[4] = raid_recX_int8; - 44 270 : raid_rec_ptr[5] = raid_recX_int8; + 39 271 : raid_rec_ptr[0] = raid_rec1_int8; + 40 271 : raid_rec_ptr[1] = raid_rec2_int8; + 41 271 : raid_rec_ptr[2] = raid_recX_int8; + 42 271 : raid_rec_ptr[3] = raid_recX_int8; + 43 271 : raid_rec_ptr[4] = raid_recX_int8; + 44 271 : raid_rec_ptr[5] = raid_recX_int8; 45 : 46 : #ifdef CONFIG_X86 47 : #ifdef CONFIG_SSE2 - 48 270 : if (raid_cpu_has_sse2()) { - 49 270 : raid_gen_ptr[0] = raid_gen1_sse2; + 48 271 : if (raid_cpu_has_sse2()) { + 49 271 : raid_gen_ptr[0] = raid_gen1_sse2; 50 : #ifdef CONFIG_X86_64 51 : if (raid_cpu_has_slowextendedreg()) { 52 : raid_gen_ptr[1] = raid_gen2_sse2; @@ -118,14 +118,14 @@ 56 : /* note that raid_cpu_has_slowextendedreg() doesn't affect parz */ 57 : raid_genz_ptr = raid_genz_sse2ext; 58 : #else - 59 270 : raid_gen_ptr[1] = raid_gen2_sse2; - 60 270 : raid_genz_ptr = raid_genz_sse2; + 59 271 : raid_gen_ptr[1] = raid_gen2_sse2; + 60 271 : raid_genz_ptr = raid_genz_sse2; 61 : #endif 62 : } 63 : #endif 64 : 65 : #ifdef CONFIG_SSSE3 - 66 270 : if (raid_cpu_has_ssse3()) { + 66 271 : if (raid_cpu_has_ssse3()) { 67 : #ifdef CONFIG_X86_64 68 : if (raid_cpu_has_slowextendedreg()) { 69 : raid_gen3_ptr = raid_gen3_ssse3; @@ -139,22 +139,22 @@ 77 : raid_gen_ptr[5] = raid_gen6_ssse3ext; 78 : } 79 : #else - 80 269 : raid_gen3_ptr = raid_gen3_ssse3; - 81 269 : raid_gen_ptr[3] = raid_gen4_ssse3; - 82 269 : raid_gen_ptr[4] = raid_gen5_ssse3; - 83 269 : raid_gen_ptr[5] = raid_gen6_ssse3; + 80 270 : raid_gen3_ptr = raid_gen3_ssse3; + 81 270 : raid_gen_ptr[3] = raid_gen4_ssse3; + 82 270 : raid_gen_ptr[4] = raid_gen5_ssse3; + 83 270 : raid_gen_ptr[5] = raid_gen6_ssse3; 84 : #endif - 85 269 : raid_rec_ptr[0] = raid_rec1_ssse3; - 86 269 : raid_rec_ptr[1] = raid_rec2_ssse3; - 87 269 : raid_rec_ptr[2] = raid_recX_ssse3; - 88 269 : raid_rec_ptr[3] = raid_recX_ssse3; - 89 269 : raid_rec_ptr[4] = raid_recX_ssse3; - 90 269 : raid_rec_ptr[5] = raid_recX_ssse3; + 85 270 : raid_rec_ptr[0] = raid_rec1_ssse3; + 86 270 : raid_rec_ptr[1] = raid_rec2_ssse3; + 87 270 : raid_rec_ptr[2] = raid_recX_ssse3; + 88 270 : raid_rec_ptr[3] = raid_recX_ssse3; + 89 270 : raid_rec_ptr[4] = raid_recX_ssse3; + 90 270 : raid_rec_ptr[5] = raid_recX_ssse3; 91 : } 92 : #endif 93 : 94 : #ifdef CONFIG_AVX2 - 95 270 : if (raid_cpu_has_avx2()) { + 95 271 : if (raid_cpu_has_avx2()) { 96 2 : raid_gen_ptr[0] = raid_gen1_avx2; 97 2 : raid_gen_ptr[1] = raid_gen2_avx2; 98 : #ifdef CONFIG_X86_64 @@ -175,8 +175,8 @@ 113 : #endif /* CONFIG_X86 */ 114 : 115 : /* set the default mode */ - 116 270 : raid_mode(RAID_MODE_CAUCHY); - 117 270 : } + 116 271 : raid_mode(RAID_MODE_CAUCHY); + 117 271 : } 118 : 119 : /* 120 : * Reference parity computation. diff --git a/cov/raid/raid.c.func-sort-c.html b/cov/raid/raid.c.func-sort-c.html index 1f035c3f..05da72d1 100644 --- a/cov/raid/raid.c.func-sort-c.html +++ b/cov/raid/raid.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -61,23 +61,23 @@ raid_gen - 1235917 + 1235650 raid_data - 214914 + 214670 raid_invert - 172507 + 172489 raid_delta_gen - 171503 + 171491 raid_rec1of1 - 101792 + 101560 raid_rec @@ -85,7 +85,7 @@ raid_mode - 539 + 541 raid_zero diff --git a/cov/raid/raid.c.func.html b/cov/raid/raid.c.func.html index 1758cd6d..217f6747 100644 --- a/cov/raid/raid.c.func.html +++ b/cov/raid/raid.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -61,23 +61,23 @@ raid_data - 214914 + 214670 raid_delta_gen - 171503 + 171491 raid_gen - 1235917 + 1235650 raid_invert - 172507 + 172489 raid_mode - 539 + 541 raid_rec @@ -85,7 +85,7 @@ raid_rec1of1 - 101792 + 101560 raid_rec2of2_int8 diff --git a/cov/raid/raid.c.gcov.html b/cov/raid/raid.c.gcov.html index 9923f537..918df0e1 100644 --- a/cov/raid/raid.c.gcov.html +++ b/cov/raid/raid.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 9 @@ -235,16 +235,16 @@ 173 : */ 174 : const uint8_t (*raid_gfgen)[256]; 175 : - 176 539 : void raid_mode(int mode) + 176 541 : void raid_mode(int mode) 177 : { - 178 539 : if (mode == RAID_MODE_VANDERMONDE) { + 178 541 : if (mode == RAID_MODE_VANDERMONDE) { 179 2 : raid_gen_ptr[2] = raid_genz_ptr; 180 2 : raid_gfgen = gfvandermonde; 181 : } else { - 182 537 : raid_gen_ptr[2] = raid_gen3_ptr; - 183 537 : raid_gfgen = gfcauchy; + 182 539 : raid_gen_ptr[2] = raid_gen3_ptr; + 183 539 : raid_gfgen = gfcauchy; 184 : } - 185 539 : } + 185 541 : } 186 : 187 : /** 188 : * Buffer filled with 0 used in recovering. @@ -282,17 +282,17 @@ 220 : void (*raid_gen3_ptr)(int nd, size_t size, void **vv); 221 : void (*raid_genz_ptr)(int nd, size_t size, void **vv); 222 : - 223 1235917 : void raid_gen(int nd, int np, size_t size, void **v) + 223 1235650 : void raid_gen(int nd, int np, size_t size, void **v) 224 : { 225 : /* enforce limit on size */ - 226 1235917 : BUG_ON(size % 64 != 0); + 226 1235650 : BUG_ON(size % 64 != 0); 227 : 228 : /* enforce limit on number of failures */ - 229 1235917 : BUG_ON(np < 1); - 230 1235917 : BUG_ON(np > RAID_PARITY_MAX); + 229 1235650 : BUG_ON(np < 1); + 230 1235650 : BUG_ON(np > RAID_PARITY_MAX); 231 : - 232 1235917 : raid_gen_ptr[np - 1](nd, size, v); - 233 1235917 : } + 232 1235650 : raid_gen_ptr[np - 1](nd, size, v); + 233 1235650 : } 234 : 235 : /** 236 : * Inverts the square matrix M of size nxn into V. @@ -305,44 +305,44 @@ 243 : * @V Destination matrix where the result is put. 244 : * @n Number of rows and columns of the matrix. 245 : */ - 246 172507 : void raid_invert(uint8_t *M, uint8_t *V, int n) + 246 172489 : void raid_invert(uint8_t *M, uint8_t *V, int n) 247 : { 248 : int i, j, k; 249 : 250 : /* set the identity matrix in V */ - 251 797578 : for (i = 0; i < n; ++i) - 252 3219440 : for (j = 0; j < n; ++j) - 253 2594369 : V[i * n + j] = i == j; + 251 797524 : for (i = 0; i < n; ++i) + 252 3219332 : for (j = 0; j < n; ++j) + 253 2594297 : V[i * n + j] = i == j; 254 : 255 : /* for each element in the diagonal */ - 256 797578 : for (k = 0; k < n; ++k) { + 256 797524 : for (k = 0; k < n; ++k) { 257 : uint8_t f; 258 : 259 : /* the diagonal element cannot be 0 because */ 260 : /* we are inverting matrices with all the square */ 261 : /* submatrices not singular */ - 262 625071 : BUG_ON(M[k * n + k] == 0); + 262 625035 : BUG_ON(M[k * n + k] == 0); 263 : 264 : /* make the diagonal element to be 1 */ - 265 1250142 : f = inv(M[k * n + k]); - 266 3219440 : for (j = 0; j < n; ++j) { - 267 5188738 : M[k * n + j] = mul(f, M[k * n + j]); - 268 5188738 : V[k * n + j] = mul(f, V[k * n + j]); + 265 1250070 : f = inv(M[k * n + k]); + 266 3219332 : for (j = 0; j < n; ++j) { + 267 5188594 : M[k * n + j] = mul(f, M[k * n + j]); + 268 5188594 : V[k * n + j] = mul(f, V[k * n + j]); 269 : } 270 : 271 : /* make all the elements over and under the diagonal */ 272 : /* to be zero */ - 273 3219440 : for (i = 0; i < n; ++i) { - 274 2594369 : if (i == k) - 275 625071 : continue; - 276 1969298 : f = M[i * n + k]; - 277 11270958 : for (j = 0; j < n; ++j) { - 278 18603320 : M[i * n + j] ^= mul(f, M[k * n + j]); - 279 18603320 : V[i * n + j] ^= mul(f, V[k * n + j]); + 273 3219332 : for (i = 0; i < n; ++i) { + 274 2594297 : if (i == k) + 275 625035 : continue; + 276 1969262 : f = M[i * n + k]; + 277 11270850 : for (j = 0; j < n; ++j) { + 278 18603176 : M[i * n + j] ^= mul(f, M[k * n + j]); + 279 18603176 : V[i * n + j] ^= mul(f, V[k * n + j]); 280 : } 281 : } 282 : } - 283 172507 : } + 283 172489 : } 284 : 285 : /** 286 : * Computes the parity without the missing data blocks @@ -350,7 +350,7 @@ 288 : * 289 : * This is the parity expressed as Pa,Qa,Ra,Sa,Ta,Ua in the equations. 290 : */ - 291 171503 : void raid_delta_gen(int nr, int *id, int *ip, int nd, size_t size, void **v) + 291 171491 : void raid_delta_gen(int nr, int *id, int *ip, int nd, size_t size, void **v) 292 : { 293 : void *p[RAID_PARITY_MAX]; 294 : void *pa[RAID_PARITY_MAX]; @@ -360,17 +360,17 @@ 298 : 299 : /* total number of parities we are going to process */ 300 : /* they are both the used and the unused ones */ - 301 171503 : np = ip[nr - 1] + 1; + 301 171491 : np = ip[nr - 1] + 1; 302 : 303 : /* latest missing data block */ - 304 171503 : latest = v[id[nr - 1]]; + 304 171491 : latest = v[id[nr - 1]]; 305 : 306 : /* setup pointers for delta computation */ - 307 873053 : for (i = 0, j = 0; i < np; ++i) { + 307 873017 : for (i = 0, j = 0; i < np; ++i) { 308 : /* keep a copy of the original parity vector */ - 309 701550 : p[i] = v[nd + i]; + 309 701526 : p[i] = v[nd + i]; 310 : - 311 701550 : if (ip[j] == i) { + 311 701526 : if (ip[j] == i) { 312 : /* 313 : * Set used parities to point to the missing 314 : * data blocks. @@ -381,19 +381,19 @@ 319 : 320 : /* the latest parity to use ends the for loop and */ 321 : /* then it cannot happen to process more of them */ - 322 605393 : BUG_ON(j >= nr); + 322 605363 : BUG_ON(j >= nr); 323 : 324 : /* buffer for missing data blocks */ - 325 605393 : pa[j] = v[id[j]]; + 325 605363 : pa[j] = v[id[j]]; 326 : 327 : /* set at zero the missing data blocks */ - 328 605393 : v[id[j]] = raid_zero_block; + 328 605363 : v[id[j]] = raid_zero_block; 329 : 330 : /* compute the parity over the missing data blocks */ - 331 605393 : v[nd + i] = pa[j]; + 331 605363 : v[nd + i] = pa[j]; 332 : 333 : /* check for the next used entry */ - 334 605393 : ++j; + 334 605363 : ++j; 335 : } else { 336 : /* 337 : * Unused parities are going to be rewritten with @@ -413,25 +413,25 @@ 351 : * multiple times and only the latest write will 352 : * contain the correct data. 353 : */ - 354 96157 : v[nd + i] = latest; + 354 96163 : v[nd + i] = latest; 355 : } 356 : } 357 : 358 : /* all the parities have to be processed */ - 359 171503 : BUG_ON(j != nr); + 359 171491 : BUG_ON(j != nr); 360 : 361 : /* recompute the parity, note that np may be smaller than the */ 362 : /* total number of parities available */ - 363 171503 : raid_gen(nd, np, size, v); + 363 171491 : raid_gen(nd, np, size, v); 364 : 365 : /* restore data buffers as before */ - 366 776896 : for (j = 0; j < nr; ++j) - 367 605393 : v[id[j]] = pa[j]; + 366 776854 : for (j = 0; j < nr; ++j) + 367 605363 : v[id[j]] = pa[j]; 368 : 369 : /* restore parity buffers as before */ - 370 873053 : for (i = 0; i < np; ++i) - 371 701550 : v[nd + i] = p[i]; - 372 171503 : } + 370 873017 : for (i = 0; i < np; ++i) + 371 701526 : v[nd + i] = p[i]; + 372 171491 : } 373 : 374 : /** 375 : * Recover failure of one data block for PAR1. @@ -444,29 +444,29 @@ 382 : * 383 : * Dx = Pd 384 : */ - 385 101792 : void raid_rec1of1(int *id, int nd, size_t size, void **v) + 385 101560 : void raid_rec1of1(int *id, int nd, size_t size, void **v) 386 : { 387 : void *p; 388 : void *pa; 389 : 390 : /* for PAR1 we can directly compute the missing block */ 391 : /* and we don't need to use the zero buffer */ - 392 101792 : p = v[nd]; - 393 101792 : pa = v[id[0]]; + 392 101560 : p = v[nd]; + 393 101560 : pa = v[id[0]]; 394 : 395 : /* use the parity as missing data block */ - 396 101792 : v[id[0]] = p; + 396 101560 : v[id[0]] = p; 397 : 398 : /* compute the parity over the missing data block */ - 399 101792 : v[nd] = pa; + 399 101560 : v[nd] = pa; 400 : 401 : /* compute */ - 402 101792 : raid_gen(nd, 1, size, v); + 402 101560 : raid_gen(nd, 1, size, v); 403 : 404 : /* restore as before */ - 405 101792 : v[id[0]] = pa; - 406 101792 : v[nd] = p; - 407 101792 : } + 405 101560 : v[id[0]] = pa; + 406 101560 : v[nd] = p; + 407 101560 : } 408 : 409 : /** 410 : * Recover failure of two data blocks for PAR2. @@ -615,36 +615,36 @@ 553 12 : raid_gen(nd, ir[nr - 1] - nd + 1, size, v); 554 870 : } 555 : - 556 214914 : void raid_data(int nr, int *id, int *ip, int nd, size_t size, void **v) + 556 214670 : void raid_data(int nr, int *id, int *ip, int nd, size_t size, void **v) 557 : { 558 : /* enforce limit on size */ - 559 214914 : BUG_ON(size % 64 != 0); + 559 214670 : BUG_ON(size % 64 != 0); 560 : 561 : /* enforce limit on number of failures */ - 562 214914 : BUG_ON(nr > nd); - 563 214914 : BUG_ON(nr > RAID_PARITY_MAX); + 562 214670 : BUG_ON(nr > nd); + 563 214670 : BUG_ON(nr > RAID_PARITY_MAX); 564 : 565 : /* enforce order in index vector for data */ - 566 214914 : BUG_ON(nr >= 2 && id[0] >= id[1]); - 567 214914 : BUG_ON(nr >= 3 && id[1] >= id[2]); - 568 214914 : BUG_ON(nr >= 4 && id[2] >= id[3]); - 569 214914 : BUG_ON(nr >= 5 && id[3] >= id[4]); - 570 214914 : BUG_ON(nr >= 6 && id[4] >= id[5]); + 566 214670 : BUG_ON(nr >= 2 && id[0] >= id[1]); + 567 214670 : BUG_ON(nr >= 3 && id[1] >= id[2]); + 568 214670 : BUG_ON(nr >= 4 && id[2] >= id[3]); + 569 214670 : BUG_ON(nr >= 5 && id[3] >= id[4]); + 570 214670 : BUG_ON(nr >= 6 && id[4] >= id[5]); 571 : 572 : /* enforce limit on index vector for data */ - 573 214914 : BUG_ON(nr > 0 && id[nr-1] >= nd); + 573 214670 : BUG_ON(nr > 0 && id[nr-1] >= nd); 574 : 575 : /* enforce order in index vector for parity */ - 576 214914 : BUG_ON(nr >= 2 && ip[0] >= ip[1]); - 577 214914 : BUG_ON(nr >= 3 && ip[1] >= ip[2]); - 578 214914 : BUG_ON(nr >= 4 && ip[2] >= ip[3]); - 579 214914 : BUG_ON(nr >= 5 && ip[3] >= ip[4]); - 580 214914 : BUG_ON(nr >= 6 && ip[4] >= ip[5]); + 576 214670 : BUG_ON(nr >= 2 && ip[0] >= ip[1]); + 577 214670 : BUG_ON(nr >= 3 && ip[1] >= ip[2]); + 578 214670 : BUG_ON(nr >= 4 && ip[2] >= ip[3]); + 579 214670 : BUG_ON(nr >= 5 && ip[3] >= ip[4]); + 580 214670 : BUG_ON(nr >= 6 && ip[4] >= ip[5]); 581 : 582 : /* if failed data is present */ - 583 214914 : if (nr != 0) - 584 214912 : raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v); - 585 214914 : } + 583 214670 : if (nr != 0) + 584 214668 : raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v); + 585 214670 : } 586 : diff --git a/cov/raid/tag.c.func-sort-c.html b/cov/raid/tag.c.func-sort-c.html index 5bae656b..1f9b9cc9 100644 --- a/cov/raid/tag.c.func-sort-c.html +++ b/cov/raid/tag.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 diff --git a/cov/raid/tag.c.func.html b/cov/raid/tag.c.func.html index 3a6c7b23..ed516e06 100644 --- a/cov/raid/tag.c.func.html +++ b/cov/raid/tag.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 diff --git a/cov/raid/tag.c.gcov.html b/cov/raid/tag.c.gcov.html index 9cc13623..c32dfdec 100644 --- a/cov/raid/tag.c.gcov.html +++ b/cov/raid/tag.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 diff --git a/cov/raid/test.c.func-sort-c.html b/cov/raid/test.c.func-sort-c.html index 9aae9b65..f0ff52fe 100644 --- a/cov/raid/test.c.func-sort-c.html +++ b/cov/raid/test.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 diff --git a/cov/raid/test.c.func.html b/cov/raid/test.c.func.html index 211a3488..f1adbb5b 100644 --- a/cov/raid/test.c.func.html +++ b/cov/raid/test.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 diff --git a/cov/raid/test.c.gcov.html b/cov/raid/test.c.gcov.html index 9f4fe803..f06db169 100644 --- a/cov/raid/test.c.gcov.html +++ b/cov/raid/test.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 7 diff --git a/cov/raid/x86.c.func-sort-c.html b/cov/raid/x86.c.func-sort-c.html index 52148a1e..d8bd9c3e 100644 --- a/cov/raid/x86.c.func-sort-c.html +++ b/cov/raid/x86.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 14 @@ -61,19 +61,19 @@ raid_gen6_ssse3 - 564213 + 564177 raid_gen1_sse2 - 289166 + 288948 raid_gen2_sse2 - 268726 + 268716 raid_rec1_ssse3 - 111621 + 111395 raid_recX_ssse3 @@ -81,15 +81,15 @@ raid_gen5_ssse3 - 50653 + 50654 raid_rec2_ssse3 - 44056 + 44038 raid_gen4_ssse3 - 32470 + 32469 raid_gen3_ssse3 @@ -113,7 +113,7 @@ raid_gen1_avx2 - 98 + 97
diff --git a/cov/raid/x86.c.func.html b/cov/raid/x86.c.func.html index e0e39976..80a9bfea 100644 --- a/cov/raid/x86.c.func.html +++ b/cov/raid/x86.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 14 @@ -61,11 +61,11 @@ raid_gen1_avx2 - 98 + 97 raid_gen1_sse2 - 289166 + 288948 raid_gen2_avx2 @@ -73,7 +73,7 @@ raid_gen2_sse2 - 268726 + 268716 raid_gen3_ssse3 @@ -81,15 +81,15 @@ raid_gen4_ssse3 - 32470 + 32469 raid_gen5_ssse3 - 50653 + 50654 raid_gen6_ssse3 - 564213 + 564177 raid_rec1_avx2 @@ -97,7 +97,7 @@ raid_rec1_ssse3 - 111621 + 111395 raid_rec2_avx2 @@ -105,7 +105,7 @@ raid_rec2_ssse3 - 44056 + 44038 raid_recX_avx2 diff --git a/cov/raid/x86.c.gcov.html b/cov/raid/x86.c.gcov.html index 04aeec56..7c8a2e85 100644 --- a/cov/raid/x86.c.gcov.html +++ b/cov/raid/x86.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 14 @@ -95,37 +95,37 @@ 33 : * cache block, and processing 128 bytes doesn't increase performance, and in 34 : * some cases it even decreases it. 35 : */ - 36 289166 : void raid_gen1_sse2(int nd, size_t size, void **vv) + 36 288948 : void raid_gen1_sse2(int nd, size_t size, void **vv) 37 : { - 38 289166 : uint8_t **v = (uint8_t **)vv; + 38 288948 : uint8_t **v = (uint8_t **)vv; 39 : uint8_t *p; 40 : int d, l; 41 : size_t i; 42 : - 43 289166 : l = nd - 1; - 44 289166 : p = v[nd]; + 43 288948 : l = nd - 1; + 44 288948 : p = v[nd]; 45 : 46 : raid_sse_begin(); 47 : - 48 6139786 : for (i = 0; i < size; i += 64) { - 49 5850620 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); - 50 5850620 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); - 51 5850620 : asm volatile ("movdqa %0,%%xmm2" : : "m" (v[l][i + 32])); - 52 5850620 : asm volatile ("movdqa %0,%%xmm3" : : "m" (v[l][i + 48])); - 53 37561508 : for (d = l - 1; d >= 0; --d) { - 54 31710888 : asm volatile ("pxor %0,%%xmm0" : : "m" (v[d][i])); - 55 31710888 : asm volatile ("pxor %0,%%xmm1" : : "m" (v[d][i + 16])); - 56 31710888 : asm volatile ("pxor %0,%%xmm2" : : "m" (v[d][i + 32])); - 57 31710888 : asm volatile ("pxor %0,%%xmm3" : : "m" (v[d][i + 48])); + 48 6140160 : for (i = 0; i < size; i += 64) { + 49 5851212 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); + 50 5851212 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); + 51 5851212 : asm volatile ("movdqa %0,%%xmm2" : : "m" (v[l][i + 32])); + 52 5851212 : asm volatile ("movdqa %0,%%xmm3" : : "m" (v[l][i + 48])); + 53 37573252 : for (d = l - 1; d >= 0; --d) { + 54 31722040 : asm volatile ("pxor %0,%%xmm0" : : "m" (v[d][i])); + 55 31722040 : asm volatile ("pxor %0,%%xmm1" : : "m" (v[d][i + 16])); + 56 31722040 : asm volatile ("pxor %0,%%xmm2" : : "m" (v[d][i + 32])); + 57 31722040 : asm volatile ("pxor %0,%%xmm3" : : "m" (v[d][i + 48])); 58 : } - 59 5850620 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 60 5850620 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); - 61 5850620 : asm volatile ("movntdq %%xmm2,%0" : "=m" (p[i + 32])); - 62 5850620 : asm volatile ("movntdq %%xmm3,%0" : "=m" (p[i + 48])); + 59 5851212 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 60 5851212 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); + 61 5851212 : asm volatile ("movntdq %%xmm2,%0" : "=m" (p[i + 32])); + 62 5851212 : asm volatile ("movntdq %%xmm3,%0" : "=m" (p[i + 48])); 63 : } 64 : 65 : raid_sse_end(); - 66 289166 : } + 66 288948 : } 67 : #endif 68 : 69 : #if defined(CONFIG_X86) && defined(CONFIG_AVX2) @@ -136,31 +136,31 @@ 74 : * cache block, and processing 128 bytes doesn't increase performance, and in 75 : * some cases it even decreases it. 76 : */ - 77 98 : void raid_gen1_avx2(int nd, size_t size, void **vv) + 77 97 : void raid_gen1_avx2(int nd, size_t size, void **vv) 78 : { - 79 98 : uint8_t **v = (uint8_t **)vv; + 79 97 : uint8_t **v = (uint8_t **)vv; 80 : uint8_t *p; 81 : int d, l; 82 : size_t i; 83 : - 84 98 : l = nd - 1; - 85 98 : p = v[nd]; + 84 97 : l = nd - 1; + 85 97 : p = v[nd]; 86 : 87 : raid_avx_begin(); 88 : - 89 54286 : for (i = 0; i < size; i += 64) { - 90 54188 : asm volatile ("vmovdqa %0,%%ymm0" : : "m" (v[l][i])); - 91 54188 : asm volatile ("vmovdqa %0,%%ymm1" : : "m" (v[l][i + 32])); - 92 439940 : for (d = l - 1; d >= 0; --d) { - 93 385752 : asm volatile ("vpxor %0,%%ymm0,%%ymm0" : : "m" (v[d][i])); - 94 385752 : asm volatile ("vpxor %0,%%ymm1,%%ymm1" : : "m" (v[d][i + 32])); + 89 50189 : for (i = 0; i < size; i += 64) { + 90 50092 : asm volatile ("vmovdqa %0,%%ymm0" : : "m" (v[l][i])); + 91 50092 : asm volatile ("vmovdqa %0,%%ymm1" : : "m" (v[l][i + 32])); + 92 407172 : for (d = l - 1; d >= 0; --d) { + 93 357080 : asm volatile ("vpxor %0,%%ymm0,%%ymm0" : : "m" (v[d][i])); + 94 357080 : asm volatile ("vpxor %0,%%ymm1,%%ymm1" : : "m" (v[d][i + 32])); 95 : } - 96 54188 : asm volatile ("vmovntdq %%ymm0,%0" : "=m" (p[i])); - 97 54188 : asm volatile ("vmovntdq %%ymm1,%0" : "=m" (p[i + 32])); + 96 50092 : asm volatile ("vmovntdq %%ymm0,%0" : "=m" (p[i])); + 97 50092 : asm volatile ("vmovntdq %%ymm1,%0" : "=m" (p[i + 32])); 98 : } 99 : 100 : raid_avx_end(); - 101 98 : } + 101 97 : } 102 : #endif 103 : 104 : #if defined(CONFIG_X86) && defined(CONFIG_SSE2) @@ -183,54 +183,54 @@ 121 : /* 122 : * GEN2 (RAID6 with powers of 2) SSE2 implementation 123 : */ - 124 268726 : void raid_gen2_sse2(int nd, size_t size, void **vv) + 124 268716 : void raid_gen2_sse2(int nd, size_t size, void **vv) 125 : { - 126 268726 : uint8_t **v = (uint8_t **)vv; + 126 268716 : uint8_t **v = (uint8_t **)vv; 127 : uint8_t *p; 128 : uint8_t *q; 129 : int d, l; 130 : size_t i; 131 : - 132 268726 : l = nd - 1; - 133 268726 : p = v[nd]; - 134 268726 : q = v[nd + 1]; + 132 268716 : l = nd - 1; + 133 268716 : p = v[nd]; + 134 268716 : q = v[nd + 1]; 135 : 136 : raid_sse_begin(); 137 : - 138 268726 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 138 268716 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 139 : - 140 10769166 : for (i = 0; i < size; i += 32) { - 141 10500440 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); - 142 10500440 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); - 143 10500440 : asm volatile ("movdqa %xmm0,%xmm2"); - 144 10500440 : asm volatile ("movdqa %xmm1,%xmm3"); - 145 66820488 : for (d = l - 1; d >= 0; --d) { - 146 56320048 : asm volatile ("pxor %xmm4,%xmm4"); - 147 56320048 : asm volatile ("pxor %xmm5,%xmm5"); - 148 56320048 : asm volatile ("pcmpgtb %xmm2,%xmm4"); - 149 56320048 : asm volatile ("pcmpgtb %xmm3,%xmm5"); - 150 56320048 : asm volatile ("paddb %xmm2,%xmm2"); - 151 56320048 : asm volatile ("paddb %xmm3,%xmm3"); - 152 56320048 : asm volatile ("pand %xmm7,%xmm4"); - 153 56320048 : asm volatile ("pand %xmm7,%xmm5"); - 154 56320048 : asm volatile ("pxor %xmm4,%xmm2"); - 155 56320048 : asm volatile ("pxor %xmm5,%xmm3"); + 140 10785156 : for (i = 0; i < size; i += 32) { + 141 10516440 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); + 142 10516440 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); + 143 10516440 : asm volatile ("movdqa %xmm0,%xmm2"); + 144 10516440 : asm volatile ("movdqa %xmm1,%xmm3"); + 145 66949256 : for (d = l - 1; d >= 0; --d) { + 146 56432816 : asm volatile ("pxor %xmm4,%xmm4"); + 147 56432816 : asm volatile ("pxor %xmm5,%xmm5"); + 148 56432816 : asm volatile ("pcmpgtb %xmm2,%xmm4"); + 149 56432816 : asm volatile ("pcmpgtb %xmm3,%xmm5"); + 150 56432816 : asm volatile ("paddb %xmm2,%xmm2"); + 151 56432816 : asm volatile ("paddb %xmm3,%xmm3"); + 152 56432816 : asm volatile ("pand %xmm7,%xmm4"); + 153 56432816 : asm volatile ("pand %xmm7,%xmm5"); + 154 56432816 : asm volatile ("pxor %xmm4,%xmm2"); + 155 56432816 : asm volatile ("pxor %xmm5,%xmm3"); 156 : - 157 56320048 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); - 158 56320048 : asm volatile ("movdqa %0,%%xmm5" : : "m" (v[d][i + 16])); - 159 56320048 : asm volatile ("pxor %xmm4,%xmm0"); - 160 56320048 : asm volatile ("pxor %xmm5,%xmm1"); - 161 56320048 : asm volatile ("pxor %xmm4,%xmm2"); - 162 56320048 : asm volatile ("pxor %xmm5,%xmm3"); + 157 56432816 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 158 56432816 : asm volatile ("movdqa %0,%%xmm5" : : "m" (v[d][i + 16])); + 159 56432816 : asm volatile ("pxor %xmm4,%xmm0"); + 160 56432816 : asm volatile ("pxor %xmm5,%xmm1"); + 161 56432816 : asm volatile ("pxor %xmm4,%xmm2"); + 162 56432816 : asm volatile ("pxor %xmm5,%xmm3"); 163 : } - 164 10500440 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 165 10500440 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); - 166 10500440 : asm volatile ("movntdq %%xmm2,%0" : "=m" (q[i])); - 167 10500440 : asm volatile ("movntdq %%xmm3,%0" : "=m" (q[i + 16])); + 164 10516440 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 165 10516440 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); + 166 10516440 : asm volatile ("movntdq %%xmm2,%0" : "=m" (q[i])); + 167 10516440 : asm volatile ("movntdq %%xmm3,%0" : "=m" (q[i + 16])); 168 : } 169 : 170 : raid_sse_end(); - 171 268726 : } + 171 268716 : } 172 : #endif 173 : 174 : #if defined(CONFIG_X86) && defined(CONFIG_AVX2) @@ -741,9 +741,9 @@ 679 : /* 680 : * GEN4 (quad parity with Cauchy matrix) SSSE3 implementation 681 : */ - 682 32470 : void raid_gen4_ssse3(int nd, size_t size, void **vv) + 682 32469 : void raid_gen4_ssse3(int nd, size_t size, void **vv) 683 : { - 684 32470 : uint8_t **v = (uint8_t **)vv; + 684 32469 : uint8_t **v = (uint8_t **)vv; 685 : uint8_t *p; 686 : uint8_t *q; 687 : uint8_t *r; @@ -751,102 +751,102 @@ 689 : int d, l; 690 : size_t i; 691 : - 692 32470 : l = nd - 1; - 693 32470 : p = v[nd]; - 694 32470 : q = v[nd + 1]; - 695 32470 : r = v[nd + 2]; - 696 32470 : s = v[nd + 3]; + 692 32469 : l = nd - 1; + 693 32469 : p = v[nd]; + 694 32469 : q = v[nd + 1]; + 695 32469 : r = v[nd + 2]; + 696 32469 : s = v[nd + 3]; 697 : 698 : /* special case with only one data disk */ - 699 32470 : if (l == 0) { + 699 32469 : if (l == 0) { 700 5 : for (i = 0; i < 4; ++i) 701 4 : memcpy(v[1 + i], v[0], size); - 702 32471 : return; + 702 32470 : return; 703 : } 704 : 705 : raid_sse_begin(); 706 : 707 : /* generic case with at least two data disks */ - 708 3351189 : for (i = 0; i < size; i += 16) { + 708 3334804 : for (i = 0; i < size; i += 16) { 709 : /* last disk without the by two multiplication */ - 710 3318720 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 711 3318720 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 710 3302336 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 711 3302336 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 712 : - 713 3318720 : asm volatile ("movdqa %xmm4,%xmm0"); - 714 3318720 : asm volatile ("movdqa %xmm4,%xmm1"); + 713 3302336 : asm volatile ("movdqa %xmm4,%xmm0"); + 714 3302336 : asm volatile ("movdqa %xmm4,%xmm1"); 715 : - 716 3318720 : asm volatile ("movdqa %xmm4,%xmm5"); - 717 3318720 : asm volatile ("psrlw $4,%xmm5"); - 718 3318720 : asm volatile ("pand %xmm7,%xmm4"); - 719 3318720 : asm volatile ("pand %xmm7,%xmm5"); + 716 3302336 : asm volatile ("movdqa %xmm4,%xmm5"); + 717 3302336 : asm volatile ("psrlw $4,%xmm5"); + 718 3302336 : asm volatile ("pand %xmm7,%xmm4"); + 719 3302336 : asm volatile ("pand %xmm7,%xmm5"); 720 : - 721 3318720 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); - 722 3318720 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 723 3318720 : asm volatile ("pshufb %xmm4,%xmm2"); - 724 3318720 : asm volatile ("pshufb %xmm5,%xmm7"); - 725 3318720 : asm volatile ("pxor %xmm7,%xmm2"); + 721 3302336 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); + 722 3302336 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 723 3302336 : asm volatile ("pshufb %xmm4,%xmm2"); + 724 3302336 : asm volatile ("pshufb %xmm5,%xmm7"); + 725 3302336 : asm volatile ("pxor %xmm7,%xmm2"); 726 : - 727 3318720 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][1][0][0])); - 728 3318720 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 729 3318720 : asm volatile ("pshufb %xmm4,%xmm3"); - 730 3318720 : asm volatile ("pshufb %xmm5,%xmm7"); - 731 3318720 : asm volatile ("pxor %xmm7,%xmm3"); + 727 3302336 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][1][0][0])); + 728 3302336 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 729 3302336 : asm volatile ("pshufb %xmm4,%xmm3"); + 730 3302336 : asm volatile ("pshufb %xmm5,%xmm7"); + 731 3302336 : asm volatile ("pxor %xmm7,%xmm3"); 732 : 733 : /* intermediate disks */ - 734 19886080 : for (d = l - 1; d > 0; --d) { - 735 16567360 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); - 736 16567360 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 734 19771392 : for (d = l - 1; d > 0; --d) { + 735 16469056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 736 16469056 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); 737 : - 738 16567360 : asm volatile ("pxor %xmm5,%xmm5"); - 739 16567360 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 740 16567360 : asm volatile ("paddb %xmm1,%xmm1"); - 741 16567360 : asm volatile ("pand %xmm7,%xmm5"); - 742 16567360 : asm volatile ("pxor %xmm5,%xmm1"); + 738 16469056 : asm volatile ("pxor %xmm5,%xmm5"); + 739 16469056 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 740 16469056 : asm volatile ("paddb %xmm1,%xmm1"); + 741 16469056 : asm volatile ("pand %xmm7,%xmm5"); + 742 16469056 : asm volatile ("pxor %xmm5,%xmm1"); 743 : - 744 16567360 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 744 16469056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 745 : - 746 16567360 : asm volatile ("pxor %xmm4,%xmm0"); - 747 16567360 : asm volatile ("pxor %xmm4,%xmm1"); + 746 16469056 : asm volatile ("pxor %xmm4,%xmm0"); + 747 16469056 : asm volatile ("pxor %xmm4,%xmm1"); 748 : - 749 16567360 : asm volatile ("movdqa %xmm4,%xmm5"); - 750 16567360 : asm volatile ("psrlw $4,%xmm5"); - 751 16567360 : asm volatile ("pand %xmm7,%xmm4"); - 752 16567360 : asm volatile ("pand %xmm7,%xmm5"); + 749 16469056 : asm volatile ("movdqa %xmm4,%xmm5"); + 750 16469056 : asm volatile ("psrlw $4,%xmm5"); + 751 16469056 : asm volatile ("pand %xmm7,%xmm4"); + 752 16469056 : asm volatile ("pand %xmm7,%xmm5"); 753 : - 754 16567360 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 755 16567360 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 756 16567360 : asm volatile ("pshufb %xmm4,%xmm6"); - 757 16567360 : asm volatile ("pshufb %xmm5,%xmm7"); - 758 16567360 : asm volatile ("pxor %xmm6,%xmm2"); - 759 16567360 : asm volatile ("pxor %xmm7,%xmm2"); + 754 16469056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 755 16469056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 756 16469056 : asm volatile ("pshufb %xmm4,%xmm6"); + 757 16469056 : asm volatile ("pshufb %xmm5,%xmm7"); + 758 16469056 : asm volatile ("pxor %xmm6,%xmm2"); + 759 16469056 : asm volatile ("pxor %xmm7,%xmm2"); 760 : - 761 16567360 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 762 16567360 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 763 16567360 : asm volatile ("pshufb %xmm4,%xmm6"); - 764 16567360 : asm volatile ("pshufb %xmm5,%xmm7"); - 765 16567360 : asm volatile ("pxor %xmm6,%xmm3"); - 766 16567360 : asm volatile ("pxor %xmm7,%xmm3"); + 761 16469056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 762 16469056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 763 16469056 : asm volatile ("pshufb %xmm4,%xmm6"); + 764 16469056 : asm volatile ("pshufb %xmm5,%xmm7"); + 765 16469056 : asm volatile ("pxor %xmm6,%xmm3"); + 766 16469056 : asm volatile ("pxor %xmm7,%xmm3"); 767 : } 768 : 769 : /* first disk with all coefficients at 1 */ - 770 3318720 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); - 771 3318720 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 770 3302336 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 771 3302336 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); 772 : - 773 3318720 : asm volatile ("pxor %xmm5,%xmm5"); - 774 3318720 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 775 3318720 : asm volatile ("paddb %xmm1,%xmm1"); - 776 3318720 : asm volatile ("pand %xmm7,%xmm5"); - 777 3318720 : asm volatile ("pxor %xmm5,%xmm1"); + 773 3302336 : asm volatile ("pxor %xmm5,%xmm5"); + 774 3302336 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 775 3302336 : asm volatile ("paddb %xmm1,%xmm1"); + 776 3302336 : asm volatile ("pand %xmm7,%xmm5"); + 777 3302336 : asm volatile ("pxor %xmm5,%xmm1"); 778 : - 779 3318720 : asm volatile ("pxor %xmm4,%xmm0"); - 780 3318720 : asm volatile ("pxor %xmm4,%xmm1"); - 781 3318720 : asm volatile ("pxor %xmm4,%xmm2"); - 782 3318720 : asm volatile ("pxor %xmm4,%xmm3"); + 779 3302336 : asm volatile ("pxor %xmm4,%xmm0"); + 780 3302336 : asm volatile ("pxor %xmm4,%xmm1"); + 781 3302336 : asm volatile ("pxor %xmm4,%xmm2"); + 782 3302336 : asm volatile ("pxor %xmm4,%xmm3"); 783 : - 784 3318720 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 785 3318720 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); - 786 3318720 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); - 787 3318720 : asm volatile ("movntdq %%xmm3,%0" : "=m" (s[i])); + 784 3302336 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 785 3302336 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); + 786 3302336 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); + 787 3302336 : asm volatile ("movntdq %%xmm3,%0" : "=m" (s[i])); 788 : } 789 : 790 : raid_sse_end(); @@ -1191,9 +1191,9 @@ 1129 : /* 1130 : * GEN5 (penta parity with Cauchy matrix) SSSE3 implementation 1131 : */ - 1132 50653 : void raid_gen5_ssse3(int nd, size_t size, void **vv) + 1132 50654 : void raid_gen5_ssse3(int nd, size_t size, void **vv) 1133 : { - 1134 50653 : uint8_t **v = (uint8_t **)vv; + 1134 50654 : uint8_t **v = (uint8_t **)vv; 1135 : uint8_t *p; 1136 : uint8_t *q; 1137 : uint8_t *r; @@ -1202,122 +1202,122 @@ 1140 : int d, l; 1141 : size_t i; 1142 : uint8_t buffer[16+16]; - 1143 50653 : uint8_t *pd = __align_ptr(buffer, 16); + 1143 50654 : uint8_t *pd = __align_ptr(buffer, 16); 1144 : - 1145 50653 : l = nd - 1; - 1146 50653 : p = v[nd]; - 1147 50653 : q = v[nd + 1]; - 1148 50653 : r = v[nd + 2]; - 1149 50653 : s = v[nd + 3]; - 1150 50653 : t = v[nd + 4]; + 1145 50654 : l = nd - 1; + 1146 50654 : p = v[nd]; + 1147 50654 : q = v[nd + 1]; + 1148 50654 : r = v[nd + 2]; + 1149 50654 : s = v[nd + 3]; + 1150 50654 : t = v[nd + 4]; 1151 : 1152 : /* special case with only one data disk */ - 1153 50653 : if (l == 0) { + 1153 50654 : if (l == 0) { 1154 6 : for (i = 0; i < 5; ++i) 1155 5 : memcpy(v[1 + i], v[0], size); - 1156 50654 : return; + 1156 50655 : return; 1157 : } 1158 : 1159 : raid_sse_begin(); 1160 : 1161 : /* generic case with at least two data disks */ - 1162 3921132 : for (i = 0; i < size; i += 16) { + 1162 3937517 : for (i = 0; i < size; i += 16) { 1163 : /* last disk without the by two multiplication */ - 1164 3870480 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 1164 3886864 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 1165 : - 1166 3870480 : asm volatile ("movdqa %xmm4,%xmm0"); - 1167 3870480 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); + 1166 3886864 : asm volatile ("movdqa %xmm4,%xmm0"); + 1167 3886864 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); 1168 : - 1169 3870480 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1170 3870480 : asm volatile ("movdqa %xmm4,%xmm5"); - 1171 3870480 : asm volatile ("psrlw $4,%xmm5"); - 1172 3870480 : asm volatile ("pand %xmm7,%xmm4"); - 1173 3870480 : asm volatile ("pand %xmm7,%xmm5"); + 1169 3886864 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1170 3886864 : asm volatile ("movdqa %xmm4,%xmm5"); + 1171 3886864 : asm volatile ("psrlw $4,%xmm5"); + 1172 3886864 : asm volatile ("pand %xmm7,%xmm4"); + 1173 3886864 : asm volatile ("pand %xmm7,%xmm5"); 1174 : - 1175 3870480 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][0][0][0])); - 1176 3870480 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 1177 3870480 : asm volatile ("pshufb %xmm4,%xmm1"); - 1178 3870480 : asm volatile ("pshufb %xmm5,%xmm7"); - 1179 3870480 : asm volatile ("pxor %xmm7,%xmm1"); + 1175 3886864 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][0][0][0])); + 1176 3886864 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 1177 3886864 : asm volatile ("pshufb %xmm4,%xmm1"); + 1178 3886864 : asm volatile ("pshufb %xmm5,%xmm7"); + 1179 3886864 : asm volatile ("pxor %xmm7,%xmm1"); 1180 : - 1181 3870480 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][1][0][0])); - 1182 3870480 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 1183 3870480 : asm volatile ("pshufb %xmm4,%xmm2"); - 1184 3870480 : asm volatile ("pshufb %xmm5,%xmm7"); - 1185 3870480 : asm volatile ("pxor %xmm7,%xmm2"); + 1181 3886864 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][1][0][0])); + 1182 3886864 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 1183 3886864 : asm volatile ("pshufb %xmm4,%xmm2"); + 1184 3886864 : asm volatile ("pshufb %xmm5,%xmm7"); + 1185 3886864 : asm volatile ("pxor %xmm7,%xmm2"); 1186 : - 1187 3870480 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][2][0][0])); - 1188 3870480 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); - 1189 3870480 : asm volatile ("pshufb %xmm4,%xmm3"); - 1190 3870480 : asm volatile ("pshufb %xmm5,%xmm7"); - 1191 3870480 : asm volatile ("pxor %xmm7,%xmm3"); + 1187 3886864 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][2][0][0])); + 1188 3886864 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); + 1189 3886864 : asm volatile ("pshufb %xmm4,%xmm3"); + 1190 3886864 : asm volatile ("pshufb %xmm5,%xmm7"); + 1191 3886864 : asm volatile ("pxor %xmm7,%xmm3"); 1192 : 1193 : /* intermediate disks */ - 1194 23149296 : for (d = l - 1; d > 0; --d) { - 1195 19278816 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); - 1196 19278816 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); - 1197 19278816 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1194 23263984 : for (d = l - 1; d > 0; --d) { + 1195 19377120 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 1196 19377120 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); + 1197 19377120 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1198 : - 1199 19278816 : asm volatile ("pxor %xmm5,%xmm5"); - 1200 19278816 : asm volatile ("pcmpgtb %xmm0,%xmm5"); - 1201 19278816 : asm volatile ("paddb %xmm0,%xmm0"); - 1202 19278816 : asm volatile ("pand %xmm7,%xmm5"); - 1203 19278816 : asm volatile ("pxor %xmm5,%xmm0"); + 1199 19377120 : asm volatile ("pxor %xmm5,%xmm5"); + 1200 19377120 : asm volatile ("pcmpgtb %xmm0,%xmm5"); + 1201 19377120 : asm volatile ("paddb %xmm0,%xmm0"); + 1202 19377120 : asm volatile ("pand %xmm7,%xmm5"); + 1203 19377120 : asm volatile ("pxor %xmm5,%xmm0"); 1204 : - 1205 19278816 : asm volatile ("pxor %xmm4,%xmm0"); - 1206 19278816 : asm volatile ("pxor %xmm4,%xmm6"); - 1207 19278816 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[0])); + 1205 19377120 : asm volatile ("pxor %xmm4,%xmm0"); + 1206 19377120 : asm volatile ("pxor %xmm4,%xmm6"); + 1207 19377120 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[0])); 1208 : - 1209 19278816 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1210 19278816 : asm volatile ("movdqa %xmm4,%xmm5"); - 1211 19278816 : asm volatile ("psrlw $4,%xmm5"); - 1212 19278816 : asm volatile ("pand %xmm7,%xmm4"); - 1213 19278816 : asm volatile ("pand %xmm7,%xmm5"); + 1209 19377120 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1210 19377120 : asm volatile ("movdqa %xmm4,%xmm5"); + 1211 19377120 : asm volatile ("psrlw $4,%xmm5"); + 1212 19377120 : asm volatile ("pand %xmm7,%xmm4"); + 1213 19377120 : asm volatile ("pand %xmm7,%xmm5"); 1214 : - 1215 19278816 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 1216 19278816 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 1217 19278816 : asm volatile ("pshufb %xmm4,%xmm6"); - 1218 19278816 : asm volatile ("pshufb %xmm5,%xmm7"); - 1219 19278816 : asm volatile ("pxor %xmm6,%xmm1"); - 1220 19278816 : asm volatile ("pxor %xmm7,%xmm1"); + 1215 19377120 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 1216 19377120 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 1217 19377120 : asm volatile ("pshufb %xmm4,%xmm6"); + 1218 19377120 : asm volatile ("pshufb %xmm5,%xmm7"); + 1219 19377120 : asm volatile ("pxor %xmm6,%xmm1"); + 1220 19377120 : asm volatile ("pxor %xmm7,%xmm1"); 1221 : - 1222 19278816 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 1223 19278816 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 1224 19278816 : asm volatile ("pshufb %xmm4,%xmm6"); - 1225 19278816 : asm volatile ("pshufb %xmm5,%xmm7"); - 1226 19278816 : asm volatile ("pxor %xmm6,%xmm2"); - 1227 19278816 : asm volatile ("pxor %xmm7,%xmm2"); + 1222 19377120 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 1223 19377120 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 1224 19377120 : asm volatile ("pshufb %xmm4,%xmm6"); + 1225 19377120 : asm volatile ("pshufb %xmm5,%xmm7"); + 1226 19377120 : asm volatile ("pxor %xmm6,%xmm2"); + 1227 19377120 : asm volatile ("pxor %xmm7,%xmm2"); 1228 : - 1229 19278816 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); - 1230 19278816 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); - 1231 19278816 : asm volatile ("pshufb %xmm4,%xmm6"); - 1232 19278816 : asm volatile ("pshufb %xmm5,%xmm7"); - 1233 19278816 : asm volatile ("pxor %xmm6,%xmm3"); - 1234 19278816 : asm volatile ("pxor %xmm7,%xmm3"); + 1229 19377120 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); + 1230 19377120 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); + 1231 19377120 : asm volatile ("pshufb %xmm4,%xmm6"); + 1232 19377120 : asm volatile ("pshufb %xmm5,%xmm7"); + 1233 19377120 : asm volatile ("pxor %xmm6,%xmm3"); + 1234 19377120 : asm volatile ("pxor %xmm7,%xmm3"); 1235 : } 1236 : 1237 : /* first disk with all coefficients at 1 */ - 1238 3870480 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); - 1239 3870480 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); - 1240 3870480 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1238 3886864 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 1239 3886864 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); + 1240 3886864 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1241 : - 1242 3870480 : asm volatile ("pxor %xmm5,%xmm5"); - 1243 3870480 : asm volatile ("pcmpgtb %xmm0,%xmm5"); - 1244 3870480 : asm volatile ("paddb %xmm0,%xmm0"); - 1245 3870480 : asm volatile ("pand %xmm7,%xmm5"); - 1246 3870480 : asm volatile ("pxor %xmm5,%xmm0"); + 1242 3886864 : asm volatile ("pxor %xmm5,%xmm5"); + 1243 3886864 : asm volatile ("pcmpgtb %xmm0,%xmm5"); + 1244 3886864 : asm volatile ("paddb %xmm0,%xmm0"); + 1245 3886864 : asm volatile ("pand %xmm7,%xmm5"); + 1246 3886864 : asm volatile ("pxor %xmm5,%xmm0"); 1247 : - 1248 3870480 : asm volatile ("pxor %xmm4,%xmm0"); - 1249 3870480 : asm volatile ("pxor %xmm4,%xmm1"); - 1250 3870480 : asm volatile ("pxor %xmm4,%xmm2"); - 1251 3870480 : asm volatile ("pxor %xmm4,%xmm3"); - 1252 3870480 : asm volatile ("pxor %xmm4,%xmm6"); + 1248 3886864 : asm volatile ("pxor %xmm4,%xmm0"); + 1249 3886864 : asm volatile ("pxor %xmm4,%xmm1"); + 1250 3886864 : asm volatile ("pxor %xmm4,%xmm2"); + 1251 3886864 : asm volatile ("pxor %xmm4,%xmm3"); + 1252 3886864 : asm volatile ("pxor %xmm4,%xmm6"); 1253 : - 1254 3870480 : asm volatile ("movntdq %%xmm6,%0" : "=m" (p[i])); - 1255 3870480 : asm volatile ("movntdq %%xmm0,%0" : "=m" (q[i])); - 1256 3870480 : asm volatile ("movntdq %%xmm1,%0" : "=m" (r[i])); - 1257 3870480 : asm volatile ("movntdq %%xmm2,%0" : "=m" (s[i])); - 1258 3870480 : asm volatile ("movntdq %%xmm3,%0" : "=m" (t[i])); + 1254 3886864 : asm volatile ("movntdq %%xmm6,%0" : "=m" (p[i])); + 1255 3886864 : asm volatile ("movntdq %%xmm0,%0" : "=m" (q[i])); + 1256 3886864 : asm volatile ("movntdq %%xmm1,%0" : "=m" (r[i])); + 1257 3886864 : asm volatile ("movntdq %%xmm2,%0" : "=m" (s[i])); + 1258 3886864 : asm volatile ("movntdq %%xmm3,%0" : "=m" (t[i])); 1259 : } 1260 : 1261 : raid_sse_end(); @@ -1591,9 +1591,9 @@ 1529 : /* 1530 : * GEN6 (hexa parity with Cauchy matrix) SSSE3 implementation 1531 : */ - 1532 564213 : void raid_gen6_ssse3(int nd, size_t size, void **vv) + 1532 564177 : void raid_gen6_ssse3(int nd, size_t size, void **vv) 1533 : { - 1534 564213 : uint8_t **v = (uint8_t **)vv; + 1534 564177 : uint8_t **v = (uint8_t **)vv; 1535 : uint8_t *p; 1536 : uint8_t *q; 1537 : uint8_t *r; @@ -1603,142 +1603,142 @@ 1541 : int d, l; 1542 : size_t i; 1543 : uint8_t buffer[2*16+16]; - 1544 564213 : uint8_t *pd = __align_ptr(buffer, 16); + 1544 564177 : uint8_t *pd = __align_ptr(buffer, 16); 1545 : - 1546 564213 : l = nd - 1; - 1547 564213 : p = v[nd]; - 1548 564213 : q = v[nd + 1]; - 1549 564213 : r = v[nd + 2]; - 1550 564213 : s = v[nd + 3]; - 1551 564213 : t = v[nd + 4]; - 1552 564213 : u = v[nd + 5]; + 1546 564177 : l = nd - 1; + 1547 564177 : p = v[nd]; + 1548 564177 : q = v[nd + 1]; + 1549 564177 : r = v[nd + 2]; + 1550 564177 : s = v[nd + 3]; + 1551 564177 : t = v[nd + 4]; + 1552 564177 : u = v[nd + 5]; 1553 : 1554 : /* special case with only one data disk */ - 1555 564213 : if (l == 0) { + 1555 564177 : if (l == 0) { 1556 7 : for (i = 0; i < 6; ++i) 1557 6 : memcpy(v[1 + i], v[0], size); - 1558 564214 : return; + 1558 564178 : return; 1559 : } 1560 : 1561 : raid_sse_begin(); 1562 : 1563 : /* generic case with at least two data disks */ - 1564 36100420 : for (i = 0; i < size; i += 16) { + 1564 36098080 : for (i = 0; i < size; i += 16) { 1565 : /* last disk without the by two multiplication */ - 1566 35536208 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 1566 35533904 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 1567 : - 1568 35536208 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); - 1569 35536208 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[16])); + 1568 35533904 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); + 1569 35533904 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[16])); 1570 : - 1571 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1572 35536208 : asm volatile ("movdqa %xmm4,%xmm5"); - 1573 35536208 : asm volatile ("psrlw $4,%xmm5"); - 1574 35536208 : asm volatile ("pand %xmm7,%xmm4"); - 1575 35536208 : asm volatile ("pand %xmm7,%xmm5"); + 1571 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1572 35533904 : asm volatile ("movdqa %xmm4,%xmm5"); + 1573 35533904 : asm volatile ("psrlw $4,%xmm5"); + 1574 35533904 : asm volatile ("pand %xmm7,%xmm4"); + 1575 35533904 : asm volatile ("pand %xmm7,%xmm5"); 1576 : - 1577 35536208 : asm volatile ("movdqa %0,%%xmm0" : : "m" (gfgenpshufb[l][0][0][0])); - 1578 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 1579 35536208 : asm volatile ("pshufb %xmm4,%xmm0"); - 1580 35536208 : asm volatile ("pshufb %xmm5,%xmm7"); - 1581 35536208 : asm volatile ("pxor %xmm7,%xmm0"); + 1577 35533904 : asm volatile ("movdqa %0,%%xmm0" : : "m" (gfgenpshufb[l][0][0][0])); + 1578 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 1579 35533904 : asm volatile ("pshufb %xmm4,%xmm0"); + 1580 35533904 : asm volatile ("pshufb %xmm5,%xmm7"); + 1581 35533904 : asm volatile ("pxor %xmm7,%xmm0"); 1582 : - 1583 35536208 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][1][0][0])); - 1584 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 1585 35536208 : asm volatile ("pshufb %xmm4,%xmm1"); - 1586 35536208 : asm volatile ("pshufb %xmm5,%xmm7"); - 1587 35536208 : asm volatile ("pxor %xmm7,%xmm1"); + 1583 35533904 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][1][0][0])); + 1584 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 1585 35533904 : asm volatile ("pshufb %xmm4,%xmm1"); + 1586 35533904 : asm volatile ("pshufb %xmm5,%xmm7"); + 1587 35533904 : asm volatile ("pxor %xmm7,%xmm1"); 1588 : - 1589 35536208 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][2][0][0])); - 1590 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); - 1591 35536208 : asm volatile ("pshufb %xmm4,%xmm2"); - 1592 35536208 : asm volatile ("pshufb %xmm5,%xmm7"); - 1593 35536208 : asm volatile ("pxor %xmm7,%xmm2"); + 1589 35533904 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][2][0][0])); + 1590 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); + 1591 35533904 : asm volatile ("pshufb %xmm4,%xmm2"); + 1592 35533904 : asm volatile ("pshufb %xmm5,%xmm7"); + 1593 35533904 : asm volatile ("pxor %xmm7,%xmm2"); 1594 : - 1595 35536208 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][3][0][0])); - 1596 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][3][1][0])); - 1597 35536208 : asm volatile ("pshufb %xmm4,%xmm3"); - 1598 35536208 : asm volatile ("pshufb %xmm5,%xmm7"); - 1599 35536208 : asm volatile ("pxor %xmm7,%xmm3"); + 1595 35533904 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][3][0][0])); + 1596 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][3][1][0])); + 1597 35533904 : asm volatile ("pshufb %xmm4,%xmm3"); + 1598 35533904 : asm volatile ("pshufb %xmm5,%xmm7"); + 1599 35533904 : asm volatile ("pxor %xmm7,%xmm3"); 1600 : 1601 : /* intermediate disks */ - 1602 183685936 : for (d = l - 1; d > 0; --d) { - 1603 148149728 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); - 1604 148149728 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); - 1605 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1602 183674416 : for (d = l - 1; d > 0; --d) { + 1603 148140512 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); + 1604 148140512 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); + 1605 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1606 : - 1607 148149728 : asm volatile ("pxor %xmm4,%xmm4"); - 1608 148149728 : asm volatile ("pcmpgtb %xmm6,%xmm4"); - 1609 148149728 : asm volatile ("paddb %xmm6,%xmm6"); - 1610 148149728 : asm volatile ("pand %xmm7,%xmm4"); - 1611 148149728 : asm volatile ("pxor %xmm4,%xmm6"); + 1607 148140512 : asm volatile ("pxor %xmm4,%xmm4"); + 1608 148140512 : asm volatile ("pcmpgtb %xmm6,%xmm4"); + 1609 148140512 : asm volatile ("paddb %xmm6,%xmm6"); + 1610 148140512 : asm volatile ("pand %xmm7,%xmm4"); + 1611 148140512 : asm volatile ("pxor %xmm4,%xmm6"); 1612 : - 1613 148149728 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 1613 148140512 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); 1614 : - 1615 148149728 : asm volatile ("pxor %xmm4,%xmm5"); - 1616 148149728 : asm volatile ("pxor %xmm4,%xmm6"); - 1617 148149728 : asm volatile ("movdqa %%xmm5,%0" : "=m" (pd[0])); - 1618 148149728 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[16])); + 1615 148140512 : asm volatile ("pxor %xmm4,%xmm5"); + 1616 148140512 : asm volatile ("pxor %xmm4,%xmm6"); + 1617 148140512 : asm volatile ("movdqa %%xmm5,%0" : "=m" (pd[0])); + 1618 148140512 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[16])); 1619 : - 1620 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1621 148149728 : asm volatile ("movdqa %xmm4,%xmm5"); - 1622 148149728 : asm volatile ("psrlw $4,%xmm5"); - 1623 148149728 : asm volatile ("pand %xmm7,%xmm4"); - 1624 148149728 : asm volatile ("pand %xmm7,%xmm5"); + 1620 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1621 148140512 : asm volatile ("movdqa %xmm4,%xmm5"); + 1622 148140512 : asm volatile ("psrlw $4,%xmm5"); + 1623 148140512 : asm volatile ("pand %xmm7,%xmm4"); + 1624 148140512 : asm volatile ("pand %xmm7,%xmm5"); 1625 : - 1626 148149728 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 1627 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 1628 148149728 : asm volatile ("pshufb %xmm4,%xmm6"); - 1629 148149728 : asm volatile ("pshufb %xmm5,%xmm7"); - 1630 148149728 : asm volatile ("pxor %xmm6,%xmm0"); - 1631 148149728 : asm volatile ("pxor %xmm7,%xmm0"); + 1626 148140512 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 1627 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 1628 148140512 : asm volatile ("pshufb %xmm4,%xmm6"); + 1629 148140512 : asm volatile ("pshufb %xmm5,%xmm7"); + 1630 148140512 : asm volatile ("pxor %xmm6,%xmm0"); + 1631 148140512 : asm volatile ("pxor %xmm7,%xmm0"); 1632 : - 1633 148149728 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 1634 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 1635 148149728 : asm volatile ("pshufb %xmm4,%xmm6"); - 1636 148149728 : asm volatile ("pshufb %xmm5,%xmm7"); - 1637 148149728 : asm volatile ("pxor %xmm6,%xmm1"); - 1638 148149728 : asm volatile ("pxor %xmm7,%xmm1"); + 1633 148140512 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 1634 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 1635 148140512 : asm volatile ("pshufb %xmm4,%xmm6"); + 1636 148140512 : asm volatile ("pshufb %xmm5,%xmm7"); + 1637 148140512 : asm volatile ("pxor %xmm6,%xmm1"); + 1638 148140512 : asm volatile ("pxor %xmm7,%xmm1"); 1639 : - 1640 148149728 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); - 1641 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); - 1642 148149728 : asm volatile ("pshufb %xmm4,%xmm6"); - 1643 148149728 : asm volatile ("pshufb %xmm5,%xmm7"); - 1644 148149728 : asm volatile ("pxor %xmm6,%xmm2"); - 1645 148149728 : asm volatile ("pxor %xmm7,%xmm2"); + 1640 148140512 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); + 1641 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); + 1642 148140512 : asm volatile ("pshufb %xmm4,%xmm6"); + 1643 148140512 : asm volatile ("pshufb %xmm5,%xmm7"); + 1644 148140512 : asm volatile ("pxor %xmm6,%xmm2"); + 1645 148140512 : asm volatile ("pxor %xmm7,%xmm2"); 1646 : - 1647 148149728 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][3][0][0])); - 1648 148149728 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][3][1][0])); - 1649 148149728 : asm volatile ("pshufb %xmm4,%xmm6"); - 1650 148149728 : asm volatile ("pshufb %xmm5,%xmm7"); - 1651 148149728 : asm volatile ("pxor %xmm6,%xmm3"); - 1652 148149728 : asm volatile ("pxor %xmm7,%xmm3"); + 1647 148140512 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][3][0][0])); + 1648 148140512 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][3][1][0])); + 1649 148140512 : asm volatile ("pshufb %xmm4,%xmm6"); + 1650 148140512 : asm volatile ("pshufb %xmm5,%xmm7"); + 1651 148140512 : asm volatile ("pxor %xmm6,%xmm3"); + 1652 148140512 : asm volatile ("pxor %xmm7,%xmm3"); 1653 : } 1654 : 1655 : /* first disk with all coefficients at 1 */ - 1656 35536208 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); - 1657 35536208 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); - 1658 35536208 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1656 35533904 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); + 1657 35533904 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); + 1658 35533904 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1659 : - 1660 35536208 : asm volatile ("pxor %xmm4,%xmm4"); - 1661 35536208 : asm volatile ("pcmpgtb %xmm6,%xmm4"); - 1662 35536208 : asm volatile ("paddb %xmm6,%xmm6"); - 1663 35536208 : asm volatile ("pand %xmm7,%xmm4"); - 1664 35536208 : asm volatile ("pxor %xmm4,%xmm6"); + 1660 35533904 : asm volatile ("pxor %xmm4,%xmm4"); + 1661 35533904 : asm volatile ("pcmpgtb %xmm6,%xmm4"); + 1662 35533904 : asm volatile ("paddb %xmm6,%xmm6"); + 1663 35533904 : asm volatile ("pand %xmm7,%xmm4"); + 1664 35533904 : asm volatile ("pxor %xmm4,%xmm6"); 1665 : - 1666 35536208 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); - 1667 35536208 : asm volatile ("pxor %xmm4,%xmm0"); - 1668 35536208 : asm volatile ("pxor %xmm4,%xmm1"); - 1669 35536208 : asm volatile ("pxor %xmm4,%xmm2"); - 1670 35536208 : asm volatile ("pxor %xmm4,%xmm3"); - 1671 35536208 : asm volatile ("pxor %xmm4,%xmm5"); - 1672 35536208 : asm volatile ("pxor %xmm4,%xmm6"); + 1666 35533904 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 1667 35533904 : asm volatile ("pxor %xmm4,%xmm0"); + 1668 35533904 : asm volatile ("pxor %xmm4,%xmm1"); + 1669 35533904 : asm volatile ("pxor %xmm4,%xmm2"); + 1670 35533904 : asm volatile ("pxor %xmm4,%xmm3"); + 1671 35533904 : asm volatile ("pxor %xmm4,%xmm5"); + 1672 35533904 : asm volatile ("pxor %xmm4,%xmm6"); 1673 : - 1674 35536208 : asm volatile ("movntdq %%xmm5,%0" : "=m" (p[i])); - 1675 35536208 : asm volatile ("movntdq %%xmm6,%0" : "=m" (q[i])); - 1676 35536208 : asm volatile ("movntdq %%xmm0,%0" : "=m" (r[i])); - 1677 35536208 : asm volatile ("movntdq %%xmm1,%0" : "=m" (s[i])); - 1678 35536208 : asm volatile ("movntdq %%xmm2,%0" : "=m" (t[i])); - 1679 35536208 : asm volatile ("movntdq %%xmm3,%0" : "=m" (u[i])); + 1674 35533904 : asm volatile ("movntdq %%xmm5,%0" : "=m" (p[i])); + 1675 35533904 : asm volatile ("movntdq %%xmm6,%0" : "=m" (q[i])); + 1676 35533904 : asm volatile ("movntdq %%xmm0,%0" : "=m" (r[i])); + 1677 35533904 : asm volatile ("movntdq %%xmm1,%0" : "=m" (s[i])); + 1678 35533904 : asm volatile ("movntdq %%xmm2,%0" : "=m" (t[i])); + 1679 35533904 : asm volatile ("movntdq %%xmm3,%0" : "=m" (u[i])); 1680 : } 1681 : 1682 : raid_sse_end(); @@ -2046,9 +2046,9 @@ 1984 : /* 1985 : * RAID recovering for one disk SSSE3 implementation 1986 : */ - 1987 111621 : void raid_rec1_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) + 1987 111395 : void raid_rec1_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) 1988 : { - 1989 111621 : uint8_t **v = (uint8_t **)vv; + 1989 111395 : uint8_t **v = (uint8_t **)vv; 1990 : uint8_t *p; 1991 : uint8_t *pa; 1992 : uint8_t G; @@ -2058,43 +2058,43 @@ 1996 : (void)nr; /* unused, it's always 1 */ 1997 : 1998 : /* if it's RAID5 uses the faster function */ - 1999 111621 : if (ip[0] == 0) { - 2000 101738 : raid_rec1of1(id, nd, size, vv); - 2001 213359 : return; + 1999 111395 : if (ip[0] == 0) { + 2000 101506 : raid_rec1of1(id, nd, size, vv); + 2001 212901 : return; 2002 : } 2003 : 2004 : /* setup the coefficients matrix */ - 2005 19766 : G = A(ip[0], id[0]); + 2005 19778 : G = A(ip[0], id[0]); 2006 : 2007 : /* invert it to solve the system of linear equations */ - 2008 19766 : V = inv(G); + 2008 19778 : V = inv(G); 2009 : 2010 : /* compute delta parity */ - 2011 9883 : raid_delta_gen(1, id, ip, nd, size, vv); + 2011 9889 : raid_delta_gen(1, id, ip, nd, size, vv); 2012 : - 2013 9883 : p = v[nd + ip[0]]; - 2014 9883 : pa = v[id[0]]; + 2013 9889 : p = v[nd + ip[0]]; + 2014 9889 : pa = v[id[0]]; 2015 : 2016 : raid_sse_begin(); 2017 : - 2018 9883 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 2019 9883 : asm volatile ("movdqa %0,%%xmm4" : : "m" (gfmulpshufb[V][0][0])); - 2020 9883 : asm volatile ("movdqa %0,%%xmm5" : : "m" (gfmulpshufb[V][1][0])); + 2018 9889 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 2019 9889 : asm volatile ("movdqa %0,%%xmm4" : : "m" (gfmulpshufb[V][0][0])); + 2020 9889 : asm volatile ("movdqa %0,%%xmm5" : : "m" (gfmulpshufb[V][1][0])); 2021 : - 2022 1552283 : for (i = 0; i < size; i += 16) { - 2023 1542400 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[i])); - 2024 1542400 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[i])); - 2025 1542400 : asm volatile ("movdqa %xmm4,%xmm2"); - 2026 1542400 : asm volatile ("movdqa %xmm5,%xmm3"); - 2027 1542400 : asm volatile ("pxor %xmm0,%xmm1"); - 2028 1542400 : asm volatile ("movdqa %xmm1,%xmm0"); - 2029 1542400 : asm volatile ("psrlw $4,%xmm1"); - 2030 1542400 : asm volatile ("pand %xmm7,%xmm0"); - 2031 1542400 : asm volatile ("pand %xmm7,%xmm1"); - 2032 1542400 : asm volatile ("pshufb %xmm0,%xmm2"); - 2033 1542400 : asm volatile ("pshufb %xmm1,%xmm3"); - 2034 1542400 : asm volatile ("pxor %xmm3,%xmm2"); - 2035 1542400 : asm volatile ("movdqa %%xmm2,%0" : "=m" (pa[i])); + 2022 1552673 : for (i = 0; i < size; i += 16) { + 2023 1542784 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[i])); + 2024 1542784 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[i])); + 2025 1542784 : asm volatile ("movdqa %xmm4,%xmm2"); + 2026 1542784 : asm volatile ("movdqa %xmm5,%xmm3"); + 2027 1542784 : asm volatile ("pxor %xmm0,%xmm1"); + 2028 1542784 : asm volatile ("movdqa %xmm1,%xmm0"); + 2029 1542784 : asm volatile ("psrlw $4,%xmm1"); + 2030 1542784 : asm volatile ("pand %xmm7,%xmm0"); + 2031 1542784 : asm volatile ("pand %xmm7,%xmm1"); + 2032 1542784 : asm volatile ("pshufb %xmm0,%xmm2"); + 2033 1542784 : asm volatile ("pshufb %xmm1,%xmm3"); + 2034 1542784 : asm volatile ("pxor %xmm3,%xmm2"); + 2035 1542784 : asm volatile ("movdqa %%xmm2,%0" : "=m" (pa[i])); 2036 : } 2037 : 2038 : raid_sse_end(); @@ -2105,106 +2105,106 @@ 2043 : /* 2044 : * RAID recovering for two disks SSSE3 implementation 2045 : */ - 2046 44056 : void raid_rec2_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) + 2046 44038 : void raid_rec2_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) 2047 : { - 2048 44056 : uint8_t **v = (uint8_t **)vv; - 2049 44056 : const int N = 2; - 2050 44056 : uint8_t *p[N]; - 2051 44056 : uint8_t *pa[N]; - 2052 44056 : uint8_t G[N * N]; - 2053 44056 : uint8_t V[N * N]; + 2048 44038 : uint8_t **v = (uint8_t **)vv; + 2049 44038 : const int N = 2; + 2050 44038 : uint8_t *p[N]; + 2051 44038 : uint8_t *pa[N]; + 2052 44038 : uint8_t G[N * N]; + 2053 44038 : uint8_t V[N * N]; 2054 : size_t i; 2055 : int j, k; 2056 : 2057 : (void)nr; /* unused, it's always 2 */ 2058 : 2059 : /* setup the coefficients matrix */ - 2060 132168 : for (j = 0; j < N; ++j) - 2061 264336 : for (k = 0; k < N; ++k) - 2062 352448 : G[j * N + k] = A(ip[j], id[k]); + 2060 132114 : for (j = 0; j < N; ++j) + 2061 264228 : for (k = 0; k < N; ++k) + 2062 352304 : G[j * N + k] = A(ip[j], id[k]); 2063 : 2064 : /* invert it to solve the system of linear equations */ - 2065 44056 : raid_invert(G, V, N); + 2065 44038 : raid_invert(G, V, N); 2066 : 2067 : /* compute delta parity */ - 2068 44056 : raid_delta_gen(N, id, ip, nd, size, vv); + 2068 44038 : raid_delta_gen(N, id, ip, nd, size, vv); 2069 : - 2070 132168 : for (j = 0; j < N; ++j) { - 2071 88112 : p[j] = v[nd + ip[j]]; - 2072 88112 : pa[j] = v[id[j]]; + 2070 132114 : for (j = 0; j < N; ++j) { + 2071 88076 : p[j] = v[nd + ip[j]]; + 2072 88076 : pa[j] = v[id[j]]; 2073 : } 2074 : 2075 : raid_sse_begin(); 2076 : - 2077 44056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 2077 44038 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 2078 : - 2079 3589976 : for (i = 0; i < size; i += 16) { - 2080 3545920 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[0][i])); - 2081 3545920 : asm volatile ("movdqa %0,%%xmm2" : : "m" (pa[0][i])); - 2082 3545920 : asm volatile ("movdqa %0,%%xmm1" : : "m" (p[1][i])); - 2083 3545920 : asm volatile ("movdqa %0,%%xmm3" : : "m" (pa[1][i])); - 2084 3545920 : asm volatile ("pxor %xmm2,%xmm0"); - 2085 3545920 : asm volatile ("pxor %xmm3,%xmm1"); + 2079 3588806 : for (i = 0; i < size; i += 16) { + 2080 3544768 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[0][i])); + 2081 3544768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (pa[0][i])); + 2082 3544768 : asm volatile ("movdqa %0,%%xmm1" : : "m" (p[1][i])); + 2083 3544768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (pa[1][i])); + 2084 3544768 : asm volatile ("pxor %xmm2,%xmm0"); + 2085 3544768 : asm volatile ("pxor %xmm3,%xmm1"); 2086 : - 2087 3545920 : asm volatile ("pxor %xmm6,%xmm6"); + 2087 3544768 : asm volatile ("pxor %xmm6,%xmm6"); 2088 : - 2089 3545920 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[0]][0][0])); - 2090 3545920 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[0]][1][0])); - 2091 3545920 : asm volatile ("movdqa %xmm0,%xmm4"); - 2092 3545920 : asm volatile ("movdqa %xmm0,%xmm5"); - 2093 3545920 : asm volatile ("psrlw $4,%xmm5"); - 2094 3545920 : asm volatile ("pand %xmm7,%xmm4"); - 2095 3545920 : asm volatile ("pand %xmm7,%xmm5"); - 2096 3545920 : asm volatile ("pshufb %xmm4,%xmm2"); - 2097 3545920 : asm volatile ("pshufb %xmm5,%xmm3"); - 2098 3545920 : asm volatile ("pxor %xmm2,%xmm6"); - 2099 3545920 : asm volatile ("pxor %xmm3,%xmm6"); + 2089 3544768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[0]][0][0])); + 2090 3544768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[0]][1][0])); + 2091 3544768 : asm volatile ("movdqa %xmm0,%xmm4"); + 2092 3544768 : asm volatile ("movdqa %xmm0,%xmm5"); + 2093 3544768 : asm volatile ("psrlw $4,%xmm5"); + 2094 3544768 : asm volatile ("pand %xmm7,%xmm4"); + 2095 3544768 : asm volatile ("pand %xmm7,%xmm5"); + 2096 3544768 : asm volatile ("pshufb %xmm4,%xmm2"); + 2097 3544768 : asm volatile ("pshufb %xmm5,%xmm3"); + 2098 3544768 : asm volatile ("pxor %xmm2,%xmm6"); + 2099 3544768 : asm volatile ("pxor %xmm3,%xmm6"); 2100 : - 2101 3545920 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[1]][0][0])); - 2102 3545920 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[1]][1][0])); - 2103 3545920 : asm volatile ("movdqa %xmm1,%xmm4"); - 2104 3545920 : asm volatile ("movdqa %xmm1,%xmm5"); - 2105 3545920 : asm volatile ("psrlw $4,%xmm5"); - 2106 3545920 : asm volatile ("pand %xmm7,%xmm4"); - 2107 3545920 : asm volatile ("pand %xmm7,%xmm5"); - 2108 3545920 : asm volatile ("pshufb %xmm4,%xmm2"); - 2109 3545920 : asm volatile ("pshufb %xmm5,%xmm3"); - 2110 3545920 : asm volatile ("pxor %xmm2,%xmm6"); - 2111 3545920 : asm volatile ("pxor %xmm3,%xmm6"); + 2101 3544768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[1]][0][0])); + 2102 3544768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[1]][1][0])); + 2103 3544768 : asm volatile ("movdqa %xmm1,%xmm4"); + 2104 3544768 : asm volatile ("movdqa %xmm1,%xmm5"); + 2105 3544768 : asm volatile ("psrlw $4,%xmm5"); + 2106 3544768 : asm volatile ("pand %xmm7,%xmm4"); + 2107 3544768 : asm volatile ("pand %xmm7,%xmm5"); + 2108 3544768 : asm volatile ("pshufb %xmm4,%xmm2"); + 2109 3544768 : asm volatile ("pshufb %xmm5,%xmm3"); + 2110 3544768 : asm volatile ("pxor %xmm2,%xmm6"); + 2111 3544768 : asm volatile ("pxor %xmm3,%xmm6"); 2112 : - 2113 3545920 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[0][i])); + 2113 3544768 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[0][i])); 2114 : - 2115 3545920 : asm volatile ("pxor %xmm6,%xmm6"); + 2115 3544768 : asm volatile ("pxor %xmm6,%xmm6"); 2116 : - 2117 3545920 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[2]][0][0])); - 2118 3545920 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[2]][1][0])); - 2119 3545920 : asm volatile ("movdqa %xmm0,%xmm4"); - 2120 3545920 : asm volatile ("movdqa %xmm0,%xmm5"); - 2121 3545920 : asm volatile ("psrlw $4,%xmm5"); - 2122 3545920 : asm volatile ("pand %xmm7,%xmm4"); - 2123 3545920 : asm volatile ("pand %xmm7,%xmm5"); - 2124 3545920 : asm volatile ("pshufb %xmm4,%xmm2"); - 2125 3545920 : asm volatile ("pshufb %xmm5,%xmm3"); - 2126 3545920 : asm volatile ("pxor %xmm2,%xmm6"); - 2127 3545920 : asm volatile ("pxor %xmm3,%xmm6"); + 2117 3544768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[2]][0][0])); + 2118 3544768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[2]][1][0])); + 2119 3544768 : asm volatile ("movdqa %xmm0,%xmm4"); + 2120 3544768 : asm volatile ("movdqa %xmm0,%xmm5"); + 2121 3544768 : asm volatile ("psrlw $4,%xmm5"); + 2122 3544768 : asm volatile ("pand %xmm7,%xmm4"); + 2123 3544768 : asm volatile ("pand %xmm7,%xmm5"); + 2124 3544768 : asm volatile ("pshufb %xmm4,%xmm2"); + 2125 3544768 : asm volatile ("pshufb %xmm5,%xmm3"); + 2126 3544768 : asm volatile ("pxor %xmm2,%xmm6"); + 2127 3544768 : asm volatile ("pxor %xmm3,%xmm6"); 2128 : - 2129 3545920 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[3]][0][0])); - 2130 3545920 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[3]][1][0])); - 2131 3545920 : asm volatile ("movdqa %xmm1,%xmm4"); - 2132 3545920 : asm volatile ("movdqa %xmm1,%xmm5"); - 2133 3545920 : asm volatile ("psrlw $4,%xmm5"); - 2134 3545920 : asm volatile ("pand %xmm7,%xmm4"); - 2135 3545920 : asm volatile ("pand %xmm7,%xmm5"); - 2136 3545920 : asm volatile ("pshufb %xmm4,%xmm2"); - 2137 3545920 : asm volatile ("pshufb %xmm5,%xmm3"); - 2138 3545920 : asm volatile ("pxor %xmm2,%xmm6"); - 2139 3545920 : asm volatile ("pxor %xmm3,%xmm6"); + 2129 3544768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[3]][0][0])); + 2130 3544768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[3]][1][0])); + 2131 3544768 : asm volatile ("movdqa %xmm1,%xmm4"); + 2132 3544768 : asm volatile ("movdqa %xmm1,%xmm5"); + 2133 3544768 : asm volatile ("psrlw $4,%xmm5"); + 2134 3544768 : asm volatile ("pand %xmm7,%xmm4"); + 2135 3544768 : asm volatile ("pand %xmm7,%xmm5"); + 2136 3544768 : asm volatile ("pshufb %xmm4,%xmm2"); + 2137 3544768 : asm volatile ("pshufb %xmm5,%xmm3"); + 2138 3544768 : asm volatile ("pxor %xmm2,%xmm6"); + 2139 3544768 : asm volatile ("pxor %xmm3,%xmm6"); 2140 : - 2141 3545920 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[1][i])); + 2141 3544768 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[1][i])); 2142 : } 2143 : 2144 : raid_sse_end(); - 2145 44056 : } + 2145 44038 : } 2146 : #endif 2147 : 2148 : #if defined(CONFIG_X86) && defined(CONFIG_SSSE3) diff --git a/cov/raid/x86z.c.func-sort-c.html b/cov/raid/x86z.c.func-sort-c.html index 1631ce5f..4b3634ae 100644 --- a/cov/raid/x86z.c.func-sort-c.html +++ b/cov/raid/x86z.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ raid_genz_sse2 - 1174 + 1176
diff --git a/cov/raid/x86z.c.func.html b/cov/raid/x86z.c.func.html index 4a83023c..b6fdb7c1 100644 --- a/cov/raid/x86z.c.func.html +++ b/cov/raid/x86z.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -61,7 +61,7 @@ raid_genz_sse2 - 1174 + 1176
diff --git a/cov/raid/x86z.c.gcov.html b/cov/raid/x86z.c.gcov.html index 74725de8..6a1f08a2 100644 --- a/cov/raid/x86z.c.gcov.html +++ b/cov/raid/x86z.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 @@ -102,58 +102,58 @@ 40 : /* 41 : * GENz (triple parity with powers of 2^-1) SSE2 implementation 42 : */ - 43 1174 : void raid_genz_sse2(int nd, size_t size, void **vv) + 43 1176 : void raid_genz_sse2(int nd, size_t size, void **vv) 44 : { - 45 1174 : uint8_t **v = (uint8_t**)vv; + 45 1176 : uint8_t **v = (uint8_t**)vv; 46 : uint8_t *p; 47 : uint8_t *q; 48 : uint8_t *r; 49 : int d, l; 50 : size_t i; 51 : - 52 1174 : l = nd - 1; - 53 1174 : p = v[nd]; - 54 1174 : q = v[nd + 1]; - 55 1174 : r = v[nd + 2]; + 52 1176 : l = nd - 1; + 53 1176 : p = v[nd]; + 54 1176 : q = v[nd + 1]; + 55 1176 : r = v[nd + 2]; 56 : 57 : raid_sse_begin(); 58 : - 59 1174 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfzconst16.poly[0])); - 60 1174 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfzconst16.half[0])); - 61 1174 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfzconst16.low7[0])); + 59 1176 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfzconst16.poly[0])); + 60 1176 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfzconst16.half[0])); + 61 1176 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfzconst16.low7[0])); 62 : - 63 1345766 : for (i = 0; i < size; i += 16) { - 64 1344592 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); - 65 1344592 : asm volatile ("movdqa %xmm0,%xmm1"); - 66 1344592 : asm volatile ("movdqa %xmm0,%xmm2"); - 67 10827008 : for (d = l - 1; d >= 0; --d) { - 68 9482416 : asm volatile ("pxor %xmm4,%xmm4"); - 69 9482416 : asm volatile ("pcmpgtb %xmm1,%xmm4"); - 70 9482416 : asm volatile ("paddb %xmm1,%xmm1"); - 71 9482416 : asm volatile ("pand %xmm7,%xmm4"); - 72 9482416 : asm volatile ("pxor %xmm4,%xmm1"); + 63 1378536 : for (i = 0; i < size; i += 16) { + 64 1377360 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); + 65 1377360 : asm volatile ("movdqa %xmm0,%xmm1"); + 66 1377360 : asm volatile ("movdqa %xmm0,%xmm2"); + 67 11089152 : for (d = l - 1; d >= 0; --d) { + 68 9711792 : asm volatile ("pxor %xmm4,%xmm4"); + 69 9711792 : asm volatile ("pcmpgtb %xmm1,%xmm4"); + 70 9711792 : asm volatile ("paddb %xmm1,%xmm1"); + 71 9711792 : asm volatile ("pand %xmm7,%xmm4"); + 72 9711792 : asm volatile ("pxor %xmm4,%xmm1"); 73 : - 74 9482416 : asm volatile ("movdqa %xmm2,%xmm4"); - 75 9482416 : asm volatile ("pxor %xmm5,%xmm5"); - 76 9482416 : asm volatile ("psllw $7,%xmm4"); - 77 9482416 : asm volatile ("psrlw $1,%xmm2"); - 78 9482416 : asm volatile ("pcmpgtb %xmm4,%xmm5"); - 79 9482416 : asm volatile ("pand %xmm6,%xmm2"); - 80 9482416 : asm volatile ("pand %xmm3,%xmm5"); - 81 9482416 : asm volatile ("pxor %xmm5,%xmm2"); + 74 9711792 : asm volatile ("movdqa %xmm2,%xmm4"); + 75 9711792 : asm volatile ("pxor %xmm5,%xmm5"); + 76 9711792 : asm volatile ("psllw $7,%xmm4"); + 77 9711792 : asm volatile ("psrlw $1,%xmm2"); + 78 9711792 : asm volatile ("pcmpgtb %xmm4,%xmm5"); + 79 9711792 : asm volatile ("pand %xmm6,%xmm2"); + 80 9711792 : asm volatile ("pand %xmm3,%xmm5"); + 81 9711792 : asm volatile ("pxor %xmm5,%xmm2"); 82 : - 83 9482416 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); - 84 9482416 : asm volatile ("pxor %xmm4,%xmm0"); - 85 9482416 : asm volatile ("pxor %xmm4,%xmm1"); - 86 9482416 : asm volatile ("pxor %xmm4,%xmm2"); + 83 9711792 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 84 9711792 : asm volatile ("pxor %xmm4,%xmm0"); + 85 9711792 : asm volatile ("pxor %xmm4,%xmm1"); + 86 9711792 : asm volatile ("pxor %xmm4,%xmm2"); 87 : } - 88 1344592 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 89 1344592 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); - 90 1344592 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); + 88 1377360 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 89 1377360 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); + 90 1377360 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); 91 : } 92 : 93 : raid_sse_end(); - 94 1174 : } + 94 1176 : } 95 : #endif 96 : 97 : #if defined(CONFIG_X86_64) && defined(CONFIG_SSE2) diff --git a/cov/tommyds/index-sort-f.html b/cov/tommyds/index-sort-f.html index 08c3e846..1aac10bb 100644 --- a/cov/tommyds/index-sort-f.html +++ b/cov/tommyds/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 76 diff --git a/cov/tommyds/index-sort-l.html b/cov/tommyds/index-sort-l.html index ea3ee796..85809ff9 100644 --- a/cov/tommyds/index-sort-l.html +++ b/cov/tommyds/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 76 diff --git a/cov/tommyds/index.html b/cov/tommyds/index.html index 40867411..ad75eb65 100644 --- a/cov/tommyds/index.html +++ b/cov/tommyds/index.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 76 diff --git a/cov/tommyds/tommyarray.c.func-sort-c.html b/cov/tommyds/tommyarray.c.func-sort-c.html index e115e780..5a3f8371 100644 --- a/cov/tommyds/tommyarray.c.func-sort-c.html +++ b/cov/tommyds/tommyarray.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,15 +61,15 @@ tommy_array_grow - 2208 + 2214 tommy_array_init - 521 + 523 tommy_array_done - 497 + 499 tommy_array_memory_usage diff --git a/cov/tommyds/tommyarray.c.func.html b/cov/tommyds/tommyarray.c.func.html index 7c16efad..945e89e6 100644 --- a/cov/tommyds/tommyarray.c.func.html +++ b/cov/tommyds/tommyarray.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,15 +61,15 @@ tommy_array_done - 497 + 499 tommy_array_grow - 2208 + 2214 tommy_array_init - 521 + 523 tommy_array_memory_usage diff --git a/cov/tommyds/tommyarray.c.gcov.html b/cov/tommyds/tommyarray.c.gcov.html index 0a0f2952..19d8f82f 100644 --- a/cov/tommyds/tommyarray.c.gcov.html +++ b/cov/tommyds/tommyarray.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -92,38 +92,38 @@ 30 : /******************************************************************************/ 31 : /* array */ 32 : - 33 521 : void tommy_array_init(tommy_array* array) + 33 523 : void tommy_array_init(tommy_array* array) 34 : { 35 : tommy_uint_t i; 36 : 37 : /* fixed initial size */ - 38 521 : array->bucket_bit = TOMMY_ARRAY_BIT; - 39 521 : array->bucket_max = 1 << array->bucket_bit; - 40 521 : array->bucket[0] = tommy_cast(void**, tommy_calloc(array->bucket_max, sizeof(void*))); - 41 3126 : for (i = 1; i < TOMMY_ARRAY_BIT; ++i) - 42 2605 : array->bucket[i] = array->bucket[0]; + 38 523 : array->bucket_bit = TOMMY_ARRAY_BIT; + 39 523 : array->bucket_max = 1 << array->bucket_bit; + 40 523 : array->bucket[0] = tommy_cast(void**, tommy_calloc(array->bucket_max, sizeof(void*))); + 41 3138 : for (i = 1; i < TOMMY_ARRAY_BIT; ++i) + 42 2615 : array->bucket[i] = array->bucket[0]; 43 : - 44 521 : array->count = 0; - 45 521 : } + 44 523 : array->count = 0; + 45 523 : } 46 : - 47 497 : void tommy_array_done(tommy_array* array) + 47 499 : void tommy_array_done(tommy_array* array) 48 : { 49 : tommy_uint_t i; 50 : - 51 497 : tommy_free(array->bucket[0]); - 52 499 : for (i = TOMMY_ARRAY_BIT; i < array->bucket_bit; ++i) { + 51 499 : tommy_free(array->bucket[0]); + 52 501 : for (i = TOMMY_ARRAY_BIT; i < array->bucket_bit; ++i) { 53 2 : void** segment = array->bucket[i]; 54 2 : tommy_free(&segment[((tommy_ptrdiff_t)1) << i]); 55 : } - 56 497 : } + 56 499 : } 57 : - 58 2208 : void tommy_array_grow(tommy_array* array, tommy_count_t count) + 58 2214 : void tommy_array_grow(tommy_array* array, tommy_count_t count) 59 : { - 60 2208 : if (array->count >= count) - 61 2208 : return; - 62 2208 : array->count = count; + 60 2214 : if (array->count >= count) + 61 2214 : return; + 62 2214 : array->count = count; 63 : - 64 4418 : while (count > array->bucket_max) { + 64 4430 : while (count > array->bucket_max) { 65 : void** segment; 66 : 67 : /* allocate one more segment */ diff --git a/cov/tommyds/tommyarray.h.func-sort-c.html b/cov/tommyds/tommyarray.h.func-sort-c.html index 95ea2d0e..1969ed9c 100644 --- a/cov/tommyds/tommyarray.h.func-sort-c.html +++ b/cov/tommyds/tommyarray.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -61,19 +61,19 @@ tommy_array_ref - 10268715 + 10268668 tommy_array_get - 10266507 + 10266454 tommy_array_size - 1575720 + 1575778 tommy_array_set - 2208 + 2214 tommy_array_insert diff --git a/cov/tommyds/tommyarray.h.func.html b/cov/tommyds/tommyarray.h.func.html index cf45dc82..4b216f81 100644 --- a/cov/tommyds/tommyarray.h.func.html +++ b/cov/tommyds/tommyarray.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -61,7 +61,7 @@ tommy_array_get - 10266507 + 10266454 tommy_array_insert @@ -69,15 +69,15 @@ tommy_array_ref - 10268715 + 10268668 tommy_array_set - 2208 + 2214 tommy_array_size - 1575720 + 1575778
diff --git a/cov/tommyds/tommyarray.h.gcov.html b/cov/tommyds/tommyarray.h.gcov.html index 1015219a..41939361 100644 --- a/cov/tommyds/tommyarray.h.gcov.html +++ b/cov/tommyds/tommyarray.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -152,16 +152,16 @@ 90 : * You must be sure that space for this position is already 91 : * allocated calling tommy_array_grow(). 92 : */ - 93 10268715 : tommy_inline void** tommy_array_ref(tommy_array* array, tommy_count_t pos) + 93 10268668 : tommy_inline void** tommy_array_ref(tommy_array* array, tommy_count_t pos) 94 : { 95 : tommy_uint_t bsr; 96 : - 97 10268715 : assert(pos < array->count); + 97 10268668 : assert(pos < array->count); 98 : 99 : /* get the highest bit set, in case of all 0, return 0 */ - 100 10268715 : bsr = tommy_ilog2_u32(pos | 1); + 100 10268668 : bsr = tommy_ilog2_u32(pos | 1); 101 : - 102 10268715 : return &array->bucket[bsr][pos]; + 102 10268668 : return &array->bucket[bsr][pos]; 103 : } 104 : 105 : /** @@ -169,19 +169,19 @@ 107 : * You must be sure that space for this position is already 108 : * allocated calling tommy_array_grow(). 109 : */ - 110 2208 : tommy_inline void tommy_array_set(tommy_array* array, tommy_count_t pos, void* element) + 110 2214 : tommy_inline void tommy_array_set(tommy_array* array, tommy_count_t pos, void* element) 111 : { - 112 2208 : *tommy_array_ref(array, pos) = element; - 113 2208 : } + 112 2214 : *tommy_array_ref(array, pos) = element; + 113 2214 : } 114 : 115 : /** 116 : * Gets the element at the specified position. 117 : * You must be sure that space for this position is already 118 : * allocated calling tommy_array_grow(). 119 : */ - 120 10266507 : tommy_inline void* tommy_array_get(tommy_array* array, tommy_count_t pos) + 120 10266454 : tommy_inline void* tommy_array_get(tommy_array* array, tommy_count_t pos) 121 : { - 122 10266507 : return *tommy_array_ref(array, pos); + 122 10266454 : return *tommy_array_ref(array, pos); 123 : } 124 : 125 : /** @@ -199,9 +199,9 @@ 137 : /** 138 : * Gets the initialized size of the array. 139 : */ - 140 1575720 : tommy_inline tommy_count_t tommy_array_size(tommy_array* array) + 140 1575778 : tommy_inline tommy_count_t tommy_array_size(tommy_array* array) 141 : { - 142 1575720 : return array->count; + 142 1575778 : return array->count; 143 : } 144 : 145 : /** diff --git a/cov/tommyds/tommyarrayblkof.c.func-sort-c.html b/cov/tommyds/tommyarrayblkof.c.func-sort-c.html index 1655a127..ca7ec51f 100644 --- a/cov/tommyds/tommyarrayblkof.c.func-sort-c.html +++ b/cov/tommyds/tommyarrayblkof.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,15 +61,15 @@ tommy_arrayblkof_grow - 1698354 + 1698377 tommy_arrayblkof_init - 267 + 268 tommy_arrayblkof_done - 244 + 245 tommy_arrayblkof_memory_usage diff --git a/cov/tommyds/tommyarrayblkof.c.func.html b/cov/tommyds/tommyarrayblkof.c.func.html index 0298d5a6..a2043ce2 100644 --- a/cov/tommyds/tommyarrayblkof.c.func.html +++ b/cov/tommyds/tommyarrayblkof.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,15 +61,15 @@ tommy_arrayblkof_done - 244 + 245 tommy_arrayblkof_grow - 1698354 + 1698377 tommy_arrayblkof_init - 267 + 268 tommy_arrayblkof_memory_usage diff --git a/cov/tommyds/tommyarrayblkof.c.gcov.html b/cov/tommyds/tommyarrayblkof.c.gcov.html index 86df9035..7c6784d6 100644 --- a/cov/tommyds/tommyarrayblkof.c.gcov.html +++ b/cov/tommyds/tommyarrayblkof.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -92,48 +92,48 @@ 30 : /******************************************************************************/ 31 : /* array */ 32 : - 33 267 : void tommy_arrayblkof_init(tommy_arrayblkof* array, tommy_size_t element_size) + 33 268 : void tommy_arrayblkof_init(tommy_arrayblkof* array, tommy_size_t element_size) 34 : { - 35 267 : tommy_array_init(&array->block); + 35 268 : tommy_array_init(&array->block); 36 : - 37 267 : array->element_size = element_size; - 38 267 : array->count = 0; - 39 267 : } + 37 268 : array->element_size = element_size; + 38 268 : array->count = 0; + 39 268 : } 40 : - 41 244 : void tommy_arrayblkof_done(tommy_arrayblkof* array) + 41 245 : void tommy_arrayblkof_done(tommy_arrayblkof* array) 42 : { 43 : tommy_count_t i; 44 : - 45 768 : for (i = 0; i < tommy_array_size(&array->block); ++i) - 46 524 : tommy_free(tommy_array_get(&array->block, i)); + 45 770 : for (i = 0; i < tommy_array_size(&array->block); ++i) + 46 525 : tommy_free(tommy_array_get(&array->block, i)); 47 : - 48 244 : tommy_array_done(&array->block); - 49 244 : } + 48 245 : tommy_array_done(&array->block); + 49 245 : } 50 : - 51 1698354 : void tommy_arrayblkof_grow(tommy_arrayblkof* array, tommy_count_t count) + 51 1698377 : void tommy_arrayblkof_grow(tommy_arrayblkof* array, tommy_count_t count) 52 : { 53 : tommy_count_t block_max; 54 : tommy_count_t block_mac; 55 : - 56 1698354 : if (array->count >= count) - 57 1821757 : return; - 58 1574951 : array->count = count; + 56 1698377 : if (array->count >= count) + 57 1821747 : return; + 58 1575007 : array->count = count; 59 : - 60 1574951 : block_max = (count + TOMMY_ARRAYBLKOF_SIZE - 1) / TOMMY_ARRAYBLKOF_SIZE; - 61 1574951 : block_mac = tommy_array_size(&array->block); + 60 1575007 : block_max = (count + TOMMY_ARRAYBLKOF_SIZE - 1) / TOMMY_ARRAYBLKOF_SIZE; + 61 1575007 : block_mac = tommy_array_size(&array->block); 62 : - 63 1574951 : if (block_mac < block_max) { + 63 1575007 : if (block_mac < block_max) { 64 : /* grow the block array */ - 65 554 : tommy_array_grow(&array->block, block_max); + 65 555 : tommy_array_grow(&array->block, block_max); 66 : 67 : /* allocate new blocks */ - 68 1662 : while (block_mac < block_max) { - 69 554 : void** ptr = tommy_cast(void**, tommy_calloc(TOMMY_ARRAYBLKOF_SIZE, array->element_size)); + 68 1665 : while (block_mac < block_max) { + 69 555 : void** ptr = tommy_cast(void**, tommy_calloc(TOMMY_ARRAYBLKOF_SIZE, array->element_size)); 70 : 71 : /* set the new block */ - 72 554 : tommy_array_set(&array->block, block_mac, ptr); + 72 555 : tommy_array_set(&array->block, block_mac, ptr); 73 : - 74 554 : ++block_mac; + 74 555 : ++block_mac; 75 : } 76 : } 77 : } diff --git a/cov/tommyds/tommyarrayblkof.h.func-sort-c.html b/cov/tommyds/tommyarrayblkof.h.func-sort-c.html index 671bddbe..f0445720 100644 --- a/cov/tommyds/tommyarrayblkof.h.func-sort-c.html +++ b/cov/tommyds/tommyarrayblkof.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ tommy_arrayblkof_ref - 6534594 + 6534659 tommy_arrayblkof_size - 5098627 + 5098669
diff --git a/cov/tommyds/tommyarrayblkof.h.func.html b/cov/tommyds/tommyarrayblkof.h.func.html index 254995bd..63d16647 100644 --- a/cov/tommyds/tommyarrayblkof.h.func.html +++ b/cov/tommyds/tommyarrayblkof.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ tommy_arrayblkof_ref - 6534594 + 6534659 tommy_arrayblkof_size - 5098627 + 5098669
diff --git a/cov/tommyds/tommyarrayblkof.h.gcov.html b/cov/tommyds/tommyarrayblkof.h.gcov.html index edffddf2..93bf2682 100644 --- a/cov/tommyds/tommyarrayblkof.h.gcov.html +++ b/cov/tommyds/tommyarrayblkof.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -148,23 +148,23 @@ 86 : * You must be sure that space for this position is already 87 : * allocated calling tommy_arrayblkof_grow(). 88 : */ - 89 6534594 : tommy_inline void* tommy_arrayblkof_ref(tommy_arrayblkof* array, tommy_count_t pos) + 89 6534659 : tommy_inline void* tommy_arrayblkof_ref(tommy_arrayblkof* array, tommy_count_t pos) 90 : { 91 : unsigned char* base; 92 : - 93 6534594 : assert(pos < array->count); + 93 6534659 : assert(pos < array->count); 94 : - 95 6534594 : base = tommy_cast(unsigned char*, tommy_array_get(&array->block, pos / TOMMY_ARRAYBLKOF_SIZE)); + 95 6534659 : base = tommy_cast(unsigned char*, tommy_array_get(&array->block, pos / TOMMY_ARRAYBLKOF_SIZE)); 96 : - 97 6534594 : return base + (pos % TOMMY_ARRAYBLKOF_SIZE) * array->element_size; + 97 6534659 : return base + (pos % TOMMY_ARRAYBLKOF_SIZE) * array->element_size; 98 : } 99 : 100 : /** 101 : * Gets the initialized size of the array. 102 : */ - 103 5098627 : tommy_inline tommy_count_t tommy_arrayblkof_size(tommy_arrayblkof* array) + 103 5098669 : tommy_inline tommy_count_t tommy_arrayblkof_size(tommy_arrayblkof* array) 104 : { - 105 5098627 : return array->count; + 105 5098669 : return array->count; 106 : } 107 : 108 : /** diff --git a/cov/tommyds/tommychain.h.func-sort-c.html b/cov/tommyds/tommychain.h.func-sort-c.html index cd51b466..e2cfdd86 100644 --- a/cov/tommyds/tommychain.h.func-sort-c.html +++ b/cov/tommyds/tommychain.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -61,19 +61,19 @@ tommy_chain_splice - 4492296 + 4491318 tommy_chain_merge_degenerated - 1283291 + 1283280 tommy_chain_concat - 1276680 + 1276623 tommy_chain_merge - 470675 + 470639 tommy_chain_mergesort diff --git a/cov/tommyds/tommychain.h.func.html b/cov/tommyds/tommychain.h.func.html index 7584db51..094728af 100644 --- a/cov/tommyds/tommychain.h.func.html +++ b/cov/tommyds/tommychain.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -61,15 +61,15 @@ tommy_chain_concat - 1276680 + 1276623 tommy_chain_merge - 470675 + 470639 tommy_chain_merge_degenerated - 1283291 + 1283280 tommy_chain_mergesort @@ -77,7 +77,7 @@ tommy_chain_splice - 4492296 + 4491318
diff --git a/cov/tommyds/tommychain.h.gcov.html b/cov/tommyds/tommychain.h.gcov.html index ac4fc97a..0438c98f 100644 --- a/cov/tommyds/tommychain.h.gcov.html +++ b/cov/tommyds/tommychain.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 5 @@ -119,83 +119,83 @@ 57 : /** 58 : * Splices a chain in the middle of another chain. 59 : */ - 60 4492296 : tommy_inline void tommy_chain_splice(tommy_node* first_before, tommy_node* first_after, tommy_node* second_head, tommy_node* second_tail) + 60 4491318 : tommy_inline void tommy_chain_splice(tommy_node* first_before, tommy_node* first_after, tommy_node* second_head, tommy_node* second_tail) 61 : { 62 : /* set the prev list */ - 63 4492296 : first_after->prev = second_tail; - 64 4492296 : second_head->prev = first_before; + 63 4491318 : first_after->prev = second_tail; + 64 4491318 : second_head->prev = first_before; 65 : 66 : /* set the next list */ - 67 4492296 : first_before->next = second_head; - 68 4492296 : second_tail->next = first_after; - 69 4492296 : } + 67 4491318 : first_before->next = second_head; + 68 4491318 : second_tail->next = first_after; + 69 4491318 : } 70 : 71 : /** 72 : * Concats two chains. 73 : */ - 74 1276680 : tommy_inline void tommy_chain_concat(tommy_node* first_tail, tommy_node* second_head) + 74 1276623 : tommy_inline void tommy_chain_concat(tommy_node* first_tail, tommy_node* second_head) 75 : { 76 : /* set the prev list */ - 77 1276680 : second_head->prev = first_tail; + 77 1276623 : second_head->prev = first_tail; 78 : 79 : /* set the next list */ - 80 1276680 : first_tail->next = second_head; - 81 1276680 : } + 80 1276623 : first_tail->next = second_head; + 81 1276623 : } 82 : 83 : /** 84 : * Merges two chains. 85 : */ - 86 470675 : tommy_inline void tommy_chain_merge(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) + 86 470639 : tommy_inline void tommy_chain_merge(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) 87 : { - 88 470675 : tommy_node* first_i = first->head; - 89 470675 : tommy_node* second_i = second->head; + 88 470639 : tommy_node* first_i = first->head; + 89 470639 : tommy_node* second_i = second->head; 90 : 91 : /* merge */ 92 : while (1) { - 93 9777862 : if (cmp(first_i->data, second_i->data) > 0) { - 94 4724569 : tommy_node* next = second_i->next; - 95 4724569 : if (first_i == first->head) { - 96 232273 : tommy_chain_concat(second_i, first_i); - 97 232273 : first->head = second_i; + 93 9777914 : if (cmp(first_i->data, second_i->data) > 0) { + 94 4723551 : tommy_node* next = second_i->next; + 95 4723551 : if (first_i == first->head) { + 96 232233 : tommy_chain_concat(second_i, first_i); + 97 232233 : first->head = second_i; 98 : } else { - 99 4492296 : tommy_chain_splice(first_i->prev, first_i, second_i, second_i); + 99 4491318 : tommy_chain_splice(first_i->prev, first_i, second_i, second_i); 100 : } - 101 4724569 : if (second_i == second->tail) - 102 238884 : break; - 103 4485685 : second_i = next; + 101 4723551 : if (second_i == second->tail) + 102 238890 : break; + 103 4484661 : second_i = next; 104 : } else { - 105 5053293 : if (first_i == first->tail) { - 106 231791 : tommy_chain_concat(first_i, second_i); - 107 231791 : first->tail = second->tail; - 108 231791 : break; + 105 5054363 : if (first_i == first->tail) { + 106 231749 : tommy_chain_concat(first_i, second_i); + 107 231749 : first->tail = second->tail; + 108 231749 : break; 109 : } - 110 4821502 : first_i = first_i->next; + 110 4822614 : first_i = first_i->next; 111 : } - 112 9307187 : } - 113 470675 : } + 112 9307275 : } + 113 470639 : } 114 : 115 : /** 116 : * Merges two chains managing special degenerated cases. 117 : * It's funtionally equivalent at tommy_chain_merge() but faster with already ordered chains. 118 : */ - 119 1283291 : tommy_inline void tommy_chain_merge_degenerated(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) + 119 1283280 : tommy_inline void tommy_chain_merge_degenerated(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) 120 : { 121 : /* identify the condition first <= second */ - 122 1283291 : if (cmp(first->tail->data, second->head->data) <= 0) { - 123 477903 : tommy_chain_concat(first->tail, second->head); - 124 477903 : first->tail = second->tail; - 125 477903 : return; + 122 1283280 : if (cmp(first->tail->data, second->head->data) <= 0) { + 123 477942 : tommy_chain_concat(first->tail, second->head); + 124 477942 : first->tail = second->tail; + 125 477942 : return; 126 : } 127 : 128 : /* identify the condition second < first */ 129 : /* here we must be strict on comparison to keep the sort stable */ - 130 805388 : if (cmp(second->tail->data, first->head->data) < 0) { - 131 334713 : tommy_chain_concat(second->tail, first->head); - 132 334713 : first->head = second->head; - 133 334713 : return; + 130 805338 : if (cmp(second->tail->data, first->head->data) < 0) { + 131 334699 : tommy_chain_concat(second->tail, first->head); + 132 334699 : first->head = second->head; + 133 334699 : return; 134 : } 135 : - 136 470675 : tommy_chain_merge(first, second, cmp); + 136 470639 : tommy_chain_merge(first, second, cmp); 137 : } 138 : 139 : /** @@ -241,42 +241,42 @@ 179 : tommy_chain* last; 180 : 181 : /* carry bit to add */ - 182 1284984 : last = &bit[TOMMY_CHAIN_BIT_MAX]; - 183 1284984 : bit[TOMMY_CHAIN_BIT_MAX].head = node; - 184 1284984 : bit[TOMMY_CHAIN_BIT_MAX].tail = node; - 185 1284984 : next = node->next; + 182 1284973 : last = &bit[TOMMY_CHAIN_BIT_MAX]; + 183 1284973 : bit[TOMMY_CHAIN_BIT_MAX].head = node; + 184 1284973 : bit[TOMMY_CHAIN_BIT_MAX].tail = node; + 185 1284973 : next = node->next; 186 : 187 : /* add the bit, propagating the carry */ - 188 1284984 : i = 0; - 189 1284984 : mask = counter; - 190 3847206 : while ((mask & 1) != 0) { - 191 1277238 : tommy_chain_merge_degenerated(&bit[i], last, cmp); - 192 1277238 : mask >>= 1; - 193 1277238 : last = &bit[i]; - 194 1277238 : ++i; + 188 1284973 : i = 0; + 189 1284973 : mask = counter; + 190 3847173 : while ((mask & 1) != 0) { + 191 1277227 : tommy_chain_merge_degenerated(&bit[i], last, cmp); + 192 1277227 : mask >>= 1; + 193 1277227 : last = &bit[i]; + 194 1277227 : ++i; 195 : } 196 : 197 : /* copy the carry in the first empty bit */ - 198 1284984 : bit[i] = *last; + 198 1284973 : bit[i] = *last; 199 : 200 : /* add the carry in the counter */ - 201 1284984 : ++counter; + 201 1284973 : ++counter; 202 : - 203 1284984 : if (node == tail) + 203 1284973 : if (node == tail) 204 1693 : break; - 205 1283291 : node = next; - 206 1283291 : } + 205 1283280 : node = next; + 206 1283280 : } 207 : 208 : /* merge the buckets */ 209 1693 : i = tommy_ctz_u32(counter); 210 1693 : mask = counter >> i; - 211 12413 : while (mask != 1) { - 212 9027 : mask >>= 1; - 213 9027 : if (mask & 1) + 211 12416 : while (mask != 1) { + 212 9030 : mask >>= 1; + 213 9030 : if (mask & 1) 214 6053 : tommy_chain_merge_degenerated(&bit[i + 1], &bit[i], cmp); 215 : else - 216 2974 : bit[i + 1] = bit[i]; - 217 9027 : ++i; + 216 2977 : bit[i + 1] = bit[i]; + 217 9030 : ++i; 218 : } 219 : 220 1693 : *chain = bit[i]; diff --git a/cov/tommyds/tommyhash.c.func-sort-c.html b/cov/tommyds/tommyhash.c.func-sort-c.html index d59abafe..df6507f4 100644 --- a/cov/tommyds/tommyhash.c.func-sort-c.html +++ b/cov/tommyds/tommyhash.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,11 +61,11 @@ tommy_le_uint32_read - 11587314 + 11588009 tommy_hash_u32 - 4059737 + 4059942 tommy_strhash_u32 diff --git a/cov/tommyds/tommyhash.c.func.html b/cov/tommyds/tommyhash.c.func.html index 217f4d7a..54128f24 100644 --- a/cov/tommyds/tommyhash.c.func.html +++ b/cov/tommyds/tommyhash.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -61,7 +61,7 @@ tommy_hash_u32 - 4059737 + 4059942 tommy_hash_u64 @@ -69,7 +69,7 @@ tommy_le_uint32_read - 11587314 + 11588009 tommy_strhash_u32 diff --git a/cov/tommyds/tommyhash.c.gcov.html b/cov/tommyds/tommyhash.c.gcov.html index 998b4290..68119537 100644 --- a/cov/tommyds/tommyhash.c.gcov.html +++ b/cov/tommyds/tommyhash.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 4 @@ -92,12 +92,12 @@ 30 : /******************************************************************************/ 31 : /* hash */ 32 : - 33 11587314 : tommy_inline tommy_uint32_t tommy_le_uint32_read(const void* ptr) + 33 11588009 : tommy_inline tommy_uint32_t tommy_le_uint32_read(const void* ptr) 34 : { 35 : /* allow unaligned read on Intel x86 and x86_64 platforms */ 36 : #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__x86_64__) || defined(_M_X64) 37 : /* defines from http://predef.sourceforge.net/ */ - 38 11587314 : return *(const tommy_uint32_t*)ptr; + 38 11588009 : return *(const tommy_uint32_t*)ptr; 39 : #else 40 : const unsigned char* ptr8 = tommy_cast(const unsigned char*, ptr); 41 : return ptr8[0] + ((tommy_uint32_t)ptr8[1] << 8) + ((tommy_uint32_t)ptr8[2] << 16) + ((tommy_uint32_t)ptr8[3] << 24); @@ -128,53 +128,53 @@ 66 : c ^= b; c -= tommy_rot(b, 24); \ 67 : } while (0) 68 : - 69 4059737 : tommy_uint32_t tommy_hash_u32(tommy_uint32_t init_val, const void* void_key, tommy_size_t key_len) + 69 4059942 : tommy_uint32_t tommy_hash_u32(tommy_uint32_t init_val, const void* void_key, tommy_size_t key_len) 70 : { - 71 4059737 : const unsigned char* key = tommy_cast(const unsigned char*, void_key); + 71 4059942 : const unsigned char* key = tommy_cast(const unsigned char*, void_key); 72 : tommy_uint32_t a, b, c; 73 : - 74 4059737 : a = b = c = 0xdeadbeef + ((tommy_uint32_t)key_len) + init_val; + 74 4059942 : a = b = c = 0xdeadbeef + ((tommy_uint32_t)key_len) + init_val; 75 : - 76 10239675 : while (key_len > 12) { - 77 2120201 : a += tommy_le_uint32_read(key + 0); - 78 2120201 : b += tommy_le_uint32_read(key + 4); - 79 2120201 : c += tommy_le_uint32_read(key + 8); + 76 10240213 : while (key_len > 12) { + 77 2120329 : a += tommy_le_uint32_read(key + 0); + 78 2120329 : b += tommy_le_uint32_read(key + 4); + 79 2120329 : c += tommy_le_uint32_read(key + 8); 80 : - 81 2120201 : tommy_mix(a, b, c); + 81 2120329 : tommy_mix(a, b, c); 82 : - 83 2120201 : key_len -= 12; - 84 2120201 : key += 12; + 83 2120329 : key_len -= 12; + 84 2120329 : key += 12; 85 : } 86 : - 87 4059737 : switch (key_len) { + 87 4059942 : switch (key_len) { 88 : case 0 : 89 1 : return c; /* used only when called with a zero length */ 90 : case 12 : - 91 207727 : c += tommy_le_uint32_read(key + 8); - 92 207727 : b += tommy_le_uint32_read(key + 4); - 93 207727 : a += tommy_le_uint32_read(key + 0); - 94 207727 : break; - 95 217400 : case 11 : c += ((tommy_uint32_t)key[10]) << 16; - 96 640250 : case 10 : c += ((tommy_uint32_t)key[9]) << 8; - 97 1059946 : case 9 : c += key[8]; + 91 207744 : c += tommy_le_uint32_read(key + 8); + 92 207744 : b += tommy_le_uint32_read(key + 4); + 93 207744 : a += tommy_le_uint32_read(key + 0); + 94 207744 : break; + 95 217371 : case 11 : c += ((tommy_uint32_t)key[10]) << 16; + 96 640231 : case 10 : c += ((tommy_uint32_t)key[9]) << 8; + 97 1059969 : case 9 : c += key[8]; 98 : case 8 : - 99 1470855 : b += tommy_le_uint32_read(key + 4); - 100 1470855 : a += tommy_le_uint32_read(key + 0); - 101 1470855 : break; - 102 413128 : case 7 : b += ((tommy_uint32_t)key[6]) << 16; - 103 812916 : case 6 : b += ((tommy_uint32_t)key[5]) << 8; - 104 1229635 : case 5 : b += key[4]; + 99 1470946 : b += tommy_le_uint32_read(key + 4); + 100 1470946 : a += tommy_le_uint32_read(key + 0); + 101 1470946 : break; + 102 413133 : case 7 : b += ((tommy_uint32_t)key[6]) << 16; + 103 812960 : case 6 : b += ((tommy_uint32_t)key[5]) << 8; + 104 1229671 : case 5 : b += key[4]; 105 : case 4 : - 106 1661686 : a += tommy_le_uint32_read(key + 0); - 107 1661686 : break; - 108 301707 : case 3 : a += ((tommy_uint32_t)key[2]) << 16; - 109 509493 : case 2 : a += ((tommy_uint32_t)key[1]) << 8; - 110 719468 : case 1 : a += key[0]; + 106 1661764 : a += tommy_le_uint32_read(key + 0); + 107 1661764 : break; + 108 301721 : case 3 : a += ((tommy_uint32_t)key[2]) << 16; + 109 509505 : case 2 : a += ((tommy_uint32_t)key[1]) << 8; + 110 719487 : case 1 : a += key[0]; 111 : } 112 : - 113 4059736 : tommy_final(a, b, c); + 113 4059941 : tommy_final(a, b, c); 114 : - 115 4059736 : return c; + 115 4059941 : return c; 116 : } 117 : 118 19 : tommy_uint64_t tommy_hash_u64(tommy_uint64_t init_val, const void* void_key, tommy_size_t key_len) diff --git a/cov/tommyds/tommyhash.h.func-sort-c.html b/cov/tommyds/tommyhash.h.func-sort-c.html index 16a1ee22..e16f4c74 100644 --- a/cov/tommyds/tommyhash.h.func-sort-c.html +++ b/cov/tommyds/tommyhash.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ tommy_inthash_u32 - 18827424 + 18826263 tommy_inthash_u64 - 5047758 + 5042449
diff --git a/cov/tommyds/tommyhash.h.func.html b/cov/tommyds/tommyhash.h.func.html index 1933c0e3..c3f3a49c 100644 --- a/cov/tommyds/tommyhash.h.func.html +++ b/cov/tommyds/tommyhash.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -61,11 +61,11 @@ tommy_inthash_u32 - 18827424 + 18826263 tommy_inthash_u64 - 5047758 + 5042449
diff --git a/cov/tommyds/tommyhash.h.gcov.html b/cov/tommyds/tommyhash.h.gcov.html index 12405e14..86c2762a 100644 --- a/cov/tommyds/tommyhash.h.gcov.html +++ b/cov/tommyds/tommyhash.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 @@ -167,17 +167,17 @@ 105 : * Implementation of the Robert Jenkins "4-byte Integer Hashing", 106 : * from http://burtleburtle.net/bob/hash/integer.html 107 : */ - 108 18827424 : tommy_inline tommy_uint32_t tommy_inthash_u32(tommy_uint32_t key) + 108 18826263 : tommy_inline tommy_uint32_t tommy_inthash_u32(tommy_uint32_t key) 109 : { - 110 18827424 : key -= key << 6; - 111 18827424 : key ^= key >> 17; - 112 18827424 : key -= key << 9; - 113 18827424 : key ^= key << 4; - 114 18827424 : key -= key << 3; - 115 18827424 : key ^= key << 10; - 116 18827424 : key ^= key >> 15; + 110 18826263 : key -= key << 6; + 111 18826263 : key ^= key >> 17; + 112 18826263 : key -= key << 9; + 113 18826263 : key ^= key << 4; + 114 18826263 : key -= key << 3; + 115 18826263 : key ^= key << 10; + 116 18826263 : key ^= key >> 15; 117 : - 118 18827424 : return key; + 118 18826263 : return key; 119 : } 120 : 121 : /** @@ -185,17 +185,17 @@ 123 : * Implementation of the Thomas Wang "Integer Hash Function", 124 : * from http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm 125 : */ - 126 5047758 : tommy_inline tommy_uint64_t tommy_inthash_u64(tommy_uint64_t key) + 126 5042449 : tommy_inline tommy_uint64_t tommy_inthash_u64(tommy_uint64_t key) 127 : { - 128 5047758 : key = ~key + (key << 21); - 129 5047758 : key = key ^ (key >> 24); - 130 5047758 : key = key + (key << 3) + (key << 8); - 131 5047758 : key = key ^ (key >> 14); - 132 5047758 : key = key + (key << 2) + (key << 4); - 133 5047758 : key = key ^ (key >> 28); - 134 5047758 : key = key + (key << 31); + 128 5042449 : key = ~key + (key << 21); + 129 5042449 : key = key ^ (key >> 24); + 130 5042449 : key = key + (key << 3) + (key << 8); + 131 5042449 : key = key ^ (key >> 14); + 132 5042449 : key = key + (key << 2) + (key << 4); + 133 5042449 : key = key ^ (key >> 28); + 134 5042449 : key = key + (key << 31); 135 : - 136 5047758 : return key; + 136 5042449 : return key; 137 : } 138 : 139 : #endif diff --git a/cov/tommyds/tommyhashdyn.c.func-sort-c.html b/cov/tommyds/tommyhashdyn.c.func-sort-c.html index 543ff5f0..9c360eb3 100644 --- a/cov/tommyds/tommyhashdyn.c.func-sort-c.html +++ b/cov/tommyds/tommyhashdyn.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -61,31 +61,31 @@ hashdyn_grow_step - 13236976 + 13231522 tommy_hashdyn_insert - 13236976 + 13231522 hashdyn_shrink_step - 282017 + 276876 tommy_hashdyn_remove_existing - 281889 + 276748 tommy_hashdyn_resize - 41538 + 41523 tommy_hashdyn_init - 8727 + 8760 tommy_hashdyn_done - 7998 + 8031 tommy_hashdyn_remove @@ -93,7 +93,7 @@ tommy_hashdyn_foreach - 247 + 248 tommy_hashdyn_foreach_arg diff --git a/cov/tommyds/tommyhashdyn.c.func.html b/cov/tommyds/tommyhashdyn.c.func.html index ef5510c7..f2525885 100644 --- a/cov/tommyds/tommyhashdyn.c.func.html +++ b/cov/tommyds/tommyhashdyn.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -61,19 +61,19 @@ hashdyn_grow_step - 13236976 + 13231522 hashdyn_shrink_step - 282017 + 276876 tommy_hashdyn_done - 7998 + 8031 tommy_hashdyn_foreach - 247 + 248 tommy_hashdyn_foreach_arg @@ -81,11 +81,11 @@ tommy_hashdyn_init - 8727 + 8760 tommy_hashdyn_insert - 13236976 + 13231522 tommy_hashdyn_memory_usage @@ -97,11 +97,11 @@ tommy_hashdyn_remove_existing - 281889 + 276748 tommy_hashdyn_resize - 41538 + 41523
diff --git a/cov/tommyds/tommyhashdyn.c.gcov.html b/cov/tommyds/tommyhashdyn.c.gcov.html index e0494f88..f6e08f05 100644 --- a/cov/tommyds/tommyhashdyn.c.gcov.html +++ b/cov/tommyds/tommyhashdyn.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -93,26 +93,26 @@ 31 : /******************************************************************************/ 32 : /* hashdyn */ 33 : - 34 8727 : void tommy_hashdyn_init(tommy_hashdyn* hashdyn) + 34 8760 : void tommy_hashdyn_init(tommy_hashdyn* hashdyn) 35 : { 36 : /* fixed initial size */ - 37 8727 : hashdyn->bucket_bit = TOMMY_HASHDYN_BIT; - 38 8727 : hashdyn->bucket_max = 1 << hashdyn->bucket_bit; - 39 8727 : hashdyn->bucket_mask = hashdyn->bucket_max - 1; - 40 8727 : hashdyn->bucket = tommy_cast(tommy_hashdyn_node**, tommy_calloc(hashdyn->bucket_max, sizeof(tommy_hashdyn_node*))); + 37 8760 : hashdyn->bucket_bit = TOMMY_HASHDYN_BIT; + 38 8760 : hashdyn->bucket_max = 1 << hashdyn->bucket_bit; + 39 8760 : hashdyn->bucket_mask = hashdyn->bucket_max - 1; + 40 8760 : hashdyn->bucket = tommy_cast(tommy_hashdyn_node**, tommy_calloc(hashdyn->bucket_max, sizeof(tommy_hashdyn_node*))); 41 : - 42 8727 : hashdyn->count = 0; - 43 8727 : } + 42 8760 : hashdyn->count = 0; + 43 8760 : } 44 : - 45 7998 : void tommy_hashdyn_done(tommy_hashdyn* hashdyn) + 45 8031 : void tommy_hashdyn_done(tommy_hashdyn* hashdyn) 46 : { - 47 7998 : tommy_free(hashdyn->bucket); - 48 7998 : } + 47 8031 : tommy_free(hashdyn->bucket); + 48 8031 : } 49 : 50 : /** 51 : * Resize the bucket vector. 52 : */ - 53 41538 : static void tommy_hashdyn_resize(tommy_hashdyn* hashdyn, tommy_count_t new_bucket_bit) + 53 41523 : static void tommy_hashdyn_resize(tommy_hashdyn* hashdyn, tommy_count_t new_bucket_bit) 54 : { 55 : tommy_count_t bucket_bit; 56 : tommy_count_t bucket_max; @@ -120,38 +120,38 @@ 58 : tommy_count_t new_bucket_mask; 59 : tommy_hashdyn_node** new_bucket; 60 : - 61 41538 : bucket_bit = hashdyn->bucket_bit; - 62 41538 : bucket_max = hashdyn->bucket_max; + 61 41523 : bucket_bit = hashdyn->bucket_bit; + 62 41523 : bucket_max = hashdyn->bucket_max; 63 : - 64 41538 : new_bucket_max = 1 << new_bucket_bit; - 65 41538 : new_bucket_mask = new_bucket_max - 1; + 64 41523 : new_bucket_max = 1 << new_bucket_bit; + 65 41523 : new_bucket_mask = new_bucket_max - 1; 66 : 67 : /* allocate the new vector using malloc() and not calloc() */ 68 : /* because data is fully initialized in the update process */ - 69 41538 : new_bucket = tommy_cast(tommy_hashdyn_node**, tommy_malloc(new_bucket_max * sizeof(tommy_hashdyn_node*))); + 69 41523 : new_bucket = tommy_cast(tommy_hashdyn_node**, tommy_malloc(new_bucket_max * sizeof(tommy_hashdyn_node*))); 70 : 71 : /* reinsert all the elements */ - 72 41538 : if (new_bucket_bit > bucket_bit) { + 72 41523 : if (new_bucket_bit > bucket_bit) { 73 : tommy_count_t i; 74 : 75 : /* grow */ - 76 32197009 : for (i = 0; i < bucket_max; ++i) { + 76 32195506 : for (i = 0; i < bucket_max; ++i) { 77 : tommy_hashdyn_node* j; 78 : 79 : /* setup the new two buckets */ - 80 32155520 : new_bucket[i] = 0; - 81 32155520 : new_bucket[i + bucket_max] = 0; + 80 32154032 : new_bucket[i] = 0; + 81 32154032 : new_bucket[i + bucket_max] = 0; 82 : 83 : /* reinsert the bucket */ - 84 32155520 : j = hashdyn->bucket[i]; - 85 80388800 : while (j) { - 86 16077760 : tommy_hashdyn_node* j_next = j->next; - 87 16077760 : tommy_count_t pos = j->key & new_bucket_mask; - 88 16077760 : if (new_bucket[pos]) - 89 1915117 : tommy_list_insert_tail_not_empty(new_bucket[pos], j); + 84 32154032 : j = hashdyn->bucket[i]; + 85 80385080 : while (j) { + 86 16077016 : tommy_hashdyn_node* j_next = j->next; + 87 16077016 : tommy_count_t pos = j->key & new_bucket_mask; + 88 16077016 : if (new_bucket[pos]) + 89 1915511 : tommy_list_insert_tail_not_empty(new_bucket[pos], j); 90 : else - 91 14162643 : tommy_list_insert_first(&new_bucket[pos], j); - 92 16077760 : j = j_next; + 91 14161505 : tommy_list_insert_first(&new_bucket[pos], j); + 92 16077016 : j = j_next; 93 : } 94 : } 95 : } else { @@ -167,59 +167,59 @@ 105 : } 106 : } 107 : - 108 41538 : tommy_free(hashdyn->bucket); + 108 41523 : tommy_free(hashdyn->bucket); 109 : 110 : /* setup */ - 111 41538 : hashdyn->bucket_bit = new_bucket_bit; - 112 41538 : hashdyn->bucket_max = new_bucket_max; - 113 41538 : hashdyn->bucket_mask = new_bucket_mask; - 114 41538 : hashdyn->bucket = new_bucket; - 115 41538 : } + 111 41523 : hashdyn->bucket_bit = new_bucket_bit; + 112 41523 : hashdyn->bucket_max = new_bucket_max; + 113 41523 : hashdyn->bucket_mask = new_bucket_mask; + 114 41523 : hashdyn->bucket = new_bucket; + 115 41523 : } 116 : 117 : /** 118 : * Grow. 119 : */ - 120 13236976 : tommy_inline void hashdyn_grow_step(tommy_hashdyn* hashdyn) + 120 13231522 : tommy_inline void hashdyn_grow_step(tommy_hashdyn* hashdyn) 121 : { 122 : /* grow if more than 50% full */ - 123 13236976 : if (hashdyn->count >= hashdyn->bucket_max / 2) - 124 41489 : tommy_hashdyn_resize(hashdyn, hashdyn->bucket_bit + 1); - 125 13236976 : } + 123 13231522 : if (hashdyn->count >= hashdyn->bucket_max / 2) + 124 41474 : tommy_hashdyn_resize(hashdyn, hashdyn->bucket_bit + 1); + 125 13231522 : } 126 : 127 : /** 128 : * Shrink. 129 : */ - 130 282017 : tommy_inline void hashdyn_shrink_step(tommy_hashdyn* hashdyn) + 130 276876 : tommy_inline void hashdyn_shrink_step(tommy_hashdyn* hashdyn) 131 : { 132 : /* shrink if less than 12.5% full */ - 133 282017 : if (hashdyn->count <= hashdyn->bucket_max / 8 && hashdyn->bucket_bit > TOMMY_HASHDYN_BIT) + 133 276876 : if (hashdyn->count <= hashdyn->bucket_max / 8 && hashdyn->bucket_bit > TOMMY_HASHDYN_BIT) 134 49 : tommy_hashdyn_resize(hashdyn, hashdyn->bucket_bit - 1); - 135 282017 : } + 135 276876 : } 136 : - 137 13236976 : void tommy_hashdyn_insert(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node, void* data, tommy_hash_t hash) + 137 13231522 : void tommy_hashdyn_insert(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node, void* data, tommy_hash_t hash) 138 : { - 139 13236976 : tommy_count_t pos = hash & hashdyn->bucket_mask; + 139 13231522 : tommy_count_t pos = hash & hashdyn->bucket_mask; 140 : - 141 13236976 : tommy_list_insert_tail(&hashdyn->bucket[pos], node, data); + 141 13231522 : tommy_list_insert_tail(&hashdyn->bucket[pos], node, data); 142 : - 143 13236976 : node->key = hash; + 143 13231522 : node->key = hash; 144 : - 145 13236976 : ++hashdyn->count; + 145 13231522 : ++hashdyn->count; 146 : - 147 13236976 : hashdyn_grow_step(hashdyn); - 148 13236976 : } + 147 13231522 : hashdyn_grow_step(hashdyn); + 148 13231522 : } 149 : - 150 281889 : void* tommy_hashdyn_remove_existing(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node) + 150 276748 : void* tommy_hashdyn_remove_existing(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node) 151 : { - 152 281889 : tommy_count_t pos = node->key & hashdyn->bucket_mask; + 152 276748 : tommy_count_t pos = node->key & hashdyn->bucket_mask; 153 : - 154 281889 : tommy_list_remove_existing(&hashdyn->bucket[pos], node); + 154 276748 : tommy_list_remove_existing(&hashdyn->bucket[pos], node); 155 : - 156 281889 : --hashdyn->count; + 156 276748 : --hashdyn->count; 157 : - 158 281889 : hashdyn_shrink_step(hashdyn); + 158 276748 : hashdyn_shrink_step(hashdyn); 159 : - 160 281889 : return node->data; + 160 276748 : return node->data; 161 : } 162 : 163 256 : void* tommy_hashdyn_remove(tommy_hashdyn* hashdyn, tommy_search_func* cmp, const void* cmp_arg, tommy_hash_t hash) @@ -244,22 +244,22 @@ 182 128 : return 0; 183 : } 184 : - 185 247 : void tommy_hashdyn_foreach(tommy_hashdyn* hashdyn, tommy_foreach_func* func) + 185 248 : void tommy_hashdyn_foreach(tommy_hashdyn* hashdyn, tommy_foreach_func* func) 186 : { - 187 247 : tommy_count_t bucket_max = hashdyn->bucket_max; - 188 247 : tommy_hashdyn_node** bucket = hashdyn->bucket; + 187 248 : tommy_count_t bucket_max = hashdyn->bucket_max; + 188 248 : tommy_hashdyn_node** bucket = hashdyn->bucket; 189 : tommy_count_t pos; 190 : - 191 5812535 : for (pos = 0; pos < bucket_max; ++pos) { - 192 5812288 : tommy_hashdyn_node* node = bucket[pos]; + 191 5812552 : for (pos = 0; pos < bucket_max; ++pos) { + 192 5812304 : tommy_hashdyn_node* node = bucket[pos]; 193 : - 194 13485699 : while (node) { - 195 1861123 : void* data = node->data; - 196 1861123 : node = node->next; - 197 1861123 : func(data); + 194 13485790 : while (node) { + 195 1861182 : void* data = node->data; + 196 1861182 : node = node->next; + 197 1861182 : func(data); 198 : } 199 : } - 200 247 : } + 200 248 : } 201 : 202 1 : void tommy_hashdyn_foreach_arg(tommy_hashdyn* hashdyn, tommy_foreach_arg_func* func, void* arg) 203 : { diff --git a/cov/tommyds/tommyhashdyn.h.func-sort-c.html b/cov/tommyds/tommyhashdyn.h.func-sort-c.html index f39065be..6937e5cf 100644 --- a/cov/tommyds/tommyhashdyn.h.func-sort-c.html +++ b/cov/tommyds/tommyhashdyn.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -61,11 +61,11 @@ tommy_hashdyn_bucket - 3109139 + 3108747 tommy_hashdyn_search - 3109139 + 3108747 tommy_hashdyn_count diff --git a/cov/tommyds/tommyhashdyn.h.func.html b/cov/tommyds/tommyhashdyn.h.func.html index 79320b42..60527ed5 100644 --- a/cov/tommyds/tommyhashdyn.h.func.html +++ b/cov/tommyds/tommyhashdyn.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -61,7 +61,7 @@ tommy_hashdyn_bucket - 3109139 + 3108747 tommy_hashdyn_count @@ -69,7 +69,7 @@ tommy_hashdyn_search - 3109139 + 3108747
diff --git a/cov/tommyds/tommyhashdyn.h.gcov.html b/cov/tommyds/tommyhashdyn.h.gcov.html index 713bad9b..b5142826 100644 --- a/cov/tommyds/tommyhashdyn.h.gcov.html +++ b/cov/tommyds/tommyhashdyn.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -267,9 +267,9 @@ 205 : * \param hash Hash of the element to find. 206 : * \return The head of the bucket, or 0 if empty. 207 : */ - 208 3109139 : tommy_inline tommy_hashdyn_node* tommy_hashdyn_bucket(tommy_hashdyn* hashdyn, tommy_hash_t hash) + 208 3108747 : tommy_inline tommy_hashdyn_node* tommy_hashdyn_bucket(tommy_hashdyn* hashdyn, tommy_hash_t hash) 209 : { - 210 3109139 : return hashdyn->bucket[hash & hashdyn->bucket_mask]; + 210 3108747 : return hashdyn->bucket[hash & hashdyn->bucket_mask]; 211 : } 212 : 213 : /** @@ -282,17 +282,17 @@ 220 : * \param hash Hash of the element to find. 221 : * \return The first element found, or 0 if none. 222 : */ - 223 3109139 : tommy_inline void* tommy_hashdyn_search(tommy_hashdyn* hashdyn, tommy_search_func* cmp, const void* cmp_arg, tommy_hash_t hash) + 223 3108747 : tommy_inline void* tommy_hashdyn_search(tommy_hashdyn* hashdyn, tommy_search_func* cmp, const void* cmp_arg, tommy_hash_t hash) 224 : { - 225 3109139 : tommy_hashdyn_node* i = tommy_hashdyn_bucket(hashdyn, hash); + 225 3108747 : tommy_hashdyn_node* i = tommy_hashdyn_bucket(hashdyn, hash); 226 : - 227 6897799 : while (i) { + 227 6892825 : while (i) { 228 : /* we first check if the hash matches, as in the same bucket we may have multiples hash values */ - 229 1844197 : if (i->key == hash && cmp(cmp_arg, i->data) == 0) - 230 1164676 : return i->data; - 231 679521 : i = i->next; + 229 1828483 : if (i->key == hash && cmp(cmp_arg, i->data) == 0) + 230 1153152 : return i->data; + 231 675331 : i = i->next; 232 : } - 233 1944463 : return 0; + 233 1955595 : return 0; 234 : } 235 : 236 : /** diff --git a/cov/tommyds/tommylist.c.func-sort-c.html b/cov/tommyds/tommylist.c.func-sort-c.html index fbb6a7a9..0839d722 100644 --- a/cov/tommyds/tommylist.c.func-sort-c.html +++ b/cov/tommyds/tommylist.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/tommyds/tommylist.c.func.html b/cov/tommyds/tommylist.c.func.html index 9a83a9d4..1dfa43e9 100644 --- a/cov/tommyds/tommylist.c.func.html +++ b/cov/tommyds/tommylist.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/tommyds/tommylist.c.gcov.html b/cov/tommyds/tommylist.c.gcov.html index a168b925..ff470829 100644 --- a/cov/tommyds/tommylist.c.gcov.html +++ b/cov/tommyds/tommylist.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 2 diff --git a/cov/tommyds/tommylist.h.func-sort-c.html b/cov/tommyds/tommylist.h.func-sort-c.html index 2f8e1e22..59514e63 100644 --- a/cov/tommyds/tommylist.h.func-sort-c.html +++ b/cov/tommyds/tommylist.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -61,23 +61,23 @@ tommy_list_head - 25314845 + 25304133 tommy_list_insert_first - 23362955 + 23374774 tommy_list_insert_tail - 18382476 + 18376886 tommy_list_insert_tail_not_empty - 11097281 + 11079128 tommy_list_remove_existing - 340001 + 334849 tommy_list_concat @@ -85,19 +85,19 @@ tommy_list_init - 11898 + 11929 tommy_list_foreach - 7614 + 7645 tommy_list_empty - 4384 + 4387 tommy_list_count - 259 + 260 tommy_list_tail diff --git a/cov/tommyds/tommylist.h.func.html b/cov/tommyds/tommylist.h.func.html index 9e435b68..665f8a95 100644 --- a/cov/tommyds/tommylist.h.func.html +++ b/cov/tommyds/tommylist.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -65,39 +65,39 @@ tommy_list_count - 259 + 260 tommy_list_empty - 4384 + 4387 tommy_list_foreach - 7614 + 7645 tommy_list_head - 25314845 + 25304133 tommy_list_init - 11898 + 11929 tommy_list_insert_first - 23362955 + 23374774 tommy_list_insert_tail - 18382476 + 18376886 tommy_list_insert_tail_not_empty - 11097281 + 11079128 tommy_list_remove_existing - 340001 + 334849 tommy_list_tail diff --git a/cov/tommyds/tommylist.h.gcov.html b/cov/tommyds/tommylist.h.gcov.html index f7401298..600cc1c4 100644 --- a/cov/tommyds/tommylist.h.gcov.html +++ b/cov/tommyds/tommylist.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 11 @@ -173,18 +173,18 @@ 111 : * Initializes the list. 112 : * The list is completely inplace, so it doesn't need to be deinitialized. 113 : */ - 114 11898 : tommy_inline void tommy_list_init(tommy_list* list) + 114 11929 : tommy_inline void tommy_list_init(tommy_list* list) 115 : { - 116 11898 : *list = 0; - 117 11898 : } + 116 11929 : *list = 0; + 117 11929 : } 118 : 119 : /** 120 : * Gets the head of the list. 121 : * \return The head node. For empty lists 0 is returned. 122 : */ - 123 25314845 : tommy_inline tommy_node* tommy_list_head(tommy_list* list) + 123 25304133 : tommy_inline tommy_node* tommy_list_head(tommy_list* list) 124 : { - 125 25314845 : return *list; + 125 25304133 : return *list; 126 : } 127 : 128 : /** @@ -206,16 +206,16 @@ 144 : * \param list The list to initialize. 145 : * \param node The node to insert. 146 : */ - 147 23362955 : tommy_inline void tommy_list_insert_first(tommy_list* list, tommy_node* node) + 147 23374774 : tommy_inline void tommy_list_insert_first(tommy_list* list, tommy_node* node) 148 : { 149 : /* one element "circular" prev list */ - 150 23362955 : node->prev = node; + 150 23374774 : node->prev = node; 151 : 152 : /* one element "0 terminated" next list */ - 153 23362955 : node->next = 0; + 153 23374774 : node->next = 0; 154 : - 155 23362955 : *list = node; - 156 23362955 : } + 155 23374774 : *list = node; + 156 23374774 : } 157 : 158 : /** \internal 159 : * Inserts an element at the head of a not empty list. @@ -243,16 +243,16 @@ 181 : * \param head The node at the list head. It cannot be 0. 182 : * \param node The node to insert. 183 : */ - 184 11097281 : tommy_inline void tommy_list_insert_tail_not_empty(tommy_node* head, tommy_node* node) + 184 11079128 : tommy_inline void tommy_list_insert_tail_not_empty(tommy_node* head, tommy_node* node) 185 : { 186 : /* insert in the "circular" prev list */ - 187 11097281 : node->prev = head->prev; - 188 11097281 : head->prev = node; + 187 11079128 : node->prev = head->prev; + 188 11079128 : head->prev = node; 189 : 190 : /* insert in the "0 terminated" next list */ - 191 11097281 : node->next = 0; - 192 11097281 : node->prev->next = node; - 193 11097281 : } + 191 11079128 : node->next = 0; + 192 11079128 : node->prev->next = node; + 193 11079128 : } 194 : 195 : /** 196 : * Inserts an element at the head of a list. @@ -276,17 +276,17 @@ 214 : * \param node The node to insert. 215 : * \param data The object containing the node. It's used to set the tommy_node::data field of the node. 216 : */ - 217 18382476 : tommy_inline void tommy_list_insert_tail(tommy_list* list, tommy_node* node, void* data) + 217 18376886 : tommy_inline void tommy_list_insert_tail(tommy_list* list, tommy_node* node, void* data) 218 : { - 219 18382476 : tommy_node* head = tommy_list_head(list); + 219 18376886 : tommy_node* head = tommy_list_head(list); 220 : - 221 18382476 : if (head) - 222 9182164 : tommy_list_insert_tail_not_empty(head, node); + 221 18376886 : if (head) + 222 9163617 : tommy_list_insert_tail_not_empty(head, node); 223 : else - 224 9200312 : tommy_list_insert_first(list, node); + 224 9213269 : tommy_list_insert_first(list, node); 225 : - 226 18382476 : node->data = data; - 227 18382476 : } + 226 18376886 : node->data = data; + 227 18376886 : } 228 : 229 : /** \internal 230 : * Removes an element from the head of a not empty list. @@ -314,23 +314,23 @@ 252 : * \param node The node to remove. The node must be in the list. 253 : * \return The tommy_node::data field of the node removed. 254 : */ - 255 340001 : tommy_inline void* tommy_list_remove_existing(tommy_list* list, tommy_node* node) + 255 334849 : tommy_inline void* tommy_list_remove_existing(tommy_list* list, tommy_node* node) 256 : { - 257 340001 : tommy_node* head = tommy_list_head(list); + 257 334849 : tommy_node* head = tommy_list_head(list); 258 : 259 : /* remove from the "circular" prev list */ - 260 340001 : if (node->next) - 261 117029 : node->next->prev = node->prev; + 260 334849 : if (node->next) + 261 116893 : node->next->prev = node->prev; 262 : else - 263 222972 : head->prev = node->prev; /* the last */ + 263 217956 : head->prev = node->prev; /* the last */ 264 : 265 : /* remove from the "0 terminated" next list */ - 266 340001 : if (head == node) - 267 237639 : *list = node->next; /* the new head, in case 0 */ + 266 334849 : if (head == node) + 267 234397 : *list = node->next; /* the new head, in case 0 */ 268 : else - 269 102362 : node->prev->next = node->next; + 269 100452 : node->prev->next = node->next; 270 : - 271 340001 : return node->data; + 271 334849 : return node->data; 272 : } 273 : 274 : /** @@ -349,24 +349,24 @@ 287 : /* if the second is empty, nothing to do */ 288 63152 : second_head = tommy_list_head(second); 289 63152 : if (second_head == 0) - 290 55818 : return; + 290 55882 : return; 291 : 292 : /* if the first is empty, copy the second */ - 293 7334 : first_head = tommy_list_head(first); - 294 7334 : if (first_head == 0) { - 295 6443 : *first = *second; - 296 6443 : return; + 293 7270 : first_head = tommy_list_head(first); + 294 7270 : if (first_head == 0) { + 295 6382 : *first = *second; + 296 6382 : return; 297 : } 298 : 299 : /* tail of the first list */ - 300 891 : first_tail = first_head->prev; + 300 888 : first_tail = first_head->prev; 301 : 302 : /* set the "circular" prev list */ - 303 891 : first_head->prev = second_head->prev; - 304 891 : second_head->prev = first_tail; + 303 888 : first_head->prev = second_head->prev; + 304 888 : second_head->prev = first_tail; 305 : 306 : /* set the "0 terminated" next list */ - 307 891 : first_tail->next = second_head; + 307 888 : first_tail->next = second_head; 308 : } 309 : 310 : /** @@ -382,26 +382,26 @@ 320 : * Checks if empty. 321 : * \return If the list is empty. 322 : */ - 323 4384 : tommy_inline tommy_bool_t tommy_list_empty(tommy_list* list) + 323 4387 : tommy_inline tommy_bool_t tommy_list_empty(tommy_list* list) 324 : { - 325 4384 : return tommy_list_head(list) == 0; + 325 4387 : return tommy_list_head(list) == 0; 326 : } 327 : 328 : /** 329 : * Gets the number of elements. 330 : * \note This operation is O(n). 331 : */ - 332 259 : tommy_inline tommy_count_t tommy_list_count(tommy_list* list) + 332 260 : tommy_inline tommy_count_t tommy_list_count(tommy_list* list) 333 : { - 334 259 : tommy_count_t count = 0; - 335 259 : tommy_node* i = tommy_list_head(list); + 334 260 : tommy_count_t count = 0; + 335 260 : tommy_node* i = tommy_list_head(list); 336 : - 337 2067 : while (i) { - 338 1549 : ++count; - 339 1549 : i = i->next; + 337 2075 : while (i) { + 338 1555 : ++count; + 339 1555 : i = i->next; 340 : } 341 : - 342 259 : return count; + 342 260 : return count; 343 : } 344 : 345 : /** @@ -432,16 +432,16 @@ 370 : * tommy_list_foreach(&list, free); 371 : * \endcode 372 : */ - 373 7614 : tommy_inline void tommy_list_foreach(tommy_list* list, tommy_foreach_func* func) + 373 7645 : tommy_inline void tommy_list_foreach(tommy_list* list, tommy_foreach_func* func) 374 : { - 375 7614 : tommy_node* node = tommy_list_head(list); + 375 7645 : tommy_node* node = tommy_list_head(list); 376 : - 377 3679847 : while (node) { - 378 3664619 : void* data = node->data; - 379 3664619 : node = node->next; - 380 3664619 : func(data); + 377 3679931 : while (node) { + 378 3664641 : void* data = node->data; + 379 3664641 : node = node->next; + 380 3664641 : func(data); 381 : } - 382 7614 : } + 382 7645 : } 383 : 384 : /** 385 : * Calls the specified function with an argument for each element in the list. diff --git a/cov/tommyds/tommytree.c.func-sort-c.html b/cov/tommyds/tommytree.c.func-sort-c.html index 027f2e99..82ebea9a 100644 --- a/cov/tommyds/tommytree.c.func-sort-c.html +++ b/cov/tommyds/tommytree.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 19 @@ -61,67 +61,67 @@ tommy_tree_search_node - 136779062 + 137516004 tommy_tree_delta - 112389261 + 112385081 tommy_tree_balance - 104882737 + 104878675 tommy_tree_insert_node - 96201715 + 96198722 tommy_tree_foreach_arg_node - 26344145 + 26344381 tommy_tree_search_compare - 12303747 + 12374066 tommy_tree_rotate_left - 7495135 + 7494967 tommy_tree_insert - 7471049 + 7470835 tommy_tree_foreach_node - 7052312 + 7052386 tommy_tree_remove_node - 791807 + 791513 tommy_tree_move_right - 187170 + 187087 tommy_tree_rotate_right - 171066 + 170763 tommy_tree_remove - 79718 + 79700 tommy_tree_foreach_arg - 5965 + 5977 tommy_tree_init - 3171 + 3183 tommy_tree_foreach - 1454 + 1460 tommy_tree_remove_existing diff --git a/cov/tommyds/tommytree.c.func.html b/cov/tommyds/tommytree.c.func.html index 36001430..d5863abc 100644 --- a/cov/tommyds/tommytree.c.func.html +++ b/cov/tommyds/tommytree.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 19 @@ -61,39 +61,39 @@ tommy_tree_balance - 104882737 + 104878675 tommy_tree_delta - 112389261 + 112385081 tommy_tree_foreach - 1454 + 1460 tommy_tree_foreach_arg - 5965 + 5977 tommy_tree_foreach_arg_node - 26344145 + 26344381 tommy_tree_foreach_node - 7052312 + 7052386 tommy_tree_init - 3171 + 3183 tommy_tree_insert - 7471049 + 7470835 tommy_tree_insert_node - 96201715 + 96198722 tommy_tree_memory_usage @@ -101,11 +101,11 @@ tommy_tree_move_right - 187170 + 187087 tommy_tree_remove - 79718 + 79700 tommy_tree_remove_existing @@ -113,15 +113,15 @@ tommy_tree_remove_node - 791807 + 791513 tommy_tree_rotate_left - 7495135 + 7494967 tommy_tree_rotate_right - 171066 + 170763 tommy_tree_search @@ -129,11 +129,11 @@ tommy_tree_search_compare - 12303747 + 12374066 tommy_tree_search_node - 136779062 + 137516004
diff --git a/cov/tommyds/tommytree.c.gcov.html b/cov/tommyds/tommytree.c.gcov.html index ffe0c07f..cf93057e 100644 --- a/cov/tommyds/tommytree.c.gcov.html +++ b/cov/tommyds/tommytree.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 19 @@ -94,104 +94,104 @@ 32 : /******************************************************************************/ 33 : /* tree */ 34 : - 35 3171 : void tommy_tree_init(tommy_tree* tree, tommy_compare_func* cmp) + 35 3183 : void tommy_tree_init(tommy_tree* tree, tommy_compare_func* cmp) 36 : { - 37 3171 : tree->root = 0; - 38 3171 : tree->count = 0; - 39 3171 : tree->cmp = cmp; - 40 3171 : } + 37 3183 : tree->root = 0; + 38 3183 : tree->count = 0; + 39 3183 : tree->cmp = cmp; + 40 3183 : } 41 : - 42 112389261 : static int tommy_tree_delta(tommy_tree_node* root) + 42 112385081 : static int tommy_tree_delta(tommy_tree_node* root) 43 : { - 44 112389261 : int left_height = root->prev ? root->prev->key : 0; - 45 112389261 : int right_height = root->next ? root->next->key : 0; + 44 112385081 : int left_height = root->prev ? root->prev->key : 0; + 45 112385081 : int right_height = root->next ? root->next->key : 0; 46 : - 47 112389261 : return left_height - right_height; + 47 112385081 : return left_height - right_height; 48 : } 49 : 50 : /* AVL tree operations */ 51 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node*); 52 : - 53 7495135 : static tommy_tree_node* tommy_tree_rotate_left(tommy_tree_node* root) + 53 7494967 : static tommy_tree_node* tommy_tree_rotate_left(tommy_tree_node* root) 54 : { - 55 7495135 : tommy_tree_node* next = root->next; + 55 7494967 : tommy_tree_node* next = root->next; 56 : - 57 7495135 : root->next = next->prev; + 57 7494967 : root->next = next->prev; 58 : - 59 7495135 : next->prev = tommy_tree_balance(root); + 59 7494967 : next->prev = tommy_tree_balance(root); 60 : - 61 7495135 : return tommy_tree_balance(next); + 61 7494967 : return tommy_tree_balance(next); 62 : } 63 : - 64 171066 : static tommy_tree_node* tommy_tree_rotate_right(tommy_tree_node* root) + 64 170763 : static tommy_tree_node* tommy_tree_rotate_right(tommy_tree_node* root) 65 : { - 66 171066 : tommy_tree_node* prev = root->prev; + 66 170763 : tommy_tree_node* prev = root->prev; 67 : - 68 171066 : root->prev = prev->next; + 68 170763 : root->prev = prev->next; 69 : - 70 171066 : prev->next = tommy_tree_balance(root); + 70 170763 : prev->next = tommy_tree_balance(root); 71 : - 72 171066 : return tommy_tree_balance(prev); + 72 170763 : return tommy_tree_balance(prev); 73 : } 74 : - 75 187170 : static tommy_tree_node* tommy_tree_move_right(tommy_tree_node* root, tommy_tree_node* node) + 75 187087 : static tommy_tree_node* tommy_tree_move_right(tommy_tree_node* root, tommy_tree_node* node) 76 : { - 77 187170 : if (!root) - 78 79590 : return node; + 77 187087 : if (!root) + 78 79572 : return node; 79 : - 80 107580 : root->next = tommy_tree_move_right(root->next, node); + 80 107515 : root->next = tommy_tree_move_right(root->next, node); 81 : - 82 107580 : return tommy_tree_balance(root); + 82 107515 : return tommy_tree_balance(root); 83 : } 84 : - 85 104882737 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node* root) + 85 104878675 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node* root) 86 : { - 87 104882737 : int delta = tommy_tree_delta(root); + 87 104878675 : int delta = tommy_tree_delta(root); 88 : - 89 104882737 : if (delta < -1) { - 90 7378375 : if (tommy_tree_delta(root->next) > 0) - 91 42917 : root->next = tommy_tree_rotate_right(root->next); - 92 7378375 : return tommy_tree_rotate_left(root); + 89 104878675 : if (delta < -1) { + 90 7378499 : if (tommy_tree_delta(root->next) > 0) + 91 42856 : root->next = tommy_tree_rotate_right(root->next); + 92 7378499 : return tommy_tree_rotate_left(root); 93 : } 94 : - 95 97504362 : if (delta > 1) { - 96 128149 : if (tommy_tree_delta(root->prev) < 0) - 97 116760 : root->prev = tommy_tree_rotate_left(root->prev); - 98 128149 : return tommy_tree_rotate_right(root); + 95 97500176 : if (delta > 1) { + 96 127907 : if (tommy_tree_delta(root->prev) < 0) + 97 116468 : root->prev = tommy_tree_rotate_left(root->prev); + 98 127907 : return tommy_tree_rotate_right(root); 99 : } 100 : 101 : /* recompute key */ - 102 97376213 : root->key = 0; + 102 97372269 : root->key = 0; 103 : - 104 97376213 : if (root->prev && root->prev->key > root->key) - 105 78773173 : root->key = root->prev->key; + 104 97372269 : if (root->prev && root->prev->key > root->key) + 105 78769557 : root->key = root->prev->key; 106 : - 107 97376213 : if (root->next && root->next->key > root->key) - 108 44912285 : root->key = root->next->key; + 107 97372269 : if (root->next && root->next->key > root->key) + 108 44908478 : root->key = root->next->key; 109 : 110 : /* count itself */ - 111 97376213 : root->key += 1; + 111 97372269 : root->key += 1; 112 : - 113 97376213 : return root; + 113 97372269 : return root; 114 : } 115 : - 116 96201715 : static tommy_tree_node* tommy_tree_insert_node(tommy_compare_func* cmp, tommy_tree_node* root, tommy_tree_node** let) + 116 96198722 : static tommy_tree_node* tommy_tree_insert_node(tommy_compare_func* cmp, tommy_tree_node* root, tommy_tree_node** let) 117 : { 118 : int c; 119 : - 120 96201715 : if (!root) - 121 7471048 : return *let; + 120 96198722 : if (!root) + 121 7470834 : return *let; 122 : - 123 88730667 : c = cmp((*let)->data, root->data); + 123 88727888 : c = cmp((*let)->data, root->data); 124 : - 125 88730667 : if (c < 0) { - 126 1532013 : root->prev = tommy_tree_insert_node(cmp, root->prev, let); - 127 1532013 : return tommy_tree_balance(root); + 125 88727888 : if (c < 0) { + 126 1533765 : root->prev = tommy_tree_insert_node(cmp, root->prev, let); + 127 1533765 : return tommy_tree_balance(root); 128 : } 129 : - 130 87198654 : if (c > 0) { - 131 87198653 : root->next = tommy_tree_insert_node(cmp, root->next, let); - 132 87198653 : return tommy_tree_balance(root); + 130 87194123 : if (c > 0) { + 131 87194122 : root->next = tommy_tree_insert_node(cmp, root->next, let); + 132 87194122 : return tommy_tree_balance(root); 133 : } 134 : 135 : /* already present, set the return pointer */ @@ -200,78 +200,78 @@ 138 1 : return root; 139 : } 140 : - 141 7471049 : void* tommy_tree_insert(tommy_tree* tree, tommy_tree_node* node, void* data) + 141 7470835 : void* tommy_tree_insert(tommy_tree* tree, tommy_tree_node* node, void* data) 142 : { - 143 7471049 : tommy_tree_node* insert = node; + 143 7470835 : tommy_tree_node* insert = node; 144 : - 145 7471049 : insert->data = data; - 146 7471049 : insert->prev = 0; - 147 7471049 : insert->next = 0; - 148 7471049 : insert->key = 0; + 145 7470835 : insert->data = data; + 146 7470835 : insert->prev = 0; + 147 7470835 : insert->next = 0; + 148 7470835 : insert->key = 0; 149 : - 150 7471049 : tree->root = tommy_tree_insert_node(tree->cmp, tree->root, &insert); + 150 7470835 : tree->root = tommy_tree_insert_node(tree->cmp, tree->root, &insert); 151 : - 152 7471049 : if (insert == node) - 153 7471048 : ++tree->count; + 152 7470835 : if (insert == node) + 153 7470834 : ++tree->count; 154 : - 155 7471049 : return insert->data; + 155 7470835 : return insert->data; 156 : } 157 : - 158 791807 : static tommy_tree_node* tommy_tree_remove_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data, tommy_tree_node** let) + 158 791513 : static tommy_tree_node* tommy_tree_remove_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data, tommy_tree_node** let) 159 : { 160 : int c; 161 : - 162 791807 : if (!root) + 162 791513 : if (!root) 163 128 : return 0; 164 : - 165 791679 : c = cmp(data, root->data); + 165 791385 : c = cmp(data, root->data); 166 : - 167 791679 : if (c < 0) { - 168 304695 : root->prev = tommy_tree_remove_node(cmp, root->prev, data, let); - 169 304695 : return tommy_tree_balance(root); + 167 791385 : if (c < 0) { + 168 304173 : root->prev = tommy_tree_remove_node(cmp, root->prev, data, let); + 169 304173 : return tommy_tree_balance(root); 170 : } 171 : - 172 486984 : if (c > 0) { - 173 407394 : root->next = tommy_tree_remove_node(cmp, root->next, data, let); - 174 407394 : return tommy_tree_balance(root); + 172 487212 : if (c > 0) { + 173 407640 : root->next = tommy_tree_remove_node(cmp, root->next, data, let); + 174 407640 : return tommy_tree_balance(root); 175 : } 176 : 177 : /* found */ - 178 79590 : *let = root; + 178 79572 : *let = root; 179 : - 180 79590 : return tommy_tree_move_right(root->prev, root->next); + 180 79572 : return tommy_tree_move_right(root->prev, root->next); 181 : } 182 : - 183 79718 : void* tommy_tree_remove(tommy_tree* tree, void* data) + 183 79700 : void* tommy_tree_remove(tommy_tree* tree, void* data) 184 : { - 185 79718 : tommy_tree_node* node = 0; + 185 79700 : tommy_tree_node* node = 0; 186 : - 187 79718 : tree->root = tommy_tree_remove_node(tree->cmp, tree->root, data, &node); + 187 79700 : tree->root = tommy_tree_remove_node(tree->cmp, tree->root, data, &node); 188 : - 189 79718 : if (!node) + 189 79700 : if (!node) 190 128 : return 0; 191 : - 192 79590 : --tree->count; + 192 79572 : --tree->count; 193 : - 194 79590 : return node->data; + 194 79572 : return node->data; 195 : } 196 : - 197 136779062 : static tommy_tree_node* tommy_tree_search_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data) + 197 137516004 : static tommy_tree_node* tommy_tree_search_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data) 198 : { 199 : int c; 200 : - 201 136779062 : if (!root) - 202 1588658 : return 0; + 201 137516004 : if (!root) + 202 1589078 : return 0; 203 : - 204 135190404 : c = cmp(data, root->data); + 204 135926926 : c = cmp(data, root->data); 205 : - 206 135195696 : if (c < 0) - 207 49136499 : return tommy_tree_search_node(cmp, root->prev, data); + 206 135935261 : if (c < 0) + 207 49441744 : return tommy_tree_search_node(cmp, root->prev, data); 208 : - 209 86059197 : if (c > 0) - 210 75344385 : return tommy_tree_search_node(cmp, root->next, data); + 209 86493517 : if (c > 0) + 210 75708858 : return tommy_tree_search_node(cmp, root->next, data); 211 : - 212 10714812 : return root; + 212 10784659 : return root; 213 : } 214 : 215 2 : void* tommy_tree_search(tommy_tree* tree, void* data) @@ -284,14 +284,14 @@ 222 1 : return node->data; 223 : } 224 : - 225 12303747 : void* tommy_tree_search_compare(tommy_tree* tree, tommy_compare_func* cmp, void* cmp_arg) + 225 12374066 : void* tommy_tree_search_compare(tommy_tree* tree, tommy_compare_func* cmp, void* cmp_arg) 226 : { - 227 12303747 : tommy_tree_node* node = tommy_tree_search_node(cmp, tree->root, cmp_arg); + 227 12374066 : tommy_tree_node* node = tommy_tree_search_node(cmp, tree->root, cmp_arg); 228 : - 229 12303453 : if (!node) - 230 1588690 : return 0; + 229 12373755 : if (!node) + 230 1589128 : return 0; 231 : - 232 10714763 : return node->data; + 232 10784627 : return node->data; 233 : } 234 : 235 128 : void* tommy_tree_remove_existing(tommy_tree* tree, tommy_tree_node* node) @@ -303,49 +303,49 @@ 241 128 : return data; 242 : } 243 : - 244 7052312 : static void tommy_tree_foreach_node(tommy_tree_node* root, tommy_foreach_func* func) + 244 7052386 : static void tommy_tree_foreach_node(tommy_tree_node* root, tommy_foreach_func* func) 245 : { 246 : tommy_tree_node* next; 247 : - 248 7052312 : if (!root) - 249 10579195 : return; + 248 7052386 : if (!root) + 249 10579309 : return; 250 : - 251 3525429 : tommy_tree_foreach_node(root->prev, func); + 251 3525463 : tommy_tree_foreach_node(root->prev, func); 252 : 253 : /* make a copy in case func is free() */ - 254 3525429 : next = root->next; + 254 3525463 : next = root->next; 255 : - 256 3525429 : func(root->data); + 256 3525463 : func(root->data); 257 : - 258 3525429 : tommy_tree_foreach_node(next, func); + 258 3525463 : tommy_tree_foreach_node(next, func); 259 : } 260 : - 261 1454 : void tommy_tree_foreach(tommy_tree* tree, tommy_foreach_func* func) + 261 1460 : void tommy_tree_foreach(tommy_tree* tree, tommy_foreach_func* func) 262 : { - 263 1454 : tommy_tree_foreach_node(tree->root, func); - 264 1454 : } + 263 1460 : tommy_tree_foreach_node(tree->root, func); + 264 1460 : } 265 : - 266 26344145 : static void tommy_tree_foreach_arg_node(tommy_tree_node* root, tommy_foreach_arg_func* func, void* arg) + 266 26344381 : static void tommy_tree_foreach_arg_node(tommy_tree_node* root, tommy_foreach_arg_func* func, void* arg) 267 : { 268 : tommy_tree_node* next; 269 : - 270 26344145 : if (!root) - 271 39519200 : return; + 270 26344381 : if (!root) + 271 39519560 : return; 272 : - 273 13169090 : tommy_tree_foreach_arg_node(root->prev, func, arg); + 273 13169202 : tommy_tree_foreach_arg_node(root->prev, func, arg); 274 : 275 : /* make a copy in case func is free() */ - 276 13169090 : next = root->next; + 276 13169202 : next = root->next; 277 : - 278 13169090 : func(arg, root->data); + 278 13169202 : func(arg, root->data); 279 : - 280 13169090 : tommy_tree_foreach_arg_node(next, func, arg); + 280 13169202 : tommy_tree_foreach_arg_node(next, func, arg); 281 : } 282 : - 283 5965 : void tommy_tree_foreach_arg(tommy_tree* tree, tommy_foreach_arg_func* func, void* arg) + 283 5977 : void tommy_tree_foreach_arg(tommy_tree* tree, tommy_foreach_arg_func* func, void* arg) 284 : { - 285 5965 : tommy_tree_foreach_arg_node(tree->root, func, arg); - 286 5965 : } + 285 5977 : tommy_tree_foreach_arg_node(tree->root, func, arg); + 286 5977 : } 287 : 288 1 : tommy_size_t tommy_tree_memory_usage(tommy_tree* tree) 289 : { diff --git a/cov/tommyds/tommytree.h.func-sort-c.html b/cov/tommyds/tommytree.h.func-sort-c.html index ffcdfc58..ff624258 100644 --- a/cov/tommyds/tommytree.h.func-sort-c.html +++ b/cov/tommyds/tommytree.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/tommyds/tommytree.h.func.html b/cov/tommyds/tommytree.h.func.html index 9a83836b..1d42fad9 100644 --- a/cov/tommyds/tommytree.h.func.html +++ b/cov/tommyds/tommytree.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/tommyds/tommytree.h.gcov.html b/cov/tommyds/tommytree.h.gcov.html index b097ee44..d11ce0f8 100644 --- a/cov/tommyds/tommytree.h.gcov.html +++ b/cov/tommyds/tommytree.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 1 diff --git a/cov/tommyds/tommytypes.h.func-sort-c.html b/cov/tommyds/tommytypes.h.func-sort-c.html index b3aeebb1..a9485641 100644 --- a/cov/tommyds/tommytypes.h.func-sort-c.html +++ b/cov/tommyds/tommytypes.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -61,7 +61,7 @@ tommy_ilog2_u32 - 10268715 + 10268668 tommy_ctz_u32 diff --git a/cov/tommyds/tommytypes.h.func.html b/cov/tommyds/tommytypes.h.func.html index c63029e2..b4d67947 100644 --- a/cov/tommyds/tommytypes.h.func.html +++ b/cov/tommyds/tommytypes.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -69,7 +69,7 @@ tommy_ilog2_u32 - 10268715 + 10268668
diff --git a/cov/tommyds/tommytypes.h.gcov.html b/cov/tommyds/tommytypes.h.gcov.html index 6244d621..feca1864 100644 --- a/cov/tommyds/tommytypes.h.gcov.html +++ b/cov/tommyds/tommytypes.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-11-06 + 2016-11-21 Functions: 3 @@ -390,7 +390,7 @@ 328 : * \param value Value to scan. 0 is not allowed. 329 : * \return The index of the most significant bit set. 330 : */ - 331 10268715 : tommy_inline tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value) + 331 10268668 : tommy_inline tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value) 332 : { 333 : #if defined(_MSC_VER) 334 : unsigned long count; @@ -406,7 +406,7 @@ 344 : * So we write "__builtin_clz(x) ^ 31" instead of "31 - __builtin_clz(x)", 345 : * to allow the double xor to be optimized out. 346 : */ - 347 10268715 : return __builtin_clz(value) ^ 31; + 347 10268668 : return __builtin_clz(value) ^ 31; 348 : #else 349 : /* Find the log base 2 of an N-bit integer in O(lg(N)) operations with multiply and lookup */ 350 : /* from http://graphics.stanford.edu/~seander/bithacks.html */