diff --git a/cov/cmdline/check.c.func-sort-c.html b/cov/cmdline/check.c.func-sort-c.html index 2de16b5f..1a913ec8 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-01-09 + 2016-01-16 Functions: 9 @@ -61,27 +61,27 @@ block_is_enabled - 1869102 + 1870958 file_post - 934551 + 935479 repair - 870166 + 870992 blockcmp - 469276 + 468990 repair_step - 254143 + 253884 is_hash_matching - 211335 + 211180 state_check diff --git a/cov/cmdline/check.c.func.html b/cov/cmdline/check.c.func.html index b46f8731..ee1ca6d5 100644 --- a/cov/cmdline/check.c.func.html +++ b/cov/cmdline/check.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 9 @@ -61,19 +61,19 @@ block_is_enabled - 1869102 + 1870958 blockcmp - 469276 + 468990 file_post - 934551 + 935479 is_hash_matching - 211335 + 211180 is_parity_matching @@ -81,11 +81,11 @@ repair - 870166 + 870992 repair_step - 254143 + 253884 state_check diff --git a/cov/cmdline/check.c.gcov.html b/cov/cmdline/check.c.gcov.html index 2e56b65e..2f2b5d0f 100644 --- a/cov/cmdline/check.c.gcov.html +++ b/cov/cmdline/check.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 9 @@ -129,64 +129,64 @@ 67 : * Check if a block hash matches the specified buffer. 68 : * Return ==0 if equal 69 : */ - 70 469276 : static int blockcmp(struct snapraid_state* state, int rehash, struct snapraid_block* block, unsigned pos_size, unsigned char* buffer, unsigned char* buffer_zero) + 70 468990 : 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_SIZE]; 73 : 74 : /* now compute the hash of the valid part */ - 75 469276 : if (rehash) { + 75 468990 : if (rehash) { 76 0 : memhash(state->prevhash, state->prevhashseed, hash, buffer, pos_size); 77 : } else { - 78 469276 : memhash(state->hash, state->hashseed, hash, buffer, pos_size); + 78 468990 : memhash(state->hash, state->hashseed, hash, buffer, pos_size); 79 : } 80 : 81 : /* compare the hash */ - 82 469276 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { - 83 13920 : return -1; + 82 468990 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { + 83 13884 : return -1; 84 : } 85 : 86 : /* compare to the end of the block */ - 87 455356 : if (pos_size < state->block_size) { - 88 188035 : if (memcmp(buffer + pos_size, buffer_zero + pos_size, state->block_size - pos_size) != 0) { - 89 18 : return -1; + 87 455106 : if (pos_size < state->block_size) { + 88 187996 : if (memcmp(buffer + pos_size, buffer_zero + pos_size, state->block_size - pos_size) != 0) { + 89 21 : return -1; 90 : } 91 : } 92 : - 93 455338 : return 0; + 93 455085 : 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 211335 : 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 211180 : 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 211335 : hash_checked = 0; /* keep track if we check at least one block */ + 104 211180 : hash_checked = 0; /* keep track if we check at least one block */ 105 : 106 : /* check if the recovered blocks are OK */ - 107 671195 : for (j = 0; j < failed_count; ++j) { + 107 670787 : for (j = 0; j < failed_count; ++j) { 108 : /* if we are expected to recover this block */ - 109 473798 : if (!failed[failed_map[j]].is_outofdate + 109 473512 : if (!failed[failed_map[j]].is_outofdate 110 : /* if the block has a hash to check */ - 111 469276 : && block_has_updated_hash(failed[failed_map[j]].block) + 111 468990 : && block_has_updated_hash(failed[failed_map[j]].block) 112 : ) { 113 : /* if a hash doesn't match, fail the check */ - 114 469276 : unsigned pos_size = file_block_size(failed[failed_map[j]].file, failed[failed_map[j]].file_pos, state->block_size); - 115 469276 : if (blockcmp(state, rehash, failed[failed_map[j]].block, pos_size, buffer[failed[failed_map[j]].index], buffer_zero) != 0) { - 116 13938 : log_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]); - 117 13938 : return 0; + 114 468990 : unsigned pos_size = file_block_size(failed[failed_map[j]].file, failed[failed_map[j]].file_pos, state->block_size); + 115 468990 : if (blockcmp(state, rehash, failed[failed_map[j]].block, pos_size, buffer[failed[failed_map[j]].index], buffer_zero) != 0) { + 116 13905 : log_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]); + 117 13905 : return 0; 118 : } 119 : - 120 455338 : hash_checked = 1; + 120 455085 : 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 197397 : if (!hash_checked) { + 127 197275 : 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 197397 : raid_gen(diskmax, state->level, state->block_size, buffer); - 136 197397 : return 1; + 135 197275 : raid_gen(diskmax, state->level, state->block_size, buffer); + 136 197275 : 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 254143 : 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 253884 : 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 254143 : if (failed_count == 0) { + 171 253884 : 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 254143 : n = state->level; - 180 254143 : error = 0; + 179 253884 : n = state->level; + 180 253884 : error = 0; 181 : 182 : /* setup vector of failed disk indexes */ - 183 894073 : for (i = 0; i < failed_count; ++i) - 184 639930 : id[i] = failed[failed_map[i]].index; + 183 893186 : for (i = 0; i < failed_count; ++i) + 184 639302 : 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 254143 : has_hash = 0; - 189 894073 : for (i = 0; i < failed_count; ++i) { + 188 253884 : has_hash = 0; + 189 893186 : for (i = 0; i < failed_count; ++i) { 190 : /* if we are expected to recover this block */ - 191 639930 : if (!failed[failed_map[i]].is_outofdate + 191 639302 : if (!failed[failed_map[i]].is_outofdate 192 : /* if the block has a hash to check */ - 193 630886 : && block_has_updated_hash(failed[failed_map[i]].block) + 193 630258 : && block_has_updated_hash(failed[failed_map[i]].block) 194 : ) - 195 630878 : has_hash = 1; + 195 630250 : 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 254143 : if (!has_hash && failed_count < n) { + 200 253884 : 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,54 +299,54 @@ 237 : 238 : /* if we have a hash, and enough parities */ 239 : /* (less-or-equal failures than number of parities) */ - 240 254135 : if (has_hash && failed_count <= n) { + 240 253876 : if (has_hash && failed_count <= n) { 241 : /* number of parities to use equal at the number of failures */ - 242 206565 : unsigned r = failed_count; + 242 206432 : unsigned r = failed_count; 243 : 244 : /* all combinations (r of n) parities */ - 245 206565 : combination_first(r, n, ip); + 245 206432 : combination_first(r, n, ip); 246 : do { 247 : /* if a parity is missing, do nothing */ - 248 689782 : for (i = 0; i < r; ++i) { - 249 478447 : if (buffer_recov[ip[i]] == 0) + 248 689341 : for (i = 0; i < r; ++i) { + 249 478161 : if (buffer_recov[ip[i]] == 0) 250 4649 : break; 251 : } - 252 215984 : if (i != r) + 252 215829 : if (i != r) 253 4649 : continue; 254 : 255 : /* copy the parities to use */ - 256 685133 : for (i = 0; i < r; ++i) - 257 473798 : memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size); + 256 684692 : for (i = 0; i < r; ++i) + 257 473512 : memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size); 258 : 259 : /* recover */ - 260 211335 : raid_data(r, id, ip, diskmax, state->block_size, buffer); + 260 211180 : raid_data(r, id, ip, diskmax, state->block_size, buffer); 261 : 262 : /* use the hash to check the result */ - 263 211335 : if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero)) - 264 197397 : return 0; + 263 211180 : if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero)) + 264 197275 : return 0; 265 : 266 : /* log */ - 267 13938 : log_tag("parity_error:%u:", pos); - 268 27876 : for (i = 0; i < r; ++i) { - 269 13938 : if (i != 0) + 267 13905 : log_tag("parity_error:%u:", pos); + 268 27810 : for (i = 0; i < r; ++i) { + 269 13905 : if (i != 0) 270 0 : log_tag("/"); - 271 13938 : log_tag("%s", lev_config_name(ip[i])); + 271 13905 : log_tag("%s", lev_config_name(ip[i])); 272 : } - 273 13938 : log_tag(":hash: Hash mismatch\n"); - 274 13938 : ++error; - 275 37174 : } while (combination_next(r, n, ip)); + 273 13905 : log_tag(":hash: Hash mismatch\n"); + 274 13905 : ++error; + 275 37108 : } while (combination_next(r, n, ip)); 276 : } 277 : 278 : /* return the number of failed attempts, or -1 if no strategy */ - 279 56738 : if (error) - 280 9168 : return error; + 279 56601 : if (error) + 280 9157 : return error; 281 : - 282 47570 : log_tag("strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n", + 282 47444 : 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 47570 : return -1; + 284 47444 : return -1; 285 : } 286 : - 287 870166 : 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) + 287 870992 : 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) 288 : { 289 : int ret; 290 : int error; @@ -355,51 +355,51 @@ 293 : int something_to_recover; 294 : int something_unsynced; 295 : - 296 870166 : error = 0; + 296 870992 : error = 0; 297 : 298 : /* if nothing failed, just recompute the parity */ - 299 870166 : if (failed_count == 0) { - 300 580935 : raid_gen(diskmax, state->level, state->block_size, buffer); - 301 580935 : return 0; + 299 870992 : if (failed_count == 0) { + 300 581962 : raid_gen(diskmax, state->level, state->block_size, buffer); + 301 581962 : return 0; 302 : } 303 : 304 : /* logs the status */ - 305 1019108 : for (j = 0; j < failed_count; ++j) { + 305 1018351 : for (j = 0; j < failed_count; ++j) { 306 : const char* desc; 307 : const char* hash; 308 : const char* data; - 309 729877 : struct snapraid_block* block = failed[j].block; - 310 729877 : unsigned block_state = block_state_get(block); + 309 729321 : struct snapraid_block* block = failed[j].block; + 310 729321 : unsigned block_state = block_state_get(block); 311 : - 312 729877 : switch (block_state) { + 312 729321 : switch (block_state) { 313 18454 : case BLOCK_STATE_DELETED : desc = "delete"; break; 314 13851 : case BLOCK_STATE_CHG : desc = "change"; break; 315 62282 : case BLOCK_STATE_REP : desc = "replace"; break; - 316 635290 : case BLOCK_STATE_BLK : desc = "block"; break; + 316 634734 : case BLOCK_STATE_BLK : desc = "block"; break; 317 : /* LCOV_EXCL_START */ 318 : default : desc = "unknown"; break; 319 : /* LCOV_EXCL_STOP */ 320 : } 321 : - 322 729877 : if (hash_is_invalid(block->hash)) { + 322 729321 : if (hash_is_invalid(block->hash)) { 323 13843 : hash = "lost"; - 324 716034 : } else if (hash_is_zero(block->hash)) { + 324 715478 : } else if (hash_is_zero(block->hash)) { 325 8 : hash = "zero"; 326 : } else { - 327 716026 : hash = "known"; + 327 715470 : hash = "known"; 328 : } 329 : - 330 729877 : if (failed[j].is_bad) - 331 644152 : data = "bad"; + 330 729321 : if (failed[j].is_bad) + 331 643596 : data = "bad"; 332 : else 333 85725 : data = "good"; 334 : - 335 729877 : if (failed[j].file) { - 336 711423 : struct snapraid_disk* disk = failed[j].disk; - 337 711423 : struct snapraid_file* file = failed[j].file; - 338 711423 : block_off_t file_pos = failed[j].file_pos; + 335 729321 : if (failed[j].file) { + 336 710867 : struct snapraid_disk* disk = failed[j].disk; + 337 710867 : struct snapraid_file* file = failed[j].file; + 338 710867 : block_off_t file_pos = failed[j].file_pos; 339 : - 340 711423 : log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, desc, hash, data, disk->name, esc(file->sub), file_pos); + 340 710867 : log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, desc, hash, data, disk->name, esc(file->sub), file_pos); 341 : } else { 342 18454 : log_tag("entry:%u:%s:%s:%s:\n", j, desc, hash, data); 343 : } @@ -421,58 +421,58 @@ 359 : /* We are interested to recover BLK, REP and CHG blocks if they are marked as bad, */ 360 : /* but we are not interested in DELETED ones. */ 361 : - 362 289231 : n = 0; - 363 289231 : something_to_recover = 0; /* keep track if there is at least one block to fix */ - 364 1019108 : for (j = 0; j < failed_count; ++j) { - 365 729877 : if (failed[j].is_bad) { - 366 644152 : unsigned block_state = block_state_get(failed[j].block); + 362 289030 : n = 0; + 363 289030 : something_to_recover = 0; /* keep track if there is at least one block to fix */ + 364 1018351 : for (j = 0; j < failed_count; ++j) { + 365 729321 : if (failed[j].is_bad) { + 366 643596 : unsigned block_state = block_state_get(failed[j].block); 367 : - 368 644152 : assert(block_state != BLOCK_STATE_DELETED); /* we cannot have bad DELETED blocks */ + 368 643596 : assert(block_state != BLOCK_STATE_DELETED); /* we cannot have bad DELETED blocks */ 369 : 370 : /* if we have the hash for it */ - 371 644152 : if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP) + 371 643596 : if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP) 372 : /* try to fetch the block using the known hash */ - 373 644144 : && (state_import_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0 - 374 639672 : || state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0) + 373 643588 : && (state_import_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0 + 374 639116 : || state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0) 375 : ) { 376 : /* we already have corrected it! */ - 377 22310 : log_tag("hash_import: Fixed entry %u\n", j); + 377 22382 : log_tag("hash_import: Fixed entry %u\n", j); 378 : } else { 379 : /* otherwise try to recover it */ - 380 621842 : failed_map[n] = j; - 381 621842 : ++n; + 380 621214 : failed_map[n] = j; + 381 621214 : ++n; 382 : 383 : /* we have something to try to recover */ - 384 621842 : something_to_recover = 1; + 384 621214 : something_to_recover = 1; 385 : } 386 : } 387 : } 388 : 389 : /* if nothing to fix */ - 390 289231 : if (!something_to_recover) { - 391 44132 : log_tag("recover_sync:%u:%u: Skipped for already recovered\n", pos, n); + 390 289030 : if (!something_to_recover) { + 391 44190 : log_tag("recover_sync:%u:%u: Skipped for already recovered\n", pos, n); 392 : 393 : /* recompute only the parity */ - 394 44132 : raid_gen(diskmax, state->level, state->block_size, buffer); - 395 44132 : return 0; + 394 44190 : raid_gen(diskmax, state->level, state->block_size, buffer); + 395 44190 : return 0; 396 : } 397 : - 398 245099 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); - 399 245099 : if (ret == 0) { + 398 244840 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); + 399 244840 : if (ret == 0) { 400 : /* reprocess the CHG blocks, for which we don't have a hash to check */ 401 : /* if they were BAD we have to use some heuristics to ensure that we have recovered */ 402 : /* the state after the sync. If unsure, we assume the worst case */ 403 : - 404 670084 : for (j = 0; j < failed_count; ++j) { + 404 669725 : for (j = 0; j < failed_count; ++j) { 405 : /* we take care only of BAD blocks we have to write back */ - 406 477201 : if (failed[j].is_bad) { - 407 463729 : unsigned block_state = block_state_get(failed[j].block); + 406 476964 : if (failed[j].is_bad) { + 407 463492 : unsigned block_state = block_state_get(failed[j].block); 408 : 409 : /* BLK and REP blocks are always OK, because at this point */ 410 : /* we have already checked their hash */ - 411 463729 : if (block_state != BLOCK_STATE_CHG) { - 412 463721 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); - 413 463721 : continue; + 411 463492 : if (block_state != BLOCK_STATE_CHG) { + 412 463484 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); + 413 463484 : continue; 414 : } 415 : 416 : /* for CHG blocks we have to 'guess' if they are correct or not */ @@ -514,15 +514,15 @@ 452 : } 453 : } 454 : - 455 192883 : return 0; + 455 192761 : return 0; 456 : } - 457 52216 : if (ret > 0) - 458 9168 : error += ret; + 457 52079 : if (ret > 0) + 458 9157 : error += ret; 459 : - 460 52216 : if (ret < 0) - 461 43048 : log_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n); + 460 52079 : if (ret < 0) + 461 42922 : log_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n); 462 : else - 463 9168 : log_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret); + 463 9157 : log_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret); 464 : 465 : /* Now assume that the parity IS NOT updated at the current state, */ 466 : /* but still represent the state before the last 'sync' process. */ @@ -532,15 +532,15 @@ 470 : /* but we are not interested to recover CHG (new version) and REP (new version) blocks, */ 471 : /* even if marked as bad, because we don't have parity for them and it's just impossible, */ 472 : /* and we are not interested to recover DELETED ones. */ - 473 52216 : n = 0; - 474 52216 : something_to_recover = 0; /* keep track if there is at least one block to fix */ - 475 52216 : something_unsynced = 0; /* keep track if we have some unsynced info to process */ - 476 232278 : for (j = 0; j < failed_count; ++j) { - 477 180062 : unsigned block_state = block_state_get(failed[j].block); + 473 52079 : n = 0; + 474 52079 : something_to_recover = 0; /* keep track if there is at least one block to fix */ + 475 52079 : something_unsynced = 0; /* keep track if we have some unsynced info to process */ + 476 231766 : for (j = 0; j < failed_count; ++j) { + 477 179687 : unsigned block_state = block_state_get(failed[j].block); 478 : - 479 180062 : if (block_state == BLOCK_STATE_DELETED - 480 171018 : || block_state == BLOCK_STATE_CHG - 481 171018 : || block_state == BLOCK_STATE_REP + 479 179687 : if (block_state == BLOCK_STATE_DELETED + 480 170643 : || block_state == BLOCK_STATE_CHG + 481 170643 : || block_state == BLOCK_STATE_REP 482 : ) { 483 : /* If the block is CHG, REP or DELETED, we don't have the original content of block, */ 484 : /* and we must try to recover it. */ @@ -582,24 +582,24 @@ 520 : /* it also applies to CHG and DELETE blocks because we want to have */ 521 : /* a successful recovering only if a BLK one is matching */ 522 9044 : failed[j].is_outofdate = 1; - 523 171018 : } else if (failed[j].is_bad) { + 523 170643 : } else if (failed[j].is_bad) { 524 : /* If the block is bad we don't know its content, and we try to recover it */ 525 : /* At this point, we can have only BLK ones */ 526 : - 527 171018 : assert(block_state == BLOCK_STATE_BLK); + 527 170643 : assert(block_state == BLOCK_STATE_BLK); 528 : 529 : /* we have something we are interested to recover */ - 530 171018 : something_to_recover = 1; + 530 170643 : something_to_recover = 1; 531 : 532 : /* we try to recover it */ - 533 171018 : failed_map[n] = j; - 534 171018 : ++n; + 533 170643 : failed_map[n] = j; + 534 170643 : ++n; 535 : } 536 : } 537 : 538 : /* if nothing to fix, we just don't try */ 539 : /* if nothing unsynced we also don't retry, because it's the same try as before */ - 540 52216 : if (something_to_recover && something_unsynced) { + 540 52079 : if (something_to_recover && something_unsynced) { 541 9044 : ret = repair_step(state, rehash, pos, diskmax, failed, failed_map, n, buffer, buffer_recov, buffer_zero); 542 9044 : if (ret == 0) { 543 : /* reprocess the REP and CHG blocks, for which we have recovered and old state */ @@ -633,17 +633,17 @@ 571 : else 572 0 : log_tag("recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret); 573 : } else { - 574 43172 : log_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n, + 574 43035 : log_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n, 575 : !something_to_recover ? " nothing to recover" : "", 576 : !something_unsynced ? " nothing unsynched" : "" 577 : ); 578 : } 579 : 580 : /* return the number of failed attempts, or -1 if no strategy */ - 581 47694 : if (error) - 582 4646 : return error; + 581 47557 : if (error) + 582 4635 : return error; 583 : else - 584 43048 : return -1; + 584 42922 : return -1; 585 : } 586 : 587 : /** @@ -655,19 +655,19 @@ 593 : * fix. This assumption is not always correct, and in such case we have to 594 : * skip the whole postprocessing. And example, is when fixing only bad blocks. 595 : */ - 596 934551 : static int file_post(struct snapraid_state* state, int fix, unsigned i, struct snapraid_handle* handle, unsigned diskmax) + 596 935479 : static int file_post(struct snapraid_state* state, int fix, unsigned i, struct snapraid_handle* handle, unsigned diskmax) 597 : { 598 : unsigned j; 599 : int ret; 600 : 601 : /* if we are processing only bad blocks, we don't have to do any post-processing */ 602 : /* as we don't have any guarantee to process the last block of the fixed files */ - 603 934551 : if (state->opt.badonly) - 604 9358 : return 0; + 603 935479 : if (state->opt.badonly) + 604 9374 : return 0; 605 : 606 : /* for all the files print the final status, and does the final time fix */ 607 : /* we also ensure to close files after processing the last block */ - 608 6476351 : for (j = 0; j < diskmax; ++j) { + 608 6482735 : for (j = 0; j < diskmax; ++j) { 609 : struct snapraid_block* block; 610 : struct snapraid_disk* disk; 611 : struct snapraid_file* collide_file; @@ -676,51 +676,51 @@ 614 : char path[PATH_MAX]; 615 : uint64_t inode; 616 : - 617 5551158 : disk = handle[j].disk; - 618 5551158 : if (!disk) { + 617 5556630 : disk = handle[j].disk; + 618 5556630 : if (!disk) { 619 : /* if no disk, nothing to do */ - 620 3403281 : continue; + 620 3408433 : continue; 621 : } 622 : - 623 5537121 : block = fs_par2block_get(disk, i); - 624 5537121 : if (!block_has_file(block)) { + 623 5542569 : block = fs_par2block_get(disk, i); + 624 5542569 : if (!block_has_file(block)) { 625 : /* if no file, nothing to do */ - 626 210707 : continue; + 626 213403 : continue; 627 : } 628 : - 629 5326414 : file = fs_par2file_get(disk, i, &file_pos); - 630 5326414 : pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub); + 629 5329166 : file = fs_par2file_get(disk, i, &file_pos); + 630 5329166 : pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub); 631 : 632 : /* if it isn't the last block in the file */ - 633 5326414 : if (!file_block_is_last(file, file_pos)) { + 633 5329166 : if (!file_block_is_last(file, file_pos)) { 634 : /* nothing to do */ - 635 3164500 : continue; + 635 3166908 : continue; 636 : } 637 : 638 : /* if the file is excluded, we have nothing to adjust as the file is never written */ - 639 2161914 : if (file_flag_has(file, FILE_IS_EXCLUDED) - 640 2065035 : || (state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED))) { + 639 2162258 : if (file_flag_has(file, FILE_IS_EXCLUDED) + 640 2065317 : || (state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED))) { 641 : /* nothing to do, but close the file */ 642 : goto close_and_continue; 643 : } 644 : 645 : /* finish the fix process if it's the last block of the files */ - 646 2065035 : if (fix) { + 646 2065317 : if (fix) { 647 : /* mark that we finished with this file */ 648 : /* to identify later any NOT finished ones */ - 649 757215 : file_flag_set(file, FILE_IS_FINISHED); + 649 757286 : file_flag_set(file, FILE_IS_FINISHED); 650 : 651 : /* if the file is damaged, meaning that a fix failed */ - 652 757215 : if (file_flag_has(file, FILE_IS_DAMAGED)) { + 652 757286 : if (file_flag_has(file, FILE_IS_DAMAGED)) { 653 : /* rename it to .unrecoverable */ 654 : char path_to[PATH_MAX]; 655 : - 656 63364 : pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", disk->dir, file->sub); + 656 63260 : pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", disk->dir, file->sub); 657 : 658 : /* ensure to close the file before renaming */ - 659 63364 : if (handle[j].file == file) { - 660 63364 : ret = handle_close(&handle[j]); - 661 63364 : if (ret != 0) { + 659 63260 : if (handle[j].file == file) { + 660 63260 : ret = handle_close(&handle[j]); + 661 63260 : if (ret != 0) { 662 : /* LCOV_EXCL_START */ 663 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); 664 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -729,8 +729,8 @@ 667 : } 668 : } 669 : - 670 63364 : ret = rename(path, path_to); - 671 63364 : if (ret != 0) { + 670 63260 : ret = rename(path, path_to); + 671 63260 : if (ret != 0) { 672 : /* LCOV_EXCL_START */ 673 : log_fatal("Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno)); 674 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); @@ -738,22 +738,22 @@ 676 : /* LCOV_EXCL_STOP */ 677 : } 678 : - 679 63364 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub)); - 680 63364 : msg_info("unrecoverable %s\n", path); + 679 63260 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub)); + 680 63260 : msg_info("unrecoverable %s\n", path); 681 : 682 : /* and do not set the time if damaged */ - 683 63364 : goto close_and_continue; + 683 63260 : goto close_and_continue; 684 : } 685 : 686 : /* if the file is not fixed, meaning that it is untouched */ - 687 693851 : if (!file_flag_has(file, FILE_IS_FIXED)) { + 687 694026 : if (!file_flag_has(file, FILE_IS_FIXED)) { 688 : /* nothing to do, but close the file */ - 689 574395 : goto close_and_continue; + 689 574495 : goto close_and_continue; 690 : } 691 : 692 : /* if the file is closed or different than the one expected, reopen it */ 693 : /* a different open file could happen when filtering for bad blocks */ - 694 119456 : if (handle[j].file != file) { + 694 119531 : if (handle[j].file != file) { 695 : /* close a potential different file */ 696 0 : ret = handle_close(&handle[j]); 697 0 : if (ret != 0) { @@ -776,13 +776,13 @@ 714 : } 715 : } 716 : - 717 119456 : log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub)); - 718 119456 : msg_info("recovered %s\n", path); + 717 119531 : log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub)); + 718 119531 : msg_info("recovered %s\n", path); 719 : - 720 119456 : inode = handle[j].st.st_ino; + 720 119531 : inode = handle[j].st.st_ino; 721 : 722 : /* search for the corresponding inode */ - 723 119456 : collide_file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); + 723 119531 : collide_file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); 724 : 725 : /* if the inode is already in the database and it refers at a different file name, */ 726 : /* we can fix the file time ONLY if the time and size allow to differentiate */ @@ -792,15 +792,15 @@ 730 : /* when recreating them the inodes may be reused in a different order, */ 731 : /* and at the next sync some files may have matching inode/size/time even if different name */ 732 : /* not allowing sync to detect that the file is changed and not renamed */ - 733 119456 : if (!collide_file /* if not in the database, there is no collision */ - 734 37496 : || strcmp(collide_file->sub, file->sub) == 0 /* if the name is the same, it's the right collision */ - 735 35757 : || collide_file->size != file->size /* if the size is different, the collision is identified */ - 736 10 : || collide_file->mtime_sec != file->mtime_sec /* if the mtime is different, the collision is identified */ + 733 119531 : if (!collide_file /* if not in the database, there is no collision */ + 734 36876 : || strcmp(collide_file->sub, file->sub) == 0 /* if the name is the same, it's the right collision */ + 735 33424 : || collide_file->size != file->size /* if the size is different, the collision is identified */ + 736 7 : || collide_file->mtime_sec != file->mtime_sec /* if the mtime is different, the collision is identified */ 737 5 : || collide_file->mtime_nsec != file->mtime_nsec /* same for mtime_nsec */ 738 : ) { 739 : /* set the original modification time */ - 740 119455 : ret = handle_utime(&handle[j]); - 741 238910 : if (ret == -1) { + 740 119530 : ret = handle_utime(&handle[j]); + 741 239060 : if (ret == -1) { 742 : /* LCOV_EXCL_START */ 743 : /* mark the file as damaged */ 744 : file_flag_set(file, FILE_IS_DAMAGED); @@ -814,22 +814,22 @@ 752 : } else { 753 : /* we are not fixing, but only checking */ 754 : /* print just the final status */ - 755 1307820 : if (file_flag_has(file, FILE_IS_DAMAGED)) { - 756 9087 : if (state->opt.auditonly) { - 757 2758 : log_tag("status:damaged:%s:%s\n", disk->name, esc(file->sub)); - 758 2758 : msg_info("damaged %s\n", path); + 755 1308031 : if (file_flag_has(file, FILE_IS_DAMAGED)) { + 756 9029 : if (state->opt.auditonly) { + 757 2748 : log_tag("status:damaged:%s:%s\n", disk->name, esc(file->sub)); + 758 2748 : msg_info("damaged %s\n", path); 759 : } else { - 760 6329 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub)); - 761 6329 : msg_info("unrecoverable %s\n", path); + 760 6281 : log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub)); + 761 6281 : msg_info("unrecoverable %s\n", path); 762 : } - 763 1298733 : } else if (file_flag_has(file, FILE_IS_FIXED)) { - 764 76728 : log_tag("status:recoverable:%s:%s\n", disk->name, esc(file->sub)); - 765 76728 : msg_info("recoverable %s\n", path); + 763 1299002 : } else if (file_flag_has(file, FILE_IS_FIXED)) { + 764 76758 : log_tag("status:recoverable:%s:%s\n", disk->name, esc(file->sub)); + 765 76758 : msg_info("recoverable %s\n", path); 766 : } else { - 767 1222005 : log_tag("status:correct:%s:%s\n", disk->name, esc(file->sub)); + 767 1222244 : log_tag("status:correct:%s:%s\n", disk->name, esc(file->sub)); 768 : /* we don't use msg_verbose() because it also goes into the log */ - 769 1222005 : if (msg_level >= MSG_VERBOSE) - 770 23203 : msg_info("correct %s\n", path); + 769 1222244 : if (msg_level >= MSG_VERBOSE) + 770 23207 : msg_info("correct %s\n", path); 771 : } 772 : } 773 : @@ -837,11 +837,11 @@ 775 : /* if the opened file is the correct one, close it */ 776 : /* in case of excluded and fragmented files it's possible */ 777 : /* that the opened file is not the current one */ - 778 2161914 : if (handle[j].file == file) { + 778 2162258 : if (handle[j].file == file) { 779 : /* ensure to close the file just after finishing with it */ 780 : /* to avoid to keep it open without any possible use */ - 781 1978155 : ret = handle_close(&handle[j]); - 782 1978155 : if (ret != 0) { + 781 1978786 : ret = handle_close(&handle[j]); + 782 1978786 : if (ret != 0) { 783 : /* LCOV_EXCL_START */ 784 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); 785 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -851,56 +851,56 @@ 789 : } 790 : } 791 : - 792 925193 : return 0; + 792 926105 : return 0; 793 : } 794 : 795 : /** 796 : * Check if we have to process the specified block index ::i. 797 : */ - 798 1869102 : static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct snapraid_handle* handle, unsigned diskmax) + 798 1870958 : static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct snapraid_handle* handle, unsigned diskmax) 799 : { 800 : snapraid_info info; 801 : unsigned j; 802 : unsigned l; 803 : 804 : /* get block specific info */ - 805 1869102 : info = info_get(&state->infoarr, i); + 805 1870958 : info = info_get(&state->infoarr, i); 806 : 807 : /* if we filter for only bad blocks */ - 808 1869102 : if (state->opt.badonly) { + 808 1870958 : if (state->opt.badonly) { 809 : /* skip if this is not bad */ - 810 18716 : if (!info_get_bad(info)) - 811 15174 : return 0; + 810 18748 : if (!info_get_bad(info)) + 811 15204 : return 0; 812 : } 813 : 814 : /* for each parity */ - 815 2123608 : for (l = 0; l < state->level; ++l) { - 816 2040324 : if (!state->parity[l].is_excluded) { - 817 1770644 : return 1; + 815 2125818 : for (l = 0; l < state->level; ++l) { + 816 2042438 : if (!state->parity[l].is_excluded) { + 817 1772374 : return 1; 818 : } 819 : } 820 : 821 : /* for each disk */ - 822 385562 : for (j = 0; j < diskmax; ++j) { + 822 386210 : for (j = 0; j < diskmax; ++j) { 823 : struct snapraid_block* block; 824 : 825 : /* if no disk, nothing to check */ - 826 350436 : if (!handle[j].disk) + 826 350990 : if (!handle[j].disk) 827 0 : continue; 828 : - 829 350436 : block = fs_par2block_get(handle[j].disk, i); + 829 350990 : block = fs_par2block_get(handle[j].disk, i); 830 : 831 : /* try to recover all files, even the ones without hash */ 832 : /* because in some cases we can recover also them */ - 833 350436 : if (block_has_file(block)) { - 834 343994 : struct snapraid_file* file = fs_par2file_get(handle[j].disk, i, 0); - 835 343994 : if (!file_flag_has(file, FILE_IS_EXCLUDED)) { /* only if the file is not filtered out */ - 836 48158 : return 1; + 833 350990 : if (block_has_file(block)) { + 834 344328 : struct snapraid_file* file = fs_par2file_get(handle[j].disk, i, 0); + 835 344328 : if (!file_flag_has(file, FILE_IS_EXCLUDED)) { /* only if the file is not filtered out */ + 836 48160 : return 1; 837 : } 838 : } 839 : } 840 : - 841 35126 : return 0; + 841 35220 : return 0; 842 : } 843 : 844 118 : static int state_check_process(struct snapraid_state* state, int fix, struct snapraid_parity_handle** parity, block_off_t blockstart, block_off_t blockmax) @@ -945,33 +945,33 @@ 883 : 884 : /* first count the number of blocks to process */ 885 118 : countmax = 0; - 886 934669 : for (i = blockstart; i < blockmax; ++i) { - 887 934551 : if (!block_is_enabled(state, i, handle, diskmax)) - 888 25150 : continue; - 889 909401 : ++countmax; + 886 935597 : for (i = blockstart; i < blockmax; ++i) { + 887 935479 : if (!block_is_enabled(state, i, handle, diskmax)) + 888 25212 : continue; + 889 910267 : ++countmax; 890 : } 891 : 892 : /* check all the blocks in files */ 893 118 : countsize = 0; 894 118 : countpos = 0; 895 118 : state_progress_begin(state, blockstart, blockmax, countmax); - 896 934669 : for (i = blockstart; i < blockmax; ++i) { + 896 935597 : for (i = blockstart; i < blockmax; ++i) { 897 : unsigned failed_count; 898 : int valid_parity; 899 : snapraid_info info; 900 : int rehash; 901 : - 902 934551 : if (!block_is_enabled(state, i, handle, diskmax)) { + 902 935479 : if (!block_is_enabled(state, i, handle, diskmax)) { 903 : /* post process the files */ - 904 25150 : ret = file_post(state, fix, i, handle, diskmax); - 905 25150 : if (ret == -1) { + 904 25212 : ret = file_post(state, fix, i, handle, diskmax); + 905 25212 : if (ret == -1) { 906 0 : log_fatal("Stopping at block %u\n", i); 907 0 : ++unrecoverable_error; 908 0 : goto bail; 909 : } 910 : 911 : /* and now continue with the next block */ - 912 25150 : continue; + 912 25212 : continue; 913 : } 914 : 915 : /* If we have valid parity, and it makes sense to check its content. */ @@ -979,19 +979,19 @@ 917 : /* but we don't report parity errors */ 918 : /* Note that with auditonly, we anyway skip the full parity check, */ 919 : /* because we also don't read it at all */ - 920 909401 : valid_parity = 1; + 920 910267 : valid_parity = 1; 921 : 922 : /* keep track of the number of failed blocks */ - 923 909401 : failed_count = 0; + 923 910267 : failed_count = 0; 924 : 925 : /* get block specific info */ - 926 909401 : info = info_get(&state->infoarr, i); + 926 910267 : info = info_get(&state->infoarr, i); 927 : 928 : /* if we have to use the old hash */ - 929 909401 : rehash = info_get_rehash(info); + 929 910267 : rehash = info_get_rehash(info); 930 : 931 : /* for each disk, process the block */ - 932 6365807 : for (j = 0; j < diskmax; ++j) { + 932 6371869 : for (j = 0; j < diskmax; ++j) { 933 : int read_size; 934 : unsigned char hash[HASH_SIZE]; 935 : struct snapraid_disk* disk; @@ -1001,26 +1001,26 @@ 939 : unsigned block_state; 940 : 941 : /* if the disk position is not used */ - 942 5456406 : disk = handle[j].disk; - 943 5456406 : if (!disk) { + 942 5461602 : disk = handle[j].disk; + 943 5461602 : if (!disk) { 944 : /* use an empty block */ - 945 14037 : memset(buffer[j], 0, state->block_size); - 946 953296 : continue; + 945 14061 : memset(buffer[j], 0, state->block_size); + 946 955323 : continue; 947 : } 948 : 949 : /* if the disk block is not used */ - 950 5442369 : block = fs_par2block_get(disk, i); - 951 5442369 : if (block == BLOCK_EMPTY) { + 950 5447541 : block = fs_par2block_get(disk, i); + 951 5447541 : if (block == BLOCK_EMPTY) { 952 : /* use an empty block */ - 953 189495 : memset(buffer[j], 0, state->block_size); - 954 189495 : continue; + 953 192064 : memset(buffer[j], 0, state->block_size); + 954 192064 : continue; 955 : } 956 : 957 : /* get the state of the block */ - 958 5252874 : block_state = block_state_get(block); + 958 5255477 : block_state = block_state_get(block); 959 : 960 : /* if the parity is not valid */ - 961 5252874 : if (block_has_invalid_parity(block)) { + 961 5255477 : if (block_has_invalid_parity(block)) { 962 : /* mark the parity as invalid, and don't try to check/fix it */ 963 : /* because it will be recomputed at the next sync */ 964 94587 : valid_parity = 0; @@ -1028,7 +1028,7 @@ 966 : } 967 : 968 : /* if the block is DELETED */ - 969 5252874 : if (block_state == BLOCK_STATE_DELETED) { + 969 5255477 : if (block_state == BLOCK_STATE_DELETED) { 970 : /* use an empty block */ 971 18454 : memset(buffer[j], 0, state->block_size); 972 : @@ -1047,10 +1047,10 @@ 985 : } 986 : 987 : /* get the file of this block */ - 988 5234420 : file = fs_par2file_get(disk, i, &file_pos); + 988 5237023 : file = fs_par2file_get(disk, i, &file_pos); 989 : 990 : /* if we are only hashing, we can skip excluded files and don't even read them */ - 991 5234420 : if (state->opt.auditonly && file_flag_has(file, FILE_IS_EXCLUDED)) { + 991 5237023 : if (state->opt.auditonly && file_flag_has(file, FILE_IS_EXCLUDED)) { 992 : /* use an empty block */ 993 : /* in true, this is unnecessary, because we are not checking any parity */ 994 : /* but we keep it for completeness */ @@ -1059,10 +1059,10 @@ 997 : } 998 : 999 : /* if the file is closed or different than the current one */ - 1000 5234420 : if (handle[j].file == 0 || handle[j].file != file) { + 1000 5237023 : if (handle[j].file == 0 || handle[j].file != file) { 1001 : /* close the old one, if any */ - 1002 2259919 : ret = handle_close(&handle[j]); - 1003 2259919 : if (ret == -1) { + 1002 2259926 : ret = handle_close(&handle[j]); + 1003 2259926 : if (ret == -1) { 1004 : /* LCOV_EXCL_START */ 1005 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(handle[j].file->sub), strerror(errno)); 1006 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -1073,10 +1073,10 @@ 1011 : } 1012 : 1013 : /* if fixing, and the file is not excluded, we must open for writing */ - 1014 2259919 : if (fix && !file_flag_has(file, FILE_IS_EXCLUDED)) { + 1014 2259926 : if (fix && !file_flag_has(file, FILE_IS_EXCLUDED)) { 1015 : /* if fixing, create the file, open for writing and resize if required */ - 1016 771290 : ret = handle_create(&handle[j], file, state->file_mode); - 1017 771290 : if (ret == -1) { + 1016 771365 : ret = handle_create(&handle[j], file, state->file_mode); + 1017 771365 : if (ret == -1) { 1018 : /* LCOV_EXCL_START */ 1019 : if (errno == EACCES) { 1020 : log_fatal("WARNING! Please give write permission to the file.\n"); @@ -1090,69 +1090,69 @@ 1028 : } 1029 : 1030 : /* check if the file was just created */ - 1031 1542580 : if (handle[j].created != 0) { + 1031 1542730 : if (handle[j].created != 0) { 1032 : /* if fragmented, it may be reopened, so remember that the file */ 1033 : /* was originally missing */ - 1034 113107 : file_flag_set(file, FILE_IS_CREATED); + 1034 113054 : file_flag_set(file, FILE_IS_CREATED); 1035 : } 1036 : } else { 1037 : /* open the file only for reading */ - 1038 1488629 : if (!file_flag_has(file, FILE_IS_MISSING)) - 1039 1372724 : ret = handle_open(&handle[j], file, state->file_mode, - 1040 1372724 : log_error, state->opt.expected_missing ? log_expected : 0); + 1038 1488561 : if (!file_flag_has(file, FILE_IS_MISSING)) + 1039 1372929 : ret = handle_open(&handle[j], file, state->file_mode, + 1040 1372929 : log_error, state->opt.expected_missing ? log_expected : 0); 1041 : else - 1042 115905 : ret = -1; /* if the file is missing, we cannot open it */ - 1043 1488629 : if (ret == -1) { + 1042 115632 : ret = -1; /* if the file is missing, we cannot open it */ + 1043 1488561 : if (ret == -1) { 1044 : /* save the failed block for the check/fix */ - 1045 194668 : failed[failed_count].is_bad = 1; - 1046 194668 : failed[failed_count].is_outofdate = 0; - 1047 194668 : failed[failed_count].index = j; - 1048 194668 : failed[failed_count].block = block; - 1049 194668 : failed[failed_count].disk = disk; - 1050 194668 : failed[failed_count].file = file; - 1051 194668 : failed[failed_count].file_pos = file_pos; - 1052 194668 : failed[failed_count].handle = &handle[j]; - 1053 194668 : ++failed_count; + 1045 194158 : failed[failed_count].is_bad = 1; + 1046 194158 : failed[failed_count].is_outofdate = 0; + 1047 194158 : failed[failed_count].index = j; + 1048 194158 : failed[failed_count].block = block; + 1049 194158 : failed[failed_count].disk = disk; + 1050 194158 : failed[failed_count].file = file; + 1051 194158 : failed[failed_count].file_pos = file_pos; + 1052 194158 : failed[failed_count].handle = &handle[j]; + 1053 194158 : ++failed_count; 1054 : - 1055 194668 : log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc(file->sub), file_pos); - 1056 194668 : ++error; + 1055 194158 : log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc(file->sub), file_pos); + 1056 194158 : ++error; 1057 : 1058 : /* mark the file as missing, to avoid to retry to open it again */ 1059 : /* note that this can be done only if we are not fixing it */ 1060 : /* otherwise, it could be recreated */ - 1061 194668 : file_flag_set(file, FILE_IS_MISSING); - 1062 194668 : continue; + 1061 194158 : file_flag_set(file, FILE_IS_MISSING); + 1062 194158 : continue; 1063 : } 1064 : } 1065 : 1066 : /* if it's the first open, and not excluded */ - 1067 2065251 : if (!file_flag_has(file, FILE_IS_OPENED) - 1068 2049859 : && !file_flag_has(file, FILE_IS_EXCLUDED)) { + 1067 2065768 : if (!file_flag_has(file, FILE_IS_OPENED) + 1068 2050390 : && !file_flag_has(file, FILE_IS_EXCLUDED)) { 1069 : 1070 : /* check if the file is changed */ - 1071 1998374 : if (handle[j].st.st_size != file->size - 1072 1805527 : || handle[j].st.st_mtime != file->mtime_sec - 1073 1781193 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec + 1071 1998901 : if (handle[j].st.st_size != file->size + 1072 1806252 : || handle[j].st.st_mtime != file->mtime_sec + 1073 1781912 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec 1074 : /* don't check the inode to support file-system without persistent inodes */ 1075 : ) { 1076 : /* report that the file is not synced */ - 1077 217181 : file_flag_set(file, FILE_IS_UNSYNCED); + 1077 216989 : file_flag_set(file, FILE_IS_UNSYNCED); 1078 : } 1079 : } 1080 : 1081 : /* if it's the first open, and not excluded and larger */ - 1082 2065251 : if (!file_flag_has(file, FILE_IS_OPENED) - 1083 2049859 : && !file_flag_has(file, FILE_IS_EXCLUDED) - 1084 1998374 : && !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED)) - 1085 1998374 : && handle[j].st.st_size > file->size + 1082 2065768 : if (!file_flag_has(file, FILE_IS_OPENED) + 1083 2050390 : && !file_flag_has(file, FILE_IS_EXCLUDED) + 1084 1998901 : && !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED)) + 1085 1998901 : && handle[j].st.st_size > file->size 1086 : ) { - 1087 8640 : log_error("File '%s' is larger than expected.\n", handle[j].path); - 1088 8640 : log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc(file->sub)); - 1089 8640 : ++error; + 1087 8464 : log_error("File '%s' is larger than expected.\n", handle[j].path); + 1088 8464 : log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc(file->sub)); + 1089 8464 : ++error; 1090 : - 1091 8640 : if (fix) { - 1092 3187 : ret = handle_truncate(&handle[j], file); - 1093 3187 : if (ret == -1) { + 1091 8464 : if (fix) { + 1092 3129 : ret = handle_truncate(&handle[j], file); + 1093 3129 : if (ret == -1) { 1094 : /* LCOV_EXCL_START */ 1095 : log_fatal("DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n"); 1096 : log_fatal("Stopping at block %u\n", i); @@ -1161,43 +1161,43 @@ 1099 : /* LCOV_EXCL_STOP */ 1100 : } 1101 : - 1102 3187 : log_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc(file->sub)); - 1103 3187 : ++recovered_error; + 1102 3129 : log_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc(file->sub)); + 1103 3129 : ++recovered_error; 1104 : } 1105 : } 1106 : 1107 : /* mark the file as opened at least one time */ 1108 : /* this is used to avoid to check the unsynced and size */ 1109 : /* more than one time, in case the file is reopened later */ - 1110 2065251 : file_flag_set(file, FILE_IS_OPENED); + 1110 2065768 : file_flag_set(file, FILE_IS_OPENED); 1111 : } 1112 : 1113 : /* read from the file */ - 1114 5039752 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, - 1115 5039752 : log_error, state->opt.expected_missing ? log_expected : 0); - 1116 5039752 : if (read_size == -1) { + 1114 5042865 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, + 1115 5042865 : log_error, state->opt.expected_missing ? log_expected : 0); + 1116 5042865 : if (read_size == -1) { 1117 : /* save the failed block for the check/fix */ - 1118 442526 : failed[failed_count].is_bad = 1; /* it's bad because we cannot read it */ - 1119 442526 : failed[failed_count].is_outofdate = 0; - 1120 442526 : failed[failed_count].index = j; - 1121 442526 : failed[failed_count].block = block; - 1122 442526 : failed[failed_count].disk = disk; - 1123 442526 : failed[failed_count].file = file; - 1124 442526 : failed[failed_count].file_pos = file_pos; - 1125 442526 : failed[failed_count].handle = &handle[j]; - 1126 442526 : ++failed_count; + 1118 442280 : failed[failed_count].is_bad = 1; /* it's bad because we cannot read it */ + 1119 442280 : failed[failed_count].is_outofdate = 0; + 1120 442280 : failed[failed_count].index = j; + 1121 442280 : failed[failed_count].block = block; + 1122 442280 : failed[failed_count].disk = disk; + 1123 442280 : failed[failed_count].file = file; + 1124 442280 : failed[failed_count].file_pos = file_pos; + 1125 442280 : failed[failed_count].handle = &handle[j]; + 1126 442280 : ++failed_count; 1127 : - 1128 442526 : log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(file->sub), file_pos); - 1129 442526 : ++error; - 1130 442526 : continue; + 1128 442280 : log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(file->sub), file_pos); + 1129 442280 : ++error; + 1130 442280 : continue; 1131 : } 1132 : - 1133 4597226 : countsize += read_size; + 1133 4600585 : countsize += read_size; 1134 : 1135 : /* always insert CHG blocks, the repair functions needs all of them */ 1136 : /* because the parity may be still referring at the old state */ 1137 : /* and the repair must be aware of it */ - 1138 4597226 : if (block_state == BLOCK_STATE_CHG) { + 1138 4600585 : if (block_state == BLOCK_STATE_CHG) { 1139 : /* we DO NOT mark them as bad to avoid to overwrite them with wrong data. */ 1140 : /* if we don't have a hash, we always assume the first read of the block correct. */ 1141 13843 : failed[failed_count].is_bad = 0; /* we assume the CHG block correct */ @@ -1212,39 +1212,39 @@ 1150 13843 : continue; 1151 : } 1152 : - 1153 4583383 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); + 1153 4586742 : assert(block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP); 1154 : 1155 : /* compute the hash of the block just read */ - 1156 4583383 : if (rehash) { - 1157 27231 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); + 1156 4586742 : if (rehash) { + 1157 27243 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); 1158 : } else { - 1159 4556152 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); + 1159 4559499 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); 1160 : } 1161 : 1162 : /* compare the hash */ - 1163 4583383 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { - 1164 12808 : unsigned diff = memdiff(hash, block->hash, HASH_SIZE); + 1163 4586742 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { + 1164 12974 : unsigned diff = memdiff(hash, block->hash, HASH_SIZE); 1165 : 1166 : /* save the failed block for the check/fix */ - 1167 12808 : failed[failed_count].is_bad = 1; /* it's bad because the hash doesn't match */ - 1168 12808 : failed[failed_count].is_outofdate = 0; - 1169 12808 : failed[failed_count].index = j; - 1170 12808 : failed[failed_count].block = block; - 1171 12808 : failed[failed_count].disk = disk; - 1172 12808 : failed[failed_count].file = file; - 1173 12808 : failed[failed_count].file_pos = file_pos; - 1174 12808 : failed[failed_count].handle = &handle[j]; - 1175 12808 : ++failed_count; + 1167 12974 : failed[failed_count].is_bad = 1; /* it's bad because the hash doesn't match */ + 1168 12974 : failed[failed_count].is_outofdate = 0; + 1169 12974 : failed[failed_count].index = j; + 1170 12974 : failed[failed_count].block = block; + 1171 12974 : failed[failed_count].disk = disk; + 1172 12974 : failed[failed_count].file = file; + 1173 12974 : failed[failed_count].file_pos = file_pos; + 1174 12974 : failed[failed_count].handle = &handle[j]; + 1175 12974 : ++failed_count; 1176 : - 1177 12808 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc(file->sub), file_pos, diff); - 1178 12808 : ++error; - 1179 12808 : continue; + 1177 12974 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc(file->sub), file_pos, diff); + 1178 12974 : ++error; + 1179 12974 : continue; 1180 : } 1181 : 1182 : /* always insert REP blocks, the repair functions needs all of them */ 1183 : /* because the parity may be still referring at the old state */ 1184 : /* and the repair must be aware of it */ - 1185 4570575 : if (block_state == BLOCK_STATE_REP) { + 1185 4573768 : if (block_state == BLOCK_STATE_REP) { 1186 53428 : failed[failed_count].is_bad = 0; /* it's not bad */ 1187 53428 : failed[failed_count].is_outofdate = 0; 1188 53428 : failed[failed_count].index = j; @@ -1259,67 +1259,67 @@ 1197 : } 1198 : 1199 : /* now read and check the parity if requested */ - 1200 909401 : if (!state->opt.auditonly) { + 1200 910267 : if (!state->opt.auditonly) { 1201 : void* buffer_recov[LEV_MAX]; 1202 : void* buffer_zero; 1203 : 1204 : /* buffers for parity read and not computed */ - 1205 4166971 : for (l = 0; l < state->level; ++l) - 1206 3296805 : buffer_recov[l] = buffer[diskmax + state->level + l]; - 1207 2794357 : for (; l < LEV_MAX; ++l) - 1208 1924191 : buffer_recov[l] = 0; + 1205 4171025 : for (l = 0; l < state->level; ++l) + 1206 3300033 : buffer_recov[l] = buffer[diskmax + state->level + l]; + 1207 2796911 : for (; l < LEV_MAX; ++l) + 1208 1925919 : buffer_recov[l] = 0; 1209 : 1210 : /* the zero buffer is the last one */ - 1211 870166 : buffer_zero = buffer[buffermax - 1]; + 1211 870992 : buffer_zero = buffer[buffermax - 1]; 1212 : 1213 : /* read the parity */ - 1214 4166971 : for (l = 0; l < state->level; ++l) { - 1215 3296805 : if (parity[l]) { - 1216 3282919 : ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error); - 1217 3282919 : if (ret == -1) { - 1218 90295 : buffer_recov[l] = 0; /* no parity to use */ + 1214 4171025 : for (l = 0; l < state->level; ++l) { + 1215 3300033 : if (parity[l]) { + 1216 3286131 : ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error); + 1217 3286131 : if (ret == -1) { + 1218 90335 : buffer_recov[l] = 0; /* no parity to use */ 1219 : - 1220 90295 : log_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l)); - 1221 90295 : ++error; + 1220 90335 : log_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l)); + 1221 90335 : ++error; 1222 : } 1223 : } else { - 1224 13886 : buffer_recov[l] = 0; + 1224 13902 : buffer_recov[l] = 0; 1225 : } 1226 : } 1227 : 1228 : /* try all the recovering strategies */ - 1229 870166 : ret = repair(state, rehash, i, diskmax, failed, failed_map, failed_count, buffer, buffer_recov, buffer_zero); - 1230 870166 : if (ret != 0) { + 1229 870992 : ret = repair(state, rehash, i, diskmax, failed, failed_map, failed_count, buffer, buffer_recov, buffer_zero); + 1230 870992 : if (ret != 0) { 1231 : /* increment the number of errors */ - 1232 47694 : if (ret > 0) - 1233 4646 : error += ret; - 1234 47694 : ++unrecoverable_error; + 1232 47557 : if (ret > 0) + 1233 4635 : error += ret; + 1234 47557 : ++unrecoverable_error; 1235 : 1236 : /* print a list of all the errors in files */ - 1237 218712 : for (j = 0; j < failed_count; ++j) { - 1238 171018 : if (failed[j].is_bad) - 1239 166496 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].disk->name, esc(failed[j].file->sub), failed[j].file_pos); + 1237 218200 : for (j = 0; j < failed_count; ++j) { + 1238 170643 : if (failed[j].is_bad) + 1239 166121 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].disk->name, esc(failed[j].file->sub), failed[j].file_pos); 1240 : } 1241 : 1242 : /* keep track of damaged files */ - 1243 218712 : for (j = 0; j < failed_count; ++j) { - 1244 171018 : if (failed[j].is_bad) - 1245 166496 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); + 1243 218200 : for (j = 0; j < failed_count; ++j) { + 1244 170643 : if (failed[j].is_bad) + 1245 166121 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1246 : } 1247 : } else { 1248 : /* now counts partial recovers */ 1249 : /* note that this could happen only when we have an incomplete 'sync' */ 1250 : /* and that we have recovered is the state before the 'sync' */ - 1251 822472 : int partial_recover_error = 0; + 1251 823435 : int partial_recover_error = 0; 1252 : 1253 : /* print a list of all the errors in files */ - 1254 1381331 : for (j = 0; j < failed_count; ++j) { - 1255 558859 : if (failed[j].is_bad && failed[j].is_outofdate) { + 1254 1382113 : for (j = 0; j < failed_count; ++j) { + 1255 558678 : if (failed[j].is_bad && failed[j].is_outofdate) { 1256 8 : ++partial_recover_error; 1257 8 : log_tag("unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].disk->name, esc(failed[j].file->sub), failed[j].file_pos); 1258 : } 1259 : } - 1260 822472 : if (partial_recover_error != 0) { + 1260 823435 : if (partial_recover_error != 0) { 1261 8 : error += partial_recover_error; 1262 8 : ++unrecoverable_error; 1263 : } @@ -1327,36 +1327,36 @@ 1265 : /* now check parities, but only if all the blocks have it computed */ 1266 : /* if you check/fix after a partial sync, it's OK to have parity errors on the blocks with invalid parity */ 1267 : /* and doesn't make sense to try to fix it */ - 1268 822472 : if (valid_parity) { + 1268 823435 : if (valid_parity) { 1269 : /* check the parity */ - 1270 3725482 : for (l = 0; l < state->level; ++l) { - 1271 2964593 : if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) { - 1272 10750 : unsigned diff = memdiff(buffer_recov[l], buffer[diskmax + l], state->block_size); + 1270 3729908 : for (l = 0; l < state->level; ++l) { + 1271 2968058 : if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) { + 1272 10860 : unsigned diff = memdiff(buffer_recov[l], buffer[diskmax + l], state->block_size); 1273 : 1274 : /* mark that the read parity is wrong, setting ptr to 0 */ - 1275 10750 : buffer_recov[l] = 0; + 1275 10860 : buffer_recov[l] = 0; 1276 : - 1277 10750 : log_tag("parity_error:%u:%s: Data error, diff bits %u\n", i, lev_config_name(l), diff); - 1278 10750 : ++error; + 1277 10860 : log_tag("parity_error:%u:%s: Data error, diff bits %u\n", i, lev_config_name(l), diff); + 1278 10860 : ++error; 1279 : } 1280 : } 1281 : } 1282 : 1283 : /* now write recovered files */ - 1284 822472 : if (fix) { + 1284 823435 : if (fix) { 1285 : /* update the fixed files */ - 1286 652441 : for (j = 0; j < failed_count; ++j) { + 1286 652859 : for (j = 0; j < failed_count; ++j) { 1287 : /* nothing to do if it doesn't need recovering */ - 1288 338114 : if (!failed[j].is_bad) + 1288 338152 : if (!failed[j].is_bad) 1289 40318 : continue; 1290 : 1291 : /* do not fix if the file is excluded */ - 1292 297796 : if (file_flag_has(failed[j].file, FILE_IS_EXCLUDED) - 1293 288532 : || (state->opt.syncedonly && file_flag_has(failed[j].file, FILE_IS_UNSYNCED))) - 1294 9264 : continue; + 1292 297834 : if (file_flag_has(failed[j].file, FILE_IS_EXCLUDED) + 1293 288554 : || (state->opt.syncedonly && file_flag_has(failed[j].file, FILE_IS_UNSYNCED))) + 1294 9280 : continue; 1295 : - 1296 288532 : ret = handle_write(failed[j].handle, failed[j].file_pos, buffer[failed[j].index], state->block_size); - 1297 288532 : if (ret == -1) { + 1296 288554 : ret = handle_write(failed[j].handle, failed[j].file_pos, buffer[failed[j].index], state->block_size); + 1297 288554 : if (ret == -1) { 1298 : /* LCOV_EXCL_START */ 1299 : /* mark the file as damaged */ 1300 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); @@ -1374,7 +1374,7 @@ 1312 : } 1313 : 1314 : /* if we are not sure that the recovered content is uptodate */ - 1315 288532 : if (failed[j].is_outofdate) { + 1315 288554 : if (failed[j].is_outofdate) { 1316 : /* mark the file as damaged */ 1317 8 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1318 8 : continue; @@ -1382,27 +1382,27 @@ 1320 : 1321 : /* mark the file as containing some fixes */ 1322 : /* note that it could be also marked as damaged in other iterations */ - 1323 288524 : file_flag_set(failed[j].file, FILE_IS_FIXED); + 1323 288546 : file_flag_set(failed[j].file, FILE_IS_FIXED); 1324 : - 1325 288524 : log_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].disk->name, esc(failed[j].file->sub), failed[j].file_pos); - 1326 288524 : ++recovered_error; + 1325 288546 : log_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].disk->name, esc(failed[j].file->sub), failed[j].file_pos); + 1326 288546 : ++recovered_error; 1327 : } 1328 : 1329 : /* update parity only if all the blocks have it computed */ 1330 : /* if you check/fix after a partial sync, you do not want to fix parity */ 1331 : /* for blocks that are going to have it computed in the sync completion */ - 1332 314327 : if (valid_parity) { + 1332 314707 : if (valid_parity) { 1333 : /* update the parity */ - 1334 962923 : for (l = 0; l < state->level; ++l) { + 1334 964277 : for (l = 0; l < state->level; ++l) { 1335 : /* if the parity on disk is wrong */ - 1336 697776 : if (buffer_recov[l] == 0 + 1336 698750 : if (buffer_recov[l] == 0 1337 : /* and we have access at the parity */ - 1338 67218 : && parity[l] != 0 + 1338 67322 : && parity[l] != 0 1339 : /* and the parity is not excluded */ - 1340 62539 : && !state->parity[l].is_excluded + 1340 62635 : && !state->parity[l].is_excluded 1341 : ) { - 1342 62539 : ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size); - 1343 62539 : if (ret == -1) { + 1342 62635 : ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size); + 1343 62635 : if (ret == -1) { 1344 : /* LCOV_EXCL_START */ 1345 : /* we do not use DANGER because it could be ENOSPC which is not always correctly reported */ 1346 : log_fatal("WARNING! Without a working %s disk, it isn't possible to fix errors on it.\n", lev_name(l)); @@ -1412,17 +1412,17 @@ 1350 : /* LCOV_EXCL_STOP */ 1351 : } 1352 : - 1353 62539 : log_tag("parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l)); - 1354 62539 : ++recovered_error; + 1353 62635 : log_tag("parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l)); + 1354 62635 : ++recovered_error; 1355 : } 1356 : } 1357 : } 1358 : } else { 1359 : /* if we are not fixing, we just set the FIXED flag */ 1360 : /* meaning that we could fix this file if we try */ - 1361 728890 : for (j = 0; j < failed_count; ++j) { - 1362 220745 : if (failed[j].is_bad) { - 1363 179860 : file_flag_set(failed[j].file, FILE_IS_FIXED); + 1361 729254 : for (j = 0; j < failed_count; ++j) { + 1362 220526 : if (failed[j].is_bad) { + 1363 179641 : file_flag_set(failed[j].file, FILE_IS_FIXED); 1364 : } 1365 : } 1366 : } @@ -1430,26 +1430,26 @@ 1368 : } else { 1369 : /* if we are not checking, we just set the DAMAGED flag */ 1370 : /* to report that the file is damaged, and we don't know if we can fix it */ - 1371 45085 : for (j = 0; j < failed_count; ++j) { - 1372 5850 : if (failed[j].is_bad) { - 1373 5850 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); + 1371 45091 : for (j = 0; j < failed_count; ++j) { + 1372 5816 : if (failed[j].is_bad) { + 1373 5816 : file_flag_set(failed[j].file, FILE_IS_DAMAGED); 1374 : } 1375 : } 1376 : } 1377 : 1378 : /* post process the files */ - 1379 909401 : ret = file_post(state, fix, i, handle, diskmax); - 1380 909401 : if (ret == -1) { + 1379 910267 : ret = file_post(state, fix, i, handle, diskmax); + 1380 910267 : if (ret == -1) { 1381 0 : log_fatal("Stopping at block %u\n", i); 1382 0 : ++unrecoverable_error; 1383 0 : goto bail; 1384 : } 1385 : 1386 : /* count the number of processed block */ - 1387 909401 : ++countpos; + 1387 910267 : ++countpos; 1388 : 1389 : /* progress */ - 1390 909401 : if (state_progress(state, i, countpos, countmax, countsize)) { + 1390 910267 : if (state_progress(state, i, countpos, countmax, countsize)) { 1391 : /* LCOV_EXCL_START */ 1392 : break; 1393 : /* LCOV_EXCL_STOP */ @@ -1467,18 +1467,18 @@ 1405 : /* for each empty file in the disk */ 1406 705 : disk = handle[i].disk; 1407 705 : node = disk->filelist; - 1408 2188784 : while (node) { + 1408 2189134 : while (node) { 1409 : char path[PATH_MAX]; 1410 : struct stat st; 1411 : struct snapraid_file* file; - 1412 2187374 : int unsuccesful = 0; + 1412 2187724 : int unsuccesful = 0; 1413 : - 1414 2187374 : file = node->data; - 1415 2187374 : node = node->next; /* next node */ + 1414 2187724 : file = node->data; + 1415 2187724 : node = node->next; /* next node */ 1416 : 1417 : /* if not empty, it's already checked and continue to the next one */ - 1418 2187374 : if (file->size != 0) { - 1419 4369013 : continue; + 1418 2187724 : if (file->size != 0) { + 1419 4369713 : continue; 1420 : } 1421 : 1422 : /* if excluded continue to the next one */ @@ -1490,29 +1490,29 @@ 1428 2783 : pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub); 1429 2783 : ret = stat(path, &st); 1430 2783 : if (ret == -1) { - 1431 169 : unsuccesful = 1; + 1431 164 : unsuccesful = 1; 1432 : - 1433 169 : log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno)); - 1434 169 : log_tag("error:%s:%s: Empty file stat error\n", disk->name, esc(file->sub)); - 1435 169 : ++error; - 1436 2614 : } else if (!S_ISREG(st.st_mode)) { + 1433 164 : log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno)); + 1434 164 : log_tag("error:%s:%s: Empty file stat error\n", disk->name, esc(file->sub)); + 1435 164 : ++error; + 1436 2619 : } else if (!S_ISREG(st.st_mode)) { 1437 0 : unsuccesful = 1; 1438 : 1439 0 : log_tag("error:%s:%s: Empty file error for not regular file\n", disk->name, esc(file->sub)); 1440 0 : ++error; - 1441 2614 : } else if (st.st_size != 0) { - 1442 14 : unsuccesful = 1; + 1441 2619 : } else if (st.st_size != 0) { + 1442 3 : unsuccesful = 1; 1443 : - 1444 14 : log_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc(file->sub), st.st_size); - 1445 14 : ++error; + 1444 3 : log_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc(file->sub), st.st_size); + 1445 3 : ++error; 1446 : } 1447 : 1448 2783 : if (fix && unsuccesful) { 1449 : int f; 1450 : 1451 : /* create the ancestor directories */ - 1452 158 : ret = mkancestor(path); - 1453 158 : if (ret != 0) { + 1452 153 : ret = mkancestor(path); + 1453 153 : if (ret != 0) { 1454 : /* LCOV_EXCL_START */ 1455 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); 1456 : log_fatal("Stopping\n"); @@ -1523,8 +1523,8 @@ 1461 : 1462 : /* create it */ 1463 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ - 1464 158 : f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600); - 1465 158 : if (f == -1) { + 1464 153 : f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600); + 1465 153 : if (f == -1) { 1466 : /* LCOV_EXCL_START */ 1467 : log_fatal("Error creating empty file '%s'. %s.\n", path, strerror(errno)); 1468 : if (errno == EACCES) { @@ -1540,8 +1540,8 @@ 1478 : } 1479 : 1480 : /* set the original modification time */ - 1481 158 : ret = fmtime(f, file->mtime_sec, file->mtime_nsec); - 1482 158 : if (ret != 0) { + 1481 153 : ret = fmtime(f, file->mtime_sec, file->mtime_nsec); + 1482 153 : if (ret != 0) { 1483 : /* LCOV_EXCL_START */ 1484 : close(f); 1485 : @@ -1554,8 +1554,8 @@ 1492 : } 1493 : 1494 : /* close it */ - 1495 158 : ret = close(f); - 1496 158 : if (ret != 0) { + 1495 153 : ret = close(f); + 1496 153 : if (ret != 0) { 1497 : /* LCOV_EXCL_START */ 1498 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); 1499 : log_fatal("Stopping\n"); @@ -1564,11 +1564,11 @@ 1502 : /* LCOV_EXCL_STOP */ 1503 : } 1504 : - 1505 158 : log_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc(file->sub)); - 1506 158 : ++recovered_error; + 1505 153 : log_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc(file->sub)); + 1506 153 : ++recovered_error; 1507 : - 1508 158 : log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub)); - 1509 158 : msg_info("recovered %s%s\n", disk->dir, file->sub); + 1508 153 : log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub)); + 1509 153 : msg_info("recovered %s%s\n", disk->dir, file->sub); 1510 : } 1511 : } 1512 : @@ -1650,33 +1650,33 @@ 1588 66532 : pathprint(path, sizeof(path), "%s%s", disk->dir, slink->sub); 1589 66532 : ret = readlink(path, linkto, sizeof(linkto)); 1590 66532 : if (ret < 0) { - 1591 4273 : unsuccesful = 1; + 1591 4297 : unsuccesful = 1; 1592 : - 1593 4273 : log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno)); - 1594 4273 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(slink->sub)); - 1595 4273 : ++error; - 1596 62259 : } else if (ret >= PATH_MAX) { + 1593 4297 : log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno)); + 1594 4297 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(slink->sub)); + 1595 4297 : ++error; + 1596 62235 : } else if (ret >= PATH_MAX) { 1597 0 : unsuccesful = 1; 1598 : 1599 0 : log_error("Error reading symlink '%s'. Symlink too long.\n", path); 1600 0 : log_tag("symlink_error:%s:%s: Symlink read error\n", disk->name, esc(slink->sub)); 1601 0 : ++error; 1602 : } else { - 1603 62259 : linkto[ret] = 0; + 1603 62235 : linkto[ret] = 0; 1604 : - 1605 62259 : if (strcmp(linkto, slink->linkto) != 0) { - 1606 561 : unsuccesful = 1; + 1605 62235 : if (strcmp(linkto, slink->linkto) != 0) { + 1606 539 : unsuccesful = 1; 1607 : - 1608 561 : log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(slink->sub), linkto, slink->linkto); - 1609 561 : ++error; + 1608 539 : log_tag("symlink_error:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(slink->sub), linkto, slink->linkto); + 1609 539 : ++error; 1610 : } 1611 : } 1612 : } 1613 : 1614 66850 : if (fix && unsuccesful && !unrecoverable) { 1615 : /* create the ancestor directories */ - 1616 3941 : ret = mkancestor(path); - 1617 3941 : if (ret != 0) { + 1616 3942 : ret = mkancestor(path); + 1617 3942 : if (ret != 0) { 1618 : /* LCOV_EXCL_START */ 1619 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); 1620 : log_fatal("Stopping\n"); @@ -1686,8 +1686,8 @@ 1624 : } 1625 : 1626 : /* if it exists, it must be deleted before recreating */ - 1627 3941 : ret = remove(path); - 1628 3941 : if (ret != 0 && errno != ENOENT) { + 1627 3942 : ret = remove(path); + 1628 3942 : if (ret != 0 && errno != ENOENT) { 1629 : /* LCOV_EXCL_START */ 1630 : log_fatal("Error removing '%s'. %s.\n", path, strerror(errno)); 1631 : log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); @@ -1698,7 +1698,7 @@ 1636 : } 1637 : 1638 : /* create it */ - 1639 3941 : if (link_flag_has(slink, FILE_IS_HARDLINK)) { + 1639 3942 : if (link_flag_has(slink, FILE_IS_HARDLINK)) { 1640 12 : ret = hardlink(pathto, path); 1641 12 : if (ret != 0) { 1642 : /* LCOV_EXCL_START */ @@ -1718,8 +1718,8 @@ 1656 12 : log_tag("hardlink_fixed:%s:%s: Fixed hardlink error\n", disk->name, esc(slink->sub)); 1657 12 : ++recovered_error; 1658 : } else { - 1659 3929 : ret = symlink(slink->linkto, path); - 1660 3929 : if (ret != 0) { + 1659 3930 : ret = symlink(slink->linkto, path); + 1660 3930 : if (ret != 0) { 1661 : /* LCOV_EXCL_START */ 1662 : log_fatal("Error writing symlink '%s' to '%s'. %s.\n", path, slink->linkto, strerror(errno)); 1663 : if (errno == EACCES) { @@ -1734,12 +1734,12 @@ 1672 : /* LCOV_EXCL_STOP */ 1673 : } 1674 : - 1675 3929 : log_tag("symlink_fixed:%s:%s: Fixed symlink error\n", disk->name, esc(slink->sub)); - 1676 3929 : ++recovered_error; + 1675 3930 : log_tag("symlink_fixed:%s:%s: Fixed symlink error\n", disk->name, esc(slink->sub)); + 1676 3930 : ++recovered_error; 1677 : } 1678 : - 1679 3941 : log_tag("status:recovered:%s:%s\n", disk->name, esc(slink->sub)); - 1680 3941 : msg_info("recovered %s%s\n", disk->dir, slink->sub); + 1679 3942 : log_tag("status:recovered:%s:%s\n", disk->name, esc(slink->sub)); + 1680 3942 : msg_info("recovered %s%s\n", disk->dir, slink->sub); 1681 : } 1682 : } 1683 : @@ -1846,23 +1846,23 @@ 1784 : /* for each file in the disk */ 1785 269 : disk = handle[i].disk; 1786 269 : node = disk->filelist; - 1787 870715 : while (node) { + 1787 870849 : while (node) { 1788 : char path[PATH_MAX]; 1789 : struct snapraid_file* file; 1790 : - 1791 870177 : file = node->data; - 1792 870177 : node = node->next; /* next node */ + 1791 870311 : file = node->data; + 1792 870311 : node = node->next; /* next node */ 1793 : 1794 : /* if the file was not created, meaning that it was already existing */ - 1795 870177 : if (!file_flag_has(file, FILE_IS_CREATED)) { + 1795 870311 : if (!file_flag_has(file, FILE_IS_CREATED)) { 1796 : /* nothing to do */ - 1797 1627247 : continue; + 1797 1627568 : continue; 1798 : } 1799 : 1800 : /* if processing was finished */ - 1801 113107 : if (file_flag_has(file, FILE_IS_FINISHED)) { + 1801 113054 : if (file_flag_has(file, FILE_IS_FINISHED)) { 1802 : /* nothing to do */ - 1803 113107 : continue; + 1803 113054 : continue; 1804 : } 1805 : 1806 : /* 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 df63bf7b..131855f9 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-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/cmdline/device.c.func.html b/cov/cmdline/device.c.func.html index 9ffc7cc5..0e478eff 100644 --- a/cov/cmdline/device.c.func.html +++ b/cov/cmdline/device.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/cmdline/device.c.gcov.html b/cov/cmdline/device.c.gcov.html index 8b590e26..70af25a8 100644 --- a/cov/cmdline/device.c.gcov.html +++ b/cov/cmdline/device.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/cmdline/dry.c.func-sort-c.html b/cov/cmdline/dry.c.func-sort-c.html index fd89714e..c72b7b45 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-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/cmdline/dry.c.func.html b/cov/cmdline/dry.c.func.html index 318ac87c..ec3f7b73 100644 --- a/cov/cmdline/dry.c.func.html +++ b/cov/cmdline/dry.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/cmdline/dry.c.gcov.html b/cov/cmdline/dry.c.gcov.html index 6886148c..6bb03593 100644 --- a/cov/cmdline/dry.c.gcov.html +++ b/cov/cmdline/dry.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -116,38 +116,38 @@ 54 2 : countsize = 0; 55 2 : countpos = 0; 56 2 : state_progress_begin(state, blockstart, blockmax, countmax); - 57 7088 : for (i = blockstart; i < blockmax; ++i) { + 57 7104 : for (i = blockstart; i < blockmax; ++i) { 58 : /* for each disk, process the block */ - 59 49602 : for (j = 0; j < diskmax; ++j) { + 59 49714 : for (j = 0; j < diskmax; ++j) { 60 : int read_size; 61 : struct snapraid_block* block; - 62 42516 : struct snapraid_disk* disk = handle[j].disk; + 62 42612 : struct snapraid_disk* disk = handle[j].disk; 63 : struct snapraid_file* file; 64 : block_off_t file_pos; 65 : - 66 42516 : if (!disk) { + 66 42612 : if (!disk) { 67 : /* if no disk, nothing to do */ - 68 9855 : continue; + 68 9919 : continue; 69 : } 70 : - 71 37837 : block = fs_par2block_get(disk, i); + 71 37925 : block = fs_par2block_get(disk, i); 72 : - 73 37837 : if (!block_has_file(block)) { + 73 37925 : if (!block_has_file(block)) { 74 : /* if no file, nothing to do */ - 75 497 : continue; + 75 545 : continue; 76 : } 77 : 78 : /* get the file of this block */ - 79 37340 : file = fs_par2file_get(disk, i, &file_pos); + 79 37380 : file = fs_par2file_get(disk, i, &file_pos); 80 : 81 : /* until now is CPU */ - 82 37340 : state_usage_cpu(state); + 82 37380 : state_usage_cpu(state); 83 : 84 : /* if the file is closed or different than the current one */ - 85 37340 : if (handle[j].file == 0 || handle[j].file != file) { + 85 37380 : if (handle[j].file == 0 || handle[j].file != file) { 86 : /* close the old one, if any */ - 87 15096 : ret = handle_close(&handle[j]); - 88 15096 : if (ret == -1) { + 87 15101 : ret = handle_close(&handle[j]); + 88 15101 : if (ret == -1) { 89 : /* LCOV_EXCL_START */ 90 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(handle[j].file->sub), strerror(errno)); 91 : log_fatal("DANGER! Unexpected close error in a data disk, it isn't possible to dry.\n"); @@ -158,8 +158,8 @@ 96 : } 97 : 98 : /* open the file only for reading */ - 99 15096 : ret = handle_open(&handle[j], file, state->file_mode, log_fatal, 0); - 100 15096 : if (ret == -1) { + 99 15101 : ret = handle_open(&handle[j], file, state->file_mode, log_fatal, 0); + 100 15101 : if (ret == -1) { 101 : /* LCOV_EXCL_START */ 102 : log_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); 103 : log_fatal("DANGER! Unexpected open error in a data disk, it isn't possible to dry.\n"); @@ -171,41 +171,41 @@ 109 : } 110 : 111 : /* read from the file */ - 112 37340 : read_size = handle_read(&handle[j], file_pos, buffer_aligned, state->block_size, log_error, 0); - 113 37340 : if (read_size == -1) { + 112 37380 : read_size = handle_read(&handle[j], file_pos, buffer_aligned, state->block_size, log_error, 0); + 113 37380 : if (read_size == -1) { 114 0 : log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(file->sub), file_pos); 115 0 : ++error; 116 0 : continue; 117 : } 118 : 119 : /* until now is disk */ - 120 37340 : state_usage_disk(state, disk); + 120 37380 : state_usage_disk(state, disk); 121 : - 122 37340 : countsize += read_size; + 122 37380 : countsize += read_size; 123 : } 124 : 125 : /* read the parity */ - 126 49602 : for (l = 0; l < state->level; ++l) { - 127 42516 : if (parity[l]) { + 126 49714 : for (l = 0; l < state->level; ++l) { + 127 42612 : if (parity[l]) { 128 : /* until now is CPU */ - 129 42516 : state_usage_cpu(state); + 129 42612 : state_usage_cpu(state); 130 : - 131 42516 : ret = parity_read(parity[l], i, buffer_aligned, state->block_size, log_error); - 132 42516 : if (ret == -1) { + 131 42612 : ret = parity_read(parity[l], i, buffer_aligned, state->block_size, log_error); + 132 42612 : if (ret == -1) { 133 0 : log_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l)); 134 0 : ++error; 135 : } 136 : 137 : /* until now is parity */ - 138 42516 : state_usage_parity(state, l); + 138 42612 : state_usage_parity(state, l); 139 : } 140 : } 141 : 142 : /* count the number of processed block */ - 143 7086 : ++countpos; + 143 7102 : ++countpos; 144 : 145 : /* progress */ - 146 7086 : if (state_progress(state, i, countpos, countmax, countsize)) { + 146 7102 : if (state_progress(state, i, countpos, countmax, countsize)) { 147 : /* LCOV_EXCL_START */ 148 : break; 149 : /* LCOV_EXCL_STOP */ diff --git a/cov/cmdline/dup.c.func-sort-c.html b/cov/cmdline/dup.c.func-sort-c.html index bf95ff92..6f640c9d 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-01-09 + 2016-01-16 Functions: 5 @@ -61,19 +61,19 @@ hash_alloc - 16970 + 16976 hash_free - 16970 + 16976 hash_hash - 16970 + 16976 hash_compare - 14 + 18 state_dup diff --git a/cov/cmdline/dup.c.func.html b/cov/cmdline/dup.c.func.html index 3dd795c3..e59dcd91 100644 --- a/cov/cmdline/dup.c.func.html +++ b/cov/cmdline/dup.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 5 @@ -61,19 +61,19 @@ hash_alloc - 16970 + 16976 hash_compare - 14 + 18 hash_free - 16970 + 16976 hash_hash - 16970 + 16976 state_dup diff --git a/cov/cmdline/dup.c.gcov.html b/cov/cmdline/dup.c.gcov.html index 2be2ce52..b0933857 100644 --- a/cov/cmdline/dup.c.gcov.html +++ b/cov/cmdline/dup.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 5 @@ -98,54 +98,54 @@ 36 : tommy_hashdyn_node node; 37 : }; 38 : - 39 16970 : struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) + 39 16976 : struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) 40 : { 41 : struct snapraid_hash* hash; 42 : block_off_t i; 43 : unsigned char* buf; 44 : - 45 16970 : hash = malloc_nofail(sizeof(struct snapraid_hash)); - 46 16970 : hash->disk = disk; - 47 16970 : hash->file = file; + 45 16976 : hash = malloc_nofail(sizeof(struct snapraid_hash)); + 46 16976 : hash->disk = disk; + 47 16976 : hash->file = file; 48 : - 49 16970 : buf = malloc_nofail(file->blockmax * HASH_SIZE); + 49 16976 : buf = malloc_nofail(file->blockmax * HASH_SIZE); 50 : 51 : /* set the back pointer */ - 52 58942 : for (i = 0; i < file->blockmax; ++i) { - 53 41972 : struct snapraid_block* block = fs_file2block_get(file, i); + 52 58996 : for (i = 0; i < file->blockmax; ++i) { + 53 42020 : struct snapraid_block* block = fs_file2block_get(file, i); 54 : - 55 41972 : memcpy(buf + i * HASH_SIZE, block->hash, HASH_SIZE); + 55 42020 : memcpy(buf + i * HASH_SIZE, block->hash, HASH_SIZE); 56 : - 57 41972 : if (!block_has_updated_hash(block)) { + 57 42020 : if (!block_has_updated_hash(block)) { 58 0 : free(buf); 59 0 : free(hash); 60 0 : return 0; 61 : } 62 : } 63 : - 64 16970 : memhash(state->besthash, state->hashseed, hash->hash, buf, file->blockmax * HASH_SIZE); + 64 16976 : memhash(state->besthash, state->hashseed, hash->hash, buf, file->blockmax * HASH_SIZE); 65 : - 66 16970 : free(buf); + 66 16976 : free(buf); 67 : - 68 16970 : return hash; + 68 16976 : return hash; 69 : } 70 : - 71 16970 : static inline tommy_uint32_t hash_hash(struct snapraid_hash* hash) + 71 16976 : static inline tommy_uint32_t hash_hash(struct snapraid_hash* hash) 72 : { - 73 16970 : return tommy_hash_u32(0, hash->hash, HASH_SIZE); + 73 16976 : return tommy_hash_u32(0, hash->hash, HASH_SIZE); 74 : } 75 : - 76 16970 : void hash_free(struct snapraid_hash* hash) + 76 16976 : void hash_free(struct snapraid_hash* hash) 77 : { - 78 16970 : free(hash); - 79 16970 : } + 78 16976 : free(hash); + 79 16976 : } 80 : - 81 14 : int hash_compare(const void* void_arg, const void* void_data) + 81 18 : int hash_compare(const void* void_arg, const void* void_data) 82 : { - 83 14 : const char* arg = void_arg; - 84 14 : const struct snapraid_hash* hash = void_data; + 83 18 : const char* arg = void_arg; + 84 18 : const struct snapraid_hash* hash = void_data; 85 : - 86 14 : return memcmp(arg, hash->hash, HASH_SIZE); + 86 18 : return memcmp(arg, hash->hash, HASH_SIZE); 87 : } 88 : 89 3 : void state_dup(struct snapraid_state* state) @@ -168,32 +168,32 @@ 106 18 : struct snapraid_disk* disk = i->data; 107 : 108 : /* for each file */ - 109 17012 : for (j = disk->filelist; j != 0; j = j->next) { - 110 16994 : struct snapraid_file* file = j->data; + 109 17018 : for (j = disk->filelist; j != 0; j = j->next) { + 110 17000 : struct snapraid_file* file = j->data; 111 : struct snapraid_hash* hash; 112 : tommy_hash_t hash32; 113 : 114 : /* if empty, skip it */ - 115 16994 : if (file->size == 0) + 115 17000 : if (file->size == 0) 116 24 : continue; 117 : - 118 16970 : hash = hash_alloc(state, disk, file); + 118 16976 : hash = hash_alloc(state, disk, file); 119 : 120 : /* if no hash, skip it */ - 121 16970 : if (!hash) + 121 16976 : if (!hash) 122 0 : continue; 123 : - 124 16970 : hash32 = hash_hash(hash); + 124 16976 : hash32 = hash_hash(hash); 125 : - 126 16970 : struct snapraid_hash* found = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash32); - 127 16970 : if (found) { - 128 14 : ++count; - 129 14 : size += found->file->size; - 130 14 : log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), found->disk->name, esc(found->file->sub), found->file->size); - 131 14 : printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, found->disk->dir, found->file->sub); - 132 14 : hash_free(hash); + 126 16976 : struct snapraid_hash* found = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash32); + 127 16976 : if (found) { + 128 18 : ++count; + 129 18 : size += found->file->size; + 130 18 : log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), found->disk->name, esc(found->file->sub), found->file->size); + 131 18 : printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, found->disk->dir, found->file->sub); + 132 18 : hash_free(hash); 133 : } else { - 134 16956 : tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32); + 134 16958 : tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32); 135 : } 136 : } 137 : } diff --git a/cov/cmdline/elem.c.func-sort-c.html b/cov/cmdline/elem.c.func-sort-c.html index fdcb8ada..16a053e9 100644 --- a/cov/cmdline/elem.c.func-sort-c.html +++ b/cov/cmdline/elem.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 546 - 582 - 93.8 % + 548 + 583 + 94.0 % Date: - 2016-01-09 + 2016-01-16 Functions: 62 @@ -61,115 +61,115 @@ chunk_parity_inside_compare - 102351431 + 102361796 chunk_file_compare - 44153325 + 44162450 - fs_file2block_get - 44106216 + fs_file2block_get + 44005284 chunk_parity_compare - 43351652 + 43323431 fs_par2chunk_get_ts - 38418652 + 38412957 fs_par2file_get_ts - 38311850 + 38306069 - fs_par2block_get_ts - 26733115 + fs_par2block_get_ts + 26721446 chunk_file_inside_compare - 21495373 + 21328815 filter_apply - 12222233 + 12223998 fs_file2chunk_get_ts - 10223247 + 10190236 - fs_allocate - 8975787 + fs_allocate + 8981211 file_block_size - 6677441 + 6680330 chunk_file_check_foreach - 6441048 + 6425469 chunk_parity_check_foreach - 6441048 + 6425469 filter_recurse - 6118464 + 6119907 file_block_is_last - 5326414 + 5329166 - fs_file2par_get_ts - 4878725 + fs_file2par_maybe_ts + 4840928 chunk_alloc - 3657427 + 3658037 file_alloc - 3611495 + 3612132 chunk_free - 3486903 + 3487501 file_free - 3466242 + 3466869 filter_element - 3273724 + 3274485 filter_path - 3270701 + 3271462 filter_content - 3114300 + 3114995 file_inode_compare_to_arg - 927047 + 927285 - time_compare - 707506 + time_compare + 717256 file_path_compare - 129121 + 129157 filter_type - 125387 + 125183 link_alloc @@ -180,32 +180,32 @@ 111078 - fs_deallocate - 106802 + fs_deallocate + 106888 file_path_compare_to_arg - 104908 + 103230 filter_existence - 80688 + 80702 file_physical_compare - 49676 + 59718 chunk_disk_size_compare - 48702 + 48684 file_name - 47994 + 48014 filter_correctness - 38732 + 38698 link_name_compare_to_arg @@ -213,27 +213,27 @@ file_dup - 24707 + 24709 file_namestamp_compare - 23997 + 24007 file_name_compare - 23997 + 24007 file_stamp_compare - 23661 + 23670 file_copy - 23633 + 23636 disk_size - 4165 + 4219 filter_dir @@ -241,31 +241,31 @@ fs_check - 2838 + 2880 disk_alloc - 1525 + 1537 - map_alloc - 1495 + map_alloc + 1507 content_alloc - 1490 + 1504 disk_free - 1399 + 1411 - map_free - 1375 + map_free + 1387 content_free - 1353 + 1367 link_alpha_compare @@ -273,7 +273,7 @@ disk_is_empty - 870 + 888 dir_alloc @@ -285,11 +285,11 @@ filter_alloc_file - 514 + 518 filter_free - 477 + 481 dir_name_compare @@ -301,7 +301,7 @@ chunk_disk_empty_compare - 13 + 12 filter_alloc_disk diff --git a/cov/cmdline/elem.c.func.html b/cov/cmdline/elem.c.func.html index b00e3681..a21a427d 100644 --- a/cov/cmdline/elem.c.func.html +++ b/cov/cmdline/elem.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 546 - 582 - 93.8 % + 548 + 583 + 94.0 % Date: - 2016-01-09 + 2016-01-16 Functions: 62 @@ -61,51 +61,51 @@ chunk_alloc - 3657427 + 3658037 chunk_disk_empty_compare - 13 + 12 chunk_disk_size_compare - 48702 + 48684 chunk_file_check_foreach - 6441048 + 6425469 chunk_file_compare - 44153325 + 44162450 chunk_file_inside_compare - 21495373 + 21328815 chunk_free - 3486903 + 3487501 chunk_parity_check_foreach - 6441048 + 6425469 chunk_parity_compare - 43351652 + 43323431 chunk_parity_inside_compare - 102351431 + 102361796 content_alloc - 1490 + 1504 content_free - 1353 + 1367 dir_alloc @@ -121,43 +121,43 @@ disk_alloc - 1525 + 1537 disk_free - 1399 + 1411 disk_is_empty - 870 + 888 disk_size - 4165 + 4219 file_alloc - 3611495 + 3612132 file_block_is_last - 5326414 + 5329166 file_block_size - 6677441 + 6680330 file_copy - 23633 + 23636 file_dup - 24707 + 24709 file_free - 3466242 + 3466869 file_inode_compare @@ -165,27 +165,27 @@ file_inode_compare_to_arg - 927047 + 927285 file_name - 47994 + 48014 file_name_compare - 23997 + 24007 file_namestamp_compare - 23997 + 24007 file_path_compare - 129121 + 129157 file_path_compare_to_arg - 104908 + 103230 file_pathstamp_compare @@ -193,7 +193,7 @@ file_physical_compare - 49676 + 59718 file_rename @@ -201,7 +201,7 @@ file_stamp_compare - 23661 + 23670 filter_alloc_disk @@ -209,19 +209,19 @@ filter_alloc_file - 514 + 518 filter_apply - 12222233 + 12223998 filter_content - 3114300 + 3114995 filter_correctness - 38732 + 38698 filter_dir @@ -229,63 +229,63 @@ filter_element - 3273724 + 3274485 filter_existence - 80688 + 80702 filter_free - 477 + 481 filter_path - 3270701 + 3271462 filter_recurse - 6118464 + 6119907 filter_type - 125387 + 125183 - fs_allocate - 8975787 + fs_allocate + 8981211 fs_check - 2838 + 2880 - fs_deallocate - 106802 + fs_deallocate + 106888 - fs_file2block_get - 44106216 + fs_file2block_get + 44005284 fs_file2chunk_get_ts - 10223247 + 10190236 - fs_file2par_get_ts - 4878725 + fs_file2par_maybe_ts + 4840928 - fs_par2block_get_ts - 26733115 + fs_par2block_get_ts + 26721446 fs_par2chunk_get_ts - 38418652 + 38412957 fs_par2file_get_ts - 38311850 + 38306069 link_alloc @@ -304,16 +304,16 @@ 31837 - map_alloc - 1495 + map_alloc + 1507 - map_free - 1375 + map_free + 1387 - time_compare - 707506 + time_compare + 717256
diff --git a/cov/cmdline/elem.c.gcov.html b/cov/cmdline/elem.c.gcov.html index 647e3a16..4ff4c06d 100644 --- a/cov/cmdline/elem.c.gcov.html +++ b/cov/cmdline/elem.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 546 - 582 - 93.8 % + 548 + 583 + 94.0 % Date: - 2016-01-09 + 2016-01-16 Functions: 62 @@ -86,23 +86,23 @@ 24 : /****************************************************************************/ 25 : /* snapraid */ 26 : - 27 1490 : struct snapraid_content* content_alloc(const char* path, uint64_t dev) + 27 1504 : struct snapraid_content* content_alloc(const char* path, uint64_t dev) 28 : { 29 : struct snapraid_content* content; 30 : - 31 1490 : content = malloc_nofail(sizeof(struct snapraid_content)); - 32 1490 : pathimport(content->content, sizeof(content->content), path); - 33 1490 : content->device = dev; + 31 1504 : content = malloc_nofail(sizeof(struct snapraid_content)); + 32 1504 : pathimport(content->content, sizeof(content->content), path); + 33 1504 : content->device = dev; 34 : - 35 1490 : return content; + 35 1504 : return content; 36 : } 37 : - 38 1353 : void content_free(struct snapraid_content* content) + 38 1367 : void content_free(struct snapraid_content* content) 39 : { - 40 1353 : free(content); - 41 1353 : } + 40 1367 : free(content); + 41 1367 : } 42 : - 43 514 : struct snapraid_filter* filter_alloc_file(int direction, const char* pattern) + 43 518 : struct snapraid_filter* filter_alloc_file(int direction, const char* pattern) 44 : { 45 : struct snapraid_filter* filter; 46 : char* i; @@ -111,18 +111,18 @@ 49 : int token_is_valid; 50 : int token_is_filled; 51 : - 52 514 : filter = malloc_nofail(sizeof(struct snapraid_filter)); - 53 514 : pathimport(filter->pattern, sizeof(filter->pattern), pattern); - 54 514 : filter->direction = direction; + 52 518 : filter = malloc_nofail(sizeof(struct snapraid_filter)); + 53 518 : pathimport(filter->pattern, sizeof(filter->pattern), pattern); + 54 518 : filter->direction = direction; 55 : 56 : /* find first and last slash */ - 57 514 : first = 0; - 58 514 : last = 0; + 57 518 : first = 0; + 58 518 : last = 0; 59 : /* reject invalid tokens, like "<empty>", ".", ".." and more dots */ - 60 514 : token_is_valid = 0; - 61 514 : token_is_filled = 0; - 62 6372 : for (i = filter->pattern; *i; ++i) { - 63 5859 : if (*i == '/') { + 60 518 : token_is_valid = 0; + 61 518 : token_is_filled = 0; + 62 6422 : for (i = filter->pattern; *i; ++i) { + 63 5905 : if (*i == '/') { 64 : /* reject invalid tokens, but accept an empty one as first */ 65 5 : if (!token_is_valid && (first != 0 || token_is_filled)) { 66 1 : free(filter); @@ -135,27 +135,27 @@ 73 4 : if (!first) 74 3 : first = i; 75 4 : last = i; - 76 5854 : } else if (*i != '.') { - 77 5344 : token_is_valid = 1; - 78 5344 : token_is_filled = 1; + 76 5900 : } else if (*i != '.') { + 77 5386 : token_is_valid = 1; + 78 5386 : token_is_filled = 1; 79 : } else { - 80 510 : token_is_filled = 1; + 80 514 : token_is_filled = 1; 81 : } 82 : } 83 : 84 : /* reject invalid tokens, but accept an empty one as last, but not if it's the only one */ - 85 513 : if (!token_is_valid && (first == 0 || token_is_filled)) { + 85 517 : if (!token_is_valid && (first == 0 || token_is_filled)) { 86 1 : free(filter); 87 1 : return 0; 88 : } 89 : 90 : /* it's a file filter */ - 91 512 : filter->is_disk = 0; + 91 516 : filter->is_disk = 0; 92 : - 93 512 : if (first == 0) { + 93 516 : if (first == 0) { 94 : /* no slash */ - 95 509 : filter->is_path = 0; - 96 509 : filter->is_dir = 0; + 95 513 : filter->is_path = 0; + 96 513 : filter->is_dir = 0; 97 3 : } else if (first == last && last[1] == 0) { 98 : /* one slash at the end */ 99 1 : filter->is_path = 0; @@ -178,7 +178,7 @@ 116 : } 117 : } 118 : - 119 511 : return filter; + 119 515 : return filter; 120 : } 121 : 122 8 : struct snapraid_filter* filter_alloc_disk(int direction, const char* pattern) @@ -205,140 +205,140 @@ 143 8 : return filter; 144 : } 145 : - 146 477 : void filter_free(struct snapraid_filter* filter) + 146 481 : void filter_free(struct snapraid_filter* filter) 147 : { - 148 477 : free(filter); - 149 477 : } + 148 481 : free(filter); + 149 481 : } 150 : - 151 125387 : const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size) + 151 125183 : const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size) 152 : { 153 : const char* direction; - 154 125387 : if (filter->direction < 0) - 155 125133 : direction = "exclude"; + 154 125183 : if (filter->direction < 0) + 155 124927 : direction = "exclude"; 156 : else - 157 254 : direction = "include"; + 157 256 : direction = "include"; 158 : - 159 125387 : if (filter->is_disk) + 159 125183 : if (filter->is_disk) 160 0 : pathprint(out, out_size, "%s %s:", direction, filter->pattern); - 161 125387 : else if (filter->is_dir) + 161 125183 : else if (filter->is_dir) 162 0 : pathprint(out, out_size, "%s %s/", direction, filter->pattern); 163 : else - 164 125387 : pathprint(out, out_size, "%s %s", direction, filter->pattern); + 164 125183 : pathprint(out, out_size, "%s %s", direction, filter->pattern); 165 : - 166 125387 : return out; + 166 125183 : return out; 167 : } 168 : - 169 12222233 : static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* path, const char* name, int is_dir) + 169 12223998 : static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* path, const char* name, int is_dir) 170 : { - 171 12222233 : int ret = 0; + 171 12223998 : int ret = 0; 172 : 173 : /* match dirs with dirs and files with files */ - 174 12222233 : if (filter->is_dir && !is_dir) - 175 2946 : return 0; - 176 12219287 : if (!filter->is_dir && is_dir) - 177 6106768 : return 0; + 174 12223998 : if (filter->is_dir && !is_dir) + 175 2949 : return 0; + 176 12221049 : if (!filter->is_dir && is_dir) + 177 6107090 : return 0; 178 : - 179 6112519 : if (filter->is_path) { + 179 6113959 : if (filter->is_path) { 180 : /* skip initial slash, as always missing from the path */ - 181 2946 : if (fnmatch(filter->pattern + 1, path, FNM_PATHNAME | FNM_CASEINSENSITIVE_FOR_WIN) == 0) + 181 2949 : if (fnmatch(filter->pattern + 1, path, FNM_PATHNAME | FNM_CASEINSENSITIVE_FOR_WIN) == 0) 182 0 : ret = filter->direction; 183 : } else { - 184 6109573 : if (fnmatch(filter->pattern, name, FNM_CASEINSENSITIVE_FOR_WIN) == 0) - 185 127869 : ret = filter->direction; + 184 6111010 : if (fnmatch(filter->pattern, name, FNM_CASEINSENSITIVE_FOR_WIN) == 0) + 185 127661 : ret = filter->direction; 186 : } 187 : - 188 6112519 : if (reason != 0 && ret < 0) - 189 124879 : *reason = filter; + 188 6113959 : if (reason != 0 && ret < 0) + 189 124671 : *reason = filter; 190 : - 191 6112519 : return ret; + 191 6113959 : return ret; 192 : } 193 : - 194 6118464 : static int filter_recurse(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* const_path, int is_dir) + 194 6119907 : static int filter_recurse(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* const_path, int is_dir) 195 : { 196 : char path[PATH_MAX]; 197 : char* name; 198 : unsigned i; 199 : - 200 6118464 : pathcpy(path, sizeof(path), const_path); + 200 6119907 : pathcpy(path, sizeof(path), const_path); 201 : 202 : /* filter for all the directories */ - 203 6118464 : name = path; - 204 88222216 : for (i = 0; path[i] != 0; ++i) { - 205 82106742 : if (path[i] == '/') { + 203 6119907 : name = path; + 204 88226852 : for (i = 0; path[i] != 0; ++i) { + 205 82109935 : if (path[i] == '/') { 206 : /* set a terminator */ - 207 6106759 : path[i] = 0; + 207 6107081 : path[i] = 0; 208 : 209 : /* filter the directory */ - 210 6106759 : if (filter_apply(filter, reason, path, name, 1) != 0) + 210 6107081 : if (filter_apply(filter, reason, path, name, 1) != 0) 211 2990 : return filter->direction; 212 : 213 : /* restore the slash */ - 214 6103769 : path[i] = '/'; + 214 6104091 : path[i] = '/'; 215 : 216 : /* next name */ - 217 6103769 : name = path + i + 1; + 217 6104091 : name = path + i + 1; 218 : } 219 : } 220 : 221 : /* filter the final file */ - 222 6115474 : if (filter_apply(filter, reason, path, name, is_dir) != 0) - 223 124879 : return filter->direction; + 222 6116917 : if (filter_apply(filter, reason, path, name, is_dir) != 0) + 223 124671 : return filter->direction; 224 : - 225 5990595 : return 0; + 225 5992246 : return 0; 226 : } 227 : - 228 3273724 : static int filter_element(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub, int is_dir) + 228 3274485 : static int filter_element(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub, int is_dir) 229 : { 230 : tommy_node* i; 231 : - 232 3273724 : int direction = 1; /* by default include all */ + 232 3274485 : int direction = 1; /* by default include all */ 233 : 234 : /* for each filter */ - 235 9365584 : for (i = tommy_list_head(filterlist); i != 0; i = i->next) { + 235 9368018 : for (i = tommy_list_head(filterlist); i != 0; i = i->next) { 236 : int ret; - 237 6228405 : struct snapraid_filter* filter = i->data; + 237 6229872 : struct snapraid_filter* filter = i->data; 238 : - 239 6228405 : if (filter->is_disk) { - 240 109941 : if (fnmatch(filter->pattern, disk, FNM_CASEINSENSITIVE_FOR_WIN) == 0) - 241 8676 : ret = filter->direction; + 239 6229872 : if (filter->is_disk) { + 240 109965 : if (fnmatch(filter->pattern, disk, FNM_CASEINSENSITIVE_FOR_WIN) == 0) + 241 8678 : ret = filter->direction; 242 : else - 243 101265 : ret = 0; - 244 109941 : if (reason != 0 && ret < 0) + 243 101287 : ret = 0; + 244 109965 : if (reason != 0 && ret < 0) 245 0 : *reason = filter; 246 : } else { - 247 6118464 : ret = filter_recurse(filter, reason, sub, is_dir); + 247 6119907 : ret = filter_recurse(filter, reason, sub, is_dir); 248 : } 249 : - 250 6228405 : if (ret > 0) { + 250 6229872 : if (ret > 0) { 251 : /* include the file */ - 252 11666 : return 0; - 253 6216739 : } else if (ret < 0) { + 252 11668 : return 0; + 253 6218204 : } else if (ret < 0) { 254 : /* exclude the file */ - 255 124879 : return -1; + 255 124671 : return -1; 256 : } else { 257 : /* default is opposite of the last filter */ - 258 6091860 : direction = -filter->direction; - 259 6091860 : if (reason != 0 && direction < 0) - 260 3051823 : *reason = filter; + 258 6093533 : direction = -filter->direction; + 259 6093533 : if (reason != 0 && direction < 0) + 260 3052540 : *reason = filter; 261 : /* continue with the next one */ 262 : } 263 : } 264 : 265 : /* directories are always included by default, otherwise we cannot apply rules */ 266 : /* to the contained files */ - 267 3137179 : if (is_dir) + 267 3138146 : if (is_dir) 268 3022 : return 0; 269 : 270 : /* files are excluded/included depending of the last rule processed */ - 271 3134157 : if (direction < 0) - 272 57574 : return -1; + 271 3135124 : if (direction < 0) + 272 57587 : return -1; 273 : - 274 3076583 : return 0; + 274 3077537 : return 0; 275 : } 276 : - 277 3270701 : int filter_path(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) + 277 3271462 : int filter_path(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) 278 : { - 279 3270701 : return filter_element(filterlist, reason, disk, sub, 0); + 279 3271462 : return filter_element(filterlist, reason, disk, sub, 0); 280 : } 281 : 282 3023 : int filter_dir(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub) @@ -346,21 +346,21 @@ 284 3023 : return filter_element(filterlist, reason, disk, sub, 1); 285 : } 286 : - 287 80688 : int filter_existence(int filter_missing, const char* dir, const char* sub) + 287 80702 : int filter_existence(int filter_missing, const char* dir, const char* sub) 288 : { 289 : char path[PATH_MAX]; 290 : struct stat st; 291 : - 292 80688 : if (!filter_missing) - 293 34978 : return 0; + 292 80702 : if (!filter_missing) + 293 34986 : return 0; 294 : 295 : /* we directly check if in the disk the file is present or not */ - 296 45710 : pathprint(path, sizeof(path), "%s%s", dir, sub); + 296 45716 : pathprint(path, sizeof(path), "%s%s", dir, sub); 297 : - 298 45710 : if (lstat(path, &st) != 0) { + 298 45716 : if (lstat(path, &st) != 0) { 299 : /* if the file doesn't exist, we don't filter it out */ - 300 4913 : if (errno == ENOENT) - 301 4913 : return 0; + 300 4871 : if (errno == ENOENT) + 301 4871 : return 0; 302 : /* LCOV_EXCL_START */ 303 : log_fatal("Error in stat file '%s'. %s.\n", path, strerror(errno)); 304 : exit(EXIT_FAILURE); @@ -368,111 +368,111 @@ 306 : } 307 : 308 : /* the file is present, so we filter it out */ - 309 40797 : return 1; + 309 40845 : return 1; 310 : } 311 : - 312 38732 : int filter_correctness(int filter_error, tommy_arrayblkof* infoarr, struct snapraid_disk* disk, struct snapraid_file* file) + 312 38698 : int filter_correctness(int filter_error, tommy_arrayblkof* infoarr, struct snapraid_disk* disk, struct snapraid_file* file) 313 : { 314 : unsigned i; 315 : - 316 38732 : if (!filter_error) - 317 16190 : return 0; + 316 38698 : if (!filter_error) + 317 16150 : return 0; 318 : 319 : /* check each block of the file */ - 320 60567 : for (i = 0; i < file->blockmax; ++i) { - 321 46357 : block_off_t parity_pos = fs_file2par_get(disk, file, i); - 322 46357 : snapraid_info info = info_get(infoarr, parity_pos); + 320 60678 : for (i = 0; i < file->blockmax; ++i) { + 321 46466 : block_off_t parity_pos = fs_file2par_get(disk, file, i); + 322 46466 : snapraid_info info = info_get(infoarr, parity_pos); 323 : 324 : /* if the file has a bad block, don't exclude it */ - 325 46357 : if (info_get_bad(info)) - 326 8332 : return 0; + 325 46466 : if (info_get_bad(info)) + 326 8336 : return 0; 327 : } 328 : 329 : /* the file is correct, so we filter it out */ - 330 14210 : return 1; + 330 14212 : return 1; 331 : } 332 : - 333 3114300 : int filter_content(tommy_list* contentlist, const char* path) + 333 3114995 : int filter_content(tommy_list* contentlist, const char* path) 334 : { 335 : tommy_node* i; 336 : - 337 40437716 : for (i = tommy_list_head(contentlist); i != 0; i = i->next) { - 338 17104558 : struct snapraid_content* content = i->data; + 337 40446128 : for (i = tommy_list_head(contentlist); i != 0; i = i->next) { + 338 17108069 : struct snapraid_content* content = i->data; 339 : char tmp[PATH_MAX]; 340 : - 341 17104558 : if (pathcmp(content->content, path) == 0) + 341 17108069 : if (pathcmp(content->content, path) == 0) 342 0 : return -1; 343 : 344 : /* exclude also the ".tmp" copy used to save it */ - 345 17104558 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - 346 17104558 : if (pathcmp(tmp, path) == 0) + 345 17108069 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); + 346 17108069 : if (pathcmp(tmp, path) == 0) 347 0 : return -1; 348 : 349 : /* exclude also the ".lock" file */ - 350 17104558 : pathprint(tmp, sizeof(tmp), "%s.lock", content->content); - 351 17104558 : if (pathcmp(tmp, path) == 0) + 350 17108069 : pathprint(tmp, sizeof(tmp), "%s.lock", content->content); + 351 17108069 : if (pathcmp(tmp, path) == 0) 352 0 : return -1; 353 : } 354 : - 355 3114300 : return 0; + 355 3114995 : return 0; 356 : } 357 : - 358 3611495 : 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) + 358 3612132 : 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) 359 : { 360 : struct snapraid_file* file; 361 : block_off_t i; 362 : - 363 3611495 : file = malloc_nofail(sizeof(struct snapraid_file)); - 364 3611495 : file->sub = strdup_nofail(sub); - 365 3611495 : file->size = size; - 366 3611495 : file->blockmax = (size + block_size - 1) / block_size; - 367 3611495 : file->mtime_sec = mtime_sec; - 368 3611495 : file->mtime_nsec = mtime_nsec; - 369 3611495 : file->inode = inode; - 370 3611495 : file->physical = physical; - 371 3611495 : file->flag = 0; - 372 3611495 : file->blockvec = malloc_nofail(file->blockmax * sizeof(struct snapraid_block)); + 363 3612132 : file = malloc_nofail(sizeof(struct snapraid_file)); + 364 3612132 : file->sub = strdup_nofail(sub); + 365 3612132 : file->size = size; + 366 3612132 : file->blockmax = (size + block_size - 1) / block_size; + 367 3612132 : file->mtime_sec = mtime_sec; + 368 3612132 : file->mtime_nsec = mtime_nsec; + 369 3612132 : file->inode = inode; + 370 3612132 : file->physical = physical; + 371 3612132 : file->flag = 0; + 372 3612132 : file->blockvec = malloc_nofail(file->blockmax * sizeof(struct snapraid_block)); 373 : - 374 12530604 : for (i = 0; i < file->blockmax; ++i) { - 375 8919109 : block_state_set(&file->blockvec[i], BLOCK_STATE_CHG); - 376 8919109 : hash_invalid_set(file->blockvec[i].hash); + 374 12536645 : for (i = 0; i < file->blockmax; ++i) { + 375 8924513 : block_state_set(&file->blockvec[i], BLOCK_STATE_CHG); + 376 8924513 : hash_invalid_set(file->blockvec[i].hash); 377 : } 378 : - 379 3611495 : return file; + 379 3612132 : return file; 380 : } 381 : - 382 24707 : struct snapraid_file* file_dup(struct snapraid_file* copy) + 382 24709 : struct snapraid_file* file_dup(struct snapraid_file* copy) 383 : { 384 : struct snapraid_file* file; 385 : block_off_t i; 386 : - 387 24707 : file = malloc_nofail(sizeof(struct snapraid_file)); - 388 24707 : file->sub = strdup_nofail(copy->sub); - 389 24707 : file->size = copy->size; - 390 24707 : file->blockmax = copy->blockmax; - 391 24707 : file->mtime_sec = copy->mtime_sec; - 392 24707 : file->mtime_nsec = copy->mtime_nsec; - 393 24707 : file->inode = copy->inode; - 394 24707 : file->physical = copy->physical; - 395 24707 : file->flag = copy->flag; - 396 24707 : file->blockvec = malloc_nofail(file->blockmax * sizeof(struct snapraid_block)); + 387 24709 : file = malloc_nofail(sizeof(struct snapraid_file)); + 388 24709 : file->sub = strdup_nofail(copy->sub); + 389 24709 : file->size = copy->size; + 390 24709 : file->blockmax = copy->blockmax; + 391 24709 : file->mtime_sec = copy->mtime_sec; + 392 24709 : file->mtime_nsec = copy->mtime_nsec; + 393 24709 : file->inode = copy->inode; + 394 24709 : file->physical = copy->physical; + 395 24709 : file->flag = copy->flag; + 396 24709 : file->blockvec = malloc_nofail(file->blockmax * sizeof(struct snapraid_block)); 397 : - 398 81385 : for (i = 0; i < file->blockmax; ++i) { - 399 56678 : file->blockvec[i].state = copy->blockvec[i].state; - 400 56678 : memcpy(file->blockvec[i].hash, copy->blockvec[i].hash, HASH_SIZE); + 398 81407 : for (i = 0; i < file->blockmax; ++i) { + 399 56698 : file->blockvec[i].state = copy->blockvec[i].state; + 400 56698 : memcpy(file->blockvec[i].hash, copy->blockvec[i].hash, HASH_SIZE); 401 : } 402 : - 403 24707 : return file; + 403 24709 : return file; 404 : } 405 : - 406 3466242 : void file_free(struct snapraid_file* file) + 406 3466869 : void file_free(struct snapraid_file* file) 407 : { - 408 3466242 : free(file->sub); - 409 3466242 : file->sub = 0; - 410 3466242 : free(file->blockvec); - 411 3466242 : file->blockvec = 0; - 412 3466242 : free(file); - 413 3466242 : } + 408 3466869 : free(file->sub); + 409 3466869 : file->sub = 0; + 410 3466869 : free(file->blockvec); + 411 3466869 : file->blockvec = 0; + 412 3466869 : free(file); + 413 3466869 : } 414 : 415 155 : void file_rename(struct snapraid_file* file, const char* sub) 416 : { @@ -480,94 +480,94 @@ 418 155 : file->sub = strdup_nofail(sub); 419 155 : } 420 : - 421 23633 : void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file) + 421 23636 : void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file) 422 : { 423 : block_off_t i; 424 : - 425 23633 : if (src_file->size != dst_file->size) { + 425 23636 : if (src_file->size != dst_file->size) { 426 : /* LCOV_EXCL_START */ 427 : log_fatal("Internal inconsistency in copy file with different size\n"); 428 : os_abort(); 429 : /* LCOV_EXCL_STOP */ 430 : } 431 : - 432 23633 : if (src_file->mtime_sec != dst_file->mtime_sec) { + 432 23636 : if (src_file->mtime_sec != dst_file->mtime_sec) { 433 : /* LCOV_EXCL_START */ 434 : log_fatal("Internal inconsistency in copy file with different mtime_sec\n"); 435 : os_abort(); 436 : /* LCOV_EXCL_STOP */ 437 : } 438 : - 439 23633 : if (src_file->mtime_nsec != dst_file->mtime_nsec) { + 439 23636 : if (src_file->mtime_nsec != dst_file->mtime_nsec) { 440 : /* LCOV_EXCL_START */ 441 : log_fatal("Internal inconsistency in copy file with different mtime_nsec\n"); 442 : os_abort(); 443 : /* LCOV_EXCL_STOP */ 444 : } 445 : - 446 81852 : for (i = 0; i < dst_file->blockmax; ++i) { + 446 81879 : for (i = 0; i < dst_file->blockmax; ++i) { 447 : /* set a block with hash computed but without parity */ - 448 58219 : block_state_set(&dst_file->blockvec[i], BLOCK_STATE_REP); + 448 58243 : block_state_set(&dst_file->blockvec[i], BLOCK_STATE_REP); 449 : 450 : /* copy the hash */ - 451 58219 : memcpy(dst_file->blockvec[i].hash, src_file->blockvec[i].hash, HASH_SIZE); + 451 58243 : memcpy(dst_file->blockvec[i].hash, src_file->blockvec[i].hash, HASH_SIZE); 452 : } 453 : - 454 23633 : file_flag_set(dst_file, FILE_IS_COPY); - 455 23633 : } + 454 23636 : file_flag_set(dst_file, FILE_IS_COPY); + 455 23636 : } 456 : - 457 47994 : const char* file_name(const struct snapraid_file* file) + 457 48014 : const char* file_name(const struct snapraid_file* file) 458 : { - 459 47994 : const char* r = strrchr(file->sub, '/'); + 459 48014 : const char* r = strrchr(file->sub, '/'); 460 : - 461 47994 : if (!r) - 462 60 : r = file->sub; + 461 48014 : if (!r) + 462 78 : r = file->sub; 463 : else - 464 47934 : ++r; - 465 47994 : return r; + 464 47936 : ++r; + 465 48014 : return r; 466 : } 467 : - 468 6677441 : unsigned file_block_size(struct snapraid_file* file, block_off_t file_pos, unsigned block_size) + 468 6680330 : unsigned file_block_size(struct snapraid_file* file, block_off_t file_pos, unsigned block_size) 469 : { 470 : /* if it's the last block */ - 471 6677441 : if (file_pos + 1 == file->blockmax) { + 471 6680330 : if (file_pos + 1 == file->blockmax) { 472 : unsigned block_remainder; - 473 2717238 : if (file->size == 0) + 473 2717718 : if (file->size == 0) 474 0 : return 0; - 475 2717238 : block_remainder = file->size % block_size; - 476 2717238 : if (block_remainder == 0) - 477 2543 : block_remainder = block_size; - 478 2717238 : return block_remainder; + 475 2717718 : block_remainder = file->size % block_size; + 476 2717718 : if (block_remainder == 0) + 477 2959 : block_remainder = block_size; + 478 2717718 : return block_remainder; 479 : } 480 : - 481 3960203 : return block_size; + 481 3962612 : return block_size; 482 : } 483 : - 484 5326414 : int file_block_is_last(struct snapraid_file* file, block_off_t file_pos) + 484 5329166 : int file_block_is_last(struct snapraid_file* file, block_off_t file_pos) 485 : { - 486 5326414 : if (file_pos == 0 && file->blockmax == 0) + 486 5329166 : if (file_pos == 0 && file->blockmax == 0) 487 0 : return 1; 488 : - 489 5326414 : if (file_pos >= file->blockmax) { + 489 5329166 : if (file_pos >= file->blockmax) { 490 : /* LCOV_EXCL_START */ 491 : log_fatal("Internal inconsistency in file block position\n"); 492 : os_abort(); 493 : /* LCOV_EXCL_STOP */ 494 : } 495 : - 496 5326414 : return file_pos == file->blockmax - 1; + 496 5329166 : return file_pos == file->blockmax - 1; 497 : } 498 : - 499 927047 : int file_inode_compare_to_arg(const void* void_arg, const void* void_data) + 499 927285 : int file_inode_compare_to_arg(const void* void_arg, const void* void_data) 500 : { - 501 927047 : const uint64_t* arg = void_arg; - 502 927047 : const struct snapraid_file* file = void_data; + 501 927285 : const uint64_t* arg = void_arg; + 502 927285 : const struct snapraid_file* file = void_data; 503 : - 504 927047 : if (*arg < file->inode) + 504 927285 : if (*arg < file->inode) 505 0 : return -1; - 506 927047 : if (*arg > file->inode) + 506 927285 : if (*arg > file->inode) 507 0 : return 1; - 508 927047 : return 0; + 508 927285 : return 0; 509 : } 510 : 511 0 : int file_inode_compare(const void* void_a, const void* void_b) @@ -582,76 +582,76 @@ 520 0 : return 0; 521 : } 522 : - 523 129121 : int file_path_compare(const void* void_a, const void* void_b) + 523 129157 : int file_path_compare(const void* void_a, const void* void_b) 524 : { - 525 129121 : const struct snapraid_file* file_a = void_a; - 526 129121 : const struct snapraid_file* file_b = void_b; + 525 129157 : const struct snapraid_file* file_a = void_a; + 526 129157 : const struct snapraid_file* file_b = void_b; 527 : - 528 129121 : return strcmp(file_a->sub, file_b->sub); + 528 129157 : return strcmp(file_a->sub, file_b->sub); 529 : } 530 : - 531 49676 : int file_physical_compare(const void* void_a, const void* void_b) + 531 59718 : int file_physical_compare(const void* void_a, const void* void_b) 532 : { - 533 49676 : const struct snapraid_file* file_a = void_a; - 534 49676 : const struct snapraid_file* file_b = void_b; + 533 59718 : const struct snapraid_file* file_a = void_a; + 534 59718 : const struct snapraid_file* file_b = void_b; 535 : - 536 49676 : if (file_a->physical < file_b->physical) - 537 34678 : return -1; - 538 14998 : if (file_a->physical > file_b->physical) - 539 14996 : return 1; + 536 59718 : if (file_a->physical < file_b->physical) + 537 37856 : return -1; + 538 21862 : if (file_a->physical > file_b->physical) + 539 21860 : return 1; 540 2 : return 0; 541 : } 542 : - 543 104908 : int file_path_compare_to_arg(const void* void_arg, const void* void_data) + 543 103230 : int file_path_compare_to_arg(const void* void_arg, const void* void_data) 544 : { - 545 104908 : const char* arg = void_arg; - 546 104908 : const struct snapraid_file* file = void_data; + 545 103230 : const char* arg = void_arg; + 546 103230 : const struct snapraid_file* file = void_data; 547 : - 548 104908 : return strcmp(arg, file->sub); + 548 103230 : return strcmp(arg, file->sub); 549 : } 550 : - 551 23997 : int file_name_compare(const void* void_a, const void* void_b) + 551 24007 : int file_name_compare(const void* void_a, const void* void_b) 552 : { - 553 23997 : const struct snapraid_file* file_a = void_a; - 554 23997 : const struct snapraid_file* file_b = void_b; - 555 23997 : const char* name_a = file_name(file_a); - 556 23997 : const char* name_b = file_name(file_b); + 553 24007 : const struct snapraid_file* file_a = void_a; + 554 24007 : const struct snapraid_file* file_b = void_b; + 555 24007 : const char* name_a = file_name(file_a); + 556 24007 : const char* name_b = file_name(file_b); 557 : - 558 23997 : return strcmp(name_a, name_b); + 558 24007 : return strcmp(name_a, name_b); 559 : } 560 : - 561 23661 : int file_stamp_compare(const void* void_a, const void* void_b) + 561 23670 : int file_stamp_compare(const void* void_a, const void* void_b) 562 : { - 563 23661 : const struct snapraid_file* file_a = void_a; - 564 23661 : const struct snapraid_file* file_b = void_b; + 563 23670 : const struct snapraid_file* file_a = void_a; + 564 23670 : const struct snapraid_file* file_b = void_b; 565 : - 566 23661 : if (file_a->size < file_b->size) + 566 23670 : if (file_a->size < file_b->size) 567 0 : return -1; - 568 23661 : if (file_a->size > file_b->size) + 568 23670 : if (file_a->size > file_b->size) 569 0 : return 1; 570 : - 571 23661 : if (file_a->mtime_sec < file_b->mtime_sec) + 571 23670 : if (file_a->mtime_sec < file_b->mtime_sec) 572 0 : return -1; - 573 23661 : if (file_a->mtime_sec > file_b->mtime_sec) + 573 23670 : if (file_a->mtime_sec > file_b->mtime_sec) 574 0 : return 1; 575 : - 576 23661 : if (file_a->mtime_nsec < file_b->mtime_nsec) + 576 23670 : if (file_a->mtime_nsec < file_b->mtime_nsec) 577 0 : return -1; - 578 23661 : if (file_a->mtime_nsec > file_b->mtime_nsec) + 578 23670 : if (file_a->mtime_nsec > file_b->mtime_nsec) 579 0 : return 1; 580 : - 581 23661 : return 0; + 581 23670 : return 0; 582 : } 583 : - 584 23997 : int file_namestamp_compare(const void* void_a, const void* void_b) + 584 24007 : int file_namestamp_compare(const void* void_a, const void* void_b) 585 : { 586 : int ret; 587 : - 588 23997 : ret = file_name_compare(void_a, void_b); - 589 23997 : if (ret != 0) - 590 336 : return ret; + 588 24007 : ret = file_name_compare(void_a, void_b); + 589 24007 : if (ret != 0) + 590 337 : return ret; 591 : - 592 23661 : return file_stamp_compare(void_a, void_b); + 592 23670 : return file_stamp_compare(void_a, void_b); 593 : } 594 : 595 0 : int file_pathstamp_compare(const void* void_a, const void* void_b) @@ -665,66 +665,66 @@ 603 0 : return file_stamp_compare(void_a, void_b); 604 : } 605 : - 606 3657427 : struct snapraid_chunk* chunk_alloc(block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos, block_off_t count) + 606 3658037 : struct snapraid_chunk* chunk_alloc(block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos, block_off_t count) 607 : { 608 : struct snapraid_chunk* chunk; 609 : - 610 3657427 : if (count == 0) { + 610 3658037 : if (count == 0) { 611 : /* LCOV_EXCL_START */ 612 : log_fatal("Internal inconsistency when allocating empty chunk for file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax); 613 : os_abort(); 614 : /* LCOV_EXCL_STOP */ 615 : } - 616 3657427 : if (file_pos + count > file->blockmax) { + 616 3658037 : if (file_pos + count > file->blockmax) { 617 : /* LCOV_EXCL_START */ 618 : log_fatal("Internal inconsistency when allocating overflowing chunk for file '%s' at position '%u:%u/%u'\n", file->sub, file_pos, count, file->blockmax); 619 : os_abort(); 620 : /* LCOV_EXCL_STOP */ 621 : } 622 : - 623 3657427 : chunk = malloc_nofail(sizeof(struct snapraid_chunk)); - 624 3657427 : chunk->parity_pos = parity_pos; - 625 3657427 : chunk->file = file; - 626 3657427 : chunk->file_pos = file_pos; - 627 3657427 : chunk->count = count; + 623 3658037 : chunk = malloc_nofail(sizeof(struct snapraid_chunk)); + 624 3658037 : chunk->parity_pos = parity_pos; + 625 3658037 : chunk->file = file; + 626 3658037 : chunk->file_pos = file_pos; + 627 3658037 : chunk->count = count; 628 : - 629 3657427 : return chunk; + 629 3658037 : return chunk; 630 : } 631 : - 632 3486903 : void chunk_free(struct snapraid_chunk* chunk) + 632 3487501 : void chunk_free(struct snapraid_chunk* chunk) 633 : { - 634 3486903 : free(chunk); - 635 3486903 : } + 634 3487501 : free(chunk); + 635 3487501 : } 636 : - 637 43351652 : int chunk_parity_compare(const void* void_a, const void* void_b) + 637 43323431 : int chunk_parity_compare(const void* void_a, const void* void_b) 638 : { - 639 43351652 : const struct snapraid_chunk* arg_a = void_a; - 640 43351652 : const struct snapraid_chunk* arg_b = void_b; + 639 43323431 : const struct snapraid_chunk* arg_a = void_a; + 640 43323431 : const struct snapraid_chunk* arg_b = void_b; 641 : - 642 43351652 : if (arg_a->parity_pos < arg_b->parity_pos) - 643 2220745 : return -1; - 644 41130907 : if (arg_a->parity_pos > arg_b->parity_pos) - 645 41089282 : return 1; + 642 43323431 : if (arg_a->parity_pos < arg_b->parity_pos) + 643 2215613 : return -1; + 644 41107818 : if (arg_a->parity_pos > arg_b->parity_pos) + 645 41066186 : return 1; 646 : - 647 41625 : return 0; + 647 41632 : return 0; 648 : } 649 : - 650 44153325 : int chunk_file_compare(const void* void_a, const void* void_b) + 650 44162450 : int chunk_file_compare(const void* void_a, const void* void_b) 651 : { - 652 44153325 : const struct snapraid_chunk* arg_a = void_a; - 653 44153325 : const struct snapraid_chunk* arg_b = void_b; + 652 44162450 : const struct snapraid_chunk* arg_a = void_a; + 653 44162450 : const struct snapraid_chunk* arg_b = void_b; 654 : - 655 44153325 : if (arg_a->file < arg_b->file) - 656 875219 : return -1; - 657 43278106 : if (arg_a->file > arg_b->file) - 658 43205895 : return 1; + 655 44162450 : if (arg_a->file < arg_b->file) + 656 877820 : return -1; + 657 43284630 : if (arg_a->file > arg_b->file) + 658 43212428 : return 1; 659 : - 660 72211 : if (arg_a->file_pos < arg_b->file_pos) - 661 194 : return -1; - 662 72017 : if (arg_a->file_pos > arg_b->file_pos) - 663 30392 : return 1; + 660 72202 : if (arg_a->file_pos < arg_b->file_pos) + 661 208 : return -1; + 662 71994 : if (arg_a->file_pos > arg_b->file_pos) + 663 30362 : return 1; 664 : - 665 41625 : return 0; + 665 41632 : return 0; 666 : } 667 : 668 116876 : struct snapraid_link* link_alloc(const char* sub, const char* linkto, unsigned link_flag) @@ -787,61 +787,61 @@ 725 229 : return strcmp(arg, dir->sub); 726 : } 727 : - 728 1525 : struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev, const char* uuid, int skip) + 728 1537 : struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev, const char* uuid, int skip) 729 : { 730 : struct snapraid_disk* disk; 731 : - 732 1525 : disk = malloc_nofail(sizeof(struct snapraid_disk)); - 733 1525 : pathcpy(disk->name, sizeof(disk->name), name); - 734 1525 : pathimport(disk->dir, sizeof(disk->dir), dir); - 735 1525 : pathcpy(disk->uuid, sizeof(disk->uuid), uuid); + 732 1537 : disk = malloc_nofail(sizeof(struct snapraid_disk)); + 733 1537 : pathcpy(disk->name, sizeof(disk->name), name); + 734 1537 : pathimport(disk->dir, sizeof(disk->dir), dir); + 735 1537 : pathcpy(disk->uuid, sizeof(disk->uuid), uuid); 736 : 737 : /* ensure that the dir terminate with "/" if it isn't empty */ - 738 1525 : pathslash(disk->dir, sizeof(disk->dir)); + 738 1537 : pathslash(disk->dir, sizeof(disk->dir)); 739 : - 740 1525 : disk->smartctl[0] = 0; - 741 1525 : disk->device = dev; - 742 1525 : disk->tick = 0; - 743 1525 : disk->total_blocks = 0; - 744 1525 : disk->free_blocks = 0; - 745 1525 : disk->first_free_block = 0; - 746 1525 : disk->has_volatile_inodes = 0; - 747 1525 : disk->has_unreliable_physical = 0; - 748 1525 : disk->has_different_uuid = 0; - 749 1525 : disk->has_unsupported_uuid = *uuid == 0; /* empty UUID means unsupported */ - 750 1525 : disk->had_empty_uuid = 0; - 751 1525 : disk->mapping_idx = -1; - 752 1525 : disk->skip_access = skip; - 753 1525 : tommy_list_init(&disk->filelist); - 754 1525 : tommy_list_init(&disk->deletedlist); - 755 1525 : tommy_hashdyn_init(&disk->inodeset); - 756 1525 : tommy_hashdyn_init(&disk->pathset); - 757 1525 : tommy_hashdyn_init(&disk->stampset); - 758 1525 : tommy_list_init(&disk->linklist); - 759 1525 : tommy_hashdyn_init(&disk->linkset); - 760 1525 : tommy_list_init(&disk->dirlist); - 761 1525 : tommy_hashdyn_init(&disk->dirset); - 762 1525 : tommy_tree_init(&disk->fs_parity, chunk_parity_compare); - 763 1525 : tommy_tree_init(&disk->fs_file, chunk_file_compare); - 764 1525 : disk->fs_last = 0; + 740 1537 : disk->smartctl[0] = 0; + 741 1537 : disk->device = dev; + 742 1537 : disk->tick = 0; + 743 1537 : disk->total_blocks = 0; + 744 1537 : disk->free_blocks = 0; + 745 1537 : disk->first_free_block = 0; + 746 1537 : disk->has_volatile_inodes = 0; + 747 1537 : disk->has_unreliable_physical = 0; + 748 1537 : disk->has_different_uuid = 0; + 749 1537 : disk->has_unsupported_uuid = *uuid == 0; /* empty UUID means unsupported */ + 750 1537 : disk->had_empty_uuid = 0; + 751 1537 : disk->mapping_idx = -1; + 752 1537 : disk->skip_access = skip; + 753 1537 : tommy_list_init(&disk->filelist); + 754 1537 : tommy_list_init(&disk->deletedlist); + 755 1537 : tommy_hashdyn_init(&disk->inodeset); + 756 1537 : tommy_hashdyn_init(&disk->pathset); + 757 1537 : tommy_hashdyn_init(&disk->stampset); + 758 1537 : tommy_list_init(&disk->linklist); + 759 1537 : tommy_hashdyn_init(&disk->linkset); + 760 1537 : tommy_list_init(&disk->dirlist); + 761 1537 : tommy_hashdyn_init(&disk->dirset); + 762 1537 : tommy_tree_init(&disk->fs_parity, chunk_parity_compare); + 763 1537 : tommy_tree_init(&disk->fs_file, chunk_file_compare); + 764 1537 : disk->fs_last = 0; 765 : - 766 1525 : return disk; + 766 1537 : return disk; 767 : } 768 : - 769 1399 : void disk_free(struct snapraid_disk* disk) + 769 1411 : void disk_free(struct snapraid_disk* disk) 770 : { - 771 1399 : tommy_list_foreach(&disk->filelist, (tommy_foreach_func*)file_free); - 772 1399 : tommy_list_foreach(&disk->deletedlist, (tommy_foreach_func*)file_free); - 773 1399 : tommy_tree_foreach(&disk->fs_file, (tommy_foreach_func*)chunk_free); - 774 1399 : tommy_hashdyn_done(&disk->inodeset); - 775 1399 : tommy_hashdyn_done(&disk->pathset); - 776 1399 : tommy_hashdyn_done(&disk->stampset); - 777 1399 : tommy_list_foreach(&disk->linklist, (tommy_foreach_func*)link_free); - 778 1399 : tommy_hashdyn_done(&disk->linkset); - 779 1399 : tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free); - 780 1399 : tommy_hashdyn_done(&disk->dirset); - 781 1399 : free(disk); - 782 1399 : } + 771 1411 : tommy_list_foreach(&disk->filelist, (tommy_foreach_func*)file_free); + 772 1411 : tommy_list_foreach(&disk->deletedlist, (tommy_foreach_func*)file_free); + 773 1411 : tommy_tree_foreach(&disk->fs_file, (tommy_foreach_func*)chunk_free); + 774 1411 : tommy_hashdyn_done(&disk->inodeset); + 775 1411 : tommy_hashdyn_done(&disk->pathset); + 776 1411 : tommy_hashdyn_done(&disk->stampset); + 777 1411 : tommy_list_foreach(&disk->linklist, (tommy_foreach_func*)link_free); + 778 1411 : tommy_hashdyn_done(&disk->linkset); + 779 1411 : tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free); + 780 1411 : tommy_hashdyn_done(&disk->dirset); + 781 1411 : free(disk); + 782 1411 : } 783 : 784 : struct chunk_disk_empty { 785 : block_off_t blockmax; @@ -850,38 +850,38 @@ 788 : /** 789 : * Compare the chunk if inside the specified blockmax. 790 : */ - 791 13 : static int chunk_disk_empty_compare(const void* void_a, const void* void_b) + 791 12 : static int chunk_disk_empty_compare(const void* void_a, const void* void_b) 792 : { - 793 13 : const struct chunk_disk_empty* arg_a = void_a; - 794 13 : const struct snapraid_chunk* arg_b = void_b; + 793 12 : const struct chunk_disk_empty* arg_a = void_a; + 794 12 : const struct snapraid_chunk* arg_b = void_b; 795 : 796 : /* if the block is inside the specified blockmax, it's found */ - 797 13 : if (arg_a->blockmax > arg_b->parity_pos) - 798 8 : return 0; + 797 12 : if (arg_a->blockmax > arg_b->parity_pos) + 798 7 : return 0; 799 : 800 : /* otherwise search for a smaller one */ 801 5 : return -1; 802 : } 803 : - 804 870 : int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax) + 804 888 : int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax) 805 : { - 806 870 : struct chunk_disk_empty arg = { blockmax }; + 806 888 : struct chunk_disk_empty arg = { blockmax }; 807 : 808 : /* if there is an element, it's not empty */ 809 : /* even if links and dirs have no block allocation */ - 810 870 : if (!tommy_list_empty(&disk->filelist)) - 811 778 : return 0; - 812 92 : if (!tommy_list_empty(&disk->linklist)) + 810 888 : if (!tommy_list_empty(&disk->filelist)) + 811 789 : return 0; + 812 99 : if (!tommy_list_empty(&disk->linklist)) 813 0 : return 0; - 814 92 : if (!tommy_list_empty(&disk->dirlist)) + 814 99 : if (!tommy_list_empty(&disk->dirlist)) 815 0 : return 0; 816 : 817 : /* search for any chunk inside blockmax */ - 818 92 : if (tommy_tree_search_compare(&disk->fs_parity, chunk_disk_empty_compare, &arg) != 0) - 819 8 : return 0; + 818 99 : if (tommy_tree_search_compare(&disk->fs_parity, chunk_disk_empty_compare, &arg) != 0) + 819 7 : return 0; 820 : 821 : /* finally, it's empty */ - 822 84 : return 1; + 822 92 : return 1; 823 : } 824 : 825 : struct chunk_disk_size { @@ -893,24 +893,24 @@ 831 : * 832 : * The maximum parity position is stored as size. 833 : */ - 834 48702 : static int chunk_disk_size_compare(const void* void_a, const void* void_b) + 834 48684 : static int chunk_disk_size_compare(const void* void_a, const void* void_b) 835 : { - 836 48702 : struct chunk_disk_size* arg_a = (void*)void_a; - 837 48702 : const struct snapraid_chunk* arg_b = void_b; + 836 48684 : struct chunk_disk_size* arg_a = (void*)void_a; + 837 48684 : const struct snapraid_chunk* arg_b = void_b; 838 : 839 : /* get the maximum size */ - 840 48702 : if (arg_a->size < arg_b->parity_pos + arg_b->count) - 841 48702 : arg_a->size = arg_b->parity_pos + arg_b->count; + 840 48684 : if (arg_a->size < arg_b->parity_pos + arg_b->count) + 841 48684 : arg_a->size = arg_b->parity_pos + arg_b->count; 842 : 843 : /* search always for a bigger one */ - 844 48702 : return 1; + 844 48684 : return 1; 845 : } 846 : - 847 4165 : block_off_t disk_size(struct snapraid_disk* disk) + 847 4219 : block_off_t disk_size(struct snapraid_disk* disk) 848 : { - 849 4165 : struct chunk_disk_size arg = { 0 }; - 850 4165 : tommy_tree_search_compare(&disk->fs_parity, chunk_disk_size_compare, &arg); - 851 4165 : return arg.size; + 849 4219 : struct chunk_disk_size arg = { 0 }; + 850 4219 : tommy_tree_search_compare(&disk->fs_parity, chunk_disk_size_compare, &arg); + 851 4219 : return arg.size; 852 : } 853 : 854 : struct chunk_check { @@ -918,23 +918,23 @@ 856 : int result; 857 : }; 858 : - 859 6441048 : void chunk_parity_check_foreach(void* void_arg, void* void_obj) + 859 6425469 : void chunk_parity_check_foreach(void* void_arg, void* void_obj) 860 : { - 861 6441048 : struct chunk_check* arg = void_arg; - 862 6441048 : const struct snapraid_chunk* obj = void_obj; - 863 6441048 : const struct snapraid_chunk* prev = arg->prev; + 861 6425469 : struct chunk_check* arg = void_arg; + 862 6425469 : const struct snapraid_chunk* obj = void_obj; + 863 6425469 : const struct snapraid_chunk* prev = arg->prev; 864 : 865 : /* set the next previous block */ - 866 6441048 : arg->prev = obj; + 866 6425469 : arg->prev = obj; 867 : 868 : /* stop reporting if too many errors */ - 869 6441048 : if (arg->result > 100) { + 869 6425469 : if (arg->result > 100) { 870 : /* LCOV_EXCL_START */ 871 : return; 872 : /* LCOV_EXCL_STOP */ 873 : } 874 : - 875 6441048 : if (obj->count == 0) { + 875 6425469 : if (obj->count == 0) { 876 : /* LCOV_EXCL_START */ 877 : log_fatal("Internal inconsistency in parity count zero for file '%s' at '%u'\n", 878 : obj->file->sub, obj->parity_pos); @@ -944,11 +944,11 @@ 882 : } 883 : 884 : /* check only if there is a previous block */ - 885 6441048 : if (!prev) - 886 2588 : return; + 885 6425469 : if (!prev) + 886 2618 : return; 887 : 888 : /* check the order */ - 889 6438460 : if (prev->parity_pos >= obj->parity_pos) { + 889 6422851 : if (prev->parity_pos >= obj->parity_pos) { 890 : /* LCOV_EXCL_START */ 891 : log_fatal("Internal inconsistency in parity order for files '%s' at '%u:%u' and '%s' at '%u:%u'\n", 892 : prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count); @@ -958,7 +958,7 @@ 896 : } 897 : 898 : /* check that the chunks don't overlap */ - 899 6438460 : if (prev->parity_pos + prev->count > obj->parity_pos) { + 899 6422851 : if (prev->parity_pos + prev->count > obj->parity_pos) { 900 : /* LCOV_EXCL_START */ 901 : log_fatal("Internal inconsistency for parity overlap for files '%s' at '%u:%u' and '%s' at '%u:%u'\n", 902 : prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count); @@ -968,23 +968,23 @@ 906 : } 907 : } 908 : - 909 6441048 : void chunk_file_check_foreach(void* void_arg, void* void_obj) + 909 6425469 : void chunk_file_check_foreach(void* void_arg, void* void_obj) 910 : { - 911 6441048 : struct chunk_check* arg = void_arg; - 912 6441048 : const struct snapraid_chunk* obj = void_obj; - 913 6441048 : const struct snapraid_chunk* prev = arg->prev; + 911 6425469 : struct chunk_check* arg = void_arg; + 912 6425469 : const struct snapraid_chunk* obj = void_obj; + 913 6425469 : const struct snapraid_chunk* prev = arg->prev; 914 : 915 : /* set the next previous block */ - 916 6441048 : arg->prev = obj; + 916 6425469 : arg->prev = obj; 917 : 918 : /* stop reporting if too many errors */ - 919 6441048 : if (arg->result > 100) { + 919 6425469 : if (arg->result > 100) { 920 : /* LCOV_EXCL_START */ 921 : return; 922 : /* LCOV_EXCL_STOP */ 923 : } 924 : - 925 6441048 : if (obj->count == 0) { + 925 6425469 : if (obj->count == 0) { 926 : /* LCOV_EXCL_START */ 927 : log_fatal("Internal inconsistency in file count zero for file '%s' at '%u'\n", 928 : obj->file->sub, obj->file_pos); @@ -996,11 +996,11 @@ 934 : /* note that for deleted files, some chunks may be missing */ 935 : 936 : /* if the files are different */ - 937 6441048 : if (!prev || prev->file != obj->file) { - 938 6395699 : if (prev != 0) { - 939 6393111 : if (file_flag_has(prev->file, FILE_IS_DELETED)) { + 937 6425469 : if (!prev || prev->file != obj->file) { + 938 6380270 : if (prev != 0) { + 939 6377652 : if (file_flag_has(prev->file, FILE_IS_DELETED)) { 940 : /* check that the chunk doesn't overflow the file */ - 941 59771 : if (prev->file_pos + prev->count > prev->file->blockmax) { + 941 59765 : if (prev->file_pos + prev->count > prev->file->blockmax) { 942 : /* LCOV_EXCL_START */ 943 : log_fatal("Internal inconsistency in delete end for file '%s' at '%u:%u' overflowing size '%u'\n", 944 : prev->file->sub, prev->file_pos, prev->count, prev->file->blockmax); @@ -1010,7 +1010,7 @@ 948 : } 949 : } else { 950 : /* check that the chunk ends the file */ - 951 6333340 : if (prev->file_pos + prev->count != prev->file->blockmax) { + 951 6317887 : if (prev->file_pos + prev->count != prev->file->blockmax) { 952 : /* LCOV_EXCL_START */ 953 : log_fatal("Internal inconsistency in file end for file '%s' at '%u:%u' instead of size '%u'\n", 954 : prev->file->sub, prev->file_pos, prev->count, prev->file->blockmax); @@ -1021,9 +1021,9 @@ 959 : } 960 : } 961 : - 962 12791398 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { + 962 12760540 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { 963 : /* check that the chunk doesn't overflow the file */ - 964 59854 : if (obj->file_pos + obj->count > obj->file->blockmax) { + 964 59848 : if (obj->file_pos + obj->count > obj->file->blockmax) { 965 : /* LCOV_EXCL_START */ 966 : log_fatal("Internal inconsistency in delete start for file '%s' at '%u:%u' overflowing size '%u'\n", 967 : obj->file->sub, obj->file_pos, obj->count, obj->file->blockmax); @@ -1033,7 +1033,7 @@ 971 : } 972 : } else { 973 : /* check that the chunk starts the file */ - 974 6335845 : if (obj->file_pos != 0) { + 974 6320422 : if (obj->file_pos != 0) { 975 : /* LCOV_EXCL_START */ 976 : log_fatal("Internal inconsistency in file start for file '%s' at '%u:%u'\n", 977 : obj->file->sub, obj->file_pos, obj->count); @@ -1044,7 +1044,7 @@ 982 : } 983 : } else { 984 : /* check the order */ - 985 45349 : if (prev->file_pos >= obj->file_pos) { + 985 45199 : if (prev->file_pos >= obj->file_pos) { 986 : /* LCOV_EXCL_START */ 987 : log_fatal("Internal inconsistency in file order for file '%s' at '%u:%u' and at '%u:%u'\n", 988 : prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count); @@ -1053,7 +1053,7 @@ 991 : /* LCOV_EXCL_STOP */ 992 : } 993 : - 994 45349 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { + 994 45199 : if (file_flag_has(obj->file, FILE_IS_DELETED)) { 995 : /* check that the chunks don't overlap */ 996 27 : if (prev->file_pos + prev->count > obj->file_pos) { 997 : /* LCOV_EXCL_START */ @@ -1065,7 +1065,7 @@ 1003 : } 1004 : } else { 1005 : /* check that the chunks are sequential */ - 1006 45322 : if (prev->file_pos + prev->count != obj->file_pos) { + 1006 45172 : if (prev->file_pos + prev->count != obj->file_pos) { 1007 : /* LCOV_EXCL_START */ 1008 : log_fatal("Internal inconsistency in file sequence for file '%s' at '%u:%u' and at '%u:%u'\n", 1009 : prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count); @@ -1077,25 +1077,25 @@ 1015 : } 1016 : } 1017 : - 1018 2838 : int fs_check(struct snapraid_disk* disk) + 1018 2880 : int fs_check(struct snapraid_disk* disk) 1019 : { 1020 : struct chunk_check arg; 1021 : 1022 : /* error count starts from 0 */ - 1023 2838 : arg.result = 0; + 1023 2880 : arg.result = 0; 1024 : 1025 : /* check parity sequence */ - 1026 2838 : arg.prev = 0; - 1027 2838 : tommy_tree_foreach_arg(&disk->fs_parity, chunk_parity_check_foreach, &arg); + 1026 2880 : arg.prev = 0; + 1027 2880 : tommy_tree_foreach_arg(&disk->fs_parity, chunk_parity_check_foreach, &arg); 1028 : 1029 : /* check file sequence */ - 1030 2838 : arg.prev = 0; - 1031 2838 : tommy_tree_foreach_arg(&disk->fs_file, chunk_file_check_foreach, &arg); + 1030 2880 : arg.prev = 0; + 1031 2880 : tommy_tree_foreach_arg(&disk->fs_file, chunk_file_check_foreach, &arg); 1032 : - 1033 2838 : if (arg.result != 0) + 1033 2880 : if (arg.result != 0) 1034 0 : return -1; 1035 : - 1036 2838 : return 0; + 1036 2880 : return 0; 1037 : } 1038 : 1039 : struct chunk_parity_inside { @@ -1105,17 +1105,17 @@ 1043 : /** 1044 : * Compare the chunk if containing the specified parity position. 1045 : */ - 1046 102351431 : static int chunk_parity_inside_compare(const void* void_a, const void* void_b) + 1046 102361796 : static int chunk_parity_inside_compare(const void* void_a, const void* void_b) 1047 : { - 1048 102351431 : const struct chunk_parity_inside* arg_a = void_a; - 1049 102351431 : const struct snapraid_chunk* arg_b = void_b; + 1048 102361796 : const struct chunk_parity_inside* arg_a = void_a; + 1049 102361796 : const struct snapraid_chunk* arg_b = void_b; 1050 : - 1051 102351431 : if (arg_a->parity_pos < arg_b->parity_pos) - 1052 35386523 : return -1; - 1053 66964908 : if (arg_a->parity_pos >= arg_b->parity_pos + arg_b->count) - 1054 59326333 : return 1; + 1051 102361796 : if (arg_a->parity_pos < arg_b->parity_pos) + 1052 35326122 : return -1; + 1053 67035674 : if (arg_a->parity_pos >= arg_b->parity_pos + arg_b->count) + 1054 59415030 : return 1; 1055 : - 1056 7638575 : return 0; + 1056 7620644 : return 0; 1057 : } 1058 : 1059 : /** @@ -1123,28 +1123,28 @@ 1061 : * The search is optimized for sequential accesses. 1062 : * \return If not found return 0 1063 : */ - 1064 38418652 : static struct snapraid_chunk* fs_par2chunk_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos) + 1064 38412957 : static struct snapraid_chunk* fs_par2chunk_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos) 1065 : { 1066 : struct snapraid_chunk* chunk; 1067 : 1068 : /* check if the last accessed chunk matches */ - 1069 38418652 : if (*fs_last - 1070 38399475 : && parity_pos >= (*fs_last)->parity_pos - 1071 38241144 : && parity_pos < (*fs_last)->parity_pos + (*fs_last)->count + 1069 38412957 : if (*fs_last + 1070 38393928 : && parity_pos >= (*fs_last)->parity_pos + 1071 38235652 : && parity_pos < (*fs_last)->parity_pos + (*fs_last)->count 1072 : ) { - 1073 29222600 : chunk = *fs_last; + 1073 29215970 : chunk = *fs_last; 1074 : } else { - 1075 9196052 : struct chunk_parity_inside arg = { parity_pos }; - 1076 9196052 : chunk = tommy_tree_search_compare(&disk->fs_parity, chunk_parity_inside_compare, &arg); + 1075 9196987 : struct chunk_parity_inside arg = { parity_pos }; + 1076 9196987 : chunk = tommy_tree_search_compare(&disk->fs_parity, chunk_parity_inside_compare, &arg); 1077 : } 1078 : - 1079 38418652 : if (!chunk) - 1080 1557477 : return 0; + 1079 38412957 : if (!chunk) + 1080 1576343 : return 0; 1081 : 1082 : /* store the last accessed chunk */ - 1083 36861175 : *fs_last = chunk; + 1083 36836614 : *fs_last = chunk; 1084 : - 1085 36861175 : return chunk; + 1085 36836614 : return chunk; 1086 : } 1087 : 1088 : struct chunk_file_inside { @@ -1155,22 +1155,22 @@ 1093 : /** 1094 : * Compare the chunk if containing the specified file position. 1095 : */ - 1096 21495373 : static int chunk_file_inside_compare(const void* void_a, const void* void_b) + 1096 21328815 : static int chunk_file_inside_compare(const void* void_a, const void* void_b) 1097 : { - 1098 21495373 : const struct chunk_file_inside* arg_a = void_a; - 1099 21495373 : const struct snapraid_chunk* arg_b = void_b; + 1098 21328815 : const struct chunk_file_inside* arg_a = void_a; + 1099 21328815 : const struct snapraid_chunk* arg_b = void_b; 1100 : - 1101 21495373 : if (arg_a->file < arg_b->file) - 1102 8992026 : return -1; - 1103 12503347 : if (arg_a->file > arg_b->file) - 1104 10470075 : return 1; + 1101 21328815 : if (arg_a->file < arg_b->file) + 1102 8915963 : return -1; + 1103 12412852 : if (arg_a->file > arg_b->file) + 1104 10396177 : return 1; 1105 : - 1106 2033272 : if (arg_a->file_pos < arg_b->file_pos) - 1107 7395 : return -1; - 1108 2025877 : if (arg_a->file_pos >= arg_b->file_pos + arg_b->count) - 1109 9044 : return 1; + 1106 2016675 : if (arg_a->file_pos < arg_b->file_pos) + 1107 8204 : return -1; + 1108 2008471 : if (arg_a->file_pos >= arg_b->file_pos + arg_b->count) + 1109 7996 : return 1; 1110 : - 1111 2016833 : return 0; + 1111 2000475 : return 0; 1112 : } 1113 : 1114 : /** @@ -1178,228 +1178,224 @@ 1116 : * The search is optimized for sequential accesses. 1117 : * \return If not found return 0 1118 : */ - 1119 10223247 : static struct snapraid_chunk* fs_file2chunk_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos) + 1119 10190236 : static struct snapraid_chunk* fs_file2chunk_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos) 1120 : { 1121 : struct snapraid_chunk* chunk; 1122 : 1123 : /* check if the last accessed chunk matches */ - 1124 10223247 : if (*fs_last - 1125 10199301 : && file == (*fs_last)->file - 1126 8220750 : && file_pos >= (*fs_last)->file_pos - 1127 8220750 : && file_pos < (*fs_last)->file_pos + (*fs_last)->count + 1124 10190236 : if (*fs_last + 1125 10166262 : && file == (*fs_last)->file + 1126 8203962 : && file_pos >= (*fs_last)->file_pos + 1127 8203962 : && file_pos < (*fs_last)->file_pos + (*fs_last)->count 1128 : ) { - 1129 8206414 : chunk = *fs_last; + 1129 8189753 : chunk = *fs_last; 1130 : } else { - 1131 2016833 : struct chunk_file_inside arg = { file, file_pos }; - 1132 2016833 : chunk = tommy_tree_search_compare(&disk->fs_file, chunk_file_inside_compare, &arg); + 1131 2000483 : struct chunk_file_inside arg = { file, file_pos }; + 1132 2000483 : chunk = tommy_tree_search_compare(&disk->fs_file, chunk_file_inside_compare, &arg); 1133 : } 1134 : - 1135 10223247 : if (!chunk) - 1136 0 : return 0; + 1135 10190236 : if (!chunk) + 1136 8 : return 0; 1137 : 1138 : /* store the last accessed chunk */ - 1139 10223247 : *fs_last = chunk; + 1139 10190228 : *fs_last = chunk; 1140 : - 1141 10223247 : return chunk; + 1141 10190228 : return chunk; 1142 : } 1143 : - 1144 38311850 : struct snapraid_file* fs_par2file_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos, block_off_t* file_pos) + 1144 38306069 : struct snapraid_file* fs_par2file_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos, block_off_t* file_pos) 1145 : { 1146 : struct snapraid_chunk* chunk; 1147 : - 1148 38311850 : chunk = fs_par2chunk_get_ts(disk, fs_last, parity_pos); - 1149 38311850 : if (!chunk) - 1150 1557477 : return 0; + 1148 38306069 : chunk = fs_par2chunk_get_ts(disk, fs_last, parity_pos); + 1149 38306069 : if (!chunk) + 1150 1576343 : return 0; 1151 : - 1152 36754373 : if (file_pos) - 1153 36410379 : *file_pos = chunk->file_pos + (parity_pos - chunk->parity_pos); + 1152 36729726 : if (file_pos) + 1153 36385398 : *file_pos = chunk->file_pos + (parity_pos - chunk->parity_pos); 1154 : - 1155 36754373 : return chunk->file; + 1155 36729726 : return chunk->file; 1156 : } 1157 : - 1158 4878725 : block_off_t fs_file2par_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos) + 1158 4840928 : block_off_t fs_file2par_maybe_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos) 1159 : { 1160 : struct snapraid_chunk* chunk; 1161 : - 1162 4878725 : chunk = fs_file2chunk_get_ts(disk, fs_last, file, file_pos); - 1163 4878725 : if (!chunk) { - 1164 : /* LCOV_EXCL_START */ - 1165 : log_fatal("Internal inconsistency when resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name); - 1166 : os_abort(); - 1167 : /* LCOV_EXCL_STOP */ - 1168 : } - 1169 : - 1170 4878725 : return chunk->parity_pos + (file_pos - chunk->file_pos); - 1171 : } - 1172 : - 1173 8975787 : void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos) - 1174 : { - 1175 : struct snapraid_chunk* chunk; - 1176 : struct snapraid_chunk* parity_chunk; - 1177 : struct snapraid_chunk* file_chunk; + 1162 4840928 : chunk = fs_file2chunk_get_ts(disk, fs_last, file, file_pos); + 1163 4840928 : if (!chunk) + 1164 8 : return POS_INVALID; + 1165 : + 1166 4840920 : return chunk->parity_pos + (file_pos - chunk->file_pos); + 1167 : } + 1168 : + 1169 8981211 : void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snapraid_file* file, block_off_t file_pos) + 1170 : { + 1171 : struct snapraid_chunk* chunk; + 1172 : struct snapraid_chunk* parity_chunk; + 1173 : struct snapraid_chunk* file_chunk; + 1174 : + 1175 8981211 : if (file_pos > 0) { + 1176 : /* search an existing chunk for the previous file_pos */ + 1177 5349308 : chunk = fs_file2chunk_get_ts(disk, &disk->fs_last, file, file_pos - 1); 1178 : - 1179 8975787 : if (file_pos > 0) { - 1180 : /* search an existing chunk for the previous file_pos */ - 1181 5344522 : chunk = fs_file2chunk_get_ts(disk, &disk->fs_last, file, file_pos - 1); - 1182 : - 1183 5344522 : if (chunk != 0 && parity_pos == chunk->parity_pos + chunk->count) { - 1184 : /* ensure that we are extending the chunk at the end */ - 1185 5318361 : if (file_pos != chunk->file_pos + chunk->count) { - 1186 : /* LCOV_EXCL_START */ - 1187 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' in the middle of chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name); - 1188 : os_abort(); - 1189 : /* LCOV_EXCL_STOP */ - 1190 : } - 1191 : - 1192 : /* extend the existing chunk */ - 1193 5318361 : ++chunk->count; + 1179 5349308 : if (chunk != 0 && parity_pos == chunk->parity_pos + chunk->count) { + 1180 : /* ensure that we are extending the chunk at the end */ + 1181 5323175 : if (file_pos != chunk->file_pos + chunk->count) { + 1182 : /* LCOV_EXCL_START */ + 1183 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' in the middle of chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name); + 1184 : os_abort(); + 1185 : /* LCOV_EXCL_STOP */ + 1186 : } + 1187 : + 1188 : /* extend the existing chunk */ + 1189 5323175 : ++chunk->count; + 1190 : + 1191 14304386 : return; + 1192 : } + 1193 : } 1194 : - 1195 14294148 : return; - 1196 : } - 1197 : } - 1198 : - 1199 : /* a chunk doesn't exist, and we have to create a new one */ - 1200 3657426 : chunk = chunk_alloc(parity_pos, file, file_pos, 1); + 1195 : /* a chunk doesn't exist, and we have to create a new one */ + 1196 3658036 : chunk = chunk_alloc(parity_pos, file, file_pos, 1); + 1197 : + 1198 : /* insert the chunk in the trees */ + 1199 3658036 : parity_chunk = tommy_tree_insert(&disk->fs_parity, &chunk->parity_node, chunk); + 1200 3658036 : file_chunk = tommy_tree_insert(&disk->fs_file, &chunk->file_node, chunk); 1201 : - 1202 : /* insert the chunk in the trees */ - 1203 3657426 : parity_chunk = tommy_tree_insert(&disk->fs_parity, &chunk->parity_node, chunk); - 1204 3657426 : file_chunk = tommy_tree_insert(&disk->fs_file, &chunk->file_node, chunk); - 1205 : - 1206 3657426 : if (parity_chunk != chunk || file_chunk != chunk) { - 1207 : /* LCOV_EXCL_START */ - 1208 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' for existing chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name); - 1209 : os_abort(); - 1210 : /* LCOV_EXCL_STOP */ - 1211 : } + 1202 3658036 : if (parity_chunk != chunk || file_chunk != chunk) { + 1203 : /* LCOV_EXCL_START */ + 1204 : log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' for existing chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name); + 1205 : os_abort(); + 1206 : /* LCOV_EXCL_STOP */ + 1207 : } + 1208 : + 1209 : /* store the last accessed chunk */ + 1210 3658036 : disk->fs_last = chunk; + 1211 : } 1212 : - 1213 : /* store the last accessed chunk */ - 1214 3657426 : disk->fs_last = chunk; - 1215 : } - 1216 : - 1217 106802 : void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos) - 1218 : { - 1219 : struct snapraid_chunk* chunk; - 1220 : struct snapraid_chunk* second_chunk; - 1221 : struct snapraid_chunk* parity_chunk; - 1222 : struct snapraid_chunk* file_chunk; - 1223 : block_off_t first_count, second_count; - 1224 : - 1225 106802 : chunk = fs_par2chunk_get_ts(disk, &disk->fs_last, parity_pos); - 1226 106802 : if (!chunk) { - 1227 : /* LCOV_EXCL_START */ - 1228 : log_fatal("Internal inconsistency when deallocating parity position '%u' for not existing chunk in disk '%s'\n", parity_pos, disk->name); - 1229 : os_abort(); - 1230 : /* LCOV_EXCL_STOP */ - 1231 : } - 1232 : - 1233 : /* if it's the only block of the chunk, delete it */ - 1234 106802 : if (chunk->count == 1) { - 1235 : /* remove from the trees */ - 1236 41625 : tommy_tree_remove(&disk->fs_parity, chunk); - 1237 41625 : tommy_tree_remove(&disk->fs_file, chunk); - 1238 : - 1239 : /* deallocate */ - 1240 41625 : chunk_free(chunk); - 1241 : - 1242 : /* clear the last accessed chunk */ - 1243 41625 : disk->fs_last = 0; - 1244 41625 : return; - 1245 : } - 1246 : - 1247 : /* if it's at the start of the chunk, shrink the chunk */ - 1248 65177 : if (parity_pos == chunk->parity_pos) { - 1249 65175 : ++chunk->parity_pos; - 1250 65175 : ++chunk->file_pos; - 1251 65175 : --chunk->count; - 1252 65175 : return; - 1253 : } - 1254 : - 1255 : /* if it's at the end of the chunk, shrink the chunk */ - 1256 2 : if (parity_pos == chunk->parity_pos + chunk->count - 1) { - 1257 1 : --chunk->count; - 1258 1 : return; - 1259 : } + 1213 106888 : void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos) + 1214 : { + 1215 : struct snapraid_chunk* chunk; + 1216 : struct snapraid_chunk* second_chunk; + 1217 : struct snapraid_chunk* parity_chunk; + 1218 : struct snapraid_chunk* file_chunk; + 1219 : block_off_t first_count, second_count; + 1220 : + 1221 106888 : chunk = fs_par2chunk_get_ts(disk, &disk->fs_last, parity_pos); + 1222 106888 : if (!chunk) { + 1223 : /* LCOV_EXCL_START */ + 1224 : log_fatal("Internal inconsistency when deallocating parity position '%u' for not existing chunk in disk '%s'\n", parity_pos, disk->name); + 1225 : os_abort(); + 1226 : /* LCOV_EXCL_STOP */ + 1227 : } + 1228 : + 1229 : /* if it's the only block of the chunk, delete it */ + 1230 106888 : if (chunk->count == 1) { + 1231 : /* remove from the trees */ + 1232 41632 : tommy_tree_remove(&disk->fs_parity, chunk); + 1233 41632 : tommy_tree_remove(&disk->fs_file, chunk); + 1234 : + 1235 : /* deallocate */ + 1236 41632 : chunk_free(chunk); + 1237 : + 1238 : /* clear the last accessed chunk */ + 1239 41632 : disk->fs_last = 0; + 1240 41632 : return; + 1241 : } + 1242 : + 1243 : /* if it's at the start of the chunk, shrink the chunk */ + 1244 65256 : if (parity_pos == chunk->parity_pos) { + 1245 65254 : ++chunk->parity_pos; + 1246 65254 : ++chunk->file_pos; + 1247 65254 : --chunk->count; + 1248 65254 : return; + 1249 : } + 1250 : + 1251 : /* if it's at the end of the chunk, shrink the chunk */ + 1252 2 : if (parity_pos == chunk->parity_pos + chunk->count - 1) { + 1253 1 : --chunk->count; + 1254 1 : return; + 1255 : } + 1256 : + 1257 : /* otherwise it's in the middle */ + 1258 1 : first_count = parity_pos - chunk->parity_pos; + 1259 1 : second_count = chunk->count - first_count - 1; 1260 : - 1261 : /* otherwise it's in the middle */ - 1262 1 : first_count = parity_pos - chunk->parity_pos; - 1263 1 : second_count = chunk->count - first_count - 1; - 1264 : - 1265 : /* adjust the first chunk */ - 1266 1 : chunk->count = first_count; - 1267 : - 1268 : /* allocate the second chunk */ - 1269 1 : second_chunk = chunk_alloc(chunk->parity_pos + first_count + 1, chunk->file, chunk->file_pos + first_count + 1, second_count); + 1261 : /* adjust the first chunk */ + 1262 1 : chunk->count = first_count; + 1263 : + 1264 : /* allocate the second chunk */ + 1265 1 : second_chunk = chunk_alloc(chunk->parity_pos + first_count + 1, chunk->file, chunk->file_pos + first_count + 1, second_count); + 1266 : + 1267 : /* insert the chunk in the trees */ + 1268 1 : parity_chunk = tommy_tree_insert(&disk->fs_parity, &second_chunk->parity_node, second_chunk); + 1269 1 : file_chunk = tommy_tree_insert(&disk->fs_file, &second_chunk->file_node, second_chunk); 1270 : - 1271 : /* insert the chunk in the trees */ - 1272 1 : parity_chunk = tommy_tree_insert(&disk->fs_parity, &second_chunk->parity_node, second_chunk); - 1273 1 : file_chunk = tommy_tree_insert(&disk->fs_file, &second_chunk->file_node, second_chunk); - 1274 : - 1275 1 : if (parity_chunk != second_chunk || file_chunk != second_chunk) { - 1276 : /* LCOV_EXCL_START */ - 1277 : log_fatal("Internal inconsistency when deallocating parity position '%u' for splitting chunk '%u:%u' in disk '%s'\n", parity_pos, second_chunk->file_pos, second_chunk->count, disk->name); - 1278 : os_abort(); - 1279 : /* LCOV_EXCL_STOP */ - 1280 : } + 1271 1 : if (parity_chunk != second_chunk || file_chunk != second_chunk) { + 1272 : /* LCOV_EXCL_START */ + 1273 : log_fatal("Internal inconsistency when deallocating parity position '%u' for splitting chunk '%u:%u' in disk '%s'\n", parity_pos, second_chunk->file_pos, second_chunk->count, disk->name); + 1274 : os_abort(); + 1275 : /* LCOV_EXCL_STOP */ + 1276 : } + 1277 : + 1278 : /* store the last accessed chunk */ + 1279 1 : disk->fs_last = second_chunk; + 1280 : } 1281 : - 1282 : /* store the last accessed chunk */ - 1283 1 : disk->fs_last = second_chunk; - 1284 : } - 1285 : - 1286 44106216 : struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos) - 1287 : { - 1288 44106216 : if (file_pos >= file->blockmax) { - 1289 : /* LCOV_EXCL_START */ - 1290 : log_fatal("Internal inconsistency when dereferencing file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax); - 1291 : os_abort(); - 1292 : /* LCOV_EXCL_STOP */ - 1293 : } - 1294 : - 1295 44106216 : return &file->blockvec[file_pos]; - 1296 : } - 1297 : - 1298 26733115 : struct snapraid_block* fs_par2block_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos) - 1299 : { - 1300 : struct snapraid_file* file; - 1301 : block_off_t file_pos; - 1302 : - 1303 26733115 : file = fs_par2file_get_ts(disk, fs_last, parity_pos, &file_pos); - 1304 : - 1305 26733115 : if (!file) - 1306 1557477 : return BLOCK_EMPTY; - 1307 : - 1308 25175638 : return fs_file2block_get(file, file_pos); - 1309 : } + 1282 44005284 : struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos) + 1283 : { + 1284 44005284 : if (file_pos >= file->blockmax) { + 1285 : /* LCOV_EXCL_START */ + 1286 : log_fatal("Internal inconsistency when dereferencing file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax); + 1287 : os_abort(); + 1288 : /* LCOV_EXCL_STOP */ + 1289 : } + 1290 : + 1291 44005284 : return &file->blockvec[file_pos]; + 1292 : } + 1293 : + 1294 26721446 : struct snapraid_block* fs_par2block_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos) + 1295 : { + 1296 : struct snapraid_file* file; + 1297 : block_off_t file_pos; + 1298 : + 1299 26721446 : file = fs_par2file_get_ts(disk, fs_last, parity_pos, &file_pos); + 1300 : + 1301 26721446 : if (!file) + 1302 1576343 : return BLOCK_EMPTY; + 1303 : + 1304 25145103 : return fs_file2block_get(file, file_pos); + 1305 : } + 1306 : + 1307 1507 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid) + 1308 : { + 1309 : struct snapraid_map* map; 1310 : - 1311 1495 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid) - 1312 : { - 1313 : struct snapraid_map* map; - 1314 : - 1315 1495 : map = malloc_nofail(sizeof(struct snapraid_map)); - 1316 1495 : pathcpy(map->name, sizeof(map->name), name); - 1317 1495 : map->position = position; - 1318 1495 : map->total_blocks = total_blocks; - 1319 1495 : map->free_blocks = free_blocks; - 1320 1495 : pathcpy(map->uuid, sizeof(map->uuid), uuid); - 1321 : - 1322 1495 : return map; - 1323 : } - 1324 : - 1325 1375 : void map_free(struct snapraid_map* map) - 1326 : { - 1327 1375 : free(map); - 1328 1375 : } - 1329 : - 1330 707506 : int time_compare(const void* void_a, const void* void_b) - 1331 : { - 1332 707506 : const time_t* time_a = void_a; - 1333 707506 : const time_t* time_b = void_b; - 1334 : - 1335 707506 : if (*time_a < *time_b) - 1336 26871 : return -1; - 1337 680635 : if (*time_a > *time_b) - 1338 146878 : return 1; - 1339 533757 : return 0; - 1340 : } + 1311 1507 : map = malloc_nofail(sizeof(struct snapraid_map)); + 1312 1507 : pathcpy(map->name, sizeof(map->name), name); + 1313 1507 : map->position = position; + 1314 1507 : map->total_blocks = total_blocks; + 1315 1507 : map->free_blocks = free_blocks; + 1316 1507 : pathcpy(map->uuid, sizeof(map->uuid), uuid); + 1317 : + 1318 1507 : return map; + 1319 : } + 1320 : + 1321 1387 : void map_free(struct snapraid_map* map) + 1322 : { + 1323 1387 : free(map); + 1324 1387 : } + 1325 : + 1326 717256 : int time_compare(const void* void_a, const void* void_b) + 1327 : { + 1328 717256 : const time_t* time_a = void_a; + 1329 717256 : const time_t* time_b = void_b; + 1330 : + 1331 717256 : if (*time_a < *time_b) + 1332 27900 : return -1; + 1333 689356 : if (*time_a > *time_b) + 1334 156362 : return 1; + 1335 532994 : return 0; + 1336 : } diff --git a/cov/cmdline/elem.h.func-sort-c.html b/cov/cmdline/elem.h.func-sort-c.html index 8bc953ab..06022e9a 100644 --- a/cov/cmdline/elem.h.func-sort-c.html +++ b/cov/cmdline/elem.h.func-sort-c.html @@ -31,17 +31,17 @@ lcov.info Lines: - 115 - 116 - 99.1 % + 121 + 122 + 99.2 % Date: - 2016-01-09 + 2016-01-16 Functions: - 39 - 39 + 41 + 41 100.0 % @@ -61,127 +61,135 @@ block_state_get - 49967196 + 49924589 file_flag_has - 33706389 + 33676848 - fs_par2block_get - 22209416 + fs_par2block_get + 22233152 block_state_set - 18633161 + 18644176 block_has_file - 13243669 + 13254717 block_has_invalid_parity - 11837218 + 11847406 fs_par2file_get - 11578735 + 11584623 hash_invalid_set - 9036734 + 9042162 file_stamp_hash - 6198269 + 6199048 file_flag_set - 5250833 + 5249321 - info_get - 5104110 + info_get + 5095494 file_inode_hash - 4924816 + 4923043 + + + fs_file2par_get_ts + 4698533 file_path_hash - 3815727 + 3814698 filter_hidden - 3114300 + 3114995 block_has_past_hash - 2401624 + 2403226 block_has_updated_hash - 2075259 + 2074724 - info_get_rehash - 2058338 + info_get_rehash + 2053300 - info_set - 1639782 + info_set + 1641726 - info_get_time - 890086 + info_get_time + 884150 hash_is_zero - 761026 + 760550 hash_is_invalid - 759605 + 759088 - fs_file2par_get - 519510 + fs_file2par_get + 377489 - info_get_bad - 338860 + info_get_bad + 339090 block_has_file_and_valid_parity - 257893 + 257940 link_flag_has - 205548 + 205549 - info_make - 174394 + info_make + 174544 link_name_hash 151170 + + fs_file2par_maybe + 142395 + hash_zero_set - 115487 + 115543 link_flag_get - 89637 + 89093 - info_get_justsynced - 79285 + info_get_justsynced + 79114 hash_is_real - 44133 + 44212 link_flag_set @@ -189,15 +197,15 @@ file_flag_clear - 20621 + 19577 - info_set_rehash - 9207 + info_set_rehash + 9215 - info_set_bad - 1771 + info_set_bad + 1772 dir_name_hash diff --git a/cov/cmdline/elem.h.func.html b/cov/cmdline/elem.h.func.html index d9c2ba6e..6421231b 100644 --- a/cov/cmdline/elem.h.func.html +++ b/cov/cmdline/elem.h.func.html @@ -31,17 +31,17 @@ lcov.info Lines: - 115 - 116 - 99.1 % + 121 + 122 + 99.2 % Date: - 2016-01-09 + 2016-01-16 Functions: - 39 - 39 + 41 + 41 100.0 % @@ -61,31 +61,31 @@ block_has_file - 13243669 + 13254717 block_has_file_and_valid_parity - 257893 + 257940 block_has_invalid_parity - 11837218 + 11847406 block_has_past_hash - 2401624 + 2403226 block_has_updated_hash - 2075259 + 2074724 block_state_get - 49967196 + 49924589 block_state_set - 18633161 + 18644176 dir_flag_has @@ -101,107 +101,115 @@ file_flag_clear - 20621 + 19577 file_flag_has - 33706389 + 33676848 file_flag_set - 5250833 + 5249321 file_inode_hash - 4924816 + 4923043 file_path_hash - 3815727 + 3814698 file_stamp_hash - 6198269 + 6199048 filter_hidden - 3114300 + 3114995 - fs_file2par_get - 519510 + fs_file2par_get + 377489 - fs_par2block_get - 22209416 + fs_file2par_get_ts + 4698533 + + + fs_file2par_maybe + 142395 + + + fs_par2block_get + 22233152 fs_par2file_get - 11578735 + 11584623 hash_invalid_set - 9036734 + 9042162 hash_is_invalid - 759605 + 759088 hash_is_real - 44133 + 44212 hash_is_zero - 761026 + 760550 hash_zero_set - 115487 + 115543 - info_get - 5104110 + info_get + 5095494 - info_get_bad - 338860 + info_get_bad + 339090 - info_get_justsynced - 79285 + info_get_justsynced + 79114 - info_get_rehash - 2058338 + info_get_rehash + 2053300 - info_get_time - 890086 + info_get_time + 884150 - info_make - 174394 + info_make + 174544 - info_set - 1639782 + info_set + 1641726 - info_set_bad - 1771 + info_set_bad + 1772 - info_set_rehash - 9207 + info_set_rehash + 9215 link_flag_get - 89637 + 89093 link_flag_has - 205548 + 205549 link_flag_let diff --git a/cov/cmdline/elem.h.gcov.html b/cov/cmdline/elem.h.gcov.html index e99f6062..e948922c 100644 --- a/cov/cmdline/elem.h.gcov.html +++ b/cov/cmdline/elem.h.gcov.html @@ -31,17 +31,17 @@ lcov.info Lines: - 115 - 116 - 99.1 % + 121 + 122 + 99.2 % Date: - 2016-01-09 + 2016-01-16 Functions: - 39 - 39 + 41 + 41 100.0 % @@ -519,13 +519,13 @@ 457 : * Filter hidden files. 458 : * Return !=0 if it matches and it should be excluded. 459 : */ - 460 3114300 : static inline int filter_hidden(int enable, struct dirent* dd) + 460 3114995 : static inline int filter_hidden(int enable, struct dirent* dd) 461 : { - 462 3114300 : if (enable && dirent_hidden(dd)) { + 462 3114995 : if (enable && dirent_hidden(dd)) { 463 0 : return 1; /* filter out */ 464 : } 465 : - 466 3114300 : return 0; + 466 3114995 : return 0; 467 : } 468 : 469 : /** @@ -566,15 +566,15 @@ 504 : * 505 : * An invalid hash is represented with all bytes at 0x00. 506 : */ - 507 759605 : static inline int hash_is_invalid(const unsigned char* hash) + 507 759088 : static inline int hash_is_invalid(const unsigned char* hash) 508 : { 509 : unsigned i; 510 : - 511 1179159 : for (i = 0; i < HASH_SIZE; ++i) - 512 1153105 : if (hash[i] != 0x00) - 513 733551 : return 0; + 511 1178874 : for (i = 0; i < HASH_SIZE; ++i) + 512 1152810 : if (hash[i] != 0x00) + 513 733024 : return 0; 514 : - 515 26054 : return 1; + 515 26064 : return 1; 516 : } 517 : 518 : /** @@ -582,40 +582,40 @@ 520 : * 521 : * A zero hash is represented with all bytes at 0xFF. 522 : */ - 523 761026 : static inline int hash_is_zero(const unsigned char* hash) + 523 760550 : static inline int hash_is_zero(const unsigned char* hash) 524 : { 525 : unsigned i; 526 : - 527 994627 : for (i = 0; i < HASH_SIZE; ++i) - 528 980198 : if (hash[i] != 0xFF) - 529 746597 : return 0; + 527 994989 : for (i = 0; i < HASH_SIZE; ++i) + 528 980520 : if (hash[i] != 0xFF) + 529 746081 : return 0; 530 : - 531 14429 : return 1; + 531 14469 : return 1; 532 : } 533 : 534 : /** 535 : * Check if the specified hash is a real hash. 536 : */ - 537 44133 : static inline int hash_is_real(const unsigned char* hash) + 537 44212 : static inline int hash_is_real(const unsigned char* hash) 538 : { - 539 44133 : return !hash_is_zero(hash) && !hash_is_invalid(hash); + 539 44212 : return !hash_is_zero(hash) && !hash_is_invalid(hash); 540 : } 541 : 542 : /** 543 : * Set the hash to the special INVALID value. 544 : */ - 545 9036734 : static inline void hash_invalid_set(unsigned char* hash) + 545 9042162 : static inline void hash_invalid_set(unsigned char* hash) 546 : { - 547 9036734 : memset(hash, 0x00, HASH_SIZE); - 548 9036734 : } + 547 9042162 : memset(hash, 0x00, HASH_SIZE); + 548 9042162 : } 549 : 550 : /** 551 : * Set the hash to the special ZERO value. 552 : */ - 553 115487 : static inline void hash_zero_set(unsigned char* hash) + 553 115543 : static inline void hash_zero_set(unsigned char* hash) 554 : { - 555 115487 : memset(hash, 0xFF, HASH_SIZE); - 556 115487 : } + 555 115543 : memset(hash, 0xFF, HASH_SIZE); + 556 115543 : } 557 : 558 : /** 559 : * Get the state of the block. @@ -623,32 +623,32 @@ 561 : * For this function, it's allowed to pass a NULL block 562 : * pointer than results in the BLOCK_STATE_EMPTY state. 563 : */ - 564 49967196 : static inline unsigned block_state_get(const struct snapraid_block* block) + 564 49924589 : static inline unsigned block_state_get(const struct snapraid_block* block) 565 : { - 566 49967196 : if (block == BLOCK_EMPTY) - 567 1604566 : return BLOCK_STATE_EMPTY; + 566 49924589 : if (block == BLOCK_EMPTY) + 567 1624550 : return BLOCK_STATE_EMPTY; 568 : - 569 48362630 : return block->state; + 569 48300039 : return block->state; 570 : } 571 : 572 : /** 573 : * Set the state of the block. 574 : */ - 575 18633161 : static inline void block_state_set(struct snapraid_block* block, unsigned state) + 575 18644176 : static inline void block_state_set(struct snapraid_block* block, unsigned state) 576 : { - 577 18633161 : block->state = state; - 578 18633161 : } + 577 18644176 : block->state = state; + 578 18644176 : } 579 : 580 : /** 581 : * Check if the specified block has an updated hash. 582 : * 583 : * Note that EMPTY / CHG / DELETED return 0. 584 : */ - 585 2075259 : static inline int block_has_updated_hash(const struct snapraid_block* block) + 585 2074724 : static inline int block_has_updated_hash(const struct snapraid_block* block) 586 : { - 587 2075259 : unsigned state = block_state_get(block); + 587 2074724 : unsigned state = block_state_get(block); 588 : - 589 2075259 : return state == BLOCK_STATE_BLK || state == BLOCK_STATE_REP; + 589 2074724 : return state == BLOCK_STATE_BLK || state == BLOCK_STATE_REP; 590 : } 591 : 592 : /** @@ -657,11 +657,11 @@ 595 : * 596 : * Note that EMPTY / BLK / REP return 0. 597 : */ - 598 2401624 : static inline int block_has_past_hash(const struct snapraid_block* block) + 598 2403226 : static inline int block_has_past_hash(const struct snapraid_block* block) 599 : { - 600 2401624 : unsigned state = block_state_get(block); + 600 2403226 : unsigned state = block_state_get(block); 601 : - 602 2401624 : return state == BLOCK_STATE_CHG || state == BLOCK_STATE_DELETED; + 602 2403226 : return state == BLOCK_STATE_CHG || state == BLOCK_STATE_DELETED; 603 : } 604 : 605 : /** @@ -669,12 +669,12 @@ 607 : * 608 : * Note that EMPTY / DELETED return 0. 609 : */ - 610 13243669 : static inline int block_has_file(const struct snapraid_block* block) + 610 13254717 : static inline int block_has_file(const struct snapraid_block* block) 611 : { - 612 13243669 : unsigned state = block_state_get(block); + 612 13254717 : unsigned state = block_state_get(block); 613 : - 614 13243669 : return state == BLOCK_STATE_BLK - 615 13243669 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; + 614 13254717 : return state == BLOCK_STATE_BLK + 615 13254717 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; 616 : } 617 : 618 : /** @@ -682,12 +682,12 @@ 620 : * 621 : * Note that EMPTY / BLK return 0. 622 : */ - 623 11837218 : static inline int block_has_invalid_parity(const struct snapraid_block* block) + 623 11847406 : static inline int block_has_invalid_parity(const struct snapraid_block* block) 624 : { - 625 11837218 : unsigned state = block_state_get(block); + 625 11847406 : unsigned state = block_state_get(block); 626 : - 627 11837218 : return state == BLOCK_STATE_DELETED - 628 11837218 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; + 627 11847406 : return state == BLOCK_STATE_DELETED + 628 11847406 : || state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP; 629 : } 630 : 631 : /** @@ -695,27 +695,27 @@ 633 : * 634 : * Note that anything different than BLK return 0. 635 : */ - 636 257893 : static inline int block_has_file_and_valid_parity(const struct snapraid_block* block) + 636 257940 : static inline int block_has_file_and_valid_parity(const struct snapraid_block* block) 637 : { - 638 257893 : unsigned state = block_state_get(block); + 638 257940 : unsigned state = block_state_get(block); 639 : - 640 257893 : return state == BLOCK_STATE_BLK; + 640 257940 : return state == BLOCK_STATE_BLK; 641 : } 642 : - 643 33706389 : static inline int file_flag_has(const struct snapraid_file* file, unsigned mask) + 643 33676848 : static inline int file_flag_has(const struct snapraid_file* file, unsigned mask) 644 : { - 645 33706389 : return (file->flag & mask) == mask; + 645 33676848 : return (file->flag & mask) == mask; 646 : } 647 : - 648 5250833 : static inline void file_flag_set(struct snapraid_file* file, unsigned mask) + 648 5249321 : static inline void file_flag_set(struct snapraid_file* file, unsigned mask) 649 : { - 650 5250833 : file->flag |= mask; - 651 5250833 : } + 650 5249321 : file->flag |= mask; + 651 5249321 : } 652 : - 653 20621 : static inline void file_flag_clear(struct snapraid_file* file, unsigned mask) + 653 19577 : static inline void file_flag_clear(struct snapraid_file* file, unsigned mask) 654 : { - 655 20621 : file->flag &= ~mask; - 656 20621 : } + 655 19577 : file->flag &= ~mask; + 656 19577 : } 657 : 658 : /** 659 : * Allocate a file. @@ -781,9 +781,9 @@ 719 : /** 720 : * Compute the hash of a file inode. 721 : */ - 722 4924816 : static inline tommy_uint32_t file_inode_hash(uint64_t inode) + 722 4923043 : static inline tommy_uint32_t file_inode_hash(uint64_t inode) 723 : { - 724 4924816 : return (tommy_uint32_t)tommy_inthash_u64(inode); + 724 4923043 : return (tommy_uint32_t)tommy_inthash_u64(inode); 725 : } 726 : 727 : /** @@ -802,17 +802,17 @@ 740 : /** 741 : * Compute the hash of a file path. 742 : */ - 743 3815727 : static inline tommy_uint32_t file_path_hash(const char* sub) + 743 3814698 : static inline tommy_uint32_t file_path_hash(const char* sub) 744 : { - 745 3815727 : return tommy_hash_u32(0, sub, strlen(sub)); + 745 3814698 : return tommy_hash_u32(0, sub, strlen(sub)); 746 : } 747 : 748 : /** 749 : * Compute the hash of a file stamp. 750 : */ - 751 6198269 : static inline tommy_uint32_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec) + 751 6199048 : static inline tommy_uint32_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec) 752 : { - 753 6198269 : return tommy_inthash_u32((tommy_uint32_t)size ^ tommy_inthash_u32(mtime_sec ^ tommy_inthash_u32(mtime_nsec))); + 753 6199048 : return tommy_inthash_u32((tommy_uint32_t)size ^ tommy_inthash_u32(mtime_sec ^ tommy_inthash_u32(mtime_nsec))); 754 : } 755 : 756 : /** @@ -835,9 +835,9 @@ 773 : */ 774 : int chunk_file_compare(const void* void_a, const void* void_b); 775 : - 776 205548 : static inline int link_flag_has(const struct snapraid_link* slink, unsigned mask) + 776 205549 : static inline int link_flag_has(const struct snapraid_link* slink, unsigned mask) 777 : { - 778 205548 : return (slink->flag & mask) == mask; + 778 205549 : return (slink->flag & mask) == mask; 779 : } 780 : 781 37571 : static inline void link_flag_set(struct snapraid_link* slink, unsigned mask) @@ -856,9 +856,9 @@ 794 6 : slink->flag |= flag & mask; 795 6 : } 796 : - 797 89637 : static inline unsigned link_flag_get(struct snapraid_link* slink, unsigned mask) + 797 89093 : static inline unsigned link_flag_get(struct snapraid_link* slink, unsigned mask) 798 : { - 799 89637 : return slink->flag & mask; + 799 89093 : return slink->flag & mask; 800 : } 801 : 802 : /** @@ -991,162 +991,190 @@ 929 : * Return 0 if no file is using it. 930 : * \note This function is NOT thread-safe as it uses the the disk cache. 931 : */ - 932 11578735 : static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) + 932 11584623 : static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos) 933 : { - 934 11578735 : return fs_par2file_get_ts(disk, &disk->fs_last, parity_pos, file_pos); + 934 11584623 : return fs_par2file_get_ts(disk, &disk->fs_last, parity_pos, file_pos); 935 : } 936 : 937 : /** 938 : * Like fs_file2par_get() but thread-safe. 939 : */ - 940 : block_off_t fs_file2par_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos); + 940 : block_off_t fs_file2par_maybe_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos); 941 : 942 : /** 943 : * Get the parity position from the file position. - 944 : * \note This function is NOT thread-safe as it uses the the disk cache. - 945 : */ - 946 519510 : static inline block_off_t fs_file2par_get(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) - 947 : { - 948 519510 : return fs_file2par_get_ts(disk, &disk->fs_last, file, file_pos); - 949 : } - 950 : - 951 : /** - 952 : * Like fs_par2block_get() but thread-safe. - 953 : */ - 954 : struct snapraid_block* fs_par2block_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos); - 955 : - 956 : /** - 957 : * Get the block from the parity position. - 958 : * Return BLOCK_EMPTY==0 if the block is over the end of the disk or not used. - 959 : * \note This function is NOT thread-safe as it uses the the disk cache. - 960 : */ - 961 22209416 : static inline struct snapraid_block* fs_par2block_get(struct snapraid_disk* disk, block_off_t parity_pos) - 962 : { - 963 22209416 : return fs_par2block_get_ts(disk, &disk->fs_last, parity_pos); - 964 : } - 965 : - 966 : /** - 967 : * Allocate a disk mapping. - 968 : * Uses uuid="" if not available. - 969 : */ - 970 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid); - 971 : - 972 : /** - 973 : * Deallocate a disk mapping. - 974 : */ - 975 : void map_free(struct snapraid_map* map); - 976 : - 977 : /** - 978 : * Mask used to store additional information in the info bits. - 979 : * - 980 : * These bits reduce the granularity of the time in the memory representation. + 944 : * Return POS_INVALID if no parity is allocated. + 945 : * \note This function is NOT thread-safe as it uses the the disk cache. + 946 : */ + 947 142395 : static inline block_off_t fs_file2par_maybe(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) + 948 : { + 949 142395 : return fs_file2par_maybe_ts(disk, &disk->fs_last, file, file_pos); + 950 : } + 951 : + 952 : /** + 953 : * Like fs_file2par_get() but thread-safe. + 954 : */ + 955 4698533 : static inline block_off_t fs_file2par_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, struct snapraid_file* file, block_off_t file_pos) + 956 : { + 957 : block_off_t ret; + 958 : + 959 4698533 : ret = fs_file2par_maybe_ts(disk, fs_last, file, file_pos); + 960 4698533 : if (ret == POS_INVALID) { + 961 : /* LCOV_EXCL_START */ + 962 : log_fatal("Internal inconsistency when resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name); + 963 : os_abort(); + 964 : /* LCOV_EXCL_STOP */ + 965 : } + 966 : + 967 4698533 : return ret; + 968 : } + 969 : + 970 : /** + 971 : * Get the parity position from the file position. + 972 : * \note This function is NOT thread-safe as it uses the the disk cache. + 973 : */ + 974 377489 : static inline block_off_t fs_file2par_get(struct snapraid_disk* disk, struct snapraid_file* file, block_off_t file_pos) + 975 : { + 976 377489 : return fs_file2par_get_ts(disk, &disk->fs_last, file, file_pos); + 977 : } + 978 : + 979 : /** + 980 : * Like fs_par2block_get() but thread-safe. 981 : */ - 982 : #define INFO_MASK 0x7 + 982 : struct snapraid_block* fs_par2block_get_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t parity_pos); 983 : 984 : /** - 985 : * Make an info. - 986 : */ - 987 174394 : static inline snapraid_info info_make(time_t last_access, int error, int rehash, int justsynced) - 988 : { - 989 : /* clear the lowest bits as reserved for other information */ - 990 174394 : snapraid_info info = last_access & ~INFO_MASK; - 991 : - 992 174394 : if (error != 0) - 993 5365 : info |= 0x1; - 994 174394 : if (rehash != 0) - 995 14409 : info |= 0x2; - 996 174394 : if (justsynced != 0) - 997 122709 : info |= 0x4; - 998 174394 : return info; - 999 : } - 1000 : - 1001 : /** - 1002 : * Extract the time information. - 1003 : * This is the last time when the block was know to be correct. - 1004 : * The "scrubbed" info tells if the time is referreing at the latest sync or scrub. - 1005 : */ - 1006 890086 : static inline time_t info_get_time(snapraid_info info) - 1007 : { - 1008 890086 : return info & ~INFO_MASK; - 1009 : } - 1010 : - 1011 : /** - 1012 : * Extract the error information. - 1013 : * Report if the block address had some problem. + 985 : * Get the block from the parity position. + 986 : * Return BLOCK_EMPTY==0 if the block is over the end of the disk or not used. + 987 : * \note This function is NOT thread-safe as it uses the the disk cache. + 988 : */ + 989 22233152 : static inline struct snapraid_block* fs_par2block_get(struct snapraid_disk* disk, block_off_t parity_pos) + 990 : { + 991 22233152 : return fs_par2block_get_ts(disk, &disk->fs_last, parity_pos); + 992 : } + 993 : + 994 : /** + 995 : * Allocate a disk mapping. + 996 : * Uses uuid="" if not available. + 997 : */ + 998 : struct snapraid_map* map_alloc(const char* name, unsigned position, block_off_t total_blocks, block_off_t free_blocks, const char* uuid); + 999 : + 1000 : /** + 1001 : * Deallocate a disk mapping. + 1002 : */ + 1003 : void map_free(struct snapraid_map* map); + 1004 : + 1005 : /** + 1006 : * Mask used to store additional information in the info bits. + 1007 : * + 1008 : * These bits reduce the granularity of the time in the memory representation. + 1009 : */ + 1010 : #define INFO_MASK 0x7 + 1011 : + 1012 : /** + 1013 : * Make an info. 1014 : */ - 1015 338860 : static inline int info_get_bad(snapraid_info info) + 1015 174544 : static inline snapraid_info info_make(time_t last_access, int error, int rehash, int justsynced) 1016 : { - 1017 338860 : return (info & 0x1) != 0; - 1018 : } + 1017 : /* clear the lowest bits as reserved for other information */ + 1018 174544 : snapraid_info info = last_access & ~INFO_MASK; 1019 : - 1020 : /** - 1021 : * Extract the rehash information. - 1022 : * Report if the block address is using the old hash and needs to be rehashed. - 1023 : */ - 1024 2058338 : static inline int info_get_rehash(snapraid_info info) - 1025 : { - 1026 2058338 : return (info & 0x2) != 0; + 1020 174544 : if (error != 0) + 1021 5311 : info |= 0x1; + 1022 174544 : if (rehash != 0) + 1023 14426 : info |= 0x2; + 1024 174544 : if (justsynced != 0) + 1025 122837 : info |= 0x4; + 1026 174544 : return info; 1027 : } 1028 : 1029 : /** - 1030 : * Extract the scrubbed information. - 1031 : * Report if the block address was never scrubbed. - 1032 : */ - 1033 79285 : static inline int info_get_justsynced(snapraid_info info) - 1034 : { - 1035 79285 : return (info & 0x4) != 0; - 1036 : } - 1037 : - 1038 : /** - 1039 : * Mark the block address as with error. - 1040 : */ - 1041 1771 : static inline snapraid_info info_set_bad(snapraid_info info) - 1042 : { - 1043 1771 : return info | 0x1; - 1044 : } - 1045 : - 1046 : /** - 1047 : * Mark the block address as with rehash. - 1048 : */ - 1049 9207 : static inline snapraid_info info_set_rehash(snapraid_info info) - 1050 : { - 1051 9207 : return info | 0x2; - 1052 : } - 1053 : - 1054 : /** - 1055 : * Set the info at the specified position. - 1056 : * The position is allocated if not yet done. - 1057 : */ - 1058 1639782 : static inline void info_set(tommy_arrayblkof* array, unsigned pos, snapraid_info info) - 1059 : { - 1060 1639782 : tommy_arrayblkof_grow(array, pos + 1); - 1061 : - 1062 1639782 : memcpy(tommy_arrayblkof_ref(array, pos), &info, sizeof(snapraid_info)); - 1063 1639782 : } - 1064 : - 1065 : /** - 1066 : * Get the info at the specified position. - 1067 : * For not allocated position, 0 is returned. + 1030 : * Extract the time information. + 1031 : * This is the last time when the block was know to be correct. + 1032 : * The "scrubbed" info tells if the time is referreing at the latest sync or scrub. + 1033 : */ + 1034 884150 : static inline time_t info_get_time(snapraid_info info) + 1035 : { + 1036 884150 : return info & ~INFO_MASK; + 1037 : } + 1038 : + 1039 : /** + 1040 : * Extract the error information. + 1041 : * Report if the block address had some problem. + 1042 : */ + 1043 339090 : static inline int info_get_bad(snapraid_info info) + 1044 : { + 1045 339090 : return (info & 0x1) != 0; + 1046 : } + 1047 : + 1048 : /** + 1049 : * Extract the rehash information. + 1050 : * Report if the block address is using the old hash and needs to be rehashed. + 1051 : */ + 1052 2053300 : static inline int info_get_rehash(snapraid_info info) + 1053 : { + 1054 2053300 : return (info & 0x2) != 0; + 1055 : } + 1056 : + 1057 : /** + 1058 : * Extract the scrubbed information. + 1059 : * Report if the block address was never scrubbed. + 1060 : */ + 1061 79114 : static inline int info_get_justsynced(snapraid_info info) + 1062 : { + 1063 79114 : return (info & 0x4) != 0; + 1064 : } + 1065 : + 1066 : /** + 1067 : * Mark the block address as with error. 1068 : */ - 1069 5104110 : static inline snapraid_info info_get(tommy_arrayblkof* array, unsigned pos) + 1069 1772 : static inline snapraid_info info_set_bad(snapraid_info info) 1070 : { - 1071 : snapraid_info info; - 1072 : - 1073 5104110 : if (pos >= tommy_arrayblkof_size(array)) - 1074 262738 : return 0; - 1075 : - 1076 4841372 : memcpy(&info, tommy_arrayblkof_ref(array, pos), sizeof(snapraid_info)); - 1077 : - 1078 4841372 : return info; - 1079 : } - 1080 : - 1081 : /** - 1082 : * Compare times - 1083 : */ - 1084 : int time_compare(const void* void_a, const void* void_b); - 1085 : - 1086 : #endif - 1087 : + 1071 1772 : return info | 0x1; + 1072 : } + 1073 : + 1074 : /** + 1075 : * Mark the block address as with rehash. + 1076 : */ + 1077 9215 : static inline snapraid_info info_set_rehash(snapraid_info info) + 1078 : { + 1079 9215 : return info | 0x2; + 1080 : } + 1081 : + 1082 : /** + 1083 : * Set the info at the specified position. + 1084 : * The position is allocated if not yet done. + 1085 : */ + 1086 1641726 : static inline void info_set(tommy_arrayblkof* array, unsigned pos, snapraid_info info) + 1087 : { + 1088 1641726 : tommy_arrayblkof_grow(array, pos + 1); + 1089 : + 1090 1641726 : memcpy(tommy_arrayblkof_ref(array, pos), &info, sizeof(snapraid_info)); + 1091 1641726 : } + 1092 : + 1093 : /** + 1094 : * Get the info at the specified position. + 1095 : * For not allocated position, 0 is returned. + 1096 : */ + 1097 5095494 : static inline snapraid_info info_get(tommy_arrayblkof* array, unsigned pos) + 1098 : { + 1099 : snapraid_info info; + 1100 : + 1101 5095494 : if (pos >= tommy_arrayblkof_size(array)) + 1102 262643 : return 0; + 1103 : + 1104 4832851 : memcpy(&info, tommy_arrayblkof_ref(array, pos), sizeof(snapraid_info)); + 1105 : + 1106 4832851 : return info; + 1107 : } + 1108 : + 1109 : /** + 1110 : * Compare times + 1111 : */ + 1112 : int time_compare(const void* void_a, const void* void_b); + 1113 : + 1114 : #endif + 1115 : diff --git a/cov/cmdline/handle.c.func-sort-c.html b/cov/cmdline/handle.c.func-sort-c.html index 2444eacb..a3b8176d 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-01-09 + 2016-01-16 Functions: 8 @@ -61,35 +61,35 @@ handle_read - 5713632 + 5716944 handle_close - 4590919 + 4591332 handle_open - 2024387 + 2024756 handle_create - 771290 + 771365 handle_write - 288532 + 288554 handle_utime - 119455 + 119530 handle_truncate - 3187 + 3129 handle_map - 214 + 216
diff --git a/cov/cmdline/handle.c.func.html b/cov/cmdline/handle.c.func.html index cb35a7e7..c4efd864 100644 --- a/cov/cmdline/handle.c.func.html +++ b/cov/cmdline/handle.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 @@ -61,35 +61,35 @@ handle_close - 4590919 + 4591332 handle_create - 771290 + 771365 handle_map - 214 + 216 handle_open - 2024387 + 2024756 handle_read - 5713632 + 5716944 handle_truncate - 3187 + 3129 handle_utime - 119455 + 119530 handle_write - 288532 + 288554
diff --git a/cov/cmdline/handle.c.gcov.html b/cov/cmdline/handle.c.gcov.html index 84f0dbae..1e2f7788 100644 --- a/cov/cmdline/handle.c.gcov.html +++ b/cov/cmdline/handle.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 @@ -86,66 +86,66 @@ 24 : /****************************************************************************/ 25 : /* handle */ 26 : - 27 771290 : int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, int mode) + 27 771365 : 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 771290 : if (handle->file == file && handle->f != -1) { + 33 771365 : if (handle->file == file && handle->f != -1) { 34 0 : return 0; 35 : } 36 : - 37 771290 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); + 37 771365 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); 38 : - 39 771290 : ret = mkancestor(handle->path); - 40 771290 : if (ret != 0) { + 39 771365 : ret = mkancestor(handle->path); + 40 771365 : if (ret != 0) { 41 : /* LCOV_EXCL_START */ 42 : return -1; 43 : /* LCOV_EXCL_STOP */ 44 : } 45 : 46 : /* initial values, changed later if required */ - 47 771290 : handle->created = 0; + 47 771365 : handle->created = 0; 48 : 49 : /* flags for opening */ 50 : /* O_BINARY: open as binary file (Windows only) */ 51 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ 52 : /* O_SEQUENTIAL: improve performance for sequential access (Windows only) */ - 53 771290 : flags = O_BINARY | O_NOFOLLOW; - 54 771290 : if ((mode & MODE_SEQUENTIAL) != 0) - 55 771290 : flags |= O_SEQUENTIAL; + 53 771365 : flags = O_BINARY | O_NOFOLLOW; + 54 771365 : if ((mode & MODE_SEQUENTIAL) != 0) + 55 771365 : flags |= O_SEQUENTIAL; 56 : 57 : /* open for read write */ - 58 771290 : handle->f = open(handle->path, flags | O_RDWR); + 58 771365 : handle->f = open(handle->path, flags | O_RDWR); 59 : 60 : /* if failed for missing write permission */ - 61 771290 : if (handle->f == -1 && (errno == EACCES || errno == EROFS)) { + 61 771365 : if (handle->f == -1 && (errno == EACCES || errno == EROFS)) { 62 : /* open for real-only */ 63 0 : handle->f = open(handle->path, flags | O_RDONLY); 64 : } 65 : 66 : /* if failed for missing file */ - 67 771290 : if (handle->f == -1 && errno == ENOENT) { + 67 771365 : if (handle->f == -1 && errno == ENOENT) { 68 : char path_from[PATH_MAX]; 69 : 70 : /* check if exists a .unrecoverable copy, and rename to the real one */ - 71 176470 : pathprint(path_from, sizeof(path_from), "%s.unrecoverable", handle->path); + 71 176313 : pathprint(path_from, sizeof(path_from), "%s.unrecoverable", handle->path); 72 : - 73 176470 : if (rename(path_from, handle->path) == 0) { + 73 176313 : if (rename(path_from, handle->path) == 0) { 74 : /* open for read write */ - 75 63363 : handle->f = open(handle->path, flags | O_RDWR); + 75 63259 : handle->f = open(handle->path, flags | O_RDWR); 76 : } else { 77 : /* create it */ - 78 113107 : handle->f = open(handle->path, flags | O_RDWR | O_CREAT, 0600); - 79 113107 : if (handle->f != -1) { + 78 113054 : handle->f = open(handle->path, flags | O_RDWR | O_CREAT, 0600); + 79 113054 : if (handle->f != -1) { 80 : /* mark it as created if really done */ - 81 113107 : handle->created = 1; + 81 113054 : handle->created = 1; 82 : } 83 : } 84 : } 85 : - 86 771290 : if (handle->f == -1) { + 86 771365 : if (handle->f == -1) { 87 : /* LCOV_EXCL_START */ 88 : /* invalidate for error */ 89 : handle->file = 0; @@ -158,11 +158,11 @@ 96 : } 97 : 98 : /* just opened */ - 99 771290 : handle->file = file; + 99 771365 : handle->file = file; 100 : 101 : /* get the stat info */ - 102 771290 : ret = fstat(handle->f, &handle->st); - 103 771290 : if (ret != 0) { + 102 771365 : ret = fstat(handle->f, &handle->st); + 103 771365 : if (ret != 0) { 104 : /* LCOV_EXCL_START */ 105 : log_fatal("Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); 106 : return -1; @@ -170,13 +170,13 @@ 108 : } 109 : 110 : /* get the size of the existing data */ - 111 771290 : handle->valid_size = handle->st.st_size; + 111 771365 : handle->valid_size = handle->st.st_size; 112 : 113 : #if HAVE_POSIX_FADVISE - 114 771290 : if ((mode & MODE_SEQUENTIAL) != 0) { + 114 771365 : if ((mode & MODE_SEQUENTIAL) != 0) { 115 : /* advise sequential access */ - 116 771290 : ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL); - 117 771290 : if (ret != 0) { + 116 771365 : ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL); + 117 771365 : if (ret != 0) { 118 : /* LCOV_EXCL_START */ 119 : log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(ret)); 120 : return -1; @@ -185,15 +185,15 @@ 123 : } 124 : #endif 125 : - 126 771290 : return 0; + 126 771365 : return 0; 127 : } 128 : - 129 3187 : int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file) + 129 3129 : int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file) 130 : { 131 : int ret; 132 : - 133 3187 : ret = ftruncate(handle->f, file->size); - 134 3187 : if (ret != 0) { + 133 3129 : ret = ftruncate(handle->f, file->size); + 134 3129 : if (ret != 0) { 135 : /* LCOV_EXCL_START */ 136 : if (errno == EACCES) { 137 : log_fatal("Failed to truncate file '%s' for missing write permission.\n", handle->path); @@ -205,58 +205,58 @@ 143 : } 144 : 145 : /* adjust the size to the truncated size */ - 146 3187 : handle->valid_size = file->size; + 146 3129 : handle->valid_size = file->size; 147 : - 148 3187 : return 0; + 148 3129 : return 0; 149 : } 150 : - 151 2024387 : int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing) + 151 2024756 : int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing) 152 : { 153 : int ret; 154 : int flags; 155 : - 156 2024387 : if (!out_missing) - 157 2023815 : out_missing = out; + 156 2024756 : if (!out_missing) + 157 2024202 : out_missing = out; 158 : 159 : /* if already opened, nothing to do */ - 160 2024387 : if (handle->file == file && handle->f != -1) { - 161 363056 : return 0; + 160 2024756 : if (handle->file == file && handle->f != -1) { + 161 363353 : return 0; 162 : } 163 : - 164 1661331 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); + 164 1661403 : pathprint(handle->path, sizeof(handle->path), "%s%s", handle->disk->dir, file->sub); 165 : 166 : /* for sure not created */ - 167 1661331 : handle->created = 0; + 167 1661403 : handle->created = 0; 168 : 169 : /* flags for opening */ 170 : /* O_BINARY: open as binary file (Windows only) */ 171 : /* O_NOFOLLOW: do not follow links to ensure to open the real file */ 172 : /* O_SEQUENTIAL: improve performance for sequential access (Windows only) */ - 173 1661331 : flags = O_BINARY | O_NOFOLLOW; - 174 1661331 : if ((mode & MODE_SEQUENTIAL) != 0) - 175 1649996 : flags |= O_SEQUENTIAL; + 173 1661403 : flags = O_BINARY | O_NOFOLLOW; + 174 1661403 : if ((mode & MODE_SEQUENTIAL) != 0) + 175 1650065 : flags |= O_SEQUENTIAL; 176 : 177 : /* open for read */ - 178 1661331 : handle->f = open_noatime(handle->path, flags | O_RDONLY); - 179 1661331 : if (handle->f == -1) { + 178 1661403 : handle->f = open_noatime(handle->path, flags | O_RDONLY); + 179 1661403 : if (handle->f == -1) { 180 : /* invalidate for error */ - 181 78781 : handle->file = 0; - 182 78781 : handle->f = -1; - 183 78781 : handle->valid_size = 0; + 181 78544 : handle->file = 0; + 182 78544 : handle->f = -1; + 183 78544 : handle->valid_size = 0; 184 : - 185 78781 : if (errno == ENOENT) - 186 78769 : out_missing("Missing file '%s'.\n", handle->path); + 185 78544 : if (errno == ENOENT) + 186 78532 : out_missing("Missing file '%s'.\n", handle->path); 187 : else 188 12 : out("Error opening file '%s'. %s.\n", handle->path, strerror(errno)); - 189 78781 : return -1; + 189 78544 : return -1; 190 : } 191 : 192 : /* just opened */ - 193 1582550 : handle->file = file; + 193 1582859 : handle->file = file; 194 : 195 : /* get the stat info */ - 196 1582550 : ret = fstat(handle->f, &handle->st); - 197 1582550 : if (ret != 0) { + 196 1582859 : ret = fstat(handle->f, &handle->st); + 197 1582859 : if (ret != 0) { 198 : /* LCOV_EXCL_START */ 199 : out("Error accessing file '%s'. %s.\n", handle->path, strerror(errno)); 200 : return -1; @@ -264,13 +264,13 @@ 202 : } 203 : 204 : /* get the size of the existing data */ - 205 1582550 : handle->valid_size = handle->st.st_size; + 205 1582859 : handle->valid_size = handle->st.st_size; 206 : 207 : #if HAVE_POSIX_FADVISE - 208 1582550 : if ((mode & MODE_SEQUENTIAL) != 0) { + 208 1582859 : if ((mode & MODE_SEQUENTIAL) != 0) { 209 : /* advise sequential access */ - 210 1571215 : ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL); - 211 1571215 : if (ret != 0) { + 210 1571521 : ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL); + 211 1571521 : if (ret != 0) { 212 : /* LCOV_EXCL_START */ 213 : out("Error advising file '%s'. %s.\n", handle->path, strerror(ret)); 214 : return -1; @@ -279,17 +279,17 @@ 217 : } 218 : #endif 219 : - 220 1582550 : return 0; + 220 1582859 : return 0; 221 : } 222 : - 223 4590919 : int handle_close(struct snapraid_handle* handle) + 223 4591332 : int handle_close(struct snapraid_handle* handle) 224 : { 225 : int ret; 226 : 227 : /* close if open */ - 228 4590919 : if (handle->f != -1) { - 229 2353840 : ret = close(handle->f); - 230 2353840 : if (ret != 0) { + 228 4591332 : if (handle->f != -1) { + 229 2354224 : ret = close(handle->f); + 230 2354224 : if (ret != 0) { 231 : /* LCOV_EXCL_START */ 232 : log_fatal("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno)); 233 : @@ -303,36 +303,36 @@ 241 : } 242 : 243 : /* reset the descriptor */ - 244 4590919 : handle->file = 0; - 245 4590919 : handle->f = -1; - 246 4590919 : handle->valid_size = 0; + 244 4591332 : handle->file = 0; + 245 4591332 : handle->f = -1; + 246 4591332 : handle->valid_size = 0; 247 : - 248 4590919 : return 0; + 248 4591332 : return 0; 249 : } 250 : - 251 5713632 : int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing) + 251 5716944 : int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing) 252 : { 253 : ssize_t read_ret; 254 : data_off_t offset; 255 : unsigned read_size; 256 : unsigned count; 257 : - 258 5713632 : offset = file_pos * (data_off_t)block_size; + 258 5716944 : offset = file_pos * (data_off_t)block_size; 259 : - 260 5713632 : if (!out_missing) - 261 5700398 : out_missing = out; + 260 5716944 : if (!out_missing) + 261 5703849 : out_missing = out; 262 : 263 : /* check if we are going to read only not initialized data */ - 264 5713632 : if (offset >= handle->valid_size) { + 264 5716944 : if (offset >= handle->valid_size) { 265 : /* if the file is missing, it's at 0 size, or it's rebuilt while reading */ - 266 433671 : if (offset == handle->valid_size || handle->valid_size == 0) - 267 432378 : out_missing("Reading data from missing file '%s' at offset %" PRIu64 ".\n", handle->path, offset); + 266 433274 : if (offset == handle->valid_size || handle->valid_size == 0) + 267 431967 : out_missing("Reading data from missing file '%s' at offset %" PRIu64 ".\n", handle->path, offset); 268 : else - 269 1293 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset); - 270 433671 : return -1; + 269 1307 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset); + 270 433274 : return -1; 271 : } 272 : - 273 5279961 : read_size = file_block_size(handle->file, file_pos, block_size); + 273 5283670 : read_size = file_block_size(handle->file, file_pos, block_size); 274 : 275 : #if !HAVE_PREAD 276 : if (lseek(handle->f, offset, SEEK_SET) != offset) { @@ -343,32 +343,32 @@ 281 : } 282 : #endif 283 : - 284 5279961 : count = 0; + 284 5283670 : count = 0; 285 : do { 286 : 287 : #if HAVE_PREAD - 288 5288816 : read_ret = pread(handle->f, block_buffer + count, read_size - count, offset + count); + 288 5292676 : read_ret = pread(handle->f, block_buffer + count, read_size - count, offset + count); 289 : #else 290 : read_ret = read(handle->f, block_buffer + count, read_size - count); 291 : #endif 292 : - 293 5288816 : if (read_ret < 0) { + 293 5292676 : if (read_ret < 0) { 294 : /* LCOV_EXCL_START */ 295 : out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, read_size - count, strerror(errno)); 296 : return -1; 297 : /* LCOV_EXCL_STOP */ 298 : } - 299 5288816 : if (read_ret == 0) { - 300 8855 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno)); - 301 8855 : return -1; + 299 5292676 : if (read_ret == 0) { + 300 9006 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno)); + 301 9006 : return -1; 302 : } 303 : - 304 5279961 : count += read_ret; - 305 5279961 : } while (count < read_size); + 304 5283670 : count += read_ret; + 305 5283670 : } while (count < read_size); 306 : 307 : /* pad with 0 */ - 308 5271106 : if (read_size < block_size) { - 309 2132322 : memset(block_buffer + read_size, 0, block_size - read_size); + 308 5274664 : if (read_size < block_size) { + 309 2132484 : memset(block_buffer + read_size, 0, block_size - read_size); 310 : } 311 : 312 : /* Here isn't needed to call posix_fadvise(..., POSIX_FADV_DONTNEED) */ @@ -382,21 +382,21 @@ 320 : /* at: https://lkml.org/lkml/2010/12/6/122 */ 321 : /* We relay only on the automatic readahead triggered by POSIX_FADV_SEQUENTIAL. */ 322 : - 323 5271106 : return read_size; + 323 5274664 : return read_size; 324 : } 325 : - 326 288532 : int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size) + 326 288554 : int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size) 327 : { 328 : ssize_t write_ret; 329 : data_off_t offset; 330 : unsigned write_size; 331 : - 332 288532 : offset = file_pos * (data_off_t)block_size; + 332 288554 : offset = file_pos * (data_off_t)block_size; 333 : - 334 288532 : write_size = file_block_size(handle->file, file_pos, block_size); + 334 288554 : write_size = file_block_size(handle->file, file_pos, block_size); 335 : 336 : #if HAVE_PWRITE - 337 288532 : write_ret = pwrite(handle->f, block_buffer, write_size, offset); + 337 288554 : write_ret = pwrite(handle->f, block_buffer, write_size, offset); 338 : #else 339 : if (lseek(handle->f, offset, SEEK_SET) != offset) { 340 : /* LCOV_EXCL_START */ @@ -407,7 +407,7 @@ 345 : 346 : write_ret = write(handle->f, block_buffer, write_size); 347 : #endif - 348 288532 : if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */ + 348 288554 : if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */ 349 : /* LCOV_EXCL_START */ 350 : log_fatal("Error writing file '%s'. %s.\n", handle->path, strerror(errno)); 351 : return -1; @@ -415,87 +415,87 @@ 353 : } 354 : 355 : /* adjust the size of the valid data */ - 356 288532 : if (handle->valid_size < offset + write_size) { - 357 282422 : handle->valid_size = offset + write_size; + 356 288554 : if (handle->valid_size < offset + write_size) { + 357 282395 : handle->valid_size = offset + write_size; 358 : } 359 : 360 : /* Here doesn't make sense to call posix_fadvise(..., POSIX_FADV_DONTNEED) because */ 361 : /* at this time the data is still not yet written and it cannot be discharged. */ 362 : - 363 288532 : return 0; + 363 288554 : return 0; 364 : } 365 : - 366 119455 : int handle_utime(struct snapraid_handle* handle) + 366 119530 : int handle_utime(struct snapraid_handle* handle) 367 : { 368 : int ret; 369 : 370 : /* do nothing if not opened */ - 371 119455 : if (handle->f == -1) + 371 119530 : if (handle->f == -1) 372 0 : return 0; 373 : - 374 119455 : ret = fmtime(handle->f, handle->file->mtime_sec, handle->file->mtime_nsec); + 374 119530 : ret = fmtime(handle->f, handle->file->mtime_sec, handle->file->mtime_nsec); 375 : - 376 119455 : if (ret != 0) { + 376 119530 : if (ret != 0) { 377 : /* LCOV_EXCL_START */ 378 : log_fatal("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno)); 379 : return -1; 380 : /* LCOV_EXCL_STOP */ 381 : } 382 : - 383 119455 : return 0; + 383 119530 : return 0; 384 : } 385 : - 386 214 : struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handlemax) + 386 216 : struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handlemax) 387 : { 388 : tommy_node* i; 389 : unsigned j; - 390 214 : unsigned size = 0; + 390 216 : unsigned size = 0; 391 : struct snapraid_handle* handle; 392 : 393 : /* get the size of the mapping */ - 394 214 : size = 0; - 395 1493 : for (i = state->maplist; i != 0; i = i->next) { - 396 1279 : struct snapraid_map* map = i->data; - 397 1279 : if (map->position > size) - 398 925 : size = map->position; + 394 216 : size = 0; + 395 1507 : for (i = state->maplist; i != 0; i = i->next) { + 396 1291 : struct snapraid_map* map = i->data; + 397 1291 : if (map->position > size) + 398 916 : size = map->position; 399 : } - 400 214 : ++size; /* size is one more than the max */ + 400 216 : ++size; /* size is one more than the max */ 401 : - 402 214 : handle = malloc_nofail(size * sizeof(struct snapraid_handle)); + 402 216 : handle = malloc_nofail(size * sizeof(struct snapraid_handle)); 403 : - 404 1498 : for (j = 0; j < size; ++j) { + 404 1512 : for (j = 0; j < size; ++j) { 405 : /* default for empty position */ - 406 1284 : handle[j].disk = 0; - 407 1284 : handle[j].file = 0; - 408 1284 : handle[j].f = -1; - 409 1284 : handle[j].valid_size = 0; + 406 1296 : handle[j].disk = 0; + 407 1296 : handle[j].file = 0; + 408 1296 : handle[j].f = -1; + 409 1296 : handle[j].valid_size = 0; 410 : } 411 : 412 : /* set the vector */ - 413 1493 : for (i = state->disklist; i != 0; i = i->next) { + 413 1507 : for (i = state->disklist; i != 0; i = i->next) { 414 : struct snapraid_map* map; - 415 1279 : struct snapraid_disk* disk = i->data; + 415 1291 : struct snapraid_disk* disk = i->data; 416 : tommy_node* k; 417 : 418 : /* search the mapping for this disk */ - 419 1279 : map = 0; - 420 4464 : for (k = state->maplist; k != 0; k = k->next) { - 421 4464 : map = k->data; - 422 4464 : if (strcmp(disk->name, map->name) == 0) - 423 1279 : break; + 419 1291 : map = 0; + 420 4506 : for (k = state->maplist; k != 0; k = k->next) { + 421 4506 : map = k->data; + 422 4506 : if (strcmp(disk->name, map->name) == 0) + 423 1291 : break; 424 : } - 425 1279 : if (!map) { + 425 1291 : if (!map) { 426 : /* LCOV_EXCL_START */ 427 : log_fatal("Internal error for inconsistent disk mapping.\n"); 428 : os_abort(); 429 : /* LCOV_EXCL_STOP */ 430 : } 431 : - 432 1279 : handle[map->position].disk = disk; + 432 1291 : handle[map->position].disk = disk; 433 : } 434 : - 435 214 : *handlemax = size; - 436 214 : return handle; + 435 216 : *handlemax = size; + 436 216 : return handle; 437 : } 438 : diff --git a/cov/cmdline/import.c.func-sort-c.html b/cov/cmdline/import.c.func-sort-c.html index fc384422..e309310b 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-01-09 + 2016-01-16 Functions: 7 @@ -61,11 +61,11 @@ import_block_hash - 657660 + 657104 state_import_fetch - 653188 + 652632 import_block_hash_compare diff --git a/cov/cmdline/import.c.func.html b/cov/cmdline/import.c.func.html index c081b511..df0026ea 100644 --- a/cov/cmdline/import.c.func.html +++ b/cov/cmdline/import.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 @@ -61,7 +61,7 @@ import_block_hash - 657660 + 657104 import_block_hash_compare @@ -89,7 +89,7 @@ state_import_fetch - 653188 + 652632
diff --git a/cov/cmdline/import.c.gcov.html b/cov/cmdline/import.c.gcov.html index a3d12909..7e3ad851 100644 --- a/cov/cmdline/import.c.gcov.html +++ b/cov/cmdline/import.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 657660 : static inline tommy_uint32_t import_block_hash(const unsigned char* hash) + 49 657104 : 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 657660 : return hash[0] | ((uint32_t)hash[1] << 8) | ((uint32_t)hash[2] << 16) | ((uint32_t)hash[3] << 24); + 52 657104 : 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) @@ -212,24 +212,24 @@ 150 1750 : free(file); 151 1750 : } 152 : - 153 653188 : int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid_block* missing_block, unsigned char* buffer) + 153 652632 : int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid_block* missing_block, unsigned char* buffer) 154 : { 155 : struct snapraid_import_block* block; 156 : int ret; 157 : int f; - 158 653188 : const unsigned char* hash = missing_block->hash; - 159 653188 : unsigned block_size = state->block_size; + 158 652632 : const unsigned char* hash = missing_block->hash; + 159 652632 : unsigned block_size = state->block_size; 160 : unsigned read_size; 161 : unsigned char buffer_hash[HASH_SIZE]; 162 : const char* path; 163 : - 164 653188 : if (rehash) { + 164 652632 : if (rehash) { 165 0 : block = tommy_hashdyn_search(&state->previmportset, import_block_prevhash_compare, hash, import_block_hash(hash)); 166 : } else { - 167 653188 : block = tommy_hashdyn_search(&state->importset, import_block_hash_compare, hash, import_block_hash(hash)); + 167 652632 : block = tommy_hashdyn_search(&state->importset, import_block_hash_compare, hash, import_block_hash(hash)); 168 : } - 169 653188 : if (!block) - 170 648716 : return -1; + 169 652632 : if (!block) + 170 648160 : return -1; 171 : 172 4472 : path = block->file->path; 173 4472 : read_size = block->size; diff --git a/cov/cmdline/index-sort-f.html b/cov/cmdline/index-sort-f.html index 4610da17..7f8db994 100644 --- a/cov/cmdline/index-sort-f.html +++ b/cov/cmdline/index-sort-f.html @@ -31,17 +31,17 @@ lcov.info Lines: - 7401 - 8084 + 7412 + 8093 91.6 % Date: - 2016-01-09 + 2016-01-16 Functions: - 390 - 401 + 392 + 403 97.3 % @@ -132,10 +132,10 @@ elem.c -
93.8%93.8%
+
94.0%94.0%
- 93.8 % - 546 / 582 + 94.0 % + 548 / 583 96.9 % 62 / 64 @@ -392,22 +392,22 @@ scan.c -
89.1%89.1%
+
89.3%89.3%
- 89.1 % - 554 / 622 + 89.3 % + 557 / 624 100.0 % 23 / 23 elem.h -
99.1%99.1%
+
99.2%99.2%
- 99.1 % - 115 / 116 + 99.2 % + 121 / 122 100.0 % - 39 / 39 + 41 / 41 diff --git a/cov/cmdline/index-sort-l.html b/cov/cmdline/index-sort-l.html index e8ea2475..46d924d5 100644 --- a/cov/cmdline/index-sort-l.html +++ b/cov/cmdline/index-sort-l.html @@ -31,17 +31,17 @@ lcov.info Lines: - 7401 - 8084 + 7412 + 8093 91.6 % Date: - 2016-01-09 + 2016-01-16 Functions: - 390 - 401 + 392 + 403 97.3 % @@ -122,10 +122,10 @@ scan.c -
89.1%89.1%
+
89.3%89.3%
- 89.1 % - 554 / 622 + 89.3 % + 557 / 624 100.0 % 23 / 23 @@ -242,10 +242,10 @@ elem.c -
93.8%93.8%
+
94.0%94.0%
- 93.8 % - 546 / 582 + 94.0 % + 548 / 583 96.9 % 62 / 64 @@ -312,12 +312,12 @@ elem.h -
99.1%99.1%
+
99.2%99.2%
- 99.1 % - 115 / 116 + 99.2 % + 121 / 122 100.0 % - 39 / 39 + 41 / 41 speed.c diff --git a/cov/cmdline/index.html b/cov/cmdline/index.html index 852332c6..4794f321 100644 --- a/cov/cmdline/index.html +++ b/cov/cmdline/index.html @@ -31,17 +31,17 @@ lcov.info Lines: - 7401 - 8084 + 7412 + 8093 91.6 % Date: - 2016-01-09 + 2016-01-16 Functions: - 390 - 401 + 392 + 403 97.3 % @@ -112,22 +112,22 @@ elem.c -
93.8%93.8%
+
94.0%94.0%
- 93.8 % - 546 / 582 + 94.0 % + 548 / 583 96.9 % 62 / 64 elem.h -
99.1%99.1%
+
99.2%99.2%
- 99.1 % - 115 / 116 + 99.2 % + 121 / 122 100.0 % - 39 / 39 + 41 / 41 handle.c @@ -242,10 +242,10 @@ scan.c -
89.1%89.1%
+
89.3%89.3%
- 89.1 % - 554 / 622 + 89.3 % + 557 / 624 100.0 % 23 / 23 diff --git a/cov/cmdline/list.c.func-sort-c.html b/cov/cmdline/list.c.func-sort-c.html index a1d33ff3..79d9a593 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-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/list.c.func.html b/cov/cmdline/list.c.func.html index 77720432..c4883efc 100644 --- a/cov/cmdline/list.c.func.html +++ b/cov/cmdline/list.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/list.c.gcov.html b/cov/cmdline/list.c.gcov.html index 41e63009..48ca446b 100644 --- a/cov/cmdline/list.c.gcov.html +++ b/cov/cmdline/list.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 @@ -110,34 +110,34 @@ 48 18 : tommy_list_sort(&disk->filelist, file_path_compare); 49 : 50 : /* for each file */ - 51 17012 : for (j = disk->filelist; j != 0; j = j->next) { - 52 16994 : struct snapraid_file* file = j->data; + 51 17018 : for (j = disk->filelist; j != 0; j = j->next) { + 52 17000 : struct snapraid_file* file = j->data; 53 : #if HAVE_LOCALTIME_R 54 : struct tm tm_res; 55 : #endif 56 : struct tm* tm; 57 : time_t t; 58 : - 59 16994 : ++file_count; - 60 16994 : file_size += file->size; + 59 17000 : ++file_count; + 60 17000 : file_size += file->size; 61 : - 62 16994 : log_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc(file->sub), file->size, file->mtime_sec, file->mtime_nsec, file->inode); + 62 17000 : log_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc(file->sub), file->size, file->mtime_sec, file->mtime_nsec, file->inode); 63 : - 64 16994 : t = file->mtime_sec; + 64 17000 : t = file->mtime_sec; 65 : #if HAVE_LOCALTIME_R - 66 16994 : tm = localtime_r(&t, &tm_res); + 66 17000 : tm = localtime_r(&t, &tm_res); 67 : #else 68 : tm = localtime(&t); 69 : #endif 70 : - 71 16994 : printf("%12" PRIu64 " ", file->size); - 72 16994 : if (tm) { - 73 16994 : printf("%04u/%02u/%02u %02u:%02u", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); - 74 16994 : if (msg_level >= MSG_VERBOSE) - 75 16994 : printf(":%02u.%03u", tm->tm_sec, file->mtime_nsec / 1000000); - 76 16994 : printf(" "); + 71 17000 : printf("%12" PRIu64 " ", file->size); + 72 17000 : if (tm) { + 73 17000 : printf("%04u/%02u/%02u %02u:%02u", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); + 74 17000 : if (msg_level >= MSG_VERBOSE) + 75 17000 : printf(":%02u.%03u", tm->tm_sec, file->mtime_nsec / 1000000); + 76 17000 : printf(" "); 77 : } - 78 16994 : printf("%s%s\n", disk->dir, file->sub); + 78 17000 : printf("%s%s\n", disk->dir, file->sub); 79 : } 80 : 81 : /* sort by name */ diff --git a/cov/cmdline/mkstream.c.func-sort-c.html b/cov/cmdline/mkstream.c.func-sort-c.html index e22bee50..fd1ee42c 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-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/cmdline/mkstream.c.func.html b/cov/cmdline/mkstream.c.func.html index 5b87fdd6..cf83d196 100644 --- a/cov/cmdline/mkstream.c.func.html +++ b/cov/cmdline/mkstream.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/cmdline/mkstream.c.gcov.html b/cov/cmdline/mkstream.c.gcov.html index 7c9b10f2..973e3276 100644 --- a/cov/cmdline/mkstream.c.gcov.html +++ b/cov/cmdline/mkstream.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/cmdline/mktest.c.func-sort-c.html b/cov/cmdline/mktest.c.func-sort-c.html index 2268a650..60fe0b0a 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-01-09 + 2016-01-16 Functions: 18 @@ -61,23 +61,23 @@ rnd - 50969532 + 50977685 rndnz - 50559223 + 50567397 file_cmp - 146593 + 146542 rndnz_range - 31151 + 31156 rnd_name - 26849 + 26840 cmd_generate @@ -93,19 +93,19 @@ cmd_write - 4719 - - - cmd_delete - 3209 - - - cmd_append - 3192 + 4786 cmd_truncate - 3139 + 3204 + + + cmd_delete + 3141 + + + cmd_append + 3130 cmd_damage @@ -121,7 +121,7 @@ cmd_generate_symlink - 940 + 931 main diff --git a/cov/cmdline/mktest.c.func.html b/cov/cmdline/mktest.c.func.html index 3b8f65ae..b7d4bbca 100644 --- a/cov/cmdline/mktest.c.func.html +++ b/cov/cmdline/mktest.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 18 @@ -61,7 +61,7 @@ cmd_append - 3192 + 3130 cmd_change @@ -73,7 +73,7 @@ cmd_delete - 3209 + 3141 cmd_generate @@ -85,15 +85,15 @@ cmd_generate_symlink - 940 + 931 cmd_truncate - 3139 + 3204 cmd_write - 4719 + 4786 fallback @@ -101,7 +101,7 @@ file_cmp - 146593 + 146542 help @@ -113,15 +113,15 @@ rnd - 50969532 + 50977685 rnd_name - 26849 + 26840 rndnz - 50559223 + 50567397 rndnz_damage @@ -129,7 +129,7 @@ rndnz_range - 31151 + 31156
diff --git a/cov/cmdline/mktest.c.gcov.html b/cov/cmdline/mktest.c.gcov.html index 2f63044d..7a835d49 100644 --- a/cov/cmdline/mktest.c.gcov.html +++ b/cov/cmdline/mktest.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 18 @@ -89,28 +89,28 @@ 27 : */ 28 : unsigned long long seed = 0; 29 : - 30 50969532 : unsigned rnd(unsigned max) + 30 50977685 : unsigned rnd(unsigned max) 31 : { - 32 50969532 : seed = seed * 6364136223846793005LL + 1442695040888963407LL; + 32 50977685 : seed = seed * 6364136223846793005LL + 1442695040888963407LL; 33 : - 34 50969532 : return (seed >> 32) % max; + 34 50977685 : return (seed >> 32) % max; 35 : } 36 : - 37 50559223 : unsigned rndnz(unsigned max) + 37 50567397 : unsigned rndnz(unsigned max) 38 : { - 39 50559223 : if (max <= 1) + 39 50567397 : if (max <= 1) 40 2831 : return 1; 41 : else - 42 50556392 : return rnd(max - 1) + 1; + 42 50564566 : return rnd(max - 1) + 1; 43 : } 44 : - 45 31151 : void rndnz_range(unsigned char* data, int size) + 45 31156 : void rndnz_range(unsigned char* data, int size) 46 : { 47 : int i; 48 : - 49 50585115 : for (i = 0; i < size; ++i) - 50 50553964 : data[i] = rndnz(256); - 51 31151 : } + 49 50593290 : for (i = 0; i < size; ++i) + 50 50562134 : data[i] = rndnz(256); + 51 31156 : } 52 : 53 1821 : void rndnz_damage(unsigned char* data, int size) 54 : { @@ -121,8 +121,8 @@ 59 : unsigned char c; 60 : 61 : do { - 62 1828 : c = rndnz(256); - 63 1828 : } while (c == data[i]); + 62 1832 : c = rndnz(256); + 63 1832 : } while (c == data[i]); 64 : 65 1821 : data[i] = c; 66 : } @@ -131,23 +131,23 @@ 69 : char CHARSET[] = "qwertyuiopasdfghjklzxcvbnm1234567890 .-+"; 70 : #define CHARSET_LEN (sizeof(CHARSET) - 1) 71 : - 72 26849 : void rnd_name(char* file) + 72 26840 : void rnd_name(char* file) 73 : { - 74 26849 : int l = 1 + rnd(20); + 74 26840 : int l = 1 + rnd(20); 75 : - 76 335469 : while (l) { - 77 281771 : *file++ = CHARSET[rnd(CHARSET_LEN)]; - 78 281771 : --l; + 76 335385 : while (l) { + 77 281705 : *file++ = CHARSET[rnd(CHARSET_LEN)]; + 78 281705 : --l; 79 : } - 80 26849 : *file = 0; - 81 26849 : } + 80 26840 : *file = 0; + 81 26840 : } 82 : 83 : /****************************************************************************/ 84 : /* file */ 85 : - 86 146593 : int file_cmp(const void* a, const void* b) + 86 146542 : int file_cmp(const void* a, const void* b) 87 : { - 88 146593 : return strcmp(a, b); + 88 146542 : 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 940 : void cmd_generate_symlink(const char* path, const char* linkto) + 200 931 : void cmd_generate_symlink(const char* path, const char* linkto) 201 : { 202 : /* remove the existing file/symlink if any */ - 203 940 : if (remove(path) != 0) { - 204 919 : if (errno != ENOENT) { + 203 931 : if (remove(path) != 0) { + 204 910 : 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 940 : if (symlink(linkto, path) != 0) { + 212 931 : 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 940 : } + 218 931 : } 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 4719 : void cmd_write(const char* path, int size) + 291 4786 : void cmd_write(const char* path, int size) 292 : { 293 : struct stat st; 294 : - 295 4719 : if (lstat(path, &st) != 0) { + 295 4786 : 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 4719 : if (S_ISREG(st.st_mode)) { + 302 4786 : if (S_ISREG(st.st_mode)) { 303 : unsigned char* data; 304 : off_t off; 305 : int f; 306 : 307 : /* not over the end */ - 308 4692 : if (size > st.st_size) - 309 175 : size = st.st_size; + 308 4759 : if (size > st.st_size) + 309 191 : size = st.st_size; 310 : 311 : /* start at random position inside the file */ - 312 4692 : if (size < st.st_size) - 313 4517 : off = rnd(st.st_size - size); + 312 4759 : if (size < st.st_size) + 313 4568 : off = rnd(st.st_size - size); 314 : else - 315 175 : off = 0; + 315 191 : off = 0; 316 : - 317 4692 : data = malloc(size); + 317 4759 : data = malloc(size); 318 : - 319 4692 : rndnz_range(data, size); + 319 4759 : rndnz_range(data, size); 320 : - 321 4692 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); - 322 4692 : if (f < 0) { + 321 4759 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); + 322 4759 : 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 4692 : if (lseek(f, off, SEEK_SET) != off) { + 329 4759 : 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 4692 : if (write(f, data, size) != size) { + 336 4759 : 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 4692 : if (close(f) != 0) { + 343 4759 : 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 4692 : free(data); + 350 4759 : free(data); 351 : } - 352 4719 : } + 352 4786 : } 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 3192 : void cmd_append(const char* path, int size) + 459 3130 : void cmd_append(const char* path, int size) 460 : { 461 : struct stat st; 462 : - 463 3192 : if (lstat(path, &st) != 0) { + 463 3130 : 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 3192 : if (S_ISREG(st.st_mode)) { + 470 3130 : if (S_ISREG(st.st_mode)) { 471 : unsigned char* data; 472 : int f; 473 : - 474 3192 : data = malloc(size); + 474 3130 : data = malloc(size); 475 : - 476 3192 : rndnz_range(data, size); + 476 3130 : rndnz_range(data, size); 477 : - 478 3192 : f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW); - 479 3192 : if (f < 0) { + 478 3130 : f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW); + 479 3130 : 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 3192 : if (write(f, data, size) != size) { + 486 3130 : 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 3192 : if (close(f) != 0) { + 493 3130 : 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 3192 : free(data); + 500 3130 : free(data); 501 : } - 502 3192 : } + 502 3130 : } 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 3139 : void cmd_truncate(const char* path, int size) + 510 3204 : void cmd_truncate(const char* path, int size) 511 : { 512 : struct stat st; 513 : - 514 3139 : if (lstat(path, &st) != 0) { + 514 3204 : 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 3139 : if (S_ISREG(st.st_mode)) { + 521 3204 : if (S_ISREG(st.st_mode)) { 522 : off_t off; 523 : int f; 524 : 525 : /* if file is empty, just rewrite it */ - 526 3139 : if (st.st_size == 0) { - 527 4 : size = 0; + 526 3204 : if (st.st_size == 0) { + 527 3 : size = 0; 528 : } else { 529 : /* don't truncate files to 0 size to avoid ZERO file size protection */ - 530 3135 : if (size >= st.st_size) - 531 211 : size = st.st_size - 1; + 530 3201 : if (size >= st.st_size) + 531 189 : size = st.st_size - 1; 532 : } 533 : - 534 3139 : off = st.st_size - size; + 534 3204 : off = st.st_size - size; 535 : - 536 3139 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); - 537 3139 : if (f < 0) { + 536 3204 : f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW); + 537 3204 : 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 3139 : if (ftruncate(f, off) != 0) { + 544 3204 : 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 3139 : if (close(f) != 0) { + 551 3204 : 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 3139 : } + 558 3204 : } 559 : 560 : /** 561 : * Delete a file. 562 : * - The file must exist. 563 : */ - 564 3209 : void cmd_delete(const char* path) + 564 3141 : void cmd_delete(const char* path) 565 : { - 566 3209 : if (remove(path) != 0) { + 566 3141 : 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 3209 : } + 572 3141 : } 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 13153 : return; + 583 13150 : return; 584 : - 585 13103 : if (lstat(path, &st) != 0) { + 585 13106 : 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 13103 : if (S_ISLNK(st.st_mode)) { + 592 13106 : if (S_ISLNK(st.st_mode)) { 593 : /* symlink */ - 594 393 : if (rnd(2) == 0) { + 594 394 : if (rnd(2) == 0) { 595 : /* delete */ - 596 186 : if (remove(path) != 0) { + 596 196 : 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 207 : if (remove(path) != 0) { + 606 198 : 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 207 : rnd_name(linkto); + 613 198 : rnd_name(linkto); 614 : - 615 207 : cmd_generate_symlink(path, linkto); + 615 198 : cmd_generate_symlink(path, linkto); 616 : } - 617 12710 : } else if (S_ISREG(st.st_mode)) { + 617 12712 : } else if (S_ISREG(st.st_mode)) { 618 : int r; 619 : - 620 12710 : r = rnd(4); + 620 12712 : r = rnd(4); 621 : - 622 12710 : if (r == 0) { - 623 3170 : cmd_write(path, size); - 624 9540 : } else if (r == 1) { - 625 3192 : cmd_append(path, size); - 626 6348 : } else if (r == 2) { - 627 3139 : cmd_truncate(path, size); + 622 12712 : if (r == 0) { + 623 3237 : cmd_write(path, size); + 624 9475 : } else if (r == 1) { + 625 3130 : cmd_append(path, size); + 626 6345 : } else if (r == 2) { + 627 3204 : cmd_truncate(path, size); 628 : } else { - 629 3209 : cmd_delete(path); + 629 3141 : 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 1f49f399..97cdcce5 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-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ fmix32 - 7745044 + 7750824 MurmurHash3_x86_128 - 1936261 + 1937706
diff --git a/cov/cmdline/murmur3.c.func.html b/cov/cmdline/murmur3.c.func.html index aec58569..ed9cbecc 100644 --- a/cov/cmdline/murmur3.c.func.html +++ b/cov/cmdline/murmur3.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ MurmurHash3_x86_128 - 1936261 + 1937706 fmix32 - 7745044 + 7750824
diff --git a/cov/cmdline/murmur3.c.gcov.html b/cov/cmdline/murmur3.c.gcov.html index 75a6add6..8def46d3 100644 --- a/cov/cmdline/murmur3.c.gcov.html +++ b/cov/cmdline/murmur3.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 7745044 : static inline uint32_t fmix32(uint32_t h) + 32 7750824 : static inline uint32_t fmix32(uint32_t h) 33 : { - 34 7745044 : h ^= h >> 16; - 35 7745044 : h *= 0x85ebca6b; - 36 7745044 : h ^= h >> 13; - 37 7745044 : h *= 0xc2b2ae35; - 38 7745044 : h ^= h >> 16; - 39 7745044 : return h; + 34 7750824 : h ^= h >> 16; + 35 7750824 : h *= 0x85ebca6b; + 36 7750824 : h ^= h >> 13; + 37 7750824 : h *= 0xc2b2ae35; + 38 7750824 : h ^= h >> 16; + 39 7750824 : return h; 40 : } 41 : 42 : /* @@ -137,17 +137,17 @@ 75 : uint32_t c3 = 0x38b34ae5; 76 : uint32_t c4 = 0xa1e38b93; 77 : - 78 1936261 : void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, void* digest) + 78 1937706 : 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 1936261 : uint32_t h1 = ((const uint32_t*)seed)[0]; - 86 1936261 : uint32_t h2 = ((const uint32_t*)seed)[1]; - 87 1936261 : uint32_t h3 = ((const uint32_t*)seed)[2]; - 88 1936261 : uint32_t h4 = ((const uint32_t*)seed)[3]; + 85 1937706 : uint32_t h1 = ((const uint32_t*)seed)[0]; + 86 1937706 : uint32_t h2 = ((const uint32_t*)seed)[1]; + 87 1937706 : uint32_t h3 = ((const uint32_t*)seed)[2]; + 88 1937706 : uint32_t h4 = ((const uint32_t*)seed)[3]; 89 : 90 : #if WORDS_BIGENDIAN 91 : h1 = util_swap32(h1); @@ -156,16 +156,16 @@ 94 : h4 = util_swap32(h4); 95 : #endif 96 : - 97 1936261 : nblocks = size / 16; - 98 1936261 : blocks = data; - 99 1936261 : end = blocks + nblocks * 4; + 97 1937706 : nblocks = size / 16; + 98 1937706 : blocks = data; + 99 1937706 : end = blocks + nblocks * 4; 100 : 101 : /* body */ - 102 103248950 : while (blocks < end) { - 103 99376428 : uint32_t k1 = blocks[0]; - 104 99376428 : uint32_t k2 = blocks[1]; - 105 99376428 : uint32_t k3 = blocks[2]; - 106 99376428 : uint32_t k4 = blocks[3]; + 102 103342191 : while (blocks < end) { + 103 99466779 : uint32_t k1 = blocks[0]; + 104 99466779 : uint32_t k2 = blocks[1]; + 105 99466779 : uint32_t k3 = blocks[2]; + 106 99466779 : uint32_t k4 = blocks[3]; 107 : 108 : #if WORDS_BIGENDIAN 109 : k1 = util_swap32(k1); @@ -174,71 +174,71 @@ 112 : k4 = util_swap32(k4); 113 : #endif 114 : - 115 99376428 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; + 115 99466779 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; 116 : - 117 99376428 : h1 = util_rotl32(h1, 19); h1 += h2; h1 = h1 * 5 + 0x561ccd1b; + 117 99466779 : h1 = util_rotl32(h1, 19); h1 += h2; h1 = h1 * 5 + 0x561ccd1b; 118 : - 119 99376428 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; + 119 99466779 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; 120 : - 121 99376428 : h2 = util_rotl32(h2, 17); h2 += h3; h2 = h2 * 5 + 0x0bcaa747; + 121 99466779 : h2 = util_rotl32(h2, 17); h2 += h3; h2 = h2 * 5 + 0x0bcaa747; 122 : - 123 99376428 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; + 123 99466779 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; 124 : - 125 99376428 : h3 = util_rotl32(h3, 15); h3 += h4; h3 = h3 * 5 + 0x96cd1c35; + 125 99466779 : h3 = util_rotl32(h3, 15); h3 += h4; h3 = h3 * 5 + 0x96cd1c35; 126 : - 127 99376428 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; + 127 99466779 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; 128 : - 129 99376428 : h4 = util_rotl32(h4, 13); h4 += h1; h4 = h4 * 5 + 0x32ac3b17; + 129 99466779 : h4 = util_rotl32(h4, 13); h4 += h1; h4 = h4 * 5 + 0x32ac3b17; 130 : - 131 99376428 : blocks += 4; + 131 99466779 : blocks += 4; 132 : } 133 : 134 : /* tail */ - 135 1936261 : size_remainder = size & 15; - 136 1936261 : if (size_remainder != 0) { - 137 726747 : const uint8_t* tail = (const uint8_t*)blocks; + 135 1937706 : size_remainder = size & 15; + 136 1937706 : if (size_remainder != 0) { + 137 726781 : const uint8_t* tail = (const uint8_t*)blocks; 138 : - 139 726747 : uint32_t k1 = 0; - 140 726747 : uint32_t k2 = 0; - 141 726747 : uint32_t k3 = 0; - 142 726747 : uint32_t k4 = 0; + 139 726781 : uint32_t k1 = 0; + 140 726781 : uint32_t k2 = 0; + 141 726781 : uint32_t k3 = 0; + 142 726781 : uint32_t k4 = 0; 143 : - 144 726747 : switch (size_remainder) { - 145 47814 : case 15 : k4 ^= (uint32_t)tail[14] << 16; - 146 97089 : case 14 : k4 ^= (uint32_t)tail[13] << 8; - 147 145774 : case 13 : k4 ^= (uint32_t)tail[12] << 0; - 148 145774 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; - 149 194991 : case 12 : k3 ^= (uint32_t)tail[11] << 24; - 150 244008 : case 11 : k3 ^= (uint32_t)tail[10] << 16; - 151 292626 : case 10 : k3 ^= (uint32_t)tail[ 9] << 8; - 152 342276 : case 9 : k3 ^= (uint32_t)tail[ 8] << 0; - 153 342276 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; - 154 392525 : case 8 : k2 ^= (uint32_t)tail[ 7] << 24; - 155 438669 : case 7 : k2 ^= (uint32_t)tail[ 6] << 16; - 156 487770 : case 6 : k2 ^= (uint32_t)tail[ 5] << 8; - 157 534928 : case 5 : k2 ^= (uint32_t)tail[ 4] << 0; - 158 534928 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; - 159 583310 : case 4 : k1 ^= (uint32_t)tail[ 3] << 24; - 160 630301 : case 3 : k1 ^= (uint32_t)tail[ 2] << 16; - 161 678080 : case 2 : k1 ^= (uint32_t)tail[ 1] << 8; - 162 726747 : case 1 : k1 ^= (uint32_t)tail[ 0] << 0; - 163 726747 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; + 144 726781 : switch (size_remainder) { + 145 47824 : case 15 : k4 ^= (uint32_t)tail[14] << 16; + 146 97051 : case 14 : k4 ^= (uint32_t)tail[13] << 8; + 147 145725 : case 13 : k4 ^= (uint32_t)tail[12] << 0; + 148 145725 : k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4; + 149 194913 : case 12 : k3 ^= (uint32_t)tail[11] << 24; + 150 243911 : case 11 : k3 ^= (uint32_t)tail[10] << 16; + 151 292582 : case 10 : k3 ^= (uint32_t)tail[ 9] << 8; + 152 342231 : case 9 : k3 ^= (uint32_t)tail[ 8] << 0; + 153 342231 : k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3; + 154 392442 : case 8 : k2 ^= (uint32_t)tail[ 7] << 24; + 155 438596 : case 7 : k2 ^= (uint32_t)tail[ 6] << 16; + 156 487627 : case 6 : k2 ^= (uint32_t)tail[ 5] << 8; + 157 534775 : case 5 : k2 ^= (uint32_t)tail[ 4] << 0; + 158 534775 : k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2; + 159 583246 : case 4 : k1 ^= (uint32_t)tail[ 3] << 24; + 160 630303 : case 3 : k1 ^= (uint32_t)tail[ 2] << 16; + 161 678017 : case 2 : k1 ^= (uint32_t)tail[ 1] << 8; + 162 726781 : case 1 : k1 ^= (uint32_t)tail[ 0] << 0; + 163 726781 : k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1; 164 : } 165 : } 166 : 167 : /* finalization */ - 168 1936261 : h1 ^= size; h2 ^= size; h3 ^= size; h4 ^= size; + 168 1937706 : h1 ^= size; h2 ^= size; h3 ^= size; h4 ^= size; 169 : - 170 1936261 : h1 += h2; h1 += h3; h1 += h4; - 171 1936261 : h2 += h1; h3 += h1; h4 += h1; + 170 1937706 : h1 += h2; h1 += h3; h1 += h4; + 171 1937706 : h2 += h1; h3 += h1; h4 += h1; 172 : - 173 1936261 : h1 = fmix32(h1); - 174 1936261 : h2 = fmix32(h2); - 175 1936261 : h3 = fmix32(h3); - 176 1936261 : h4 = fmix32(h4); + 173 1937706 : h1 = fmix32(h1); + 174 1937706 : h2 = fmix32(h2); + 175 1937706 : h3 = fmix32(h3); + 176 1937706 : h4 = fmix32(h4); 177 : - 178 1936261 : h1 += h2; h1 += h3; h1 += h4; - 179 1936261 : h2 += h1; h3 += h1; h4 += h1; + 178 1937706 : h1 += h2; h1 += h3; h1 += h4; + 179 1937706 : h2 += h1; h3 += h1; h4 += h1; 180 : 181 : #if WORDS_BIGENDIAN 182 : h1 = util_swap32(h1); @@ -247,11 +247,11 @@ 185 : h4 = util_swap32(h4); 186 : #endif 187 : - 188 1936261 : ((uint32_t*)digest)[0] = h1; - 189 1936261 : ((uint32_t*)digest)[1] = h2; - 190 1936261 : ((uint32_t*)digest)[2] = h3; - 191 1936261 : ((uint32_t*)digest)[3] = h4; - 192 1936261 : } + 188 1937706 : ((uint32_t*)digest)[0] = h1; + 189 1937706 : ((uint32_t*)digest)[1] = h2; + 190 1937706 : ((uint32_t*)digest)[2] = h3; + 191 1937706 : ((uint32_t*)digest)[3] = h4; + 192 1937706 : } 193 : diff --git a/cov/cmdline/nano.c.func-sort-c.html b/cov/cmdline/nano.c.func-sort-c.html index 9a6e5795..7ddfdfc9 100644 --- a/cov/cmdline/nano.c.func-sort-c.html +++ b/cov/cmdline/nano.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/nano.c.func.html b/cov/cmdline/nano.c.func.html index 40cd8921..a815de8b 100644 --- a/cov/cmdline/nano.c.func.html +++ b/cov/cmdline/nano.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/nano.c.gcov.html b/cov/cmdline/nano.c.gcov.html index 6c81a29b..89cd4914 100644 --- a/cov/cmdline/nano.c.gcov.html +++ b/cov/cmdline/nano.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 @@ -96,13 +96,13 @@ 34 : tommy_node* j; 35 : 36 : /* for all files */ - 37 5731 : for (j = disk->filelist; j != 0; j = j->next) { - 38 5725 : struct snapraid_file* file = j->data; + 37 5734 : for (j = disk->filelist; j != 0; j = j->next) { + 38 5728 : struct snapraid_file* file = j->data; 39 : 40 : /* if the file has a zero nanosecond timestamp */ 41 : /* note that symbolic links are not in the file list */ 42 : /* and then are not processed */ - 43 5725 : if (file->mtime_nsec == 0) { + 43 5728 : if (file->mtime_nsec == 0) { 44 : char path[PATH_MAX]; 45 : struct stat st; 46 : int f; diff --git a/cov/cmdline/parity.c.func-sort-c.html b/cov/cmdline/parity.c.func-sort-c.html index 9234472e..6f1cd2f7 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-01-09 + 2016-01-16 Functions: 10 @@ -61,31 +61,31 @@ parity_read - 3492991 + 3496527 parity_write - 559380 + 560054 parity_close - 1000 + 1012 parity_allocated_size - 616 + 623 parity_create - 599 + 611 parity_chsize - 599 + 611 parity_sync - 447 + 459 parity_open @@ -93,7 +93,7 @@ parity_used_size - 80 + 82 parity_is_invalid diff --git a/cov/cmdline/parity.c.func.html b/cov/cmdline/parity.c.func.html index 72656e05..bc2d78dc 100644 --- a/cov/cmdline/parity.c.func.html +++ b/cov/cmdline/parity.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -61,19 +61,19 @@ parity_allocated_size - 616 + 623 parity_chsize - 599 + 611 parity_close - 1000 + 1012 parity_create - 599 + 611 parity_is_invalid @@ -89,19 +89,19 @@ parity_read - 3492991 + 3496527 parity_sync - 447 + 459 parity_used_size - 80 + 82 parity_write - 559380 + 560054
diff --git a/cov/cmdline/parity.c.gcov.html b/cov/cmdline/parity.c.gcov.html index ac06a6d2..ef58543a 100644 --- a/cov/cmdline/parity.c.gcov.html +++ b/cov/cmdline/parity.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -88,56 +88,56 @@ 26 : /****************************************************************************/ 27 : /* parity */ 28 : - 29 616 : block_off_t parity_allocated_size(struct snapraid_state* state) + 29 623 : block_off_t parity_allocated_size(struct snapraid_state* state) 30 : { 31 : block_off_t parity_block; 32 : tommy_node* i; 33 : 34 : /* compute the size of the parity file */ - 35 616 : parity_block = 0; - 36 4302 : for (i = state->disklist; i != 0; i = i->next) { - 37 3686 : struct snapraid_disk* disk = i->data; + 35 623 : parity_block = 0; + 36 4351 : for (i = state->disklist; i != 0; i = i->next) { + 37 3728 : struct snapraid_disk* disk = i->data; 38 : 39 : /* start from the declared size */ - 40 3686 : block_off_t block = disk_size(disk); + 40 3728 : block_off_t block = disk_size(disk); 41 : 42 : /* decrease the block until an allocated one, but part of a file */ 43 : /* we don't stop at deleted blocks, because we want to have them cleared */ 44 : /* if they are at the end of the parity */ - 45 128726 : while (block > parity_block && !block_has_file(fs_par2block_get(disk, block - 1))) + 45 128810 : while (block > parity_block && !block_has_file(fs_par2block_get(disk, block - 1))) 46 121354 : --block; 47 : 48 : /* get the highest value */ - 49 3686 : if (block > parity_block) - 50 2201 : parity_block = block; + 49 3728 : if (block > parity_block) + 50 2204 : parity_block = block; 51 : } 52 : - 53 616 : return parity_block; + 53 623 : return parity_block; 54 : } 55 : - 56 80 : block_off_t parity_used_size(struct snapraid_state* state) + 56 82 : block_off_t parity_used_size(struct snapraid_state* state) 57 : { 58 : block_off_t parity_block; 59 : tommy_node* i; 60 : 61 : /* compute the size of the parity file */ - 62 80 : parity_block = 0; - 63 559 : for (i = state->disklist; i != 0; i = i->next) { - 64 479 : struct snapraid_disk* disk = i->data; + 62 82 : parity_block = 0; + 63 573 : for (i = state->disklist; i != 0; i = i->next) { + 64 491 : struct snapraid_disk* disk = i->data; 65 : 66 : /* start from the declared size */ - 67 479 : block_off_t block = disk_size(disk); + 67 491 : block_off_t block = disk_size(disk); 68 : 69 : /* decrease the block until an used one */ - 70 258592 : while (block > parity_block && !block_has_file_and_valid_parity(fs_par2block_get(disk, block - 1))) - 71 257634 : --block; + 70 258661 : while (block > parity_block && !block_has_file_and_valid_parity(fs_par2block_get(disk, block - 1))) + 71 257679 : --block; 72 : 73 : /* get the highest value */ - 74 479 : if (block > parity_block) - 75 259 : parity_block = block; + 74 491 : if (block > parity_block) + 75 261 : parity_block = block; 76 : } 77 : - 78 80 : return parity_block; + 78 82 : return parity_block; 79 : } 80 : 81 1 : int parity_is_invalid(struct snapraid_state* state) @@ -211,20 +211,20 @@ 149 : } 150 : } 151 : - 152 599 : int parity_create(struct snapraid_parity_handle* parity, const char* path, data_off_t* out_size, int mode) + 152 611 : int parity_create(struct snapraid_parity_handle* parity, const char* path, data_off_t* out_size, int mode) 153 : { 154 : int ret; 155 : int flags; 156 : - 157 599 : pathcpy(parity->path, sizeof(parity->path), path); + 157 611 : pathcpy(parity->path, sizeof(parity->path), path); 158 : 159 : /* opening in sequential mode in Windows */ 160 : /* O_SEQUENTIAL: opening in sequential mode in Windows */ - 161 599 : flags = O_RDWR | O_CREAT | O_BINARY; - 162 599 : if ((mode & MODE_SEQUENTIAL) != 0) - 163 599 : flags |= O_SEQUENTIAL; - 164 599 : parity->f = open(parity->path, flags, 0600); - 165 599 : if (parity->f == -1) { + 161 611 : flags = O_RDWR | O_CREAT | O_BINARY; + 162 611 : if ((mode & MODE_SEQUENTIAL) != 0) + 163 611 : flags |= O_SEQUENTIAL; + 164 611 : parity->f = open(parity->path, flags, 0600); + 165 611 : if (parity->f == -1) { 166 : /* LCOV_EXCL_START */ 167 : log_fatal("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno)); 168 : return -1; @@ -232,8 +232,8 @@ 170 : } 171 : 172 : /* get the stat info */ - 173 599 : ret = fstat(parity->f, &parity->st); - 174 599 : if (ret != 0) { + 173 611 : ret = fstat(parity->f, &parity->st); + 174 611 : if (ret != 0) { 175 : /* LCOV_EXCL_START */ 176 : log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); 177 : goto bail; @@ -241,10 +241,10 @@ 179 : } 180 : 181 : #if HAVE_POSIX_FADVISE - 182 599 : if ((mode & MODE_SEQUENTIAL) != 0) { + 182 611 : if ((mode & MODE_SEQUENTIAL) != 0) { 183 : /* advise sequential access */ - 184 599 : ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL); - 185 599 : if (ret != 0) { + 184 611 : ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL); + 185 611 : if (ret != 0) { 186 : /* LCOV_EXCL_START */ 187 : log_fatal("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret)); 188 : goto bail; @@ -254,10 +254,10 @@ 192 : #endif 193 : 194 : /* get the size of the existing data */ - 195 599 : parity->valid_size = parity->st.st_size; - 196 599 : *out_size = parity->st.st_size; + 195 611 : parity->valid_size = parity->st.st_size; + 196 611 : *out_size = parity->st.st_size; 197 : - 198 599 : return 0; + 198 611 : return 0; 199 : 200 : bail: 201 : /* LCOV_EXCL_START */ @@ -268,28 +268,28 @@ 206 : /* LCOV_EXCL_STOP */ 207 : } 208 : - 209 599 : int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_off_t* out_size, int skip_fallocate) + 209 611 : int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_off_t* out_size, int skip_fallocate) 210 : { 211 : int ret; 212 : - 213 599 : if (parity->st.st_size < size) { + 213 611 : if (parity->st.st_size < size) { 214 : int f_ret; 215 : int f_errno; 216 : const char* call; 217 : 218 : #if HAVE_FALLOCATE - 219 95 : call = "fallocate"; - 220 95 : if (!skip_fallocate) { + 219 101 : call = "fallocate"; + 220 101 : if (!skip_fallocate) { 221 : /* allocate real space using the specific Linux fallocate() operation. */ 222 : /* If the underline file-system doesn't support it, this operation fails, */ 223 : /* instead posix_fallocate() fallbacks to write the whole file. */ - 224 94 : ret = fallocate(parity->f, 0, 0, size); + 224 100 : ret = fallocate(parity->f, 0, 0, size); 225 : 226 : /* fallocate() returns the error number as positive integer, */ 227 : /* and in this case it doesn't set errno, just like posix_fallocate() */ 228 : /* Checking the glibc code (2.11.1 and 2.14.1) it seems that ENOSYS */ 229 : /* may be returned in errno, so we support both the return way */ - 230 94 : if (ret > 0) { /* if a positive error is returned, convert it to errno */ + 230 100 : if (ret > 0) { /* if a positive error is returned, convert it to errno */ 231 : /* LCOV_EXCL_START */ 232 : errno = ret; 233 : ret = -1; @@ -302,7 +302,7 @@ 240 : 241 : /* we get EOPNOTSUPP if the operation is not supported, like in ext3/ext2 */ 242 : /* or ENOSYS with kernel before 2.6.23 */ - 243 95 : if (errno == EOPNOTSUPP || errno == ENOSYS) { + 243 101 : if (errno == EOPNOTSUPP || errno == ENOSYS) { 244 : /* fallback using ftruncate() */ 245 1 : call = "ftruncate"; 246 1 : ret = ftruncate(parity->f, size); @@ -315,12 +315,12 @@ 253 : ret = ftruncate(parity->f, size); 254 : #endif 255 : /* save the state of the grow operation */ - 256 95 : f_ret = ret; - 257 95 : f_errno = errno; + 256 101 : f_ret = ret; + 257 101 : f_errno = errno; 258 : 259 : /* get the stat info */ - 260 95 : ret = fstat(parity->f, &parity->st); - 261 95 : if (ret != 0) { + 260 101 : ret = fstat(parity->f, &parity->st); + 261 101 : if (ret != 0) { 262 : /* LCOV_EXCL_START */ 263 : log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); 264 : goto bail; @@ -328,10 +328,10 @@ 266 : } 267 : 268 : /* return the new size */ - 269 95 : *out_size = parity->st.st_size; + 269 101 : *out_size = parity->st.st_size; 270 : 271 : /* now check the error */ - 272 95 : if (f_ret != 0) { + 272 101 : if (f_ret != 0) { 273 : /* LCOV_EXCL_START */ 274 : if (f_errno == ENOSPC) { 275 : log_fatal("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call); @@ -341,7 +341,7 @@ 279 : goto bail; 280 : /* LCOV_EXCL_STOP */ 281 : } - 282 504 : } else if (parity->st.st_size > size) { + 282 510 : } else if (parity->st.st_size > size) { 283 : int f_ret; 284 : int f_errno; 285 : @@ -376,7 +376,7 @@ 314 72 : parity->valid_size = size; 315 : } 316 : - 317 599 : return 0; + 317 611 : return 0; 318 : 319 : bail: 320 : /* LCOV_EXCL_START */ @@ -440,7 +440,7 @@ 378 : /* LCOV_EXCL_STOP */ 379 : } 380 : - 381 447 : int parity_sync(struct snapraid_parity_handle* parity) + 381 459 : int parity_sync(struct snapraid_parity_handle* parity) 382 : { 383 : #if HAVE_FSYNC 384 : int ret; @@ -448,8 +448,8 @@ 386 : /* Ensure that data changes are written to disk. */ 387 : /* This is required to ensure that parity is more updated than content */ 388 : /* in case of a system crash. */ - 389 447 : ret = fsync(parity->f); - 390 447 : if (ret != 0) { + 389 459 : ret = fsync(parity->f); + 390 459 : if (ret != 0) { 391 : /* LCOV_EXCL_START */ 392 : log_fatal("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno)); 393 : return -1; @@ -457,15 +457,15 @@ 395 : } 396 : #endif 397 : - 398 447 : return 0; + 398 459 : return 0; 399 : } 400 : - 401 1000 : int parity_close(struct snapraid_parity_handle* parity) + 401 1012 : int parity_close(struct snapraid_parity_handle* parity) 402 : { 403 : int ret; 404 : - 405 1000 : ret = close(parity->f); - 406 1000 : if (ret != 0) { + 405 1012 : ret = close(parity->f); + 406 1012 : if (ret != 0) { 407 : /* LCOV_EXCL_START */ 408 : /* invalidate for error */ 409 : parity->f = -1; @@ -480,21 +480,21 @@ 418 : } 419 : 420 : /* reset the descriptor */ - 421 1000 : parity->f = -1; - 422 1000 : parity->valid_size = 0; + 421 1012 : parity->f = -1; + 422 1012 : parity->valid_size = 0; 423 : - 424 1000 : return 0; + 424 1012 : return 0; 425 : } 426 : - 427 559380 : int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size) + 427 560054 : int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size) 428 : { 429 : ssize_t write_ret; 430 : data_off_t offset; 431 : - 432 559380 : offset = pos * (data_off_t)block_size; + 432 560054 : offset = pos * (data_off_t)block_size; 433 : 434 : #if HAVE_PWRITE - 435 559380 : write_ret = pwrite(parity->f, block_buffer, block_size, offset); + 435 560054 : write_ret = pwrite(parity->f, block_buffer, block_size, offset); 436 : #else 437 : if (lseek(parity->f, offset, SEEK_SET) != offset) { 438 : /* LCOV_EXCL_START */ @@ -509,7 +509,7 @@ 447 : 448 : write_ret = write(parity->f, block_buffer, block_size); 449 : #endif - 450 559380 : if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */ + 450 560054 : if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */ 451 : /* LCOV_EXCL_START */ 452 : if (errno == ENOSPC) { 453 : log_fatal("Failed to grow parity file '%s' using write due lack of space.\n", parity->path); @@ -521,28 +521,28 @@ 459 : } 460 : 461 : /* adjust the size of the valid data */ - 462 559380 : if (parity->valid_size < offset + block_size) { - 463 171021 : parity->valid_size = offset + block_size; + 462 560054 : if (parity->valid_size < offset + block_size) { + 463 171013 : parity->valid_size = offset + block_size; 464 : } 465 : 466 : /* Here doesn't make sense to call posix_fadvise(..., POSIX_FADV_DONTNEED) because */ 467 : /* at this time the data is still in not yet written and it cannot be discharged. */ 468 : - 469 559380 : return 0; + 469 560054 : return 0; 470 : } 471 : - 472 3492991 : int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out) + 472 3496527 : int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out) 473 : { 474 : ssize_t read_ret; 475 : data_off_t offset; 476 : unsigned count; 477 : - 478 3492991 : offset = pos * (data_off_t)block_size; + 478 3496527 : offset = pos * (data_off_t)block_size; 479 : 480 : /* check if we are going to read only not initialized data */ - 481 3492991 : if (offset >= parity->valid_size) { - 482 90295 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", parity->path, offset); - 483 90295 : return -1; + 481 3496527 : if (offset >= parity->valid_size) { + 482 90335 : out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", parity->path, offset); + 483 90335 : return -1; 484 : } 485 : 486 : #if !HAVE_PREAD @@ -554,36 +554,36 @@ 492 : } 493 : #endif 494 : - 495 3402696 : count = 0; + 495 3406192 : count = 0; 496 : do { 497 : 498 : #if HAVE_PREAD - 499 3402696 : read_ret = pread(parity->f, block_buffer + count, block_size - count, offset + count); + 499 3406192 : read_ret = pread(parity->f, block_buffer + count, block_size - count, offset + count); 500 : #else 501 : read_ret = read(parity->f, block_buffer + count, block_size - count); 502 : #endif - 503 3402696 : if (read_ret < 0) { + 503 3406192 : if (read_ret < 0) { 504 : /* LCOV_EXCL_START */ 505 : out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno)); 506 : return -1; 507 : /* LCOV_EXCL_STOP */ 508 : } - 509 3402696 : if (read_ret == 0) { + 509 3406192 : if (read_ret == 0) { 510 : /* LCOV_EXCL_START */ 511 : out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno)); 512 : return -1; 513 : /* LCOV_EXCL_STOP */ 514 : } 515 : - 516 3402696 : count += read_ret; - 517 3402696 : } while (count < block_size); + 516 3406192 : count += read_ret; + 517 3406192 : } while (count < block_size); 518 : 519 : /* Here isn't needed to call posix_fadvise(..., POSIX_FADV_DONTNEED) */ 520 : /* because we already advised sequential access with POSIX_FADV_SEQUENTIAL. */ 521 : /* In Linux 2.6.33 it's enough to ensure that data is not kept in the cache. */ 522 : /* Better to do nothing and save a syscall for each block. */ 523 : - 524 3402696 : return block_size; + 524 3406192 : return block_size; 525 : } 526 : diff --git a/cov/cmdline/pool.c.func-sort-c.html b/cov/cmdline/pool.c.func-sort-c.html index 227f106b..5f1d9dbc 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-01-09 + 2016-01-16 Functions: 3 @@ -61,7 +61,7 @@ make_link - 17583 + 17589 clean_dir diff --git a/cov/cmdline/pool.c.func.html b/cov/cmdline/pool.c.func.html index a874cb8a..12aa6775 100644 --- a/cov/cmdline/pool.c.func.html +++ b/cov/cmdline/pool.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -65,7 +65,7 @@ make_link - 17583 + 17589 state_pool diff --git a/cov/cmdline/pool.c.gcov.html b/cov/cmdline/pool.c.gcov.html index 3172ab70..ebd8dc77 100644 --- a/cov/cmdline/pool.c.gcov.html +++ b/cov/cmdline/pool.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -107,24 +107,24 @@ 45 : struct dirent* dd; 46 : 47 : /* clear errno to detect erroneous conditions */ - 48 5767 : errno = 0; - 49 5767 : dd = readdir(d); - 50 5767 : if (dd == 0 && errno != 0) { + 48 5768 : errno = 0; + 49 5768 : dd = readdir(d); + 50 5768 : if (dd == 0 && errno != 0) { 51 : /* LCOV_EXCL_START */ 52 : log_fatal("Error reading pool directory '%s'. %s.\n", dir, strerror(errno)); 53 : exit(EXIT_FAILURE); 54 : /* LCOV_EXCL_STOP */ 55 : } - 56 5767 : if (dd == 0 && errno == 0) { + 56 5768 : if (dd == 0 && errno == 0) { 57 5 : break; /* finished */ 58 : } 59 : 60 : /* skip "." and ".." files */ - 61 5762 : name = dd->d_name; - 62 5762 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) + 61 5763 : name = dd->d_name; + 62 5763 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) 63 10 : continue; 64 : - 65 5752 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); + 65 5753 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); 66 : 67 : #if HAVE_STRUCT_DIRENT_D_STAT 68 : /* convert dirent to lstat result */ @@ -142,7 +142,7 @@ 80 : } 81 : #else 82 : /* get lstat info about the file */ - 83 5752 : if (lstat(path_next, &st) != 0) { + 83 5753 : if (lstat(path_next, &st) != 0) { 84 : /* LCOV_EXCL_START */ 85 : log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno)); 86 : exit(EXIT_FAILURE); @@ -150,12 +150,12 @@ 88 : } 89 : #endif 90 : - 91 5752 : if (S_ISLNK(st.st_mode)) { + 91 5753 : if (S_ISLNK(st.st_mode)) { 92 : int ret; 93 : 94 : /* delete the link */ - 95 5750 : ret = remove(path_next); - 96 5750 : if (ret < 0) { + 95 5751 : ret = remove(path_next); + 96 5751 : if (ret < 0) { 97 : /* LCOV_EXCL_START */ 98 : log_fatal("Error removing symlink '%s'. %s.\n", path_next, strerror(errno)); 99 : exit(EXIT_FAILURE); @@ -194,7 +194,7 @@ 132 0 : ignored = 1; 133 0 : msg_verbose("Ignoring pool file '%s'\n", path_next); 134 : } - 135 5762 : } + 135 5763 : } 136 : 137 5 : if (closedir(d) != 0) { 138 : /* LCOV_EXCL_START */ @@ -209,7 +209,7 @@ 147 : /** 148 : * Create a link to the specified disk entry. 149 : */ - 150 17583 : static void make_link(const char* pool_dir, const char* share_dir, struct snapraid_disk* disk, const char* sub) + 150 17589 : static void make_link(const char* pool_dir, const char* share_dir, struct snapraid_disk* disk, const char* sub) 151 : { 152 : char path[PATH_MAX]; 153 : char linkto[PATH_MAX]; @@ -217,33 +217,33 @@ 155 : int ret; 156 : 157 : /* make the source path */ - 158 17583 : pathprint(path, sizeof(path), "%s%s", pool_dir, sub); + 158 17589 : pathprint(path, sizeof(path), "%s%s", pool_dir, sub); 159 : 160 : /* make the linkto path */ - 161 17583 : if (share_dir[0] != 0) { + 161 17589 : if (share_dir[0] != 0) { 162 : /* with a shared directory, use it */ - 163 17583 : pathprint(linkto, sizeof(linkto), "%s%s/%s", share_dir, disk->name, sub); + 163 17589 : pathprint(linkto, sizeof(linkto), "%s%s/%s", share_dir, disk->name, sub); 164 : } else { 165 : /* without a share directory, use the local disk paths */ 166 0 : pathprint(linkto, sizeof(linkto), "%s%s", disk->dir, sub); 167 : } 168 : 169 : /* create the ancestor directories */ - 170 17583 : ret = mkancestor(path); - 171 17583 : if (ret != 0) { + 170 17589 : ret = mkancestor(path); + 171 17589 : if (ret != 0) { 172 : /* LCOV_EXCL_START */ 173 : exit(EXIT_FAILURE); 174 : /* LCOV_EXCL_STOP */ 175 : } 176 : 177 : /* convert back slashes */ - 178 17583 : pathexport(linkto_exported, sizeof(linkto_exported), linkto); + 178 17589 : pathexport(linkto_exported, sizeof(linkto_exported), linkto); 179 : 180 : /* create the symlink */ - 181 17583 : ret = symlink(linkto_exported, path); - 182 17583 : if (ret != 0) { - 183 517 : if (errno == EEXIST) { - 184 517 : log_fatal("WARNING! Duplicate pooling for '%s'\n", path); + 181 17589 : ret = symlink(linkto_exported, path); + 182 17589 : if (ret != 0) { + 183 521 : if (errno == EEXIST) { + 184 521 : log_fatal("WARNING! Duplicate pooling for '%s'\n", path); 185 : #ifdef _WIN32 186 : } else if (errno == EPERM) { 187 : /* LCOV_EXCL_START */ @@ -258,7 +258,7 @@ 196 : /* LCOV_EXCL_STOP */ 197 : } 198 : } - 199 17583 : } + 199 17589 : } 200 : 201 3 : void state_pool(struct snapraid_state* state) 202 : { @@ -296,10 +296,10 @@ 234 18 : struct snapraid_disk* disk = i->data; 235 : 236 : /* for each file */ - 237 17012 : for (j = disk->filelist; j != 0; j = j->next) { - 238 16994 : struct snapraid_file* file = j->data; - 239 16994 : make_link(pool_dir, share_dir, disk, file->sub); - 240 16994 : ++count; + 237 17018 : for (j = disk->filelist; j != 0; j = j->next) { + 238 17000 : struct snapraid_file* file = j->data; + 239 17000 : make_link(pool_dir, share_dir, disk, file->sub); + 240 17000 : ++count; 241 : } 242 : 243 : /* for each link */ diff --git a/cov/cmdline/portable.h.func-sort-c.html b/cov/cmdline/portable.h.func-sort-c.html index 5265a465..d4dc5f83 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-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/portable.h.func.html b/cov/cmdline/portable.h.func.html index c83d5fe3..fbd6b744 100644 --- a/cov/cmdline/portable.h.func.html +++ b/cov/cmdline/portable.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/portable.h.gcov.html b/cov/cmdline/portable.h.gcov.html index c75de15a..88ccb362 100644 --- a/cov/cmdline/portable.h.gcov.html +++ b/cov/cmdline/portable.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/rehash.c.func-sort-c.html b/cov/cmdline/rehash.c.func-sort-c.html index 4ebb089d..c0632cd3 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-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/rehash.c.func.html b/cov/cmdline/rehash.c.func.html index 66f4b11d..a7e56200 100644 --- a/cov/cmdline/rehash.c.func.html +++ b/cov/cmdline/rehash.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/cmdline/rehash.c.gcov.html b/cov/cmdline/rehash.c.gcov.html index a8adc540..ae79cc3b 100644 --- a/cov/cmdline/rehash.c.gcov.html +++ b/cov/cmdline/rehash.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 @@ -126,17 +126,17 @@ 64 : } 65 : 66 : /* mark all the block for rehashing */ - 67 9208 : for (i = 0; i < blockmax; ++i) { + 67 9216 : for (i = 0; i < blockmax; ++i) { 68 : snapraid_info info; 69 : 70 : /* if it's unused */ - 71 9207 : info = info_get(&state->infoarr, i); - 72 9207 : if (info == 0) { + 71 9215 : info = info_get(&state->infoarr, i); + 72 9215 : if (info == 0) { 73 : /* skip it */ 74 0 : continue; 75 : } 76 : - 77 9207 : if (info_get_rehash(info)) { + 77 9215 : if (info_get_rehash(info)) { 78 : /* LCOV_EXCL_START */ 79 : log_fatal("Internal inconsistency for a rehash already in progress\n"); 80 : os_abort(); @@ -144,10 +144,10 @@ 82 : } 83 : 84 : /* enable the rehash */ - 85 9207 : info = info_set_rehash(info); + 85 9215 : info = info_set_rehash(info); 86 : 87 : /* save it */ - 88 9207 : info_set(&state->infoarr, i, info); + 88 9215 : info_set(&state->infoarr, i, info); 89 : } 90 : 91 : /* save the new content file */ diff --git a/cov/cmdline/scan.c.func-sort-c.html b/cov/cmdline/scan.c.func-sort-c.html index c5b96cf3..d7b74b71 100644 --- a/cov/cmdline/scan.c.func-sort-c.html +++ b/cov/cmdline/scan.c.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 554 - 622 - 89.1 % + 557 + 624 + 89.3 % Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -60,47 +60,47 @@ Hit count Sort by hit count - dd_name_compare - 10959090 + dd_name_compare + 10960001 - dstat - 1049496 + dstat + 1049732 - scan_file - 1048310 + scan_file + 1048546 - scan_file_keep - 968997 + scan_file_keep + 969226 file_is_full_invalid_parity_and_stable - 968997 + 969226 scan_file_delayed_allocate - 103840 + 103849 - scan_file_insert - 103840 + scan_file_insert + 103849 scan_file_allocate - 103840 + 103849 - dd_ino_compare - 103366 + dd_ino_compare + 103390 - scan_file_refresh - 79133 + scan_file_refresh + 79140 - scan_file_remove + scan_file_remove 58983 @@ -112,43 +112,43 @@ 34294 - file_is_full_hashed_and_stable - 23661 + file_is_full_hashed_and_stable + 23670 scan_link_insert 2457 - scan_dir - 1713 + scan_dir + 1725 scan_link_remove 956 - scan_emptydir + scan_emptydir 239 - state_diffscan - 88 + state_diffscan + 90 - state_scan - 81 + state_scan + 83 - scan_emptydir_insert + scan_emptydir_insert 10 - state_diff + state_diff 7 - scan_emptydir_remove + scan_emptydir_remove 2 diff --git a/cov/cmdline/scan.c.func.html b/cov/cmdline/scan.c.func.html index 93ca7fe6..4a64fdb8 100644 --- a/cov/cmdline/scan.c.func.html +++ b/cov/cmdline/scan.c.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 554 - 622 - 89.1 % + 557 + 624 + 89.3 % Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -60,48 +60,48 @@ Hit count Sort by hit count - dd_ino_compare - 103366 + dd_ino_compare + 103390 - dd_name_compare - 10959090 + dd_name_compare + 10960001 - dstat - 1049496 + dstat + 1049732 - file_is_full_hashed_and_stable - 23661 + file_is_full_hashed_and_stable + 23670 file_is_full_invalid_parity_and_stable - 968997 + 969226 - scan_dir - 1713 + scan_dir + 1725 - scan_emptydir + scan_emptydir 239 - scan_emptydir_insert + scan_emptydir_insert 10 - scan_emptydir_remove + scan_emptydir_remove 2 - scan_file - 1048310 + scan_file + 1048546 scan_file_allocate - 103840 + 103849 scan_file_deallocate @@ -109,22 +109,22 @@ scan_file_delayed_allocate - 103840 + 103849 - scan_file_insert - 103840 + scan_file_insert + 103849 - scan_file_keep - 968997 + scan_file_keep + 969226 - scan_file_refresh - 79133 + scan_file_refresh + 79140 - scan_file_remove + scan_file_remove 58983 @@ -140,16 +140,16 @@ 956 - state_diff + state_diff 7 - state_diffscan - 88 + state_diffscan + 90 - state_scan - 81 + state_scan + 83
diff --git a/cov/cmdline/scan.c.gcov.html b/cov/cmdline/scan.c.gcov.html index 6fbcb4f0..c7d39c70 100644 --- a/cov/cmdline/scan.c.gcov.html +++ b/cov/cmdline/scan.c.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 554 - 622 - 89.1 % + 557 + 624 + 89.3 % Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -219,72 +219,72 @@ 157 : /** 158 : * Insert the specified file in the parity. 159 : */ - 160 103840 : static void scan_file_allocate(struct snapraid_scan* scan, struct snapraid_file* file) + 160 103849 : static void scan_file_allocate(struct snapraid_scan* scan, struct snapraid_file* file) 161 : { - 162 103840 : struct snapraid_state* state = scan->state; - 163 103840 : struct snapraid_disk* disk = scan->disk; + 162 103849 : struct snapraid_state* state = scan->state; + 163 103849 : struct snapraid_disk* disk = scan->disk; 164 : block_off_t i; 165 : block_off_t parity_pos; 166 : 167 : /* state changed */ - 168 103840 : state->need_write = 1; + 168 103849 : state->need_write = 1; 169 : 170 : /* allocate the blocks of the file */ - 171 103840 : parity_pos = disk->first_free_block; - 172 355546 : for (i = 0; i < file->blockmax; ++i) { + 171 103849 : parity_pos = disk->first_free_block; + 172 355697 : for (i = 0; i < file->blockmax; ++i) { 173 : struct snapraid_block* block; 174 : struct snapraid_block* over_block; 175 : snapraid_info info; 176 : 177 : /* increment the position until the first really free block */ - 178 1072060 : while (block_has_file(fs_par2block_get(disk, parity_pos))) - 179 568648 : ++parity_pos; + 178 1073951 : while (block_has_file(fs_par2block_get(disk, parity_pos))) + 179 570255 : ++parity_pos; 180 : 181 : /* get block we are going to overwrite, if any */ - 182 251706 : over_block = fs_par2block_get(disk, parity_pos); + 182 251848 : over_block = fs_par2block_get(disk, parity_pos); 183 : 184 : /* deallocate it */ - 185 251706 : if (over_block != BLOCK_EMPTY) - 186 95873 : fs_deallocate(disk, parity_pos); + 185 251848 : if (over_block != BLOCK_EMPTY) + 186 95935 : fs_deallocate(disk, parity_pos); 187 : 188 : /* get block specific info */ - 189 251706 : info = info_get(&state->infoarr, parity_pos); + 189 251848 : info = info_get(&state->infoarr, parity_pos); 190 : 191 : /* get the new block we are going to write */ - 192 251706 : block = fs_file2block_get(file, i); + 192 251848 : block = fs_file2block_get(file, i); 193 : 194 : /* if the file block already has an updated hash without rehash */ - 195 251706 : if (block_has_updated_hash(block) && !info_get_rehash(info)) { + 195 251848 : if (block_has_updated_hash(block) && !info_get_rehash(info)) { 196 : /* the only possible case is for REP blocks */ - 197 86941 : assert(block_state_get(block) == BLOCK_STATE_REP); + 197 86985 : assert(block_state_get(block) == BLOCK_STATE_REP); 198 : 199 : /* convert to a REP block */ - 200 86941 : block_state_set(block, BLOCK_STATE_REP); + 200 86985 : block_state_set(block, BLOCK_STATE_REP); 201 : 202 : /* and keep the hash as it's */ 203 : } else { 204 : unsigned over_state; 205 : 206 : /* convert to a CHG block */ - 207 164765 : block_state_set(block, BLOCK_STATE_CHG); + 207 164863 : block_state_set(block, BLOCK_STATE_CHG); 208 : 209 : /* state of the block we are going to overwrite */ - 210 164765 : over_state = block_state_get(over_block); + 210 164863 : over_state = block_state_get(over_block); 211 : 212 : /* if the block is an empty one */ - 213 164765 : if (over_state == BLOCK_STATE_EMPTY) { + 213 164863 : if (over_state == BLOCK_STATE_EMPTY) { 214 : /* the block was empty and filled with zeros */ 215 : /* set the hash to the special ZERO value */ - 216 115487 : hash_zero_set(block->hash); + 216 115543 : hash_zero_set(block->hash); 217 : } else { 218 : /* otherwise it's a DELETED one */ - 219 49278 : assert(over_state == BLOCK_STATE_DELETED); + 219 49320 : assert(over_state == BLOCK_STATE_DELETED); 220 : 221 : /* copy the past hash of the block */ - 222 49278 : memcpy(block->hash, over_block->hash, HASH_SIZE); + 222 49320 : memcpy(block->hash, over_block->hash, HASH_SIZE); 223 : 224 : /* if we have not already cleared the past hash */ - 225 49278 : if (!state->clear_past_hash) { + 225 49320 : if (!state->clear_past_hash) { 226 : /* in this case we don't know if the old state is still the one */ 227 : /* stored inside the parity, because after an aborted sync, the parity */ 228 : /* may be or may be not have been updated with the new data */ @@ -301,15 +301,15 @@ 239 : } 240 : 241 : /* store in the disk map, after invalidating all the other blocks */ - 242 251706 : fs_allocate(disk, parity_pos, file, i); + 242 251848 : fs_allocate(disk, parity_pos, file, i); 243 : 244 : /* set the new free position */ - 245 251706 : disk->first_free_block = parity_pos + 1; + 245 251848 : disk->first_free_block = parity_pos + 1; 246 : } 247 : 248 : /* insert in the list of contained files */ - 249 103840 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); - 250 103840 : } + 249 103849 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); + 250 103849 : } 251 : 252 : /** 253 : * Delete the specified file from the parity. @@ -342,17 +342,17 @@ 280 : } 281 : 282 : /* free all the blocks of the file */ - 283 200146 : for (i = 0; i < file->blockmax; ++i) { - 284 141163 : struct snapraid_block* block = fs_file2block_get(file, i); + 283 200216 : for (i = 0; i < file->blockmax; ++i) { + 284 141233 : struct snapraid_block* block = fs_file2block_get(file, i); 285 : unsigned block_state; 286 : 287 : /* in case we scan after an aborted sync, */ 288 : /* we could get also intermediate states */ - 289 141163 : block_state = block_state_get(block); - 290 141163 : switch (block_state) { + 289 141233 : block_state = block_state_get(block); + 290 141233 : switch (block_state) { 291 : case BLOCK_STATE_BLK : 292 : /* we keep the hash making it an "old" hash, because the parity is still containing data for it */ - 293 33358 : break; + 293 33404 : break; 294 : case BLOCK_STATE_CHG : 295 : /* if we have not already cleared the past hash */ 296 28000 : if (!state->clear_past_hash) { @@ -372,8 +372,8 @@ 310 28000 : break; 311 : case BLOCK_STATE_REP : 312 : /* we just don't know the old hash, and then we set it to invalid */ - 313 79805 : hash_invalid_set(block->hash); - 314 79805 : break; + 313 79829 : hash_invalid_set(block->hash); + 314 79829 : break; 315 : default : 316 : /* LCOV_EXCL_START */ 317 : log_fatal("Internal inconsistency in file '%s' deallocating block '%u:%u' state %u\n", file->sub, i, file->blockmax, block_state); @@ -382,7 +382,7 @@ 320 : } 321 : 322 : /* set the block as deleted */ - 323 141163 : block_state_set(block, BLOCK_STATE_DELETED); + 323 141233 : block_state_set(block, BLOCK_STATE_DELETED); 324 : } 325 : 326 : /* mark the file as deleted */ @@ -392,13 +392,13 @@ 330 58983 : tommy_list_insert_tail(&disk->deletedlist, &file->nodelist, file); 331 58983 : } 332 : - 333 103840 : static void scan_file_delayed_allocate(struct snapraid_scan* scan, struct snapraid_file* file) + 333 103849 : static void scan_file_delayed_allocate(struct snapraid_scan* scan, struct snapraid_file* file) 334 : { - 335 103840 : struct snapraid_state* state = scan->state; - 336 103840 : struct snapraid_disk* disk = scan->disk; + 335 103849 : struct snapraid_state* state = scan->state; + 336 103849 : struct snapraid_disk* disk = scan->disk; 337 : 338 : /* if we sort for physical offsets we have to read them for new files */ - 339 103840 : if (state->opt.force_order == SORT_PHYSICAL + 339 103849 : if (state->opt.force_order == SORT_PHYSICAL 340 11432 : && file->physical == FILEPHY_UNREAD_OFFSET 341 : ) { 342 : char path_next[PATH_MAX]; @@ -414,1495 +414,1505 @@ 352 : } 353 : 354 : /* insert in the delayed list */ - 355 103840 : tommy_list_insert_tail(&scan->file_insert_list, &file->nodelist, file); - 356 103840 : } + 355 103849 : tommy_list_insert_tail(&scan->file_insert_list, &file->nodelist, file); + 356 103849 : } 357 : 358 : /** 359 : * Check if a file is completely formed of blocks with invalid parity, 360 : * and no rehash is tagged, and if it has at least one block. 361 : */ - 362 968997 : static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) + 362 969226 : static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) 363 : { 364 : block_off_t i; 365 : 366 : /* with no block, it never has an invalid parity */ - 367 968997 : if (file->blockmax == 0) - 368 1354 : return 0; + 367 969226 : if (file->blockmax == 0) + 368 1353 : return 0; 369 : 370 : /* check all blocks */ - 371 1032530 : for (i = 0; i < file->blockmax; ++i) { + 371 1032782 : for (i = 0; i < file->blockmax; ++i) { 372 : snapraid_info info; - 373 1007823 : struct snapraid_block* block = fs_file2block_get(file, i); + 373 1008073 : struct snapraid_block* block = fs_file2block_get(file, i); 374 : block_off_t parity_pos; 375 : 376 : /* exclude blocks with parity */ - 377 1007823 : if (!block_has_invalid_parity(block)) - 378 923696 : return 0; + 377 1008073 : if (!block_has_invalid_parity(block)) + 378 923921 : return 0; 379 : 380 : /* - 381 : * Get the parity position, but only after checking - 382 : * that the file has invalid parity. - 383 : * This is not really required, as we are sure - 384 : * that 'kept" files are mapped into parity. - 385 : */ - 386 84127 : parity_pos = fs_file2par_get(disk, file, i); - 387 : - 388 : /* get block specific info */ - 389 84127 : info = info_get(&state->infoarr, parity_pos); - 390 : - 391 : /* if rehash fails */ - 392 84127 : if (info_get_rehash(info)) - 393 19240 : return 0; - 394 : } - 395 : - 396 24707 : return 1; - 397 : } - 398 : - 399 : /** - 400 : * Check if a file is completely formed of blocks with an updated hash, - 401 : * and no rehash is tagged, and if it has at least one block. - 402 : */ - 403 23661 : static int file_is_full_hashed_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) - 404 : { - 405 : block_off_t i; - 406 : - 407 : /* with no block, it never has a hash */ - 408 23661 : if (file->blockmax == 0) - 409 27 : return 0; - 410 : - 411 : /* check all blocks */ - 412 81853 : for (i = 0; i < file->blockmax; ++i) { - 413 : snapraid_info info; - 414 58220 : struct snapraid_block* block = fs_file2block_get(file, i); - 415 : block_off_t parity_pos; - 416 : - 417 : /* exclude blocks without hash */ - 418 58220 : if (!block_has_updated_hash(block)) - 419 1 : return 0; - 420 : - 421 : /* - 422 : * Get the parity position, but only AFTER checking - 423 : * that the file has an updated hash. - 424 : * This is required because not hashed files may be - 425 : * not yet mapped into parity. - 426 : * - 427 : * This happens when a new file is in the delayed insertion - 428 : * list, and scan finds a copy of it, and it tries to copy - 429 : * the hash info. - 430 : * As just allocated files have only CHG blocks, checking that - 431 : * the hash is updated is enough to exclude such cases. - 432 : */ - 433 58219 : parity_pos = fs_file2par_get(disk, file, i); - 434 : - 435 : /* get block specific info */ - 436 58219 : info = info_get(&state->infoarr, parity_pos); - 437 : - 438 : /* exclude blocks needing a rehash */ - 439 58219 : if (info_get_rehash(info)) - 440 0 : return 0; - 441 : } - 442 : - 443 23633 : return 1; - 444 : } - 445 : - 446 : /** - 447 : * Refresh the file info. - 448 : * - 449 : * This is needed by Windows as the normal way to list directories may report not - 450 : * updated info. Only the GetFileInformationByHandle() func, called file-by-file, - 451 : * really ensures to return synced info. - 452 : * - 453 : * If this happens, we read also the physical offset, to avoid to read it later. - 454 : */ - 455 79133 : static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struct stat* st, uint64_t* physical) - 456 : { - 457 : #if HAVE_LSTAT_SYNC - 458 : struct snapraid_state* state = scan->state; - 459 : struct snapraid_disk* disk = scan->disk; - 460 : - 461 : /* if the st_sync is not set, ensure to get synced info */ - 462 : if (st->st_sync == 0) { - 463 : char path_next[PATH_MAX]; - 464 : struct stat synced_st; - 465 : - 466 : pathprint(path_next, sizeof(path_next), "%s%s", disk->dir, sub); - 467 : - 468 : /* if we sort for physical offsets we have to read them for new files */ - 469 : if (state->opt.force_order == SORT_PHYSICAL - 470 : && *physical == FILEPHY_UNREAD_OFFSET - 471 : ) { - 472 : /* do nothing, leave the pointer to read the physical offset */ - 473 : } else { - 474 : physical = 0; /* set the pointer to 0 to read nothing */ - 475 : } - 476 : - 477 : if (lstat_sync(path_next, &synced_st, physical) != 0) { - 478 : /* LCOV_EXCL_START */ - 479 : log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno)); - 480 : exit(EXIT_FAILURE); - 481 : /* LCOV_EXCL_STOP */ - 482 : } - 483 : - 484 : if (st->st_mtime != synced_st.st_mtime - 485 : || st->st_mtimensec != synced_st.st_mtimensec - 486 : ) { - 487 : #ifndef _WIN32 - 488 : /* - 489 : * In Windows having different metadata is expected with open files - 490 : * because the metadata in the directory is updated only when the file - 491 : * is closed. - 492 : * - 493 : * See also: - 494 : * Why is the file size reported incorrectly for files that are still being written to? - 495 : * http://blogs.msdn.com/b/oldnewthing/archive/2011/12/26/10251026.aspx - 496 : */ - 497 : log_fatal("WARNING! Detected uncached time change for file '%s'\n", sub); - 498 : log_fatal("It's better if you run SnapRAID without other processes running.\n"); - 499 : #endif - 500 : st->st_mtime = synced_st.st_mtime; - 501 : st->st_mtimensec = synced_st.st_mtimensec; - 502 : } - 503 : - 504 : if (st->st_size != synced_st.st_size) { - 505 : #ifndef _WIN32 - 506 : log_fatal("WARNING! Detected uncached size change for file '%s'\n", sub); - 507 : log_fatal("It's better if you run SnapRAID without other processes running.\n"); - 508 : #endif - 509 : st->st_size = synced_st.st_size; - 510 : } - 511 : - 512 : if (st->st_ino != synced_st.st_ino) { - 513 : log_fatal("DANGER! Detected uncached inode change for file '%s'\n", sub); - 514 : log_fatal("Please ensure to run SnapRAID without other processes running.\n"); - 515 : /* at this point, it's too late to change inode */ - 516 : /* and having inconsistent inodes may result to internal failures */ - 517 : /* so, it's better to abort */ - 518 : exit(EXIT_FAILURE); - 519 : } - 520 : } - 521 : #else - 522 : (void)scan; - 523 : (void)sub; - 524 : (void)st; - 525 : (void)physical; - 526 : #endif - 527 79133 : } - 528 : - 529 : /** - 530 : * Insert the file in the data set. - 531 : */ - 532 103840 : static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* file) - 533 : { - 534 103840 : struct snapraid_disk* disk = scan->disk; - 535 : - 536 : /* insert the file in the containers */ - 537 103840 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) - 538 103840 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 539 103840 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); - 540 103840 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); - 541 : - 542 : /* delayed allocation of the parity */ - 543 103840 : scan_file_delayed_allocate(scan, file); - 544 103840 : } + 381 : * Get the parity position. + 382 : * + 383 : * Note that here we expect to always have mapped + 384 : * parity, because kept files always have it. + 385 : * + 386 : * Anyway, checking for POS_INVALID doesn't hurt. + 387 : */ + 388 84152 : parity_pos = fs_file2par_maybe(disk, file, i); + 389 : + 390 : /* if it's not mapped, it cannot have rehash */ + 391 84152 : if (parity_pos != POS_INVALID) { + 392 : /* get block specific info */ + 393 84152 : info = info_get(&state->infoarr, parity_pos); + 394 : + 395 : /* if rehash fails */ + 396 84152 : if (info_get_rehash(info)) + 397 19243 : return 0; + 398 : } + 399 : } + 400 : + 401 24709 : return 1; + 402 : } + 403 : + 404 : /** + 405 : * Check if a file is completely formed of blocks with an updated hash, + 406 : * and no rehash is tagged, and if it has at least one block. + 407 : */ + 408 23670 : static int file_is_full_hashed_and_stable(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file) + 409 : { + 410 : block_off_t i; + 411 : + 412 : /* with no block, it never has a hash */ + 413 23670 : if (file->blockmax == 0) + 414 27 : return 0; + 415 : + 416 : /* check all blocks */ + 417 81886 : for (i = 0; i < file->blockmax; ++i) { + 418 : snapraid_info info; + 419 58250 : struct snapraid_block* block = fs_file2block_get(file, i); + 420 : block_off_t parity_pos; + 421 : + 422 : /* exclude blocks without hash */ + 423 58250 : if (!block_has_updated_hash(block)) + 424 7 : return 0; + 425 : + 426 : /* + 427 : * Get the parity position. + 428 : * + 429 : * Note that it's possible to have files + 430 : * not mapped into the parity, even if they + 431 : * have a valid hash. + 432 : * + 433 : * This happens for example, for 'copied' files + 434 : * that have REP blocks, but not yet mapped. + 435 : * + 436 : * If there are multiple copies, it's also possible + 437 : * that such files are used as 'source' to copy + 438 : * hashes, and then to get them inside this function. + 439 : */ + 440 58243 : parity_pos = fs_file2par_maybe(disk, file, i); + 441 : + 442 : /* if it's not mapped, it cannot have rehash */ + 443 58243 : if (parity_pos != POS_INVALID) { + 444 : /* get block specific info */ + 445 58235 : info = info_get(&state->infoarr, parity_pos); + 446 : + 447 : /* exclude blocks needing a rehash */ + 448 58235 : if (info_get_rehash(info)) + 449 0 : return 0; + 450 : } + 451 : } + 452 : + 453 23636 : return 1; + 454 : } + 455 : + 456 : /** + 457 : * Refresh the file info. + 458 : * + 459 : * This is needed by Windows as the normal way to list directories may report not + 460 : * updated info. Only the GetFileInformationByHandle() func, called file-by-file, + 461 : * really ensures to return synced info. + 462 : * + 463 : * If this happens, we read also the physical offset, to avoid to read it later. + 464 : */ + 465 79140 : static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struct stat* st, uint64_t* physical) + 466 : { + 467 : #if HAVE_LSTAT_SYNC + 468 : struct snapraid_state* state = scan->state; + 469 : struct snapraid_disk* disk = scan->disk; + 470 : + 471 : /* if the st_sync is not set, ensure to get synced info */ + 472 : if (st->st_sync == 0) { + 473 : char path_next[PATH_MAX]; + 474 : struct stat synced_st; + 475 : + 476 : pathprint(path_next, sizeof(path_next), "%s%s", disk->dir, sub); + 477 : + 478 : /* if we sort for physical offsets we have to read them for new files */ + 479 : if (state->opt.force_order == SORT_PHYSICAL + 480 : && *physical == FILEPHY_UNREAD_OFFSET + 481 : ) { + 482 : /* do nothing, leave the pointer to read the physical offset */ + 483 : } else { + 484 : physical = 0; /* set the pointer to 0 to read nothing */ + 485 : } + 486 : + 487 : if (lstat_sync(path_next, &synced_st, physical) != 0) { + 488 : /* LCOV_EXCL_START */ + 489 : log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno)); + 490 : exit(EXIT_FAILURE); + 491 : /* LCOV_EXCL_STOP */ + 492 : } + 493 : + 494 : if (st->st_mtime != synced_st.st_mtime + 495 : || st->st_mtimensec != synced_st.st_mtimensec + 496 : ) { + 497 : #ifndef _WIN32 + 498 : /* + 499 : * In Windows having different metadata is expected with open files + 500 : * because the metadata in the directory is updated only when the file + 501 : * is closed. + 502 : * + 503 : * See also: + 504 : * Why is the file size reported incorrectly for files that are still being written to? + 505 : * http://blogs.msdn.com/b/oldnewthing/archive/2011/12/26/10251026.aspx + 506 : */ + 507 : log_fatal("WARNING! Detected uncached time change for file '%s'\n", sub); + 508 : log_fatal("It's better if you run SnapRAID without other processes running.\n"); + 509 : #endif + 510 : st->st_mtime = synced_st.st_mtime; + 511 : st->st_mtimensec = synced_st.st_mtimensec; + 512 : } + 513 : + 514 : if (st->st_size != synced_st.st_size) { + 515 : #ifndef _WIN32 + 516 : log_fatal("WARNING! Detected uncached size change for file '%s'\n", sub); + 517 : log_fatal("It's better if you run SnapRAID without other processes running.\n"); + 518 : #endif + 519 : st->st_size = synced_st.st_size; + 520 : } + 521 : + 522 : if (st->st_ino != synced_st.st_ino) { + 523 : log_fatal("DANGER! Detected uncached inode change for file '%s'\n", sub); + 524 : log_fatal("Please ensure to run SnapRAID without other processes running.\n"); + 525 : /* at this point, it's too late to change inode */ + 526 : /* and having inconsistent inodes may result to internal failures */ + 527 : /* so, it's better to abort */ + 528 : exit(EXIT_FAILURE); + 529 : } + 530 : } + 531 : #else + 532 : (void)scan; + 533 : (void)sub; + 534 : (void)st; + 535 : (void)physical; + 536 : #endif + 537 79140 : } + 538 : + 539 : /** + 540 : * Insert the file in the data set. + 541 : */ + 542 103849 : static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* file) + 543 : { + 544 103849 : struct snapraid_disk* disk = scan->disk; 545 : - 546 : /** - 547 : * Remove the file from the data set. - 548 : * - 549 : * File is then deleted. - 550 : */ - 551 58983 : static void scan_file_remove(struct snapraid_scan* scan, struct snapraid_file* file) - 552 : { - 553 58983 : struct snapraid_disk* disk = scan->disk; - 554 : - 555 : /* remove the file from the containers */ - 556 58983 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) - 557 58942 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); - 558 58983 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); - 559 58983 : tommy_hashdyn_remove_existing(&disk->stampset, &file->stampset); - 560 : - 561 : /* deallocate the file from the parity */ - 562 58983 : scan_file_deallocate(scan, file); - 563 58983 : } + 546 : /* insert the file in the containers */ + 547 103849 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) + 548 103849 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 549 103849 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); + 550 103849 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); + 551 : + 552 : /* delayed allocation of the parity */ + 553 103849 : scan_file_delayed_allocate(scan, file); + 554 103849 : } + 555 : + 556 : /** + 557 : * Remove the file from the data set. + 558 : * + 559 : * File is then deleted. + 560 : */ + 561 58983 : static void scan_file_remove(struct snapraid_scan* scan, struct snapraid_file* file) + 562 : { + 563 58983 : struct snapraid_disk* disk = scan->disk; 564 : - 565 : /** - 566 : * Keep the file as it's (or with only a name/inode modification). - 567 : * - 568 : * If the file is kept, nothing has to be done. - 569 : * - 570 : * But if a file contains only blocks with invalid parity, it's reallocated to ensure - 571 : * to always minimize the space used in the parity. - 572 : * - 573 : * This could happen after a failed sync, when some other files are deleted, - 574 : * and then new ones can be moved backward to fill the hole created. - 575 : */ - 576 968997 : static void scan_file_keep(struct snapraid_scan* scan, struct snapraid_file* file) - 577 : { - 578 968997 : struct snapraid_disk* disk = scan->disk; - 579 : - 580 : /* if the file is full invalid, schedule a reinsert at later stage */ - 581 968997 : if (file_is_full_invalid_parity_and_stable(scan->state, disk, file)) { - 582 24707 : struct snapraid_file* copy = file_dup(file); - 583 : - 584 : /* remove the file */ - 585 24707 : scan_file_remove(scan, file); - 586 : - 587 : /* reinsert the copy in the delayed list */ - 588 24707 : scan_file_insert(scan, copy); - 589 : } - 590 968997 : } - 591 : - 592 : /** - 593 : * Process a file. - 594 : */ - 595 1048310 : static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub, struct stat* st, uint64_t physical) - 596 : { - 597 1048310 : struct snapraid_state* state = scan->state; - 598 1048310 : struct snapraid_disk* disk = scan->disk; - 599 : struct snapraid_file* file; - 600 : tommy_node* i; - 601 : int is_original_file_size_different_than_zero; - 602 : int is_file_already_present; - 603 : int is_file_reported; - 604 : - 605 : /* - 606 : * If the disk has persistent inodes and UUID, try a search on the past inodes, - 607 : * to detect moved files. - 608 : * - 609 : * For persistent inodes we mean inodes that keep their values when the file-system - 610 : * is unmounted and remounted. This don't always happen. - 611 : * - 612 : * Cases found are: - 613 : * - Linux FUSE with exFAT driver from https://code.google.com/p/exfat/. - 614 : * Inodes are reassigned at every mount restarting from 1 and incrementing. - 615 : * As worse, the exFAT support in FUSE doesn't use subsecond precision in timestamps - 616 : * making inode collision more easy (exFAT by design supports 10ms precision). - 617 : * - Linux VFAT kernel (3.2) driver. Inodes are fully reassigned at every mount. + 565 : /* remove the file from the containers */ + 566 58983 : if (!file_flag_has(file, FILE_IS_WITHOUT_INODE)) + 567 58940 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 568 58983 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); + 569 58983 : tommy_hashdyn_remove_existing(&disk->stampset, &file->stampset); + 570 : + 571 : /* deallocate the file from the parity */ + 572 58983 : scan_file_deallocate(scan, file); + 573 58983 : } + 574 : + 575 : /** + 576 : * Keep the file as it's (or with only a name/inode modification). + 577 : * + 578 : * If the file is kept, nothing has to be done. + 579 : * + 580 : * But if a file contains only blocks with invalid parity, it's reallocated to ensure + 581 : * to always minimize the space used in the parity. + 582 : * + 583 : * This could happen after a failed sync, when some other files are deleted, + 584 : * and then new ones can be moved backward to fill the hole created. + 585 : */ + 586 969226 : static void scan_file_keep(struct snapraid_scan* scan, struct snapraid_file* file) + 587 : { + 588 969226 : struct snapraid_disk* disk = scan->disk; + 589 : + 590 : /* if the file is full invalid, schedule a reinsert at later stage */ + 591 969226 : if (file_is_full_invalid_parity_and_stable(scan->state, disk, file)) { + 592 24709 : struct snapraid_file* copy = file_dup(file); + 593 : + 594 : /* remove the file */ + 595 24709 : scan_file_remove(scan, file); + 596 : + 597 : /* reinsert the copy in the delayed list */ + 598 24709 : scan_file_insert(scan, copy); + 599 : } + 600 969226 : } + 601 : + 602 : /** + 603 : * Process a file. + 604 : */ + 605 1048546 : static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub, struct stat* st, uint64_t physical) + 606 : { + 607 1048546 : struct snapraid_state* state = scan->state; + 608 1048546 : struct snapraid_disk* disk = scan->disk; + 609 : struct snapraid_file* file; + 610 : tommy_node* i; + 611 : int is_original_file_size_different_than_zero; + 612 : int is_file_already_present; + 613 : int is_file_reported; + 614 : + 615 : /* + 616 : * If the disk has persistent inodes and UUID, try a search on the past inodes, + 617 : * to detect moved files. 618 : * - 619 : * In such cases, to avoid possible random collisions, it's better to disable the moved - 620 : * file recognition. + 619 : * For persistent inodes we mean inodes that keep their values when the file-system + 620 : * is unmounted and remounted. This don't always happen. 621 : * - 622 : * For persistent UUID we mean that it has the same UUID as before. - 623 : * Otherwise, if the UUID is changed, likely it's a new recreated file-system, - 624 : * and then the inode have no meaning. - 625 : * - 626 : * Note that to disable the search by past inode, we do this implicitly - 627 : * removing all the past inode before searching for files. - 628 : * This ensures that no file is found with a past inode, but at the same time, - 629 : * it allows to find new files with the same inode, to identify them as hardlinks. - 630 : */ - 631 1048310 : int has_past_inodes = !disk->has_volatile_inodes && !disk->has_different_uuid && !disk->has_unsupported_uuid; - 632 : - 633 : /* always search with the new inode, in the all new inodes found until now, */ - 634 : /* with the eventual presence of also the past inodes */ - 635 1048310 : uint64_t inode = st->st_ino; - 636 : - 637 1048310 : file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); - 638 : - 639 : /* identify moved files with past inodes and hardlinks with the new inodes */ - 640 1048310 : if (file) { - 641 : /* check if the file is not changed */ - 642 889551 : if (file->size == st->st_size - 643 871917 : && file->mtime_sec == st->st_mtime - 644 868905 : && (file->mtime_nsec == STAT_NSEC(st) - 645 : /* always accept the stored value if it's STAT_NSEC_INVALID */ - 646 : /* it happens when upgrading from an old version of SnapRAID */ - 647 : /* not yet supporting the nanosecond field */ - 648 6 : || file->mtime_nsec == STAT_NSEC_INVALID - 649 : ) - 650 : ) { - 651 : /* check if multiple files have the same inode */ - 652 868899 : if (file_flag_has(file, FILE_IS_PRESENT)) { - 653 : #if HAVE_STRUCT_STAT_ST_NLINK - 654 180 : if (st->st_nlink <= 1) { - 655 : /* LCOV_EXCL_START */ - 656 : log_fatal("Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub); - 657 : os_abort(); - 658 : /* LCOV_EXCL_STOP */ - 659 : } - 660 : #endif - 661 : /* it's a hardlink */ - 662 180 : scan_link(scan, is_diff, sub, file->sub, FILE_IS_HARDLINK); - 663 180 : return; - 664 : } - 665 : - 666 : /* mark as present */ - 667 868719 : file_flag_set(file, FILE_IS_PRESENT); - 668 : - 669 : /* update the nanoseconds mtime only if different */ - 670 : /* to avoid unneeded updates */ - 671 868719 : if (file->mtime_nsec == STAT_NSEC_INVALID - 672 0 : && STAT_NSEC(st) != file->mtime_nsec - 673 : ) { - 674 0 : file->mtime_nsec = STAT_NSEC(st); + 622 : * Cases found are: + 623 : * - Linux FUSE with exFAT driver from https://code.google.com/p/exfat/. + 624 : * Inodes are reassigned at every mount restarting from 1 and incrementing. + 625 : * As worse, the exFAT support in FUSE doesn't use subsecond precision in timestamps + 626 : * making inode collision more easy (exFAT by design supports 10ms precision). + 627 : * - Linux VFAT kernel (3.2) driver. Inodes are fully reassigned at every mount. + 628 : * + 629 : * In such cases, to avoid possible random collisions, it's better to disable the moved + 630 : * file recognition. + 631 : * + 632 : * For persistent UUID we mean that it has the same UUID as before. + 633 : * Otherwise, if the UUID is changed, likely it's a new recreated file-system, + 634 : * and then the inode have no meaning. + 635 : * + 636 : * Note that to disable the search by past inode, we do this implicitly + 637 : * removing all the past inode before searching for files. + 638 : * This ensures that no file is found with a past inode, but at the same time, + 639 : * it allows to find new files with the same inode, to identify them as hardlinks. + 640 : */ + 641 1048546 : int has_past_inodes = !disk->has_volatile_inodes && !disk->has_different_uuid && !disk->has_unsupported_uuid; + 642 : + 643 : /* always search with the new inode, in the all new inodes found until now, */ + 644 : /* with the eventual presence of also the past inodes */ + 645 1048546 : uint64_t inode = st->st_ino; + 646 : + 647 1048546 : file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode)); + 648 : + 649 : /* identify moved files with past inodes and hardlinks with the new inodes */ + 650 1048546 : if (file) { + 651 : /* check if the file is not changed */ + 652 890409 : if (file->size == st->st_size + 653 873833 : && file->mtime_sec == st->st_mtime + 654 870810 : && (file->mtime_nsec == STAT_NSEC(st) + 655 : /* always accept the stored value if it's STAT_NSEC_INVALID */ + 656 : /* it happens when upgrading from an old version of SnapRAID */ + 657 : /* not yet supporting the nanosecond field */ + 658 7 : || file->mtime_nsec == STAT_NSEC_INVALID + 659 : ) + 660 : ) { + 661 : /* check if multiple files have the same inode */ + 662 870803 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 663 : #if HAVE_STRUCT_STAT_ST_NLINK + 664 180 : if (st->st_nlink <= 1) { + 665 : /* LCOV_EXCL_START */ + 666 : log_fatal("Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub); + 667 : os_abort(); + 668 : /* LCOV_EXCL_STOP */ + 669 : } + 670 : #endif + 671 : /* it's a hardlink */ + 672 180 : scan_link(scan, is_diff, sub, file->sub, FILE_IS_HARDLINK); + 673 180 : return; + 674 : } 675 : - 676 : /* we have to save the new mtime */ - 677 0 : state->need_write = 1; - 678 : } - 679 : - 680 868719 : if (strcmp(file->sub, sub) != 0) { - 681 : /* if the path is different, it means a moved file with the same inode */ - 682 155 : ++scan->count_move; - 683 : - 684 155 : log_tag("scan:move:%s:%s:%s\n", disk->name, esc(file->sub), esc(sub)); - 685 155 : if (is_diff) { - 686 0 : printf("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub); - 687 : } - 688 : - 689 : /* remove from the name set */ - 690 155 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); - 691 : - 692 : /* save the new name */ - 693 155 : file_rename(file, sub); - 694 : - 695 : /* reinsert in the name set */ - 696 155 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); - 697 : - 698 : /* we have to save the new name */ - 699 155 : state->need_write = 1; - 700 : } else { - 701 : /* otherwise it's equal */ - 702 868564 : ++scan->count_equal; - 703 : - 704 868564 : if (state->opt.gui) { - 705 22587 : log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub)); - 706 : } - 707 : } - 708 : - 709 : /* mark the file as kept */ - 710 868719 : scan_file_keep(scan, file); - 711 : - 712 : /* nothing more to do */ - 713 868719 : return; - 714 : } - 715 : - 716 : /* here the file matches the inode, but not the other info */ - 717 : /* if could be a modified file with the same name, */ - 718 : /* or a restored/copied file that get assigned a previously used inode, */ - 719 : /* or a file-system with not persistent inodes */ - 720 : - 721 : /* for sure it cannot be already present */ - 722 20652 : if (file_flag_has(file, FILE_IS_PRESENT)) { - 723 : /* LCOV_EXCL_START */ - 724 : 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); - 725 : os_abort(); - 726 : /* LCOV_EXCL_STOP */ - 727 : } - 728 : - 729 : /* assume a previously used inode, it's the worst case */ - 730 : /* and we handle it removing the duplicate stored inode. */ - 731 : /* If the file is found by name (not necessarily in this function call), */ - 732 : /* it will have the inode restored, otherwise, it will get removed */ - 733 : - 734 : /* remove from the inode set */ - 735 20652 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); - 736 : - 737 : /* clear the inode */ - 738 : /* this is not really needed for correct functionality */ - 739 : /* because we are going to set FILE_IS_WITHOUT_INODE */ - 740 : /* but it's easier for debugging to have invalid inodes set to 0 */ - 741 20652 : file->inode = 0; - 742 : - 743 : /* mark as missing inode */ - 744 20652 : file_flag_set(file, FILE_IS_WITHOUT_INODE); - 745 : - 746 : /* go further to find it by name */ - 747 : } - 748 : - 749 : /* initialize for later overwrite */ - 750 179411 : is_file_reported = 0; - 751 179411 : is_original_file_size_different_than_zero = 0; + 676 : /* mark as present */ + 677 870623 : file_flag_set(file, FILE_IS_PRESENT); + 678 : + 679 : /* update the nanoseconds mtime only if different */ + 680 : /* to avoid unneeded updates */ + 681 870623 : if (file->mtime_nsec == STAT_NSEC_INVALID + 682 0 : && STAT_NSEC(st) != file->mtime_nsec + 683 : ) { + 684 0 : file->mtime_nsec = STAT_NSEC(st); + 685 : + 686 : /* we have to save the new mtime */ + 687 0 : state->need_write = 1; + 688 : } + 689 : + 690 870623 : if (strcmp(file->sub, sub) != 0) { + 691 : /* if the path is different, it means a moved file with the same inode */ + 692 155 : ++scan->count_move; + 693 : + 694 155 : log_tag("scan:move:%s:%s:%s\n", disk->name, esc(file->sub), esc(sub)); + 695 155 : if (is_diff) { + 696 0 : printf("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub); + 697 : } + 698 : + 699 : /* remove from the name set */ + 700 155 : tommy_hashdyn_remove_existing(&disk->pathset, &file->pathset); + 701 : + 702 : /* save the new name */ + 703 155 : file_rename(file, sub); + 704 : + 705 : /* reinsert in the name set */ + 706 155 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); + 707 : + 708 : /* we have to save the new name */ + 709 155 : state->need_write = 1; + 710 : } else { + 711 : /* otherwise it's equal */ + 712 870468 : ++scan->count_equal; + 713 : + 714 870468 : if (state->opt.gui) { + 715 22599 : log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub)); + 716 : } + 717 : } + 718 : + 719 : /* mark the file as kept */ + 720 870623 : scan_file_keep(scan, file); + 721 : + 722 : /* nothing more to do */ + 723 870623 : return; + 724 : } + 725 : + 726 : /* here the file matches the inode, but not the other info */ + 727 : /* if could be a modified file with the same name, */ + 728 : /* or a restored/copied file that get assigned a previously used inode, */ + 729 : /* or a file-system with not persistent inodes */ + 730 : + 731 : /* for sure it cannot be already present */ + 732 19606 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 733 : /* LCOV_EXCL_START */ + 734 : 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); + 735 : os_abort(); + 736 : /* LCOV_EXCL_STOP */ + 737 : } + 738 : + 739 : /* assume a previously used inode, it's the worst case */ + 740 : /* and we handle it removing the duplicate stored inode. */ + 741 : /* If the file is found by name (not necessarily in this function call), */ + 742 : /* it will have the inode restored, otherwise, it will get removed */ + 743 : + 744 : /* remove from the inode set */ + 745 19606 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 746 : + 747 : /* clear the inode */ + 748 : /* this is not really needed for correct functionality */ + 749 : /* because we are going to set FILE_IS_WITHOUT_INODE */ + 750 : /* but it's easier for debugging to have invalid inodes set to 0 */ + 751 19606 : file->inode = 0; 752 : - 753 : /* then try finding it by name */ - 754 179411 : file = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub, file_path_hash(sub)); + 753 : /* mark as missing inode */ + 754 19606 : file_flag_set(file, FILE_IS_WITHOUT_INODE); 755 : - 756 : /* keep track if the file already exists */ - 757 179411 : is_file_already_present = file != 0; + 756 : /* go further to find it by name */ + 757 : } 758 : - 759 179411 : if (is_file_already_present) { - 760 : /* if the file is without an inode */ - 761 104908 : if (file_flag_has(file, FILE_IS_WITHOUT_INODE)) { - 762 : /* set it now */ - 763 20621 : file->inode = st->st_ino; - 764 : - 765 : /* insert in the set */ - 766 20621 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 767 : - 768 : /* unmark as missing inode */ - 769 20621 : file_flag_clear(file, FILE_IS_WITHOUT_INODE); - 770 : } else { - 771 : /* here the inode has to be different, otherwise we would have found it before */ - 772 84287 : if (file->inode == st->st_ino) { - 773 : /* LCOV_EXCL_START */ - 774 : log_fatal("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub); - 775 : os_abort(); - 776 : /* LCOV_EXCL_STOP */ - 777 : } - 778 : } - 779 : - 780 : /* for sure it cannot be already present */ - 781 104908 : if (file_flag_has(file, FILE_IS_PRESENT)) { - 782 : /* LCOV_EXCL_START */ - 783 : log_fatal("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub); - 784 : os_abort(); - 785 : /* LCOV_EXCL_STOP */ - 786 : } - 787 : - 788 : /* check if the file is not changed */ - 789 104908 : if (file->size == st->st_size - 790 104314 : && file->mtime_sec == st->st_mtime - 791 100278 : && (file->mtime_nsec == STAT_NSEC(st) - 792 : /* always accept the stored value if it's STAT_NSEC_INVALID */ - 793 : /* it happens when upgrading from an old version of SnapRAID */ - 794 : /* not yet supporting the nanosecond field */ - 795 0 : || file->mtime_nsec == STAT_NSEC_INVALID - 796 : ) - 797 : ) { - 798 : /* mark as present */ - 799 100278 : file_flag_set(file, FILE_IS_PRESENT); - 800 : - 801 : /* update the nano seconds mtime only if different */ - 802 : /* to avoid unneeded updates */ - 803 100278 : if (file->mtime_nsec == STAT_NSEC_INVALID - 804 0 : && STAT_NSEC(st) != STAT_NSEC_INVALID - 805 : ) { - 806 0 : file->mtime_nsec = STAT_NSEC(st); - 807 : - 808 : /* we have to save the new mtime */ - 809 0 : state->need_write = 1; - 810 : } - 811 : - 812 : /* if when processing the disk we used the past inodes values */ - 813 100278 : if (has_past_inodes) { - 814 : /* if persistent inodes are supported, we are sure that the inode number */ - 815 : /* is now different, because otherwise the file would have been found */ - 816 : /* when searching by inode. */ - 817 : /* if the inode is different, it means a rewritten file with the same path */ - 818 : /* like when restoring a backup that restores also the timestamp */ - 819 100268 : ++scan->count_restore; - 820 : - 821 100268 : log_tag("scan:restore:%s:%s\n", disk->name, esc(sub)); - 822 100268 : if (is_diff) { - 823 0 : printf("restore %s%s\n", disk->dir, sub); - 824 : } - 825 : - 826 : /* remove from the inode set */ - 827 100268 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); - 828 : - 829 : /* save the new inode */ - 830 100268 : file->inode = st->st_ino; - 831 : - 832 : /* reinsert in the inode set */ - 833 100268 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 834 : - 835 : /* we have to save the new inode */ - 836 100268 : state->need_write = 1; - 837 : } else { - 838 : /* otherwise it's the case of not persistent inode, where doesn't */ - 839 : /* matter if the inode is different or equal, because they have no */ - 840 : /* meaning, and then we don't even save them */ - 841 10 : ++scan->count_equal; - 842 : - 843 10 : if (state->opt.gui) { - 844 0 : log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub)); - 845 : } - 846 : } - 847 : - 848 : /* mark the file as kept */ - 849 100278 : scan_file_keep(scan, file); - 850 : - 851 : /* nothing more to do */ - 852 100278 : return; - 853 : } - 854 : - 855 : /* here if the file is changed but with the correct name */ - 856 : - 857 : /* keep track if the original file was not of zero size */ - 858 4630 : is_original_file_size_different_than_zero = file->size != 0; - 859 : - 860 : /* remove it, and continue to insert it again */ - 861 4630 : scan_file_remove(scan, file); - 862 : - 863 : /* and continue to insert it again */ - 864 : } - 865 : - 866 : /* refresh the info, to ensure that they are synced, */ - 867 : /* note that we refresh only the info of the new or modified files */ - 868 : /* because this is slow operation */ - 869 79133 : scan_file_refresh(scan, sub, st, &physical); - 870 : - 871 : #ifndef _WIN32 - 872 : /* do a safety check to ensure that the common ext4 case of zeroing */ - 873 : /* the size of a file after a crash doesn't propagate to the backup */ - 874 : /* this check is specific for Linux, so we disable it on Windows */ - 875 79133 : if (is_original_file_size_different_than_zero && st->st_size == 0) { - 876 0 : if (!state->opt.force_zero) { - 877 : /* LCOV_EXCL_START */ - 878 : log_fatal("The file '%s%s' has unexpected zero size!\n", disk->dir, sub); - 879 : log_fatal("It's possible that after a kernel crash this file was lost,\n"); - 880 : log_fatal("and you can use 'snapraid --filter %s fix' to recover it.\n", sub); - 881 : if (!is_diff) { - 882 : log_fatal("If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command); - 883 : exit(EXIT_FAILURE); - 884 : } - 885 : /* LCOV_EXCL_STOP */ - 886 : } - 887 : } - 888 : #else - 889 : /* avoid the unused warning in Windows */ - 890 : (void)is_original_file_size_different_than_zero; - 891 : #endif - 892 : - 893 : /* insert it */ - 894 79133 : file = file_alloc(state->block_size, sub, st->st_size, st->st_mtime, STAT_NSEC(st), st->st_ino, physical); - 895 : - 896 : /* mark it as present */ - 897 79133 : file_flag_set(file, FILE_IS_PRESENT); - 898 : - 899 : /* if copy detection is enabled */ - 900 : /* note that the copy detection is tried also for updated files */ - 901 : /* this makes sense because it may happen to have two different copies */ - 902 : /* of the same file, and we move the right one over the wrong one */ - 903 : /* in such case we have a "copy" over an "update" */ - 904 79133 : if (!state->opt.force_nocopy) { - 905 79133 : tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); - 906 : - 907 : /* search for a file with the same name and stamp in all the disks */ - 908 422996 : for (i = state->disklist; i != 0; i = i->next) { - 909 367496 : struct snapraid_disk* other_disk = i->data; - 910 : struct snapraid_file* other_file; - 911 : - 912 : /* if the nanosecond part of the time stamp is valid, search */ - 913 : /* for name and stamp, otherwise for path and stamp */ - 914 367496 : if (file->mtime_nsec != 0 && file->mtime_nsec != STAT_NSEC_INVALID) - 915 367388 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_namestamp_compare, file, hash); - 916 : else - 917 108 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_pathstamp_compare, file, hash); - 918 : - 919 : /* if found, and it's a fully hashed file */ - 920 367496 : if (other_file && file_is_full_hashed_and_stable(scan->state, other_disk, other_file)) { - 921 : /* assume that the file is a copy, and reuse the hash */ - 922 23633 : file_copy(other_file, file); - 923 : - 924 : /* revert old counter and use the copy one */ - 925 23633 : ++scan->count_copy; - 926 : - 927 23633 : log_tag("scan:copy:%s:%s:%s:%s\n", other_disk->name, esc(other_file->sub), disk->name, esc(file->sub)); - 928 23633 : if (is_diff) { - 929 31 : printf("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub); - 930 : } - 931 : - 932 : /* mark it as reported */ - 933 23633 : is_file_reported = 1; - 934 : - 935 : /* no need to continue the search */ - 936 23633 : break; - 937 : } - 938 : } - 939 : } - 940 : - 941 : /* if not yet reported, do it now */ - 942 79133 : if (!is_file_reported) { - 943 55500 : if (is_file_already_present) { - 944 4630 : ++scan->count_change; - 945 : - 946 4630 : log_tag("scan:update:%s:%s\n", disk->name, esc(sub)); - 947 4630 : if (is_diff) { - 948 118 : printf("update %s%s\n", disk->dir, sub); - 949 : } - 950 : } else { - 951 50870 : ++scan->count_insert; - 952 : - 953 50870 : log_tag("scan:add:%s:%s\n", disk->name, esc(sub)); - 954 50870 : if (is_diff) { - 955 17051 : printf("add %s%s\n", disk->dir, sub); - 956 : } - 957 : } - 958 : } - 959 : - 960 : /* insert the file in the delayed list */ - 961 79133 : scan_file_insert(scan, file); - 962 : } - 963 : - 964 : /** - 965 : * Remove the specified dir from the data set. - 966 : */ - 967 2 : static void scan_emptydir_remove(struct snapraid_scan* scan, struct snapraid_dir* dir) - 968 : { - 969 2 : struct snapraid_state* state = scan->state; - 970 2 : struct snapraid_disk* disk = scan->disk; - 971 : - 972 : /* state changed */ - 973 2 : state->need_write = 1; - 974 : - 975 : /* remove the file from the dir containers */ - 976 2 : tommy_hashdyn_remove_existing(&disk->dirset, &dir->nodeset); - 977 2 : tommy_list_remove_existing(&disk->dirlist, &dir->nodelist); - 978 : - 979 : /* deallocate */ - 980 2 : dir_free(dir); - 981 2 : } - 982 : - 983 : /** - 984 : * Insert the specified dir in the data set. - 985 : */ - 986 10 : static void scan_emptydir_insert(struct snapraid_scan* scan, struct snapraid_dir* dir) - 987 : { - 988 10 : struct snapraid_state* state = scan->state; - 989 10 : struct snapraid_disk* disk = scan->disk; - 990 : - 991 : /* state changed */ - 992 10 : state->need_write = 1; - 993 : - 994 : /* insert the dir in the dir containers */ - 995 10 : tommy_hashdyn_insert(&disk->dirset, &dir->nodeset, dir, dir_name_hash(dir->sub)); - 996 10 : tommy_list_insert_tail(&disk->dirlist, &dir->nodelist, dir); - 997 10 : } - 998 : - 999 : /** - 1000 : * Process a dir. - 1001 : */ - 1002 239 : static void scan_emptydir(struct snapraid_scan* scan, const char* sub) - 1003 : { - 1004 239 : struct snapraid_disk* disk = scan->disk; - 1005 : struct snapraid_dir* dir; - 1006 : - 1007 : /* check if the dir already exists */ - 1008 239 : dir = tommy_hashdyn_search(&disk->dirset, dir_name_compare, sub, dir_name_hash(sub)); - 1009 239 : if (dir) { - 1010 : /* check if multiple files have the same name */ - 1011 229 : if (dir_flag_has(dir, FILE_IS_PRESENT)) { - 1012 : /* LCOV_EXCL_START */ - 1013 : log_fatal("Internal inconsistency for dir '%s%s'\n", disk->dir, sub); - 1014 : os_abort(); - 1015 : /* LCOV_EXCL_STOP */ - 1016 : } - 1017 : - 1018 : /* mark as present */ - 1019 229 : dir_flag_set(dir, FILE_IS_PRESENT); - 1020 : - 1021 : /* nothing more to do */ - 1022 468 : return; - 1023 : } else { - 1024 : /* and continue to insert it */ - 1025 : } - 1026 : - 1027 : /* insert it */ - 1028 10 : dir = dir_alloc(sub); - 1029 : - 1030 : /* mark it as present */ - 1031 10 : dir_flag_set(dir, FILE_IS_PRESENT); - 1032 : - 1033 : /* insert it in the delayed insert list */ - 1034 10 : tommy_list_insert_tail(&scan->dir_insert_list, &dir->nodelist, dir); - 1035 : } + 759 : /* initialize for later overwrite */ + 760 177743 : is_file_reported = 0; + 761 177743 : is_original_file_size_different_than_zero = 0; + 762 : + 763 : /* then try finding it by name */ + 764 177743 : file = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub, file_path_hash(sub)); + 765 : + 766 : /* keep track if the file already exists */ + 767 177743 : is_file_already_present = file != 0; + 768 : + 769 177743 : if (is_file_already_present) { + 770 : /* if the file is without an inode */ + 771 103230 : if (file_flag_has(file, FILE_IS_WITHOUT_INODE)) { + 772 : /* set it now */ + 773 19577 : file->inode = st->st_ino; + 774 : + 775 : /* insert in the set */ + 776 19577 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 777 : + 778 : /* unmark as missing inode */ + 779 19577 : file_flag_clear(file, FILE_IS_WITHOUT_INODE); + 780 : } else { + 781 : /* here the inode has to be different, otherwise we would have found it before */ + 782 83653 : if (file->inode == st->st_ino) { + 783 : /* LCOV_EXCL_START */ + 784 : log_fatal("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub); + 785 : os_abort(); + 786 : /* LCOV_EXCL_STOP */ + 787 : } + 788 : } + 789 : + 790 : /* for sure it cannot be already present */ + 791 103230 : if (file_flag_has(file, FILE_IS_PRESENT)) { + 792 : /* LCOV_EXCL_START */ + 793 : log_fatal("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub); + 794 : os_abort(); + 795 : /* LCOV_EXCL_STOP */ + 796 : } + 797 : + 798 : /* check if the file is not changed */ + 799 103230 : if (file->size == st->st_size + 800 102636 : && file->mtime_sec == st->st_mtime + 801 98603 : && (file->mtime_nsec == STAT_NSEC(st) + 802 : /* always accept the stored value if it's STAT_NSEC_INVALID */ + 803 : /* it happens when upgrading from an old version of SnapRAID */ + 804 : /* not yet supporting the nanosecond field */ + 805 0 : || file->mtime_nsec == STAT_NSEC_INVALID + 806 : ) + 807 : ) { + 808 : /* mark as present */ + 809 98603 : file_flag_set(file, FILE_IS_PRESENT); + 810 : + 811 : /* update the nano seconds mtime only if different */ + 812 : /* to avoid unneeded updates */ + 813 98603 : if (file->mtime_nsec == STAT_NSEC_INVALID + 814 0 : && STAT_NSEC(st) != STAT_NSEC_INVALID + 815 : ) { + 816 0 : file->mtime_nsec = STAT_NSEC(st); + 817 : + 818 : /* we have to save the new mtime */ + 819 0 : state->need_write = 1; + 820 : } + 821 : + 822 : /* if when processing the disk we used the past inodes values */ + 823 98603 : if (has_past_inodes) { + 824 : /* if persistent inodes are supported, we are sure that the inode number */ + 825 : /* is now different, because otherwise the file would have been found */ + 826 : /* when searching by inode. */ + 827 : /* if the inode is different, it means a rewritten file with the same path */ + 828 : /* like when restoring a backup that restores also the timestamp */ + 829 98589 : ++scan->count_restore; + 830 : + 831 98589 : log_tag("scan:restore:%s:%s\n", disk->name, esc(sub)); + 832 98589 : if (is_diff) { + 833 0 : printf("restore %s%s\n", disk->dir, sub); + 834 : } + 835 : + 836 : /* remove from the inode set */ + 837 98589 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 838 : + 839 : /* save the new inode */ + 840 98589 : file->inode = st->st_ino; + 841 : + 842 : /* reinsert in the inode set */ + 843 98589 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 844 : + 845 : /* we have to save the new inode */ + 846 98589 : state->need_write = 1; + 847 : } else { + 848 : /* otherwise it's the case of not persistent inode, where doesn't */ + 849 : /* matter if the inode is different or equal, because they have no */ + 850 : /* meaning, and then we don't even save them */ + 851 14 : ++scan->count_equal; + 852 : + 853 14 : if (state->opt.gui) { + 854 0 : log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub)); + 855 : } + 856 : } + 857 : + 858 : /* mark the file as kept */ + 859 98603 : scan_file_keep(scan, file); + 860 : + 861 : /* nothing more to do */ + 862 98603 : return; + 863 : } + 864 : + 865 : /* here if the file is changed but with the correct name */ + 866 : + 867 : /* keep track if the original file was not of zero size */ + 868 4627 : is_original_file_size_different_than_zero = file->size != 0; + 869 : + 870 : /* remove it, and continue to insert it again */ + 871 4627 : scan_file_remove(scan, file); + 872 : + 873 : /* and continue to insert it again */ + 874 : } + 875 : + 876 : /* refresh the info, to ensure that they are synced, */ + 877 : /* note that we refresh only the info of the new or modified files */ + 878 : /* because this is slow operation */ + 879 79140 : scan_file_refresh(scan, sub, st, &physical); + 880 : + 881 : #ifndef _WIN32 + 882 : /* do a safety check to ensure that the common ext4 case of zeroing */ + 883 : /* the size of a file after a crash doesn't propagate to the backup */ + 884 : /* this check is specific for Linux, so we disable it on Windows */ + 885 79140 : if (is_original_file_size_different_than_zero && st->st_size == 0) { + 886 0 : if (!state->opt.force_zero) { + 887 : /* LCOV_EXCL_START */ + 888 : log_fatal("The file '%s%s' has unexpected zero size!\n", disk->dir, sub); + 889 : log_fatal("It's possible that after a kernel crash this file was lost,\n"); + 890 : log_fatal("and you can use 'snapraid --filter %s fix' to recover it.\n", sub); + 891 : if (!is_diff) { + 892 : log_fatal("If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command); + 893 : exit(EXIT_FAILURE); + 894 : } + 895 : /* LCOV_EXCL_STOP */ + 896 : } + 897 : } + 898 : #else + 899 : /* avoid the unused warning in Windows */ + 900 : (void)is_original_file_size_different_than_zero; + 901 : #endif + 902 : + 903 : /* insert it */ + 904 79140 : file = file_alloc(state->block_size, sub, st->st_size, st->st_mtime, STAT_NSEC(st), st->st_ino, physical); + 905 : + 906 : /* mark it as present */ + 907 79140 : file_flag_set(file, FILE_IS_PRESENT); + 908 : + 909 : /* if copy detection is enabled */ + 910 : /* note that the copy detection is tried also for updated files */ + 911 : /* this makes sense because it may happen to have two different copies */ + 912 : /* of the same file, and we move the right one over the wrong one */ + 913 : /* in such case we have a "copy" over an "update" */ + 914 79140 : if (!state->opt.force_nocopy) { + 915 79140 : tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); + 916 : + 917 : /* search for a file with the same name and stamp in all the disks */ + 918 423032 : for (i = state->disklist; i != 0; i = i->next) { + 919 367528 : struct snapraid_disk* other_disk = i->data; + 920 : struct snapraid_file* other_file; + 921 : + 922 : /* if the nanosecond part of the time stamp is valid, search */ + 923 : /* for name and stamp, otherwise for path and stamp */ + 924 367528 : if (file->mtime_nsec != 0 && file->mtime_nsec != STAT_NSEC_INVALID) + 925 367420 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_namestamp_compare, file, hash); + 926 : else + 927 108 : other_file = tommy_hashdyn_search(&other_disk->stampset, file_pathstamp_compare, file, hash); + 928 : + 929 : /* if found, and it's a fully hashed file */ + 930 367528 : if (other_file && file_is_full_hashed_and_stable(scan->state, other_disk, other_file)) { + 931 : /* assume that the file is a copy, and reuse the hash */ + 932 23636 : file_copy(other_file, file); + 933 : + 934 : /* revert old counter and use the copy one */ + 935 23636 : ++scan->count_copy; + 936 : + 937 23636 : log_tag("scan:copy:%s:%s:%s:%s\n", other_disk->name, esc(other_file->sub), disk->name, esc(file->sub)); + 938 23636 : if (is_diff) { + 939 31 : printf("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub); + 940 : } + 941 : + 942 : /* mark it as reported */ + 943 23636 : is_file_reported = 1; + 944 : + 945 : /* no need to continue the search */ + 946 23636 : break; + 947 : } + 948 : } + 949 : } + 950 : + 951 : /* if not yet reported, do it now */ + 952 79140 : if (!is_file_reported) { + 953 55504 : if (is_file_already_present) { + 954 4627 : ++scan->count_change; + 955 : + 956 4627 : log_tag("scan:update:%s:%s\n", disk->name, esc(sub)); + 957 4627 : if (is_diff) { + 958 118 : printf("update %s%s\n", disk->dir, sub); + 959 : } + 960 : } else { + 961 50877 : ++scan->count_insert; + 962 : + 963 50877 : log_tag("scan:add:%s:%s\n", disk->name, esc(sub)); + 964 50877 : if (is_diff) { + 965 17054 : printf("add %s%s\n", disk->dir, sub); + 966 : } + 967 : } + 968 : } + 969 : + 970 : /* insert the file in the delayed list */ + 971 79140 : scan_file_insert(scan, file); + 972 : } + 973 : + 974 : /** + 975 : * Remove the specified dir from the data set. + 976 : */ + 977 2 : static void scan_emptydir_remove(struct snapraid_scan* scan, struct snapraid_dir* dir) + 978 : { + 979 2 : struct snapraid_state* state = scan->state; + 980 2 : struct snapraid_disk* disk = scan->disk; + 981 : + 982 : /* state changed */ + 983 2 : state->need_write = 1; + 984 : + 985 : /* remove the file from the dir containers */ + 986 2 : tommy_hashdyn_remove_existing(&disk->dirset, &dir->nodeset); + 987 2 : tommy_list_remove_existing(&disk->dirlist, &dir->nodelist); + 988 : + 989 : /* deallocate */ + 990 2 : dir_free(dir); + 991 2 : } + 992 : + 993 : /** + 994 : * Insert the specified dir in the data set. + 995 : */ + 996 10 : static void scan_emptydir_insert(struct snapraid_scan* scan, struct snapraid_dir* dir) + 997 : { + 998 10 : struct snapraid_state* state = scan->state; + 999 10 : struct snapraid_disk* disk = scan->disk; + 1000 : + 1001 : /* state changed */ + 1002 10 : state->need_write = 1; + 1003 : + 1004 : /* insert the dir in the dir containers */ + 1005 10 : tommy_hashdyn_insert(&disk->dirset, &dir->nodeset, dir, dir_name_hash(dir->sub)); + 1006 10 : tommy_list_insert_tail(&disk->dirlist, &dir->nodelist, dir); + 1007 10 : } + 1008 : + 1009 : /** + 1010 : * Process a dir. + 1011 : */ + 1012 239 : static void scan_emptydir(struct snapraid_scan* scan, const char* sub) + 1013 : { + 1014 239 : struct snapraid_disk* disk = scan->disk; + 1015 : struct snapraid_dir* dir; + 1016 : + 1017 : /* check if the dir already exists */ + 1018 239 : dir = tommy_hashdyn_search(&disk->dirset, dir_name_compare, sub, dir_name_hash(sub)); + 1019 239 : if (dir) { + 1020 : /* check if multiple files have the same name */ + 1021 229 : if (dir_flag_has(dir, FILE_IS_PRESENT)) { + 1022 : /* LCOV_EXCL_START */ + 1023 : log_fatal("Internal inconsistency for dir '%s%s'\n", disk->dir, sub); + 1024 : os_abort(); + 1025 : /* LCOV_EXCL_STOP */ + 1026 : } + 1027 : + 1028 : /* mark as present */ + 1029 229 : dir_flag_set(dir, FILE_IS_PRESENT); + 1030 : + 1031 : /* nothing more to do */ + 1032 468 : return; + 1033 : } else { + 1034 : /* and continue to insert it */ + 1035 : } 1036 : - 1037 : struct dirent_sorted { - 1038 : /* node for data structures */ - 1039 : tommy_node node; - 1040 : - 1041 : #if HAVE_STRUCT_DIRENT_D_INO - 1042 : uint64_t d_ino; /**< Inode number. */ - 1043 : #endif - 1044 : #if HAVE_STRUCT_DIRENT_D_TYPE - 1045 : uint32_t d_type; /**< File type. */ - 1046 : #endif - 1047 : #if HAVE_STRUCT_DIRENT_D_STAT - 1048 : struct stat d_stat; /**< Stat result. */ - 1049 : #endif - 1050 : char d_name[]; /**< Variable length name. It must be the last field. */ - 1051 : }; - 1052 : - 1053 : #if HAVE_STRUCT_DIRENT_D_INO - 1054 103366 : static int dd_ino_compare(const void* void_a, const void* void_b) - 1055 : { - 1056 103366 : const struct dirent_sorted* a = void_a; - 1057 103366 : const struct dirent_sorted* b = void_b; - 1058 : - 1059 103366 : if (a->d_ino < b->d_ino) - 1060 49430 : return -1; - 1061 53936 : if (a->d_ino > b->d_ino) - 1062 53936 : return 1; - 1063 : - 1064 0 : return 0; - 1065 : } - 1066 : #endif - 1067 : - 1068 10959090 : static int dd_name_compare(const void* void_a, const void* void_b) - 1069 : { - 1070 10959090 : const struct dirent_sorted* a = void_a; - 1071 10959090 : const struct dirent_sorted* b = void_b; - 1072 : - 1073 10959090 : return strcmp(a->d_name, b->d_name); - 1074 : } - 1075 : - 1076 : /** - 1077 : * Return the stat info of a dir entry. - 1078 : */ - 1079 : #if HAVE_STRUCT_DIRENT_D_STAT - 1080 : #define DSTAT(file, dd, buf) dstat(dd) - 1081 : struct stat* dstat(struct dirent_sorted* dd) - 1082 : { - 1083 : return &dd->d_stat; + 1037 : /* insert it */ + 1038 10 : dir = dir_alloc(sub); + 1039 : + 1040 : /* mark it as present */ + 1041 10 : dir_flag_set(dir, FILE_IS_PRESENT); + 1042 : + 1043 : /* insert it in the delayed insert list */ + 1044 10 : tommy_list_insert_tail(&scan->dir_insert_list, &dir->nodelist, dir); + 1045 : } + 1046 : + 1047 : struct dirent_sorted { + 1048 : /* node for data structures */ + 1049 : tommy_node node; + 1050 : + 1051 : #if HAVE_STRUCT_DIRENT_D_INO + 1052 : uint64_t d_ino; /**< Inode number. */ + 1053 : #endif + 1054 : #if HAVE_STRUCT_DIRENT_D_TYPE + 1055 : uint32_t d_type; /**< File type. */ + 1056 : #endif + 1057 : #if HAVE_STRUCT_DIRENT_D_STAT + 1058 : struct stat d_stat; /**< Stat result. */ + 1059 : #endif + 1060 : char d_name[]; /**< Variable length name. It must be the last field. */ + 1061 : }; + 1062 : + 1063 : #if HAVE_STRUCT_DIRENT_D_INO + 1064 103390 : static int dd_ino_compare(const void* void_a, const void* void_b) + 1065 : { + 1066 103390 : const struct dirent_sorted* a = void_a; + 1067 103390 : const struct dirent_sorted* b = void_b; + 1068 : + 1069 103390 : if (a->d_ino < b->d_ino) + 1070 49438 : return -1; + 1071 53952 : if (a->d_ino > b->d_ino) + 1072 53952 : return 1; + 1073 : + 1074 0 : return 0; + 1075 : } + 1076 : #endif + 1077 : + 1078 10960001 : static int dd_name_compare(const void* void_a, const void* void_b) + 1079 : { + 1080 10960001 : const struct dirent_sorted* a = void_a; + 1081 10960001 : const struct dirent_sorted* b = void_b; + 1082 : + 1083 10960001 : return strcmp(a->d_name, b->d_name); 1084 : } - 1085 : #else - 1086 : #define DSTAT(file, dd, buf) dstat(file, buf) - 1087 1049496 : struct stat* dstat(const char* file, struct stat* st) - 1088 : { - 1089 1049496 : if (lstat(file, st) != 0) { - 1090 : /* LCOV_EXCL_START */ - 1091 : log_fatal("Error in stat file/directory '%s'. %s.\n", file, strerror(errno)); - 1092 : exit(EXIT_FAILURE); - 1093 : /* LCOV_EXCL_STOP */ - 1094 : } - 1095 1049496 : return st; - 1096 : } - 1097 : #endif - 1098 : - 1099 : /** - 1100 : * Process a directory. - 1101 : * Return != 0 if at least one file or link is processed. - 1102 : */ - 1103 1713 : static int scan_dir(struct snapraid_scan* scan, int level, int is_diff, const char* dir, const char* sub) - 1104 : { - 1105 1713 : struct snapraid_state* state = scan->state; - 1106 1713 : struct snapraid_disk* disk = scan->disk; - 1107 1713 : int processed = 0; - 1108 : DIR* d; - 1109 : tommy_list list; - 1110 : tommy_node* node; - 1111 : - 1112 1713 : tommy_list_init(&list); - 1113 : - 1114 1713 : d = opendir(dir); - 1115 1713 : if (!d) { - 1116 : /* LCOV_EXCL_START */ - 1117 : log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno)); - 1118 : if (level == 0) - 1119 : log_fatal("If this is the disk mount point, remember to create it manually\n"); - 1120 : else - 1121 : log_fatal("If it's a permission problem, you can exclude it in the config file with:\n\texclude /%s\n", sub); - 1122 : exit(EXIT_FAILURE); - 1123 : /* LCOV_EXCL_STOP */ - 1124 : } - 1125 : - 1126 : /* read the full directory */ - 1127 : while (1) { - 1128 : char path_next[PATH_MAX]; - 1129 : char sub_next[PATH_MAX]; - 1130 : struct dirent_sorted* entry; - 1131 : const char* name; - 1132 : struct dirent* dd; - 1133 : size_t name_len; - 1134 : - 1135 : /* clear errno to detect erroneous conditions */ - 1136 1088749 : errno = 0; - 1137 1088749 : dd = readdir(d); - 1138 1088749 : if (dd == 0 && errno != 0) { - 1139 : /* LCOV_EXCL_START */ - 1140 : log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno)); - 1141 : log_fatal("You can exclude it in the config file with:\n\texclude /%s\n", sub); - 1142 : exit(EXIT_FAILURE); - 1143 : /* LCOV_EXCL_STOP */ - 1144 : } - 1145 1088749 : if (dd == 0) { - 1146 1713 : break; /* finished */ - 1147 : } - 1148 : - 1149 : /* skip "." and ".." files */ - 1150 1087036 : name = dd->d_name; - 1151 1087036 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) - 1152 6852 : continue; - 1153 : - 1154 1083610 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); - 1155 1083610 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); - 1156 : - 1157 : /* check for not supported file names */ - 1158 1083610 : if (name[0] == 0) { - 1159 : /* LCOV_EXCL_START */ - 1160 : log_fatal("Unsupported name '%s' in file '%s'.\n", name, path_next); - 1161 : exit(EXIT_FAILURE); - 1162 : /* LCOV_EXCL_STOP */ - 1163 : } - 1164 : - 1165 : /* exclude hidden files even before calling lstat() */ - 1166 1083610 : if (filter_hidden(state->filter_hidden, dd) != 0) { - 1167 0 : msg_verbose("Excluding hidden '%s'\n", path_next); - 1168 0 : continue; - 1169 : } - 1170 : - 1171 : /* exclude content files even before calling lstat() */ - 1172 1083610 : if (filter_content(&state->contentlist, path_next) != 0) { - 1173 0 : msg_verbose("Excluding content '%s'\n", path_next); - 1174 0 : continue; - 1175 : } - 1176 : - 1177 1083610 : name_len = strlen(dd->d_name); - 1178 1083610 : entry = malloc_nofail(sizeof(struct dirent_sorted) + name_len + 1); - 1179 : - 1180 : /* copy the dir entry */ - 1181 : #if HAVE_STRUCT_DIRENT_D_INO - 1182 1083610 : entry->d_ino = dd->d_ino; - 1183 : #endif - 1184 : #if HAVE_STRUCT_DIRENT_D_TYPE - 1185 1083610 : entry->d_type = dd->d_type; - 1186 : #endif - 1187 : #if HAVE_STRUCT_DIRENT_D_STAT - 1188 : /* convert dirent to lstat result */ - 1189 : dirent_lstat(dd, &entry->d_stat); - 1190 : - 1191 : /* note that at this point the st_mode may be 0 */ - 1192 : #endif - 1193 1083610 : memcpy(entry->d_name, dd->d_name, name_len + 1); - 1194 : - 1195 : /* insert in the list */ - 1196 1083610 : tommy_list_insert_tail(&list, &entry->node, entry); - 1197 1087036 : } - 1198 : - 1199 1713 : if (closedir(d) != 0) { - 1200 : /* LCOV_EXCL_START */ - 1201 : log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno)); - 1202 : exit(EXIT_FAILURE); - 1203 : /* LCOV_EXCL_STOP */ - 1204 : } - 1205 : - 1206 1713 : if (state->opt.force_order == SORT_ALPHA) { - 1207 : /* if requested sort alphabetically */ - 1208 : /* this is mainly done for testing to ensure to always */ - 1209 : /* process in the same way in different platforms */ - 1210 1677 : tommy_list_sort(&list, dd_name_compare); - 1211 : } - 1212 : #if HAVE_STRUCT_DIRENT_D_INO - 1213 36 : else if (!disk->has_volatile_inodes) { - 1214 : /* if inodes are persistent */ - 1215 : /* sort the list of dir entries by inodes */ - 1216 36 : tommy_list_sort(&list, dd_ino_compare); - 1217 : } - 1218 : /* otherwise just keep the insertion order */ - 1219 : #endif - 1220 : - 1221 : /* process the sorted dir entries */ - 1222 1713 : node = list; - 1223 1087036 : while (node != 0) { - 1224 : char path_next[PATH_MAX]; - 1225 : char sub_next[PATH_MAX]; - 1226 : char out[PATH_MAX]; - 1227 1083610 : struct snapraid_filter* reason = 0; - 1228 1083610 : struct dirent_sorted* dd = node->data; - 1229 1083610 : const char* name = dd->d_name; - 1230 : struct stat* st; - 1231 : int type; - 1232 : #if !HAVE_STRUCT_DIRENT_D_STAT - 1233 : struct stat st_buf; - 1234 : #endif - 1235 : - 1236 1083610 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); - 1237 1083610 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); - 1238 : - 1239 : /* start with an unknown type */ - 1240 1083610 : type = -1; - 1241 1083610 : st = 0; - 1242 : - 1243 : /* if dirent has the type, use it */ - 1244 : #if HAVE_STRUCT_DIRENT_D_TYPE - 1245 1083610 : switch (dd->d_type) { - 1246 0 : case DT_UNKNOWN : break; - 1247 1048310 : case DT_REG : type = 0; break; - 1248 34114 : case DT_LNK : type = 1; break; - 1249 1186 : case DT_DIR : type = 2; break; - 1250 0 : default : type = 3; break; - 1251 : } - 1252 : #endif - 1253 : - 1254 : /* if type is still unknown */ - 1255 1083610 : if (type < 0) { - 1256 : /* get the type from stat */ - 1257 0 : st = DSTAT(path_next, dd, &st_buf); - 1258 : - 1259 : #if HAVE_STRUCT_DIRENT_D_STAT - 1260 : /* if the st_mode field is missing, takes care to fill it using normal lstat() */ - 1261 : /* at now this can happen only in Windows (with HAVE_STRUCT_DIRENT_D_STAT defined), */ - 1262 : /* because we use a directory reading method that doesn't read info about ReparsePoint. */ - 1263 : /* Note that here we cannot call here lstat_sync(), because we don't know what kind */ - 1264 : /* of file is it, and lstat_sync() doesn't always work */ - 1265 : if (st->st_mode == 0) { - 1266 : if (lstat(path_next, st) != 0) { - 1267 : /* LCOV_EXCL_START */ - 1268 : log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno)); - 1269 : exit(EXIT_FAILURE); - 1270 : /* LCOV_EXCL_STOP */ - 1271 : } - 1272 : } - 1273 : #endif - 1274 : - 1275 0 : if (S_ISREG(st->st_mode)) - 1276 0 : type = 0; - 1277 0 : else if (S_ISLNK(st->st_mode)) - 1278 0 : type = 1; - 1279 0 : else if (S_ISDIR(st->st_mode)) - 1280 0 : type = 2; - 1281 : else - 1282 0 : type = 3; - 1283 : } + 1085 : + 1086 : /** + 1087 : * Return the stat info of a dir entry. + 1088 : */ + 1089 : #if HAVE_STRUCT_DIRENT_D_STAT + 1090 : #define DSTAT(file, dd, buf) dstat(dd) + 1091 : struct stat* dstat(struct dirent_sorted* dd) + 1092 : { + 1093 : return &dd->d_stat; + 1094 : } + 1095 : #else + 1096 : #define DSTAT(file, dd, buf) dstat(file, buf) + 1097 1049732 : struct stat* dstat(const char* file, struct stat* st) + 1098 : { + 1099 1049732 : if (lstat(file, st) != 0) { + 1100 : /* LCOV_EXCL_START */ + 1101 : log_fatal("Error in stat file/directory '%s'. %s.\n", file, strerror(errno)); + 1102 : exit(EXIT_FAILURE); + 1103 : /* LCOV_EXCL_STOP */ + 1104 : } + 1105 1049732 : return st; + 1106 : } + 1107 : #endif + 1108 : + 1109 : /** + 1110 : * Process a directory. + 1111 : * Return != 0 if at least one file or link is processed. + 1112 : */ + 1113 1725 : static int scan_dir(struct snapraid_scan* scan, int level, int is_diff, const char* dir, const char* sub) + 1114 : { + 1115 1725 : struct snapraid_state* state = scan->state; + 1116 1725 : struct snapraid_disk* disk = scan->disk; + 1117 1725 : int processed = 0; + 1118 : DIR* d; + 1119 : tommy_list list; + 1120 : tommy_node* node; + 1121 : + 1122 1725 : tommy_list_init(&list); + 1123 : + 1124 1725 : d = opendir(dir); + 1125 1725 : if (!d) { + 1126 : /* LCOV_EXCL_START */ + 1127 : log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno)); + 1128 : if (level == 0) + 1129 : log_fatal("If this is the disk mount point, remember to create it manually\n"); + 1130 : else + 1131 : log_fatal("If it's a permission problem, you can exclude it in the config file with:\n\texclude /%s\n", sub); + 1132 : exit(EXIT_FAILURE); + 1133 : /* LCOV_EXCL_STOP */ + 1134 : } + 1135 : + 1136 : /* read the full directory */ + 1137 : while (1) { + 1138 : char path_next[PATH_MAX]; + 1139 : char sub_next[PATH_MAX]; + 1140 : struct dirent_sorted* entry; + 1141 : const char* name; + 1142 : struct dirent* dd; + 1143 : size_t name_len; + 1144 : + 1145 : /* clear errno to detect erroneous conditions */ + 1146 1089021 : errno = 0; + 1147 1089021 : dd = readdir(d); + 1148 1089021 : if (dd == 0 && errno != 0) { + 1149 : /* LCOV_EXCL_START */ + 1150 : log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno)); + 1151 : log_fatal("You can exclude it in the config file with:\n\texclude /%s\n", sub); + 1152 : exit(EXIT_FAILURE); + 1153 : /* LCOV_EXCL_STOP */ + 1154 : } + 1155 1089021 : if (dd == 0) { + 1156 1725 : break; /* finished */ + 1157 : } + 1158 : + 1159 : /* skip "." and ".." files */ + 1160 1087296 : name = dd->d_name; + 1161 1087296 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) + 1162 6900 : continue; + 1163 : + 1164 1083846 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); + 1165 1083846 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); + 1166 : + 1167 : /* check for not supported file names */ + 1168 1083846 : if (name[0] == 0) { + 1169 : /* LCOV_EXCL_START */ + 1170 : log_fatal("Unsupported name '%s' in file '%s'.\n", name, path_next); + 1171 : exit(EXIT_FAILURE); + 1172 : /* LCOV_EXCL_STOP */ + 1173 : } + 1174 : + 1175 : /* exclude hidden files even before calling lstat() */ + 1176 1083846 : if (filter_hidden(state->filter_hidden, dd) != 0) { + 1177 0 : msg_verbose("Excluding hidden '%s'\n", path_next); + 1178 0 : continue; + 1179 : } + 1180 : + 1181 : /* exclude content files even before calling lstat() */ + 1182 1083846 : if (filter_content(&state->contentlist, path_next) != 0) { + 1183 0 : msg_verbose("Excluding content '%s'\n", path_next); + 1184 0 : continue; + 1185 : } + 1186 : + 1187 1083846 : name_len = strlen(dd->d_name); + 1188 1083846 : entry = malloc_nofail(sizeof(struct dirent_sorted) + name_len + 1); + 1189 : + 1190 : /* copy the dir entry */ + 1191 : #if HAVE_STRUCT_DIRENT_D_INO + 1192 1083846 : entry->d_ino = dd->d_ino; + 1193 : #endif + 1194 : #if HAVE_STRUCT_DIRENT_D_TYPE + 1195 1083846 : entry->d_type = dd->d_type; + 1196 : #endif + 1197 : #if HAVE_STRUCT_DIRENT_D_STAT + 1198 : /* convert dirent to lstat result */ + 1199 : dirent_lstat(dd, &entry->d_stat); + 1200 : + 1201 : /* note that at this point the st_mode may be 0 */ + 1202 : #endif + 1203 1083846 : memcpy(entry->d_name, dd->d_name, name_len + 1); + 1204 : + 1205 : /* insert in the list */ + 1206 1083846 : tommy_list_insert_tail(&list, &entry->node, entry); + 1207 1087296 : } + 1208 : + 1209 1725 : if (closedir(d) != 0) { + 1210 : /* LCOV_EXCL_START */ + 1211 : log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno)); + 1212 : exit(EXIT_FAILURE); + 1213 : /* LCOV_EXCL_STOP */ + 1214 : } + 1215 : + 1216 1725 : if (state->opt.force_order == SORT_ALPHA) { + 1217 : /* if requested sort alphabetically */ + 1218 : /* this is mainly done for testing to ensure to always */ + 1219 : /* process in the same way in different platforms */ + 1220 1689 : tommy_list_sort(&list, dd_name_compare); + 1221 : } + 1222 : #if HAVE_STRUCT_DIRENT_D_INO + 1223 36 : else if (!disk->has_volatile_inodes) { + 1224 : /* if inodes are persistent */ + 1225 : /* sort the list of dir entries by inodes */ + 1226 36 : tommy_list_sort(&list, dd_ino_compare); + 1227 : } + 1228 : /* otherwise just keep the insertion order */ + 1229 : #endif + 1230 : + 1231 : /* process the sorted dir entries */ + 1232 1725 : node = list; + 1233 1087296 : while (node != 0) { + 1234 : char path_next[PATH_MAX]; + 1235 : char sub_next[PATH_MAX]; + 1236 : char out[PATH_MAX]; + 1237 1083846 : struct snapraid_filter* reason = 0; + 1238 1083846 : struct dirent_sorted* dd = node->data; + 1239 1083846 : const char* name = dd->d_name; + 1240 : struct stat* st; + 1241 : int type; + 1242 : #if !HAVE_STRUCT_DIRENT_D_STAT + 1243 : struct stat st_buf; + 1244 : #endif + 1245 : + 1246 1083846 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); + 1247 1083846 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); + 1248 : + 1249 : /* start with an unknown type */ + 1250 1083846 : type = -1; + 1251 1083846 : st = 0; + 1252 : + 1253 : /* if dirent has the type, use it */ + 1254 : #if HAVE_STRUCT_DIRENT_D_TYPE + 1255 1083846 : switch (dd->d_type) { + 1256 0 : case DT_UNKNOWN : break; + 1257 1048546 : case DT_REG : type = 0; break; + 1258 34114 : case DT_LNK : type = 1; break; + 1259 1186 : case DT_DIR : type = 2; break; + 1260 0 : default : type = 3; break; + 1261 : } + 1262 : #endif + 1263 : + 1264 : /* if type is still unknown */ + 1265 1083846 : if (type < 0) { + 1266 : /* get the type from stat */ + 1267 0 : st = DSTAT(path_next, dd, &st_buf); + 1268 : + 1269 : #if HAVE_STRUCT_DIRENT_D_STAT + 1270 : /* if the st_mode field is missing, takes care to fill it using normal lstat() */ + 1271 : /* at now this can happen only in Windows (with HAVE_STRUCT_DIRENT_D_STAT defined), */ + 1272 : /* because we use a directory reading method that doesn't read info about ReparsePoint. */ + 1273 : /* Note that here we cannot call here lstat_sync(), because we don't know what kind */ + 1274 : /* of file is it, and lstat_sync() doesn't always work */ + 1275 : if (st->st_mode == 0) { + 1276 : if (lstat(path_next, st) != 0) { + 1277 : /* LCOV_EXCL_START */ + 1278 : log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno)); + 1279 : exit(EXIT_FAILURE); + 1280 : /* LCOV_EXCL_STOP */ + 1281 : } + 1282 : } + 1283 : #endif 1284 : - 1285 1083610 : if (type == 0) { /* REG */ - 1286 1048310 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 1287 : - 1288 : /* late stat, if not yet called */ - 1289 1048310 : if (!st) - 1290 1048310 : st = DSTAT(path_next, dd, &st_buf); - 1291 : - 1292 : #if HAVE_LSTAT_SYNC - 1293 : /* if the st_ino field is missing, takes care to fill it using the extended lstat() */ - 1294 : /* this can happen only in Windows */ - 1295 : if (st->st_ino == 0) { - 1296 : if (lstat_sync(path_next, st, 0) != 0) { - 1297 : /* LCOV_EXCL_START */ - 1298 : log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno)); - 1299 : exit(EXIT_FAILURE); - 1300 : /* LCOV_EXCL_STOP */ - 1301 : } - 1302 : } - 1303 : #endif - 1304 : - 1305 1048310 : scan_file(scan, is_diff, sub_next, st, FILEPHY_UNREAD_OFFSET); - 1306 1048310 : processed = 1; - 1307 : } else { - 1308 0 : msg_verbose("Excluding file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); - 1309 : } - 1310 35300 : } else if (type == 1) { /* LNK */ - 1311 34114 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 1312 : char subnew[PATH_MAX]; - 1313 : int ret; + 1285 0 : if (S_ISREG(st->st_mode)) + 1286 0 : type = 0; + 1287 0 : else if (S_ISLNK(st->st_mode)) + 1288 0 : type = 1; + 1289 0 : else if (S_ISDIR(st->st_mode)) + 1290 0 : type = 2; + 1291 : else + 1292 0 : type = 3; + 1293 : } + 1294 : + 1295 1083846 : if (type == 0) { /* REG */ + 1296 1048546 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 1297 : + 1298 : /* late stat, if not yet called */ + 1299 1048546 : if (!st) + 1300 1048546 : st = DSTAT(path_next, dd, &st_buf); + 1301 : + 1302 : #if HAVE_LSTAT_SYNC + 1303 : /* if the st_ino field is missing, takes care to fill it using the extended lstat() */ + 1304 : /* this can happen only in Windows */ + 1305 : if (st->st_ino == 0) { + 1306 : if (lstat_sync(path_next, st, 0) != 0) { + 1307 : /* LCOV_EXCL_START */ + 1308 : log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno)); + 1309 : exit(EXIT_FAILURE); + 1310 : /* LCOV_EXCL_STOP */ + 1311 : } + 1312 : } + 1313 : #endif 1314 : - 1315 34114 : ret = readlink(path_next, subnew, sizeof(subnew)); - 1316 34114 : if (ret >= PATH_MAX) { - 1317 : /* LCOV_EXCL_START */ - 1318 : log_fatal("Error in readlink file '%s'. Symlink too long.\n", path_next); - 1319 : exit(EXIT_FAILURE); - 1320 : /* LCOV_EXCL_STOP */ - 1321 : } - 1322 34114 : if (ret < 0) { - 1323 : /* LCOV_EXCL_START */ - 1324 : log_fatal("Error in readlink file '%s'. %s.\n", path_next, strerror(errno)); - 1325 : exit(EXIT_FAILURE); - 1326 : /* LCOV_EXCL_STOP */ - 1327 : } - 1328 34114 : if (ret == 0) - 1329 0 : log_fatal("WARNING! Empty symbolic link '%s'.\n", path_next); - 1330 : - 1331 : /* readlink doesn't put the final 0 */ - 1332 34114 : subnew[ret] = 0; - 1333 : - 1334 : /* process as a symbolic link */ - 1335 34114 : scan_link(scan, is_diff, sub_next, subnew, FILE_IS_SYMLINK); - 1336 34114 : processed = 1; - 1337 : } else { - 1338 0 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); - 1339 : } - 1340 1186 : } else if (type == 2) { /* DIR */ - 1341 1186 : if (filter_dir(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 1342 : #ifndef _WIN32 - 1343 : /* late stat, if not yet called */ - 1344 1186 : if (!st) - 1345 1186 : st = DSTAT(path_next, dd, &st_buf); - 1346 : - 1347 : /* in Unix don't follow mount points in different devices */ - 1348 : /* in Windows we are already skipping them reporting them as special files */ - 1349 1186 : if ((uint64_t)st->st_dev != disk->device) { - 1350 0 : log_fatal("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next); - 1351 : } else - 1352 : #endif - 1353 : { - 1354 : char sub_dir[PATH_MAX]; - 1355 : - 1356 : /* recurse */ - 1357 1186 : pathslash(path_next, sizeof(path_next)); - 1358 1186 : pathcpy(sub_dir, sizeof(sub_dir), sub_next); - 1359 1186 : pathslash(sub_dir, sizeof(sub_dir)); - 1360 1186 : if (scan_dir(scan, level + 1, is_diff, path_next, sub_dir) == 0) { - 1361 : /* scan the directory as empty dir */ - 1362 239 : scan_emptydir(scan, sub_next); - 1363 : } - 1364 : /* or we processed something internally, or we have added the empty dir */ - 1365 1186 : processed = 1; - 1366 : } - 1367 : } else { - 1368 0 : msg_verbose("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); - 1369 : } - 1370 : } else { - 1371 0 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 1372 : /* late stat, if not yet called */ - 1373 0 : if (!st) - 1374 0 : st = DSTAT(path_next, dd, &st_buf); - 1375 : - 1376 0 : log_fatal("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next); + 1315 1048546 : scan_file(scan, is_diff, sub_next, st, FILEPHY_UNREAD_OFFSET); + 1316 1048546 : processed = 1; + 1317 : } else { + 1318 0 : msg_verbose("Excluding file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 1319 : } + 1320 35300 : } else if (type == 1) { /* LNK */ + 1321 34114 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 1322 : char subnew[PATH_MAX]; + 1323 : int ret; + 1324 : + 1325 34114 : ret = readlink(path_next, subnew, sizeof(subnew)); + 1326 34114 : if (ret >= PATH_MAX) { + 1327 : /* LCOV_EXCL_START */ + 1328 : log_fatal("Error in readlink file '%s'. Symlink too long.\n", path_next); + 1329 : exit(EXIT_FAILURE); + 1330 : /* LCOV_EXCL_STOP */ + 1331 : } + 1332 34114 : if (ret < 0) { + 1333 : /* LCOV_EXCL_START */ + 1334 : log_fatal("Error in readlink file '%s'. %s.\n", path_next, strerror(errno)); + 1335 : exit(EXIT_FAILURE); + 1336 : /* LCOV_EXCL_STOP */ + 1337 : } + 1338 34114 : if (ret == 0) + 1339 0 : log_fatal("WARNING! Empty symbolic link '%s'.\n", path_next); + 1340 : + 1341 : /* readlink doesn't put the final 0 */ + 1342 34114 : subnew[ret] = 0; + 1343 : + 1344 : /* process as a symbolic link */ + 1345 34114 : scan_link(scan, is_diff, sub_next, subnew, FILE_IS_SYMLINK); + 1346 34114 : processed = 1; + 1347 : } else { + 1348 0 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 1349 : } + 1350 1186 : } else if (type == 2) { /* DIR */ + 1351 1186 : if (filter_dir(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 1352 : #ifndef _WIN32 + 1353 : /* late stat, if not yet called */ + 1354 1186 : if (!st) + 1355 1186 : st = DSTAT(path_next, dd, &st_buf); + 1356 : + 1357 : /* in Unix don't follow mount points in different devices */ + 1358 : /* in Windows we are already skipping them reporting them as special files */ + 1359 1186 : if ((uint64_t)st->st_dev != disk->device) { + 1360 0 : log_fatal("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next); + 1361 : } else + 1362 : #endif + 1363 : { + 1364 : char sub_dir[PATH_MAX]; + 1365 : + 1366 : /* recurse */ + 1367 1186 : pathslash(path_next, sizeof(path_next)); + 1368 1186 : pathcpy(sub_dir, sizeof(sub_dir), sub_next); + 1369 1186 : pathslash(sub_dir, sizeof(sub_dir)); + 1370 1186 : if (scan_dir(scan, level + 1, is_diff, path_next, sub_dir) == 0) { + 1371 : /* scan the directory as empty dir */ + 1372 239 : scan_emptydir(scan, sub_next); + 1373 : } + 1374 : /* or we processed something internally, or we have added the empty dir */ + 1375 1186 : processed = 1; + 1376 : } 1377 : } else { - 1378 0 : msg_verbose("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 1378 0 : msg_verbose("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); 1379 : } - 1380 : } - 1381 : - 1382 : /* next entry */ - 1383 1083610 : node = node->next; - 1384 : - 1385 : /* free the present one */ - 1386 1083610 : free(dd); - 1387 : } - 1388 : - 1389 1713 : return processed; - 1390 : } + 1380 : } else { + 1381 0 : if (filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 1382 : /* late stat, if not yet called */ + 1383 0 : if (!st) + 1384 0 : st = DSTAT(path_next, dd, &st_buf); + 1385 : + 1386 0 : log_fatal("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next); + 1387 : } else { + 1388 0 : msg_verbose("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 1389 : } + 1390 : } 1391 : - 1392 88 : static int state_diffscan(struct snapraid_state* state, int is_diff) - 1393 : { - 1394 : tommy_node* i; - 1395 : tommy_node* j; - 1396 : tommy_list scanlist; - 1397 : int done; - 1398 : fptr* msg; - 1399 : struct snapraid_scan total; - 1400 : int no_difference; + 1392 : /* next entry */ + 1393 1083846 : node = node->next; + 1394 : + 1395 : /* free the present one */ + 1396 1083846 : free(dd); + 1397 : } + 1398 : + 1399 1725 : return processed; + 1400 : } 1401 : - 1402 88 : tommy_list_init(&scanlist); - 1403 : - 1404 88 : if (is_diff) - 1405 7 : msg_progress("Comparing...\n"); - 1406 : - 1407 : /* first scan all the directory and find new and deleted files */ - 1408 615 : for (i = state->disklist; i != 0; i = i->next) { - 1409 527 : struct snapraid_disk* disk = i->data; - 1410 : struct snapraid_scan* scan; - 1411 : tommy_node* node; - 1412 : int ret; - 1413 : int has_persistent_inode; - 1414 : - 1415 527 : scan = malloc_nofail(sizeof(struct snapraid_scan)); - 1416 527 : scan->state = state; - 1417 527 : scan->disk = disk; - 1418 527 : scan->count_equal = 0; - 1419 527 : scan->count_move = 0; - 1420 527 : scan->count_copy = 0; - 1421 527 : scan->count_restore = 0; - 1422 527 : scan->count_change = 0; - 1423 527 : scan->count_remove = 0; - 1424 527 : scan->count_insert = 0; - 1425 527 : tommy_list_init(&scan->file_insert_list); - 1426 527 : tommy_list_init(&scan->link_insert_list); - 1427 527 : tommy_list_init(&scan->dir_insert_list); - 1428 : - 1429 527 : tommy_list_insert_tail(&scanlist, &scan->node, scan); - 1430 : - 1431 527 : if (!is_diff) - 1432 485 : msg_progress("Scanning disk %s...\n", disk->name); - 1433 : - 1434 : /* check if the disk supports persistent inodes */ - 1435 527 : ret = fsinfo(disk->dir, &has_persistent_inode, 0, 0); - 1436 527 : if (ret < 0) { - 1437 : /* LCOV_EXCL_START */ - 1438 : log_fatal("Error accessing disk '%s' to get file-system info. %s.\n", disk->dir, strerror(errno)); - 1439 : exit(EXIT_FAILURE); - 1440 : /* LCOV_EXCL_STOP */ - 1441 : } - 1442 527 : if (!has_persistent_inode) { - 1443 0 : disk->has_volatile_inodes = 1; - 1444 : } - 1445 : - 1446 : /* if inodes or UUID are not persistent/changed/unsupported */ - 1447 527 : if (disk->has_volatile_inodes || disk->has_different_uuid || disk->has_unsupported_uuid) { - 1448 : /* remove all the inodes from the inode collection */ - 1449 : /* if they are not persistent, all of them could be changed now */ - 1450 : /* and we don't want to find false matching ones */ - 1451 : /* see scan_file() for more details */ - 1452 90 : node = disk->filelist; - 1453 190 : while (node) { - 1454 10 : struct snapraid_file* file = node->data; + 1402 90 : static int state_diffscan(struct snapraid_state* state, int is_diff) + 1403 : { + 1404 : tommy_node* i; + 1405 : tommy_node* j; + 1406 : tommy_list scanlist; + 1407 : int done; + 1408 : fptr* msg; + 1409 : struct snapraid_scan total; + 1410 : int no_difference; + 1411 : + 1412 90 : tommy_list_init(&scanlist); + 1413 : + 1414 90 : if (is_diff) + 1415 7 : msg_progress("Comparing...\n"); + 1416 : + 1417 : /* first scan all the directory and find new and deleted files */ + 1418 629 : for (i = state->disklist; i != 0; i = i->next) { + 1419 539 : struct snapraid_disk* disk = i->data; + 1420 : struct snapraid_scan* scan; + 1421 : tommy_node* node; + 1422 : int ret; + 1423 : int has_persistent_inode; + 1424 : + 1425 539 : scan = malloc_nofail(sizeof(struct snapraid_scan)); + 1426 539 : scan->state = state; + 1427 539 : scan->disk = disk; + 1428 539 : scan->count_equal = 0; + 1429 539 : scan->count_move = 0; + 1430 539 : scan->count_copy = 0; + 1431 539 : scan->count_restore = 0; + 1432 539 : scan->count_change = 0; + 1433 539 : scan->count_remove = 0; + 1434 539 : scan->count_insert = 0; + 1435 539 : tommy_list_init(&scan->file_insert_list); + 1436 539 : tommy_list_init(&scan->link_insert_list); + 1437 539 : tommy_list_init(&scan->dir_insert_list); + 1438 : + 1439 539 : tommy_list_insert_tail(&scanlist, &scan->node, scan); + 1440 : + 1441 539 : if (!is_diff) + 1442 497 : msg_progress("Scanning disk %s...\n", disk->name); + 1443 : + 1444 : /* check if the disk supports persistent inodes */ + 1445 539 : ret = fsinfo(disk->dir, &has_persistent_inode, 0, 0); + 1446 539 : if (ret < 0) { + 1447 : /* LCOV_EXCL_START */ + 1448 : log_fatal("Error accessing disk '%s' to get file-system info. %s.\n", disk->dir, strerror(errno)); + 1449 : exit(EXIT_FAILURE); + 1450 : /* LCOV_EXCL_STOP */ + 1451 : } + 1452 539 : if (!has_persistent_inode) { + 1453 0 : disk->has_volatile_inodes = 1; + 1454 : } 1455 : - 1456 10 : node = node->next; - 1457 : - 1458 : /* remove from the inode set */ - 1459 10 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); - 1460 : - 1461 : /* clear the inode */ - 1462 10 : file->inode = 0; - 1463 : - 1464 : /* mark as missing inode */ - 1465 10 : file_flag_set(file, FILE_IS_WITHOUT_INODE); - 1466 : } - 1467 : } - 1468 : - 1469 527 : scan_dir(scan, 0, is_diff, disk->dir, ""); - 1470 : } - 1471 : - 1472 : /* we split the search in two phases because to detect files */ - 1473 : /* moved from one disk to another we have to start deletion */ - 1474 : /* only when all disks have all the new files found */ - 1475 : - 1476 : /* now process all the new and deleted files */ - 1477 615 : for (i = scanlist; i != 0; i = i->next) { - 1478 527 : struct snapraid_scan* scan = i->data; - 1479 527 : struct snapraid_disk* disk = scan->disk; - 1480 : tommy_node* node; - 1481 : unsigned phy_count; - 1482 : unsigned phy_dup; - 1483 : uint64_t phy_last; - 1484 : struct snapraid_file* phy_file_last; + 1456 : /* if inodes or UUID are not persistent/changed/unsupported */ + 1457 539 : if (disk->has_volatile_inodes || disk->has_different_uuid || disk->has_unsupported_uuid) { + 1458 : /* remove all the inodes from the inode collection */ + 1459 : /* if they are not persistent, all of them could be changed now */ + 1460 : /* and we don't want to find false matching ones */ + 1461 : /* see scan_file() for more details */ + 1462 93 : node = disk->filelist; + 1463 200 : while (node) { + 1464 14 : struct snapraid_file* file = node->data; + 1465 : + 1466 14 : node = node->next; + 1467 : + 1468 : /* remove from the inode set */ + 1469 14 : tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset); + 1470 : + 1471 : /* clear the inode */ + 1472 14 : file->inode = 0; + 1473 : + 1474 : /* mark as missing inode */ + 1475 14 : file_flag_set(file, FILE_IS_WITHOUT_INODE); + 1476 : } + 1477 : } + 1478 : + 1479 539 : scan_dir(scan, 0, is_diff, disk->dir, ""); + 1480 : } + 1481 : + 1482 : /* we split the search in two phases because to detect files */ + 1483 : /* moved from one disk to another we have to start deletion */ + 1484 : /* only when all disks have all the new files found */ 1485 : - 1486 : /* check for removed files */ - 1487 527 : node = disk->filelist; - 1488 974990 : while (node) { - 1489 973936 : struct snapraid_file* file = node->data; - 1490 : - 1491 : /* next node */ - 1492 973936 : node = node->next; - 1493 : - 1494 : /* remove if not present */ - 1495 973936 : if (!file_flag_has(file, FILE_IS_PRESENT)) { - 1496 29646 : ++scan->count_remove; - 1497 : - 1498 29646 : log_tag("scan:remove:%s:%s\n", disk->name, esc(file->sub)); - 1499 29646 : if (is_diff) { - 1500 97 : printf("remove %s%s\n", disk->dir, file->sub); - 1501 : } - 1502 : - 1503 29646 : scan_file_remove(scan, file); - 1504 : } - 1505 : } - 1506 : - 1507 : /* check for removed links */ - 1508 527 : node = disk->linklist; - 1509 33847 : while (node) { - 1510 32793 : struct snapraid_link* slink = node->data; - 1511 : - 1512 : /* next node */ - 1513 32793 : node = node->next; - 1514 : - 1515 : /* remove if not present */ - 1516 32793 : if (!link_flag_has(slink, FILE_IS_PRESENT)) { - 1517 956 : ++scan->count_remove; - 1518 : - 1519 956 : log_tag("scan:remove:%s:%s\n", disk->name, esc(slink->sub)); - 1520 956 : if (is_diff) { - 1521 10 : printf("remove %s%s\n", disk->dir, slink->sub); - 1522 : } - 1523 : - 1524 956 : scan_link_remove(scan, slink); - 1525 : } - 1526 : } - 1527 : - 1528 : /* check for removed dirs */ - 1529 527 : node = disk->dirlist; - 1530 1285 : while (node) { - 1531 231 : struct snapraid_dir* dir = node->data; - 1532 : - 1533 : /* next node */ - 1534 231 : node = node->next; - 1535 : - 1536 : /* remove if not present */ - 1537 231 : if (!dir_flag_has(dir, FILE_IS_PRESENT)) { - 1538 2 : scan_emptydir_remove(scan, dir); - 1539 : } - 1540 : } - 1541 : - 1542 : /* sort the files before inserting them */ - 1543 : /* we use a stable sort to ensure that if the reported physical offset/inode */ - 1544 : /* are always 0, we keep at least the directory order */ - 1545 527 : switch (state->opt.force_order) { - 1546 : case SORT_PHYSICAL : - 1547 12 : tommy_list_sort(&scan->file_insert_list, file_physical_compare); - 1548 12 : break; - 1549 : case SORT_INODE : - 1550 0 : tommy_list_sort(&scan->file_insert_list, file_inode_compare); - 1551 0 : break; - 1552 : case SORT_ALPHA : - 1553 515 : tommy_list_sort(&scan->file_insert_list, file_path_compare); - 1554 515 : break; - 1555 : case SORT_DIR : - 1556 : /* already in order */ - 1557 0 : break; - 1558 : } - 1559 : - 1560 : /* insert all the new files, we insert them only after the deletion */ - 1561 : /* to reuse the just freed space */ - 1562 : /* also check if the physical offset reported are fakes or not */ - 1563 527 : node = scan->file_insert_list; - 1564 527 : phy_count = 0; - 1565 527 : phy_dup = 0; - 1566 527 : phy_last = FILEPHY_UNREAD_OFFSET; - 1567 527 : phy_file_last = 0; - 1568 104894 : while (node) { - 1569 103840 : struct snapraid_file* file = node->data; - 1570 : - 1571 : /* if the file is not empty, count duplicate physical offsets */ - 1572 103840 : if (state->opt.force_order == SORT_PHYSICAL && file->size != 0) { - 1573 11418 : if (phy_file_last != 0 && file->physical == phy_last - 1574 : /* files without offset are expected to have duplicates */ - 1575 0 : && phy_last != FILEPHY_WITHOUT_OFFSET - 1576 : ) { - 1577 : /* if verbose, print the list of duplicates real offsets */ - 1578 : /* other cases are for offsets not supported, so we don't need to report them file by file */ - 1579 0 : if (phy_last >= FILEPHY_REAL_OFFSET) { - 1580 0 : log_fatal("WARNING! Files '%s%s' and '%s%s' have the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last); - 1581 : } - 1582 0 : ++phy_dup; - 1583 : } - 1584 11418 : phy_file_last = file; - 1585 11418 : phy_last = file->physical; - 1586 11418 : ++phy_count; - 1587 : } - 1588 : - 1589 : /* next node */ - 1590 103840 : node = node->next; - 1591 : - 1592 : /* insert in the parity */ - 1593 103840 : scan_file_allocate(scan, file); - 1594 : } - 1595 : - 1596 : /* mark the disk without reliable physical offset if it has duplicates */ - 1597 : /* here it should never happen because we already sorted out hardlinks */ - 1598 527 : if (state->opt.force_order == SORT_PHYSICAL && phy_dup > 0) { - 1599 0 : disk->has_unreliable_physical = 1; - 1600 : } + 1486 : /* now process all the new and deleted files */ + 1487 629 : for (i = scanlist; i != 0; i = i->next) { + 1488 539 : struct snapraid_scan* scan = i->data; + 1489 539 : struct snapraid_disk* disk = scan->disk; + 1490 : tommy_node* node; + 1491 : unsigned phy_count; + 1492 : unsigned phy_dup; + 1493 : uint64_t phy_last; + 1494 : struct snapraid_file* phy_file_last; + 1495 : + 1496 : /* check for removed files */ + 1497 539 : node = disk->filelist; + 1498 975242 : while (node) { + 1499 974164 : struct snapraid_file* file = node->data; + 1500 : + 1501 : /* next node */ + 1502 974164 : node = node->next; + 1503 : + 1504 : /* remove if not present */ + 1505 974164 : if (!file_flag_has(file, FILE_IS_PRESENT)) { + 1506 29647 : ++scan->count_remove; + 1507 : + 1508 29647 : log_tag("scan:remove:%s:%s\n", disk->name, esc(file->sub)); + 1509 29647 : if (is_diff) { + 1510 97 : printf("remove %s%s\n", disk->dir, file->sub); + 1511 : } + 1512 : + 1513 29647 : scan_file_remove(scan, file); + 1514 : } + 1515 : } + 1516 : + 1517 : /* check for removed links */ + 1518 539 : node = disk->linklist; + 1519 33871 : while (node) { + 1520 32793 : struct snapraid_link* slink = node->data; + 1521 : + 1522 : /* next node */ + 1523 32793 : node = node->next; + 1524 : + 1525 : /* remove if not present */ + 1526 32793 : if (!link_flag_has(slink, FILE_IS_PRESENT)) { + 1527 956 : ++scan->count_remove; + 1528 : + 1529 956 : log_tag("scan:remove:%s:%s\n", disk->name, esc(slink->sub)); + 1530 956 : if (is_diff) { + 1531 10 : printf("remove %s%s\n", disk->dir, slink->sub); + 1532 : } + 1533 : + 1534 956 : scan_link_remove(scan, slink); + 1535 : } + 1536 : } + 1537 : + 1538 : /* check for removed dirs */ + 1539 539 : node = disk->dirlist; + 1540 1309 : while (node) { + 1541 231 : struct snapraid_dir* dir = node->data; + 1542 : + 1543 : /* next node */ + 1544 231 : node = node->next; + 1545 : + 1546 : /* remove if not present */ + 1547 231 : if (!dir_flag_has(dir, FILE_IS_PRESENT)) { + 1548 2 : scan_emptydir_remove(scan, dir); + 1549 : } + 1550 : } + 1551 : + 1552 : /* sort the files before inserting them */ + 1553 : /* we use a stable sort to ensure that if the reported physical offset/inode */ + 1554 : /* are always 0, we keep at least the directory order */ + 1555 539 : switch (state->opt.force_order) { + 1556 : case SORT_PHYSICAL : + 1557 12 : tommy_list_sort(&scan->file_insert_list, file_physical_compare); + 1558 12 : break; + 1559 : case SORT_INODE : + 1560 0 : tommy_list_sort(&scan->file_insert_list, file_inode_compare); + 1561 0 : break; + 1562 : case SORT_ALPHA : + 1563 527 : tommy_list_sort(&scan->file_insert_list, file_path_compare); + 1564 527 : break; + 1565 : case SORT_DIR : + 1566 : /* already in order */ + 1567 0 : break; + 1568 : } + 1569 : + 1570 : /* insert all the new files, we insert them only after the deletion */ + 1571 : /* to reuse the just freed space */ + 1572 : /* also check if the physical offset reported are fakes or not */ + 1573 539 : node = scan->file_insert_list; + 1574 539 : phy_count = 0; + 1575 539 : phy_dup = 0; + 1576 539 : phy_last = FILEPHY_UNREAD_OFFSET; + 1577 539 : phy_file_last = 0; + 1578 104927 : while (node) { + 1579 103849 : struct snapraid_file* file = node->data; + 1580 : + 1581 : /* if the file is not empty, count duplicate physical offsets */ + 1582 103849 : if (state->opt.force_order == SORT_PHYSICAL && file->size != 0) { + 1583 11418 : if (phy_file_last != 0 && file->physical == phy_last + 1584 : /* files without offset are expected to have duplicates */ + 1585 0 : && phy_last != FILEPHY_WITHOUT_OFFSET + 1586 : ) { + 1587 : /* if verbose, print the list of duplicates real offsets */ + 1588 : /* other cases are for offsets not supported, so we don't need to report them file by file */ + 1589 0 : if (phy_last >= FILEPHY_REAL_OFFSET) { + 1590 0 : log_fatal("WARNING! Files '%s%s' and '%s%s' have the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last); + 1591 : } + 1592 0 : ++phy_dup; + 1593 : } + 1594 11418 : phy_file_last = file; + 1595 11418 : phy_last = file->physical; + 1596 11418 : ++phy_count; + 1597 : } + 1598 : + 1599 : /* next node */ + 1600 103849 : node = node->next; 1601 : - 1602 : /* insert all the new links */ - 1603 527 : node = scan->link_insert_list; - 1604 3511 : while (node) { - 1605 2457 : struct snapraid_link* slink = node->data; - 1606 : - 1607 : /* next node */ - 1608 2457 : node = node->next; - 1609 : - 1610 : /* insert it */ - 1611 2457 : scan_link_insert(scan, slink); - 1612 : } - 1613 : - 1614 : /* insert all the new dirs */ - 1615 527 : node = scan->dir_insert_list; - 1616 1064 : while (node) { - 1617 10 : struct snapraid_dir* dir = node->data; - 1618 : - 1619 : /* next node */ - 1620 10 : node = node->next; - 1621 : - 1622 : /* insert it */ - 1623 10 : scan_emptydir_insert(scan, dir); - 1624 : } - 1625 : } - 1626 : - 1627 : /* check for disks where all the previously existing files where removed */ - 1628 88 : if (!state->opt.force_empty) { - 1629 82 : int all_missing = 0; - 1630 82 : int all_rewritten = 0; - 1631 82 : done = 0; - 1632 573 : for (i = state->disklist, j = scanlist; i != 0; i = i->next, j = j->next) { - 1633 491 : struct snapraid_disk* disk = i->data; - 1634 491 : struct snapraid_scan* scan = j->data; - 1635 : - 1636 491 : if (scan->count_equal == 0 - 1637 71 : && scan->count_move == 0 - 1638 71 : && scan->count_restore == 0 - 1639 71 : && (scan->count_remove != 0 || scan->count_change != 0) - 1640 : ) { - 1641 1 : if (!done) { - 1642 1 : done = 1; - 1643 1 : log_fatal("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir); - 1644 : } else { - 1645 0 : log_fatal(", disk '%s' at dir '%s'", disk->name, disk->dir); - 1646 : } - 1647 : - 1648 : /* detect the special condition of all files missing */ - 1649 1 : if (scan->count_change == 0) - 1650 1 : all_missing = 1; - 1651 : - 1652 : /* detect the special condition of all files rewritten */ - 1653 1 : if (scan->count_remove == 0) - 1654 0 : all_rewritten = 1; - 1655 : } - 1656 : } - 1657 82 : if (done) { - 1658 1 : log_fatal("\nare now missing or rewritten!\n"); - 1659 1 : if (all_rewritten) { - 1660 0 : log_fatal("This could happen when restoring a disk with a backup\n"); - 1661 0 : log_fatal("program that is not setting correctly the timestamps.\n"); - 1662 : } - 1663 1 : if (all_missing) { - 1664 1 : log_fatal("This could happen when some disks are not mounted\n"); - 1665 1 : log_fatal("in the expected directory.\n"); - 1666 : } - 1667 1 : if (!is_diff) { - 1668 1 : log_fatal("If you want to '%s' anyway, use 'snapraid --force-empty %s'.\n", state->command, state->command); - 1669 1 : exit(EXIT_FAILURE); - 1670 : } - 1671 : } - 1672 : } - 1673 : - 1674 : /* check for disks without the physical offset support */ - 1675 87 : if (state->opt.force_order == SORT_PHYSICAL) { - 1676 2 : done = 0; - 1677 14 : for (i = state->disklist; i != 0; i = i->next) { - 1678 12 : struct snapraid_disk* disk = i->data; - 1679 : - 1680 12 : if (disk->has_unreliable_physical) { - 1681 0 : if (!done) { - 1682 0 : done = 1; - 1683 0 : log_fatal("WARNING! Physical offsets not supported for disk '%s'", disk->name); - 1684 : } else { - 1685 0 : log_fatal(", '%s'", disk->name); - 1686 : } - 1687 : } - 1688 : } - 1689 2 : if (done) { - 1690 0 : log_fatal(". Files order won't be optimal.\n"); - 1691 : } - 1692 : } - 1693 : - 1694 : /* check for disks without persistent inodes */ - 1695 87 : done = 0; - 1696 608 : for (i = state->disklist; i != 0; i = i->next) { - 1697 521 : struct snapraid_disk* disk = i->data; - 1698 : - 1699 521 : if (disk->has_volatile_inodes) { - 1700 0 : if (!done) { - 1701 0 : done = 1; - 1702 0 : log_fatal("WARNING! Inodes are not persistent for disks: '%s'", disk->name); - 1703 : } else { - 1704 0 : log_fatal(", '%s'", disk->name); - 1705 : } - 1706 : } - 1707 : } - 1708 87 : if (done) { - 1709 0 : log_fatal(". Move operations won't be optimal.\n"); - 1710 : } - 1711 : - 1712 : /* check for disks with changed UUID */ - 1713 87 : done = 0; - 1714 608 : for (i = state->disklist; i != 0; i = i->next) { - 1715 521 : struct snapraid_disk* disk = i->data; - 1716 : - 1717 : /* don't print the message if the UUID changed because before */ - 1718 : /* it was no set. */ - 1719 : /* this is the normal condition for an empty disk because it */ - 1720 : /* isn't stored */ - 1721 521 : if (disk->has_different_uuid && !disk->had_empty_uuid) { - 1722 2 : if (!done) { - 1723 2 : done = 1; - 1724 2 : log_fatal("WARNING! UUID is changed for disks: '%s'", disk->name); - 1725 : } else { - 1726 0 : log_fatal(", '%s'", disk->name); - 1727 : } - 1728 : } - 1729 : } - 1730 87 : if (done) { - 1731 2 : log_fatal(". Move operations won't be optimal.\n"); - 1732 : } - 1733 : - 1734 : /* check for disks with unsupported UUID */ - 1735 87 : done = 0; - 1736 608 : for (i = state->disklist; i != 0; i = i->next) { - 1737 521 : struct snapraid_disk* disk = i->data; - 1738 : - 1739 521 : if (disk->has_unsupported_uuid) { - 1740 0 : if (!done) { - 1741 0 : done = 1; - 1742 0 : log_fatal("WARNING! UUID is unsupported for disks: '%s'", disk->name); - 1743 : } else { - 1744 0 : log_fatal(", '%s'", disk->name); - 1745 : } - 1746 : } - 1747 : } - 1748 87 : if (done) { - 1749 0 : log_fatal(". Move operations won't be optimal.\n"); - 1750 : #if defined(_linux) && !HAVE_BLKID - 1751 : log_fatal("The 'blkid' library is not linked in SnapRAID!\n"); - 1752 : log_fatal("Try rebuilding it after installing the libblkid-dev/devel package.\n"); - 1753 : #endif - 1754 : } - 1755 : - 1756 87 : total.count_equal = 0; - 1757 87 : total.count_move = 0; - 1758 87 : total.count_copy = 0; - 1759 87 : total.count_restore = 0; - 1760 87 : total.count_change = 0; - 1761 87 : total.count_remove = 0; - 1762 87 : total.count_insert = 0; - 1763 : - 1764 608 : for (i = scanlist; i != 0; i = i->next) { - 1765 521 : struct snapraid_scan* scan = i->data; - 1766 521 : total.count_equal += scan->count_equal; - 1767 521 : total.count_move += scan->count_move; - 1768 521 : total.count_copy += scan->count_copy; - 1769 521 : total.count_restore += scan->count_restore; - 1770 521 : total.count_change += scan->count_change; - 1771 521 : total.count_remove += scan->count_remove; - 1772 521 : total.count_insert += scan->count_insert; - 1773 : } - 1774 : - 1775 87 : if (is_diff) { - 1776 7 : msg_status("\n"); - 1777 7 : msg = msg_status; - 1778 : } else { - 1779 80 : msg = msg_verbose; - 1780 : } - 1781 : - 1782 87 : msg("%8u equal\n", total.count_equal); - 1783 87 : msg("%8u moved\n", total.count_move); - 1784 87 : msg("%8u copied\n", total.count_copy); - 1785 87 : msg("%8u restored\n", total.count_restore); - 1786 87 : msg("%8u updated\n", total.count_change); - 1787 87 : msg("%8u removed\n", total.count_remove); - 1788 87 : msg("%8u added\n", total.count_insert); - 1789 : - 1790 87 : log_tag("summary:equal:%u\n", total.count_equal); - 1791 87 : log_tag("summary:moved:%u\n", total.count_move); - 1792 87 : log_tag("summary:copied:%u\n", total.count_copy); - 1793 87 : log_tag("summary:restored:%u\n", total.count_restore); - 1794 87 : log_tag("summary:updated:%u\n", total.count_change); - 1795 87 : log_tag("summary:removed:%u\n", total.count_remove); - 1796 87 : log_tag("summary:added:%u\n", total.count_insert); - 1797 : - 1798 260 : no_difference = !total.count_move && !total.count_copy && !total.count_restore - 1799 144 : && !total.count_change && !total.count_remove && !total.count_insert; - 1800 : - 1801 87 : if (is_diff) { - 1802 7 : if (no_difference) { - 1803 1 : msg_status("No differences\n"); - 1804 : } else { - 1805 6 : msg_status("There are differences!\n"); - 1806 : } - 1807 : } - 1808 : - 1809 87 : if (no_difference) { - 1810 14 : log_tag("summary:exit:equal\n"); - 1811 : } else { - 1812 73 : log_tag("summary:exit:diff\n"); - 1813 : } - 1814 87 : log_flush(); - 1815 : - 1816 87 : tommy_list_foreach(&scanlist, (tommy_foreach_func*)free); - 1817 : - 1818 : /* check the file-system on all disks */ - 1819 87 : state_fscheck(state, "after scan"); - 1820 : - 1821 87 : if (is_diff) { - 1822 : /* check for file difference */ - 1823 7 : if (!no_difference) - 1824 6 : return 1; + 1602 : /* insert in the parity */ + 1603 103849 : scan_file_allocate(scan, file); + 1604 : } + 1605 : + 1606 : /* mark the disk without reliable physical offset if it has duplicates */ + 1607 : /* here it should never happen because we already sorted out hardlinks */ + 1608 539 : if (state->opt.force_order == SORT_PHYSICAL && phy_dup > 0) { + 1609 0 : disk->has_unreliable_physical = 1; + 1610 : } + 1611 : + 1612 : /* insert all the new links */ + 1613 539 : node = scan->link_insert_list; + 1614 3535 : while (node) { + 1615 2457 : struct snapraid_link* slink = node->data; + 1616 : + 1617 : /* next node */ + 1618 2457 : node = node->next; + 1619 : + 1620 : /* insert it */ + 1621 2457 : scan_link_insert(scan, slink); + 1622 : } + 1623 : + 1624 : /* insert all the new dirs */ + 1625 539 : node = scan->dir_insert_list; + 1626 1088 : while (node) { + 1627 10 : struct snapraid_dir* dir = node->data; + 1628 : + 1629 : /* next node */ + 1630 10 : node = node->next; + 1631 : + 1632 : /* insert it */ + 1633 10 : scan_emptydir_insert(scan, dir); + 1634 : } + 1635 : } + 1636 : + 1637 : /* check for disks where all the previously existing files where removed */ + 1638 90 : if (!state->opt.force_empty) { + 1639 84 : int all_missing = 0; + 1640 84 : int all_rewritten = 0; + 1641 84 : done = 0; + 1642 587 : for (i = state->disklist, j = scanlist; i != 0; i = i->next, j = j->next) { + 1643 503 : struct snapraid_disk* disk = i->data; + 1644 503 : struct snapraid_scan* scan = j->data; + 1645 : + 1646 503 : if (scan->count_equal == 0 + 1647 73 : && scan->count_move == 0 + 1648 73 : && scan->count_restore == 0 + 1649 73 : && (scan->count_remove != 0 || scan->count_change != 0) + 1650 : ) { + 1651 1 : if (!done) { + 1652 1 : done = 1; + 1653 1 : log_fatal("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir); + 1654 : } else { + 1655 0 : log_fatal(", disk '%s' at dir '%s'", disk->name, disk->dir); + 1656 : } + 1657 : + 1658 : /* detect the special condition of all files missing */ + 1659 1 : if (scan->count_change == 0) + 1660 1 : all_missing = 1; + 1661 : + 1662 : /* detect the special condition of all files rewritten */ + 1663 1 : if (scan->count_remove == 0) + 1664 0 : all_rewritten = 1; + 1665 : } + 1666 : } + 1667 84 : if (done) { + 1668 1 : log_fatal("\nare now missing or rewritten!\n"); + 1669 1 : if (all_rewritten) { + 1670 0 : log_fatal("This could happen when restoring a disk with a backup\n"); + 1671 0 : log_fatal("program that is not setting correctly the timestamps.\n"); + 1672 : } + 1673 1 : if (all_missing) { + 1674 1 : log_fatal("This could happen when some disks are not mounted\n"); + 1675 1 : log_fatal("in the expected directory.\n"); + 1676 : } + 1677 1 : if (!is_diff) { + 1678 1 : log_fatal("If you want to '%s' anyway, use 'snapraid --force-empty %s'.\n", state->command, state->command); + 1679 1 : exit(EXIT_FAILURE); + 1680 : } + 1681 : } + 1682 : } + 1683 : + 1684 : /* check for disks without the physical offset support */ + 1685 89 : if (state->opt.force_order == SORT_PHYSICAL) { + 1686 2 : done = 0; + 1687 14 : for (i = state->disklist; i != 0; i = i->next) { + 1688 12 : struct snapraid_disk* disk = i->data; + 1689 : + 1690 12 : if (disk->has_unreliable_physical) { + 1691 0 : if (!done) { + 1692 0 : done = 1; + 1693 0 : log_fatal("WARNING! Physical offsets not supported for disk '%s'", disk->name); + 1694 : } else { + 1695 0 : log_fatal(", '%s'", disk->name); + 1696 : } + 1697 : } + 1698 : } + 1699 2 : if (done) { + 1700 0 : log_fatal(". Files order won't be optimal.\n"); + 1701 : } + 1702 : } + 1703 : + 1704 : /* check for disks without persistent inodes */ + 1705 89 : done = 0; + 1706 622 : for (i = state->disklist; i != 0; i = i->next) { + 1707 533 : struct snapraid_disk* disk = i->data; + 1708 : + 1709 533 : if (disk->has_volatile_inodes) { + 1710 0 : if (!done) { + 1711 0 : done = 1; + 1712 0 : log_fatal("WARNING! Inodes are not persistent for disks: '%s'", disk->name); + 1713 : } else { + 1714 0 : log_fatal(", '%s'", disk->name); + 1715 : } + 1716 : } + 1717 : } + 1718 89 : if (done) { + 1719 0 : log_fatal(". Move operations won't be optimal.\n"); + 1720 : } + 1721 : + 1722 : /* check for disks with changed UUID */ + 1723 89 : done = 0; + 1724 622 : for (i = state->disklist; i != 0; i = i->next) { + 1725 533 : struct snapraid_disk* disk = i->data; + 1726 : + 1727 : /* don't print the message if the UUID changed because before */ + 1728 : /* it was no set. */ + 1729 : /* this is the normal condition for an empty disk because it */ + 1730 : /* isn't stored */ + 1731 533 : if (disk->has_different_uuid && !disk->had_empty_uuid) { + 1732 4 : if (!done) { + 1733 2 : done = 1; + 1734 2 : log_fatal("WARNING! UUID is changed for disks: '%s'", disk->name); + 1735 : } else { + 1736 2 : log_fatal(", '%s'", disk->name); + 1737 : } + 1738 : } + 1739 : } + 1740 89 : if (done) { + 1741 2 : log_fatal(". Move operations won't be optimal.\n"); + 1742 : } + 1743 : + 1744 : /* check for disks with unsupported UUID */ + 1745 89 : done = 0; + 1746 622 : for (i = state->disklist; i != 0; i = i->next) { + 1747 533 : struct snapraid_disk* disk = i->data; + 1748 : + 1749 533 : if (disk->has_unsupported_uuid) { + 1750 0 : if (!done) { + 1751 0 : done = 1; + 1752 0 : log_fatal("WARNING! UUID is unsupported for disks: '%s'", disk->name); + 1753 : } else { + 1754 0 : log_fatal(", '%s'", disk->name); + 1755 : } + 1756 : } + 1757 : } + 1758 89 : if (done) { + 1759 0 : log_fatal(". Move operations won't be optimal.\n"); + 1760 : #if defined(_linux) && !HAVE_BLKID + 1761 : log_fatal("The 'blkid' library is not linked in SnapRAID!\n"); + 1762 : log_fatal("Try rebuilding it after installing the libblkid-dev/devel package.\n"); + 1763 : #endif + 1764 : } + 1765 : + 1766 89 : total.count_equal = 0; + 1767 89 : total.count_move = 0; + 1768 89 : total.count_copy = 0; + 1769 89 : total.count_restore = 0; + 1770 89 : total.count_change = 0; + 1771 89 : total.count_remove = 0; + 1772 89 : total.count_insert = 0; + 1773 : + 1774 622 : for (i = scanlist; i != 0; i = i->next) { + 1775 533 : struct snapraid_scan* scan = i->data; + 1776 533 : total.count_equal += scan->count_equal; + 1777 533 : total.count_move += scan->count_move; + 1778 533 : total.count_copy += scan->count_copy; + 1779 533 : total.count_restore += scan->count_restore; + 1780 533 : total.count_change += scan->count_change; + 1781 533 : total.count_remove += scan->count_remove; + 1782 533 : total.count_insert += scan->count_insert; + 1783 : } + 1784 : + 1785 89 : if (is_diff) { + 1786 7 : msg_status("\n"); + 1787 7 : msg = msg_status; + 1788 : } else { + 1789 82 : msg = msg_verbose; + 1790 : } + 1791 : + 1792 89 : msg("%8u equal\n", total.count_equal); + 1793 89 : msg("%8u moved\n", total.count_move); + 1794 89 : msg("%8u copied\n", total.count_copy); + 1795 89 : msg("%8u restored\n", total.count_restore); + 1796 89 : msg("%8u updated\n", total.count_change); + 1797 89 : msg("%8u removed\n", total.count_remove); + 1798 89 : msg("%8u added\n", total.count_insert); + 1799 : + 1800 89 : log_tag("summary:equal:%u\n", total.count_equal); + 1801 89 : log_tag("summary:moved:%u\n", total.count_move); + 1802 89 : log_tag("summary:copied:%u\n", total.count_copy); + 1803 89 : log_tag("summary:restored:%u\n", total.count_restore); + 1804 89 : log_tag("summary:updated:%u\n", total.count_change); + 1805 89 : log_tag("summary:removed:%u\n", total.count_remove); + 1806 89 : log_tag("summary:added:%u\n", total.count_insert); + 1807 : + 1808 266 : no_difference = !total.count_move && !total.count_copy && !total.count_restore + 1809 147 : && !total.count_change && !total.count_remove && !total.count_insert; + 1810 : + 1811 89 : if (is_diff) { + 1812 7 : if (no_difference) { + 1813 1 : msg_status("No differences\n"); + 1814 : } else { + 1815 6 : msg_status("There are differences!\n"); + 1816 : } + 1817 : } + 1818 : + 1819 89 : if (no_difference) { + 1820 14 : log_tag("summary:exit:equal\n"); + 1821 : } else { + 1822 75 : log_tag("summary:exit:diff\n"); + 1823 : } + 1824 89 : log_flush(); 1825 : - 1826 : /* check also for incomplete "sync" */ - 1827 1 : if (parity_is_invalid(state)) - 1828 0 : return 1; - 1829 : } + 1826 89 : tommy_list_foreach(&scanlist, (tommy_foreach_func*)free); + 1827 : + 1828 : /* check the file-system on all disks */ + 1829 89 : state_fscheck(state, "after scan"); 1830 : - 1831 81 : return 0; - 1832 : } - 1833 : - 1834 7 : int state_diff(struct snapraid_state* state) - 1835 : { - 1836 7 : return state_diffscan(state, 1); - 1837 : } - 1838 : - 1839 81 : void state_scan(struct snapraid_state* state) - 1840 : { - 1841 81 : (void)state_diffscan(state, 0); /* ignore return value */ - 1842 80 : } + 1831 89 : if (is_diff) { + 1832 : /* check for file difference */ + 1833 7 : if (!no_difference) + 1834 6 : return 1; + 1835 : + 1836 : /* check also for incomplete "sync" */ + 1837 1 : if (parity_is_invalid(state)) + 1838 0 : return 1; + 1839 : } + 1840 : + 1841 83 : return 0; + 1842 : } 1843 : + 1844 7 : int state_diff(struct snapraid_state* state) + 1845 : { + 1846 7 : return state_diffscan(state, 1); + 1847 : } + 1848 : + 1849 83 : void state_scan(struct snapraid_state* state) + 1850 : { + 1851 83 : (void)state_diffscan(state, 0); /* ignore return value */ + 1852 82 : } + 1853 : diff --git a/cov/cmdline/scrub.c.func-sort-c.html b/cov/cmdline/scrub.c.func-sort-c.html index 677e4c72..81cdf449 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-01-09 + 2016-01-16 Functions: 4 @@ -61,7 +61,7 @@ block_is_enabled - 111994 + 112170 state_scrub_process diff --git a/cov/cmdline/scrub.c.func.html b/cov/cmdline/scrub.c.func.html index 0a104426..633c2227 100644 --- a/cov/cmdline/scrub.c.func.html +++ b/cov/cmdline/scrub.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,7 +61,7 @@ block_is_enabled - 111994 + 112170 md diff --git a/cov/cmdline/scrub.c.gcov.html b/cov/cmdline/scrub.c.gcov.html index d8624e9e..48fcd4c2 100644 --- a/cov/cmdline/scrub.c.gcov.html +++ b/cov/cmdline/scrub.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -110,55 +110,55 @@ 48 : /** 49 : * Check if we have to process the specified block index ::i. 50 : */ - 51 111994 : static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct snapraid_plan* plan) + 51 112170 : static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct snapraid_plan* plan) 52 : { 53 : time_t blocktime; 54 : snapraid_info info; 55 : 56 : /* don't scrub unused blocks in all plans */ - 57 111994 : info = info_get(&state->infoarr, i); - 58 111994 : if (info == 0) + 57 112170 : info = info_get(&state->infoarr, i); + 58 112170 : if (info == 0) 59 0 : return 0; 60 : 61 : /* bad blocks are always scrubbed in all plans */ - 62 111994 : if (info_get_bad(info)) - 63 3542 : return 1; + 62 112170 : if (info_get_bad(info)) + 63 3544 : return 1; 64 : - 65 108452 : switch (plan->plan) { + 65 108626 : switch (plan->plan) { 66 : case SCRUB_FULL : 67 : /* in 'full' plan everything is scrubbed */ - 68 17014 : return 1; + 68 17044 : return 1; 69 : case SCRUB_EVEN : 70 : /* in 'even' plan, scrub only even blocks */ - 71 18414 : return i % 2 == 0; + 71 18430 : return i % 2 == 0; 72 : case SCRUB_NEW : 73 : /* in 'sync' plan, only blocks never scrubbed */ - 74 9358 : return info_get_justsynced(info); + 74 9374 : return info_get_justsynced(info); 75 : case SCRUB_BAD : 76 : /* in 'bad' plan, only bad blocks (already reported) */ - 77 7518 : return 0; + 77 7534 : return 0; 78 : } 79 : 80 : /* if it's too new */ - 81 56148 : blocktime = info_get_time(info); - 82 56148 : if (blocktime > plan->timelimit) { + 81 56244 : blocktime = info_get_time(info); + 82 56244 : if (blocktime > plan->timelimit) { 83 : /* skip it */ - 84 20662 : return 0; + 84 20726 : return 0; 85 : } 86 : 87 : /* if the time is less than the limit, always include */ 88 : /* otherwise, check if we reached the last limit count */ - 89 35486 : if (blocktime == plan->timelimit) { + 89 35518 : if (blocktime == plan->timelimit) { 90 : /* if we reached the count limit */ - 91 18980 : if (plan->countlast >= plan->lastlimit) { + 91 18780 : if (plan->countlast >= plan->lastlimit) { 92 : /* skip it */ - 93 13790 : return 0; + 93 13788 : return 0; 94 : } 95 : - 96 5190 : ++plan->countlast; + 96 4992 : ++plan->countlast; 97 : } 98 : - 99 21696 : return 1; + 99 21730 : return 1; 100 : } 101 : 102 11 : static int state_scrub_process(struct snapraid_state* state, struct snapraid_parity_handle** parity, block_off_t blockstart, block_off_t blockmax, struct snapraid_plan* plan, time_t now) @@ -204,11 +204,11 @@ 142 : /* first count the number of blocks to process */ 143 11 : countmax = 0; 144 11 : plan->countlast = 0; - 145 56008 : for (i = blockstart; i < blockmax; ++i) { - 146 55997 : if (!block_is_enabled(state, i, plan)) - 147 28002 : continue; + 145 56096 : for (i = blockstart; i < blockmax; ++i) { + 146 56085 : if (!block_is_enabled(state, i, plan)) + 147 28053 : continue; 148 : - 149 27995 : ++countmax; + 149 28032 : ++countmax; 150 : } 151 : 152 : /* compute the autosave size for all disk, even if not read */ @@ -225,7 +225,7 @@ 163 11 : countpos = 0; 164 11 : plan->countlast = 0; 165 11 : state_progress_begin(state, blockstart, blockmax, countmax); - 166 56008 : for (i = blockstart; i < blockmax; ++i) { + 166 56096 : for (i = blockstart; i < blockmax; ++i) { 167 : snapraid_info info; 168 : int error_on_this_block; 169 : int silent_error_on_this_block; @@ -233,65 +233,65 @@ 171 : int block_is_unsynced; 172 : int rehash; 173 : - 174 55997 : if (!block_is_enabled(state, i, plan)) - 175 28002 : continue; + 174 56085 : if (!block_is_enabled(state, i, plan)) + 175 28053 : continue; 176 : 177 : /* one more block processed for autosave */ - 178 27995 : ++autosavedone; - 179 27995 : --autosavemissing; + 178 28032 : ++autosavedone; + 179 28032 : --autosavemissing; 180 : 181 : /* by default process the block, and skip it if something goes wrong */ - 182 27995 : error_on_this_block = 0; - 183 27995 : silent_error_on_this_block = 0; - 184 27995 : io_error_on_this_block = 0; + 182 28032 : error_on_this_block = 0; + 183 28032 : silent_error_on_this_block = 0; + 184 28032 : io_error_on_this_block = 0; 185 : 186 : /* if all the blocks at this address are synced */ 187 : /* if not, parity is not even checked */ - 188 27995 : block_is_unsynced = 0; + 188 28032 : block_is_unsynced = 0; 189 : 190 : /* get block specific info */ - 191 27995 : info = info_get(&state->infoarr, i); + 191 28032 : info = info_get(&state->infoarr, i); 192 : 193 : /* if we have to use the old hash */ - 194 27995 : rehash = info_get_rehash(info); + 194 28032 : rehash = info_get_rehash(info); 195 : 196 : /* for each disk, process the block */ - 197 195965 : for (j = 0; j < diskmax; ++j) { + 197 196224 : for (j = 0; j < diskmax; ++j) { 198 : int read_size; 199 : unsigned char hash[HASH_SIZE]; 200 : struct snapraid_block* block; 201 : int file_is_unsynced; - 202 167970 : struct snapraid_disk* disk = handle[j].disk; + 202 168192 : struct snapraid_disk* disk = handle[j].disk; 203 : struct snapraid_file* file; 204 : block_off_t file_pos; 205 : 206 : /* if the file on this disk is synced */ 207 : /* if not, silent errors are assumed as expected error */ - 208 167970 : file_is_unsynced = 0; + 208 168192 : file_is_unsynced = 0; 209 : 210 : /* by default no rehash in case of "continue" */ - 211 167970 : rehandle[j].block = 0; + 211 168192 : rehandle[j].block = 0; 212 : 213 : /* if the disk position is not used */ - 214 167970 : if (!disk) { + 214 168192 : if (!disk) { 215 : /* use an empty block */ 216 0 : memset(buffer[j], 0, state->block_size); - 217 2397 : continue; + 217 2505 : continue; 218 : } 219 : 220 : /* if the block is not used */ - 221 167970 : block = fs_par2block_get(disk, i); - 222 167970 : if (!block_has_file(block)) { + 221 168192 : block = fs_par2block_get(disk, i); + 222 168192 : if (!block_has_file(block)) { 223 : /* use an empty block */ - 224 1477 : memset(buffer[j], 0, state->block_size); - 225 1477 : continue; + 224 1585 : memset(buffer[j], 0, state->block_size); + 225 1585 : continue; 226 : } 227 : 228 : /* get the file of this block */ - 229 166493 : file = fs_par2file_get(disk, i, &file_pos); + 229 166607 : file = fs_par2file_get(disk, i, &file_pos); 230 : 231 : /* if the block is unsynced, errors are expected */ - 232 166493 : if (block_has_invalid_parity(block)) { + 232 166607 : if (block_has_invalid_parity(block)) { 233 : /* report that the block and the file are not synced */ 234 0 : block_is_unsynced = 1; 235 0 : file_is_unsynced = 1; @@ -299,14 +299,14 @@ 237 : } 238 : 239 : /* until now is CPU */ - 240 166493 : state_usage_cpu(state); + 240 166607 : state_usage_cpu(state); 241 : 242 : /* if the file is different than the current one, close it */ - 243 166493 : if (handle[j].file != 0 && handle[j].file != file) { + 243 166607 : if (handle[j].file != 0 && handle[j].file != file) { 244 : /* keep a pointer at the file we are going to close for error reporting */ - 245 78228 : struct snapraid_file* report = handle[j].file; - 246 78228 : ret = handle_close(&handle[j]); - 247 78228 : if (ret == -1) { + 245 78218 : struct snapraid_file* report = handle[j].file; + 246 78218 : ret = handle_close(&handle[j]); + 247 78218 : if (ret == -1) { 248 : /* LCOV_EXCL_START */ 249 : /* This one is really an unexpected error, because we are only reading */ 250 : /* and closing a descriptor should never fail */ @@ -329,8 +329,8 @@ 267 : } 268 : } 269 : - 270 166493 : ret = handle_open(&handle[j], file, state->file_mode, log_error, 0); - 271 166493 : if (ret == -1) { + 270 166607 : ret = handle_open(&handle[j], file, state->file_mode, log_error, 0); + 271 166607 : if (ret == -1) { 272 0 : if (errno == EIO) { 273 : /* LCOV_EXCL_START */ 274 : log_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); @@ -349,14 +349,14 @@ 287 : } 288 : 289 : /* check if the file is changed */ - 290 166493 : if (handle[j].st.st_size != file->size - 291 166493 : || handle[j].st.st_mtime != file->mtime_sec - 292 160895 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec + 290 166607 : if (handle[j].st.st_size != file->size + 291 166607 : || handle[j].st.st_mtime != file->mtime_sec + 292 161012 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec 293 : /* don't check the inode to support file-system without persistent inodes */ 294 : ) { 295 : /* report that the block and the file are not synced */ - 296 5598 : block_is_unsynced = 1; - 297 5598 : file_is_unsynced = 1; + 296 5595 : block_is_unsynced = 1; + 297 5595 : file_is_unsynced = 1; 298 : /* follow */ 299 : } 300 : @@ -364,8 +364,8 @@ 302 : /* from the last sync, as we are expected to return errors if running */ 303 : /* in an unsynced array. This is just like the check command. */ 304 : - 305 166493 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, log_error, 0); - 306 166493 : if (read_size == -1) { + 305 166607 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, log_error, 0); + 306 166607 : if (read_size == -1) { 307 0 : if (errno == EIO) { 308 0 : log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), file_pos, strerror(errno)); 309 0 : if (io_error >= state->opt.io_error_limit) { @@ -391,24 +391,24 @@ 329 : } 330 : 331 : /* until now is disk */ - 332 166493 : state_usage_disk(state, disk); + 332 166607 : state_usage_disk(state, disk); 333 : - 334 166493 : countsize += read_size; + 334 166607 : countsize += read_size; 335 : 336 : /* now compute the hash */ - 337 166493 : if (rehash) { - 338 27235 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); + 337 166607 : if (rehash) { + 338 27247 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); 339 : 340 : /* compute the new hash, and store it */ - 341 27235 : rehandle[j].block = block; - 342 27235 : memhash(state->hash, state->hashseed, rehandle[j].hash, buffer[j], read_size); + 341 27247 : rehandle[j].block = block; + 342 27247 : memhash(state->hash, state->hashseed, rehandle[j].hash, buffer[j], read_size); 343 : } else { - 344 139258 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); + 344 139360 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); 345 : } 346 : - 347 166493 : if (block_has_updated_hash(block)) { + 347 166607 : if (block_has_updated_hash(block)) { 348 : /* compare the hash */ - 349 166493 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { + 349 166607 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { 350 920 : unsigned diff = memdiff(hash, block->hash, HASH_SIZE); 351 : 352 920 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc(file->sub), file_pos, diff); @@ -428,22 +428,22 @@ 366 : } 367 : 368 : /* if we have read all the data required and it's correct, proceed with the parity check */ - 369 27995 : if (!error_on_this_block && !silent_error_on_this_block && !io_error_on_this_block) { + 369 28032 : if (!error_on_this_block && !silent_error_on_this_block && !io_error_on_this_block) { 370 : unsigned char* buffer_recov[LEV_MAX]; 371 : 372 : /* until now is CPU */ - 373 27075 : state_usage_cpu(state); + 373 27112 : state_usage_cpu(state); 374 : 375 : /* buffers for parity read and not computed */ - 376 189525 : for (l = 0; l < state->level; ++l) - 377 162450 : buffer_recov[l] = buffer[diskmax + state->level + l]; - 378 27075 : for (; l < LEV_MAX; ++l) + 376 189784 : for (l = 0; l < state->level; ++l) + 377 162672 : buffer_recov[l] = buffer[diskmax + state->level + l]; + 378 27112 : for (; l < LEV_MAX; ++l) 379 0 : buffer_recov[l] = 0; 380 : 381 : /* read the parity */ - 382 189525 : for (l = 0; l < state->level; ++l) { - 383 162450 : ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error); - 384 162450 : if (ret == -1) { + 382 189784 : for (l = 0; l < state->level; ++l) { + 383 162672 : ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error); + 384 162672 : if (ret == -1) { 385 0 : buffer_recov[l] = 0; 386 : 387 0 : if (errno == EIO) { @@ -471,15 +471,15 @@ 409 : } 410 : 411 : /* until now is parity */ - 412 162450 : state_usage_parity(state, l); + 412 162672 : state_usage_parity(state, l); 413 : } 414 : 415 : /* compute the parity */ - 416 27075 : raid_gen(diskmax, state->level, state->block_size, buffer); + 416 27112 : raid_gen(diskmax, state->level, state->block_size, buffer); 417 : 418 : /* compare the parity */ - 419 189525 : for (l = 0; l < state->level; ++l) { - 420 162450 : if (buffer_recov[l] && memcmp(buffer[diskmax + l], buffer_recov[l], state->block_size) != 0) { + 419 189784 : for (l = 0; l < state->level; ++l) { + 420 162672 : if (buffer_recov[l] && memcmp(buffer[diskmax + l], buffer_recov[l], state->block_size) != 0) { 421 0 : unsigned diff = memdiff(buffer[diskmax + l], buffer_recov[l], state->block_size); 422 : 423 0 : log_tag("parity_error:%u:%s: Data error, diff bits %u\n", i, lev_config_name(l), diff); @@ -497,42 +497,42 @@ 435 : } 436 : } 437 : - 438 27995 : if (silent_error_on_this_block || io_error_on_this_block) { + 438 28032 : if (silent_error_on_this_block || io_error_on_this_block) { 439 : /* set the error status keeping other info */ 440 920 : info_set(&state->infoarr, i, info_set_bad(info)); - 441 27075 : } else if (error_on_this_block) { + 441 27112 : } else if (error_on_this_block) { 442 : /* do nothing, as this is a generic error */ 443 : /* likely caused by a not synced array */ 444 : } else { 445 : /* if rehash is needed */ - 446 27075 : if (rehash) { + 446 27112 : if (rehash) { 447 : /* store all the new hash already computed */ - 448 32228 : for (j = 0; j < diskmax; ++j) { - 449 27624 : if (rehandle[j].block) - 450 27235 : memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE); + 448 32256 : for (j = 0; j < diskmax; ++j) { + 449 27648 : if (rehandle[j].block) + 450 27247 : memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE); 451 : } 452 : } 453 : 454 : /* update the time info of the block */ 455 : /* and clear any other flag */ - 456 27075 : info_set(&state->infoarr, i, info_make(now, 0, 0, 0)); + 456 27112 : info_set(&state->infoarr, i, info_make(now, 0, 0, 0)); 457 : } 458 : 459 : /* mark the state as needing write */ - 460 27995 : state->need_write = 1; + 460 28032 : state->need_write = 1; 461 : 462 : /* count the number of processed block */ - 463 27995 : ++countpos; + 463 28032 : ++countpos; 464 : 465 : /* progress */ - 466 27995 : if (state_progress(state, i, countpos, countmax, countsize)) { + 466 28032 : if (state_progress(state, i, countpos, countmax, countsize)) { 467 : /* LCOV_EXCL_START */ 468 : break; 469 : /* LCOV_EXCL_STOP */ 470 : } 471 : 472 : /* autosave */ - 473 27995 : if (state->autosave != 0 + 473 28032 : if (state->autosave != 0 474 0 : && autosavedone >= autosavelimit /* if we have reached the limit */ 475 0 : && autosavemissing >= autosavelimit /* if we have at least a full step to do */ 476 : ) { @@ -705,14 +705,14 @@ 643 : /* copy the info in the temp vector */ 644 11 : count = 0; 645 11 : log_tag("block_count:%u\n", blockmax); - 646 56008 : for (i = 0; i < blockmax; ++i) { - 647 55997 : snapraid_info info = info_get(&state->infoarr, i); + 646 56096 : for (i = 0; i < blockmax; ++i) { + 647 56085 : snapraid_info info = info_get(&state->infoarr, i); 648 : 649 : /* skip unused blocks */ - 650 55997 : if (info == 0) + 650 56085 : if (info == 0) 651 0 : continue; 652 : - 653 55997 : timemap[count++] = info_get_time(info); + 653 56085 : timemap[count++] = info_get_time(info); 654 : } 655 : 656 11 : if (!count) { @@ -728,12 +728,12 @@ 666 : /* output the info map */ 667 11 : i = 0; 668 11 : log_tag("info_count:%u\n", count); - 669 49 : while (i < count) { - 670 27 : unsigned j = i + 1; - 671 56024 : while (j < count && timemap[i] == timemap[j]) - 672 55970 : ++j; - 673 27 : log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)timemap[i], j - i); - 674 27 : i = j; + 669 51 : while (i < count) { + 670 29 : unsigned j = i + 1; + 671 56114 : while (j < count && timemap[i] == timemap[j]) + 672 56056 : ++j; + 673 29 : log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)timemap[i], j - i); + 674 29 : i = j; 675 : } 676 : 677 : /* compute the limits from count/recentlimit */ @@ -754,8 +754,8 @@ 692 : /* count how many entries for this exact time we have to scrub */ 693 : /* if the blocks have all the same time, we end with countlimit == lastlimit */ 694 5 : ps.lastlimit = 1; - 695 2600 : while (countlimit > ps.lastlimit && timemap[countlimit - ps.lastlimit - 1] == ps.timelimit) - 696 2590 : ++ps.lastlimit; + 695 2501 : while (countlimit > ps.lastlimit && timemap[countlimit - ps.lastlimit - 1] == ps.timelimit) + 696 2491 : ++ps.lastlimit; 697 : } else { 698 : /* if nothing to scrub, disable also other limits */ 699 1 : ps.timelimit = 0; diff --git a/cov/cmdline/search.c.func-sort-c.html b/cov/cmdline/search.c.func-sort-c.html index b4963364..21c7cda5 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-01-09 + 2016-01-16 Functions: 7 @@ -61,19 +61,19 @@ search_file - 1843303 + 1843992 search_file_free - 1843303 + 1843992 state_search_fetch - 639672 + 639116 search_file_compare - 20073 + 20091 search_dir diff --git a/cov/cmdline/search.c.func.html b/cov/cmdline/search.c.func.html index bc92b8ca..c07919b8 100644 --- a/cov/cmdline/search.c.func.html +++ b/cov/cmdline/search.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 @@ -65,15 +65,15 @@ search_file - 1843303 + 1843992 search_file_compare - 20073 + 20091 search_file_free - 1843303 + 1843992 state_search @@ -85,7 +85,7 @@ state_search_fetch - 639672 + 639116
diff --git a/cov/cmdline/search.c.gcov.html b/cov/cmdline/search.c.gcov.html index 06f79786..f354c3db 100644 --- a/cov/cmdline/search.c.gcov.html +++ b/cov/cmdline/search.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 @@ -85,27 +85,27 @@ 23 : /****************************************************************************/ 24 : /* search */ 25 : - 26 1843303 : static void search_file(struct snapraid_state* state, const char* path, data_off_t size, int64_t mtime_sec, int mtime_nsec) + 26 1843992 : 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 1843303 : file = malloc_nofail(sizeof(struct snapraid_search_file)); - 32 1843303 : file->path = strdup_nofail(path); - 33 1843303 : file->size = size; - 34 1843303 : file->mtime_sec = mtime_sec; - 35 1843303 : file->mtime_nsec = mtime_nsec; + 31 1843992 : file = malloc_nofail(sizeof(struct snapraid_search_file)); + 32 1843992 : file->path = strdup_nofail(path); + 33 1843992 : file->size = size; + 34 1843992 : file->mtime_sec = mtime_sec; + 35 1843992 : file->mtime_nsec = mtime_nsec; 36 : - 37 1843303 : file_hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); + 37 1843992 : file_hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); 38 : - 39 1843303 : tommy_hashdyn_insert(&state->searchset, &file->node, file, file_hash); - 40 1843303 : } + 39 1843992 : tommy_hashdyn_insert(&state->searchset, &file->node, file, file_hash); + 40 1843992 : } 41 : - 42 1843303 : void search_file_free(struct snapraid_search_file* file) + 42 1843992 : void search_file_free(struct snapraid_search_file* file) 43 : { - 44 1843303 : free(file->path); - 45 1843303 : free(file); - 46 1843303 : } + 44 1843992 : free(file->path); + 45 1843992 : free(file); + 46 1843992 : } 47 : 48 : struct search_file_compare_arg { 49 : const struct snapraid_state* state; @@ -117,29 +117,29 @@ 55 : int prevhash; 56 : }; 57 : - 58 20073 : int search_file_compare(const void* void_arg, const void* void_data) + 58 20091 : int search_file_compare(const void* void_arg, const void* void_data) 59 : { - 60 20073 : const struct search_file_compare_arg* arg = void_arg; - 61 20073 : const struct snapraid_search_file* file = void_data; - 62 20073 : const struct snapraid_state* state = arg->state; + 60 20091 : const struct search_file_compare_arg* arg = void_arg; + 61 20091 : const struct snapraid_search_file* file = void_data; + 62 20091 : const struct snapraid_state* state = arg->state; 63 : unsigned char buffer_hash[HASH_SIZE]; - 64 20073 : const char* path = file->path; + 64 20091 : const char* path = file->path; 65 : int f; 66 : ssize_t ret; 67 : 68 : /* compare file info */ - 69 20073 : if (arg->file->size != file->size) + 69 20091 : if (arg->file->size != file->size) 70 0 : return -1; 71 : - 72 20073 : if (arg->file->mtime_sec != file->mtime_sec) + 72 20091 : if (arg->file->mtime_sec != file->mtime_sec) 73 0 : return -1; 74 : - 75 20073 : if (arg->file->mtime_nsec != file->mtime_nsec) + 75 20091 : if (arg->file->mtime_nsec != file->mtime_nsec) 76 0 : return -1; 77 : 78 : /* read the block and compare the hash */ - 79 20073 : f = open(path, O_RDONLY | O_BINARY); - 80 20073 : if (f == -1) { + 79 20091 : f = open(path, O_RDONLY | O_BINARY); + 80 20091 : if (f == -1) { 81 : /* LCOV_EXCL_START */ 82 : if (errno == ENOENT) { 83 : log_fatal("DANGER! file '%s' disappeared.\n", path); @@ -151,23 +151,23 @@ 89 : /* LCOV_EXCL_STOP */ 90 : } 91 : - 92 20073 : if (lseek(f, arg->offset, SEEK_SET) != arg->offset) { + 92 20091 : if (lseek(f, arg->offset, SEEK_SET) != arg->offset) { 93 : /* LCOV_EXCL_START */ 94 : log_fatal("Error seeking file '%s'. %s.\n", path, strerror(errno)); 95 : exit(EXIT_FAILURE); 96 : /* LCOV_EXCL_STOP */ 97 : } 98 : - 99 20073 : ret = read(f, arg->buffer, arg->read_size); - 100 20073 : if (ret < 0 || (unsigned)ret != arg->read_size) { + 99 20091 : ret = read(f, arg->buffer, arg->read_size); + 100 20091 : if (ret < 0 || (unsigned)ret != arg->read_size) { 101 : /* LCOV_EXCL_START */ 102 : log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno)); 103 : exit(EXIT_FAILURE); 104 : /* LCOV_EXCL_STOP */ 105 : } 106 : - 107 20073 : ret = close(f); - 108 20073 : if (ret != 0) { + 107 20091 : ret = close(f); + 108 20091 : if (ret != 0) { 109 : /* LCOV_EXCL_START */ 110 : log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno)); 111 : exit(EXIT_FAILURE); @@ -175,46 +175,46 @@ 113 : } 114 : 115 : /* compute the hash */ - 116 20073 : if (arg->prevhash) + 116 20091 : if (arg->prevhash) 117 0 : memhash(state->prevhash, state->prevhashseed, buffer_hash, arg->buffer, arg->read_size); 118 : else - 119 20073 : memhash(state->hash, state->hashseed, buffer_hash, arg->buffer, arg->read_size); + 119 20091 : memhash(state->hash, state->hashseed, buffer_hash, arg->buffer, arg->read_size); 120 : 121 : /* check if the hash is matching */ - 122 20073 : if (memcmp(buffer_hash, arg->block->hash, HASH_SIZE) != 0) - 123 2235 : return -1; + 122 20091 : if (memcmp(buffer_hash, arg->block->hash, HASH_SIZE) != 0) + 123 2181 : return -1; 124 : - 125 17838 : if (arg->read_size != state->block_size) { + 125 17910 : if (arg->read_size != state->block_size) { 126 : /* fill the remaining with 0 */ 127 7108 : memset(arg->buffer + arg->read_size, 0, state->block_size - arg->read_size); 128 : } 129 : - 130 17838 : return 0; + 130 17910 : return 0; 131 : } 132 : - 133 639672 : 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) + 133 639116 : 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) 134 : { 135 : struct snapraid_search_file* file; 136 : tommy_uint32_t file_hash; 137 : struct search_file_compare_arg arg; 138 : - 139 639672 : arg.state = state; - 140 639672 : arg.block = missing_block; - 141 639672 : arg.file = missing_file; - 142 639672 : arg.buffer = buffer; - 143 639672 : arg.offset = state->block_size * (data_off_t)missing_file_pos; - 144 639672 : arg.read_size = file_block_size(missing_file, missing_file_pos, state->block_size); - 145 639672 : arg.prevhash = prevhash; + 139 639116 : arg.state = state; + 140 639116 : arg.block = missing_block; + 141 639116 : arg.file = missing_file; + 142 639116 : arg.buffer = buffer; + 143 639116 : arg.offset = state->block_size * (data_off_t)missing_file_pos; + 144 639116 : arg.read_size = file_block_size(missing_file, missing_file_pos, state->block_size); + 145 639116 : arg.prevhash = prevhash; 146 : - 147 639672 : file_hash = file_stamp_hash(arg.file->size, arg.file->mtime_sec, arg.file->mtime_nsec); + 147 639116 : file_hash = file_stamp_hash(arg.file->size, arg.file->mtime_sec, arg.file->mtime_nsec); 148 : 149 : /* search in the hashtable, and also check if the data matches the hash */ - 150 639672 : file = tommy_hashdyn_search(&state->searchset, search_file_compare, &arg, file_hash); - 151 639672 : if (!file) - 152 621834 : return -1; + 150 639116 : file = tommy_hashdyn_search(&state->searchset, search_file_compare, &arg, file_hash); + 151 639116 : if (!file) + 152 621206 : return -1; 153 : 154 : /* if found, buffer is already set with data */ - 155 17838 : return 0; + 155 17910 : return 0; 156 : } 157 : 158 2462 : static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk, const char* dir, const char* sub) @@ -233,40 +233,40 @@ 171 : char path_next[PATH_MAX]; 172 : char sub_next[PATH_MAX]; 173 : char out[PATH_MAX]; - 174 2039885 : struct snapraid_filter* reason = 0; + 174 2040344 : struct snapraid_filter* reason = 0; 175 : struct stat st; 176 : const char* name; 177 : struct dirent* dd; 178 : 179 : /* clear errno to detect erroneous conditions */ - 180 2039885 : errno = 0; - 181 2039885 : dd = readdir(d); - 182 2039885 : if (dd == 0 && errno != 0) { + 180 2040344 : errno = 0; + 181 2040344 : dd = readdir(d); + 182 2040344 : if (dd == 0 && errno != 0) { 183 : /* LCOV_EXCL_START */ 184 : log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno)); 185 : exit(EXIT_FAILURE); 186 : /* LCOV_EXCL_STOP */ 187 : } - 188 2039885 : if (dd == 0) { + 188 2040344 : if (dd == 0) { 189 2462 : break; /* finished */ 190 : } 191 : 192 : /* skip "." and ".." files */ - 193 2037423 : name = dd->d_name; - 194 2037423 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) + 193 2037882 : name = dd->d_name; + 194 2037882 : if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) 195 9848 : continue; 196 : - 197 2032499 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); - 198 2032499 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); + 197 2032958 : pathprint(path_next, sizeof(path_next), "%s%s", dir, name); + 198 2032958 : pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); 199 : 200 : /* exclude hidden files even before calling lstat() */ - 201 2032499 : if (disk != 0 && filter_hidden(state->filter_hidden, dd) != 0) { + 201 2032958 : if (disk != 0 && filter_hidden(state->filter_hidden, dd) != 0) { 202 0 : msg_verbose("Excluding hidden '%s'\n", path_next); 203 0 : continue; 204 : } 205 : 206 : /* exclude content files even before calling lstat() */ - 207 2032499 : if (disk != 0 && filter_content(&state->contentlist, path_next) != 0) { + 207 2032958 : if (disk != 0 && filter_content(&state->contentlist, path_next) != 0) { 208 0 : msg_verbose("Excluding content '%s'\n", path_next); 209 0 : continue; 210 : } @@ -290,7 +290,7 @@ 228 : } 229 : #else 230 : /* get lstat info about the file */ - 231 2032499 : if (lstat(path_next, &st) != 0) { + 231 2032958 : if (lstat(path_next, &st) != 0) { 232 : /* LCOV_EXCL_START */ 233 : log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno)); 234 : exit(EXIT_FAILURE); @@ -298,13 +298,13 @@ 236 : } 237 : #endif 238 : - 239 2032499 : if (S_ISREG(st.st_mode)) { - 240 1968182 : if (disk == 0 || filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { - 241 1843303 : search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st)); + 239 2032958 : if (S_ISREG(st.st_mode)) { + 240 1968663 : if (disk == 0 || filter_path(&state->filterlist, &reason, disk->name, sub_next) == 0) { + 241 1843992 : search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st)); 242 : } else { - 243 124879 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); + 243 124671 : msg_verbose("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); 244 : } - 245 64317 : } else if (S_ISDIR(st.st_mode)) { + 245 64295 : } else if (S_ISDIR(st.st_mode)) { 246 1781 : if (disk == 0 || filter_dir(&state->filterlist, &reason, disk->name, sub_next) == 0) { 247 1781 : pathslash(path_next, sizeof(path_next)); 248 1781 : pathslash(sub_next, sizeof(sub_next)); @@ -313,7 +313,7 @@ 251 0 : msg_verbose("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out))); 252 : } 253 : } - 254 2037423 : } + 254 2037882 : } 255 : 256 2462 : if (closedir(d) != 0) { 257 : /* LCOV_EXCL_START */ diff --git a/cov/cmdline/selftest.c.func-sort-c.html b/cov/cmdline/selftest.c.func-sort-c.html index ef0b6b12..caa84f70 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-01-09 + 2016-01-16 Functions: 8 diff --git a/cov/cmdline/selftest.c.func.html b/cov/cmdline/selftest.c.func.html index bb9ef14f..8f183a95 100644 --- a/cov/cmdline/selftest.c.func.html +++ b/cov/cmdline/selftest.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 diff --git a/cov/cmdline/selftest.c.gcov.html b/cov/cmdline/selftest.c.gcov.html index 31f5f6df..4a6a4bb0 100644 --- a/cov/cmdline/selftest.c.gcov.html +++ b/cov/cmdline/selftest.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 diff --git a/cov/cmdline/snapraid.c.func-sort-c.html b/cov/cmdline/snapraid.c.func-sort-c.html index 1a663a69..efcc0fb3 100644 --- a/cov/cmdline/snapraid.c.func-sort-c.html +++ b/cov/cmdline/snapraid.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 @@ -61,27 +61,27 @@ main - 265 + 267 config - 265 + 267 log_open - 255 + 257 log_close - 233 + 235 memory - 230 + 232 signal_init - 216 + 218 version diff --git a/cov/cmdline/snapraid.c.func.html b/cov/cmdline/snapraid.c.func.html index ccd27a1f..a1371bc9 100644 --- a/cov/cmdline/snapraid.c.func.html +++ b/cov/cmdline/snapraid.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 @@ -61,27 +61,27 @@ config - 265 + 267 log_close - 233 + 235 log_open - 255 + 257 main - 265 + 267 memory - 230 + 232 signal_init - 216 + 218 usage diff --git a/cov/cmdline/snapraid.c.gcov.html b/cov/cmdline/snapraid.c.gcov.html index 7343ea06..1cb2ce59 100644 --- a/cov/cmdline/snapraid.c.gcov.html +++ b/cov/cmdline/snapraid.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 8 @@ -136,24 +136,24 @@ 74 1 : printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n"); 75 1 : } 76 : - 77 230 : void memory(void) + 77 232 : void memory(void) 78 : { - 79 230 : log_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter_get()); + 79 232 : log_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter_get()); 80 : 81 : /* size of the block */ - 82 230 : log_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block))); - 83 230 : log_tag("memory:chunk:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_chunk))); - 84 230 : log_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file))); - 85 230 : log_tag("memory:link:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_link))); - 86 230 : log_tag("memory:dir:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_dir))); + 82 232 : log_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block))); + 83 232 : log_tag("memory:chunk:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_chunk))); + 84 232 : log_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file))); + 85 232 : log_tag("memory:link:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_link))); + 86 232 : log_tag("memory:dir:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_dir))); 87 : - 88 230 : msg_progress("Using %u MiB of memory.\n", (unsigned)(malloc_counter_get() / (1024 * 1024))); - 89 230 : } + 88 232 : msg_progress("Using %u MiB of memory.\n", (unsigned)(malloc_counter_get() / (1024 * 1024))); + 89 232 : } 90 : 91 : /****************************************************************************/ 92 : /* log */ 93 : - 94 255 : void log_open(const char* file) + 94 257 : void log_open(const char* file) 95 : { 96 : char path[PATH_MAX]; 97 : const char* mode; @@ -163,8 +163,8 @@ 101 : struct tm* tm; 102 : 103 : /* leave stdlog at 0 if not specified */ - 104 255 : if (file == 0) - 105 359 : return; + 104 257 : if (file == 0) + 105 363 : return; 106 : 107 77 : t = time(0); 108 77 : tm = localtime(&t); @@ -237,9 +237,9 @@ 175 : } 176 : } 177 : - 178 233 : void log_close(const char* file) + 178 235 : void log_close(const char* file) 179 : { - 180 233 : if (stdlog != stdout && stdlog != stderr && stdlog != 0) { + 180 235 : if (stdlog != stdout && stdlog != stderr && stdlog != 0) { 181 74 : if (fclose(stdlog) != 0) { 182 : /* LCOV_EXCL_START */ 183 : log_fatal("Error closing the log file '%s'. %s.\n", file, strerror(errno)); @@ -248,13 +248,13 @@ 186 : } 187 : } 188 : - 189 233 : stdlog = 0; - 190 233 : } + 189 235 : stdlog = 0; + 190 235 : } 191 : 192 : /****************************************************************************/ 193 : /* config */ 194 : - 195 265 : void config(char* conf, size_t conf_size, const char* argv0) + 195 267 : void config(char* conf, size_t conf_size, const char* argv0) 196 : { 197 : #ifdef _WIN32 198 : char* slash; @@ -271,9 +271,9 @@ 209 : #else 210 : (void)argv0; 211 : - 212 265 : pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf"); + 212 267 : pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf"); 213 : #endif - 214 265 : } + 214 267 : } 215 : 216 : /****************************************************************************/ 217 : /* main */ @@ -456,25 +456,25 @@ 394 : } 395 : /* LCOV_EXCL_STOP */ 396 : - 397 216 : void signal_init(void) + 397 218 : void signal_init(void) 398 : { 399 : #if HAVE_SIGACTION 400 : struct sigaction sa; 401 : - 402 216 : sa.sa_handler = signal_handler; - 403 216 : sigemptyset(&sa.sa_mask); + 402 218 : sa.sa_handler = signal_handler; + 403 218 : sigemptyset(&sa.sa_mask); 404 : 405 : /* use the SA_RESTART to automatically restart interrupted system calls */ - 406 216 : sa.sa_flags = SA_RESTART; + 406 218 : sa.sa_flags = SA_RESTART; 407 : - 408 216 : sigaction(SIGHUP, &sa, 0); - 409 216 : sigaction(SIGTERM, &sa, 0); - 410 216 : sigaction(SIGINT, &sa, 0); - 411 216 : sigaction(SIGQUIT, &sa, 0); + 408 218 : sigaction(SIGHUP, &sa, 0); + 409 218 : sigaction(SIGTERM, &sa, 0); + 410 218 : sigaction(SIGINT, &sa, 0); + 411 218 : sigaction(SIGQUIT, &sa, 0); 412 : #else 413 : signal(SIGINT, signal_handler); 414 : #endif - 415 216 : } + 415 218 : } 416 : 417 : #define OPERATION_DIFF 0 418 : #define OPERATION_SYNC 1 @@ -495,7 +495,7 @@ 433 : #define OPERATION_DEVICES 16 434 : #define OPERATION_SMART 17 435 : - 436 265 : int main(int argc, char* argv[]) + 436 267 : int main(int argc, char* argv[]) 437 : { 438 : int c; 439 : struct snapraid_option opt; @@ -526,38 +526,38 @@ 464 : int i; 465 : 466 : /* defaults */ - 467 265 : config(conf, sizeof(conf), argv[0]); - 468 265 : memset(&opt, 0, sizeof(opt)); - 469 265 : opt.io_error_limit = 100; - 470 265 : blockstart = 0; - 471 265 : blockcount = 0; - 472 265 : tommy_list_init(&filterlist_file); - 473 265 : tommy_list_init(&filterlist_disk); - 474 265 : period = 1000; - 475 265 : filter_missing = 0; - 476 265 : filter_error = 0; - 477 265 : plan = SCRUB_AUTO; - 478 265 : olderthan = SCRUB_AUTO; - 479 265 : import_timestamp = 0; - 480 265 : import_content = 0; - 481 265 : log_file = 0; - 482 265 : lock = 0; - 483 265 : gen_conf = 0; - 484 265 : speedtest = 0; - 485 265 : run = 0; + 467 267 : config(conf, sizeof(conf), argv[0]); + 468 267 : memset(&opt, 0, sizeof(opt)); + 469 267 : opt.io_error_limit = 100; + 470 267 : blockstart = 0; + 471 267 : blockcount = 0; + 472 267 : tommy_list_init(&filterlist_file); + 473 267 : tommy_list_init(&filterlist_disk); + 474 267 : period = 1000; + 475 267 : filter_missing = 0; + 476 267 : filter_error = 0; + 477 267 : plan = SCRUB_AUTO; + 478 267 : olderthan = SCRUB_AUTO; + 479 267 : import_timestamp = 0; + 480 267 : import_content = 0; + 481 267 : log_file = 0; + 482 267 : lock = 0; + 483 267 : gen_conf = 0; + 484 267 : speedtest = 0; + 485 267 : run = 0; 486 : - 487 265 : opterr = 0; - 488 2809 : while ((c = + 487 267 : opterr = 0; + 488 2829 : while ((c = 489 : #if HAVE_GETOPT_LONG 490 : getopt_long(argc, argv, OPTIONS, long_options, 0)) 491 : #else 492 : getopt(argc, argv, OPTIONS)) 493 : #endif 494 : != EOF) { - 495 2284 : switch (c) { + 495 2300 : switch (c) { 496 : case 'c' : - 497 258 : pathimport(conf, sizeof(conf), optarg); - 498 258 : break; + 497 260 : pathimport(conf, sizeof(conf), optarg); + 498 260 : break; 499 : case 'f' : { 500 6 : struct snapraid_filter* filter = filter_alloc_file(1, optarg); 501 6 : if (!filter) { @@ -698,8 +698,8 @@ 636 23 : ++msg_level; 637 23 : break; 638 : case 'q' : - 639 705 : --msg_level; - 640 705 : break; + 639 711 : --msg_level; + 640 711 : break; 641 : case 'G' : 642 23 : opt.gui = 1; 643 23 : break; @@ -725,8 +725,8 @@ 663 23 : opt.expect_recoverable = 1; 664 23 : break; 665 : case OPT_TEST_SKIP_SELF : - 666 258 : opt.skip_self = 1; - 667 258 : break; + 666 260 : opt.skip_self = 1; + 667 260 : break; 668 : case OPT_TEST_SKIP_SIGN : 669 0 : opt.skip_sign = 1; 670 0 : break; @@ -737,9 +737,9 @@ 675 1 : opt.skip_sequential = 1; 676 1 : break; 677 : case OPT_TEST_SKIP_DEVICE : - 678 265 : opt.skip_device = 1; - 679 265 : period = 50; /* reduce period of the speed test */ - 680 265 : break; + 678 267 : opt.skip_device = 1; + 679 267 : period = 50; /* reduce period of the speed test */ + 680 267 : break; 681 : case OPT_TEST_SKIP_CONTENT_CHECK : 682 0 : opt.skip_content_check = 1; 683 0 : break; @@ -765,8 +765,8 @@ 703 0 : opt.force_order = SORT_INODE; 704 0 : break; 705 : case OPT_TEST_FORCE_ORDER_ALPHA : - 706 256 : opt.force_order = SORT_ALPHA; - 707 256 : break; + 706 258 : opt.force_order = SORT_ALPHA; + 707 258 : break; 708 : case OPT_TEST_FORCE_ORDER_DIR : 709 0 : opt.force_order = SORT_DIR; 710 0 : break; @@ -796,8 +796,8 @@ 734 0 : opt.force_scan_winfind = 1; 735 0 : break; 736 : case OPT_TEST_FORCE_PROGRESS : - 737 256 : opt.force_progress = 1; - 738 256 : break; + 737 258 : opt.force_progress = 1; + 738 258 : break; 739 : case OPT_TEST_FORCE_AUTOSAVE_AT : 740 1 : opt.force_autosave_at = atoi(optarg); 741 1 : break; @@ -824,34 +824,34 @@ 762 : } 763 : } 764 : - 765 260 : os_init(opt.force_scan_winfind); - 766 260 : raid_init(); - 767 260 : crc32c_init(); + 765 262 : os_init(opt.force_scan_winfind); + 766 262 : raid_init(); + 767 262 : crc32c_init(); 768 : - 769 260 : if (speedtest != 0) { + 769 262 : if (speedtest != 0) { 770 4 : speed(period); 771 4 : os_done(); 772 4 : exit(EXIT_SUCCESS); 773 : } 774 : - 775 256 : if (gen_conf != 0) { + 775 258 : if (gen_conf != 0) { 776 1 : generate_configuration(gen_conf); 777 1 : os_done(); 778 1 : exit(EXIT_SUCCESS); 779 : } 780 : - 781 255 : if (optind + 1 != argc) { + 781 257 : if (optind + 1 != argc) { 782 : /* LCOV_EXCL_START */ 783 : usage(); 784 : exit(EXIT_FAILURE); 785 : /* LCOV_EXCL_STOP */ 786 : } 787 : - 788 255 : command = argv[optind]; - 789 255 : if (strcmp(command, "diff") == 0) { + 788 257 : command = argv[optind]; + 789 257 : if (strcmp(command, "diff") == 0) { 790 7 : operation = OPERATION_DIFF; - 791 248 : } else if (strcmp(argv[optind], "sync") == 0) { - 792 82 : operation = OPERATION_SYNC; + 791 250 : } else if (strcmp(argv[optind], "sync") == 0) { + 792 84 : operation = OPERATION_SYNC; 793 166 : } else if (strcmp(argv[optind], "check") == 0) { 794 75 : operation = OPERATION_CHECK; 795 91 : } else if (strcmp(argv[optind], "fix") == 0) { @@ -892,11 +892,11 @@ 830 : } 831 : 832 : /* check options compatibility */ - 833 255 : switch (operation) { + 833 257 : switch (operation) { 834 : case OPERATION_CHECK : 835 75 : break; 836 : default : - 837 180 : if (opt.auditonly) { + 837 182 : if (opt.auditonly) { 838 : /* LCOV_EXCL_START */ 839 : log_fatal("You cannot use -a, --audit-only with the '%s' command\n", command); 840 : exit(EXIT_FAILURE); @@ -904,11 +904,11 @@ 842 : } 843 : } 844 : - 845 255 : switch (operation) { + 845 257 : switch (operation) { 846 : case OPERATION_FIX : 847 46 : break; 848 : default : - 849 209 : if (opt.force_device) { + 849 211 : if (opt.force_device) { 850 : /* LCOV_EXCL_START */ 851 : log_fatal("You cannot use -D, --force-device with the '%s' command\n", command); 852 : exit(EXIT_FAILURE); @@ -916,11 +916,11 @@ 854 : } 855 : } 856 : - 857 255 : switch (operation) { + 857 257 : switch (operation) { 858 : case OPERATION_SYNC : 859 : case OPERATION_CHECK : 860 : case OPERATION_FIX : - 861 203 : break; + 861 205 : break; 862 : default : 863 52 : if (opt.force_nocopy) { 864 : /* LCOV_EXCL_START */ @@ -930,9 +930,9 @@ 868 : } 869 : } 870 : - 871 255 : switch (operation) { + 871 257 : switch (operation) { 872 : case OPERATION_SYNC : - 873 82 : break; + 873 84 : break; 874 : default : 875 173 : if (opt.prehash) { 876 : /* LCOV_EXCL_START */ @@ -949,45 +949,45 @@ 887 : } 888 : } 889 : - 890 255 : if (opt.force_full && opt.force_nocopy) { + 890 257 : if (opt.force_full && opt.force_nocopy) { 891 : /* LCOV_EXCL_START */ 892 : log_fatal("You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n"); 893 : exit(EXIT_FAILURE); 894 : /* LCOV_EXCL_STOP */ 895 : } 896 : - 897 255 : if (opt.prehash && opt.force_nocopy) { + 897 257 : if (opt.prehash && opt.force_nocopy) { 898 : /* LCOV_EXCL_START */ 899 : log_fatal("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n"); 900 : exit(EXIT_FAILURE); 901 : /* LCOV_EXCL_STOP */ 902 : } 903 : - 904 255 : switch (operation) { + 904 257 : switch (operation) { 905 : case OPERATION_CHECK : 906 : case OPERATION_FIX : 907 : case OPERATION_DRY : 908 123 : break; 909 : default : - 910 132 : if (!tommy_list_empty(&filterlist_file)) { + 910 134 : if (!tommy_list_empty(&filterlist_file)) { 911 : /* LCOV_EXCL_START */ 912 : log_fatal("You cannot use -f, --filter with the '%s' command\n", command); 913 : exit(EXIT_FAILURE); 914 : /* LCOV_EXCL_STOP */ 915 : } - 916 132 : if (!tommy_list_empty(&filterlist_disk)) { + 916 134 : if (!tommy_list_empty(&filterlist_disk)) { 917 : /* LCOV_EXCL_START */ 918 : log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command); 919 : exit(EXIT_FAILURE); 920 : /* LCOV_EXCL_STOP */ 921 : } - 922 132 : if (filter_missing != 0) { + 922 134 : if (filter_missing != 0) { 923 : /* LCOV_EXCL_START */ 924 : log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command); 925 : exit(EXIT_FAILURE); 926 : /* LCOV_EXCL_STOP */ 927 : } - 928 132 : if (filter_error != 0) { + 928 134 : if (filter_error != 0) { 929 : /* LCOV_EXCL_START */ 930 : log_fatal("You cannot use -e, --filter-error with the '%s' command\n", command); 931 : exit(EXIT_FAILURE); @@ -997,19 +997,19 @@ 935 : 936 : /* errors must be always fixed on all disks */ 937 : /* because we don't keep the information on what disk is the error */ - 938 255 : if (filter_error != 0 && !tommy_list_empty(&filterlist_disk)) { + 938 257 : if (filter_error != 0 && !tommy_list_empty(&filterlist_disk)) { 939 : /* LCOV_EXCL_START */ 940 : log_fatal("You cannot use -e, --filter-error and -d, --filter-disk at the same time\n"); 941 : exit(EXIT_FAILURE); 942 : /* LCOV_EXCL_STOP */ 943 : } 944 : - 945 255 : switch (operation) { + 945 257 : switch (operation) { 946 : case OPERATION_CHECK : 947 : case OPERATION_FIX : 948 121 : break; 949 : default : - 950 134 : if (import_timestamp != 0 || import_content != 0) { + 950 136 : if (import_timestamp != 0 || import_content != 0) { 951 : /* LCOV_EXCL_START */ 952 : log_fatal("You cannot import with the '%s' command\n", command); 953 : exit(EXIT_FAILURE); @@ -1017,7 +1017,7 @@ 955 : } 956 : } 957 : - 958 255 : switch (operation) { + 958 257 : switch (operation) { 959 : case OPERATION_LIST : 960 : case OPERATION_DUP : 961 : case OPERATION_STATUS : @@ -1030,7 +1030,7 @@ 968 24 : break; 969 : } 970 : - 971 255 : switch (operation) { + 971 257 : switch (operation) { 972 : case OPERATION_DIFF : 973 : case OPERATION_LIST : 974 : case OPERATION_DUP : @@ -1046,7 +1046,7 @@ 984 35 : break; 985 : } 986 : - 987 255 : switch (operation) { + 987 257 : switch (operation) { 988 : case OPERATION_FIX : 989 : case OPERATION_CHECK : 990 : /* avoid to stop processing if a content file is not accessible */ @@ -1054,7 +1054,7 @@ 992 121 : break; 993 : } 994 : - 995 255 : switch (operation) { + 995 257 : switch (operation) { 996 : case OPERATION_DIFF : 997 : case OPERATION_LIST : 998 : case OPERATION_DUP : @@ -1068,7 +1068,7 @@ 1006 22 : break; 1007 : } 1008 : - 1009 255 : switch (operation) { + 1009 257 : switch (operation) { 1010 : case OPERATION_DEVICES : 1011 : case OPERATION_SMART : 1012 : /* we may need to use these commands during operations */ @@ -1077,39 +1077,39 @@ 1015 : } 1016 : 1017 : /* open the log file */ - 1018 255 : log_open(log_file); + 1018 257 : log_open(log_file); 1019 : 1020 : /* print generic info into the log */ - 1021 255 : t = time(0); - 1022 255 : tm = localtime(&t); - 1023 255 : log_tag("version:%s\n", PACKAGE_VERSION); - 1024 255 : log_tag("unixtime:%" PRIi64 "\n", (int64_t)t); - 1025 255 : if (tm) { + 1021 257 : t = time(0); + 1022 257 : tm = localtime(&t); + 1023 257 : log_tag("version:%s\n", PACKAGE_VERSION); + 1024 257 : log_tag("unixtime:%" PRIi64 "\n", (int64_t)t); + 1025 257 : if (tm) { 1026 : char datetime[64]; - 1027 255 : strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); - 1028 255 : log_tag("time:%s\n", datetime); + 1027 257 : strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); + 1028 257 : log_tag("time:%s\n", datetime); 1029 : } - 1030 255 : log_tag("command:%s\n", command); - 1031 3377 : for (i = 0; i < argc; ++i) - 1032 3122 : log_tag("argv:%u:%s\n", i, argv[i]); - 1033 255 : log_flush(); + 1030 257 : log_tag("command:%s\n", command); + 1031 3401 : for (i = 0; i < argc; ++i) + 1032 3144 : log_tag("argv:%u:%s\n", i, argv[i]); + 1033 257 : log_flush(); 1034 : - 1035 255 : if (!opt.skip_self) + 1035 257 : if (!opt.skip_self) 1036 1 : selftest(); 1037 : - 1038 255 : state_init(&state); + 1038 257 : state_init(&state); 1039 : 1040 : /* read the configuration file */ - 1041 255 : state_config(&state, conf, command, &opt, &filterlist_disk); + 1041 257 : state_config(&state, conf, command, &opt, &filterlist_disk); 1042 : 1043 : /* set the raid mode */ - 1044 254 : raid_mode(state.raid_mode); + 1044 256 : raid_mode(state.raid_mode); 1045 : 1046 : #if HAVE_LOCKFILE 1047 : /* create the lock file */ - 1048 254 : if (!opt.skip_lock && state.lockfile[0]) { - 1049 251 : lock = lock_lock(state.lockfile); - 1050 251 : if (lock == -1) { + 1048 256 : if (!opt.skip_lock && state.lockfile[0]) { + 1049 253 : lock = lock_lock(state.lockfile); + 1050 253 : if (lock == -1) { 1051 : /* LCOV_EXCL_START */ 1052 : if (errno != EWOULDBLOCK) { 1053 : log_fatal("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); @@ -1125,7 +1125,7 @@ 1063 : (void)lock; 1064 : #endif 1065 : - 1066 254 : if (operation == OPERATION_DIFF) { + 1066 256 : if (operation == OPERATION_DIFF) { 1067 7 : state_read(&state); 1068 : 1069 7 : ret = state_diff(&state); @@ -1133,7 +1133,7 @@ 1071 : /* abort if sync needed */ 1072 7 : if (ret > 0) 1073 6 : exit(EXIT_SYNC_NEEDED); - 1074 247 : } else if (operation == OPERATION_SYNC) { + 1074 249 : } else if (operation == OPERATION_SYNC) { 1075 : 1076 : /* in the next state read ensures to clear all the past hashes in case */ 1077 : /* we are reading from an incomplete sync */ @@ -1161,19 +1161,19 @@ 1099 : /* but without saving the content file representing this new EMPTY state. */ 1100 : /* - Another file is added again over the DELETE ones */ 1101 : /* with the hash of DELETED blocks not representing the real parity state */ - 1102 82 : state.clear_past_hash = 1; + 1102 84 : state.clear_past_hash = 1; 1103 : - 1104 82 : state_read(&state); + 1104 84 : state_read(&state); 1105 : - 1106 81 : state_scan(&state); + 1106 83 : state_scan(&state); 1107 : 1108 : /* refresh the size info before the content write */ - 1109 80 : state_refresh(&state); + 1109 82 : state_refresh(&state); 1110 : - 1111 80 : memory(); + 1111 82 : memory(); 1112 : 1113 : /* intercept signals while operating */ - 1114 80 : signal_init(); + 1114 82 : signal_init(); 1115 : 1116 : /* save the new state before the sync */ 1117 : /* this allow to recover the case of the changes in the array after an aborted sync. */ @@ -1189,11 +1189,11 @@ 1127 : /* because the files triggering these changes are now deleted */ 1128 : /* and they aren't listed in the content file */ 1129 : - 1130 80 : if (state.need_write) - 1131 78 : state_write(&state); + 1130 82 : if (state.need_write) + 1131 80 : state_write(&state); 1132 : 1133 : /* run a test command if required */ - 1134 80 : if (run != 0) { + 1134 82 : if (run != 0) { 1135 10 : ret = system(run); /* ignore error */ 1136 10 : if (ret != 0) { 1137 : /* LCOV_EXCL_START */ @@ -1210,21 +1210,21 @@ 1148 : /* The worst case is the FAT file-system with a two seconds resolution for mtime. */ 1149 : /* If you don't use FAT, the wait is not needed, because most file-systems have now */ 1150 : /* at least microseconds resolution, but better to be safe. */ - 1151 80 : if (!opt.skip_self) + 1151 82 : if (!opt.skip_self) 1152 0 : sleep(2); 1153 : - 1154 80 : ret = state_sync(&state, blockstart, blockcount); + 1154 82 : ret = state_sync(&state, blockstart, blockcount); 1155 : 1156 : /* save the new state if required */ - 1157 80 : if (!opt.kill_after_sync) { - 1158 70 : if ((state.need_write || state.opt.force_content_write)) - 1159 51 : state_write(&state); + 1157 82 : if (!opt.kill_after_sync) { + 1158 72 : if ((state.need_write || state.opt.force_content_write)) + 1159 52 : state_write(&state); 1160 : } else { 1161 10 : log_fatal("WARNING! Skipped state write for --test-kill-after-sync option.\n"); 1162 : } 1163 : 1164 : /* abort if required */ - 1165 80 : if (ret != 0) { + 1165 82 : if (ret != 0) { 1166 : /* LCOV_EXCL_START */ 1167 : exit(EXIT_FAILURE); 1168 : /* LCOV_EXCL_STOP */ @@ -1363,11 +1363,11 @@ 1301 : } 1302 : 1303 : /* close log file */ - 1304 233 : log_close(log_file); + 1304 235 : log_close(log_file); 1305 : 1306 : #if HAVE_LOCKFILE - 1307 233 : if (!opt.skip_lock && state.lockfile[0]) { - 1308 231 : if (lock_unlock(lock) == -1) { + 1307 235 : if (!opt.skip_lock && state.lockfile[0]) { + 1308 233 : if (lock_unlock(lock) == -1) { 1309 : /* LCOV_EXCL_START */ 1310 : log_fatal("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno)); 1311 : exit(EXIT_FAILURE); @@ -1376,13 +1376,13 @@ 1314 : } 1315 : #endif 1316 : - 1317 233 : state_done(&state); - 1318 233 : tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); - 1319 233 : tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); + 1317 235 : state_done(&state); + 1318 235 : tommy_list_foreach(&filterlist_file, (tommy_foreach_func*)filter_free); + 1319 235 : tommy_list_foreach(&filterlist_disk, (tommy_foreach_func*)filter_free); 1320 : - 1321 233 : os_done(); + 1321 235 : os_done(); 1322 : - 1323 233 : return EXIT_SUCCESS; + 1323 235 : return EXIT_SUCCESS; 1324 : } 1325 : diff --git a/cov/cmdline/speed.c.func-sort-c.html b/cov/cmdline/speed.c.func-sort-c.html index 4b48a521..7778e2b4 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-01-09 + 2016-01-16 Functions: 2 @@ -61,7 +61,7 @@ diffgettimeofday - 1878 + 1889 speed diff --git a/cov/cmdline/speed.c.func.html b/cov/cmdline/speed.c.func.html index 2ea02544..7bfd6656 100644 --- a/cov/cmdline/speed.c.func.html +++ b/cov/cmdline/speed.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -61,7 +61,7 @@ diffgettimeofday - 1878 + 1889 speed diff --git a/cov/cmdline/speed.c.gcov.html b/cov/cmdline/speed.c.gcov.html index 3d202c50..cabd0104 100644 --- a/cov/cmdline/speed.c.gcov.html +++ b/cov/cmdline/speed.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -100,14 +100,14 @@ 38 : /** 39 : * Differential us of two timeval. 40 : */ - 41 1878 : static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop) + 41 1889 : static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop) 42 : { 43 : int64_t d; 44 : - 45 1878 : d = 1000000LL * (stop->tv_sec - start->tv_sec); - 46 1878 : d += stop->tv_usec - start->tv_usec; + 45 1889 : d = 1000000LL * (stop->tv_sec - start->tv_sec); + 46 1889 : d += stop->tv_usec - start->tv_usec; 47 : - 48 1878 : return d; + 48 1889 : return d; 49 : } 50 : 51 : /** @@ -224,7 +224,7 @@ 162 : 163 4 : printf("Speed test using %u data buffers of %u bytes, for a total of %u KiB.\n", nd, size, nd * size / 1024); 164 4 : printf("Memory blocks have a displacement of %u bytes to improve cache performance.\n", RAID_MALLOC_DISPLACEMENT); - 165 4 : printf("The reported values are the aggregate bandwidth of all data blocks in MiB/s,\n"); + 165 4 : printf("The reported values are the aggregate bandwidth of all data blocks in MB/s,\n"); 166 4 : printf("not counting parity blocks.\n"); 167 4 : printf("\n"); 168 : @@ -232,10 +232,10 @@ 170 4 : printf("%8s", "memset"); 171 4 : fflush(stdout); 172 : - 173 375 : SPEED_START { - 174 3339 : for (j = 0; j < nd; ++j) - 175 2968 : memset(v[j], j, size); - 176 371 : } SPEED_STOP + 173 388 : SPEED_START { + 174 3456 : for (j = 0; j < nd; ++j) + 175 3072 : memset(v[j], j, size); + 176 384 : } SPEED_STOP 177 : 178 4 : printf("%8" PRIu64, ds / dt); 179 4 : printf("\n"); @@ -358,9 +358,9 @@ 296 : #ifdef CONFIG_X86 297 : #ifdef CONFIG_SSE2 298 4 : if (raid_cpu_has_sse2()) { - 299 317 : SPEED_START { - 300 313 : raid_gen1_sse2(nd, size, v); - 301 313 : } SPEED_STOP + 299 316 : SPEED_START { + 300 312 : raid_gen1_sse2(nd, size, v); + 301 312 : } SPEED_STOP 302 : 303 4 : printf("%8" PRIu64, ds / dt); 304 4 : fflush(stdout); @@ -707,9 +707,9 @@ 645 4 : printf("%8s", raid_gen6_tag()); 646 4 : fflush(stdout); 647 : - 648 12 : SPEED_START { - 649 8 : raid_gen6_int8(nd, size, v); - 650 8 : } SPEED_STOP + 648 11 : SPEED_START { + 649 7 : raid_gen6_int8(nd, size, v); + 650 7 : } SPEED_STOP 651 : 652 4 : printf("%8" PRIu64, ds / dt); 653 4 : fflush(stdout); diff --git a/cov/cmdline/spooky2.c.func-sort-c.html b/cov/cmdline/spooky2.c.func-sort-c.html index 8c286716..bbfc0188 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-01-09 + 2016-01-16 Functions: 1 @@ -61,7 +61,7 @@ SpookyHash128 - 3855152 + 3856988
diff --git a/cov/cmdline/spooky2.c.func.html b/cov/cmdline/spooky2.c.func.html index 6c188d72..6df222cc 100644 --- a/cov/cmdline/spooky2.c.func.html +++ b/cov/cmdline/spooky2.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 @@ -61,7 +61,7 @@ SpookyHash128 - 3855152 + 3856988
diff --git a/cov/cmdline/spooky2.c.gcov.html b/cov/cmdline/spooky2.c.gcov.html index 8e1b9ebc..1fe0a058 100644 --- a/cov/cmdline/spooky2.c.gcov.html +++ b/cov/cmdline/spooky2.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 @@ -170,7 +170,7 @@ 108 : // 109 : #define sc_const 0xdeadbeefdeadbeefLL 110 : - 111 3855152 : void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* digest) + 111 3856988 : 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]; @@ -182,39 +182,39 @@ 120 : unsigned i; 121 : #endif 122 : - 123 3855152 : h9 = ((const uint64_t*)seed)[0]; - 124 3855152 : h10 = ((const uint64_t*)seed)[1]; + 123 3856988 : h9 = ((const uint64_t*)seed)[0]; + 124 3856988 : h10 = ((const uint64_t*)seed)[1]; 125 : 126 : #if WORDS_BIGENDIAN 127 : h9 = util_swap64(h9); 128 : h10 = util_swap64(h10); 129 : #endif 130 : - 131 3855152 : h0 = h3 = h6 = h9; - 132 3855152 : h1 = h4 = h7 = h10; - 133 3855152 : h2 = h5 = h8 = h11 = sc_const; + 131 3856988 : h0 = h3 = h6 = h9; + 132 3856988 : h1 = h4 = h7 = h10; + 133 3856988 : h2 = h5 = h8 = h11 = sc_const; 134 : - 135 3855152 : nblocks = size / sc_blockSize; - 136 3855152 : blocks = data; - 137 3855152 : end = blocks + nblocks * sc_numVars; + 135 3856988 : nblocks = size / sc_blockSize; + 136 3856988 : blocks = data; + 137 3856988 : end = blocks + nblocks * sc_numVars; 138 : 139 : /* body */ - 140 38762369 : while (blocks < end) { + 140 38784019 : while (blocks < end) { 141 : #if WORDS_BIGENDIAN 142 : for (i = 0; i < sc_numVars; ++i) 143 : buf[i] = util_swap64(blocks[i]); 144 : Mix(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); 145 : #else - 146 31052065 : Mix(blocks, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); + 146 31070043 : Mix(blocks, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); 147 : #endif - 148 31052065 : blocks += sc_numVars; + 148 31070043 : blocks += sc_numVars; 149 : } 150 : 151 : /* tail */ - 152 3855152 : size_remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); - 153 3855152 : memcpy(buf, end, size_remainder); - 154 3855152 : memset(((uint8_t*)buf) + size_remainder, 0, sc_blockSize - size_remainder); - 155 3855152 : ((uint8_t*)buf)[sc_blockSize - 1] = size_remainder; + 152 3856988 : size_remainder = (size - ((const uint8_t*)end - (const uint8_t*)data)); + 153 3856988 : memcpy(buf, end, size_remainder); + 154 3856988 : memset(((uint8_t*)buf) + size_remainder, 0, sc_blockSize - size_remainder); + 155 3856988 : ((uint8_t*)buf)[sc_blockSize - 1] = size_remainder; 156 : 157 : /* finalization */ 158 : #if WORDS_BIGENDIAN @@ -222,16 +222,16 @@ 160 : buf[i] = util_swap64(buf[i]); 161 : #endif 162 : - 163 3855152 : End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); + 163 3856988 : End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); 164 : 165 : #if WORDS_BIGENDIAN 166 : h0 = util_swap64(h0); 167 : h1 = util_swap64(h1); 168 : #endif 169 : - 170 3855152 : ((uint64_t*)digest)[0] = h0; - 171 3855152 : ((uint64_t*)digest)[1] = h1; - 172 3855152 : } + 170 3856988 : ((uint64_t*)digest)[0] = h0; + 171 3856988 : ((uint64_t*)digest)[1] = h1; + 172 3856988 : } 173 : diff --git a/cov/cmdline/state.c.func-sort-c.html b/cov/cmdline/state.c.func-sort-c.html index f380d70f..d9178044 100644 --- a/cov/cmdline/state.c.func-sort-c.html +++ b/cov/cmdline/state.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 36 @@ -61,111 +61,111 @@ fs_is_block_deleted_ts - 4507856 + 4472427 fs_info_is_required - 1513218 + 1515002 state_progress - 1048979 + 1049984 fs_position_is_required - 752491 + 746566 lev_config_name - 178997 + 179222 find_disk_by_name - 6723 + 6817 lev_config_scan - 6118 + 6172 state_verify_thread - 990 + 1011 state_fscheck - 474 + 481 validate_smartctl - 358 + 362 state_init - 256 + 258 state_config - 255 + 257 lev_raid_name - 254 + 256 state_config_check - 254 + 256 state_read - 250 + 252 state_map - 249 + 251 state_read_content - 243 + 245 state_content_check - 242 + 244 state_done - 234 + 236 state_progress_end - 214 + 216 state_progress_begin - 214 + 216 state_refresh - 160 + 164 state_write - 145 + 148 state_write_thread - 145 + 148 state_write_content - 145 + 148 state_verify_content - 145 + 148 state_rename_content - 145 + 148 state_skip @@ -177,7 +177,7 @@ state_usage_print - 89 + 91 lev_name diff --git a/cov/cmdline/state.c.func.html b/cov/cmdline/state.c.func.html index 912c6cfc..5192f171 100644 --- a/cov/cmdline/state.c.func.html +++ b/cov/cmdline/state.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 36 @@ -65,7 +65,7 @@ find_disk_by_name - 6723 + 6817 find_disk_by_uuid @@ -73,11 +73,11 @@ fs_info_is_required - 1513218 + 1515002 fs_is_block_deleted_ts - 4507856 + 4472427 fs_position_clear_deleted @@ -85,7 +85,7 @@ fs_position_is_required - 752491 + 746566 generate_configuration @@ -93,11 +93,11 @@ lev_config_name - 178997 + 179222 lev_config_scan - 6118 + 6172 lev_name @@ -105,23 +105,23 @@ lev_raid_name - 254 + 256 state_config - 255 + 257 state_config_check - 254 + 256 state_content_check - 242 + 244 state_done - 234 + 236 state_filter @@ -129,27 +129,27 @@ state_fscheck - 474 + 481 state_init - 256 + 258 state_map - 249 + 251 state_progress - 1048979 + 1049984 state_progress_begin - 214 + 216 state_progress_end - 214 + 216 state_progress_restart @@ -161,19 +161,19 @@ state_read - 250 + 252 state_read_content - 243 + 245 state_refresh - 160 + 164 state_rename_content - 145 + 148 state_skip @@ -181,31 +181,31 @@ state_usage_print - 89 + 91 state_verify_content - 145 + 148 state_verify_thread - 990 + 1011 state_write - 145 + 148 state_write_content - 145 + 148 state_write_thread - 145 + 148 validate_smartctl - 358 + 362
diff --git a/cov/cmdline/state.c.gcov.html b/cov/cmdline/state.c.gcov.html index f17512ad..627660e0 100644 --- a/cov/cmdline/state.c.gcov.html +++ b/cov/cmdline/state.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 36 @@ -123,65 +123,65 @@ 61 0 : return 0; 62 : } 63 : - 64 178997 : const char* lev_config_name(unsigned l) + 64 179222 : const char* lev_config_name(unsigned l) 65 : { - 66 178997 : switch (l) { - 67 70574 : case 0 : return "parity"; - 68 57456 : case 1 : return "2-parity"; - 69 12748 : case 2 : return "3-parity"; - 70 12744 : case 3 : return "4-parity"; - 71 12740 : case 4 : return "5-parity"; - 72 12735 : case 5 : return "6-parity"; + 66 179222 : switch (l) { + 67 70562 : case 0 : return "parity"; + 68 57517 : case 1 : return "2-parity"; + 69 12792 : case 2 : return "3-parity"; + 70 12788 : case 3 : return "4-parity"; + 71 12784 : case 4 : return "5-parity"; + 72 12779 : case 5 : return "6-parity"; 73 : } 74 : 75 0 : return 0; 76 : } 77 : - 78 6118 : static int lev_config_scan(const char* s, unsigned* level, unsigned* mode) + 78 6172 : static int lev_config_scan(const char* s, unsigned* level, unsigned* mode) 79 : { - 80 6118 : if (strcmp(s, "parity") == 0 || strcmp(s, "1-parity") == 0) { - 81 434 : *level = 0; - 82 434 : return 0; + 80 6172 : if (strcmp(s, "parity") == 0 || strcmp(s, "1-parity") == 0) { + 81 438 : *level = 0; + 82 438 : return 0; 83 : } 84 : - 85 5684 : if (strcmp(s, "q-parity") == 0 || strcmp(s, "2-parity") == 0) { - 86 221 : *level = 1; - 87 221 : return 0; + 85 5734 : if (strcmp(s, "q-parity") == 0 || strcmp(s, "2-parity") == 0) { + 86 223 : *level = 1; + 87 223 : return 0; 88 : } 89 : - 90 5463 : if (strcmp(s, "r-parity") == 0 || strcmp(s, "3-parity") == 0) { - 91 196 : *level = 2; - 92 196 : return 0; + 90 5511 : if (strcmp(s, "r-parity") == 0 || strcmp(s, "3-parity") == 0) { + 91 198 : *level = 2; + 92 198 : return 0; 93 : } 94 : - 95 5267 : if (strcmp(s, "4-parity") == 0) { - 96 193 : *level = 3; - 97 193 : return 0; + 95 5313 : if (strcmp(s, "4-parity") == 0) { + 96 195 : *level = 3; + 97 195 : return 0; 98 : } 99 : - 100 5074 : if (strcmp(s, "5-parity") == 0) { - 101 190 : *level = 4; - 102 190 : return 0; + 100 5118 : if (strcmp(s, "5-parity") == 0) { + 101 192 : *level = 4; + 102 192 : return 0; 103 : } 104 : - 105 4884 : if (strcmp(s, "6-parity") == 0) { - 106 186 : *level = 5; - 107 186 : return 0; + 105 4926 : if (strcmp(s, "6-parity") == 0) { + 106 188 : *level = 5; + 107 188 : return 0; 108 : } 109 : - 110 4698 : if (strcmp(s, "z-parity") == 0) { + 110 4738 : if (strcmp(s, "z-parity") == 0) { 111 0 : *level = 2; 112 0 : if (mode) 113 0 : *mode = RAID_MODE_VANDERMONDE; 114 0 : return 0; 115 : } 116 : - 117 4698 : return -1; + 117 4738 : return -1; 118 : } 119 : - 120 254 : const char* lev_raid_name(unsigned mode, unsigned n) + 120 256 : const char* lev_raid_name(unsigned mode, unsigned n) 121 : { - 122 254 : switch (n) { + 122 256 : switch (n) { 123 34 : case 1 : return "par1"; 124 25 : case 2 : return "par2"; 125 3 : case 3 : if (mode == RAID_MODE_CAUCHY) @@ -190,81 +190,81 @@ 128 0 : return "parz"; 129 3 : case 4 : return "par4"; 130 4 : case 5 : return "par5"; - 131 185 : case 6 : return "par6"; + 131 187 : case 6 : return "par6"; 132 : } 133 : 134 0 : return 0; 135 : } 136 : - 137 256 : void state_init(struct snapraid_state* state) + 137 258 : void state_init(struct snapraid_state* state) 138 : { 139 : unsigned l; 140 : - 141 256 : memset(&state->opt, 0, sizeof(state->opt)); - 142 256 : state->filter_hidden = 0; - 143 256 : state->autosave = 0; - 144 256 : state->need_write = 0; - 145 256 : state->checked_read = 0; - 146 256 : state->block_size = 256 * 1024; /* default 256 KiB */ - 147 256 : state->raid_mode = RAID_MODE_CAUCHY; - 148 256 : state->file_mode = MODE_SEQUENTIAL; - 149 1792 : for (l = 0; l < LEV_MAX; ++l) { - 150 1536 : state->parity[l].path[0] = 0; - 151 1536 : state->parity[l].smartctl[0] = 0; - 152 1536 : state->parity[l].uuid[0] = 0; - 153 1536 : state->parity[l].device = 0; - 154 1536 : state->parity[l].total_blocks = 0; - 155 1536 : state->parity[l].free_blocks = 0; - 156 1536 : state->parity[l].tick = 0; - 157 1536 : state->parity[l].skip_access = 0; - 158 1536 : state->parity[l].is_excluded = 0; + 141 258 : memset(&state->opt, 0, sizeof(state->opt)); + 142 258 : state->filter_hidden = 0; + 143 258 : state->autosave = 0; + 144 258 : state->need_write = 0; + 145 258 : state->checked_read = 0; + 146 258 : state->block_size = 256 * 1024; /* default 256 KiB */ + 147 258 : state->raid_mode = RAID_MODE_CAUCHY; + 148 258 : state->file_mode = MODE_SEQUENTIAL; + 149 1806 : for (l = 0; l < LEV_MAX; ++l) { + 150 1548 : state->parity[l].path[0] = 0; + 151 1548 : state->parity[l].smartctl[0] = 0; + 152 1548 : state->parity[l].uuid[0] = 0; + 153 1548 : state->parity[l].device = 0; + 154 1548 : state->parity[l].total_blocks = 0; + 155 1548 : state->parity[l].free_blocks = 0; + 156 1548 : state->parity[l].tick = 0; + 157 1548 : state->parity[l].skip_access = 0; + 158 1548 : state->parity[l].is_excluded = 0; 159 : } - 160 256 : state->tick_io = 0; - 161 256 : state->tick_cpu = 0; - 162 256 : state->tick_last = tick(); - 163 256 : state->share[0] = 0; - 164 256 : state->pool[0] = 0; - 165 256 : state->pool_device = 0; - 166 256 : state->lockfile[0] = 0; - 167 256 : state->level = 1; /* default is the lowest protection */ - 168 256 : state->clear_past_hash = 0; - 169 256 : state->no_conf = 0; + 160 258 : state->tick_io = 0; + 161 258 : state->tick_cpu = 0; + 162 258 : state->tick_last = tick(); + 163 258 : state->share[0] = 0; + 164 258 : state->pool[0] = 0; + 165 258 : state->pool_device = 0; + 166 258 : state->lockfile[0] = 0; + 167 258 : state->level = 1; /* default is the lowest protection */ + 168 258 : state->clear_past_hash = 0; + 169 258 : state->no_conf = 0; 170 : - 171 256 : tommy_list_init(&state->disklist); - 172 256 : tommy_list_init(&state->maplist); - 173 256 : tommy_list_init(&state->contentlist); - 174 256 : tommy_list_init(&state->filterlist); - 175 256 : tommy_list_init(&state->importlist); - 176 256 : tommy_hashdyn_init(&state->importset); - 177 256 : tommy_hashdyn_init(&state->previmportset); - 178 256 : tommy_hashdyn_init(&state->searchset); - 179 256 : tommy_arrayblkof_init(&state->infoarr, sizeof(snapraid_info)); - 180 256 : } + 171 258 : tommy_list_init(&state->disklist); + 172 258 : tommy_list_init(&state->maplist); + 173 258 : tommy_list_init(&state->contentlist); + 174 258 : tommy_list_init(&state->filterlist); + 175 258 : tommy_list_init(&state->importlist); + 176 258 : tommy_hashdyn_init(&state->importset); + 177 258 : tommy_hashdyn_init(&state->previmportset); + 178 258 : tommy_hashdyn_init(&state->searchset); + 179 258 : tommy_arrayblkof_init(&state->infoarr, sizeof(snapraid_info)); + 180 258 : } 181 : - 182 234 : void state_done(struct snapraid_state* state) + 182 236 : void state_done(struct snapraid_state* state) 183 : { - 184 234 : tommy_list_foreach(&state->disklist, (tommy_foreach_func*)disk_free); - 185 234 : tommy_list_foreach(&state->maplist, (tommy_foreach_func*)map_free); - 186 234 : tommy_list_foreach(&state->contentlist, (tommy_foreach_func*)content_free); - 187 234 : tommy_list_foreach(&state->filterlist, (tommy_foreach_func*)filter_free); - 188 234 : tommy_list_foreach(&state->importlist, (tommy_foreach_func*)import_file_free); - 189 234 : tommy_hashdyn_foreach(&state->searchset, (tommy_foreach_func*)search_file_free); - 190 234 : tommy_hashdyn_done(&state->importset); - 191 234 : tommy_hashdyn_done(&state->previmportset); - 192 234 : tommy_hashdyn_done(&state->searchset); - 193 234 : tommy_arrayblkof_done(&state->infoarr); - 194 234 : } + 184 236 : tommy_list_foreach(&state->disklist, (tommy_foreach_func*)disk_free); + 185 236 : tommy_list_foreach(&state->maplist, (tommy_foreach_func*)map_free); + 186 236 : tommy_list_foreach(&state->contentlist, (tommy_foreach_func*)content_free); + 187 236 : tommy_list_foreach(&state->filterlist, (tommy_foreach_func*)filter_free); + 188 236 : tommy_list_foreach(&state->importlist, (tommy_foreach_func*)import_file_free); + 189 236 : tommy_hashdyn_foreach(&state->searchset, (tommy_foreach_func*)search_file_free); + 190 236 : tommy_hashdyn_done(&state->importset); + 191 236 : tommy_hashdyn_done(&state->previmportset); + 192 236 : tommy_hashdyn_done(&state->searchset); + 193 236 : tommy_arrayblkof_done(&state->infoarr); + 194 236 : } 195 : 196 : /** 197 : * Check the configuration. 198 : */ - 199 254 : static void state_config_check(struct snapraid_state* state, const char* path, tommy_list* filterlist_disk) + 199 256 : static void state_config_check(struct snapraid_state* state, const char* path, tommy_list* filterlist_disk) 200 : { 201 : tommy_node* i; 202 : unsigned l; 203 : 204 : /* check for parity level */ - 205 254 : if (state->raid_mode == RAID_MODE_VANDERMONDE) { + 205 256 : if (state->raid_mode == RAID_MODE_VANDERMONDE) { 206 0 : if (state->level > 3) { 207 : /* LCOV_EXCL_START */ 208 : log_fatal("If you use the z-parity you cannot have more than 3 parities.\n"); @@ -282,7 +282,7 @@ 220 : } 221 : } 222 : - 223 254 : if (tommy_list_empty(&state->contentlist)) { + 223 256 : if (tommy_list_empty(&state->contentlist)) { 224 : /* LCOV_EXCL_START */ 225 : log_fatal("No 'content' specification in '%s'\n", path); 226 : exit(EXIT_FAILURE); @@ -290,11 +290,11 @@ 228 : } 229 : 230 : /* check for equal paths */ - 231 1743 : for (i = state->contentlist; i != 0; i = i->next) { - 232 1489 : struct snapraid_content* content = i->data; + 231 1759 : for (i = state->contentlist; i != 0; i = i->next) { + 232 1503 : struct snapraid_content* content = i->data; 233 : - 234 9693 : for (l = 0; l < state->level; ++l) { - 235 8204 : if (pathcmp(state->parity[l].path, content->content) == 0) { + 234 9791 : for (l = 0; l < state->level; ++l) { + 235 8288 : if (pathcmp(state->parity[l].path, content->content) == 0) { 236 : /* LCOV_EXCL_START */ 237 : log_fatal("Same path used for '%s' and 'content' as '%s'\n", lev_config_name(l), content->content); 238 : exit(EXIT_FAILURE); @@ -304,7 +304,7 @@ 242 : } 243 : 244 : /* check device of data disks */ - 245 254 : if (!state->opt.skip_device && !state->opt.skip_disk_access) { + 245 256 : if (!state->opt.skip_device && !state->opt.skip_disk_access) { 246 0 : for (i = state->disklist; i != 0; i = i->next) { 247 : tommy_node* j; 248 0 : struct snapraid_disk* disk = i->data; @@ -387,7 +387,7 @@ 325 : } 326 : 327 : /* check device of parity disks */ - 328 254 : if (!state->opt.skip_device && !state->opt.skip_parity_access) { + 328 256 : if (!state->opt.skip_device && !state->opt.skip_parity_access) { 329 0 : for (l = 0; l < state->level; ++l) { 330 : unsigned j; 331 : @@ -467,7 +467,7 @@ 405 : #endif 406 : 407 : /* count the content files */ - 408 254 : if (!state->opt.skip_device && !state->opt.skip_content_access) { + 408 256 : if (!state->opt.skip_device && !state->opt.skip_content_access) { 409 : unsigned content_count; 410 : 411 0 : content_count = 0; @@ -500,7 +500,7 @@ 438 : 439 : /* check for speed */ 440 : #ifdef CONFIG_X86 - 441 254 : if (!raid_cpu_has_ssse3()) + 441 256 : if (!raid_cpu_has_ssse3()) 442 : #endif 443 0 : if (state->raid_mode == RAID_MODE_CAUCHY && !state->opt.no_warnings) { 444 0 : if (state->level == 3) { @@ -513,7 +513,7 @@ 451 : } 452 : 453 : /* ensure that specified filter disks are valid ones */ - 454 262 : for (i = tommy_list_head(filterlist_disk); i != 0; i = i->next) { + 454 264 : for (i = tommy_list_head(filterlist_disk); i != 0; i = i->next) { 455 : tommy_node* j; 456 8 : struct snapraid_filter* filter = i->data; 457 43 : for (j = state->disklist; j != 0; j = j->next) { @@ -534,39 +534,39 @@ 472 : } 473 : } 474 : } - 475 254 : } + 475 256 : } 476 : 477 : /** 478 : * Validate the smartctl command. 479 : * 480 : * It must contains only one %s string, and not other % chars. 481 : */ - 482 358 : static int validate_smartctl(const char* custom) + 482 362 : static int validate_smartctl(const char* custom) 483 : { - 484 358 : const char* s = custom; - 485 358 : int arg = 0; + 484 362 : const char* s = custom; + 485 362 : int arg = 0; 486 : - 487 2506 : while (*s) { - 488 1790 : if (s[0] == '%' && s[1] == 's') { - 489 179 : if (arg) { + 487 2534 : while (*s) { + 488 1810 : if (s[0] == '%' && s[1] == 's') { + 489 181 : if (arg) { 490 : /* LCOV_EXCL_START */ 491 : return -1; 492 : /* LCOV_EXCL_STOP */ 493 : } - 494 179 : arg = 1; - 495 1611 : } else if (s[0] == '%') { + 494 181 : arg = 1; + 495 1629 : } else if (s[0] == '%') { 496 : /* LCOV_EXCL_START */ 497 : return -1; 498 : /* LCOV_EXCL_STOP */ 499 : } 500 : - 501 1790 : ++s; + 501 1810 : ++s; 502 : } 503 : - 504 358 : return 0; + 504 362 : return 0; 505 : } 506 : - 507 255 : void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk) + 507 257 : void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk) 508 : { 509 : STREAM* f; 510 : unsigned line; @@ -574,23 +574,23 @@ 512 : unsigned l; 513 : 514 : /* copy the options */ - 515 255 : state->opt = *opt; + 515 257 : state->opt = *opt; 516 : 517 : /* if unset, sort by physical order */ - 518 255 : if (!state->opt.force_order) + 518 257 : if (!state->opt.force_order) 519 1 : state->opt.force_order = SORT_PHYSICAL; 520 : 521 : /* adjust file mode */ - 522 255 : if (state->opt.skip_sequential) + 522 257 : if (state->opt.skip_sequential) 523 1 : state->file_mode &= ~MODE_SEQUENTIAL; 524 : 525 : /* store current command */ - 526 255 : state->command = command; + 526 257 : state->command = command; 527 : - 528 255 : log_tag("conf:%s\n", path); + 528 257 : log_tag("conf:%s\n", path); 529 : - 530 255 : f = sopen_read(path); - 531 255 : if (!f) { + 530 257 : f = sopen_read(path); + 531 257 : if (!f) { 532 : /* LCOV_EXCL_START */ 533 : if (errno == ENOENT) { 534 : log_fatal("No configuration file found at '%s'\n", path); @@ -603,7 +603,7 @@ 541 : /* LCOV_EXCL_STOP */ 542 : } 543 : - 544 255 : line = 1; + 544 257 : line = 1; 545 : while (1) { 546 : char tag[PATH_MAX]; 547 : char buffer[PATH_MAX]; @@ -612,11 +612,11 @@ 550 : unsigned level; 551 : 552 : /* skip initial spaces */ - 553 6015 : sgetspace(f); + 553 6067 : sgetspace(f); 554 : 555 : /* read the command */ - 556 6015 : ret = sgettok(f, tag, sizeof(tag)); - 557 6015 : if (ret < 0) { + 556 6067 : ret = sgettok(f, tag, sizeof(tag)); + 557 6067 : if (ret < 0) { 558 : /* LCOV_EXCL_START */ 559 : log_fatal("Error reading the configuration file '%s' at line %u\n", path, line); 560 : exit(EXIT_FAILURE); @@ -624,83 +624,83 @@ 562 : } 563 : 564 : /* skip spaces after the command */ - 565 6015 : sgetspace(f); + 565 6067 : sgetspace(f); 566 : - 567 6015 : if (strcmp(tag, "blocksize") == 0 + 567 6067 : if (strcmp(tag, "blocksize") == 0 568 : /* block_size is the old format of the option */ - 569 5760 : || strcmp(tag, "block_size") == 0) { + 569 5810 : || strcmp(tag, "block_size") == 0) { 570 : - 571 255 : ret = sgetu32(f, &state->block_size); - 572 255 : if (ret < 0) { + 571 257 : ret = sgetu32(f, &state->block_size); + 572 257 : if (ret < 0) { 573 : /* LCOV_EXCL_START */ 574 : log_fatal("Invalid 'blocksize' specification in '%s' at line %u\n", path, line); 575 : exit(EXIT_FAILURE); 576 : /* LCOV_EXCL_STOP */ 577 : } - 578 255 : if (state->block_size < 1) { + 578 257 : if (state->block_size < 1) { 579 : /* LCOV_EXCL_START */ 580 : log_fatal("Too small 'blocksize' specification in '%s' at line %u\n", path, line); 581 : exit(EXIT_FAILURE); 582 : /* LCOV_EXCL_STOP */ 583 : } - 584 255 : if (state->block_size > 16 * 1024) { + 584 257 : if (state->block_size > 16 * 1024) { 585 : /* LCOV_EXCL_START */ 586 : log_fatal("Too big 'blocksize' specification in '%s' at line %u\n", path, line); 587 : exit(EXIT_FAILURE); 588 : /* LCOV_EXCL_STOP */ 589 : } 590 : /* check if it's a power of 2 */ - 591 255 : if ((state->block_size & (state->block_size - 1)) != 0) { + 591 257 : if ((state->block_size & (state->block_size - 1)) != 0) { 592 : /* LCOV_EXCL_START */ 593 : log_fatal("Not power of 2 'blocksize' specification in '%s' at line %u\n", path, line); 594 : exit(EXIT_FAILURE); 595 : /* LCOV_EXCL_STOP */ 596 : } - 597 255 : state->block_size *= 1024; - 598 5760 : } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { + 597 257 : state->block_size *= 1024; + 598 5810 : } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { 599 : char device[PATH_MAX]; 600 : char* slash; 601 : uint64_t dev; 602 : int skip_access; 603 : - 604 1241 : if (*state->parity[level].path) { + 604 1253 : if (*state->parity[level].path) { 605 : /* LCOV_EXCL_START */ 606 : log_fatal("Multiple '%s' specification in '%s' at line %u\n", tag, path, line); 607 : exit(EXIT_FAILURE); 608 : /* LCOV_EXCL_STOP */ 609 : } 610 : - 611 1241 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 612 1241 : if (ret < 0) { + 611 1253 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 612 1253 : if (ret < 0) { 613 : /* LCOV_EXCL_START */ 614 : log_fatal("Invalid '%s' specification in '%s' at line %u\n", tag, path, line); 615 : exit(EXIT_FAILURE); 616 : /* LCOV_EXCL_STOP */ 617 : } 618 : - 619 1241 : if (!*buffer) { + 619 1253 : if (!*buffer) { 620 : /* LCOV_EXCL_START */ 621 : log_fatal("Empty '%s' specification in '%s' at line %u\n", tag, path, line); 622 : exit(EXIT_FAILURE); 623 : /* LCOV_EXCL_STOP */ 624 : } 625 : - 626 1241 : pathimport(state->parity[level].path, sizeof(state->parity[level].path), buffer); + 626 1253 : pathimport(state->parity[level].path, sizeof(state->parity[level].path), buffer); 627 : - 628 1241 : skip_access = 0; - 629 1241 : if (!state->opt.skip_parity_access) { + 628 1253 : skip_access = 0; + 629 1253 : if (!state->opt.skip_parity_access) { 630 : struct stat st; 631 : 632 : /* get the device of the directory containing the parity file */ - 633 1066 : pathimport(device, sizeof(device), buffer); - 634 1066 : slash = strrchr(device, '/'); - 635 1066 : if (slash) - 636 1066 : *slash = 0; + 633 1078 : pathimport(device, sizeof(device), buffer); + 634 1078 : slash = strrchr(device, '/'); + 635 1078 : if (slash) + 636 1078 : *slash = 0; 637 : else 638 0 : pathcpy(device, sizeof(device), "."); 639 : - 640 1066 : if (stat(device, &st) == 0) { - 641 1064 : dev = st.st_dev; + 640 1078 : if (stat(device, &st) == 0) { + 641 1076 : dev = st.st_dev; 642 : } else { 643 : /* if the disk can be skipped */ 644 2 : if (state->opt.force_device) { @@ -725,13 +725,13 @@ 663 175 : dev = 0; 664 : } 665 : - 666 1240 : state->parity[level].device = dev; - 667 1240 : state->parity[level].skip_access = skip_access; + 666 1252 : state->parity[level].device = dev; + 667 1252 : state->parity[level].skip_access = skip_access; 668 : 669 : /* adjust the level */ - 670 1240 : if (state->level < level + 1) - 671 985 : state->level = level + 1; - 672 4519 : } else if (strcmp(tag, "share") == 0) { + 670 1252 : if (state->level < level + 1) + 671 995 : state->level = level + 1; + 672 4557 : } else if (strcmp(tag, "share") == 0) { 673 34 : if (*state->share) { 674 : /* LCOV_EXCL_START */ 675 : log_fatal("Multiple 'share' specification in '%s' at line %u\n", path, line); @@ -755,7 +755,7 @@ 693 : } 694 : 695 34 : pathimport(state->share, sizeof(state->share), buffer); - 696 4485 : } else if (strcmp(tag, "pool") == 0) { + 696 4523 : } else if (strcmp(tag, "pool") == 0) { 697 : struct stat st; 698 : 699 34 : if (*state->pool) { @@ -791,29 +791,29 @@ 729 : } 730 : 731 34 : state->pool_device = st.st_dev; - 732 4451 : } else if (strcmp(tag, "content") == 0) { + 732 4489 : } else if (strcmp(tag, "content") == 0) { 733 : struct snapraid_content* content; 734 : char device[PATH_MAX]; 735 : char* slash; 736 : struct stat st; 737 : uint64_t dev; 738 : - 739 1489 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 740 1489 : if (ret < 0) { + 739 1503 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 740 1503 : if (ret < 0) { 741 : /* LCOV_EXCL_START */ 742 : log_fatal("Invalid 'content' specification in '%s' at line %u\n", path, line); 743 : exit(EXIT_FAILURE); 744 : /* LCOV_EXCL_STOP */ 745 : } 746 : - 747 1489 : if (pathcmp(buffer, "/dev/null") == 0 || pathcmp(buffer, "NUL") == 0) { + 747 1503 : if (pathcmp(buffer, "/dev/null") == 0 || pathcmp(buffer, "NUL") == 0) { 748 : /* LCOV_EXCL_START */ 749 : log_fatal("You cannot use the null device as 'content' specification in '%s' at line %u\n", path, line); 750 : exit(EXIT_FAILURE); 751 : /* LCOV_EXCL_STOP */ 752 : } 753 : - 754 1489 : if (!*buffer) { + 754 1503 : if (!*buffer) { 755 : /* LCOV_EXCL_START */ 756 : log_fatal("Empty 'content' specification in '%s' at line %u\n", path, line); 757 : exit(EXIT_FAILURE); @@ -821,12 +821,12 @@ 759 : } 760 : 761 : /* check if the content file is already specified */ - 762 5591 : for (i = state->contentlist; i != 0; i = i->next) { - 763 4102 : content = i->data; - 764 4102 : if (pathcmp(content->content, buffer) == 0) + 762 5647 : for (i = state->contentlist; i != 0; i = i->next) { + 763 4144 : content = i->data; + 764 4144 : if (pathcmp(content->content, buffer) == 0) 765 0 : break; 766 : } - 767 1489 : if (i) { + 767 1503 : if (i) { 768 : /* LCOV_EXCL_START */ 769 : log_fatal("Duplicate 'content' specification in '%s' at line %u\n", path, line); 770 : exit(EXIT_FAILURE); @@ -834,14 +834,14 @@ 772 : } 773 : 774 : /* get the device of the directory containing the content file */ - 775 1489 : pathimport(device, sizeof(device), buffer); - 776 1489 : slash = strrchr(device, '/'); - 777 1489 : if (slash) - 778 1489 : *slash = 0; + 775 1503 : pathimport(device, sizeof(device), buffer); + 776 1503 : slash = strrchr(device, '/'); + 777 1503 : if (slash) + 778 1503 : *slash = 0; 779 : else 780 0 : pathcpy(device, sizeof(device), "."); - 781 1489 : if (stat(device, &st) == 0) { - 782 1488 : dev = st.st_dev; + 781 1503 : if (stat(device, &st) == 0) { + 782 1502 : dev = st.st_dev; 783 : } else { 784 1 : if (state->opt.skip_content_access) { 785 : /* use a fake device */ @@ -856,15 +856,15 @@ 794 : } 795 : 796 : /* set the lock file at the first accessible content file */ - 797 1489 : if (state->lockfile[0] == 0 && dev != 0) { - 798 254 : pathcpy(state->lockfile, sizeof(state->lockfile), buffer); - 799 254 : pathcat(state->lockfile, sizeof(state->lockfile), ".lock"); + 797 1503 : if (state->lockfile[0] == 0 && dev != 0) { + 798 256 : pathcpy(state->lockfile, sizeof(state->lockfile), buffer); + 799 256 : pathcat(state->lockfile, sizeof(state->lockfile), ".lock"); 800 : } 801 : - 802 1489 : content = content_alloc(buffer, dev); + 802 1503 : content = content_alloc(buffer, dev); 803 : - 804 1489 : tommy_list_insert_tail(&state->contentlist, &content->node, content); - 805 2962 : } else if (strcmp(tag, "disk") == 0) { + 804 1503 : tommy_list_insert_tail(&state->contentlist, &content->node, content); + 805 2986 : } else if (strcmp(tag, "disk") == 0) { 806 : char dir[PATH_MAX]; 807 : char device[PATH_MAX]; 808 : char uuid[UUID_MAX]; @@ -872,32 +872,32 @@ 810 : uint64_t dev; 811 : int skip_access; 812 : - 813 1519 : ret = sgettok(f, buffer, sizeof(buffer)); - 814 1519 : if (ret < 0) { + 813 1531 : ret = sgettok(f, buffer, sizeof(buffer)); + 814 1531 : if (ret < 0) { 815 : /* LCOV_EXCL_START */ 816 : log_fatal("Invalid 'disk' name specification in '%s' at line %u\n", path, line); 817 : exit(EXIT_FAILURE); 818 : /* LCOV_EXCL_STOP */ 819 : } 820 : - 821 1519 : if (!*buffer) { + 821 1531 : if (!*buffer) { 822 : /* LCOV_EXCL_START */ 823 : log_fatal("Empty 'disk' name specification in '%s' at line %u\n", path, line); 824 : exit(EXIT_FAILURE); 825 : /* LCOV_EXCL_STOP */ 826 : } 827 : - 828 1519 : sgetspace(f); + 828 1531 : sgetspace(f); 829 : - 830 1519 : ret = sgetlasttok(f, dir, sizeof(dir)); - 831 1519 : if (ret < 0) { + 830 1531 : ret = sgetlasttok(f, dir, sizeof(dir)); + 831 1531 : if (ret < 0) { 832 : /* LCOV_EXCL_START */ 833 : log_fatal("Invalid 'disk' dir specification in '%s' at line %u\n", path, line); 834 : exit(EXIT_FAILURE); 835 : /* LCOV_EXCL_STOP */ 836 : } 837 : - 838 1519 : if (!*dir) { + 838 1531 : if (!*dir) { 839 : /* LCOV_EXCL_START */ 840 : log_fatal("Empty 'disk' dir specification in '%s' at line %u\n", path, line); 841 : exit(EXIT_FAILURE); @@ -905,15 +905,15 @@ 843 : } 844 : 845 : /* get the device of the dir */ - 846 1519 : pathimport(device, sizeof(device), dir); + 846 1531 : pathimport(device, sizeof(device), dir); 847 : 848 : /* check if the disk name already exists */ - 849 5304 : for (i = state->disklist; i != 0; i = i->next) { - 850 3785 : disk = i->data; - 851 3785 : if (strcmp(disk->name, buffer) == 0) + 849 5346 : for (i = state->disklist; i != 0; i = i->next) { + 850 3815 : disk = i->data; + 851 3815 : if (strcmp(disk->name, buffer) == 0) 852 0 : break; 853 : } - 854 1519 : if (i) { + 854 1531 : if (i) { 855 : /* LCOV_EXCL_START */ 856 : log_fatal("Duplicate disk name '%s' at line %u\n", buffer, line); 857 : exit(EXIT_FAILURE); @@ -921,20 +921,20 @@ 859 : } 860 : 861 : /* if the disk has to be present */ - 862 1519 : skip_access = 0; - 863 1519 : if (!state->opt.skip_disk_access) { + 862 1531 : skip_access = 0; + 863 1531 : if (!state->opt.skip_disk_access) { 864 : struct stat st; 865 : - 866 1375 : if (stat(device, &st) == 0) { - 867 1374 : dev = st.st_dev; + 866 1387 : if (stat(device, &st) == 0) { + 867 1386 : dev = st.st_dev; 868 : 869 : /* read the uuid, if unsupported use an empty one */ - 870 1374 : if (devuuid(dev, uuid, sizeof(uuid)) != 0) { + 870 1386 : if (devuuid(dev, uuid, sizeof(uuid)) != 0) { 871 0 : *uuid = 0; 872 : } 873 : 874 : /* fake a different UUID when testing */ - 875 1374 : if (state->opt.fake_uuid) { + 875 1386 : if (state->opt.fake_uuid) { 876 2 : snprintf(uuid, sizeof(uuid), "fake-uuid-%d", state->opt.fake_uuid); 877 2 : --state->opt.fake_uuid; 878 : } @@ -964,45 +964,45 @@ 902 144 : *uuid = 0; 903 : } 904 : - 905 1519 : disk = disk_alloc(buffer, dir, dev, uuid, skip_access); + 905 1531 : disk = disk_alloc(buffer, dir, dev, uuid, skip_access); 906 : - 907 1519 : tommy_list_insert_tail(&state->disklist, &disk->node, disk); - 908 1443 : } else if (strcmp(tag, "smartctl") == 0) { + 907 1531 : tommy_list_insert_tail(&state->disklist, &disk->node, disk); + 908 1455 : } else if (strcmp(tag, "smartctl") == 0) { 909 : char custom[PATH_MAX]; 910 : - 911 358 : ret = sgettok(f, buffer, sizeof(buffer)); - 912 358 : if (ret < 0) { + 911 362 : ret = sgettok(f, buffer, sizeof(buffer)); + 912 362 : if (ret < 0) { 913 : /* LCOV_EXCL_START */ 914 : log_fatal("Invalid 'smartctl' name specification in '%s' at line %u\n", path, line); 915 : exit(EXIT_FAILURE); 916 : /* LCOV_EXCL_STOP */ 917 : } 918 : - 919 358 : if (!*buffer) { + 919 362 : if (!*buffer) { 920 : /* LCOV_EXCL_START */ 921 : log_fatal("Empty 'smartctl' name specification in '%s' at line %u\n", path, line); 922 : exit(EXIT_FAILURE); 923 : /* LCOV_EXCL_STOP */ 924 : } 925 : - 926 358 : sgetspace(f); + 926 362 : sgetspace(f); 927 : - 928 358 : ret = sgetlasttok(f, custom, sizeof(custom)); - 929 358 : if (ret < 0) { + 928 362 : ret = sgetlasttok(f, custom, sizeof(custom)); + 929 362 : if (ret < 0) { 930 : /* LCOV_EXCL_START */ 931 : log_fatal("Invalid 'smartctl' option specification in '%s' at line %u\n", path, line); 932 : exit(EXIT_FAILURE); 933 : /* LCOV_EXCL_STOP */ 934 : } 935 : - 936 358 : if (!*custom) { + 936 362 : if (!*custom) { 937 : /* LCOV_EXCL_START */ 938 : log_fatal("Empty 'smartctl' option specification in '%s' at line %u\n", path, line); 939 : exit(EXIT_FAILURE); 940 : /* LCOV_EXCL_STOP */ 941 : } 942 : - 943 358 : if (validate_smartctl(custom) != 0) { + 943 362 : if (validate_smartctl(custom) != 0) { 944 : /* LCOV_EXCL_START */ 945 : log_fatal("Invalid 'smartctl' option specification in '%s' at line %u\n", path, line); 946 : exit(EXIT_FAILURE); @@ -1010,97 +1010,97 @@ 948 : } 949 : 950 : /* search for parity */ - 951 358 : if (lev_config_scan(buffer, &level, 0) == 0) { - 952 179 : if (state->parity[level].smartctl[0] != 0) { + 951 362 : if (lev_config_scan(buffer, &level, 0) == 0) { + 952 181 : if (state->parity[level].smartctl[0] != 0) { 953 : /* LCOV_EXCL_START */ 954 : log_fatal("Duplicate parity smartctl '%s' at line %u\n", buffer, line); 955 : exit(EXIT_FAILURE); 956 : /* LCOV_EXCL_STOP */ 957 : } 958 : - 959 179 : pathcpy(state->parity[level].smartctl, sizeof(state->parity[level].smartctl), custom); + 959 181 : pathcpy(state->parity[level].smartctl, sizeof(state->parity[level].smartctl), custom); 960 : } else { 961 : struct snapraid_disk* disk; 962 : 963 : /* search the disk */ - 964 179 : disk = 0; - 965 179 : for (i = state->disklist; i != 0; i = i->next) { - 966 179 : disk = i->data; - 967 179 : if (strcmp(disk->name, buffer) == 0) - 968 179 : break; + 964 181 : disk = 0; + 965 181 : for (i = state->disklist; i != 0; i = i->next) { + 966 181 : disk = i->data; + 967 181 : if (strcmp(disk->name, buffer) == 0) + 968 181 : break; 969 : } - 970 179 : if (!disk) { + 970 181 : if (!disk) { 971 : /* LCOV_EXCL_START */ 972 : log_fatal("Missing disk smartctl '%s' at line %u\n", buffer, line); 973 : exit(EXIT_FAILURE); 974 : /* LCOV_EXCL_STOP */ 975 : } - 976 179 : if (disk->smartctl[0] != 0) { + 976 181 : if (disk->smartctl[0] != 0) { 977 : /* LCOV_EXCL_START */ 978 : log_fatal("Duplicate disk name '%s' at line %u\n", buffer, line); 979 : exit(EXIT_FAILURE); 980 : /* LCOV_EXCL_STOP */ 981 : } 982 : - 983 179 : pathcpy(disk->smartctl, sizeof(disk->smartctl), custom); + 983 181 : pathcpy(disk->smartctl, sizeof(disk->smartctl), custom); 984 : } - 985 1085 : } else if (strcmp(tag, "nohidden") == 0) { + 985 1093 : } else if (strcmp(tag, "nohidden") == 0) { 986 0 : state->filter_hidden = 1; - 987 1085 : } else if (strcmp(tag, "exclude") == 0) { + 987 1093 : } else if (strcmp(tag, "exclude") == 0) { 988 : struct snapraid_filter* filter; 989 : - 990 254 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 991 254 : if (ret < 0) { + 990 256 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 991 256 : if (ret < 0) { 992 : /* LCOV_EXCL_START */ 993 : log_fatal("Invalid 'exclude' specification in '%s' at line %u\n", path, line); 994 : exit(EXIT_FAILURE); 995 : /* LCOV_EXCL_STOP */ 996 : } 997 : - 998 254 : if (!*buffer) { + 998 256 : if (!*buffer) { 999 : /* LCOV_EXCL_START */ 1000 : log_fatal("Empty 'exclude' specification in '%s' at line %u\n", path, line); 1001 : exit(EXIT_FAILURE); 1002 : /* LCOV_EXCL_STOP */ 1003 : } 1004 : - 1005 254 : filter = filter_alloc_file(-1, buffer); - 1006 254 : if (!filter) { + 1005 256 : filter = filter_alloc_file(-1, buffer); + 1006 256 : if (!filter) { 1007 : /* LCOV_EXCL_START */ 1008 : log_fatal("Invalid 'exclude' specification '%s' in '%s' at line %u\n", buffer, path, line); 1009 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); 1010 : exit(EXIT_FAILURE); 1011 : /* LCOV_EXCL_STOP */ 1012 : } - 1013 254 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); - 1014 831 : } else if (strcmp(tag, "include") == 0) { + 1013 256 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); + 1014 837 : } else if (strcmp(tag, "include") == 0) { 1015 : struct snapraid_filter* filter; 1016 : - 1017 254 : ret = sgetlasttok(f, buffer, sizeof(buffer)); - 1018 254 : if (ret < 0) { + 1017 256 : ret = sgetlasttok(f, buffer, sizeof(buffer)); + 1018 256 : if (ret < 0) { 1019 : /* LCOV_EXCL_START */ 1020 : log_fatal("Invalid 'include' specification in '%s' at line %u\n", path, line); 1021 : exit(EXIT_FAILURE); 1022 : /* LCOV_EXCL_STOP */ 1023 : } 1024 : - 1025 254 : if (!*buffer) { + 1025 256 : if (!*buffer) { 1026 : /* LCOV_EXCL_START */ 1027 : log_fatal("Empty 'include' specification in '%s' at line %u\n", path, line); 1028 : exit(EXIT_FAILURE); 1029 : /* LCOV_EXCL_STOP */ 1030 : } 1031 : - 1032 254 : filter = filter_alloc_file(1, buffer); - 1033 254 : if (!filter) { + 1032 256 : filter = filter_alloc_file(1, buffer); + 1033 256 : if (!filter) { 1034 : /* LCOV_EXCL_START */ 1035 : log_fatal("Invalid 'include' specification '%s' in '%s' at line %u\n", buffer, path, line); 1036 : log_fatal("Filters using relative paths are not supported. Ensure to add an initial slash\n"); 1037 : exit(EXIT_FAILURE); 1038 : /* LCOV_EXCL_STOP */ 1039 : } - 1040 254 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); - 1041 577 : } else if (strcmp(tag, "autosave") == 0) { + 1040 256 : tommy_list_insert_tail(&state->filterlist, &filter->node, filter); + 1041 581 : } else if (strcmp(tag, "autosave") == 0) { 1042 : char* e; 1043 : 1044 34 : ret = sgetlasttok(f, buffer, sizeof(buffer)); @@ -1129,7 +1129,7 @@ 1067 : 1068 : /* convert to GB */ 1069 34 : state->autosave *= GIGA; - 1070 543 : } else if (tag[0] == 0) { + 1070 547 : } else if (tag[0] == 0) { 1071 : /* allow empty lines */ 1072 34 : } else if (tag[0] == '#') { 1073 34 : ret = sgetline(f, buffer, sizeof(buffer)); @@ -1147,42 +1147,42 @@ 1085 : } 1086 : 1087 : /* skip final spaces */ - 1088 6014 : sgetspace(f); + 1088 6066 : sgetspace(f); 1089 : 1090 : /* next line */ - 1091 6014 : c = sgeteol(f); - 1092 6014 : if (c == EOF) { - 1093 254 : break; + 1091 6066 : c = sgeteol(f); + 1092 6066 : if (c == EOF) { + 1093 256 : break; 1094 : } - 1095 5760 : if (c != '\n') { + 1095 5810 : if (c != '\n') { 1096 : /* LCOV_EXCL_START */ 1097 : log_fatal("Extra data in '%s' at line %u\n", path, line); 1098 : exit(EXIT_FAILURE); 1099 : /* LCOV_EXCL_STOP */ 1100 : } - 1101 5760 : ++line; - 1102 5760 : } + 1101 5810 : ++line; + 1102 5810 : } 1103 : - 1104 254 : if (serror(f)) { + 1104 256 : if (serror(f)) { 1105 : /* LCOV_EXCL_START */ 1106 : log_fatal("Error reading the configuration file '%s' at line %u\n", path, line); 1107 : exit(EXIT_FAILURE); 1108 : /* LCOV_EXCL_STOP */ 1109 : } 1110 : - 1111 254 : sclose(f); + 1111 256 : sclose(f); 1112 : - 1113 254 : state_config_check(state, path, filterlist_disk); + 1113 256 : state_config_check(state, path, filterlist_disk); 1114 : 1115 : /* select the default hash */ - 1116 254 : if (state->opt.force_murmur3) { + 1116 256 : if (state->opt.force_murmur3) { 1117 1 : state->besthash = HASH_MURMUR3; - 1118 253 : } else if (state->opt.force_spooky2) { + 1118 255 : } else if (state->opt.force_spooky2) { 1119 1 : state->besthash = HASH_SPOOKY2; 1120 : } else { 1121 : #ifdef CONFIG_X86 - 1122 252 : if (sizeof(void*) == 4 && !raid_cpu_has_slowmult()) - 1123 252 : state->besthash = HASH_MURMUR3; + 1122 254 : if (sizeof(void*) == 4 && !raid_cpu_has_slowmult()) + 1123 254 : state->besthash = HASH_MURMUR3; 1124 : else 1125 0 : state->besthash = HASH_SPOOKY2; 1126 : #else @@ -1194,10 +1194,10 @@ 1132 : } 1133 : 1134 : /* by default use the best hash */ - 1135 254 : state->hash = state->besthash; + 1135 256 : state->hash = state->besthash; 1136 : 1137 : /* by default use a random hash seed */ - 1138 254 : if (randomize(state->hashseed, HASH_SIZE) != 0) { + 1138 256 : if (randomize(state->hashseed, HASH_SIZE) != 0) { 1139 : /* LCOV_EXCL_START */ 1140 : log_fatal("Failed to get random values.\n"); 1141 : exit(EXIT_FAILURE); @@ -1205,46 +1205,46 @@ 1143 : } 1144 : 1145 : /* no previous hash by default */ - 1146 254 : state->prevhash = HASH_UNDEFINED; + 1146 256 : state->prevhash = HASH_UNDEFINED; 1147 : 1148 : /* intentionally not set the prevhashseed, if used valgrind will warn about it */ 1149 : - 1150 254 : log_tag("blocksize:%u\n", state->block_size); - 1151 1773 : for (i = state->disklist; i != 0; i = i->next) { - 1152 1519 : struct snapraid_disk* disk = i->data; - 1153 1519 : log_tag("disk:%s:%s\n", disk->name, disk->dir); + 1150 256 : log_tag("blocksize:%u\n", state->block_size); + 1151 1787 : for (i = state->disklist; i != 0; i = i->next) { + 1152 1531 : struct snapraid_disk* disk = i->data; + 1153 1531 : log_tag("disk:%s:%s\n", disk->name, disk->dir); 1154 : } 1155 : - 1156 254 : log_tag("mode:%s\n", lev_raid_name(state->raid_mode, state->level)); - 1157 1489 : for (l = 0; l < state->level; ++l) - 1158 1235 : log_tag("%s:%s\n", lev_config_name(l), state->parity[l].path); - 1159 254 : if (state->pool[0] != 0) + 1156 256 : log_tag("mode:%s\n", lev_raid_name(state->raid_mode, state->level)); + 1157 1503 : for (l = 0; l < state->level; ++l) + 1158 1247 : log_tag("%s:%s\n", lev_config_name(l), state->parity[l].path); + 1159 256 : if (state->pool[0] != 0) 1160 34 : log_tag("pool:%s\n", state->pool); - 1161 254 : if (state->share[0] != 0) + 1161 256 : if (state->share[0] != 0) 1162 34 : log_tag("share:%s\n", state->share); - 1163 254 : if (state->autosave != 0) + 1163 256 : if (state->autosave != 0) 1164 34 : log_tag("autosave:%" PRIu64 "\n", state->autosave); - 1165 762 : for (i = tommy_list_head(&state->filterlist); i != 0; i = i->next) { + 1165 768 : for (i = tommy_list_head(&state->filterlist); i != 0; i = i->next) { 1166 : char out[PATH_MAX]; - 1167 508 : struct snapraid_filter* filter = i->data; - 1168 508 : log_tag("filter:%s\n", filter_type(filter, out, sizeof(out))); + 1167 512 : struct snapraid_filter* filter = i->data; + 1168 512 : log_tag("filter:%s\n", filter_type(filter, out, sizeof(out))); 1169 : } - 1170 254 : if (state->filter_hidden) + 1170 256 : if (state->filter_hidden) 1171 0 : log_tag("filter:nohidden:\n"); - 1172 254 : log_flush(); - 1173 254 : } + 1172 256 : log_flush(); + 1173 256 : } 1174 : 1175 : /** 1176 : * Find a disk by name. 1177 : */ - 1178 6723 : static struct snapraid_disk* find_disk_by_name(struct snapraid_state* state, const char* name) + 1178 6817 : static struct snapraid_disk* find_disk_by_name(struct snapraid_state* state, const char* name) 1179 : { 1180 : tommy_node* i; 1181 : - 1182 23463 : for (i = state->disklist; i != 0; i = i->next) { - 1183 23455 : struct snapraid_disk* disk = i->data; - 1184 23455 : if (strcmp(disk->name, name) == 0) - 1185 6715 : return disk; + 1182 23789 : for (i = state->disklist; i != 0; i = i->next) { + 1183 23781 : struct snapraid_disk* disk = i->data; + 1184 23781 : if (strcmp(disk->name, name) == 0) + 1185 6809 : return disk; 1186 : } 1187 : 1188 8 : if (state->no_conf) { @@ -1297,7 +1297,7 @@ 1235 : /** 1236 : * Update the disk mapping if required. 1237 : */ - 1238 249 : static void state_map(struct snapraid_state* state) + 1238 251 : static void state_map(struct snapraid_state* state) 1239 : { 1240 : unsigned hole; 1241 : tommy_node* i; @@ -1309,16 +1309,16 @@ 1247 : /* this happens when a disk is removed from the configuration file */ 1248 : /* From SnapRAID 4.0 mappings are automatically removed if a disk is not used */ 1249 : /* when saving the content file, but we keep this code to import older content files. */ - 1250 1832 : for (i = state->maplist; i != 0; ) { - 1251 1334 : struct snapraid_map* map = i->data; + 1250 1847 : for (i = state->maplist; i != 0; ) { + 1251 1345 : struct snapraid_map* map = i->data; 1252 : struct snapraid_disk* disk; 1253 : - 1254 1334 : disk = find_disk_by_name(state, map->name); + 1254 1345 : disk = find_disk_by_name(state, map->name); 1255 : 1256 : /* go to the next mapping before removing */ - 1257 1334 : i = i->next; + 1257 1345 : i = i->next; 1258 : - 1259 1334 : if (disk == 0) { + 1259 1345 : if (disk == 0) { 1260 : /* disk not found, remove the mapping */ 1261 0 : tommy_list_remove_existing(&state->maplist, &map->node); 1262 0 : map_free(map); @@ -1327,116 +1327,116 @@ 1265 : 1266 : /* maps each unmapped disk present in the configuration file in the first available hole */ 1267 : /* this happens when you add disks for the first time in the configuration file */ - 1268 249 : hole = 0; /* first position to try */ - 1269 1738 : for (i = state->disklist; i != 0; i = i->next) { - 1270 1489 : struct snapraid_disk* disk = i->data; + 1268 251 : hole = 0; /* first position to try */ + 1269 1752 : for (i = state->disklist; i != 0; i = i->next) { + 1270 1501 : struct snapraid_disk* disk = i->data; 1271 : struct snapraid_map* map; 1272 : tommy_node* j; 1273 : 1274 : /* check if the disk is already mapped */ - 1275 5199 : for (j = state->maplist; j != 0; j = j->next) { - 1276 5044 : map = j->data; - 1277 5044 : if (strcmp(disk->name, map->name) == 0) { + 1275 5241 : for (j = state->maplist; j != 0; j = j->next) { + 1276 5085 : map = j->data; + 1277 5085 : if (strcmp(disk->name, map->name) == 0) { 1278 : /* mapping found */ - 1279 1334 : break; + 1279 1345 : break; 1280 : } 1281 : } - 1282 1489 : if (j != 0) { + 1282 1501 : if (j != 0) { 1283 : /* mapping is present, then copy the free blocks into to disk */ - 1284 1334 : disk->total_blocks = map->total_blocks; - 1285 1334 : disk->free_blocks = map->free_blocks; - 1286 1334 : continue; + 1284 1345 : disk->total_blocks = map->total_blocks; + 1285 1345 : disk->free_blocks = map->free_blocks; + 1286 1345 : continue; 1287 : } 1288 : 1289 : /* mapping not found, search for an hole */ 1290 : while (1) { - 1291 1025 : for (j = state->maplist; j != 0; j = j->next) { - 1292 870 : map = j->data; - 1293 870 : if (map->position == hole) { + 1291 1060 : for (j = state->maplist; j != 0; j = j->next) { + 1292 904 : map = j->data; + 1293 904 : if (map->position == hole) { 1294 : /* position already used */ - 1295 144 : break; + 1295 150 : break; 1296 : } 1297 : } - 1298 299 : if (j == 0) { + 1298 306 : if (j == 0) { 1299 : /* hole found */ - 1300 155 : break; + 1300 156 : break; 1301 : } 1302 : 1303 : /* try with the next one */ - 1304 144 : ++hole; - 1305 144 : } + 1304 150 : ++hole; + 1305 150 : } 1306 : 1307 : /* insert the new mapping */ - 1308 155 : map = map_alloc(disk->name, hole, 0, 0, ""); + 1308 156 : map = map_alloc(disk->name, hole, 0, 0, ""); 1309 : - 1310 155 : tommy_list_insert_tail(&state->maplist, &map->node, map); + 1310 156 : tommy_list_insert_tail(&state->maplist, &map->node, map); 1311 : } 1312 : 1313 : /* without configuration don't check for number of data disks or uuid changes */ - 1314 249 : if (state->no_conf) - 1315 250 : return; + 1314 251 : if (state->no_conf) + 1315 252 : return; 1316 : 1317 : /* counter for the number of UUID mismatches */ - 1318 248 : uuid_mismatch = 0; + 1318 250 : uuid_mismatch = 0; 1319 : 1320 : /* check if mapping match the disk uuid */ - 1321 248 : if (!state->opt.skip_disk_access) { - 1322 1570 : for (i = state->maplist; i != 0; i = i->next) { - 1323 1345 : struct snapraid_map* map = i->data; + 1321 250 : if (!state->opt.skip_disk_access) { + 1322 1584 : for (i = state->maplist; i != 0; i = i->next) { + 1323 1357 : struct snapraid_map* map = i->data; 1324 : struct snapraid_disk* disk; 1325 : - 1326 1345 : disk = find_disk_by_name(state, map->name); - 1327 1345 : if (disk == 0) { + 1326 1357 : disk = find_disk_by_name(state, map->name); + 1327 1357 : if (disk == 0) { 1328 : /* LCOV_EXCL_START */ 1329 : log_fatal("Internal inconsistency for mapping '%s'\n", map->name); 1330 : os_abort(); 1331 : /* LCOV_EXCL_STOP */ 1332 : } 1333 : - 1334 1345 : if (disk->has_unsupported_uuid) { + 1334 1357 : if (disk->has_unsupported_uuid) { 1335 : /* if uuid is not available, skip this one */ 1336 1 : continue; 1337 : } 1338 : 1339 : /* if the uuid is changed */ - 1340 1344 : if (strcmp(disk->uuid, map->uuid) != 0) { + 1340 1356 : if (strcmp(disk->uuid, map->uuid) != 0) { 1341 : /* mark the disk as with an UUID change */ - 1342 109 : disk->has_different_uuid = 1; + 1342 112 : disk->has_different_uuid = 1; 1343 : 1344 : /* if the previous uuid is available */ - 1345 109 : if (map->uuid[0] != 0) { + 1345 112 : if (map->uuid[0] != 0) { 1346 : /* count the number of uuid change */ - 1347 2 : ++uuid_mismatch; - 1348 2 : log_fatal("UUID change for disk '%s' from '%s' to '%s'\n", disk->name, map->uuid, disk->uuid); + 1347 4 : ++uuid_mismatch; + 1348 4 : log_fatal("UUID change for disk '%s' from '%s' to '%s'\n", disk->name, map->uuid, disk->uuid); 1349 : } else { 1350 : /* no message here, because having a disk without */ 1351 : /* UUID is the normal state of an empty disk */ - 1352 107 : disk->had_empty_uuid = 1; + 1352 108 : disk->had_empty_uuid = 1; 1353 : } 1354 : 1355 : /* update the uuid in the mapping, */ - 1356 109 : pathcpy(map->uuid, sizeof(map->uuid), disk->uuid); + 1356 112 : pathcpy(map->uuid, sizeof(map->uuid), disk->uuid); 1357 : 1358 : /* write the new state with the new uuid */ - 1359 109 : state->need_write = 1; + 1359 112 : state->need_write = 1; 1360 : } 1361 : } 1362 : } 1363 : 1364 : /* check the parity uuid */ - 1365 248 : if (!state->opt.skip_parity_access) { - 1366 1244 : for (l = 0; l < state->level; ++l) { + 1365 250 : if (!state->opt.skip_parity_access) { + 1366 1258 : for (l = 0; l < state->level; ++l) { 1367 : char uuid[UUID_MAX]; 1368 : int ret; 1369 : - 1370 1030 : ret = devuuid(state->parity[l].device, uuid, sizeof(uuid)); - 1371 1030 : if (ret != 0) { + 1370 1042 : ret = devuuid(state->parity[l].device, uuid, sizeof(uuid)); + 1371 1042 : if (ret != 0) { 1372 : /* uuid not available, just ignore */ 1373 1 : continue; 1374 : } 1375 : 1376 : /* if the uuid is changed */ - 1377 1029 : if (strcmp(uuid, state->parity[l].uuid) != 0) { + 1377 1041 : if (strcmp(uuid, state->parity[l].uuid) != 0) { 1378 : /* if the previous uuid is available */ 1379 46 : if (state->parity[l].uuid[0] != 0) { 1380 : /* count the number of uuid change */ @@ -1453,7 +1453,7 @@ 1391 : } 1392 : } 1393 : - 1394 248 : if (!state->opt.force_uuid && uuid_mismatch > state->level) { + 1394 250 : if (!state->opt.force_uuid && uuid_mismatch > state->level) { 1395 : /* LCOV_EXCL_START */ 1396 : log_fatal("Too many disks have UUID changed from the latest 'sync'.\n"); 1397 : log_fatal("If this happens because you really replaced them,\n"); @@ -1465,16 +1465,16 @@ 1403 : } 1404 : 1405 : /* count the number of data disks, including holes left after removing some */ - 1406 248 : diskcount = 0; - 1407 1731 : for (i = state->maplist; i != 0; i = i->next) { - 1408 1483 : struct snapraid_map* map = i->data; + 1406 250 : diskcount = 0; + 1407 1745 : for (i = state->maplist; i != 0; i = i->next) { + 1408 1495 : struct snapraid_map* map = i->data; 1409 : - 1410 1483 : if (map->position + 1 > diskcount) - 1411 1339 : diskcount = map->position + 1; + 1410 1495 : if (map->position + 1 > diskcount) + 1411 1323 : diskcount = map->position + 1; 1412 : } 1413 : 1414 : /* ensure to don't go over the limit of the RAID engine */ - 1415 248 : if (diskcount > RAID_DATA_MAX) { + 1415 250 : if (diskcount > RAID_DATA_MAX) { 1416 : /* LCOV_EXCL_START */ 1417 : log_fatal("Too many data disks. No more than %u.\n", RAID_DATA_MAX); 1418 : exit(EXIT_FAILURE); @@ -1482,47 +1482,47 @@ 1420 : } 1421 : 1422 : /* now count the real number of data disks, excluding holes left after removing some */ - 1423 248 : diskcount = tommy_list_count(&state->maplist); + 1423 250 : diskcount = tommy_list_count(&state->maplist); 1424 : 1425 : /* recommend number of parities */ - 1426 248 : if (!state->opt.no_warnings) { - 1427 248 : if (diskcount >= 36 && state->level < 6) { + 1426 250 : if (!state->opt.no_warnings) { + 1427 250 : if (diskcount >= 36 && state->level < 6) { 1428 0 : log_fatal("WARNING! With %u disks it's recommended to use six parity levels.\n", diskcount); - 1429 248 : } else if (diskcount >= 29 && state->level < 5) { + 1429 250 : } else if (diskcount >= 29 && state->level < 5) { 1430 0 : log_fatal("WARNING! With %u disks it's recommended to use five parity levels.\n", diskcount); - 1431 248 : } else if (diskcount >= 22 && state->level < 4) { + 1431 250 : } else if (diskcount >= 22 && state->level < 4) { 1432 0 : log_fatal("WARNING! With %u disks it's recommended to use four parity levels.\n", diskcount); - 1433 248 : } else if (diskcount >= 15 && state->level < 3) { + 1433 250 : } else if (diskcount >= 15 && state->level < 3) { 1434 0 : log_fatal("WARNING! With %u disks it's recommended to use three parity levels.\n", diskcount); - 1435 248 : } else if (diskcount >= 5 && state->level < 2) { + 1435 250 : } else if (diskcount >= 5 && state->level < 2) { 1436 34 : log_fatal("WARNING! With %u disks it's recommended to use two parity levels.\n", diskcount); 1437 : } 1438 : } 1439 : } 1440 : - 1441 160 : void state_refresh(struct snapraid_state* state) + 1441 164 : void state_refresh(struct snapraid_state* state) 1442 : { 1443 : tommy_node* i; 1444 : unsigned l; 1445 : 1446 : /* for all disks */ - 1447 1118 : for (i = state->maplist; i != 0; i = i->next) { - 1448 958 : struct snapraid_map* map = i->data; + 1447 1146 : for (i = state->maplist; i != 0; i = i->next) { + 1448 982 : struct snapraid_map* map = i->data; 1449 : struct snapraid_disk* disk; 1450 : uint64_t total_space; 1451 : uint64_t free_space; 1452 : int ret; 1453 : - 1454 958 : disk = find_disk_by_name(state, map->name); - 1455 958 : if (disk == 0) { + 1454 982 : disk = find_disk_by_name(state, map->name); + 1455 982 : if (disk == 0) { 1456 : /* LCOV_EXCL_START */ 1457 : log_fatal("Internal inconsistency for mapping '%s'\n", map->name); 1458 : os_abort(); 1459 : /* LCOV_EXCL_STOP */ 1460 : } 1461 : - 1462 958 : ret = fsinfo(disk->dir, 0, &total_space, &free_space); - 1463 958 : if (ret != 0) { + 1462 982 : ret = fsinfo(disk->dir, 0, &total_space, &free_space); + 1463 982 : if (ret != 0) { 1464 : /* LCOV_EXCL_START */ 1465 : log_fatal("Error accessing disk '%s' to get file-system info. %s.\n", disk->dir, strerror(errno)); 1466 : exit(EXIT_FAILURE); @@ -1530,22 +1530,22 @@ 1468 : } 1469 : 1470 : /* set the new free blocks */ - 1471 958 : map->total_blocks = total_space / state->block_size; - 1472 958 : map->free_blocks = free_space / state->block_size; + 1471 982 : map->total_blocks = total_space / state->block_size; + 1472 982 : map->free_blocks = free_space / state->block_size; 1473 : 1474 : /* also update the disk info */ - 1475 958 : disk->total_blocks = map->total_blocks; - 1476 958 : disk->free_blocks = map->free_blocks; + 1475 982 : disk->total_blocks = map->total_blocks; + 1476 982 : disk->free_blocks = map->free_blocks; 1477 : } 1478 : 1479 : /* for all parities */ - 1480 1090 : for (l = 0; l < state->level; ++l) { + 1480 1118 : for (l = 0; l < state->level; ++l) { 1481 : uint64_t total_space; 1482 : uint64_t free_space; 1483 : int ret; 1484 : - 1485 930 : ret = fsinfo(state->parity[l].path, 0, &total_space, &free_space); - 1486 930 : if (ret != 0) { + 1485 954 : ret = fsinfo(state->parity[l].path, 0, &total_space, &free_space); + 1486 954 : if (ret != 0) { 1487 : /* LCOV_EXCL_START */ 1488 : log_fatal("Error accessing file '%s' to get file-system info. %s.\n", state->parity[l].path, strerror(errno)); 1489 : exit(EXIT_FAILURE); @@ -1553,34 +1553,34 @@ 1491 : } 1492 : 1493 : /* set the new free blocks */ - 1494 930 : state->parity[l].total_blocks = total_space / state->block_size; - 1495 930 : state->parity[l].free_blocks = free_space / state->block_size; + 1494 954 : state->parity[l].total_blocks = total_space / state->block_size; + 1495 954 : state->parity[l].free_blocks = free_space / state->block_size; 1496 : } 1497 : 1498 : /* note what we don't set need_write = 1, because we don't want */ 1499 : /* to update the content file only for the free space info. */ - 1500 160 : } + 1500 164 : } 1501 : 1502 : /** 1503 : * Check the content. 1504 : */ - 1505 242 : static void state_content_check(struct snapraid_state* state, const char* path) + 1505 244 : static void state_content_check(struct snapraid_state* state, const char* path) 1506 : { 1507 : tommy_node* i; 1508 : 1509 : /* check that any map has different name and position */ - 1510 1689 : for (i = state->maplist; i != 0; i = i->next) { - 1511 1447 : struct snapraid_map* map = i->data; + 1510 1703 : for (i = state->maplist; i != 0; i = i->next) { + 1511 1459 : struct snapraid_map* map = i->data; 1512 : tommy_node* j; - 1513 5052 : for (j = i->next; j != 0; j = j->next) { - 1514 3605 : struct snapraid_map* other = j->data; - 1515 3605 : if (strcmp(map->name, other->name) == 0) { + 1513 5094 : for (j = i->next; j != 0; j = j->next) { + 1514 3635 : struct snapraid_map* other = j->data; + 1515 3635 : if (strcmp(map->name, other->name) == 0) { 1516 : /* LCOV_EXCL_START */ 1517 : log_fatal("Colliding 'map' disk specification in '%s'\n", path); 1518 : exit(EXIT_FAILURE); 1519 : /* LCOV_EXCL_STOP */ 1520 : } - 1521 3605 : if (map->position == other->position) { + 1521 3635 : if (map->position == other->position) { 1522 : /* LCOV_EXCL_START */ 1523 : log_fatal("Colliding 'map' index specification in '%s'\n", path); 1524 : exit(EXIT_FAILURE); @@ -1588,25 +1588,25 @@ 1526 : } 1527 : } 1528 : } - 1529 242 : } + 1529 244 : } 1530 : 1531 : /** 1532 : * Check if the position is REQUIRED, or we can completely clear it from the state. 1533 : * 1534 : * Note that position with only DELETED blocks are discarged. 1535 : */ - 1536 752491 : static int fs_position_is_required(struct snapraid_state* state, block_off_t pos) + 1536 746566 : static int fs_position_is_required(struct snapraid_state* state, block_off_t pos) 1537 : { 1538 : tommy_node* i; 1539 : 1540 : /* check for each disk */ - 1541 797220 : for (i = state->disklist; i != 0; i = i->next) { - 1542 797220 : struct snapraid_disk* disk = i->data; - 1543 797220 : struct snapraid_block* block = fs_par2block_get(disk, pos); + 1541 792984 : for (i = state->disklist; i != 0; i = i->next) { + 1542 792984 : struct snapraid_disk* disk = i->data; + 1543 792984 : struct snapraid_block* block = fs_par2block_get(disk, pos); 1544 : 1545 : /* if we have at least one file, the position is needed */ - 1546 797220 : if (block_has_file(block)) - 1547 752491 : return 1; + 1546 792984 : if (block_has_file(block)) + 1547 746566 : return 1; 1548 : } 1549 : 1550 0 : return 0; @@ -1624,21 +1624,21 @@ 1562 : * Note also that not requiring an info block, doesn't mean that if present it 1563 : * can be discarded. 1564 : */ - 1565 1513218 : static int fs_info_is_required(struct snapraid_state* state, block_off_t pos) + 1565 1515002 : static int fs_info_is_required(struct snapraid_state* state, block_off_t pos) 1566 : { 1567 : tommy_node* i; 1568 : 1569 : /* check for each disk */ - 1570 2062203 : for (i = state->disklist; i != 0; i = i->next) { - 1571 1994271 : struct snapraid_disk* disk = i->data; - 1572 1994271 : struct snapraid_block* block = fs_par2block_get(disk, pos); + 1570 2068422 : for (i = state->disklist; i != 0; i = i->next) { + 1571 2000506 : struct snapraid_disk* disk = i->data; + 1572 2000506 : struct snapraid_block* block = fs_par2block_get(disk, pos); 1573 : 1574 : /* if we have at least one synced file, the info is required */ - 1575 1994271 : if (block_state_get(block) == BLOCK_STATE_BLK) - 1576 1445286 : return 1; + 1575 2000506 : if (block_state_get(block) == BLOCK_STATE_BLK) + 1576 1447086 : return 1; 1577 : } 1578 : - 1579 67932 : return 0; + 1579 67916 : return 0; 1580 : } 1581 : 1582 0 : static void fs_position_clear_deleted(struct snapraid_state* state, block_off_t pos) @@ -1661,11 +1661,11 @@ 1599 : /** 1600 : * Check if a block position in a disk is deleted. 1601 : */ - 1602 4507856 : static int fs_is_block_deleted_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t pos) + 1602 4472427 : static int fs_is_block_deleted_ts(struct snapraid_disk* disk, struct snapraid_chunk** fs_last, block_off_t pos) 1603 : { - 1604 4507856 : struct snapraid_block* block = fs_par2block_get_ts(disk, fs_last, pos); + 1604 4472427 : struct snapraid_block* block = fs_par2block_get_ts(disk, fs_last, pos); 1605 : - 1606 4507856 : return block_state_get(block) == BLOCK_STATE_DELETED; + 1606 4472427 : return block_state_get(block) == BLOCK_STATE_DELETED; 1607 : } 1608 : 1609 : /** @@ -1720,7 +1720,7 @@ 1658 : } 1659 0 : } 1660 : - 1661 243 : static void state_read_content(struct snapraid_state* state, const char* path, STREAM* f) + 1661 245 : static void state_read_content(struct snapraid_state* state, const char* path, STREAM* f) 1662 : { 1663 : block_off_t blockmax; 1664 : unsigned count_file; @@ -1733,17 +1733,17 @@ 1671 : tommy_array disk_mapping; 1672 : uint32_t mapping_max; 1673 : - 1674 243 : blockmax = 0; - 1675 243 : count_file = 0; - 1676 243 : count_hardlink = 0; - 1677 243 : count_symlink = 0; - 1678 243 : count_dir = 0; - 1679 243 : crc_checked = 0; - 1680 243 : mapping_max = 0; - 1681 243 : tommy_array_init(&disk_mapping); + 1674 245 : blockmax = 0; + 1675 245 : count_file = 0; + 1676 245 : count_hardlink = 0; + 1677 245 : count_symlink = 0; + 1678 245 : count_dir = 0; + 1679 245 : crc_checked = 0; + 1680 245 : mapping_max = 0; + 1681 245 : tommy_array_init(&disk_mapping); 1682 : - 1683 243 : ret = sread(f, buffer, 12); - 1684 243 : if (ret < 0) { + 1683 245 : ret = sread(f, buffer, 12); + 1684 245 : if (ret < 0) { 1685 : /* LCOV_EXCL_START */ 1686 : decoding_error(path, f); 1687 : log_fatal("Invalid header!\n"); @@ -1758,8 +1758,8 @@ 1696 : * The previous 'm' entry is now deprecated, but supported for importing. 1697 : * Similarly for text file, we add 'mapping' and 'parity' deprecating 'map'. 1698 : */ - 1699 243 : if (memcmp(buffer, "SNAPCNT1\n\3\0\0", 12) != 0 - 1700 243 : && memcmp(buffer, "SNAPCNT2\n\3\0\0", 12) != 0) { + 1699 245 : if (memcmp(buffer, "SNAPCNT1\n\3\0\0", 12) != 0 + 1700 245 : && memcmp(buffer, "SNAPCNT2\n\3\0\0", 12) != 0) { 1701 : /* LCOV_EXCL_START */ 1702 : if (memcmp(buffer, "SNAPCNT", 7) != 0) { 1703 : decoding_error(path, f); @@ -1776,12 +1776,12 @@ 1714 : int c; 1715 : 1716 : /* read the command */ - 1717 3653019 : c = sgetc(f); - 1718 3653019 : if (c == EOF) { - 1719 242 : break; + 1717 3653695 : c = sgetc(f); + 1718 3653695 : if (c == EOF) { + 1719 244 : break; 1720 : } 1721 : - 1722 3652777 : if (c == 'f') { + 1722 3653451 : if (c == 'f') { 1723 : /* file */ 1724 : char sub[PATH_MAX]; 1725 : uint64_t v_size; @@ -1793,18 +1793,18 @@ 1731 : struct snapraid_disk* disk; 1732 : uint32_t mapping; 1733 : - 1734 3532322 : ret = sgetb32(f, &mapping); - 1735 3532322 : if (ret < 0 || mapping >= mapping_max) { + 1734 3532951 : ret = sgetb32(f, &mapping); + 1735 3532951 : if (ret < 0 || mapping >= mapping_max) { 1736 : /* LCOV_EXCL_START */ 1737 : decoding_error(path, f); 1738 : log_fatal("Internal inconsistency in mapping index!\n"); 1739 : os_abort(); 1740 : /* LCOV_EXCL_STOP */ 1741 : } - 1742 3532322 : disk = tommy_array_get(&disk_mapping, mapping); + 1742 3532951 : disk = tommy_array_get(&disk_mapping, mapping); 1743 : - 1744 3532322 : ret = sgetb64(f, &v_size); - 1745 3532322 : if (ret < 0) { + 1744 3532951 : ret = sgetb64(f, &v_size); + 1745 3532951 : if (ret < 0) { 1746 : /* LCOV_EXCL_START */ 1747 : decoding_error(path, f); 1748 : os_abort(); @@ -1812,7 +1812,7 @@ 1750 : } 1751 : 1752 : /* check for impossible file size to avoid to crash for a too big allocation */ - 1753 3532322 : if (v_size / state->block_size > blockmax) { + 1753 3532951 : if (v_size / state->block_size > blockmax) { 1754 : /* LCOV_EXCL_START */ 1755 : decoding_error(path, f); 1756 : log_fatal("Internal inconsistency in file size too big!\n"); @@ -1820,16 +1820,16 @@ 1758 : /* LCOV_EXCL_STOP */ 1759 : } 1760 : - 1761 3532322 : ret = sgetb64(f, &v_mtime_sec); - 1762 3532322 : if (ret < 0) { + 1761 3532951 : ret = sgetb64(f, &v_mtime_sec); + 1762 3532951 : if (ret < 0) { 1763 : /* LCOV_EXCL_START */ 1764 : decoding_error(path, f); 1765 : os_abort(); 1766 : /* LCOV_EXCL_STOP */ 1767 : } 1768 : - 1769 3532322 : ret = sgetb32(f, &v_mtime_nsec); - 1770 3532322 : if (ret < 0) { + 1769 3532951 : ret = sgetb32(f, &v_mtime_nsec); + 1770 3532951 : if (ret < 0) { 1771 : /* LCOV_EXCL_START */ 1772 : decoding_error(path, f); 1773 : os_abort(); @@ -1837,27 +1837,27 @@ 1775 : } 1776 : 1777 : /* STAT_NSEC_INVALID is encoded as 0 */ - 1778 3532322 : if (v_mtime_nsec == 0) + 1778 3532951 : if (v_mtime_nsec == 0) 1779 0 : v_mtime_nsec = STAT_NSEC_INVALID; 1780 : else - 1781 3532322 : --v_mtime_nsec; + 1781 3532951 : --v_mtime_nsec; 1782 : - 1783 3532322 : ret = sgetb64(f, &v_inode); - 1784 3532322 : if (ret < 0) { + 1783 3532951 : ret = sgetb64(f, &v_inode); + 1784 3532951 : if (ret < 0) { 1785 : /* LCOV_EXCL_START */ 1786 : decoding_error(path, f); 1787 : os_abort(); 1788 : /* LCOV_EXCL_STOP */ 1789 : } 1790 : - 1791 3532322 : ret = sgetbs(f, sub, sizeof(sub)); - 1792 3532322 : if (ret < 0) { + 1791 3532951 : ret = sgetbs(f, sub, sizeof(sub)); + 1792 3532951 : if (ret < 0) { 1793 : /* LCOV_EXCL_START */ 1794 : decoding_error(path, f); 1795 : os_abort(); 1796 : /* LCOV_EXCL_STOP */ 1797 : } - 1798 3532321 : if (!*sub) { + 1798 3532951 : if (!*sub) { 1799 : /* LCOV_EXCL_START */ 1800 : decoding_error(path, f); 1801 : log_fatal("Internal inconsistency for null file!\n"); @@ -1866,40 +1866,40 @@ 1804 : } 1805 : 1806 : /* allocate the file */ - 1807 3532321 : file = file_alloc(state->block_size, sub, v_size, v_mtime_sec, v_mtime_nsec, v_inode, 0); + 1807 3532951 : file = file_alloc(state->block_size, sub, v_size, v_mtime_sec, v_mtime_nsec, v_inode, 0); 1808 : 1809 : /* insert the file in the file containers */ - 1810 3532321 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); - 1811 3532321 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); - 1812 3532321 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); - 1813 3532321 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); + 1810 3532951 : tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode)); + 1811 3532951 : tommy_hashdyn_insert(&disk->pathset, &file->pathset, file, file_path_hash(file->sub)); + 1812 3532951 : tommy_hashdyn_insert(&disk->stampset, &file->stampset, file, file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec)); + 1813 3532951 : tommy_list_insert_tail(&disk->filelist, &file->nodelist, file); 1814 : 1815 : /* read all the blocks */ - 1816 3532321 : v_idx = 0; - 1817 10617218 : while (v_idx < file->blockmax) { + 1816 3532951 : v_idx = 0; + 1817 10619094 : while (v_idx < file->blockmax) { 1818 : block_off_t v_pos; 1819 : uint32_t v_count; 1820 : 1821 : /* get the "subcommand */ - 1822 3552576 : c = sgetc(f); + 1822 3553192 : c = sgetc(f); 1823 : - 1824 3552576 : ret = sgetb32(f, &v_pos); - 1825 3552576 : if (ret < 0) { + 1824 3553192 : ret = sgetb32(f, &v_pos); + 1825 3553192 : if (ret < 0) { 1826 : /* LCOV_EXCL_START */ 1827 : decoding_error(path, f); 1828 : os_abort(); 1829 : /* LCOV_EXCL_STOP */ 1830 : } 1831 : - 1832 3552576 : ret = sgetb32(f, &v_count); - 1833 3552576 : if (ret < 0) { + 1832 3553192 : ret = sgetb32(f, &v_count); + 1833 3553192 : if (ret < 0) { 1834 : /* LCOV_EXCL_START */ 1835 : decoding_error(path, f); 1836 : os_abort(); 1837 : /* LCOV_EXCL_STOP */ 1838 : } 1839 : - 1840 3552576 : if (v_idx + v_count > file->blockmax) { + 1840 3553192 : if (v_idx + v_count > file->blockmax) { 1841 : /* LCOV_EXCL_START */ 1842 : decoding_error(path, f); 1843 : log_fatal("Internal inconsistency in block number!\n"); @@ -1907,7 +1907,7 @@ 1845 : /* LCOV_EXCL_STOP */ 1846 : } 1847 : - 1848 3552576 : if (v_pos + v_count > blockmax) { + 1848 3553192 : if (v_pos + v_count > blockmax) { 1849 : /* LCOV_EXCL_START */ 1850 : decoding_error(path, f); 1851 : log_fatal("Internal inconsistency in block size %u/%u!\n", blockmax, v_pos + v_count); @@ -1942,9 +1942,9 @@ 1880 : } 1881 : 1882 : /* read the hash only for 'blk/chg/rep', and not for 'new' */ - 1883 8696195 : if (c != 'n') { - 1884 8696195 : ret = sread(f, block->hash, HASH_SIZE); - 1885 8696195 : if (ret < 0) { + 1883 8701477 : if (c != 'n') { + 1884 8701477 : ret = sread(f, block->hash, HASH_SIZE); + 1885 8701477 : if (ret < 0) { 1886 : /* LCOV_EXCL_START */ 1887 : decoding_error(path, f); 1888 : os_abort(); @@ -1957,8 +1957,8 @@ 1895 : 1896 : /* if the block contains a hash of past data */ 1897 : /* and we are clearing such undeterminated hashes */ - 1898 8696195 : if (state->clear_past_hash - 1899 2401624 : && block_has_past_hash(block) + 1898 8701477 : if (state->clear_past_hash + 1899 2403226 : && block_has_past_hash(block) 1900 : ) { 1901 : /* set the hash value to INVALID */ 1902 28006 : hash_invalid_set(block->hash); @@ -1969,9 +1969,9 @@ 1907 : /* in other sync commands */ 1908 : /* note that this is required only in sync, and we detect */ 1909 : /* this using the clear_past_hash flag */ - 1910 8696195 : if (state->clear_past_hash - 1911 2401624 : && state->opt.force_nocopy - 1912 14171 : && block_state_get(block) == BLOCK_STATE_REP + 1910 8701477 : if (state->clear_past_hash + 1911 2403226 : && state->opt.force_nocopy + 1912 14195 : && block_state_get(block) == BLOCK_STATE_REP 1913 : ) { 1914 : /* set the hash value to INVALID */ 1915 1 : hash_invalid_set(block->hash); @@ -1982,40 +1982,40 @@ 1920 : /* if we want a full sync, marks block as invalid parity */ 1921 : /* note that we do this after the force_nocopy option */ 1922 : /* to avoid to mixup the two things */ - 1923 8696195 : if (state->opt.force_full - 1924 82268 : && block_state_get(block) == BLOCK_STATE_BLK) { + 1923 8701477 : if (state->opt.force_full + 1924 82316 : && block_state_get(block) == BLOCK_STATE_BLK) { 1925 : /* convert from BLK to REP */ - 1926 82268 : block_state_set(block, BLOCK_STATE_REP); + 1926 82316 : block_state_set(block, BLOCK_STATE_REP); 1927 : } 1928 : 1929 : /* set the parity association */ - 1930 8696195 : fs_allocate(disk, v_pos, file, v_idx); + 1930 8701477 : fs_allocate(disk, v_pos, file, v_idx); 1931 : 1932 : /* go to the next block */ - 1933 8696195 : ++v_idx; - 1934 8696195 : ++v_pos; - 1935 8696195 : --v_count; + 1933 8701477 : ++v_idx; + 1934 8701477 : ++v_pos; + 1935 8701477 : --v_count; 1936 : } 1937 : } 1938 : 1939 : /* stat */ - 1940 3532321 : ++count_file; - 1941 120455 : } else if (c == 'i') { + 1940 3532951 : ++count_file; + 1941 120500 : } else if (c == 'i') { 1942 : /* "inf" command */ 1943 : snapraid_info info; 1944 : uint32_t v_pos; 1945 : uint32_t v_oldest; 1946 : - 1947 242 : ret = sgetb32(f, &v_oldest); - 1948 242 : if (ret < 0) { + 1947 244 : ret = sgetb32(f, &v_oldest); + 1948 244 : if (ret < 0) { 1949 : /* LCOV_EXCL_START */ 1950 : decoding_error(path, f); 1951 : os_abort(); 1952 : /* LCOV_EXCL_STOP */ 1953 : } 1954 : - 1955 242 : v_pos = 0; - 1956 59307 : while (v_pos < blockmax) { + 1955 244 : v_pos = 0; + 1956 59310 : while (v_pos < blockmax) { 1957 : int bad; 1958 : int rehash; 1959 : int justsynced; @@ -2023,15 +2023,15 @@ 1961 : uint32_t flag; 1962 : uint32_t v_count; 1963 : - 1964 58823 : ret = sgetb32(f, &v_count); - 1965 58823 : if (ret < 0) { + 1964 58822 : ret = sgetb32(f, &v_count); + 1965 58822 : if (ret < 0) { 1966 : /* LCOV_EXCL_START */ 1967 : decoding_error(path, f); 1968 : os_abort(); 1969 : /* LCOV_EXCL_STOP */ 1970 : } 1971 : - 1972 58823 : if (v_pos + v_count > blockmax) { + 1972 58822 : if (v_pos + v_count > blockmax) { 1973 : /* LCOV_EXCL_START */ 1974 : decoding_error(path, f); 1975 : log_fatal("Internal inconsistency in info size %u/%u!\n", blockmax, v_pos + v_count); @@ -2039,8 +2039,8 @@ 1977 : /* LCOV_EXCL_STOP */ 1978 : } 1979 : - 1980 58823 : ret = sgetb32(f, &flag); - 1981 58823 : if (ret < 0) { + 1980 58822 : ret = sgetb32(f, &flag); + 1981 58822 : if (ret < 0) { 1982 : /* LCOV_EXCL_START */ 1983 : decoding_error(path, f); 1984 : os_abort(); @@ -2048,10 +2048,10 @@ 1986 : } 1987 : 1988 : /* if there is an info */ - 1989 58823 : if ((flag & 1) != 0) { + 1989 58822 : if ((flag & 1) != 0) { 1990 : /* read the time */ - 1991 58808 : ret = sgetb32(f, &t); - 1992 58808 : if (ret < 0) { + 1991 58807 : ret = sgetb32(f, &t); + 1992 58807 : if (ret < 0) { 1993 : /* LCOV_EXCL_START */ 1994 : decoding_error(path, f); 1995 : os_abort(); @@ -2059,11 +2059,11 @@ 1997 : } 1998 : 1999 : /* analyze the flags */ - 2000 58808 : bad = (flag & 2) != 0; - 2001 58808 : rehash = (flag & 4) != 0; - 2002 58808 : justsynced = (flag & 8) != 0; + 2000 58807 : bad = (flag & 2) != 0; + 2001 58807 : rehash = (flag & 4) != 0; + 2002 58807 : justsynced = (flag & 8) != 0; 2003 : - 2004 58808 : if (rehash && state->prevhash == HASH_UNDEFINED) { + 2004 58807 : if (rehash && state->prevhash == HASH_UNDEFINED) { 2005 : /* LCOV_EXCL_START */ 2006 : decoding_error(path, f); 2007 : log_fatal("Internal inconsistency for missing previous checksum!\n"); @@ -2071,18 +2071,18 @@ 2009 : /* LCOV_EXCL_STOP */ 2010 : } 2011 : - 2012 58808 : info = info_make(t + v_oldest, bad, rehash, justsynced); + 2012 58807 : info = info_make(t + v_oldest, bad, rehash, justsynced); 2013 : } else { 2014 15 : info = 0; 2015 : } 2016 : - 2017 1630864 : while (v_count) { + 2017 1632646 : while (v_count) { 2018 : /* insert the info in the array */ - 2019 1513218 : info_set(&state->infoarr, v_pos, info); + 2019 1515002 : info_set(&state->infoarr, v_pos, info); 2020 : 2021 : /* ensure that an info is present only for used positions */ - 2022 1513218 : if (fs_info_is_required(state, v_pos)) { - 2023 1445286 : if (!info) { + 2022 1515002 : if (fs_info_is_required(state, v_pos)) { + 2023 1447086 : if (!info) { 2024 : /* LCOV_EXCL_START */ 2025 : decoding_error(path, f); 2026 : log_fatal("Internal inconsistency for missing info!\n"); @@ -2095,41 +2095,41 @@ 2033 : } 2034 : 2035 : /* go to next block */ - 2036 1513218 : ++v_pos; - 2037 1513218 : --v_count; + 2036 1515002 : ++v_pos; + 2037 1515002 : --v_count; 2038 : } 2039 : } - 2040 120213 : } else if (c == 'h') { + 2040 120256 : } else if (c == 'h') { 2041 : /* hole */ 2042 : uint32_t v_pos; 2043 : struct snapraid_disk* disk; 2044 : uint32_t mapping; 2045 : - 2046 1334 : ret = sgetb32(f, &mapping); - 2047 1334 : if (ret < 0 || mapping >= mapping_max) { + 2046 1345 : ret = sgetb32(f, &mapping); + 2047 1345 : if (ret < 0 || mapping >= mapping_max) { 2048 : /* LCOV_EXCL_START */ 2049 : decoding_error(path, f); 2050 : log_fatal("Internal inconsistency in mapping index!\n"); 2051 : os_abort(); 2052 : /* LCOV_EXCL_STOP */ 2053 : } - 2054 1334 : disk = tommy_array_get(&disk_mapping, mapping); + 2054 1345 : disk = tommy_array_get(&disk_mapping, mapping); 2055 : - 2056 1334 : v_pos = 0; - 2057 4080 : while (v_pos < blockmax) { + 2056 1345 : v_pos = 0; + 2057 4113 : while (v_pos < blockmax) { 2058 : uint32_t v_idx; 2059 : uint32_t v_count; 2060 : struct snapraid_file* deleted; 2061 : - 2062 1412 : ret = sgetb32(f, &v_count); - 2063 1412 : if (ret < 0) { + 2062 1423 : ret = sgetb32(f, &v_count); + 2063 1423 : if (ret < 0) { 2064 : /* LCOV_EXCL_START */ 2065 : decoding_error(path, f); 2066 : os_abort(); 2067 : /* LCOV_EXCL_STOP */ 2068 : } 2069 : - 2070 1412 : if (v_pos + v_count > blockmax) { + 2070 1423 : if (v_pos + v_count > blockmax) { 2071 : /* LCOV_EXCL_START */ 2072 : decoding_error(path, f); 2073 : log_fatal("Internal inconsistency in hole size %u/%u!\n", blockmax, v_pos + v_count); @@ -2138,9 +2138,9 @@ 2076 : } 2077 : 2078 : /* get the sub-command */ - 2079 1412 : c = sgetc(f); + 2079 1423 : c = sgetc(f); 2080 : - 2081 1412 : switch (c) { + 2081 1423 : switch (c) { 2082 : case 'o' : 2083 : /* if it's a run of deleted blocks */ 2084 : @@ -2187,8 +2187,8 @@ 2125 41 : break; 2126 : case 'O' : 2127 : /* go to the next run */ - 2128 1371 : v_pos += v_count; - 2129 1371 : break; + 2128 1382 : v_pos += v_count; + 2129 1382 : break; 2130 : default : 2131 : /* LCOV_EXCL_START */ 2132 : decoding_error(path, f); @@ -2197,7 +2197,7 @@ 2135 : /* LCOV_EXCL_STOP */ 2136 : } 2137 : } - 2138 118879 : } else if (c == 's') { + 2138 118911 : } else if (c == 's') { 2139 : /* symlink */ 2140 : char sub[PATH_MAX]; 2141 : char linkto[PATH_MAX]; @@ -2248,7 +2248,7 @@ 2186 : 2187 : /* stat */ 2188 113843 : ++count_symlink; - 2189 5036 : } else if (c == 'a') { + 2189 5068 : } else if (c == 'a') { 2190 : /* hardlink */ 2191 : char sub[PATH_MAX]; 2192 : char linkto[PATH_MAX]; @@ -2307,7 +2307,7 @@ 2245 : 2246 : /* stat */ 2247 576 : ++count_hardlink; - 2248 4460 : } else if (c == 'r') { + 2248 4492 : } else if (c == 'r') { 2249 : /* dir */ 2250 : char sub[PATH_MAX]; 2251 : struct snapraid_dir* dir; @@ -2349,14 +2349,14 @@ 2287 : 2288 : /* stat */ 2289 762 : ++count_dir; - 2290 3698 : } else if (c == 'c') { + 2290 3730 : } else if (c == 'c') { 2291 : /* get the subcommand */ - 2292 243 : c = sgetc(f); + 2292 245 : c = sgetc(f); 2293 : - 2294 243 : switch (c) { + 2294 245 : switch (c) { 2295 : case 'u' : - 2296 155 : state->hash = HASH_MURMUR3; - 2297 155 : break; + 2296 157 : state->hash = HASH_MURMUR3; + 2297 157 : break; 2298 : case 'k' : 2299 88 : state->hash = HASH_SPOOKY2; 2300 88 : break; @@ -2369,14 +2369,14 @@ 2307 : } 2308 : 2309 : /* read the seed */ - 2310 243 : ret = sread(f, state->hashseed, HASH_SIZE); - 2311 243 : if (ret < 0) { + 2310 245 : ret = sread(f, state->hashseed, HASH_SIZE); + 2311 245 : if (ret < 0) { 2312 : /* LCOV_EXCL_START */ 2313 : decoding_error(path, f); 2314 : os_abort(); 2315 : /* LCOV_EXCL_STOP */ 2316 : } - 2317 3455 : } else if (c == 'C') { + 2317 3485 : } else if (c == 'C') { 2318 : /* get the sub-command */ 2319 4 : c = sgetc(f); 2320 : @@ -2403,11 +2403,11 @@ 2341 : os_abort(); 2342 : /* LCOV_EXCL_STOP */ 2343 : } - 2344 3451 : } else if (c == 'z') { + 2344 3481 : } else if (c == 'z') { 2345 : block_off_t blksize; 2346 : - 2347 243 : ret = sgetb32(f, &blksize); - 2348 243 : if (ret < 0) { + 2347 245 : ret = sgetb32(f, &blksize); + 2348 245 : if (ret < 0) { 2349 : /* LCOV_EXCL_START */ 2350 : decoding_error(path, f); 2351 : os_abort(); @@ -2415,11 +2415,11 @@ 2353 : } 2354 : 2355 : /* without configuration, auto assign the block size */ - 2356 243 : if (state->no_conf) { + 2356 245 : if (state->no_conf) { 2357 1 : state->block_size = blksize; 2358 : } 2359 : - 2360 243 : if (blksize != state->block_size) { + 2360 245 : if (blksize != state->block_size) { 2361 : /* LCOV_EXCL_START */ 2362 : decoding_error(path, f); 2363 : log_fatal("Mismatching 'blksize' and 'blocksize' specification!\n"); @@ -2427,15 +2427,15 @@ 2365 : exit(EXIT_FAILURE); 2366 : /* LCOV_EXCL_STOP */ 2367 : } - 2368 3208 : } else if (c == 'x') { - 2369 243 : ret = sgetb32(f, &blockmax); - 2370 243 : if (ret < 0) { + 2368 3236 : } else if (c == 'x') { + 2369 245 : ret = sgetb32(f, &blockmax); + 2370 245 : if (ret < 0) { 2371 : /* LCOV_EXCL_START */ 2372 : decoding_error(path, f); 2373 : os_abort(); 2374 : /* LCOV_EXCL_STOP */ 2375 : } - 2376 4305 : } else if (c == 'm' || c == 'M') { + 2376 4342 : } else if (c == 'm' || c == 'M') { 2377 : struct snapraid_map* map; 2378 : char uuid[UUID_MAX]; 2379 : uint32_t v_pos; @@ -2443,16 +2443,16 @@ 2381 : uint32_t v_free_blocks; 2382 : struct snapraid_disk* disk; 2383 : - 2384 1340 : ret = sgetbs(f, buffer, sizeof(buffer)); - 2385 1340 : if (ret < 0) { + 2384 1351 : ret = sgetbs(f, buffer, sizeof(buffer)); + 2385 1351 : if (ret < 0) { 2386 : /* LCOV_EXCL_START */ 2387 : decoding_error(path, f); 2388 : os_abort(); 2389 : /* LCOV_EXCL_STOP */ 2390 : } 2391 : - 2392 1340 : ret = sgetb32(f, &v_pos); - 2393 1340 : if (ret < 0) { + 2392 1351 : ret = sgetb32(f, &v_pos); + 2393 1351 : if (ret < 0) { 2394 : /* LCOV_EXCL_START */ 2395 : decoding_error(path, f); 2396 : os_abort(); @@ -2460,17 +2460,17 @@ 2398 : } 2399 : 2400 : /* from SnapRAID 7.0 the 'M' command includes the free space */ - 2401 1340 : if (c == 'M') { - 2402 1340 : ret = sgetb32(f, &v_total_blocks); - 2403 1340 : if (ret < 0) { + 2401 1351 : if (c == 'M') { + 2402 1351 : ret = sgetb32(f, &v_total_blocks); + 2403 1351 : if (ret < 0) { 2404 : /* LCOV_EXCL_START */ 2405 : decoding_error(path, f); 2406 : os_abort(); 2407 : /* LCOV_EXCL_STOP */ 2408 : } 2409 : - 2410 1340 : ret = sgetb32(f, &v_free_blocks); - 2411 1340 : if (ret < 0) { + 2410 1351 : ret = sgetb32(f, &v_free_blocks); + 2411 1351 : if (ret < 0) { 2412 : /* LCOV_EXCL_START */ 2413 : decoding_error(path, f); 2414 : os_abort(); @@ -2482,8 +2482,8 @@ 2420 : } 2421 : 2422 : /* read the uuid */ - 2423 1340 : ret = sgetbs(f, uuid, sizeof(uuid)); - 2424 1340 : if (ret < 0) { + 2423 1351 : ret = sgetbs(f, uuid, sizeof(uuid)); + 2424 1351 : if (ret < 0) { 2425 : /* LCOV_EXCL_START */ 2426 : decoding_error(path, f); 2427 : os_abort(); @@ -2491,8 +2491,8 @@ 2429 : } 2430 : 2431 : /* find the disk */ - 2432 1340 : disk = find_disk_by_name(state, buffer); - 2433 1340 : if (!disk) { + 2432 1351 : disk = find_disk_by_name(state, buffer); + 2433 1351 : if (!disk) { 2434 : /* search by UUID if renamed */ 2435 2 : disk = find_disk_by_uuid(state, uuid); 2436 2 : if (disk) { @@ -2502,7 +2502,7 @@ 2440 2 : state->need_write = 1; 2441 : } 2442 : } - 2443 1340 : if (!disk) { + 2443 1351 : if (!disk) { 2444 : /* LCOV_EXCL_START */ 2445 : decoding_error(path, f); 2446 : log_fatal("Disk '%s' with uuid '%s' not present in the configuration file!\n", buffer, uuid); @@ -2514,47 +2514,47 @@ 2452 : /* LCOV_EXCL_STOP */ 2453 : } 2454 : - 2455 1340 : map = map_alloc(disk->name, v_pos, v_total_blocks, v_free_blocks, uuid); + 2455 1351 : map = map_alloc(disk->name, v_pos, v_total_blocks, v_free_blocks, uuid); 2456 : - 2457 1340 : tommy_list_insert_tail(&state->maplist, &map->node, map); + 2457 1351 : tommy_list_insert_tail(&state->maplist, &map->node, map); 2458 : 2459 : /* insert in the mapping vector */ - 2460 1340 : tommy_array_grow(&disk_mapping, mapping_max + 1); - 2461 1340 : tommy_array_set(&disk_mapping, mapping_max, disk); - 2462 1340 : ++mapping_max; - 2463 1625 : } else if (c == 'P') { + 2460 1351 : tommy_array_grow(&disk_mapping, mapping_max + 1); + 2461 1351 : tommy_array_set(&disk_mapping, mapping_max, disk); + 2462 1351 : ++mapping_max; + 2463 1640 : } else if (c == 'P') { 2464 : /* from SnapRAID 7.0 the 'P' command includes the free space */ 2465 : char uuid[UUID_MAX]; 2466 : uint32_t v_level; 2467 : uint32_t v_total_blocks; 2468 : uint32_t v_free_blocks; 2469 : - 2470 1383 : ret = sgetb32(f, &v_level); - 2471 1383 : if (ret < 0) { + 2470 1395 : ret = sgetb32(f, &v_level); + 2471 1395 : if (ret < 0) { 2472 : /* LCOV_EXCL_START */ 2473 : decoding_error(path, f); 2474 : os_abort(); 2475 : /* LCOV_EXCL_STOP */ 2476 : } 2477 : - 2478 1383 : ret = sgetb32(f, &v_total_blocks); - 2479 1383 : if (ret < 0) { + 2478 1395 : ret = sgetb32(f, &v_total_blocks); + 2479 1395 : if (ret < 0) { 2480 : /* LCOV_EXCL_START */ 2481 : decoding_error(path, f); 2482 : os_abort(); 2483 : /* LCOV_EXCL_STOP */ 2484 : } 2485 : - 2486 1383 : ret = sgetb32(f, &v_free_blocks); - 2487 1383 : if (ret < 0) { + 2486 1395 : ret = sgetb32(f, &v_free_blocks); + 2487 1395 : if (ret < 0) { 2488 : /* LCOV_EXCL_START */ 2489 : decoding_error(path, f); 2490 : os_abort(); 2491 : /* LCOV_EXCL_STOP */ 2492 : } 2493 : - 2494 1383 : ret = sgetbs(f, uuid, sizeof(uuid)); - 2495 1383 : if (ret < 0) { + 2494 1395 : ret = sgetbs(f, uuid, sizeof(uuid)); + 2495 1395 : if (ret < 0) { 2496 : /* LCOV_EXCL_START */ 2497 : decoding_error(path, f); 2498 : os_abort(); @@ -2562,25 +2562,25 @@ 2500 : } 2501 : 2502 : /* auto configure if configuration is missing */ - 2503 1383 : if (state->no_conf && v_level < LEV_MAX && v_level >= state->level) + 2503 1395 : if (state->no_conf && v_level < LEV_MAX && v_level >= state->level) 2504 5 : state->level = v_level + 1; 2505 : 2506 : /* if we use this parity entry */ - 2507 1383 : if (v_level < state->level) { + 2507 1395 : if (v_level < state->level) { 2508 : /* set the parity info */ - 2509 1129 : pathcpy(state->parity[v_level].uuid, sizeof(state->parity[v_level].uuid), uuid); - 2510 1129 : state->parity[v_level].total_blocks = v_total_blocks; - 2511 1129 : state->parity[v_level].free_blocks = v_free_blocks; + 2509 1141 : pathcpy(state->parity[v_level].uuid, sizeof(state->parity[v_level].uuid), uuid); + 2510 1141 : state->parity[v_level].total_blocks = v_total_blocks; + 2511 1141 : state->parity[v_level].free_blocks = v_free_blocks; 2512 : } - 2513 242 : } else if (c == 'N') { + 2513 245 : } else if (c == 'N') { 2514 : uint32_t crc_stored; 2515 : uint32_t crc_computed; 2516 : 2517 : /* get the crc before reading it from the file */ - 2518 242 : crc_computed = scrc(f); + 2518 244 : crc_computed = scrc(f); 2519 : - 2520 242 : ret = sgetble32(f, &crc_stored); - 2521 242 : if (ret < 0) { + 2520 244 : ret = sgetble32(f, &crc_stored); + 2521 244 : if (ret < 0) { 2522 : /* LCOV_EXCL_START */ 2523 : /* here don't call decoding_error() because it's too late to get the crc */ 2524 : log_fatal("Error reading the CRC in '%s' at offset %" PRIi64 "\n", path, stell(f)); @@ -2589,7 +2589,7 @@ 2527 : /* LCOV_EXCL_STOP */ 2528 : } 2529 : - 2530 242 : if (crc_stored != crc_computed) { + 2530 244 : if (crc_stored != crc_computed) { 2531 : /* LCOV_EXCL_START */ 2532 : /* here don't call decoding_error() because it's too late to get the crc */ 2533 : log_fatal("Mismatching CRC in '%s'\n", path); @@ -2598,7 +2598,7 @@ 2536 : /* LCOV_EXCL_STOP */ 2537 : } 2538 : - 2539 242 : crc_checked = 1; + 2539 244 : crc_checked = 1; 2540 : } else { 2541 : /* LCOV_EXCL_START */ 2542 : decoding_error(path, f); @@ -2606,18 +2606,18 @@ 2544 : os_abort(); 2545 : /* LCOV_EXCL_STOP */ 2546 : } - 2547 3652776 : } + 2547 3653450 : } 2548 : - 2549 242 : tommy_array_done(&disk_mapping); + 2549 244 : tommy_array_done(&disk_mapping); 2550 : - 2551 242 : if (serror(f)) { + 2551 244 : if (serror(f)) { 2552 : /* LCOV_EXCL_START */ 2553 : log_fatal("Error reading the content file '%s' at offset %" PRIi64 "\n", path, stell(f)); 2554 : exit(EXIT_FAILURE); 2555 : /* LCOV_EXCL_STOP */ 2556 : } 2557 : - 2558 242 : if (!crc_checked) { + 2558 244 : if (!crc_checked) { 2559 : /* LCOV_EXCL_START */ 2560 : log_fatal("Finished reading '%s' without finding the CRC\n", path); 2561 : log_fatal("This content file is truncated or damaged! Use an alternate copy.\n"); @@ -2626,10 +2626,10 @@ 2564 : } 2565 : 2566 : /* check the file-system on all disks */ - 2567 242 : state_fscheck(state, "after read"); + 2567 244 : state_fscheck(state, "after read"); 2568 : 2569 : /* check that the stored parity size matches the loaded state */ - 2570 242 : if (blockmax != parity_allocated_size(state)) { + 2570 244 : if (blockmax != parity_allocated_size(state)) { 2571 : /* LCOV_EXCL_START */ 2572 : log_fatal("Internal inconsistency in parity size %u/%u in '%s' at offset %" PRIi64 "\n", blockmax, parity_allocated_size(state), path, stell(f)); 2573 : if (state->opt.skip_content_check) { @@ -2641,11 +2641,11 @@ 2579 : /* LCOV_EXCL_STOP */ 2580 : } 2581 : - 2582 242 : msg_verbose("%8u files\n", count_file); - 2583 242 : msg_verbose("%8u hardlinks\n", count_hardlink); - 2584 242 : msg_verbose("%8u symlinks\n", count_symlink); - 2585 242 : msg_verbose("%8u empty dirs\n", count_dir); - 2586 242 : } + 2582 244 : msg_verbose("%8u files\n", count_file); + 2583 244 : msg_verbose("%8u hardlinks\n", count_hardlink); + 2584 244 : msg_verbose("%8u symlinks\n", count_symlink); + 2585 244 : msg_verbose("%8u empty dirs\n", count_dir); + 2586 244 : } 2587 : 2588 : struct state_write_thread_context { 2589 : struct snapraid_state* state; @@ -2665,14 +2665,14 @@ 2603 : unsigned count_dir; 2604 : }; 2605 : - 2606 145 : static void* state_write_thread(void* arg) + 2606 148 : static void* state_write_thread(void* arg) 2607 : { - 2608 145 : struct state_write_thread_context* context = arg; - 2609 145 : struct snapraid_state* state = context->state; - 2610 145 : block_off_t blockmax = context->blockmax; - 2611 145 : time_t info_oldest = context->info_oldest; - 2612 145 : int info_has_rehash = context->info_has_rehash; - 2613 145 : STREAM* f = context->f; + 2608 148 : struct state_write_thread_context* context = arg; + 2609 148 : struct snapraid_state* state = context->state; + 2610 148 : block_off_t blockmax = context->blockmax; + 2611 148 : time_t info_oldest = context->info_oldest; + 2612 148 : int info_has_rehash = context->info_has_rehash; + 2613 148 : STREAM* f = context->f; 2614 : uint32_t crc; 2615 : unsigned count_file; 2616 : unsigned count_hardlink; @@ -2683,29 +2683,29 @@ 2621 : block_off_t begin; 2622 : unsigned l; 2623 : - 2624 145 : count_file = 0; - 2625 145 : count_hardlink = 0; - 2626 145 : count_symlink = 0; - 2627 145 : count_dir = 0; + 2624 148 : count_file = 0; + 2625 148 : count_hardlink = 0; + 2626 148 : count_symlink = 0; + 2627 148 : count_dir = 0; 2628 : 2629 : /* write header */ - 2630 145 : swrite("SNAPCNT2\n\3\0\0", 12, f); + 2630 148 : swrite("SNAPCNT2\n\3\0\0", 12, f); 2631 : 2632 : /* write block size and block max */ - 2633 145 : sputc('z', f); - 2634 145 : sputb32(state->block_size, f); - 2635 145 : sputc('x', f); - 2636 145 : sputb32(blockmax, f); - 2637 145 : if (serror(f)) { + 2633 148 : sputc('z', f); + 2634 148 : sputb32(state->block_size, f); + 2635 148 : sputc('x', f); + 2636 148 : sputb32(blockmax, f); + 2637 148 : if (serror(f)) { 2638 : /* LCOV_EXCL_START */ 2639 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2640 : return context; 2641 : /* LCOV_EXCL_STOP */ 2642 : } 2643 : - 2644 145 : sputc('c', f); - 2645 145 : if (state->hash == HASH_MURMUR3) { - 2646 115 : sputc('u', f); + 2644 148 : sputc('c', f); + 2645 148 : if (state->hash == HASH_MURMUR3) { + 2646 118 : sputc('u', f); 2647 30 : } else if (state->hash == HASH_SPOOKY2) { 2648 30 : sputc('k', f); 2649 : } else { @@ -2714,8 +2714,8 @@ 2652 : return context; 2653 : /* LCOV_EXCL_STOP */ 2654 : } - 2655 145 : swrite(state->hashseed, HASH_SIZE, f); - 2656 145 : if (serror(f)) { + 2655 148 : swrite(state->hashseed, HASH_SIZE, f); + 2656 148 : if (serror(f)) { 2657 : /* LCOV_EXCL_START */ 2658 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2659 : return context; @@ -2723,7 +2723,7 @@ 2661 : } 2662 : 2663 : /* previous hash only present */ - 2664 145 : if (state->prevhash != HASH_UNDEFINED) { + 2664 148 : if (state->prevhash != HASH_UNDEFINED) { 2665 : /* if at least one rehash tag found, we have to save the previous hash */ 2666 4 : if (info_has_rehash) { 2667 3 : sputc('C', f); @@ -2748,13 +2748,13 @@ 2686 : } 2687 : 2688 : /* for each map */ - 2689 1015 : for (i = state->maplist; i != 0; i = i->next) { - 2690 870 : struct snapraid_map* map = i->data; + 2689 1036 : for (i = state->maplist; i != 0; i = i->next) { + 2690 888 : struct snapraid_map* map = i->data; 2691 : struct snapraid_disk* disk; 2692 : 2693 : /* find the disk for this mapping */ - 2694 870 : disk = find_disk_by_name(state, map->name); - 2695 870 : if (!disk) { + 2694 888 : disk = find_disk_by_name(state, map->name); + 2695 888 : if (!disk) { 2696 : /* LCOV_EXCL_START */ 2697 : log_fatal("Internal inconsistency for unmapped disk '%s'\n", map->name); 2698 : return context; @@ -2762,14 +2762,14 @@ 2700 : } 2701 : 2702 : /* save the mapping only if disk is mapped */ - 2703 870 : if (disk->mapping_idx != -1) { - 2704 786 : sputc('M', f); - 2705 786 : sputbs(map->name, f); - 2706 786 : sputb32(map->position, f); - 2707 786 : sputb32(map->total_blocks, f); - 2708 786 : sputb32(map->free_blocks, f); - 2709 786 : sputbs(map->uuid, f); - 2710 786 : if (serror(f)) { + 2703 888 : if (disk->mapping_idx != -1) { + 2704 796 : sputc('M', f); + 2705 796 : sputbs(map->name, f); + 2706 796 : sputb32(map->position, f); + 2707 796 : sputb32(map->total_blocks, f); + 2708 796 : sputb32(map->free_blocks, f); + 2709 796 : sputbs(map->uuid, f); + 2710 796 : if (serror(f)) { 2711 : /* LCOV_EXCL_START */ 2712 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2713 : return context; @@ -2779,13 +2779,13 @@ 2717 : } 2718 : 2719 : /* for each parity */ - 2720 990 : for (l = 0; l < state->level; ++l) { - 2721 845 : sputc('P', f); - 2722 845 : sputb32(l, f); - 2723 845 : sputb32(state->parity[l].total_blocks, f); - 2724 845 : sputb32(state->parity[l].free_blocks, f); - 2725 845 : sputbs(state->parity[l].uuid, f); - 2726 845 : if (serror(f)) { + 2720 1011 : for (l = 0; l < state->level; ++l) { + 2721 863 : sputc('P', f); + 2722 863 : sputb32(l, f); + 2723 863 : sputb32(state->parity[l].total_blocks, f); + 2724 863 : sputb32(state->parity[l].free_blocks, f); + 2725 863 : sputbs(state->parity[l].uuid, f); + 2726 863 : if (serror(f)) { 2727 : /* LCOV_EXCL_START */ 2728 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2729 : return context; @@ -2794,9 +2794,9 @@ 2732 : } 2733 : 2734 : /* for each disk */ - 2735 1015 : for (i = state->disklist; i != 0; i = i->next) { + 2735 1036 : for (i = state->disklist; i != 0; i = i->next) { 2736 : tommy_node* j; - 2737 870 : struct snapraid_disk* disk = i->data; + 2737 888 : struct snapraid_disk* disk = i->data; 2738 : struct snapraid_chunk* fs_last; 2739 : 2740 : /** @@ -2804,37 +2804,37 @@ 2742 : * Here we are inside a thread, and we cannot use the 2743 : * ::disk member to store this information. 2744 : */ - 2745 870 : fs_last = 0; + 2745 888 : fs_last = 0; 2746 : 2747 : /* if the disk is not mapped, skip it */ - 2748 870 : if (disk->mapping_idx < 0) - 2749 84 : continue; + 2748 888 : if (disk->mapping_idx < 0) + 2749 92 : continue; 2750 : 2751 : /* for each file */ - 2752 1765094 : for (j = disk->filelist; j != 0; j = j->next) { - 2753 1764308 : struct snapraid_file* file = j->data; + 2752 1748749 : for (j = disk->filelist; j != 0; j = j->next) { + 2753 1747953 : struct snapraid_file* file = j->data; 2754 : uint64_t size; 2755 : uint64_t mtime_sec; 2756 : int32_t mtime_nsec; 2757 : uint64_t inode; 2758 : - 2759 1764308 : size = file->size; - 2760 1764308 : mtime_sec = file->mtime_sec; - 2761 1764308 : mtime_nsec = file->mtime_nsec; - 2762 1764308 : inode = file->inode; + 2759 1747953 : size = file->size; + 2760 1747953 : mtime_sec = file->mtime_sec; + 2761 1747953 : mtime_nsec = file->mtime_nsec; + 2762 1747953 : inode = file->inode; 2763 : - 2764 1764308 : sputc('f', f); - 2765 1764308 : sputb32(disk->mapping_idx, f); - 2766 1764308 : sputb64(size, f); - 2767 1764308 : sputb64(mtime_sec, f); + 2764 1747953 : sputc('f', f); + 2765 1747953 : sputb32(disk->mapping_idx, f); + 2766 1747953 : sputb64(size, f); + 2767 1747953 : sputb64(mtime_sec, f); 2768 : /* encode STAT_NSEC_INVALID as 0 */ - 2769 1764308 : if (mtime_nsec == STAT_NSEC_INVALID) + 2769 1747953 : if (mtime_nsec == STAT_NSEC_INVALID) 2770 0 : sputb32(0, f); 2771 : else - 2772 1764308 : sputb32(mtime_nsec + 1, f); - 2773 1764308 : sputb64(inode, f); - 2774 1764308 : sputbs(file->sub, f); - 2775 1764308 : if (serror(f)) { + 2772 1747953 : sputb32(mtime_nsec + 1, f); + 2773 1747953 : sputb64(inode, f); + 2774 1747953 : sputbs(file->sub, f); + 2775 1747953 : if (serror(f)) { 2776 : /* LCOV_EXCL_START */ 2777 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2778 : return context; @@ -2842,34 +2842,34 @@ 2780 : } 2781 : 2782 : /* for all the blocks of the file */ - 2783 1764308 : begin = 0; - 2784 5303306 : while (begin < file->blockmax) { - 2785 1774690 : unsigned v_state = block_state_get(fs_file2block_get(file, begin)); - 2786 1774690 : block_off_t v_pos = fs_file2par_get_ts(disk, &fs_last, file, begin); + 2783 1747953 : begin = 0; + 2784 5254144 : while (begin < file->blockmax) { + 2785 1758238 : unsigned v_state = block_state_get(fs_file2block_get(file, begin)); + 2786 1758238 : block_off_t v_pos = fs_file2par_get_ts(disk, &fs_last, file, begin); 2787 : uint32_t v_count; 2788 : 2789 : block_off_t end; 2790 : 2791 : /* find the end of run of blocks */ - 2792 1774690 : end = begin + 1; - 2793 6121077 : while (end < file->blockmax) { - 2794 2584536 : if (v_state != block_state_get(fs_file2block_get(file, end))) - 2795 11 : break; - 2796 2584525 : if (v_pos + (end - begin) != fs_file2par_get_ts(disk, &fs_last, file, end)) - 2797 12828 : break; - 2798 2571697 : ++end; + 2792 1758238 : end = begin + 1; + 2793 6066576 : while (end < file->blockmax) { + 2794 2562818 : if (v_state != block_state_get(fs_file2block_get(file, end))) + 2795 12 : break; + 2796 2562806 : if (v_pos + (end - begin) != fs_file2par_get_ts(disk, &fs_last, file, end)) + 2797 12706 : break; + 2798 2550100 : ++end; 2799 : } 2800 : - 2801 1774690 : switch (v_state) { + 2801 1758238 : switch (v_state) { 2802 : case BLOCK_STATE_BLK : - 2803 1650586 : sputc('b', f); - 2804 1650586 : break; + 2803 1634130 : sputc('b', f); + 2804 1634130 : break; 2805 : case BLOCK_STATE_CHG : - 2806 67711 : sputc('g', f); - 2807 67711 : break; + 2806 67707 : sputc('g', f); + 2807 67707 : break; 2808 : case BLOCK_STATE_REP : - 2809 56393 : sputc('p', f); - 2810 56393 : break; + 2809 56401 : sputc('p', f); + 2810 56401 : break; 2811 : default : 2812 : /* LCOV_EXCL_START */ 2813 : log_fatal("Internal inconsistency in state for block %u state %u\n", v_pos, v_state); @@ -2877,19 +2877,19 @@ 2815 : /* LCOV_EXCL_STOP */ 2816 : } 2817 : - 2818 1774690 : sputb32(v_pos, f); + 2818 1758238 : sputb32(v_pos, f); 2819 : - 2820 1774690 : v_count = end - begin; - 2821 1774690 : sputb32(v_count, f); + 2820 1758238 : v_count = end - begin; + 2821 1758238 : sputb32(v_count, f); 2822 : 2823 : /* write hashes */ - 2824 6121077 : for (idx = begin; idx < end; ++idx) { - 2825 4346387 : struct snapraid_block* block = fs_file2block_get(file, idx); + 2824 6066576 : for (idx = begin; idx < end; ++idx) { + 2825 4308338 : struct snapraid_block* block = fs_file2block_get(file, idx); 2826 : - 2827 4346387 : swrite(block->hash, HASH_SIZE, f); + 2827 4308338 : swrite(block->hash, HASH_SIZE, f); 2828 : } 2829 : - 2830 1774690 : if (serror(f)) { + 2830 1758238 : if (serror(f)) { 2831 : /* LCOV_EXCL_START */ 2832 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2833 : return context; @@ -2897,31 +2897,31 @@ 2835 : } 2836 : 2837 : /* next begin position */ - 2838 1774690 : begin = end; + 2838 1758238 : begin = end; 2839 : } 2840 : - 2841 1764308 : ++count_file; + 2841 1747953 : ++count_file; 2842 : } 2843 : 2844 : /* for each link */ - 2845 58592 : for (j = disk->linklist; j != 0; j = j->next) { - 2846 57806 : struct snapraid_link* slink = j->data; + 2845 58058 : for (j = disk->linklist; j != 0; j = j->next) { + 2846 57262 : struct snapraid_link* slink = j->data; 2847 : - 2848 57806 : switch (link_flag_get(slink, FILE_IS_LINK_MASK)) { + 2848 57262 : switch (link_flag_get(slink, FILE_IS_LINK_MASK)) { 2849 : case FILE_IS_HARDLINK : - 2850 315 : sputc('a', f); - 2851 315 : ++count_hardlink; - 2852 315 : break; + 2850 312 : sputc('a', f); + 2851 312 : ++count_hardlink; + 2852 312 : break; 2853 : case FILE_IS_SYMLINK : - 2854 57491 : sputc('s', f); - 2855 57491 : ++count_symlink; - 2856 57491 : break; + 2854 56950 : sputc('s', f); + 2855 56950 : ++count_symlink; + 2856 56950 : break; 2857 : } 2858 : - 2859 57806 : sputb32(disk->mapping_idx, f); - 2860 57806 : sputbs(slink->sub, f); - 2861 57806 : sputbs(slink->linkto, f); - 2862 57806 : if (serror(f)) { + 2859 57262 : sputb32(disk->mapping_idx, f); + 2860 57262 : sputbs(slink->sub, f); + 2861 57262 : sputbs(slink->linkto, f); + 2862 57262 : if (serror(f)) { 2863 : /* LCOV_EXCL_START */ 2864 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2865 : return context; @@ -2930,70 +2930,70 @@ 2868 : } 2869 : 2870 : /* for each dir */ - 2871 1205 : for (j = disk->dirlist; j != 0; j = j->next) { - 2872 419 : struct snapraid_dir* dir = j->data; + 2871 1211 : for (j = disk->dirlist; j != 0; j = j->next) { + 2872 415 : struct snapraid_dir* dir = j->data; 2873 : - 2874 419 : sputc('r', f); - 2875 419 : sputb32(disk->mapping_idx, f); - 2876 419 : sputbs(dir->sub, f); - 2877 419 : if (serror(f)) { + 2874 415 : sputc('r', f); + 2875 415 : sputb32(disk->mapping_idx, f); + 2876 415 : sputbs(dir->sub, f); + 2877 415 : if (serror(f)) { 2878 : /* LCOV_EXCL_START */ 2879 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2880 : return context; 2881 : /* LCOV_EXCL_STOP */ 2882 : } 2883 : - 2884 419 : ++count_dir; + 2884 415 : ++count_dir; 2885 : } 2886 : 2887 : /* deleted blocks of the disk */ - 2888 786 : sputc('h', f); - 2889 786 : sputb32(disk->mapping_idx, f); - 2890 786 : if (serror(f)) { + 2888 796 : sputc('h', f); + 2889 796 : sputb32(disk->mapping_idx, f); + 2890 796 : if (serror(f)) { 2891 : /* LCOV_EXCL_START */ 2892 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2893 : return context; 2894 : /* LCOV_EXCL_STOP */ 2895 : } - 2896 786 : begin = 0; - 2897 2435 : while (begin < blockmax) { + 2896 796 : begin = 0; + 2897 2466 : while (begin < blockmax) { 2898 : int is_deleted; 2899 : block_off_t end; 2900 : - 2901 863 : is_deleted = fs_is_block_deleted_ts(disk, &fs_last, begin); + 2901 874 : is_deleted = fs_is_block_deleted_ts(disk, &fs_last, begin); 2902 : 2903 : /* find the end of run of blocks */ - 2904 863 : end = begin + 1; - 2905 4508642 : while (end < blockmax - 2906 4506993 : && is_deleted == fs_is_block_deleted_ts(disk, &fs_last, end) + 2904 874 : end = begin + 1; + 2905 4473223 : while (end < blockmax + 2906 4471553 : && is_deleted == fs_is_block_deleted_ts(disk, &fs_last, end) 2907 : ) { - 2908 4506916 : ++end; + 2908 4471475 : ++end; 2909 : } 2910 : - 2911 863 : sputb32(end - begin, f); + 2911 874 : sputb32(end - begin, f); 2912 : - 2913 863 : if (is_deleted) { + 2913 874 : if (is_deleted) { 2914 : /* write the run of deleted blocks with hash */ 2915 49 : sputc('o', f); 2916 : 2917 : /* write all the hash */ - 2918 15941 : while (begin < end) { - 2919 15843 : struct snapraid_block* block = fs_par2block_get_ts(disk, &fs_last, begin); + 2918 15965 : while (begin < end) { + 2919 15867 : struct snapraid_block* block = fs_par2block_get_ts(disk, &fs_last, begin); 2920 : - 2921 15843 : swrite(block->hash, HASH_SIZE, f); + 2921 15867 : swrite(block->hash, HASH_SIZE, f); 2922 : - 2923 15843 : ++begin; + 2923 15867 : ++begin; 2924 : } 2925 : } else { 2926 : /* write the run of blocks without hash */ 2927 : /* they can be either used or empty blocks */ - 2928 814 : sputc('O', f); + 2928 825 : sputc('O', f); 2929 : 2930 : /* next begin position */ - 2931 814 : begin = end; + 2931 825 : begin = end; 2932 : } 2933 : - 2934 863 : if (serror(f)) { + 2934 874 : if (serror(f)) { 2935 : /* LCOV_EXCL_START */ 2936 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2937 : return context; @@ -3003,47 +3003,47 @@ 2941 : } 2942 : 2943 : /* write the info for each block */ - 2944 145 : sputc('i', f); - 2945 145 : sputb32(info_oldest, f); - 2946 145 : begin = 0; - 2947 30551 : while (begin < blockmax) { + 2944 148 : sputc('i', f); + 2945 148 : sputb32(info_oldest, f); + 2946 148 : begin = 0; + 2947 30307 : while (begin < blockmax) { 2948 : snapraid_info info; 2949 : block_off_t end; 2950 : time_t t; 2951 : unsigned flag; 2952 : - 2953 30261 : info = info_get(&state->infoarr, begin); + 2953 30011 : info = info_get(&state->infoarr, begin); 2954 : 2955 : /* find the end of run of blocks */ - 2956 30261 : end = begin + 1; - 2957 782752 : while (end < blockmax - 2958 752349 : && info == info_get(&state->infoarr, end) + 2956 30011 : end = begin + 1; + 2957 776577 : while (end < blockmax + 2958 746421 : && info == info_get(&state->infoarr, end) 2959 : ) { - 2960 722230 : ++end; + 2960 716555 : ++end; 2961 : } 2962 : - 2963 30261 : sputb32(end - begin, f); + 2963 30011 : sputb32(end - begin, f); 2964 : 2965 : /* if there is info */ - 2966 30261 : if (info) { + 2966 30011 : if (info) { 2967 : /* other flags */ - 2968 30239 : flag = 1; /* info is present */ - 2969 30239 : if (info_get_bad(info)) - 2970 1351 : flag |= 2; - 2971 30239 : if (info_get_rehash(info)) - 2972 9806 : flag |= 4; - 2973 30239 : if (info_get_justsynced(info)) - 2974 18186 : flag |= 8; - 2975 30239 : sputb32(flag, f); + 2968 29988 : flag = 1; /* info is present */ + 2969 29988 : if (info_get_bad(info)) + 2970 1341 : flag |= 2; + 2971 29988 : if (info_get_rehash(info)) + 2972 9819 : flag |= 4; + 2973 29988 : if (info_get_justsynced(info)) + 2974 17932 : flag |= 8; + 2975 29988 : sputb32(flag, f); 2976 : - 2977 30239 : t = info_get_time(info) - info_oldest; - 2978 30239 : sputb32(t, f); + 2977 29988 : t = info_get_time(info) - info_oldest; + 2978 29988 : sputb32(t, f); 2979 : } else { 2980 : /* write a special 0 flag to mark missing info */ - 2981 22 : sputb32(0, f); + 2981 23 : sputb32(0, f); 2982 : } 2983 : - 2984 30261 : if (serror(f)) { + 2984 30011 : if (serror(f)) { 2985 : /* LCOV_EXCL_START */ 2986 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 2987 : return context; @@ -3051,13 +3051,13 @@ 2989 : } 2990 : 2991 : /* next begin position */ - 2992 30261 : begin = end; + 2992 30011 : begin = end; 2993 : } 2994 : - 2995 145 : sputc('N', f); + 2995 148 : sputc('N', f); 2996 : 2997 : /* flush data written to the disk */ - 2998 145 : if (sflush(f)) { + 2998 148 : if (sflush(f)) { 2999 : /* LCOV_EXCL_START */ 3000 : log_fatal("Error writing the content file '%s' (in flush before crc). %s.\n", serrorfile(f), strerror(errno)); 3001 : return context; @@ -3065,11 +3065,11 @@ 3003 : } 3004 : 3005 : /* get the file crc */ - 3006 145 : crc = scrc(f); + 3006 148 : crc = scrc(f); 3007 : 3008 : /* compare the crc of the data written to file */ 3009 : /* with the one of the data written to the stream */ - 3010 145 : if (crc != scrc_stream(f)) { + 3010 148 : if (crc != scrc_stream(f)) { 3011 : /* LCOV_EXCL_START */ 3012 : log_fatal("CRC mismatch writing the content stream.\n"); 3013 : log_fatal("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); @@ -3078,8 +3078,8 @@ 3016 : /* LCOV_EXCL_STOP */ 3017 : } 3018 : - 3019 145 : sputble32(crc, f); - 3020 145 : if (serror(f)) { + 3019 148 : sputble32(crc, f); + 3020 148 : if (serror(f)) { 3021 : /* LCOV_EXCL_START */ 3022 : log_fatal("Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 3023 : return context; @@ -3087,16 +3087,16 @@ 3025 : } 3026 : 3027 : /* set output variables */ - 3028 145 : context->crc = crc; - 3029 145 : context->count_file = count_file; - 3030 145 : context->count_hardlink = count_hardlink; - 3031 145 : context->count_symlink = count_symlink; - 3032 145 : context->count_dir = count_dir; + 3028 148 : context->crc = crc; + 3029 148 : context->count_file = count_file; + 3030 148 : context->count_hardlink = count_hardlink; + 3031 148 : context->count_symlink = count_symlink; + 3032 148 : context->count_dir = count_dir; 3033 : - 3034 145 : return 0; + 3034 148 : return 0; 3035 : } 3036 : - 3037 145 : static void state_write_content(struct snapraid_state* state, uint32_t* out_crc) + 3037 148 : static void state_write_content(struct snapraid_state* state, uint32_t* out_crc) 3038 : { 3039 : #if HAVE_MT_WRITE 3040 : int fail; @@ -3121,29 +3121,29 @@ 3059 : unsigned count_dir; 3060 : 3061 : /* blocks of all array */ - 3062 145 : blockmax = parity_allocated_size(state); + 3062 148 : blockmax = parity_allocated_size(state); 3063 : 3064 : /* check the file-system on all disks */ - 3065 145 : state_fscheck(state, "before write"); + 3065 148 : state_fscheck(state, "before write"); 3066 : 3067 : /* clear the info for unused blocks */ 3068 : /* and get some other info */ - 3069 145 : info_oldest = 0; /* oldest time in info */ - 3070 145 : info_has_rehash = 0; /* if there is a rehash info */ - 3071 752636 : for (idx = 0; idx < blockmax; ++idx) { + 3069 148 : info_oldest = 0; /* oldest time in info */ + 3070 148 : info_has_rehash = 0; /* if there is a rehash info */ + 3071 746714 : for (idx = 0; idx < blockmax; ++idx) { 3072 : /* if the position is used */ - 3073 752491 : if (fs_position_is_required(state, idx)) { - 3074 752491 : snapraid_info info = info_get(&state->infoarr, idx); + 3073 746566 : if (fs_position_is_required(state, idx)) { + 3074 746566 : snapraid_info info = info_get(&state->infoarr, idx); 3075 : 3076 : /* only if there is some info to store */ - 3077 752491 : if (info) { - 3078 708014 : time_t info_time = info_get_time(info); + 3077 746566 : if (info) { + 3078 702081 : time_t info_time = info_get_time(info); 3079 : - 3080 708014 : if (!info_oldest || info_time < info_oldest) - 3081 155 : info_oldest = info_time; + 3080 702081 : if (!info_oldest || info_time < info_oldest) + 3081 156 : info_oldest = info_time; 3082 : - 3083 708014 : if (info_get_rehash(info)) - 3084 18413 : info_has_rehash = 1; + 3083 702081 : if (info_get_rehash(info)) + 3084 18429 : info_has_rehash = 1; 3085 : } 3086 : } else { 3087 : /* clear any previous info */ @@ -3155,14 +3155,14 @@ 3093 : } 3094 : 3095 : /* map disks */ - 3096 145 : mapping_idx = 0; - 3097 1015 : for (i = state->maplist; i != 0; i = i->next) { - 3098 870 : struct snapraid_map* map = i->data; + 3096 148 : mapping_idx = 0; + 3097 1036 : for (i = state->maplist; i != 0; i = i->next) { + 3098 888 : struct snapraid_map* map = i->data; 3099 : struct snapraid_disk* disk; 3100 : 3101 : /* find the disk for this mapping */ - 3102 870 : disk = find_disk_by_name(state, map->name); - 3103 870 : if (!disk) { + 3102 888 : disk = find_disk_by_name(state, map->name); + 3103 888 : if (!disk) { 3104 : /* LCOV_EXCL_START */ 3105 : log_fatal("Internal inconsistency for unmapped disk '%s'\n", map->name); 3106 : os_abort(); @@ -3170,13 +3170,13 @@ 3108 : } 3109 : 3110 : /* save the mapping only for not empty disks */ - 3111 870 : if (!disk_is_empty(disk, blockmax)) { + 3111 888 : if (!disk_is_empty(disk, blockmax)) { 3112 : /* assign the mapping index used to identify disks */ - 3113 786 : disk->mapping_idx = mapping_idx; - 3114 786 : ++mapping_idx; + 3113 796 : disk->mapping_idx = mapping_idx; + 3114 796 : ++mapping_idx; 3115 : } else { 3116 : /* mark the disk as without mapping */ - 3117 84 : disk->mapping_idx = -1; + 3117 92 : disk->mapping_idx = -1; 3118 : } 3119 : } 3120 : @@ -3306,54 +3306,54 @@ 3244 : } 3245 : #else 3246 : /* count the content files */ - 3247 145 : count_content = 0; - 3248 145 : i = tommy_list_head(&state->contentlist); - 3249 1280 : while (i) { - 3250 990 : struct snapraid_content* content = i->data; - 3251 990 : msg_progress("Saving state to %s...\n", content->content); - 3252 990 : ++count_content; - 3253 990 : i = i->next; + 3247 148 : count_content = 0; + 3248 148 : i = tommy_list_head(&state->contentlist); + 3249 1307 : while (i) { + 3250 1011 : struct snapraid_content* content = i->data; + 3251 1011 : msg_progress("Saving state to %s...\n", content->content); + 3252 1011 : ++count_content; + 3253 1011 : i = i->next; 3254 : } 3255 : 3256 : /* open all the content files */ - 3257 145 : f = sopen_multi_write(count_content); - 3258 145 : if (!f) { + 3257 148 : f = sopen_multi_write(count_content); + 3258 148 : if (!f) { 3259 : /* LCOV_EXCL_START */ 3260 : log_fatal("Error opening the content files.\n"); 3261 : exit(EXIT_FAILURE); 3262 : /* LCOV_EXCL_STOP */ 3263 : } 3264 : - 3265 145 : k = 0; - 3266 145 : i = tommy_list_head(&state->contentlist); - 3267 1280 : while (i) { - 3268 990 : struct snapraid_content* content = i->data; + 3265 148 : k = 0; + 3266 148 : i = tommy_list_head(&state->contentlist); + 3267 1307 : while (i) { + 3268 1011 : struct snapraid_content* content = i->data; 3269 : char tmp[PATH_MAX]; - 3270 990 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - 3271 990 : if (sopen_multi_file(f, k, tmp) != 0) { + 3270 1011 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); + 3271 1011 : if (sopen_multi_file(f, k, tmp) != 0) { 3272 : /* LCOV_EXCL_START */ 3273 : log_fatal("Error opening the content file '%s'. %s.\n", tmp, strerror(errno)); 3274 : exit(EXIT_FAILURE); 3275 : /* LCOV_EXCL_STOP */ 3276 : } - 3277 990 : ++k; - 3278 990 : i = i->next; + 3277 1011 : ++k; + 3278 1011 : i = i->next; 3279 : } 3280 : 3281 : /* allocate the thread context */ - 3282 145 : context = malloc_nofail(sizeof(struct state_write_thread_context)); + 3282 148 : context = malloc_nofail(sizeof(struct state_write_thread_context)); 3283 : 3284 : /* initialize */ - 3285 145 : context->state = state; - 3286 145 : context->blockmax = blockmax; - 3287 145 : context->info_oldest = info_oldest; - 3288 145 : context->info_has_rehash = info_has_rehash; - 3289 145 : context->f = f; + 3285 148 : context->state = state; + 3286 148 : context->blockmax = blockmax; + 3287 148 : context->info_oldest = info_oldest; + 3288 148 : context->info_has_rehash = info_has_rehash; + 3289 148 : context->f = f; 3290 : - 3291 145 : retval = state_write_thread(context); + 3291 148 : retval = state_write_thread(context); 3292 : 3293 : /* abort on failure */ - 3294 145 : if (retval) { + 3294 148 : if (retval) { 3295 : /* LCOV_EXCL_START */ 3296 : exit(EXIT_FAILURE); 3297 : /* LCOV_EXCL_STOP */ @@ -3361,7 +3361,7 @@ 3299 : 3300 : /* Use the sequence fflush() -> fsync() -> fclose() -> rename() to ensure */ 3301 : /* than even in a system crash event we have one valid copy of the file. */ - 3302 145 : if (sflush(f) != 0) { + 3302 148 : if (sflush(f) != 0) { 3303 : /* LCOV_EXCL_START */ 3304 : log_fatal("Error writing the content file '%s', in flush(). %s.\n", serrorfile(f), strerror(errno)); 3305 : exit(EXIT_FAILURE); @@ -3369,7 +3369,7 @@ 3307 : } 3308 : 3309 : #if HAVE_FSYNC - 3310 145 : if (ssync(f) != 0) { + 3310 148 : if (ssync(f) != 0) { 3311 : /* LCOV_EXCL_START */ 3312 : log_fatal("Error writing the content file '%s' in sync(). %s.\n", serrorfile(f), strerror(errno)); 3313 : exit(EXIT_FAILURE); @@ -3377,31 +3377,31 @@ 3315 : } 3316 : #endif 3317 : - 3318 145 : if (sclose(f) != 0) { + 3318 148 : if (sclose(f) != 0) { 3319 : /* LCOV_EXCL_START */ 3320 : log_fatal("Error closing the content file. %s.\n", strerror(errno)); 3321 : exit(EXIT_FAILURE); 3322 : /* LCOV_EXCL_STOP */ 3323 : } 3324 : - 3325 145 : crc = context->crc; - 3326 145 : count_file = context->count_file; - 3327 145 : count_hardlink = context->count_hardlink; - 3328 145 : count_symlink = context->count_symlink; - 3329 145 : count_dir = context->count_dir; + 3325 148 : crc = context->crc; + 3326 148 : count_file = context->count_file; + 3327 148 : count_hardlink = context->count_hardlink; + 3328 148 : count_symlink = context->count_symlink; + 3329 148 : count_dir = context->count_dir; 3330 : - 3331 145 : free(context); + 3331 148 : free(context); 3332 : #endif 3333 : - 3334 145 : msg_verbose("%8u files\n", count_file); - 3335 145 : msg_verbose("%8u hardlinks\n", count_hardlink); - 3336 145 : msg_verbose("%8u symlinks\n", count_symlink); - 3337 145 : msg_verbose("%8u empty dirs\n", count_dir); + 3334 148 : msg_verbose("%8u files\n", count_file); + 3335 148 : msg_verbose("%8u hardlinks\n", count_hardlink); + 3336 148 : msg_verbose("%8u symlinks\n", count_symlink); + 3337 148 : msg_verbose("%8u empty dirs\n", count_dir); 3338 : - 3339 145 : *out_crc = crc; - 3340 145 : } + 3339 148 : *out_crc = crc; + 3340 148 : } 3341 : - 3342 250 : void state_read(struct snapraid_state* state) + 3342 252 : void state_read(struct snapraid_state* state) 3343 : { 3344 : STREAM* f; 3345 : char path[PATH_MAX]; @@ -3411,22 +3411,22 @@ 3349 : int c; 3350 : 3351 : /* iterate over all the available content files and load the first one present */ - 3352 250 : f = 0; - 3353 250 : node = tommy_list_head(&state->contentlist); - 3354 550 : while (node) { - 3355 293 : struct snapraid_content* content = node->data; - 3356 293 : pathcpy(path, sizeof(path), content->content); + 3352 252 : f = 0; + 3353 252 : node = tommy_list_head(&state->contentlist); + 3354 554 : while (node) { + 3355 295 : struct snapraid_content* content = node->data; + 3356 295 : pathcpy(path, sizeof(path), content->content); 3357 : - 3358 293 : if (!state->no_conf) { - 3359 292 : log_tag("content:%s\n", path); - 3360 292 : log_flush(); + 3358 295 : if (!state->no_conf) { + 3359 294 : log_tag("content:%s\n", path); + 3360 294 : log_flush(); 3361 : } - 3362 293 : msg_progress("Loading state from %s...\n", path); + 3362 295 : msg_progress("Loading state from %s...\n", path); 3363 : - 3364 293 : f = sopen_read(path); - 3365 293 : if (f != 0) { + 3364 295 : f = sopen_read(path); + 3365 295 : if (f != 0) { 3366 : /* if opened stop the search */ - 3367 243 : break; + 3367 245 : break; 3368 : } else { 3369 : /* if it's real error of an existing file, abort */ 3370 50 : if (errno != ENOENT) { @@ -3450,17 +3450,17 @@ 3388 : } 3389 : 3390 : /* if not found, assume empty */ - 3391 250 : if (!f) { + 3391 252 : if (!f) { 3392 7 : log_fatal("No content file found. Assuming empty.\n"); 3393 : 3394 : /* create the initial mapping */ 3395 7 : state_map(state); - 3396 256 : return; + 3396 258 : return; 3397 : } 3398 : 3399 : /* get the stat of the content file */ - 3400 243 : ret = fstat(shandle(f), &st); - 3401 243 : if (ret != 0) { + 3400 245 : ret = fstat(shandle(f), &st); + 3401 245 : if (ret != 0) { 3402 : /* LCOV_EXCL_START */ 3403 : log_fatal("Error stating the content file '%s'. %s.\n", path, strerror(errno)); 3404 : exit(EXIT_FAILURE); @@ -3468,14 +3468,14 @@ 3406 : } 3407 : 3408 : /* go further to check other content files */ - 3409 1891 : while (node) { + 3409 1909 : while (node) { 3410 : char other_path[PATH_MAX]; 3411 : struct stat other_st; - 3412 1405 : struct snapraid_content* content = node->data; - 3413 1405 : pathcpy(other_path, sizeof(other_path), content->content); + 3412 1419 : struct snapraid_content* content = node->data; + 3413 1419 : pathcpy(other_path, sizeof(other_path), content->content); 3414 : - 3415 1405 : ret = stat(other_path, &other_st); - 3416 1405 : if (ret != 0) { + 3415 1419 : ret = stat(other_path, &other_st); + 3416 1419 : if (ret != 0) { 3417 : /* allow missing content files, but not any other kind of error */ 3418 1 : if (errno != ENOENT) { 3419 : /* LCOV_EXCL_START */ @@ -3488,7 +3488,7 @@ 3426 1 : state->need_write = 1; 3427 : } else { 3428 : /* if the size is different */ - 3429 1404 : if (other_st.st_size != st.st_size) { + 3429 1418 : if (other_st.st_size != st.st_size) { 3430 39 : log_fatal("WARNING! Content files '%s' and '%s' have a different size!\n", path, other_path); 3431 39 : log_fatal("Likely one of the two is broken!\n"); 3432 : @@ -3498,28 +3498,28 @@ 3436 : } 3437 : 3438 : /* next content file */ - 3439 1405 : node = node->next; + 3439 1419 : node = node->next; 3440 : } 3441 : 3442 : /* start with a undefined default. */ 3443 : /* it's for compatibility with version 1.0 where MD5 was implicit. */ - 3444 243 : state->hash = HASH_UNDEFINED; + 3444 245 : state->hash = HASH_UNDEFINED; 3445 : 3446 : /* start with a zero seed, it was the default in old versions */ - 3447 243 : memset(state->hashseed, 0, HASH_SIZE); + 3447 245 : memset(state->hashseed, 0, HASH_SIZE); 3448 : 3449 : /* previous hash, start with an undefined value */ - 3450 243 : state->prevhash = HASH_UNDEFINED; + 3450 245 : state->prevhash = HASH_UNDEFINED; 3451 : 3452 : /* intentionally not set the prevhashseed, if used valgrind will warn about it */ 3453 : 3454 : /* get the first char to detect the file type */ - 3455 243 : c = sgetc(f); - 3456 243 : sungetc(c, f); + 3455 245 : c = sgetc(f); + 3456 245 : sungetc(c, f); 3457 : 3458 : /* guess the file type from the first char */ - 3459 243 : if (c == 'S') { - 3460 243 : state_read_content(state, path, f); + 3459 245 : if (c == 'S') { + 3460 245 : state_read_content(state, path, f); 3461 : } else { 3462 : /* LCOV_EXCL_START */ 3463 : log_fatal("From SnapRAID v9.0 the text content file is not supported anymore.\n"); @@ -3528,9 +3528,9 @@ 3466 : /* LCOV_EXCL_STOP */ 3467 : } 3468 : - 3469 242 : sclose(f); + 3469 244 : sclose(f); 3470 : - 3471 242 : if (state->hash == HASH_UNDEFINED) { + 3471 244 : if (state->hash == HASH_UNDEFINED) { 3472 : /* LCOV_EXCL_START */ 3473 : log_fatal("The checksum to use is not specified.\n"); 3474 : log_fatal("This happens because you are likely upgrading from SnapRAID 1.0.\n"); @@ -3541,12 +3541,12 @@ 3479 : } 3480 : 3481 : /* update the mapping */ - 3482 242 : state_map(state); + 3482 244 : state_map(state); 3483 : - 3484 242 : state_content_check(state, path); + 3484 244 : state_content_check(state, path); 3485 : 3486 : /* mark that we read the content file, and it passed all the checks */ - 3487 242 : state->checked_read = 1; + 3487 244 : state->checked_read = 1; 3488 : } 3489 : 3490 : struct state_verify_thread_context { @@ -3562,15 +3562,15 @@ 3500 : STREAM* f; 3501 : }; 3502 : - 3503 990 : static void* state_verify_thread(void* arg) + 3503 1011 : static void* state_verify_thread(void* arg) 3504 : { - 3505 990 : struct state_verify_thread_context* context = arg; - 3506 990 : STREAM* f = context->f; + 3505 1011 : struct state_verify_thread_context* context = arg; + 3506 1011 : STREAM* f = context->f; 3507 : unsigned char buf[4]; 3508 : uint32_t crc_stored; 3509 : uint32_t crc_computed; 3510 : - 3511 990 : if (sdeplete(f, buf) != 0) { + 3511 1011 : if (sdeplete(f, buf) != 0) { 3512 : /* LCOV_EXCL_START */ 3513 : log_fatal("Error flushing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); 3514 : return context; @@ -3578,9 +3578,9 @@ 3516 : } 3517 : 3518 : /* get the stored crc from the last four bytes */ - 3519 990 : crc_stored = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; + 3519 1011 : crc_stored = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; 3520 : - 3521 990 : if (crc_stored != context->crc) { + 3521 1011 : if (crc_stored != context->crc) { 3522 : /* LCOV_EXCL_START */ 3523 : log_fatal("DANGER! Wrong stored CRC in '%s'\n", serrorfile(f)); 3524 : return context; @@ -3588,40 +3588,40 @@ 3526 : } 3527 : 3528 : /* get the computed crc */ - 3529 990 : crc_computed = scrc(f); + 3529 1011 : crc_computed = scrc(f); 3530 : 3531 : /* adjust the stored crc to include itself */ - 3532 990 : crc_stored = crc32c(crc_stored, buf, 4); + 3532 1011 : crc_stored = crc32c(crc_stored, buf, 4); 3533 : - 3534 990 : if (crc_computed != crc_stored) { + 3534 1011 : if (crc_computed != crc_stored) { 3535 : /* LCOV_EXCL_START */ 3536 : log_fatal("DANGER! Wrong file CRC in '%s'\n", serrorfile(f)); 3537 : return context; 3538 : /* LCOV_EXCL_STOP */ 3539 : } 3540 : - 3541 990 : return 0; + 3541 1011 : return 0; 3542 : } 3543 : - 3544 145 : static void state_verify_content(struct snapraid_state* state, uint32_t crc) + 3544 148 : static void state_verify_content(struct snapraid_state* state, uint32_t crc) 3545 : { 3546 : tommy_node* i; 3547 : int fail; 3548 : 3549 : /* start all reading threads */ - 3550 145 : i = tommy_list_head(&state->contentlist); - 3551 1280 : while (i) { - 3552 990 : struct snapraid_content* content = i->data; + 3550 148 : i = tommy_list_head(&state->contentlist); + 3551 1307 : while (i) { + 3552 1011 : struct snapraid_content* content = i->data; 3553 : struct state_verify_thread_context* context; 3554 : char tmp[PATH_MAX]; 3555 : STREAM* f; 3556 : - 3557 990 : msg_progress("Verifying %s...\n", content->content); + 3557 1011 : msg_progress("Verifying %s...\n", content->content); 3558 : - 3559 990 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); + 3559 1011 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); 3560 : - 3561 990 : f = sopen_read(tmp); - 3562 990 : if (f == 0) { + 3561 1011 : f = sopen_read(tmp); + 3562 1011 : if (f == 0) { 3563 : /* LCOV_EXCL_START */ 3564 : log_fatal("Error reopening the content file '%s'. %s.\n", tmp, strerror(errno)); 3565 : exit(EXIT_FAILURE); @@ -3629,17 +3629,17 @@ 3567 : } 3568 : 3569 : /* allocate the thread context */ - 3570 990 : context = malloc_nofail(sizeof(struct state_verify_thread_context)); - 3571 990 : content->context = context; + 3570 1011 : context = malloc_nofail(sizeof(struct state_verify_thread_context)); + 3571 1011 : content->context = context; 3572 : 3573 : /* initialize */ - 3574 990 : context->state = state; - 3575 990 : context->content = content; - 3576 990 : context->crc = crc; - 3577 990 : context->f = f; + 3574 1011 : context->state = state; + 3575 1011 : context->content = content; + 3576 1011 : context->crc = crc; + 3577 1011 : context->f = f; 3578 : 3579 : #if HAVE_MT_VERIFY - 3580 990 : if (pthread_create(&context->thread, 0, state_verify_thread, context) != 0) { + 3580 1011 : if (pthread_create(&context->thread, 0, state_verify_thread, context) != 0) { 3581 : /* LCOV_EXCL_START */ 3582 : log_fatal("Failed to create thread.\n"); 3583 : exit(EXIT_FAILURE); @@ -3649,19 +3649,19 @@ 3587 : context->retval = state_verify_thread(context); 3588 : #endif 3589 : - 3590 990 : i = i->next; + 3590 1011 : i = i->next; 3591 : } 3592 : 3593 : /* join all thread */ - 3594 145 : fail = 0; - 3595 145 : i = tommy_list_head(&state->contentlist); - 3596 1280 : while (i) { - 3597 990 : struct snapraid_content* content = i->data; - 3598 990 : struct state_verify_thread_context* context = content->context; + 3594 148 : fail = 0; + 3595 148 : i = tommy_list_head(&state->contentlist); + 3596 1307 : while (i) { + 3597 1011 : struct snapraid_content* content = i->data; + 3598 1011 : struct state_verify_thread_context* context = content->context; 3599 : void* retval; 3600 : 3601 : #if HAVE_MT_VERIFY - 3602 990 : if (pthread_join(context->thread, &retval) != 0) { + 3602 1011 : if (pthread_join(context->thread, &retval) != 0) { 3603 : /* LCOV_EXCL_START */ 3604 : log_fatal("Failed to join thread.\n"); 3605 : exit(EXIT_FAILURE); @@ -3670,14 +3670,14 @@ 3608 : #else 3609 : retval = context->retval; 3610 : #endif - 3611 990 : if (retval) { + 3611 1011 : if (retval) { 3612 : /* LCOV_EXCL_START */ 3613 : fail = 1; 3614 : /* LCOV_EXCL_STOP */ 3615 : } else { - 3616 990 : STREAM* f = context->f; + 3616 1011 : STREAM* f = context->f; 3617 : - 3618 990 : if (sclose(f) != 0) { + 3618 1011 : if (sclose(f) != 0) { 3619 : /* LCOV_EXCL_START */ 3620 : log_fatal("Error closing the content file. %s.\n", strerror(errno)); 3621 : exit(EXIT_FAILURE); @@ -3685,57 +3685,57 @@ 3623 : } 3624 : } 3625 : - 3626 990 : free(context); + 3626 1011 : free(context); 3627 : - 3628 990 : i = i->next; + 3628 1011 : i = i->next; 3629 : } 3630 : 3631 : /* abort on failure */ - 3632 145 : if (fail) { + 3632 148 : if (fail) { 3633 : /* LCOV_EXCL_START */ 3634 : exit(EXIT_FAILURE); 3635 : /* LCOV_EXCL_STOP */ 3636 : } - 3637 145 : } + 3637 148 : } 3638 : - 3639 145 : static void state_rename_content(struct snapraid_state* state) + 3639 148 : static void state_rename_content(struct snapraid_state* state) 3640 : { 3641 : tommy_node* i; 3642 : - 3643 145 : i = tommy_list_head(&state->contentlist); - 3644 1280 : while (i) { - 3645 990 : struct snapraid_content* content = i->data; + 3643 148 : i = tommy_list_head(&state->contentlist); + 3644 1307 : while (i) { + 3645 1011 : struct snapraid_content* content = i->data; 3646 : char tmp[PATH_MAX]; 3647 : 3648 : /* now renames the just written copy with the correct name */ - 3649 990 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - 3650 990 : if (rename(tmp, content->content) != 0) { + 3649 1011 : pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); + 3650 1011 : if (rename(tmp, content->content) != 0) { 3651 : /* LCOV_EXCL_START */ 3652 : log_fatal("Error renaming the content file '%s' to '%s' in rename(). %s.\n", tmp, content->content, strerror(errno)); 3653 : exit(EXIT_FAILURE); 3654 : /* LCOV_EXCL_STOP */ 3655 : } 3656 : - 3657 990 : i = i->next; + 3657 1011 : i = i->next; 3658 : } - 3659 145 : } + 3659 148 : } 3660 : - 3661 145 : void state_write(struct snapraid_state* state) + 3661 148 : void state_write(struct snapraid_state* state) 3662 : { 3663 : uint32_t crc; 3664 : 3665 : /* write all the content files */ - 3666 145 : state_write_content(state, &crc); + 3666 148 : state_write_content(state, &crc); 3667 : 3668 : /* verify the just written files */ - 3669 145 : state_verify_content(state, crc); + 3669 148 : state_verify_content(state, crc); 3670 : 3671 : /* rename the new files, over the old ones */ - 3672 145 : state_rename_content(state); + 3672 148 : state_rename_content(state); 3673 : - 3674 145 : state->need_write = 0; /* no write needed anymore */ - 3675 145 : state->checked_read = 0; /* what we wrote is not checked in read */ - 3676 145 : } + 3674 148 : state->need_write = 0; /* no write needed anymore */ + 3675 148 : state->checked_read = 0; /* what we wrote is not checked in read */ + 3676 148 : } 3677 : 3678 122 : void state_skip(struct snapraid_state* state) 3679 : { @@ -3750,9 +3750,9 @@ 3688 727 : continue; 3689 : 3690 : /* for each file */ - 3691 1884 : for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) { - 3692 1883 : struct snapraid_file* file = j->data; - 3693 1883 : file_flag_set(file, FILE_IS_EXCLUDED); + 3691 1885 : for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) { + 3692 1884 : struct snapraid_file* file = j->data; + 3693 1884 : file_flag_set(file, FILE_IS_EXCLUDED); 3694 : } 3695 : 3696 : /* for each link */ @@ -3803,15 +3803,15 @@ 3741 12 : msg_progress("Scanning disk %s...\n", disk->name); 3742 : 3743 : /* for each file */ - 3744 133917 : for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) { - 3745 133863 : struct snapraid_file* file = j->data; + 3744 133944 : for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) { + 3745 133890 : struct snapraid_file* file = j->data; 3746 : - 3747 133863 : if (filter_path(filterlist_disk, 0, disk->name, file->sub) != 0 - 3748 80965 : || filter_path(filterlist_file, 0, disk->name, file->sub) != 0 - 3749 78124 : || filter_existence(filter_missing, disk->dir, file->sub) != 0 - 3750 38732 : || filter_correctness(filter_error, &state->infoarr, disk, file) != 0 + 3747 133890 : if (filter_path(filterlist_disk, 0, disk->name, file->sub) != 0 + 3748 80982 : || filter_path(filterlist_file, 0, disk->name, file->sub) != 0 + 3749 78138 : || filter_existence(filter_missing, disk->dir, file->sub) != 0 + 3750 38698 : || filter_correctness(filter_error, &state->infoarr, disk, file) != 0 3751 : ) { - 3752 109341 : file_flag_set(file, FILE_IS_EXCLUDED); + 3752 109404 : file_flag_set(file, FILE_IS_EXCLUDED); 3753 : } 3754 : } 3755 : @@ -3861,25 +3861,25 @@ 3799 : } 3800 : } 3801 : - 3802 214 : int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax) + 3802 216 : int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax) 3803 : { 3804 : time_t now; 3805 : - 3806 214 : if (state->opt.gui) { + 3806 216 : if (state->opt.gui) { 3807 5 : log_tag("run:begin:%u:%u:%u\n", blockstart, blockmax, countmax); 3808 5 : log_flush(); 3809 : } 3810 : - 3811 214 : now = time(0); + 3811 216 : now = time(0); 3812 : - 3813 214 : state->progress_whole_start = now; + 3813 216 : state->progress_whole_start = now; 3814 : - 3815 214 : state->progress_tick = 0; - 3816 214 : state->progress_ptr = 0; - 3817 214 : state->progress_wasted = 0; + 3815 216 : state->progress_tick = 0; + 3816 216 : state->progress_ptr = 0; + 3817 216 : state->progress_wasted = 0; 3818 : 3819 : /* stop if requested */ - 3820 214 : if (global_interrupt) { + 3820 216 : if (global_interrupt) { 3821 : /* LCOV_EXCL_START */ 3822 : if (!state->opt.gui) { 3823 : msg_status("Not starting for interruption\n"); @@ -3890,33 +3890,33 @@ 3828 : /* LCOV_EXCL_STOP */ 3829 : } 3830 : - 3831 214 : return 1; + 3831 216 : return 1; 3832 : } 3833 : - 3834 214 : void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize) + 3834 216 : void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize) 3835 : { - 3836 214 : if (state->opt.gui) { + 3836 216 : if (state->opt.gui) { 3837 5 : log_tag("run:end\n"); 3838 5 : log_flush(); - 3839 209 : } else if (countmax == 0) { - 3840 18 : msg_status("Nothing to do\n"); + 3839 211 : } else if (countmax == 0) { + 3840 19 : msg_status("Nothing to do\n"); 3841 : } else { 3842 : time_t now; 3843 : time_t elapsed; 3844 : - 3845 191 : unsigned countsize_MB = (countsize + MEGA - 1) / MEGA; + 3845 192 : unsigned countsize_MB = (countsize + MEGA - 1) / MEGA; 3846 : - 3847 191 : now = time(0); + 3847 192 : now = time(0); 3848 : - 3849 191 : elapsed = now - state->progress_whole_start - state->progress_wasted; + 3849 192 : elapsed = now - state->progress_whole_start - state->progress_wasted; 3850 : - 3851 191 : msg_bar("%u%% completed, %u MB processed", countpos * 100 / countmax, countsize_MB); - 3852 191 : if (elapsed >= 60) + 3851 192 : msg_bar("%u%% completed, %u MB processed", countpos * 100 / countmax, countsize_MB); + 3852 192 : if (elapsed >= 60) 3853 0 : msg_bar(" in %u:%02u", (unsigned)(elapsed / 3600), (unsigned)((elapsed % 3600) / 60)); - 3854 191 : msg_bar("\n"); - 3855 191 : msg_flush(); + 3854 192 : msg_bar("\n"); + 3855 192 : msg_flush(); 3856 : } - 3857 214 : } + 3857 216 : } 3858 : 3859 1 : void state_progress_stop(struct snapraid_state* state) 3860 : { @@ -3948,42 +3948,42 @@ 3886 : 3887 : #define PROGRESS_CLEAR " " 3888 : - 3889 1048979 : int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) + 3889 1049984 : int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) 3890 : { 3891 : time_t now; 3892 : int pred; 3893 : - 3894 1048979 : now = time(0); + 3894 1049984 : now = time(0); 3895 : 3896 : /* previous position */ - 3897 1048979 : pred = state->progress_ptr + PROGRESS_MAX - 1; - 3898 1048979 : if (pred >= PROGRESS_MAX) - 3899 1048786 : pred -= PROGRESS_MAX; + 3897 1049984 : pred = state->progress_ptr + PROGRESS_MAX - 1; + 3898 1049984 : if (pred >= PROGRESS_MAX) + 3899 1049790 : pred -= PROGRESS_MAX; 3900 : 3901 : /* if the previous measure is different */ - 3902 1048979 : if (state->progress_tick == 0 - 3903 1048786 : || state->progress_time[pred] != now + 3902 1049984 : if (state->progress_tick == 0 + 3903 1049790 : || state->progress_time[pred] != now 3904 : ) { 3905 : uint64_t tick_total; 3906 : uint64_t tick_cpu; 3907 : time_t elapsed; - 3908 257 : unsigned out_perc = 0; - 3909 257 : unsigned out_speed = 0; - 3910 257 : unsigned out_cpu = 0; - 3911 257 : unsigned out_eta = 0; + 3908 274 : unsigned out_perc = 0; + 3909 274 : unsigned out_speed = 0; + 3910 274 : unsigned out_cpu = 0; + 3911 274 : unsigned out_eta = 0; 3912 : - 3913 257 : tick_total = state->tick_cpu + state->tick_io; - 3914 257 : tick_cpu = state->tick_cpu; - 3915 257 : elapsed = now - state->progress_whole_start - state->progress_wasted; + 3913 274 : tick_total = state->tick_cpu + state->tick_io; + 3914 274 : tick_cpu = state->tick_cpu; + 3915 274 : elapsed = now - state->progress_whole_start - state->progress_wasted; 3916 : 3917 : /* completion percentage */ - 3918 257 : if (countmax) - 3919 257 : out_perc = countpos * 100 / countmax; + 3918 274 : if (countmax) + 3919 274 : out_perc = countpos * 100 / countmax; 3920 : 3921 : /* if we have at least 5 measures */ - 3922 257 : if (state->progress_tick >= 5 + 3922 274 : if (state->progress_tick >= 5 3923 : /* or if we are running in test mode, with at least one measure */ - 3924 257 : || (state->opt.force_progress && state->progress_tick >= 1) + 3924 273 : || (state->opt.force_progress && state->progress_tick >= 1) 3925 : ) { 3926 : int oldest; 3927 : int past; @@ -3994,76 +3994,76 @@ 3932 : uint64_t delta_tick_cpu; 3933 : 3934 : /* number of past measures */ - 3935 63 : past = state->progress_tick; + 3935 79 : past = state->progress_tick; 3936 : 3937 : /* drop the oldest ones, to promptly */ 3938 : /* skip the startup phase */ - 3939 63 : past -= past / 5; + 3939 79 : past -= past / 5; 3940 : 3941 : /* check how much we can go in the past */ - 3942 63 : if (past >= PROGRESS_MAX) { + 3942 79 : if (past >= PROGRESS_MAX) { 3943 : /* the vector is filled, so we are already in position */ 3944 : /* to get the possible oldest one */ 3945 0 : oldest = state->progress_ptr; 3946 : } else { 3947 : /* go backward the number of positions selected */ - 3948 63 : oldest = state->progress_ptr + PROGRESS_MAX - past; - 3949 63 : if (oldest >= PROGRESS_MAX) - 3950 63 : oldest -= PROGRESS_MAX; + 3948 79 : oldest = state->progress_ptr + PROGRESS_MAX - past; + 3949 79 : if (oldest >= PROGRESS_MAX) + 3950 79 : oldest -= PROGRESS_MAX; 3951 : } 3952 : - 3953 63 : delta_time = now - state->progress_time[oldest]; - 3954 63 : delta_pos = countpos - state->progress_pos[oldest]; - 3955 63 : delta_size = countsize - state->progress_size[oldest]; - 3956 63 : delta_tick_total = tick_total - state->progress_tick_total[oldest]; - 3957 63 : delta_tick_cpu = tick_cpu - state->progress_tick_cpu[oldest]; + 3953 79 : delta_time = now - state->progress_time[oldest]; + 3954 79 : delta_pos = countpos - state->progress_pos[oldest]; + 3955 79 : delta_size = countsize - state->progress_size[oldest]; + 3956 79 : delta_tick_total = tick_total - state->progress_tick_total[oldest]; + 3957 79 : delta_tick_cpu = tick_cpu - state->progress_tick_cpu[oldest]; 3958 : - 3959 : /* estimate the speed in MiB/s */ - 3960 63 : if (delta_time != 0) - 3961 63 : out_speed = (unsigned)(delta_size / MEGA / delta_time); + 3959 : /* estimate the speed in MB/s */ + 3960 79 : if (delta_time != 0) + 3961 79 : out_speed = (unsigned)(delta_size / MEGA / delta_time); 3962 : 3963 : /* estimate the cpu usage percentage */ - 3964 63 : if (delta_tick_total != 0) + 3964 79 : if (delta_tick_total != 0) 3965 9 : out_cpu = (unsigned)(delta_tick_cpu * 100U / delta_tick_total); 3966 : 3967 : /* estimate the remaining time in minutes */ - 3968 63 : if (delta_pos != 0) - 3969 63 : out_eta = (countmax - countpos) * delta_time / (60 * delta_pos); + 3968 79 : if (delta_pos != 0) + 3969 79 : out_eta = (countmax - countpos) * delta_time / (60 * delta_pos); 3970 : } 3971 : - 3972 257 : if (state->opt.gui) { + 3972 274 : if (state->opt.gui) { 3973 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); 3974 7 : log_flush(); 3975 : } else { - 3976 250 : msg_bar("%u%%, %u MiB", out_perc, (unsigned)(countsize / MEGA)); - 3977 250 : if (out_speed) - 3978 49 : msg_bar(", %u MiB/s", out_speed); - 3979 250 : if (out_cpu) + 3976 267 : msg_bar("%u%%, %u MB", out_perc, (unsigned)(countsize / MEGA)); + 3977 267 : if (out_speed) + 3978 64 : msg_bar(", %u MB/s", out_speed); + 3979 267 : if (out_cpu) 3980 9 : msg_bar(", CPU %u%%", out_cpu); - 3981 250 : if (out_eta) - 3982 4 : msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); - 3983 250 : msg_bar("%s\r", PROGRESS_CLEAR); - 3984 250 : msg_flush(); + 3981 267 : if (out_eta) + 3982 2 : msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); + 3983 267 : msg_bar("%s\r", PROGRESS_CLEAR); + 3984 267 : msg_flush(); 3985 : } 3986 : 3987 : /* store the new measure */ - 3988 257 : state->progress_time[state->progress_ptr] = now; - 3989 257 : state->progress_pos[state->progress_ptr] = countpos; - 3990 257 : state->progress_size[state->progress_ptr] = countsize; - 3991 257 : state->progress_tick_cpu[state->progress_ptr] = tick_cpu; - 3992 257 : state->progress_tick_total[state->progress_ptr] = tick_total; + 3988 274 : state->progress_time[state->progress_ptr] = now; + 3989 274 : state->progress_pos[state->progress_ptr] = countpos; + 3990 274 : state->progress_size[state->progress_ptr] = countsize; + 3991 274 : state->progress_tick_cpu[state->progress_ptr] = tick_cpu; + 3992 274 : state->progress_tick_total[state->progress_ptr] = tick_total; 3993 : 3994 : /* next position */ - 3995 257 : ++state->progress_ptr; - 3996 257 : if (state->progress_ptr >= PROGRESS_MAX) + 3995 274 : ++state->progress_ptr; + 3996 274 : if (state->progress_ptr >= PROGRESS_MAX) 3997 0 : state->progress_ptr -= PROGRESS_MAX; 3998 : 3999 : /* one more measure */ - 4000 257 : ++state->progress_tick; + 4000 274 : ++state->progress_tick; 4001 : } 4002 : 4003 : /* stop if requested */ - 4004 1048979 : if (global_interrupt) { + 4004 1049984 : if (global_interrupt) { 4005 : /* LCOV_EXCL_START */ 4006 : if (!state->opt.gui) { 4007 : log_fatal("\n"); @@ -4075,34 +4075,34 @@ 4013 : /* LCOV_EXCL_STOP */ 4014 : } 4015 : - 4016 1048979 : return 0; + 4016 1049984 : return 0; 4017 : } 4018 : - 4019 89 : void state_usage_print(struct snapraid_state* state) + 4019 91 : void state_usage_print(struct snapraid_state* state) 4020 : { 4021 : uint64_t tick_total; 4022 : uint64_t tick_max; 4023 : tommy_node* i; 4024 : unsigned l; 4025 : - 4026 89 : tick_max = 0; - 4027 89 : tick_total = 0; - 4028 621 : for (i = state->disklist; i != 0; i = i->next) { - 4029 532 : struct snapraid_disk* disk = i->data; - 4030 532 : tick_total += disk->tick; - 4031 532 : if (disk->tick > tick_max) - 4032 100 : tick_max = disk->tick; + 4026 91 : tick_max = 0; + 4027 91 : tick_total = 0; + 4028 635 : for (i = state->disklist; i != 0; i = i->next) { + 4029 544 : struct snapraid_disk* disk = i->data; + 4030 544 : tick_total += disk->tick; + 4031 544 : if (disk->tick > tick_max) + 4032 96 : tick_max = disk->tick; 4033 : } - 4034 608 : for (l = 0; l < state->level; ++l) { - 4035 519 : tick_total += state->parity[l].tick; - 4036 519 : if (state->parity[l].tick > tick_max) - 4037 19 : tick_max = state->parity[l].tick; + 4034 622 : for (l = 0; l < state->level; ++l) { + 4035 531 : tick_total += state->parity[l].tick; + 4036 531 : if (state->parity[l].tick > tick_max) + 4037 20 : tick_max = state->parity[l].tick; 4038 : } 4039 : - 4040 89 : if (!tick_total) - 4041 107 : return; + 4040 91 : if (!tick_total) + 4041 110 : return; 4042 : - 4043 71 : if (msg_level >= MSG_PROGRESS) { + 4043 72 : if (msg_level >= MSG_PROGRESS) { 4044 : /* here we don't use msg_progress() because it doesn't allow partial output */ 4045 1 : printf("Time for disk:"); 4046 7 : for (i = state->disklist; i != 0; i = i->next) { @@ -4127,22 +4127,22 @@ 4065 : } 4066 : } 4067 : - 4068 474 : void state_fscheck(struct snapraid_state* state, const char* ope) + 4068 481 : void state_fscheck(struct snapraid_state* state, const char* ope) 4069 : { 4070 : tommy_node* i; 4071 : 4072 : /* check the file-system on all disks */ - 4073 3312 : for (i = state->disklist; i != 0; i = i->next) { - 4074 2838 : struct snapraid_disk* disk = i->data; + 4073 3361 : for (i = state->disklist; i != 0; i = i->next) { + 4074 2880 : struct snapraid_disk* disk = i->data; 4075 : - 4076 2838 : if (fs_check(disk) != 0) { + 4076 2880 : if (fs_check(disk) != 0) { 4077 : /* LCOV_EXCL_START */ 4078 : log_fatal("Internal inconsistency in file-system for disk '%s' %s\n", disk->name, ope); 4079 : os_abort(); 4080 : /* LCOV_EXCL_STOP */ 4081 : } 4082 : } - 4083 474 : } + 4083 481 : } 4084 : 4085 1 : void generate_configuration(const char* path) 4086 : { diff --git a/cov/cmdline/state.h.func-sort-c.html b/cov/cmdline/state.h.func-sort-c.html index 220cc8c0..d72756fc 100644 --- a/cov/cmdline/state.h.func-sort-c.html +++ b/cov/cmdline/state.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,19 +61,19 @@ state_usage_cpu - 833206 + 833647 state_usage_parity - 706913 + 707815 state_usage_disk - 673880 + 674079 state_usage_waste - 97 + 99
diff --git a/cov/cmdline/state.h.func.html b/cov/cmdline/state.h.func.html index 2c89482c..dccc9b37 100644 --- a/cov/cmdline/state.h.func.html +++ b/cov/cmdline/state.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,19 +61,19 @@ state_usage_cpu - 833206 + 833647 state_usage_disk - 673880 + 674079 state_usage_parity - 706913 + 707815 state_usage_waste - 97 + 99
diff --git a/cov/cmdline/state.h.gcov.html b/cov/cmdline/state.h.gcov.html index 6a6fac5f..65b28ec9 100644 --- a/cov/cmdline/state.h.gcov.html +++ b/cov/cmdline/state.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -388,58 +388,58 @@ 326 : /** 327 : * Set the usage time as wasted one not counted. 328 : */ - 329 97 : static inline void state_usage_waste(struct snapraid_state* state) + 329 99 : static inline void state_usage_waste(struct snapraid_state* state) 330 : { - 331 97 : uint64_t now = tick(); + 331 99 : uint64_t now = tick(); 332 : - 333 97 : state->tick_last = now; - 334 97 : } + 333 99 : state->tick_last = now; + 334 99 : } 335 : 336 : /** 337 : * Set the usage time for CPU. 338 : */ - 339 833206 : static inline void state_usage_cpu(struct snapraid_state* state) + 339 833647 : static inline void state_usage_cpu(struct snapraid_state* state) 340 : { - 341 833206 : uint64_t now = tick(); - 342 833206 : uint64_t delta = now - state->tick_last; + 341 833647 : uint64_t now = tick(); + 342 833647 : uint64_t delta = now - state->tick_last; 343 : 344 : /* increment the time spent in computations */ - 345 833206 : state->tick_cpu += delta; + 345 833647 : state->tick_cpu += delta; 346 : - 347 833206 : state->tick_last = now; - 348 833206 : } + 347 833647 : state->tick_last = now; + 348 833647 : } 349 : 350 : /** 351 : * Set the usage time for data disk. 352 : */ - 353 673880 : static inline void state_usage_disk(struct snapraid_state* state, struct snapraid_disk* disk) + 353 674079 : static inline void state_usage_disk(struct snapraid_state* state, struct snapraid_disk* disk) 354 : { - 355 673880 : uint64_t now = tick(); - 356 673880 : uint64_t delta = now - state->tick_last; + 355 674079 : uint64_t now = tick(); + 356 674079 : uint64_t delta = now - state->tick_last; 357 : 358 : /* increment the time spent in the data disk */ - 359 673880 : disk->tick += delta; - 360 673880 : state->tick_io += delta; + 359 674079 : disk->tick += delta; + 360 674079 : state->tick_io += delta; 361 : - 362 673880 : state->tick_last = now; - 363 673880 : } + 362 674079 : state->tick_last = now; + 363 674079 : } 364 : 365 : /** 366 : * Set the usage time for parity disk. 367 : */ - 368 706913 : static inline void state_usage_parity(struct snapraid_state* state, unsigned level) + 368 707815 : static inline void state_usage_parity(struct snapraid_state* state, unsigned level) 369 : { - 370 706913 : uint64_t now = tick(); - 371 706913 : uint64_t delta = now - state->tick_last; + 370 707815 : uint64_t now = tick(); + 371 707815 : uint64_t delta = now - state->tick_last; 372 : - 373 706913 : assert(level < LEV_MAX); + 373 707815 : assert(level < LEV_MAX); 374 : 375 : /* increment the time spent in the parity disk */ - 376 706913 : state->parity[level].tick += delta; - 377 706913 : state->tick_io += delta; + 376 707815 : state->parity[level].tick += delta; + 377 707815 : state->tick_io += delta; 378 : - 379 706913 : state->tick_last = now; - 380 706913 : } + 379 707815 : state->tick_last = now; + 380 707815 : } 381 : 382 : /** 383 : * Print the stats of the usage time. diff --git a/cov/cmdline/status.c.func-sort-c.html b/cov/cmdline/status.c.func-sort-c.html index 1c2639e5..2dc5ee3b 100644 --- a/cov/cmdline/status.c.func-sort-c.html +++ b/cov/cmdline/status.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 diff --git a/cov/cmdline/status.c.func.html b/cov/cmdline/status.c.func.html index 4558d05e..76b95877 100644 --- a/cov/cmdline/status.c.func.html +++ b/cov/cmdline/status.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 diff --git a/cov/cmdline/status.c.gcov.html b/cov/cmdline/status.c.gcov.html index 6c2b85f8..a64881c8 100644 --- a/cov/cmdline/status.c.gcov.html +++ b/cov/cmdline/status.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -195,50 +195,50 @@ 133 : 134 : /* for each file in the disk */ 135 84 : node = disk->filelist; - 136 95666 : while (node) { + 136 95690 : while (node) { 137 : struct snapraid_file* file; 138 : - 139 95498 : file = node->data; - 140 95498 : node = node->next; /* next node */ + 139 95522 : file = node->data; + 140 95522 : node = node->next; /* next node */ 141 : 142 : /* check fragmentation */ - 143 95498 : if (file->blockmax != 0) { + 143 95522 : if (file->blockmax != 0) { 144 : block_off_t prev_pos; 145 : block_off_t last_pos; 146 : int fragmented; 147 : - 148 95360 : fragmented = 0; - 149 95360 : prev_pos = fs_file2par_get(disk, file, 0); - 150 235447 : for (j = 1; j < file->blockmax; ++j) { - 151 140087 : block_off_t parity_pos = fs_file2par_get(disk, file, j); - 152 140087 : if (prev_pos + 1 != parity_pos) { + 148 95384 : fragmented = 0; + 149 95384 : prev_pos = fs_file2par_get(disk, file, 0); + 150 235639 : for (j = 1; j < file->blockmax; ++j) { + 151 140255 : block_off_t parity_pos = fs_file2par_get(disk, file, j); + 152 140255 : if (prev_pos + 1 != parity_pos) { 153 698 : fragmented = 1; 154 698 : ++extra_fragment; 155 698 : ++disk_extra_fragment; 156 : } - 157 140087 : prev_pos = parity_pos; + 157 140255 : prev_pos = parity_pos; 158 : } 159 : 160 : /* keep track of latest block used */ - 161 95360 : last_pos = fs_file2par_get(disk, file, file->blockmax - 1); - 162 95360 : if (last_pos > disk_block_latest_used) { - 163 92502 : disk_block_latest_used = last_pos; + 161 95384 : last_pos = fs_file2par_get(disk, file, file->blockmax - 1); + 162 95384 : if (last_pos > disk_block_latest_used) { + 163 92527 : disk_block_latest_used = last_pos; 164 : } 165 : - 166 95360 : if (fragmented) { + 166 95384 : if (fragmented) { 167 582 : ++file_fragmented; 168 582 : ++disk_file_fragmented; 169 : } 170 : - 171 95360 : disk_block_count += file->blockmax; + 171 95384 : disk_block_count += file->blockmax; 172 : } 173 : 174 : /* count files */ - 175 95498 : ++file_count; - 176 95498 : ++disk_file_count; - 177 95498 : file_size += file->size; - 178 95498 : file_block_count += file->blockmax; - 179 95498 : disk_file_size += file->size; + 175 95522 : ++file_count; + 176 95522 : ++disk_file_count; + 177 95522 : file_size += file->size; + 178 95522 : file_block_count += file->blockmax; + 179 95522 : disk_file_size += file->size; 180 : } 181 : 182 84 : if (disk->free_blocks != 0) @@ -338,57 +338,57 @@ 276 14 : unsynced_blocks = 0; 277 14 : unscrubbed_blocks = 0; 278 14 : log_tag("block_count:%u\n", blockmax); - 279 39702 : for (i = 0; i < blockmax; ++i) { + 279 39766 : for (i = 0; i < blockmax; ++i) { 280 : int one_invalid; 281 : int one_valid; 282 : - 283 39688 : snapraid_info info = info_get(&state->infoarr, i); + 283 39752 : snapraid_info info = info_get(&state->infoarr, i); 284 : 285 : /* for each disk */ - 286 39688 : one_invalid = 0; - 287 39688 : one_valid = 0; - 288 277816 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { - 289 238128 : struct snapraid_disk* disk = node_disk->data; - 290 238128 : struct snapraid_block* block = fs_par2block_get(disk, i); + 286 39752 : one_invalid = 0; + 287 39752 : one_valid = 0; + 288 278264 : for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) { + 289 238512 : struct snapraid_disk* disk = node_disk->data; + 290 238512 : struct snapraid_block* block = fs_par2block_get(disk, i); 291 : - 292 238128 : if (block_has_file(block)) - 293 235447 : one_valid = 1; - 294 238128 : if (block_has_invalid_parity(block)) + 292 238512 : if (block_has_file(block)) + 293 235639 : one_valid = 1; + 294 238512 : if (block_has_invalid_parity(block)) 295 0 : one_invalid = 1; 296 : } 297 : 298 : /* if both valid and invalid, we need to update */ - 299 39688 : if (one_invalid && one_valid) { + 299 39752 : if (one_invalid && one_valid) { 300 0 : ++unsynced_blocks; 301 : } 302 : 303 : /* skip unused blocks */ - 304 39688 : if (info != 0) { + 304 39752 : if (info != 0) { 305 : time_t scrub_time; 306 : - 307 39688 : if (info_get_bad(info)) { - 308 1771 : if (bad == 0) + 307 39752 : if (info_get_bad(info)) { + 308 1772 : if (bad == 0) 309 2 : bad_first = i; - 310 1771 : bad_last = i; - 311 1771 : ++bad; + 310 1772 : bad_last = i; + 311 1772 : ++bad; 312 : } 313 : - 314 39688 : if (info_get_rehash(info)) - 315 4603 : ++rehash; + 314 39752 : if (info_get_rehash(info)) + 315 4607 : ++rehash; 316 : - 317 39688 : scrub_time = info_get_time(info); + 317 39752 : scrub_time = info_get_time(info); 318 : - 319 39688 : if (info_get_justsynced(info)) { - 320 20419 : ++unscrubbed_blocks; + 319 39752 : if (info_get_justsynced(info)) { + 320 20460 : ++unscrubbed_blocks; 321 : 322 : /* mark the time as not scrubbed */ - 323 20419 : scrub_time |= TIME_NEW; + 323 20460 : scrub_time |= TIME_NEW; 324 : } 325 : - 326 39688 : timemap[count++] = scrub_time; + 326 39752 : timemap[count++] = scrub_time; 327 : } 328 : - 329 39688 : if (state->opt.gui) { + 329 39752 : if (state->opt.gui) { 330 0 : if (info != 0) 331 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" : ""); 332 : else @@ -414,16 +414,16 @@ 352 : /* output the info map */ 353 8 : i = 0; 354 8 : log_tag("info_count:%u\n", count); - 355 39 : while (i < count) { - 356 23 : unsigned j = i + 1; - 357 39711 : while (j < count && timemap[i] == timemap[j]) - 358 39665 : ++j; - 359 23 : if ((timemap[i] & TIME_NEW) == 0) { - 360 8 : log_tag("info_time:%" PRIu64 ":%u:scrubbed\n", (uint64_t)timemap[i], j - i); + 355 40 : while (i < count) { + 356 24 : unsigned j = i + 1; + 357 39776 : while (j < count && timemap[i] == timemap[j]) + 358 39728 : ++j; + 359 24 : if ((timemap[i] & TIME_NEW) == 0) { + 360 9 : log_tag("info_time:%" PRIu64 ":%u:scrubbed\n", (uint64_t)timemap[i], j - i); 361 : } else { 362 15 : log_tag("info_time:%" PRIu64 ":%u:new\n", (uint64_t)(timemap[i] & ~TIME_NEW), j - i); 363 : } - 364 23 : i = j; + 364 24 : i = j; 365 : } 366 : 367 8 : oldest = timemap[0]; @@ -444,12 +444,12 @@ 382 : 383 560 : step_scrubbed = 0; 384 560 : step_new = 0; - 385 40808 : while (barpos < count && timemap[barpos] <= limit) { - 386 39688 : if ((timemap[barpos] & TIME_NEW) != 0) - 387 20419 : ++step_new; + 385 40872 : while (barpos < count && timemap[barpos] <= limit) { + 386 39752 : if ((timemap[barpos] & TIME_NEW) != 0) + 387 20460 : ++step_new; 388 : else - 389 19269 : ++step_scrubbed; - 390 39688 : ++barpos; + 389 19292 : ++step_scrubbed; + 390 39752 : ++barpos; 391 : } 392 : 393 560 : if (step_new + step_scrubbed > barmax) @@ -478,20 +478,20 @@ 416 8400 : unsigned scrubbed = bar_scrubbed[x]; 417 : 418 8400 : if (both > pivot_upper) { - 419 171 : if (scrubbed > pivot_lower) - 420 75 : printf("*"); + 419 170 : if (scrubbed > pivot_lower) + 420 74 : printf("*"); 421 : else 422 96 : printf("o"); - 423 8229 : } else if (both > pivot_lower) { - 424 23 : if (scrubbed == both) - 425 8 : printf("*"); + 423 8230 : } else if (both > pivot_lower) { + 424 24 : if (scrubbed == both) + 425 9 : printf("*"); 426 : else 427 15 : printf("o"); 428 : } else { 429 8206 : if (y == GRAPH_ROW - 1) - 430 537 : printf("_"); + 430 536 : printf("_"); 431 : else - 432 7669 : printf(" "); + 432 7670 : printf(" "); 433 : } 434 : } 435 120 : printf("\n"); @@ -536,19 +536,19 @@ 474 : 475 : /* print some of the errors */ 476 2 : bad_print = 0; - 477 709 : for (i = 0; i < blockmax; ++i) { - 478 709 : snapraid_info info = info_get(&state->infoarr, i); + 477 723 : for (i = 0; i < blockmax; ++i) { + 478 723 : snapraid_info info = info_get(&state->infoarr, i); 479 : 480 : /* skip unused blocks */ - 481 709 : if (info == 0) + 481 723 : if (info == 0) 482 0 : continue; 483 : - 484 709 : if (info_get_bad(info)) { + 484 723 : if (info_get_bad(info)) { 485 202 : printf(" %u", i); 486 202 : ++bad_print; 487 : } 488 : - 489 709 : if (bad_print > 100) { + 489 723 : if (bad_print > 100) { 490 2 : printf(" and %u more...", bad - bad_print); 491 2 : break; 492 : } diff --git a/cov/cmdline/stream.c.func-sort-c.html b/cov/cmdline/stream.c.func-sort-c.html index 94e5987f..07d9b3af 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-01-09 + 2016-01-16 Functions: 27 @@ -61,107 +61,107 @@ swrite - 20661703 + 20473005 sgetb32 - 18259411 + 18262658 sread - 12515245 + 12521197 sgetb64 - 10605158 + 10607045 sputb32 - 9119259 + 9035051 sputb64 - 5293948 + 5244883 sgetbs - 3782241 + 3782904 sputbs - 1884788 + 1867379 sfill - 607118 + 607043 sgetc_uncached - 298684 + 298700 sflush - 39024 + 39014 sgettok - 7892 + 7960 sgetline - 5251 + 5297 sgetlasttok - 5217 + 5263 sclose - 1903 + 1931 sopen_read - 1794 + 1819 scrc - 1650 + 1676 sdeplete - 1119 + 1140 sopen_multi_file - 1118 + 1139 sgetble32 - 370 + 372 sgetu32 - 255 + 257 shandle - 243 + 245 scrc_stream - 161 + 164 sopen_multi_write - 161 + 164 sputble32 - 161 + 164 ssync - 145 + 148 stell diff --git a/cov/cmdline/stream.c.func.html b/cov/cmdline/stream.c.func.html index e0d1e567..0cf4de2f 100644 --- a/cov/cmdline/stream.c.func.html +++ b/cov/cmdline/stream.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 27 @@ -61,79 +61,79 @@ sclose - 1903 + 1931 scrc - 1650 + 1676 scrc_stream - 161 + 164 sdeplete - 1119 + 1140 sfill - 607118 + 607043 sflush - 39024 + 39014 sgetb32 - 18259411 + 18262658 sgetb64 - 10605158 + 10607045 sgetble32 - 370 + 372 sgetbs - 3782241 + 3782904 sgetc_uncached - 298684 + 298700 sgetlasttok - 5217 + 5263 sgetline - 5251 + 5297 sgettok - 7892 + 7960 sgetu32 - 255 + 257 shandle - 243 + 245 sopen_multi_file - 1118 + 1139 sopen_multi_write - 161 + 164 sopen_read - 1794 + 1819 sopen_write @@ -141,27 +141,27 @@ sputb32 - 9119259 + 9035051 sputb64 - 5293948 + 5244883 sputble32 - 161 + 164 sputbs - 1884788 + 1867379 sread - 12515245 + 12521197 ssync - 145 + 148 stell @@ -169,7 +169,7 @@ swrite - 20661703 + 20473005
diff --git a/cov/cmdline/stream.c.gcov.html b/cov/cmdline/stream.c.gcov.html index 10fc5b3f..08a34d1f 100644 --- a/cov/cmdline/stream.c.gcov.html +++ b/cov/cmdline/stream.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 27 @@ -88,19 +88,19 @@ 26 : 27 : unsigned STREAM_SIZE = 1024 * 64; 28 : - 29 1794 : STREAM* sopen_read(const char* file) + 29 1819 : STREAM* sopen_read(const char* file) 30 : { 31 : #if HAVE_POSIX_FADVISE 32 : int ret; 33 : #endif - 34 1794 : STREAM* s = malloc_nofail(sizeof(STREAM)); + 34 1819 : STREAM* s = malloc_nofail(sizeof(STREAM)); 35 : - 36 1794 : s->handle_size = 1; - 37 1794 : s->handle = malloc_nofail(sizeof(struct stream_handle)); + 36 1819 : s->handle_size = 1; + 37 1819 : s->handle = malloc_nofail(sizeof(struct stream_handle)); 38 : - 39 1794 : pathcpy(s->handle[0].path, sizeof(s->handle[0].path), file); - 40 1794 : s->handle[0].f = open(file, O_RDONLY | O_BINARY | O_SEQUENTIAL); - 41 1794 : if (s->handle[0].f == -1) { + 39 1819 : pathcpy(s->handle[0].path, sizeof(s->handle[0].path), file); + 40 1819 : s->handle[0].f = open(file, O_RDONLY | O_BINARY | O_SEQUENTIAL); + 41 1819 : if (s->handle[0].f == -1) { 42 50 : free(s->handle); 43 50 : free(s); 44 50 : return 0; @@ -108,8 +108,8 @@ 46 : 47 : #if HAVE_POSIX_FADVISE 48 : /* advise sequential access */ - 49 1744 : ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL); - 50 1744 : if (ret != 0) { + 49 1769 : ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL); + 50 1769 : if (ret != 0) { 51 : /* LCOV_EXCL_START */ 52 : close(s->handle[0].f); 53 : free(s->handle); @@ -119,57 +119,57 @@ 57 : } 58 : #endif 59 : - 60 1744 : s->buffer = malloc_nofail_test(STREAM_SIZE); - 61 1744 : s->pos = s->buffer; - 62 1744 : s->end = s->buffer; - 63 1744 : s->state = STREAM_STATE_READ; - 64 1744 : s->state_index = 0; - 65 1744 : s->offset = 0; - 66 1744 : s->offset_uncached = 0; - 67 1744 : s->crc = 0; - 68 1744 : s->crc_uncached = 0; - 69 1744 : s->crc_stream = CRC_IV; + 60 1769 : s->buffer = malloc_nofail_test(STREAM_SIZE); + 61 1769 : s->pos = s->buffer; + 62 1769 : s->end = s->buffer; + 63 1769 : s->state = STREAM_STATE_READ; + 64 1769 : s->state_index = 0; + 65 1769 : s->offset = 0; + 66 1769 : s->offset_uncached = 0; + 67 1769 : s->crc = 0; + 68 1769 : s->crc_uncached = 0; + 69 1769 : s->crc_stream = CRC_IV; 70 : - 71 1744 : return s; + 71 1769 : return s; 72 : } 73 : - 74 161 : STREAM* sopen_multi_write(unsigned count) + 74 164 : STREAM* sopen_multi_write(unsigned count) 75 : { 76 : unsigned i; 77 : - 78 161 : STREAM* s = malloc_nofail(sizeof(STREAM)); + 78 164 : STREAM* s = malloc_nofail(sizeof(STREAM)); 79 : - 80 161 : s->handle_size = count; - 81 161 : s->handle = malloc_nofail(count * sizeof(struct stream_handle)); + 80 164 : s->handle_size = count; + 81 164 : s->handle = malloc_nofail(count * sizeof(struct stream_handle)); 82 : - 83 1279 : for (i = 0; i < count; ++i) - 84 1118 : s->handle[i].f = -1; + 83 1303 : for (i = 0; i < count; ++i) + 84 1139 : s->handle[i].f = -1; 85 : - 86 161 : s->buffer = malloc_nofail_test(STREAM_SIZE); - 87 161 : s->pos = s->buffer; - 88 161 : s->end = s->buffer + STREAM_SIZE; - 89 161 : s->state = STREAM_STATE_WRITE; - 90 161 : s->state_index = 0; - 91 161 : s->offset = 0; - 92 161 : s->offset_uncached = 0; - 93 161 : s->crc = 0; - 94 161 : s->crc_uncached = 0; - 95 161 : s->crc_stream = CRC_IV; + 86 164 : s->buffer = malloc_nofail_test(STREAM_SIZE); + 87 164 : s->pos = s->buffer; + 88 164 : s->end = s->buffer + STREAM_SIZE; + 89 164 : s->state = STREAM_STATE_WRITE; + 90 164 : s->state_index = 0; + 91 164 : s->offset = 0; + 92 164 : s->offset_uncached = 0; + 93 164 : s->crc = 0; + 94 164 : s->crc_uncached = 0; + 95 164 : s->crc_stream = CRC_IV; 96 : - 97 161 : return s; + 97 164 : return s; 98 : } 99 : - 100 1118 : int sopen_multi_file(STREAM* s, unsigned i, const char* file) + 100 1139 : int sopen_multi_file(STREAM* s, unsigned i, const char* file) 101 : { 102 : #if HAVE_POSIX_FADVISE 103 : int ret; 104 : #endif 105 : int f; 106 : - 107 1118 : pathcpy(s->handle[i].path, sizeof(s->handle[i].path), file); + 107 1139 : pathcpy(s->handle[i].path, sizeof(s->handle[i].path), file); 108 : - 109 1118 : f = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_SEQUENTIAL, 0600); - 110 1118 : if (f == -1) { + 109 1139 : f = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_SEQUENTIAL, 0600); + 110 1139 : if (f == -1) { 111 : /* LCOV_EXCL_START */ 112 : return -1; 113 : /* LCOV_EXCL_STOP */ @@ -177,8 +177,8 @@ 115 : 116 : #if HAVE_POSIX_FADVISE 117 : /* advise sequential access */ - 118 1118 : ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL); - 119 1118 : if (ret != 0) { + 118 1139 : ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL); + 119 1139 : if (ret != 0) { 120 : /* LCOV_EXCL_START */ 121 : close(f); 122 : return -1; @@ -186,9 +186,9 @@ 124 : } 125 : #endif 126 : - 127 1118 : s->handle[i].f = f; + 127 1139 : s->handle[i].f = f; 128 : - 129 1118 : return 0; + 129 1139 : return 0; 130 : } 131 : 132 0 : STREAM* sopen_write(const char* file) @@ -203,150 +203,150 @@ 141 0 : return s; 142 : } 143 : - 144 1903 : int sclose(STREAM* s) + 144 1931 : int sclose(STREAM* s) 145 : { - 146 1903 : int fail = 0; + 146 1931 : int fail = 0; 147 : unsigned i; 148 : - 149 1903 : if (s->state == STREAM_STATE_WRITE) { - 150 161 : if (sflush(s) != 0) { + 149 1931 : if (s->state == STREAM_STATE_WRITE) { + 150 164 : if (sflush(s) != 0) { 151 : /* LCOV_EXCL_START */ 152 : fail = 1; 153 : /* LCOV_EXCL_STOP */ 154 : } 155 : } 156 : - 157 4763 : for (i = 0; i < s->handle_size; ++i) { - 158 2860 : if (close(s->handle[i].f) != 0) { + 157 4837 : for (i = 0; i < s->handle_size; ++i) { + 158 2906 : if (close(s->handle[i].f) != 0) { 159 : /* LCOV_EXCL_START */ 160 : fail = 1; 161 : /* LCOV_EXCL_STOP */ 162 : } 163 : } 164 : - 165 1903 : free(s->handle); - 166 1903 : free(s->buffer); - 167 1903 : free(s); + 165 1931 : free(s->handle); + 166 1931 : free(s->buffer); + 167 1931 : free(s); 168 : - 169 1903 : if (fail) { + 169 1931 : if (fail) { 170 : /* LCOV_EXCL_START */ 171 : return -1; 172 : /* LCOV_EXCL_STOP */ 173 : } 174 : - 175 1903 : return 0; + 175 1931 : return 0; 176 : } 177 : - 178 243 : int shandle(STREAM* s) + 178 245 : int shandle(STREAM* s) 179 : { - 180 243 : if (!s->handle_size) { + 180 245 : if (!s->handle_size) { 181 : /* LCOV_EXCL_START */ 182 : return -1; 183 : /* LCOV_EXCL_STOP */ 184 : } 185 : - 186 243 : return s->handle[0].f; + 186 245 : return s->handle[0].f; 187 : } 188 : 189 : /** 190 : * Fill the read stream buffer. 191 : * \return 0 if at least on char is read, or EOF on error. 192 : */ - 193 607118 : static int sfill(STREAM* s) + 193 607043 : static int sfill(STREAM* s) 194 : { 195 : ssize_t ret; 196 : - 197 607118 : if (s->state != STREAM_STATE_READ) { + 197 607043 : if (s->state != STREAM_STATE_READ) { 198 : /* LCOV_EXCL_START */ 199 : return EOF; 200 : /* LCOV_EXCL_STOP */ 201 : } 202 : - 203 606102 : ret = read(s->handle[0].f, s->buffer, STREAM_SIZE); + 203 606019 : ret = read(s->handle[0].f, s->buffer, STREAM_SIZE); 204 : - 205 606102 : if (ret < 0) { + 205 606019 : if (ret < 0) { 206 : /* LCOV_EXCL_START */ 207 : s->state = STREAM_STATE_ERROR; 208 : return EOF; 209 : /* LCOV_EXCL_STOP */ 210 : } - 211 606102 : if (ret == 0) { - 212 1615 : s->state = STREAM_STATE_EOF; - 213 1615 : return EOF; + 211 606019 : if (ret == 0) { + 212 1640 : s->state = STREAM_STATE_EOF; + 213 1640 : return EOF; 214 : } 215 : 216 : /* update the crc */ - 217 604487 : s->crc_uncached = s->crc; - 218 604487 : s->crc = crc32c(s->crc, s->buffer, ret); + 217 604379 : s->crc_uncached = s->crc; + 218 604379 : s->crc = crc32c(s->crc, s->buffer, ret); 219 : 220 : /* update the offset */ - 221 604487 : s->offset_uncached = s->offset; - 222 604487 : s->offset += ret; + 221 604379 : s->offset_uncached = s->offset; + 222 604379 : s->offset += ret; 223 : - 224 604487 : s->pos = s->buffer; - 225 604487 : s->end = s->buffer + ret; + 224 604379 : s->pos = s->buffer; + 225 604379 : s->end = s->buffer + ret; 226 : - 227 604487 : return 0; + 227 604379 : return 0; 228 : } 229 : - 230 1119 : int sdeplete(STREAM* s, unsigned char* last) + 230 1140 : int sdeplete(STREAM* s, unsigned char* last) 231 : { 232 : /* last four bytes */ - 233 1119 : last[0] = 0; - 234 1119 : last[1] = 0; - 235 1119 : last[2] = 0; - 236 1119 : last[3] = 0; + 233 1140 : last[0] = 0; + 234 1140 : last[1] = 0; + 235 1140 : last[2] = 0; + 236 1140 : last[3] = 0; 237 : 238 : while (1) { 239 : /* increase the position up to 4 bytes before the end */ - 240 308434 : if (s->pos + 4 <= s->end) - 241 148580 : s->pos = s->end - 4; + 240 308343 : if (s->pos + 4 <= s->end) + 241 148468 : s->pos = s->end - 4; 242 : 243 : /* insert the last 4 bytes */ - 244 1470956 : while (s->pos < s->end) { - 245 854088 : last[0] = last[1]; - 246 854088 : last[1] = last[2]; - 247 854088 : last[2] = last[3]; - 248 854088 : last[3] = *s->pos++; + 244 1470326 : while (s->pos < s->end) { + 245 853640 : last[0] = last[1]; + 246 853640 : last[1] = last[2]; + 247 853640 : last[2] = last[3]; + 248 853640 : last[3] = *s->pos++; 249 : } 250 : 251 : /* fill again the buffer until the end of the file */ - 252 308434 : if (sfill(s) != 0) { + 252 308343 : if (sfill(s) != 0) { 253 : /* on error fail */ - 254 1119 : if (serror(s)) { + 254 1140 : if (serror(s)) { 255 : /* LCOV_EXCL_START */ 256 : return EOF; 257 : /* LCOV_EXCL_STOP */ 258 : } 259 : 260 : /* on EOF terminate */ - 261 1119 : break; + 261 1140 : break; 262 : } - 263 307315 : } + 263 307203 : } 264 : - 265 1119 : return 0; + 265 1140 : return 0; 266 : } 267 : - 268 39024 : int sflush(STREAM* s) + 268 39014 : int sflush(STREAM* s) 269 : { 270 : ssize_t ret; 271 : ssize_t size; 272 : unsigned i; 273 : - 274 39024 : if (s->state != STREAM_STATE_WRITE) { + 274 39014 : if (s->state != STREAM_STATE_WRITE) { 275 : /* LCOV_EXCL_START */ 276 : return EOF; 277 : /* LCOV_EXCL_STOP */ 278 : } 279 : - 280 39024 : size = s->pos - s->buffer; - 281 39024 : if (!size) - 282 145 : return 0; + 280 39014 : size = s->pos - s->buffer; + 281 39014 : if (!size) + 282 148 : return 0; 283 : - 284 347171 : for (i = 0; i < s->handle_size; ++i) { - 285 308292 : ret = write(s->handle[i].f, s->buffer, size); + 284 347067 : for (i = 0; i < s->handle_size; ++i) { + 285 308201 : ret = write(s->handle[i].f, s->buffer, size); 286 : - 287 308292 : if (ret != size) { + 287 308201 : if (ret != size) { 288 : /* LCOV_EXCL_START */ 289 : s->state = STREAM_STATE_ERROR; 290 : s->state_index = i; @@ -362,16 +362,16 @@ 300 : * to be able to detect memory errors on the buffer, 301 : * happening during the write. 302 : */ - 303 38879 : s->crc = crc32c(s->crc, s->buffer, size); - 304 38879 : s->crc_uncached = s->crc; + 303 38866 : s->crc = crc32c(s->crc, s->buffer, size); + 304 38866 : s->crc_uncached = s->crc; 305 : 306 : /* update the offset */ - 307 38879 : s->offset += size; - 308 38879 : s->offset_uncached = s->offset; + 307 38866 : s->offset += size; + 308 38866 : s->offset_uncached = s->offset; 309 : - 310 38879 : s->pos = s->buffer; + 310 38866 : s->pos = s->buffer; 311 : - 312 38879 : return 0; + 312 38866 : return 0; 313 : } 314 : 315 1 : int64_t stell(STREAM* s) @@ -379,100 +379,100 @@ 317 1 : return s->offset_uncached + (s->pos - s->buffer); 318 : } 319 : - 320 1650 : uint32_t scrc(STREAM*s) + 320 1676 : uint32_t scrc(STREAM*s) 321 : { - 322 1650 : return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer); + 322 1676 : return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer); 323 : } 324 : - 325 161 : uint32_t scrc_stream(STREAM*s) + 325 164 : uint32_t scrc_stream(STREAM*s) 326 : { - 327 161 : return s->crc_stream ^ CRC_IV; + 327 164 : return s->crc_stream ^ CRC_IV; 328 : } 329 : - 330 298684 : int sgetc_uncached(STREAM* s) + 330 298700 : int sgetc_uncached(STREAM* s) 331 : { 332 : /* if at the end of the buffer, fill it */ - 333 298684 : if (s->pos == s->end && sfill(s) != 0) - 334 1512 : return EOF; - 335 297172 : return *s->pos++; + 333 298700 : if (s->pos == s->end && sfill(s) != 0) + 334 1524 : return EOF; + 335 297176 : return *s->pos++; 336 : } 337 : - 338 7892 : int sgettok(STREAM* f, char* str, int size) + 338 7960 : int sgettok(STREAM* f, char* str, int size) 339 : { - 340 7892 : char* i = str; - 341 7892 : char* send = str + size; + 340 7960 : char* i = str; + 341 7960 : char* send = str + size; 342 : int c; 343 : 344 : while (1) { - 345 52707 : c = sgetc(f); - 346 52707 : if (c == EOF) { - 347 254 : break; + 345 53173 : c = sgetc(f); + 346 53173 : if (c == EOF) { + 347 256 : break; 348 : } - 349 52453 : if (c == ' ' || c == '\t') { - 350 7383 : sungetc(c, f); - 351 7383 : break; + 349 52917 : if (c == ' ' || c == '\t') { + 350 7447 : sungetc(c, f); + 351 7447 : break; 352 : } - 353 45070 : if (c == '\n') { + 353 45470 : if (c == '\n') { 354 : /* remove ending carrige return to support the Windows CR+LF format */ - 355 255 : if (i != str && i[-1] == '\r') + 355 257 : if (i != str && i[-1] == '\r') 356 0 : --i; - 357 255 : sungetc(c, f); - 358 255 : break; + 357 257 : sungetc(c, f); + 358 257 : break; 359 : } 360 : - 361 44815 : *i++ = c; + 361 45213 : *i++ = c; 362 : - 363 44815 : if (i == send) { + 363 45213 : if (i == send) { 364 : /* LCOV_EXCL_START */ 365 : return -1; 366 : /* LCOV_EXCL_STOP */ 367 : } - 368 44815 : } + 368 45213 : } 369 : - 370 7892 : *i = 0; + 370 7960 : *i = 0; 371 : - 372 7892 : return i - str; + 372 7960 : return i - str; 373 : } 374 : - 375 12515245 : int sread(STREAM* f, void* void_data, unsigned size) + 375 12521197 : int sread(STREAM* f, void* void_data, unsigned size) 376 : { - 377 12515245 : unsigned char* data = void_data; + 377 12521197 : unsigned char* data = void_data; 378 : 379 : /* if there is enough space in memory */ - 380 12515245 : if (sptrlookup(f, size)) { + 380 12521197 : if (sptrlookup(f, size)) { 381 : /* optimized version with all the data in memory */ - 382 12489054 : unsigned char* pos = sptrget(f); + 382 12494935 : unsigned char* pos = sptrget(f); 383 : 384 : /* copy it */ - 385 212622570 : while (size--) - 386 187644462 : *data++ = *pos++; + 385 212722886 : while (size--) + 386 187733016 : *data++ = *pos++; 387 : - 388 12489054 : sptrset(f, pos); + 388 12494935 : sptrset(f, pos); 389 : } else { 390 : /* standard version using sgetc() */ - 391 1376682 : while (size--) { - 392 1324300 : int c = sgetc(f); - 393 1324300 : if (c == EOF) { + 391 1376463 : while (size--) { + 392 1323939 : int c = sgetc(f); + 393 1323939 : if (c == EOF) { 394 : /* LCOV_EXCL_START */ 395 : return -1; 396 : /* LCOV_EXCL_STOP */ 397 : } 398 : - 399 1324300 : *data++ = c; + 399 1323939 : *data++ = c; 400 : } 401 : } 402 : - 403 12515245 : return 0; + 403 12521197 : return 0; 404 : } 405 : - 406 5251 : int sgetline(STREAM* f, char* str, int size) + 406 5297 : int sgetline(STREAM* f, char* str, int size) 407 : { - 408 5251 : char* i = str; - 409 5251 : char* send = str + size; + 408 5297 : char* i = str; + 409 5297 : char* send = str + size; 410 : int c; 411 : 412 : /* if there is enough data in memory */ - 413 5251 : if (sptrlookup(f, size)) { + 413 5297 : if (sptrlookup(f, size)) { 414 : /* optimized version with all the data in memory */ 415 0 : unsigned char* pos = sptrget(f); 416 : @@ -498,75 +498,75 @@ 436 0 : sptrset(f, pos); 437 : } else { 438 : while (1) { - 439 71440 : c = sgetc(f); - 440 71440 : if (c == EOF) { + 439 72066 : c = sgetc(f); + 440 72066 : if (c == EOF) { 441 : /* LCOV_EXCL_START */ 442 : break; 443 : /* LCOV_EXCL_STOP */ 444 : } - 445 71440 : if (c == '\n') { + 445 72066 : if (c == '\n') { 446 : /* remove ending carrige return to support the Windows CR+LF format */ - 447 5251 : if (i != str && i[-1] == '\r') + 447 5297 : if (i != str && i[-1] == '\r') 448 0 : --i; - 449 5251 : sungetc(c, f); - 450 5251 : break; + 449 5297 : sungetc(c, f); + 450 5297 : break; 451 : } 452 : - 453 66189 : *i++ = c; + 453 66769 : *i++ = c; 454 : - 455 66189 : if (i == send) { + 455 66769 : if (i == send) { 456 : /* LCOV_EXCL_START */ 457 : return -1; 458 : /* LCOV_EXCL_STOP */ 459 : } - 460 66189 : } + 460 66769 : } 461 : } 462 : - 463 5251 : *i = 0; + 463 5297 : *i = 0; 464 : - 465 5251 : return i - str; + 465 5297 : return i - str; 466 : } 467 : - 468 5217 : int sgetlasttok(STREAM* f, char* str, int size) + 468 5263 : int sgetlasttok(STREAM* f, char* str, int size) 469 : { 470 : int ret; 471 : - 472 5217 : ret = sgetline(f, str, size); - 473 5217 : if (ret < 0) { + 472 5263 : ret = sgetline(f, str, size); + 473 5263 : if (ret < 0) { 474 : /* LCOV_EXCL_START */ 475 : return ret; 476 : /* LCOV_EXCL_STOP */ 477 : } 478 : - 479 10434 : while (ret > 0 && (str[ret - 1] == ' ' || str[ret - 1] == '\t')) + 479 10526 : while (ret > 0 && (str[ret - 1] == ' ' || str[ret - 1] == '\t')) 480 0 : --ret; 481 : - 482 5217 : str[ret] = 0; + 482 5263 : str[ret] = 0; 483 : - 484 5217 : return ret; + 484 5263 : return ret; 485 : } 486 : - 487 255 : int sgetu32(STREAM* f, uint32_t* value) + 487 257 : int sgetu32(STREAM* f, uint32_t* value) 488 : { 489 : int c; 490 : - 491 255 : c = sgetc(f); - 492 255 : if (c >= '0' && c <= '9') { + 491 257 : c = sgetc(f); + 492 257 : if (c >= '0' && c <= '9') { 493 : uint32_t v; 494 : - 495 255 : v = c - '0'; + 495 257 : v = c - '0'; 496 : - 497 255 : c = sgetc(f); - 498 510 : while (c >= '0' && c <= '9') { + 497 257 : c = sgetc(f); + 498 514 : while (c >= '0' && c <= '9') { 499 0 : v *= 10; 500 0 : v += c - '0'; 501 0 : c = sgetc(f); 502 : } 503 : - 504 255 : *value = v; + 504 257 : *value = v; 505 : - 506 255 : sungetc(c, f); - 507 255 : return 0; + 506 257 : sungetc(c, f); + 507 257 : return 0; 508 : } else { 509 : /* LCOV_EXCL_START */ 510 : /* nothing read */ @@ -575,122 +575,122 @@ 513 : } 514 : } 515 : - 516 18259411 : int sgetb32(STREAM* f, uint32_t* value) + 516 18262658 : int sgetb32(STREAM* f, uint32_t* value) 517 : { 518 : uint32_t v; 519 : unsigned char b; 520 : unsigned char s; 521 : int c; 522 : - 523 18259411 : v = 0; - 524 18259411 : s = 0; + 523 18262658 : v = 0; + 524 18262658 : s = 0; 525 : loop: - 526 35244347 : c = sgetc(f); - 527 35244347 : if (c == EOF) { + 526 34952526 : c = sgetc(f); + 527 34952526 : if (c == EOF) { 528 : /* LCOV_EXCL_START */ 529 : return -1; 530 : /* LCOV_EXCL_STOP */ 531 : } 532 : - 533 35244347 : b = (unsigned char)c; - 534 35244347 : if ((b & 0x80) == 0) { - 535 16984936 : v |= (uint32_t)b << s; - 536 16984936 : s += 7; - 537 16984936 : if (s >= 32) { + 533 34952526 : b = (unsigned char)c; + 534 34952526 : if ((b & 0x80) == 0) { + 535 16689868 : v |= (uint32_t)b << s; + 536 16689868 : s += 7; + 537 16689868 : if (s >= 32) { 538 : /* LCOV_EXCL_START */ 539 : return -1; 540 : /* LCOV_EXCL_STOP */ 541 : } - 542 16984936 : goto loop; + 542 16689868 : goto loop; 543 : } 544 : - 545 18259411 : v |= (uint32_t)(b & 0x7f) << s; + 545 18262658 : v |= (uint32_t)(b & 0x7f) << s; 546 : - 547 18259411 : *value = v; + 547 18262658 : *value = v; 548 : - 549 18259411 : return 0; + 549 18262658 : return 0; 550 : } 551 : - 552 10605158 : int sgetb64(STREAM* f, uint64_t* value) + 552 10607045 : int sgetb64(STREAM* f, uint64_t* value) 553 : { 554 : uint64_t v; 555 : unsigned char b; 556 : unsigned char s; 557 : int c; 558 : - 559 10605158 : v = 0; - 560 10605158 : s = 0; + 559 10607045 : v = 0; + 560 10607045 : s = 0; 561 : loop: - 562 38780587 : c = sgetc(f); - 563 38780587 : if (c == EOF) { + 562 38787515 : c = sgetc(f); + 563 38787515 : if (c == EOF) { 564 : /* LCOV_EXCL_START */ 565 : return -1; 566 : /* LCOV_EXCL_STOP */ 567 : } 568 : - 569 38780587 : b = (unsigned char)c; - 570 38780587 : if ((b & 0x80) == 0) { - 571 28175429 : v |= (uint64_t)b << s; - 572 28175429 : s += 7; - 573 28175429 : if (s >= 64) { + 569 38787515 : b = (unsigned char)c; + 570 38787515 : if ((b & 0x80) == 0) { + 571 28180470 : v |= (uint64_t)b << s; + 572 28180470 : s += 7; + 573 28180470 : if (s >= 64) { 574 : /* LCOV_EXCL_START */ 575 : return -1; 576 : /* LCOV_EXCL_STOP */ 577 : } - 578 28175429 : goto loop; + 578 28180470 : goto loop; 579 : } 580 : - 581 10605158 : v |= (uint64_t)(b & 0x7f) << s; + 581 10607045 : v |= (uint64_t)(b & 0x7f) << s; 582 : - 583 10605158 : *value = v; + 583 10607045 : *value = v; 584 : - 585 10605158 : return 0; + 585 10607045 : return 0; 586 : } 587 : - 588 370 : int sgetble32(STREAM* f, uint32_t* value) + 588 372 : int sgetble32(STREAM* f, uint32_t* value) 589 : { 590 : unsigned char buf[4]; 591 : - 592 370 : if (sread(f, buf, 4) != 0) { + 592 372 : if (sread(f, buf, 4) != 0) { 593 : /* LCOV_EXCL_START */ 594 : return -1; 595 : /* LCOV_EXCL_STOP */ 596 : } 597 : - 598 370 : *value = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; + 598 372 : *value = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; 599 : - 600 370 : return 0; + 600 372 : return 0; 601 : } 602 : - 603 3782241 : int sgetbs(STREAM* f, char* str, int size) + 603 3782904 : int sgetbs(STREAM* f, char* str, int size) 604 : { 605 : uint32_t len; 606 : - 607 3782241 : if (sgetb32(f, &len) < 0) { + 607 3782904 : if (sgetb32(f, &len) < 0) { 608 : /* LCOV_EXCL_START */ 609 : return -1; 610 : /* LCOV_EXCL_STOP */ 611 : } 612 : - 613 3782241 : if (len + 1 > (uint32_t)size) { + 613 3782904 : if (len + 1 > (uint32_t)size) { 614 : /* LCOV_EXCL_START */ 615 : return -1; 616 : /* LCOV_EXCL_STOP */ 617 : } 618 : - 619 3782240 : str[len] = 0; + 619 3782904 : str[len] = 0; 620 : - 621 3782240 : return sread(f, str, (int)len); + 621 3782904 : return sread(f, str, (int)len); 622 : } 623 : - 624 20661703 : int swrite(const void* void_data, unsigned size, STREAM* f) + 624 20473005 : int swrite(const void* void_data, unsigned size, STREAM* f) 625 : { - 626 20661703 : const unsigned char* data = void_data; + 626 20473005 : const unsigned char* data = void_data; 627 : 628 : /* if there is enough space in memory */ - 629 20661703 : if (sptrlookup(f, size)) { + 629 20473005 : if (sptrlookup(f, size)) { 630 : /* optimized version with all the data in memory */ - 631 20655549 : unsigned char* pos = sptrget(f); + 631 20466902 : unsigned char* pos = sptrget(f); 632 : 633 : /** 634 : * Update the crc *before* writing the data in the buffer @@ -699,17 +699,17 @@ 637 : * to be able to detect memory errors on the buffer, 638 : * happening before we write it on the file. 639 : */ - 640 20655549 : f->crc_stream = crc32c_plain(f->crc_stream, data, size); + 640 20466902 : f->crc_stream = crc32c_plain(f->crc_stream, data, size); 641 : 642 : /* copy it */ - 643 172057609 : while (size--) - 644 130746511 : *pos++ = *data++; + 643 170277665 : while (size--) + 644 129343861 : *pos++ = *data++; 645 : - 646 20655549 : sptrset(f, pos); + 646 20466902 : sptrset(f, pos); 647 : } else { 648 : /* standard version using sputc() */ - 649 201458 : while (size--) { - 650 189150 : if (sputc(*data++, f) != 0) { + 649 200827 : while (size--) { + 650 188621 : if (sputc(*data++, f) != 0) { 651 : /* LCOV_EXCL_START */ 652 : return -1; 653 : /* LCOV_EXCL_STOP */ @@ -717,83 +717,83 @@ 655 : } 656 : } 657 : - 658 20661703 : return 0; + 658 20473005 : return 0; 659 : } 660 : - 661 9119259 : int sputb32(uint32_t value, STREAM* s) + 661 9035051 : int sputb32(uint32_t value, STREAM* s) 662 : { 663 : unsigned char b; 664 : unsigned char buf[16]; 665 : unsigned i; 666 : - 667 9119259 : i = 0; + 667 9035051 : i = 0; 668 : loop: - 669 17637493 : b = value & 0x7f; - 670 17637493 : value >>= 7; + 669 17245172 : b = value & 0x7f; + 670 17245172 : value >>= 7; 671 : - 672 17637493 : if (value) { - 673 8518234 : buf[i++] = b; - 674 8518234 : goto loop; + 672 17245172 : if (value) { + 673 8210121 : buf[i++] = b; + 674 8210121 : goto loop; 675 : } 676 : - 677 9119259 : buf[i++] = b | 0x80; + 677 9035051 : buf[i++] = b | 0x80; 678 : - 679 9119259 : return swrite(buf, i, s); + 679 9035051 : return swrite(buf, i, s); 680 : } 681 : - 682 5293948 : int sputb64(uint64_t value, STREAM* s) + 682 5244883 : int sputb64(uint64_t value, STREAM* s) 683 : { 684 : unsigned char b; 685 : unsigned char buf[16]; 686 : unsigned i; 687 : - 688 5293948 : i = 0; + 688 5244883 : i = 0; 689 : loop: - 690 19354594 : b = value & 0x7f; - 691 19354594 : value >>= 7; + 690 19175251 : b = value & 0x7f; + 691 19175251 : value >>= 7; 692 : - 693 19354594 : if (value) { - 694 14060646 : buf[i++] = b; - 695 14060646 : goto loop; + 693 19175251 : if (value) { + 694 13930368 : buf[i++] = b; + 695 13930368 : goto loop; 696 : } 697 : - 698 5293948 : buf[i++] = b | 0x80; + 698 5244883 : buf[i++] = b | 0x80; 699 : - 700 5293948 : return swrite(buf, i, s); + 700 5244883 : return swrite(buf, i, s); 701 : } 702 : - 703 161 : int sputble32(uint32_t value, STREAM* s) + 703 164 : int sputble32(uint32_t value, STREAM* s) 704 : { 705 : unsigned char buf[4]; 706 : - 707 161 : buf[0] = value & 0xFF; - 708 161 : buf[1] = (value >> 8) & 0xFF; - 709 161 : buf[2] = (value >> 16) & 0xFF; - 710 161 : buf[3] = (value >> 24) & 0xFF; + 707 164 : buf[0] = value & 0xFF; + 708 164 : buf[1] = (value >> 8) & 0xFF; + 709 164 : buf[2] = (value >> 16) & 0xFF; + 710 164 : buf[3] = (value >> 24) & 0xFF; 711 : - 712 161 : return swrite(buf, 4, s); + 712 164 : return swrite(buf, 4, s); 713 : } 714 : - 715 1884788 : int sputbs(const char* str, STREAM* f) + 715 1867379 : int sputbs(const char* str, STREAM* f) 716 : { - 717 1884788 : size_t len = strlen(str); + 717 1867379 : size_t len = strlen(str); 718 : - 719 1884788 : if (sputb32(len, f) != 0) { + 719 1867379 : if (sputb32(len, f) != 0) { 720 : /* LCOV_EXCL_START */ 721 : return -1; 722 : /* LCOV_EXCL_STOP */ 723 : } 724 : - 725 1884788 : return swrite(str, len, f); + 725 1867379 : return swrite(str, len, f); 726 : } 727 : 728 : #if HAVE_FSYNC - 729 145 : int ssync(STREAM* s) + 729 148 : int ssync(STREAM* s) 730 : { 731 : unsigned i; 732 : - 733 1135 : for (i = 0; i < s->handle_size; ++i) { - 734 990 : if (fsync(s->handle[i].f) != 0) { + 733 1159 : for (i = 0; i < s->handle_size; ++i) { + 734 1011 : if (fsync(s->handle[i].f) != 0) { 735 : /* LCOV_EXCL_START */ 736 : s->state = STREAM_STATE_ERROR; 737 : s->state_index = i; @@ -802,7 +802,7 @@ 740 : } 741 : } 742 : - 743 145 : return 0; + 743 148 : return 0; 744 : } 745 : #endif 746 : diff --git a/cov/cmdline/stream.h.func-sort-c.html b/cov/cmdline/stream.h.func-sort-c.html index 3d5cc907..1582e185 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-01-09 + 2016-01-16 Functions: 10 @@ -61,39 +61,39 @@ sgetc - 82747474 + 82464911 sptrlookup - 33182199 + 32999499 sptrset - 33144603 + 32961837 sptrget - 33144603 + 32961837 sputc - 3794625 + 3760808 serror - 3632818 + 3599296 sungetc - 33308 + 33596 sgetspace - 19921 + 20093 sgeteol - 6014 + 6066 seof diff --git a/cov/cmdline/stream.h.func.html b/cov/cmdline/stream.h.func.html index b6043b90..3f7fdb5a 100644 --- a/cov/cmdline/stream.h.func.html +++ b/cov/cmdline/stream.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -65,7 +65,7 @@ serror - 3632818 + 3599296 serrorfile @@ -73,35 +73,35 @@ sgetc - 82747474 + 82464911 sgeteol - 6014 + 6066 sgetspace - 19921 + 20093 sptrget - 33144603 + 32961837 sptrlookup - 33182199 + 32999499 sptrset - 33144603 + 32961837 sputc - 3794625 + 3760808 sungetc - 33308 + 33596
diff --git a/cov/cmdline/stream.h.gcov.html b/cov/cmdline/stream.h.gcov.html index cf65bf9c..ad3b045a 100644 --- a/cov/cmdline/stream.h.gcov.html +++ b/cov/cmdline/stream.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -221,33 +221,33 @@ 159 : /** 160 : * Check if the buffer has enough data loaded. 161 : */ - 162 33182199 : static inline int sptrlookup(STREAM* s, int size) + 162 32999499 : static inline int sptrlookup(STREAM* s, int size) 163 : { - 164 33182199 : return s->pos + size <= s->end; + 164 32999499 : return s->pos + size <= s->end; 165 : } 166 : 167 : /** 168 : * Get the current stream ptr. 169 : */ - 170 33144603 : static inline unsigned char* sptrget(STREAM* s) + 170 32961837 : static inline unsigned char* sptrget(STREAM* s) 171 : { - 172 33144603 : return s->pos; + 172 32961837 : return s->pos; 173 : } 174 : 175 : /** 176 : * Set the current stream ptr. 177 : */ - 178 33144603 : static inline void sptrset(STREAM* s, unsigned char* ptr) + 178 32961837 : static inline void sptrset(STREAM* s, unsigned char* ptr) 179 : { - 180 33144603 : s->pos = ptr; - 181 33144603 : } + 180 32961837 : s->pos = ptr; + 181 32961837 : } 182 : 183 : /** 184 : * Check the error status. Like ferror(). 185 : */ - 186 3632818 : static inline int serror(STREAM* s) + 186 3599296 : static inline int serror(STREAM* s) 187 : { - 188 3632818 : return s->state == STREAM_STATE_ERROR; + 188 3599296 : return s->state == STREAM_STATE_ERROR; 189 : } 190 : 191 : /** @@ -291,22 +291,22 @@ 229 : /** 230 : * Read a char. Like fgetc(). 231 : */ - 232 82747474 : static inline int sgetc(STREAM* s) + 232 82464911 : static inline int sgetc(STREAM* s) 233 : { - 234 82747474 : if (tommy_unlikely(s->pos == s->end)) - 235 298684 : return sgetc_uncached(s); - 236 82448790 : return *s->pos++; + 234 82464911 : if (tommy_unlikely(s->pos == s->end)) + 235 298700 : return sgetc_uncached(s); + 236 82166211 : return *s->pos++; 237 : } 238 : 239 : /** 240 : * Unread a char. 241 : * Like ungetc() but you have to unget the same char read. 242 : */ - 243 33308 : static inline void sungetc(int c, STREAM* s) + 243 33596 : static inline void sungetc(int c, STREAM* s) 244 : { - 245 33308 : if (c != EOF) - 246 32546 : --s->pos; - 247 33308 : } + 245 33596 : if (c != EOF) + 246 32828 : --s->pos; + 247 33596 : } 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 6014 : static inline int sgeteol(STREAM* f) + 258 6066 : static inline int sgeteol(STREAM* f) 259 : { 260 : int c; 261 : - 262 6014 : c = sgetc(f); - 263 6014 : if (c == '\r') + 262 6066 : c = sgetc(f); + 263 6066 : if (c == '\r') 264 0 : c = sgetc(f); 265 : - 266 6014 : return c; + 266 6066 : return c; 267 : } 268 : 269 : /** 270 : * Read all the spaces and tabs. 271 : * Return the number of spaces and tabs read. 272 : */ - 273 19921 : static inline int sgetspace(STREAM* f) + 273 20093 : static inline int sgetspace(STREAM* f) 274 : { - 275 19921 : int count = 0; + 275 20093 : int count = 0; 276 : int c; 277 : - 278 19921 : c = sgetc(f); - 279 47225 : while (c == ' ' || c == '\t') { - 280 7383 : ++count; - 281 7383 : c = sgetc(f); + 278 20093 : c = sgetc(f); + 279 47633 : while (c == ' ' || c == '\t') { + 280 7447 : ++count; + 281 7447 : c = sgetc(f); 282 : } 283 : - 284 19921 : sungetc(c, f); - 285 19921 : return count; + 284 20093 : sungetc(c, f); + 285 20093 : return count; 286 : } 287 : 288 : /** @@ -407,10 +407,10 @@ 345 : * Write a char. Like fputc(). 346 : * Return 0 on success or -1 on error. 347 : */ - 348 3794625 : static inline int sputc(int c, STREAM* s) + 348 3760808 : static inline int sputc(int c, STREAM* s) 349 : { - 350 3794625 : if (s->pos == s->end) { - 351 38573 : if (sflush(s) != 0) + 350 3760808 : if (s->pos == s->end) { + 351 38554 : if (sflush(s) != 0) 352 0 : return -1; 353 : } 354 : @@ -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 3794625 : s->crc_stream = crc32c_plain_char(s->crc_stream, c); + 362 3760808 : s->crc_stream = crc32c_plain_char(s->crc_stream, c); 363 : - 364 3794625 : *s->pos++ = c; + 364 3760808 : *s->pos++ = c; 365 : - 366 3794625 : return 0; + 366 3760808 : 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 468d779e..402b73a6 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-01-09 + 2016-01-16 Functions: 30 @@ -61,91 +61,91 @@ pathcmp - 51328958 + 51339645 pathprint - 50908928 + 50920352 malloc_counter_inc - 19792624 + 19797017 malloc_nofail - 14067108 + 14070101 pathcpy - 6956056 + 6957833 strdup_nofail - 5715940 + 5717268 log_tag - 4058806 + 4055558 esc - 3612178 + 3608964 mkancestor - 793073 + 793150 log_error - 615188 + 614775 msg_info - 295974 + 295917 msg_verbose - 127002 + 126828 fmtime - 119629 + 119699 pathexport - 17583 + 17589 log_expected - 11440 + 11254 calloc_nofail - 9576 + 9648 pathimport - 9180 + 9262 pathslash - 7469 + 7481 msg_progress - 4145 + 4207 log_flush - 1148 + 1158 msg_bar - 945 + 994 log_fatal - 822 + 830 pathcatc @@ -153,19 +153,19 @@ msg_status - 577 + 579 malloc_counter_get - 460 + 464 msg_flush - 442 + 460 pathcat - 256 + 258 pathcut diff --git a/cov/cmdline/support.c.func.html b/cov/cmdline/support.c.func.html index 9872d2eb..f1a6ed3a 100644 --- a/cov/cmdline/support.c.func.html +++ b/cov/cmdline/support.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 30 @@ -61,79 +61,79 @@ calloc_nofail - 9576 + 9648 esc - 3612178 + 3608964 fmtime - 119629 + 119699 log_error - 615188 + 614775 log_expected - 11440 + 11254 log_fatal - 822 + 830 log_flush - 1148 + 1158 log_tag - 4058806 + 4055558 malloc_counter_get - 460 + 464 malloc_counter_inc - 19792624 + 19797017 malloc_nofail - 14067108 + 14070101 mkancestor - 793073 + 793150 msg_bar - 945 + 994 msg_flush - 442 + 460 msg_info - 295974 + 295917 msg_progress - 4145 + 4207 msg_status - 577 + 579 msg_verbose - 127002 + 126828 pathcat - 256 + 258 pathcatc @@ -141,11 +141,11 @@ pathcmp - 51328958 + 51339645 pathcpy - 6956056 + 6957833 pathcut @@ -153,19 +153,19 @@ pathexport - 17583 + 17589 pathimport - 9180 + 9262 pathprint - 50908928 + 50920352 pathslash - 7469 + 7481 polish @@ -185,7 +185,7 @@ strdup_nofail - 5715940 + 5717268
diff --git a/cov/cmdline/support.c.gcov.html b/cov/cmdline/support.c.gcov.html index 265ef117..d2076cc7 100644 --- a/cov/cmdline/support.c.gcov.html +++ b/cov/cmdline/support.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 30 @@ -116,13 +116,13 @@ 54 : * caller should use log_flush(). 55 : */ 56 : - 57 822 : void log_fatal(const char* format, ...) + 57 830 : void log_fatal(const char* format, ...) 58 : { 59 : va_list ap; 60 : - 61 822 : pthread_mutex_lock(&msg_lock); + 61 830 : pthread_mutex_lock(&msg_lock); 62 : - 63 822 : if (stdlog) { + 63 830 : if (stdlog) { 64 103 : va_start(ap, format); 65 103 : fprintf(stdlog, "msg:fatal: "); 66 103 : vfprintf(stdlog, format, ap); @@ -130,89 +130,89 @@ 68 103 : va_end(ap); 69 : } 70 : - 71 822 : va_start(ap, format); - 72 822 : vfprintf(stderr, format, ap); - 73 822 : fflush(stderr); - 74 822 : va_end(ap); + 71 830 : va_start(ap, format); + 72 830 : vfprintf(stderr, format, ap); + 73 830 : fflush(stderr); + 74 830 : va_end(ap); 75 : - 76 822 : pthread_mutex_unlock(&msg_lock); - 77 822 : } + 76 830 : pthread_mutex_unlock(&msg_lock); + 77 830 : } 78 : - 79 615188 : void log_error(const char* format, ...) + 79 614775 : void log_error(const char* format, ...) 80 : { 81 : va_list ap; 82 : - 83 615188 : pthread_mutex_lock(&msg_lock); + 83 614775 : pthread_mutex_lock(&msg_lock); 84 : - 85 615188 : if (stdlog) { - 86 613309 : va_start(ap, format); - 87 613309 : fprintf(stdlog, "msg:error: "); - 88 613309 : vfprintf(stdlog, format, ap); - 89 613309 : fflush(stdlog); - 90 613309 : va_end(ap); + 85 614775 : if (stdlog) { + 86 612895 : va_start(ap, format); + 87 612895 : fprintf(stdlog, "msg:error: "); + 88 612895 : vfprintf(stdlog, format, ap); + 89 612895 : fflush(stdlog); + 90 612895 : va_end(ap); 91 : } else { - 92 1879 : va_start(ap, format); - 93 1879 : vfprintf(stderr, format, ap); - 94 1879 : fflush(stderr); - 95 1879 : va_end(ap); + 92 1880 : va_start(ap, format); + 93 1880 : vfprintf(stderr, format, ap); + 94 1880 : fflush(stderr); + 95 1880 : va_end(ap); 96 : } 97 : - 98 615188 : pthread_mutex_unlock(&msg_lock); - 99 615188 : } + 98 614775 : pthread_mutex_unlock(&msg_lock); + 99 614775 : } 100 : - 101 11440 : void log_expected(const char* format, ...) + 101 11254 : void log_expected(const char* format, ...) 102 : { 103 : va_list ap; 104 : - 105 11440 : pthread_mutex_lock(&msg_lock); + 105 11254 : pthread_mutex_lock(&msg_lock); 106 : - 107 11440 : if (stdlog) { - 108 11440 : va_start(ap, format); - 109 11440 : fprintf(stdlog, "msg:expected: "); - 110 11440 : vfprintf(stdlog, format, ap); - 111 11440 : fflush(stdlog); - 112 11440 : va_end(ap); + 107 11254 : if (stdlog) { + 108 11254 : va_start(ap, format); + 109 11254 : fprintf(stdlog, "msg:expected: "); + 110 11254 : vfprintf(stdlog, format, ap); + 111 11254 : fflush(stdlog); + 112 11254 : va_end(ap); 113 : } 114 : - 115 11440 : pthread_mutex_unlock(&msg_lock); - 116 11440 : } + 115 11254 : pthread_mutex_unlock(&msg_lock); + 116 11254 : } 117 : - 118 4058806 : void log_tag(const char* format, ...) + 118 4055558 : void log_tag(const char* format, ...) 119 : { 120 : va_list ap; 121 : - 122 4058806 : pthread_mutex_lock(&msg_lock); + 122 4055558 : pthread_mutex_lock(&msg_lock); 123 : - 124 4058806 : if (stdlog) { - 125 2977413 : va_start(ap, format); - 126 2977413 : vfprintf(stdlog, format, ap); + 124 4055558 : if (stdlog) { + 125 2975578 : va_start(ap, format); + 126 2975578 : vfprintf(stdlog, format, ap); 127 : /* here we intentionally don't flush */ 128 : /* to make the output faster */ - 129 2977413 : va_end(ap); + 129 2975578 : va_end(ap); 130 : } 131 : - 132 4058806 : pthread_mutex_unlock(&msg_lock); - 133 4058806 : } + 132 4055558 : pthread_mutex_unlock(&msg_lock); + 133 4055558 : } 134 : - 135 1148 : void log_flush(void) + 135 1158 : void log_flush(void) 136 : { - 137 1148 : pthread_mutex_lock(&msg_lock); + 137 1158 : pthread_mutex_lock(&msg_lock); 138 : - 139 1148 : if (stdlog) + 139 1158 : if (stdlog) 140 326 : fflush(stdlog); - 141 1148 : fflush(stdout); - 142 1148 : fflush(stderr); + 141 1158 : fflush(stdout); + 142 1158 : fflush(stderr); 143 : - 144 1148 : pthread_mutex_unlock(&msg_lock); - 145 1148 : } + 144 1158 : pthread_mutex_unlock(&msg_lock); + 145 1158 : } 146 : - 147 577 : void msg_status(const char* format, ...) + 147 579 : void msg_status(const char* format, ...) 148 : { 149 : va_list ap; 150 : - 151 577 : pthread_mutex_lock(&msg_lock); + 151 579 : pthread_mutex_lock(&msg_lock); 152 : - 153 577 : if (stdlog) { + 153 579 : if (stdlog) { 154 276 : va_start(ap, format); 155 276 : fprintf(stdlog, "msg:status: "); 156 276 : vfprintf(stdlog, format, ap); @@ -220,42 +220,42 @@ 158 276 : va_end(ap); 159 : } 160 : - 161 577 : if (msg_level >= MSG_STATUS) { - 162 577 : va_start(ap, format); - 163 577 : vfprintf(stdout, format, ap); - 164 577 : fflush(stdout); - 165 577 : va_end(ap); + 161 579 : if (msg_level >= MSG_STATUS) { + 162 579 : va_start(ap, format); + 163 579 : vfprintf(stdout, format, ap); + 164 579 : fflush(stdout); + 165 579 : va_end(ap); 166 : } 167 : - 168 577 : pthread_mutex_unlock(&msg_lock); - 169 577 : } + 168 579 : pthread_mutex_unlock(&msg_lock); + 169 579 : } 170 : - 171 295974 : void msg_info(const char* format, ...) + 171 295917 : void msg_info(const char* format, ...) 172 : { 173 : va_list ap; 174 : - 175 295974 : pthread_mutex_lock(&msg_lock); + 175 295917 : pthread_mutex_lock(&msg_lock); 176 : 177 : /* don't output in stdlog as these messages */ 178 : /* are always paired with a msg_tag() call */ 179 : - 180 295974 : if (msg_level >= MSG_INFO) { - 181 28827 : va_start(ap, format); - 182 28827 : vfprintf(stdout, format, ap); - 183 28827 : fflush(stdout); - 184 28827 : va_end(ap); + 180 295917 : if (msg_level >= MSG_INFO) { + 181 28833 : va_start(ap, format); + 182 28833 : vfprintf(stdout, format, ap); + 183 28833 : fflush(stdout); + 184 28833 : va_end(ap); 185 : } 186 : - 187 295974 : pthread_mutex_unlock(&msg_lock); - 188 295974 : } + 187 295917 : pthread_mutex_unlock(&msg_lock); + 188 295917 : } 189 : - 190 4145 : void msg_progress(const char* format, ...) + 190 4207 : void msg_progress(const char* format, ...) 191 : { 192 : va_list ap; 193 : - 194 4145 : pthread_mutex_lock(&msg_lock); + 194 4207 : pthread_mutex_lock(&msg_lock); 195 : - 196 4145 : if (stdlog) { + 196 4207 : if (stdlog) { 197 775 : va_start(ap, format); 198 775 : fprintf(stdlog, "msg:progress: "); 199 775 : vfprintf(stdlog, format, ap); @@ -263,68 +263,68 @@ 201 775 : va_end(ap); 202 : } 203 : - 204 4145 : if (msg_level >= MSG_PROGRESS) { + 204 4207 : if (msg_level >= MSG_PROGRESS) { 205 153 : va_start(ap, format); 206 153 : vfprintf(stdout, format, ap); 207 153 : fflush(stdout); 208 153 : va_end(ap); 209 : } 210 : - 211 4145 : pthread_mutex_unlock(&msg_lock); - 212 4145 : } + 211 4207 : pthread_mutex_unlock(&msg_lock); + 212 4207 : } 213 : - 214 945 : void msg_bar(const char* format, ...) + 214 994 : void msg_bar(const char* format, ...) 215 : { 216 : va_list ap; 217 : - 218 945 : pthread_mutex_lock(&msg_lock); + 218 994 : pthread_mutex_lock(&msg_lock); 219 : 220 : /* don't output in stdlog as these messages */ 221 : /* are intended for screen only */ 222 : /* also don't flush stdout as they are intended to be partial messages */ 223 : - 224 945 : if (msg_level >= MSG_BAR) { + 224 994 : if (msg_level >= MSG_BAR) { 225 0 : va_start(ap, format); 226 0 : vfprintf(stdout, format, ap); 227 0 : va_end(ap); 228 : } 229 : - 230 945 : pthread_mutex_unlock(&msg_lock); - 231 945 : } + 230 994 : pthread_mutex_unlock(&msg_lock); + 231 994 : } 232 : - 233 127002 : void msg_verbose(const char* format, ...) + 233 126828 : void msg_verbose(const char* format, ...) 234 : { 235 : va_list ap; 236 : - 237 127002 : pthread_mutex_lock(&msg_lock); + 237 126828 : pthread_mutex_lock(&msg_lock); 238 : - 239 127002 : if (stdlog) { - 240 125226 : va_start(ap, format); - 241 125226 : fprintf(stdlog, "msg:verbose: "); - 242 125226 : vfprintf(stdlog, format, ap); - 243 125226 : fflush(stdlog); - 244 125226 : va_end(ap); + 239 126828 : if (stdlog) { + 240 125018 : va_start(ap, format); + 241 125018 : fprintf(stdlog, "msg:verbose: "); + 242 125018 : vfprintf(stdlog, format, ap); + 243 125018 : fflush(stdlog); + 244 125018 : va_end(ap); 245 : } 246 : - 247 127002 : if (msg_level >= MSG_VERBOSE) { + 247 126828 : if (msg_level >= MSG_VERBOSE) { 248 79 : va_start(ap, format); 249 79 : vfprintf(stdout, format, ap); 250 79 : fflush(stdout); 251 79 : va_end(ap); 252 : } 253 : - 254 127002 : pthread_mutex_unlock(&msg_lock); - 255 127002 : } + 254 126828 : pthread_mutex_unlock(&msg_lock); + 255 126828 : } 256 : - 257 442 : void msg_flush(void) + 257 460 : void msg_flush(void) 258 : { - 259 442 : pthread_mutex_lock(&msg_lock); + 259 460 : pthread_mutex_lock(&msg_lock); 260 : - 261 442 : fflush(stdout); - 262 442 : fflush(stderr); + 261 460 : fflush(stdout); + 262 460 : fflush(stderr); 263 : - 264 442 : pthread_mutex_unlock(&msg_lock); - 265 442 : } + 264 460 : pthread_mutex_unlock(&msg_lock); + 265 460 : } 266 : 267 : /** 268 : * Number of buffers for esc(). @@ -351,20 +351,20 @@ 289 : *p++ = to; \ 290 : break 291 : - 292 3612178 : const char* esc(const char* str) + 292 3608964 : const char* esc(const char* str) 293 : { - 294 3612178 : char* begin = esc_table[esc_index]; - 295 3612178 : char* end = begin + PATH_MAX; - 296 3612178 : char* p = begin; + 294 3608964 : char* begin = esc_table[esc_index]; + 295 3608964 : char* end = begin + PATH_MAX; + 296 3608964 : char* p = begin; 297 : 298 : /* next call uses the next buffer */ - 299 3612178 : esc_index = (esc_index + 1) % ESC_MAX; + 299 3608964 : esc_index = (esc_index + 1) % ESC_MAX; 300 : 301 : /* copy string with escaping */ - 302 53980125 : while (*str) { - 303 46755769 : char c = *str; + 302 53928048 : while (*str) { + 303 46710120 : char c = *str; 304 : - 305 46755769 : switch (c) { + 305 46710120 : switch (c) { 306 : 307 0 : ESCAPE('\n', 'n'); 308 0 : ESCAPE('\r', 'r'); @@ -372,21 +372,21 @@ 310 0 : ESCAPE('\\', '\\'); 311 : 312 : default: - 313 46755769 : if (p == end) + 313 46710120 : if (p == end) 314 0 : goto bail; - 315 46755769 : *p++ = c; - 316 46755769 : break; + 315 46710120 : *p++ = c; + 316 46710120 : break; 317 : } 318 : - 319 46755769 : ++str; + 319 46710120 : ++str; 320 : } 321 : 322 : /* put final 0 */ - 323 3612178 : if (p == end) + 323 3608964 : if (p == end) 324 0 : goto bail; - 325 3612178 : *p = 0; + 325 3608964 : *p = 0; 326 : - 327 7224356 : return begin; + 327 7217928 : return begin; 328 : 329 : bail: 330 : /* LCOV_EXCL_START */ @@ -411,34 +411,34 @@ 349 : /****************************************************************************/ 350 : /* path */ 351 : - 352 6956056 : void pathcpy(char* dst, size_t size, const char* src) + 352 6957833 : void pathcpy(char* dst, size_t size, const char* src) 353 : { - 354 6956056 : size_t len = strlen(src); + 354 6957833 : size_t len = strlen(src); 355 : - 356 6956056 : if (len + 1 > size) { + 356 6957833 : if (len + 1 > size) { 357 : /* LCOV_EXCL_START */ 358 : log_fatal("Path too long '%s'\n", src); 359 : os_abort(); 360 : /* LCOV_EXCL_STOP */ 361 : } 362 : - 363 6956056 : memcpy(dst, src, len + 1); - 364 6956056 : } + 363 6957833 : memcpy(dst, src, len + 1); + 364 6957833 : } 365 : - 366 256 : void pathcat(char* dst, size_t size, const char* src) + 366 258 : void pathcat(char* dst, size_t size, const char* src) 367 : { - 368 256 : size_t dst_len = strlen(dst); - 369 256 : size_t src_len = strlen(src); + 368 258 : size_t dst_len = strlen(dst); + 369 258 : size_t src_len = strlen(src); 370 : - 371 256 : if (dst_len + src_len + 1 > size) { + 371 258 : if (dst_len + src_len + 1 > size) { 372 : /* LCOV_EXCL_START */ 373 : log_fatal("Path too long '%s%s'\n", dst, src); 374 : os_abort(); 375 : /* LCOV_EXCL_STOP */ 376 : } 377 : - 378 256 : memcpy(dst + dst_len, src, src_len + 1); - 379 256 : } + 378 258 : memcpy(dst + dst_len, src, src_len + 1); + 379 258 : } 380 : 381 788 : void pathcatc(char* dst, size_t size, char c) 382 : { @@ -455,9 +455,9 @@ 393 788 : dst[dst_len + 1] = 0; 394 788 : } 395 : - 396 9180 : void pathimport(char* dst, size_t size, const char* src) + 396 9262 : void pathimport(char* dst, size_t size, const char* src) 397 : { - 398 9180 : pathcpy(dst, size, src); + 398 9262 : pathcpy(dst, size, src); 399 : 400 : #ifdef _WIN32 401 : /* convert all Windows '\' to C '/' */ @@ -467,11 +467,11 @@ 405 : ++dst; 406 : } 407 : #endif - 408 9180 : } + 408 9262 : } 409 : - 410 17583 : void pathexport(char* dst, size_t size, const char* src) + 410 17589 : void pathexport(char* dst, size_t size, const char* src) 411 : { - 412 17583 : pathcpy(dst, size, src); + 412 17589 : pathcpy(dst, size, src); 413 : 414 : #ifdef _WIN32 415 : /* convert all C '/' to Windows '\' */ @@ -481,18 +481,18 @@ 419 : ++dst; 420 : } 421 : #endif - 422 17583 : } + 422 17589 : } 423 : - 424 50908928 : void pathprint(char* dst, size_t size, const char* format, ...) + 424 50920352 : void pathprint(char* dst, size_t size, const char* format, ...) 425 : { 426 : size_t len; 427 : va_list ap; 428 : - 429 50908928 : va_start(ap, format); - 430 50908928 : len = vsnprintf(dst, size, format, ap); - 431 50908928 : va_end(ap); + 429 50920352 : va_start(ap, format); + 430 50920352 : len = vsnprintf(dst, size, format, ap); + 431 50920352 : va_end(ap); 432 : - 433 50908928 : if (len >= size) { + 433 50920352 : if (len >= size) { 434 : /* LCOV_EXCL_START */ 435 : if (size > 0) { 436 : dst[size - 1] = 0; @@ -503,13 +503,13 @@ 441 : os_abort(); 442 : /* LCOV_EXCL_STOP */ 443 : } - 444 50908928 : } + 444 50920352 : } 445 : - 446 7469 : void pathslash(char* dst, size_t size) + 446 7481 : void pathslash(char* dst, size_t size) 447 : { - 448 7469 : size_t len = strlen(dst); + 448 7481 : size_t len = strlen(dst); 449 : - 450 7469 : if (len > 0 && dst[len - 1] != '/') { + 450 7481 : if (len > 0 && dst[len - 1] != '/') { 451 5944 : if (len + 2 >= size) { 452 : /* LCOV_EXCL_START */ 453 : log_fatal("Path too long '%s/'\n", dst); @@ -520,7 +520,7 @@ 458 5944 : dst[len] = '/'; 459 5944 : dst[len + 1] = 0; 460 : } - 461 7469 : } + 461 7481 : } 462 : 463 30 : void pathcut(char* dst) 464 : { @@ -531,7 +531,7 @@ 469 0 : dst[0] = 0; 470 30 : } 471 : - 472 51328958 : int pathcmp(const char* a, const char* b) + 472 51339645 : int pathcmp(const char* a, const char* b) 473 : { 474 : #ifdef _WIN32 475 : char ai[PATH_MAX]; @@ -544,32 +544,32 @@ 482 : /* case insensitive compare in Windows */ 483 : return stricmp(ai, bi); 484 : #else - 485 51328958 : return strcmp(a, b); + 485 51339645 : return strcmp(a, b); 486 : #endif 487 : } 488 : 489 : /****************************************************************************/ 490 : /* file-system */ 491 : - 492 793073 : int mkancestor(const char* file) + 492 793150 : int mkancestor(const char* file) 493 : { 494 : char dir[PATH_MAX]; 495 : struct stat st; 496 : char* c; 497 : - 498 793073 : pathcpy(dir, sizeof(dir), file); + 498 793150 : pathcpy(dir, sizeof(dir), file); 499 : - 500 793073 : c = strrchr(dir, '/'); - 501 793073 : if (!c) { + 500 793150 : c = strrchr(dir, '/'); + 501 793150 : if (!c) { 502 : /* no ancestor */ 503 0 : return 0; 504 : } 505 : 506 : /* clear the file */ - 507 793073 : *c = 0; + 507 793150 : *c = 0; 508 : 509 : /* if it's the root dir */ - 510 793073 : if (*dir == 0) { + 510 793150 : if (*dir == 0) { 511 : /* nothing more to do */ 512 0 : return 0; 513 : } @@ -592,9 +592,9 @@ 530 : * Also in Windows it's better to use lstat() than stat() because it 531 : * doen't need to open the dir with CreateFile(). 532 : */ - 533 793073 : if (lstat(dir, &st) == 0) { + 533 793150 : if (lstat(dir, &st) == 0) { 534 : /* it already exists */ - 535 792993 : return 0; + 535 793070 : return 0; 536 : } 537 : 538 : /* recursively create them all */ @@ -615,7 +615,7 @@ 553 80 : return 0; 554 : } 555 : - 556 119629 : int fmtime(int f, int64_t mtime_sec, int mtime_nsec) + 556 119699 : int fmtime(int f, int64_t mtime_sec, int mtime_nsec) 557 : { 558 : #if HAVE_FUTIMENS 559 : struct timespec tv[2]; @@ -625,15 +625,15 @@ 563 : int ret; 564 : 565 : #if HAVE_FUTIMENS /* futimens() is preferred because it gives nanosecond precision */ - 566 119629 : tv[0].tv_sec = mtime_sec; - 567 119629 : if (mtime_nsec != STAT_NSEC_INVALID) - 568 119629 : tv[0].tv_nsec = mtime_nsec; + 566 119699 : tv[0].tv_sec = mtime_sec; + 567 119699 : if (mtime_nsec != STAT_NSEC_INVALID) + 568 119699 : tv[0].tv_nsec = mtime_nsec; 569 : else 570 0 : tv[0].tv_nsec = 0; - 571 119629 : tv[1].tv_sec = tv[0].tv_sec; - 572 119629 : tv[1].tv_nsec = tv[0].tv_nsec; + 571 119699 : tv[1].tv_sec = tv[0].tv_sec; + 572 119699 : tv[1].tv_nsec = tv[0].tv_nsec; 573 : - 574 119629 : ret = futimens(f, tv); + 574 119699 : ret = futimens(f, tv); 575 : #elif HAVE_FUTIMES /* fallback to futimes() if nanosecond precision is not available */ 576 : tv[0].tv_sec = mtime_sec; 577 : if (mtime_nsec != STAT_NSEC_INVALID) @@ -658,7 +658,7 @@ 596 : #error No function available to set file timestamps with sub-second precision 597 : #endif 598 : - 599 119629 : return ret; + 599 119699 : return ret; 600 : } 601 : 602 : /****************************************************************************/ @@ -676,29 +676,29 @@ 614 : pthread_mutex_t mcounter_mutex = PTHREAD_MUTEX_INITIALIZER; 615 : #endif 616 : - 617 460 : size_t malloc_counter_get(void) + 617 464 : size_t malloc_counter_get(void) 618 : { 619 : size_t ret; 620 : #if HAVE_PTHREAD - 621 460 : pthread_mutex_lock(&mcounter_mutex); + 621 464 : pthread_mutex_lock(&mcounter_mutex); 622 : #endif - 623 460 : ret = mcounter; + 623 464 : ret = mcounter; 624 : #if HAVE_PTHREAD - 625 460 : pthread_mutex_unlock(&mcounter_mutex); + 625 464 : pthread_mutex_unlock(&mcounter_mutex); 626 : #endif - 627 460 : return ret; + 627 464 : return ret; 628 : } 629 : - 630 19792624 : void malloc_counter_inc(size_t inc) + 630 19797017 : void malloc_counter_inc(size_t inc) 631 : { 632 : #if HAVE_PTHREAD - 633 19792624 : pthread_mutex_lock(&mcounter_mutex); + 633 19797017 : pthread_mutex_lock(&mcounter_mutex); 634 : #endif - 635 19792624 : mcounter += inc; + 635 19797017 : mcounter += inc; 636 : #if HAVE_PTHREAD - 637 19792624 : pthread_mutex_unlock(&mcounter_mutex); + 637 19797017 : pthread_mutex_unlock(&mcounter_mutex); 638 : #endif - 639 19792624 : } + 639 19797017 : } 640 : 641 : /* LCOV_EXCL_START */ 642 : static ssize_t malloc_print(int f, const char* str) @@ -749,11 +749,11 @@ 687 : } 688 : /* LCOV_EXCL_STOP */ 689 : - 690 14067108 : void* malloc_nofail(size_t size) + 690 14070101 : void* malloc_nofail(size_t size) 691 : { - 692 14067108 : void* ptr = malloc(size); + 692 14070101 : void* ptr = malloc(size); 693 : - 694 14067108 : if (!ptr) { + 694 14070101 : if (!ptr) { 695 : /* LCOV_EXCL_START */ 696 : malloc_fail(size); 697 : exit(EXIT_FAILURE); @@ -767,58 +767,58 @@ 705 : /* Filling the memory doesn't ensure to disable OOM, but it increase a lot the chances to */ 706 : /* get a real error from malloc() instead than a process killed. */ 707 : /* Note that calloc() doesn't have the same effect. */ - 708 14067108 : memset(ptr, 0xA5, size); + 708 14070101 : memset(ptr, 0xA5, size); 709 : #endif 710 : - 711 14067108 : malloc_counter_inc(size); + 711 14070101 : malloc_counter_inc(size); 712 : - 713 14067108 : return ptr; + 713 14070101 : return ptr; 714 : } 715 : - 716 9576 : void* calloc_nofail(size_t count, size_t size) + 716 9648 : void* calloc_nofail(size_t count, size_t size) 717 : { 718 : void* ptr; 719 : - 720 9576 : size *= count; + 720 9648 : size *= count; 721 : 722 : /* see the note in malloc_nofail() of why we don't use calloc() */ - 723 9576 : ptr = malloc(size); + 723 9648 : ptr = malloc(size); 724 : - 725 9576 : if (!ptr) { + 725 9648 : if (!ptr) { 726 : /* LCOV_EXCL_START */ 727 : malloc_fail(size); 728 : exit(EXIT_FAILURE); 729 : /* LCOV_EXCL_STOP */ 730 : } 731 : - 732 9576 : memset(ptr, 0, size); + 732 9648 : memset(ptr, 0, size); 733 : - 734 9576 : malloc_counter_inc(size); + 734 9648 : malloc_counter_inc(size); 735 : - 736 9576 : return ptr; + 736 9648 : return ptr; 737 : } 738 : - 739 5715940 : char* strdup_nofail(const char* str) + 739 5717268 : char* strdup_nofail(const char* str) 740 : { 741 : size_t size; 742 : char* ptr; 743 : - 744 5715940 : size = strlen(str) + 1; + 744 5717268 : size = strlen(str) + 1; 745 : - 746 5715940 : ptr = malloc(size); + 746 5717268 : ptr = malloc(size); 747 : - 748 5715940 : if (!ptr) { + 748 5717268 : if (!ptr) { 749 : /* LCOV_EXCL_START */ 750 : malloc_fail(size); 751 : exit(EXIT_FAILURE); 752 : /* LCOV_EXCL_STOP */ 753 : } 754 : - 755 5715940 : memcpy(ptr, str, size); + 755 5717268 : memcpy(ptr, str, size); 756 : - 757 5715940 : malloc_counter_inc(size); + 757 5717268 : malloc_counter_inc(size); 758 : - 759 5715940 : return ptr; + 759 5717268 : return ptr; 760 : } 761 : 762 : /****************************************************************************/ @@ -866,8 +866,8 @@ 804 : char* s; 805 : 806 25 : s = fgets(buf, sizeof(buf), f); - 807 24 : if (s == 0) - 808 24 : break; + 807 25 : if (s == 0) + 808 25 : break; 809 : 810 : /* remove extraneous chars */ 811 0 : s = polish(buf); @@ -917,7 +917,7 @@ 855 : } 856 0 : } 857 : - 858 24 : return 0; + 858 25 : return 0; 859 : } 860 : 861 12 : int smartctl_flush(FILE* f, const char* file, const char* name) diff --git a/cov/cmdline/sync.c.func-sort-c.html b/cov/cmdline/sync.c.func-sort-c.html index bb2fb51e..292bb4ca 100644 --- a/cov/cmdline/sync.c.func-sort-c.html +++ b/cov/cmdline/sync.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ block_is_enabled - 772244 + 773300 state_sync - 80 + 82 state_sync_process - 76 + 78 state_hash_process diff --git a/cov/cmdline/sync.c.func.html b/cov/cmdline/sync.c.func.html index b1272bb6..5741960e 100644 --- a/cov/cmdline/sync.c.func.html +++ b/cov/cmdline/sync.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,7 +61,7 @@ block_is_enabled - 772244 + 773300 state_hash_process @@ -69,11 +69,11 @@ state_sync - 80 + 82 state_sync_process - 76 + 78
diff --git a/cov/cmdline/sync.c.gcov.html b/cov/cmdline/sync.c.gcov.html index c1ef01a5..cf1e41bd 100644 --- a/cov/cmdline/sync.c.gcov.html +++ b/cov/cmdline/sync.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -123,18 +123,18 @@ 61 42 : if (!disk) 62 0 : continue; 63 : - 64 236382 : for (i = blockstart; i < blockmax; ++i) { + 64 236670 : for (i = blockstart; i < blockmax; ++i) { 65 : struct snapraid_block* block; 66 : unsigned block_state; 67 : - 68 236340 : block = fs_par2block_get(disk, i); + 68 236628 : block = fs_par2block_get(disk, i); 69 : 70 : /* get the state of the block */ - 71 236340 : block_state = block_state_get(block); + 71 236628 : block_state = block_state_get(block); 72 : 73 : /* process REP and CHG blocks */ - 74 236340 : if (block_state != BLOCK_STATE_REP && block_state != BLOCK_STATE_CHG) - 75 222990 : continue; + 74 236628 : if (block_state != BLOCK_STATE_REP && block_state != BLOCK_STATE_CHG) + 75 223278 : continue; 76 : 77 13350 : ++countmax; 78 : } @@ -155,7 +155,7 @@ 93 42 : if (!disk) 94 0 : continue; 95 : - 96 236382 : for (i = blockstart; i < blockmax; ++i) { + 96 236670 : for (i = blockstart; i < blockmax; ++i) { 97 : snapraid_info info; 98 : int rehash; 99 : struct snapraid_block* block; @@ -165,14 +165,14 @@ 103 : struct snapraid_file* file; 104 : block_off_t file_pos; 105 : - 106 236340 : block = fs_par2block_get(disk, i); + 106 236628 : block = fs_par2block_get(disk, i); 107 : 108 : /* get the state of the block */ - 109 236340 : block_state = block_state_get(block); + 109 236628 : block_state = block_state_get(block); 110 : 111 : /* process REP and CHG blocks */ - 112 236340 : if (block_state != BLOCK_STATE_REP && block_state != BLOCK_STATE_CHG) - 113 445990 : continue; + 112 236628 : if (block_state != BLOCK_STATE_REP && block_state != BLOCK_STATE_CHG) + 113 446566 : continue; 114 : 115 : /* get the file of this block */ 116 13350 : file = fs_par2file_get(disk, i, &file_pos); @@ -466,39 +466,39 @@ 404 : /** 405 : * Check if we have to process the specified block index ::i. 406 : */ - 407 772244 : static int block_is_enabled(block_off_t i, struct snapraid_handle* handle, unsigned diskmax) + 407 773300 : static int block_is_enabled(block_off_t i, struct snapraid_handle* handle, unsigned diskmax) 408 : { 409 : unsigned j; 410 : int one_invalid; 411 : int one_valid; 412 : 413 : /* for each disk */ - 414 772244 : one_invalid = 0; - 415 772244 : one_valid = 0; - 416 5405708 : for (j = 0; j < diskmax; ++j) { + 414 773300 : one_invalid = 0; + 415 773300 : one_valid = 0; + 416 5413100 : for (j = 0; j < diskmax; ++j) { 417 : struct snapraid_block* block; 418 : 419 : /* if no disk, nothing to check */ - 420 4633464 : if (!handle[j].disk) - 421 9358 : continue; + 420 4639800 : if (!handle[j].disk) + 421 9374 : continue; 422 : - 423 4624106 : block = fs_par2block_get(handle[j].disk, i); + 423 4630426 : block = fs_par2block_get(handle[j].disk, i); 424 : - 425 4624106 : if (block_has_file(block)) - 426 4407290 : one_valid = 1; + 425 4630426 : if (block_has_file(block)) + 426 4410490 : one_valid = 1; 427 : - 428 4624106 : if (block_has_invalid_parity(block)) - 429 469940 : one_invalid = 1; + 428 4630426 : if (block_has_invalid_parity(block)) + 429 470272 : one_invalid = 1; 430 : } 431 : 432 : /* if none valid or none invalid, we don't need to update */ - 433 772244 : if (!one_invalid || !one_valid) - 434 589930 : return 0; + 433 773300 : if (!one_invalid || !one_valid) + 434 590814 : return 0; 435 : - 436 182314 : return 1; + 436 182486 : return 1; 437 : } 438 : - 439 76 : static int state_sync_process(struct snapraid_state* state, struct snapraid_parity_handle** parity, block_off_t blockstart, block_off_t blockmax) + 439 78 : static int state_sync_process(struct snapraid_state* state, struct snapraid_parity_handle** parity, block_off_t blockstart, block_off_t blockmax) 440 : { 441 : struct snapraid_handle* handle; 442 : void* rehandle_alloc; @@ -526,59 +526,59 @@ 464 : 465 : /* the sync process assumes that all the hashes are correct */ 466 : /* including the ones from CHG and DELETED blocks */ - 467 76 : assert(state->clear_past_hash != 0); + 467 78 : assert(state->clear_past_hash != 0); 468 : 469 : /* get the present time */ - 470 76 : now = time(0); + 470 78 : now = time(0); 471 : 472 : /* maps the disks to handles */ - 473 76 : handle = handle_map(state, &diskmax); + 473 78 : handle = handle_map(state, &diskmax); 474 : 475 : /* rehash buffers */ - 476 76 : rehandle = malloc_nofail_align(diskmax * sizeof(struct snapraid_rehash), &rehandle_alloc); + 476 78 : rehandle = malloc_nofail_align(diskmax * sizeof(struct snapraid_rehash), &rehandle_alloc); 477 : 478 : /* we need 2 * data + 1 * parity + 1 * zero */ - 479 76 : buffermax = 2 * diskmax + state->level + 1; + 479 78 : buffermax = 2 * diskmax + state->level + 1; 480 : - 481 76 : buffer = malloc_nofail_vector_align(diskmax, buffermax, state->block_size, &buffer_alloc); - 482 76 : if (!state->opt.skip_self) + 481 78 : buffer = malloc_nofail_vector_align(diskmax, buffermax, state->block_size, &buffer_alloc); + 482 78 : if (!state->opt.skip_self) 483 0 : mtest_vector(buffermax, state->block_size, buffer); 484 : 485 : /* fill up the zero buffer */ - 486 76 : memset(buffer[buffermax - 1], 0, state->block_size); - 487 76 : raid_zero(buffer[buffermax - 1]); + 486 78 : memset(buffer[buffermax - 1], 0, state->block_size); + 487 78 : raid_zero(buffer[buffermax - 1]); 488 : - 489 76 : failed = malloc_nofail(diskmax * sizeof(struct failed_struct)); - 490 76 : failed_map = malloc_nofail(diskmax * sizeof(unsigned)); + 489 78 : failed = malloc_nofail(diskmax * sizeof(struct failed_struct)); + 490 78 : failed_map = malloc_nofail(diskmax * sizeof(unsigned)); 491 : - 492 76 : error = 0; - 493 76 : silent_error = 0; - 494 76 : io_error = 0; + 492 78 : error = 0; + 493 78 : silent_error = 0; + 494 78 : io_error = 0; 495 : 496 : /* first count the number of blocks to process */ - 497 76 : countmax = 0; - 498 386198 : for (i = blockstart; i < blockmax; ++i) { - 499 386122 : if (!block_is_enabled(i, handle, diskmax)) - 500 294965 : continue; - 501 91157 : ++countmax; + 497 78 : countmax = 0; + 498 386728 : for (i = blockstart; i < blockmax; ++i) { + 499 386650 : if (!block_is_enabled(i, handle, diskmax)) + 500 295407 : continue; + 501 91243 : ++countmax; 502 : } 503 : 504 : /* compute the autosave size for all disk, even if not read */ 505 : /* this makes sense because the speed should be almost the same */ 506 : /* if the disks are read in parallel */ - 507 76 : autosavelimit = state->autosave / (diskmax * state->block_size); - 508 76 : autosavemissing = countmax; /* blocks to do */ - 509 76 : autosavedone = 0; /* blocks done */ + 507 78 : autosavelimit = state->autosave / (diskmax * state->block_size); + 508 78 : autosavemissing = countmax; /* blocks to do */ + 509 78 : autosavedone = 0; /* blocks done */ 510 : 511 : /* drop until now */ - 512 76 : state_usage_waste(state); + 512 78 : state_usage_waste(state); 513 : - 514 76 : countsize = 0; - 515 76 : countpos = 0; - 516 76 : if (!state_progress_begin(state, blockstart, blockmax, countmax)) + 514 78 : countsize = 0; + 515 78 : countpos = 0; + 516 78 : if (!state_progress_begin(state, blockstart, blockmax, countmax)) 517 0 : goto end; 518 : - 519 386198 : for (i = blockstart; i < blockmax; ++i) { + 519 386728 : for (i = blockstart; i < blockmax; ++i) { 520 : unsigned failed_count; 521 : int error_on_this_block; 522 : int silent_error_on_this_block; @@ -588,27 +588,27 @@ 526 : snapraid_info info; 527 : int rehash; 528 : - 529 386122 : if (!block_is_enabled(i, handle, diskmax)) - 530 294965 : continue; + 529 386650 : if (!block_is_enabled(i, handle, diskmax)) + 530 295407 : continue; 531 : 532 : /* one more block processed for autosave */ - 533 91157 : ++autosavedone; - 534 91157 : --autosavemissing; + 533 91243 : ++autosavedone; + 534 91243 : --autosavemissing; 535 : 536 : /* by default process the block, and skip it if something go wrong */ - 537 91157 : error_on_this_block = 0; - 538 91157 : silent_error_on_this_block = 0; - 539 91157 : io_error_on_this_block = 0; - 540 91157 : fixed_error_on_this_block = 0; + 537 91243 : error_on_this_block = 0; + 538 91243 : silent_error_on_this_block = 0; + 539 91243 : io_error_on_this_block = 0; + 540 91243 : fixed_error_on_this_block = 0; 541 : 542 : /* keep track of the number of failed blocks */ - 543 91157 : failed_count = 0; + 543 91243 : failed_count = 0; 544 : 545 : /* get block specific info */ - 546 91157 : info = info_get(&state->infoarr, i); + 546 91243 : info = info_get(&state->infoarr, i); 547 : 548 : /* if we have to use the old hash */ - 549 91157 : rehash = info_get_rehash(info); + 549 91243 : rehash = info_get_rehash(info); 550 : 551 : /* it could happens that all the blocks are EMPTY/BLK and CHG but with the hash */ 552 : /* still matching because the specific CHG block was not modified. */ @@ -616,55 +616,55 @@ 554 : /* have the hash cleared (::clear_past_hash flag), and then they won't never match the hash. */ 555 : /* We are treating only CHG blocks created at runtime. */ 556 : /* In such case, we can avoid to update parity, because it would be the same as before */ - 557 91157 : parity_needs_to_be_updated = state->opt.force_parity_update; + 557 91243 : parity_needs_to_be_updated = state->opt.force_parity_update; 558 : 559 : /* if the block is marked as bad, we force the parity update */ 560 : /* because the bad block may be the result of a wrong parity */ - 561 91157 : if (info_get_bad(info)) + 561 91243 : if (info_get_bad(info)) 562 0 : parity_needs_to_be_updated = 1; 563 : 564 : /* for each disk, process the block */ - 565 638099 : for (j = 0; j < diskmax; ++j) { + 565 638701 : for (j = 0; j < diskmax; ++j) { 566 : int read_size; 567 : unsigned char hash[HASH_SIZE]; 568 : struct snapraid_block* block; 569 : unsigned block_state; - 570 546942 : struct snapraid_disk* disk = handle[j].disk; + 570 547458 : struct snapraid_disk* disk = handle[j].disk; 571 : struct snapraid_file* file; 572 : block_off_t file_pos; 573 : 574 : /* by default no rehash in case of "continue" */ - 575 546942 : rehandle[j].block = 0; + 575 547458 : rehandle[j].block = 0; 576 : 577 : /* if the disk position is not used */ - 578 546942 : if (!disk) { + 578 547458 : if (!disk) { 579 : /* use an empty block */ 580 0 : memset(buffer[j], 0, state->block_size); - 581 91088 : continue; + 581 91560 : continue; 582 : } 583 : 584 : /* get the block */ - 585 546942 : block = fs_par2block_get(disk, i); + 585 547458 : block = fs_par2block_get(disk, i); 586 : 587 : /* get the state of the block */ - 588 546942 : block_state = block_state_get(block); + 588 547458 : block_state = block_state_get(block); 589 : 590 : /* if the block has invalid parity, */ 591 : /* we have to take care of it in case of recover */ - 592 546942 : if (block_has_invalid_parity(block)) { + 592 547458 : if (block_has_invalid_parity(block)) { 593 : /* store it in the failed set, because */ 594 : /* the parity may be still computed with the previous content */ - 595 234970 : failed[failed_count].index = j; - 596 234970 : failed[failed_count].size = state->block_size; - 597 234970 : failed[failed_count].block = block; - 598 234970 : ++failed_count; + 595 235136 : failed[failed_count].index = j; + 596 235136 : failed[failed_count].size = state->block_size; + 597 235136 : failed[failed_count].block = block; + 598 235136 : ++failed_count; 599 : 600 : /* if the block has invalid parity, we have to update the parity */ 601 : /* to include this block change */ 602 : /* This also apply to CHG blocks, but we are going to handle */ 603 : /* later this case to do the updates only if really needed */ - 604 234970 : if (block_state != BLOCK_STATE_CHG) - 605 140521 : parity_needs_to_be_updated = 1; + 604 235136 : if (block_state != BLOCK_STATE_CHG) + 605 140613 : parity_needs_to_be_updated = 1; 606 : 607 : /* note that DELETE blocks are skipped in the next check */ 608 : /* and we have to store them in the failed blocks */ @@ -675,24 +675,24 @@ 613 : 614 : /* if the block has no file, meanining that it's EMPTY or DELETED, */ 615 : /* it doesn't partecipate in the new parity computation */ - 616 546942 : if (!block_has_file(block)) { + 616 547458 : if (!block_has_file(block)) { 617 : /* use an empty block */ - 618 90218 : memset(buffer[j], 0, state->block_size); - 619 90218 : continue; + 618 90689 : memset(buffer[j], 0, state->block_size); + 619 90689 : continue; 620 : } 621 : 622 : /* get the file of this block */ - 623 456724 : file = fs_par2file_get(disk, i, &file_pos); + 623 456769 : file = fs_par2file_get(disk, i, &file_pos); 624 : 625 : /* until now is CPU */ - 626 456724 : state_usage_cpu(state); + 626 456769 : state_usage_cpu(state); 627 : 628 : /* if the file is different than the current one, close it */ - 629 456724 : if (handle[j].file != 0 && handle[j].file != file) { + 629 456769 : if (handle[j].file != 0 && handle[j].file != file) { 630 : /* keep a pointer at the file we are going to close for error reporting */ - 631 189542 : struct snapraid_file* report = handle[j].file; - 632 189542 : ret = handle_close(&handle[j]); - 633 189542 : if (ret == -1) { + 631 189414 : struct snapraid_file* report = handle[j].file; + 632 189414 : ret = handle_close(&handle[j]); + 633 189414 : if (ret == -1) { 634 : /* LCOV_EXCL_START */ 635 : /* This one is really an unexpected error, because we are only reading */ 636 : /* and closing a descriptor should never fail */ @@ -715,8 +715,8 @@ 653 : } 654 : } 655 : - 656 456724 : ret = handle_open(&handle[j], file, state->file_mode, log_error, 0); - 657 456724 : if (ret == -1) { + 656 456769 : ret = handle_open(&handle[j], file, state->file_mode, log_error, 0); + 657 456769 : if (ret == -1) { 658 12 : if (errno == EIO) { 659 : /* LCOV_EXCL_START */ 660 : log_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); @@ -762,10 +762,10 @@ 700 : } 701 : 702 : /* check if the file is changed */ - 703 456712 : if (handle[j].st.st_size != file->size - 704 456710 : || handle[j].st.st_mtime != file->mtime_sec - 705 456708 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec - 706 456708 : || handle[j].st.st_ino != file->inode + 703 456757 : if (handle[j].st.st_size != file->size + 704 456755 : || handle[j].st.st_mtime != file->mtime_sec + 705 456753 : || STAT_NSEC(&handle[j].st) != file->mtime_nsec + 706 456753 : || handle[j].st.st_ino != file->inode 707 : ) { 708 6 : log_tag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, esc(file->sub)); 709 6 : if (handle[j].st.st_size != file->size) { @@ -785,8 +785,8 @@ 723 6 : continue; 724 : } 725 : - 726 456706 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, log_error, 0); - 727 456706 : if (read_size == -1) { + 726 456751 : read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, log_error, 0); + 727 456751 : if (read_size == -1) { 728 : /* LCOV_EXCL_START */ 729 : if (errno == EIO) { 730 : log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), file_pos, strerror(errno)); @@ -814,26 +814,26 @@ 752 : } 753 : 754 : /* until now is disk */ - 755 456706 : state_usage_disk(state, disk); + 755 456751 : state_usage_disk(state, disk); 756 : - 757 456706 : countsize += read_size; + 757 456751 : countsize += read_size; 758 : 759 : /* now compute the hash */ - 760 456706 : if (rehash) { - 761 27231 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); + 760 456751 : if (rehash) { + 761 27243 : memhash(state->prevhash, state->prevhashseed, hash, buffer[j], read_size); 762 : 763 : /* compute the new hash, and store it */ - 764 27231 : rehandle[j].block = block; - 765 27231 : memhash(state->hash, state->hashseed, rehandle[j].hash, buffer[j], read_size); + 764 27243 : rehandle[j].block = block; + 765 27243 : memhash(state->hash, state->hashseed, rehandle[j].hash, buffer[j], read_size); 766 : } else { - 767 429475 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); + 767 429508 : memhash(state->hash, state->hashseed, hash, buffer[j], read_size); 768 : } 769 : - 770 456706 : if (block_has_updated_hash(block)) { + 770 456751 : if (block_has_updated_hash(block)) { 771 : /* compare the hash */ - 772 362275 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { + 772 362246 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { 773 : /* if the file has invalid parity, it's a REP changed during the sync */ - 774 852 : if (block_has_invalid_parity(block)) { + 774 853 : if (block_has_invalid_parity(block)) { 775 1 : log_tag("error:%u:%s:%s: Unexpected data change\n", i, disk->name, esc(file->sub)); 776 1 : log_error("Data change at file '%s' at position '%u'\n", handle[j].path, file_pos); 777 1 : log_error("WARNING! Unexpected data modification of a file without parity!\n"); @@ -854,48 +854,48 @@ 792 1 : error_on_this_block = 1; 793 1 : continue; 794 : } else { /* otherwise it's a BLK with silent error */ - 795 851 : unsigned diff = memdiff(hash, block->hash, HASH_SIZE); - 796 851 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc(file->sub), file_pos, diff); - 797 851 : log_error("Data error in file '%s' at position '%u', diff bits %u\n", handle[j].path, file_pos, diff); + 795 852 : unsigned diff = memdiff(hash, block->hash, HASH_SIZE); + 796 852 : log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u\n", i, disk->name, esc(file->sub), file_pos, diff); + 797 852 : log_error("Data error in file '%s' at position '%u', diff bits %u\n", handle[j].path, file_pos, diff); 798 : 799 : /* save the failed block for the fix */ - 800 851 : failed[failed_count].index = j; - 801 851 : failed[failed_count].size = read_size; - 802 851 : failed[failed_count].block = block; - 803 851 : ++failed_count; + 800 852 : failed[failed_count].index = j; + 801 852 : failed[failed_count].size = read_size; + 802 852 : failed[failed_count].block = block; + 803 852 : ++failed_count; 804 : 805 : /* silent errors are very rare, and are not a signal that a disk */ 806 : /* is going to fail. So, we just continue marking the block as bad */ 807 : /* just like in scrub */ - 808 851 : ++silent_error; - 809 851 : silent_error_on_this_block = 1; - 810 851 : continue; + 808 852 : ++silent_error; + 809 852 : silent_error_on_this_block = 1; + 810 852 : continue; 811 : } 812 : } 813 : } else { 814 : /* if until now the parity doesn't need to be updated */ - 815 94431 : if (!parity_needs_to_be_updated) { + 815 94505 : if (!parity_needs_to_be_updated) { 816 : /* for sure it's a CHG block, because EMPTY are processed before with "continue" */ 817 : /* and BLK and REP have "block_has_updated_hash()" as 1, and all the others */ 818 : /* have "parity_needs_to_be_updated" already at 1 */ - 819 35089 : assert(block_state_get(block) == BLOCK_STATE_CHG); + 819 35168 : assert(block_state_get(block) == BLOCK_STATE_CHG); 820 : 821 : /* if there is an hash */ - 822 35089 : if (hash_is_real(block->hash)) { + 822 35168 : if (hash_is_real(block->hash)) { 823 : /* check if the hash is changed */ - 824 8465 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { + 824 8494 : if (memcmp(hash, block->hash, HASH_SIZE) != 0) { 825 : /* the block is different, and we must update parity */ - 826 5991 : parity_needs_to_be_updated = 1; + 826 6000 : parity_needs_to_be_updated = 1; 827 : } 828 : } else { 829 : /* if the hash is already invalid, we update parity */ - 830 26624 : parity_needs_to_be_updated = 1; + 830 26674 : parity_needs_to_be_updated = 1; 831 : } 832 : } 833 : 834 : /* copy the hash in the block, but doesn't mark the block as hashed */ 835 : /* this allow in case of skipped block to do not save the failed computation */ - 836 94431 : memcpy(block->hash, hash, HASH_SIZE); + 836 94505 : memcpy(block->hash, hash, HASH_SIZE); 837 : 838 : /* note that in case of rehash, this is the wrong hash, */ 839 : /* but it will be overwritten later */ @@ -905,52 +905,52 @@ 843 : /* if we have only silent errors we can try to fix them on-the-fly */ 844 : /* note the the fix is not written to disk, but used only to */ 845 : /* compute the new parity */ - 846 91157 : if (!error_on_this_block && !io_error_on_this_block && silent_error_on_this_block) { + 846 91243 : if (!error_on_this_block && !io_error_on_this_block && silent_error_on_this_block) { 847 : unsigned failed_mac; - 848 851 : int something_to_recover = 0; + 848 852 : int something_to_recover = 0; 849 : 850 : /* setup the blocks to recover */ - 851 851 : failed_mac = 0; - 852 2553 : for (j = 0; j < failed_count; ++j) { - 853 1702 : unsigned char* block_buffer = buffer[failed[j].index]; - 854 1702 : unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index]; - 855 1702 : unsigned block_state = block_state_get(failed[j].block); + 851 852 : failed_mac = 0; + 852 2556 : for (j = 0; j < failed_count; ++j) { + 853 1704 : unsigned char* block_buffer = buffer[failed[j].index]; + 854 1704 : unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index]; + 855 1704 : unsigned block_state = block_state_get(failed[j].block); 856 : 857 : /* we try to recover only if at least one BLK is present */ - 858 1702 : if (block_state == BLOCK_STATE_BLK) - 859 851 : something_to_recover = 1; + 858 1704 : if (block_state == BLOCK_STATE_BLK) + 859 852 : something_to_recover = 1; 860 : 861 : /* save a copy of the content just read */ 862 : /* that it's going to be overwritten by the recovering function */ - 863 1702 : memcpy(block_copy, block_buffer, state->block_size); + 863 1704 : memcpy(block_copy, block_buffer, state->block_size); 864 : - 865 1702 : if (block_state == BLOCK_STATE_CHG - 866 851 : && hash_is_zero(failed[j].block->hash) + 865 1704 : if (block_state == BLOCK_STATE_CHG + 866 852 : && hash_is_zero(failed[j].block->hash) 867 : ) { 868 : /* if the block was filled with 0, restore this state */ 869 : /* and avoid to recover it */ 870 0 : memset(block_buffer, 0, state->block_size); 871 : } else { 872 : /* if we have too many failures, we cannot recover */ - 873 1702 : if (failed_mac >= state->level) + 873 1704 : if (failed_mac >= state->level) 874 0 : break; 875 : 876 : /* otherwise it has to be recovered */ - 877 1702 : failed_map[failed_mac++] = failed[j].index; + 877 1704 : failed_map[failed_mac++] = failed[j].index; 878 : } 879 : } 880 : 881 : /* if we have something to recover and enough parity */ - 882 851 : if (something_to_recover && j == failed_count) { + 882 852 : if (something_to_recover && j == failed_count) { 883 : /* until now is CPU */ - 884 851 : state_usage_cpu(state); + 884 852 : state_usage_cpu(state); 885 : 886 : /* read the parity */ 887 : /* we are sure that parity exists because */ 888 : /* we have at least one BLK block */ - 889 5957 : for (l = 0; l < state->level; ++l) { - 890 5106 : ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, log_error); - 891 5106 : if (ret == -1) { + 889 5964 : for (l = 0; l < state->level; ++l) { + 890 5112 : ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, log_error); + 891 5112 : if (ret == -1) { 892 : /* LCOV_EXCL_START */ 893 : if (errno == EIO) { 894 : log_tag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno)); @@ -978,74 +978,74 @@ 916 : } 917 : 918 : /* until now is parity */ - 919 5106 : state_usage_parity(state, l); + 919 5112 : state_usage_parity(state, l); 920 : } 921 : 922 : /* if no error in parity read */ - 923 851 : if (!io_error_on_this_block) { + 923 852 : if (!io_error_on_this_block) { 924 : /* try to fix the data */ 925 : /* note that this is a simple fix algorithm, that doesn't take into */ 926 : /* account the case of a wrong parity */ 927 : /* only 'fix' supports the most advanced fixing */ - 928 851 : raid_rec(failed_mac, failed_map, diskmax, state->level, state->block_size, buffer); + 928 852 : raid_rec(failed_mac, failed_map, diskmax, state->level, state->block_size, buffer); 929 : 930 : /* check the result and prepare the data */ - 931 5106 : for (j = 0; j < failed_count; ++j) { + 931 5112 : for (j = 0; j < failed_count; ++j) { 932 : unsigned char hash[HASH_SIZE]; - 933 1702 : unsigned char* block_buffer = buffer[failed[j].index]; - 934 1702 : unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index]; - 935 1702 : unsigned block_state = block_state_get(failed[j].block); + 933 1704 : unsigned char* block_buffer = buffer[failed[j].index]; + 934 1704 : unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index]; + 935 1704 : unsigned block_state = block_state_get(failed[j].block); 936 : - 937 1702 : if (block_state == BLOCK_STATE_BLK) { - 938 851 : unsigned size = failed[j].size; + 937 1704 : if (block_state == BLOCK_STATE_BLK) { + 938 852 : unsigned size = failed[j].size; 939 : 940 : /* compute the hash of the recovered block */ - 941 851 : if (rehash) { + 941 852 : if (rehash) { 942 0 : memhash(state->prevhash, state->prevhashseed, hash, block_buffer, size); 943 : } else { - 944 851 : memhash(state->hash, state->hashseed, hash, block_buffer, size); + 944 852 : memhash(state->hash, state->hashseed, hash, block_buffer, size); 945 : } 946 : 947 : /* if the hash doesn't match */ - 948 851 : if (memcmp(hash, failed[j].block->hash, HASH_SIZE) != 0) { + 948 852 : if (memcmp(hash, failed[j].block->hash, HASH_SIZE) != 0) { 949 : /* we have not recovered */ 950 0 : break; 951 : } 952 : 953 : /* pad with 0 if needed */ - 954 851 : if (size < state->block_size) - 955 325 : memset(block_buffer + size, 0, state->block_size - size); + 954 852 : if (size < state->block_size) + 955 345 : memset(block_buffer + size, 0, state->block_size - size); 956 : } else { 957 : /* otherwise restore the content */ 958 : /* because we are not interested in the old state */ 959 : /* that it's recovered for CHG, REP and DELETED blocks */ - 960 851 : memcpy(block_buffer, block_copy, state->block_size); + 960 852 : memcpy(block_buffer, block_copy, state->block_size); 961 : } 962 : } 963 : 964 : /* if all is processed, we have fixed it */ - 965 851 : if (j == failed_count) - 966 851 : fixed_error_on_this_block = 1; + 965 852 : if (j == failed_count) + 966 852 : fixed_error_on_this_block = 1; 967 : } 968 : } 969 : } 970 : 971 : /* if we have read all the data required and it's correct, proceed with the parity */ - 972 91157 : if (!error_on_this_block && !io_error_on_this_block - 973 91138 : && (!silent_error_on_this_block || fixed_error_on_this_block) + 972 91243 : if (!error_on_this_block && !io_error_on_this_block + 973 91224 : && (!silent_error_on_this_block || fixed_error_on_this_block) 974 : ) { 975 : /* update the parity only if really needed */ - 976 91138 : if (parity_needs_to_be_updated) { + 976 91224 : if (parity_needs_to_be_updated) { 977 : /* compute the parity */ - 978 88856 : raid_gen(diskmax, state->level, state->block_size, buffer); + 978 88964 : raid_gen(diskmax, state->level, state->block_size, buffer); 979 : 980 : /* until now is CPU */ - 981 88856 : state_usage_cpu(state); + 981 88964 : state_usage_cpu(state); 982 : 983 : /* write the parity */ - 984 585697 : for (l = 0; l < state->level; ++l) { - 985 496841 : ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size); - 986 496841 : if (ret == -1) { + 984 586383 : for (l = 0; l < state->level; ++l) { + 985 497419 : ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size); + 986 497419 : if (ret == -1) { 987 : /* LCOV_EXCL_START */ 988 : if (errno == EIO) { 989 : log_tag("parity_error:%u:%s: Write EIO error. %s\n", i, lev_config_name(l), strerror(errno)); @@ -1073,35 +1073,35 @@ 1011 : } 1012 : 1013 : /* until now is parity */ - 1014 496841 : state_usage_parity(state, l); + 1014 497419 : state_usage_parity(state, l); 1015 : } 1016 : } 1017 : 1018 : /* if no error in parity write */ - 1019 91138 : if (!io_error_on_this_block) { + 1019 91224 : if (!io_error_on_this_block) { 1020 : /* for each disk, mark the blocks as processed */ - 1021 637966 : for (j = 0; j < diskmax; ++j) { + 1021 638568 : for (j = 0; j < diskmax; ++j) { 1022 : struct snapraid_block* block; 1023 : - 1024 546828 : if (!handle[j].disk) + 1024 547344 : if (!handle[j].disk) 1025 0 : continue; 1026 : - 1027 546828 : block = fs_par2block_get(handle[j].disk, i); + 1027 547344 : block = fs_par2block_get(handle[j].disk, i); 1028 : - 1029 546828 : if (block == BLOCK_EMPTY) { + 1029 547344 : if (block == BLOCK_EMPTY) { 1030 : /* nothing to do */ - 1031 79287 : continue; + 1031 79734 : continue; 1032 : } 1033 : 1034 : /* if it's a deleted block */ - 1035 467541 : if (block_state_get(block) == BLOCK_STATE_DELETED) { + 1035 467610 : if (block_state_get(block) == BLOCK_STATE_DELETED) { 1036 : /* the parity is now updated without this block, so it's now empty */ - 1037 10929 : fs_deallocate(handle[j].disk, i); - 1038 10929 : continue; + 1037 10953 : fs_deallocate(handle[j].disk, i); + 1038 10953 : continue; 1039 : } 1040 : 1041 : /* now all the blocks have the hash and the parity computed */ - 1042 456612 : block_state_set(block, BLOCK_STATE_BLK); + 1042 456657 : block_state_set(block, BLOCK_STATE_BLK); 1043 : } 1044 : } 1045 : @@ -1110,52 +1110,52 @@ 1048 : /* wrote the parity at this time */ 1049 : /* we also update the info block only if no silent error was found */ 1050 : /* because has no sense to refresh the time for data that we know bad */ - 1051 91138 : if (parity_needs_to_be_updated - 1052 88856 : && !silent_error_on_this_block - 1053 88511 : && !io_error_on_this_block + 1051 91224 : if (parity_needs_to_be_updated + 1052 88964 : && !silent_error_on_this_block + 1053 88625 : && !io_error_on_this_block 1054 : ) { 1055 : /* if rehash is neeed */ - 1056 88511 : if (rehash) { + 1056 88625 : if (rehash) { 1057 : /* store all the new hash already computed */ - 1058 32221 : for (j = 0; j < diskmax; ++j) { - 1059 27618 : if (rehandle[j].block) - 1060 27231 : memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE); + 1058 32249 : for (j = 0; j < diskmax; ++j) { + 1059 27642 : if (rehandle[j].block) + 1060 27243 : memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE); 1061 : } 1062 : } 1063 : 1064 : /* update the time info of the block */ 1065 : /* we are also clearing any previous bad and rehash flag */ - 1066 88511 : info_set(&state->infoarr, i, info_make(now, 0, 0, 1)); + 1066 88625 : info_set(&state->infoarr, i, info_make(now, 0, 0, 1)); 1067 : } 1068 : } 1069 : 1070 : /* if a silent (even if corrected) or input/output error was found */ 1071 : /* mark the block as bad to have check/fix to handle it */ 1072 : /* because our correction is in memory only and not yet written */ - 1073 91157 : if (silent_error_on_this_block || io_error_on_this_block) { + 1073 91243 : if (silent_error_on_this_block || io_error_on_this_block) { 1074 : /* set the error status keeping the other info */ - 1075 851 : info_set(&state->infoarr, i, info_set_bad(info)); + 1075 852 : info_set(&state->infoarr, i, info_set_bad(info)); 1076 : } 1077 : 1078 : /* mark the state as needing write */ - 1079 91157 : state->need_write = 1; + 1079 91243 : state->need_write = 1; 1080 : 1081 : /* count the number of processed block */ - 1082 91157 : ++countpos; + 1082 91243 : ++countpos; 1083 : 1084 : /* progress */ - 1085 91157 : if (state_progress(state, i, countpos, countmax, countsize)) { + 1085 91243 : if (state_progress(state, i, countpos, countmax, countsize)) { 1086 : /* LCOV_EXCL_START */ 1087 : break; 1088 : /* LCOV_EXCL_STOP */ 1089 : } 1090 : 1091 : /* autosave */ - 1092 91157 : if ((state->autosave != 0 - 1093 7259 : && autosavedone >= autosavelimit /* if we have reached the limit */ + 1092 91243 : if ((state->autosave != 0 + 1093 7273 : && autosavedone >= autosavelimit /* if we have reached the limit */ 1094 0 : && autosavemissing >= autosavelimit) /* if we have at least a full step to do */ 1095 : /* or if we have a forced autosave at the specified block */ - 1096 91157 : || (state->opt.force_autosave_at != 0 && state->opt.force_autosave_at == i) + 1096 91243 : || (state->opt.force_autosave_at != 0 && state->opt.force_autosave_at == i) 1097 : ) { 1098 1 : autosavedone = 0; /* restart the counter */ 1099 : @@ -1193,15 +1193,15 @@ 1131 : } 1132 : 1133 : end: - 1134 76 : state_progress_end(state, countpos, countmax, countsize); + 1134 78 : state_progress_end(state, countpos, countmax, countsize); 1135 : - 1136 76 : state_usage_print(state); + 1136 78 : state_usage_print(state); 1137 : 1138 : /* before returning we ensure that */ 1139 : /* the parity is really written flushing the disk cache */ - 1140 517 : for (l = 0; l < state->level; ++l) { - 1141 441 : ret = parity_sync(parity[l]); - 1142 441 : if (ret == -1) { + 1140 531 : for (l = 0; l < state->level; ++l) { + 1141 453 : ret = parity_sync(parity[l]); + 1142 453 : if (ret == -1) { 1143 : /* LCOV_EXCL_START */ 1144 : log_tag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l)); 1145 : log_fatal("DANGER! Unexpected sync error in %s disk.\n", lev_name(l)); @@ -1213,43 +1213,43 @@ 1151 : } 1152 : } 1153 : - 1154 76 : if (error || silent_error || io_error) { + 1154 78 : if (error || silent_error || io_error) { 1155 12 : msg_status("\n"); 1156 12 : msg_status("%8u file errors\n", error); 1157 12 : msg_status("%8u io errors\n", io_error); 1158 12 : msg_status("%8u data errors\n", silent_error); 1159 : } else { 1160 : /* print the result only if processed something */ - 1161 64 : if (countpos != 0) - 1162 47 : msg_status("Everything OK\n"); + 1161 66 : if (countpos != 0) + 1162 48 : msg_status("Everything OK\n"); 1163 : } 1164 : - 1165 76 : if (error) + 1165 78 : if (error) 1166 11 : log_fatal("WARNING! Unexpected file errors!\n"); - 1167 76 : if (io_error) + 1167 78 : if (io_error) 1168 0 : log_fatal("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n"); - 1169 76 : if (silent_error) + 1169 78 : if (silent_error) 1170 1 : log_fatal("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n"); - 1171 76 : if (io_error || silent_error) { + 1171 78 : if (io_error || silent_error) { 1172 1 : log_fatal("Use 'snapraid status' to list the bad blocks.\n"); 1173 1 : log_fatal("Use 'snapraid -e fix' to recover.\n"); 1174 : } 1175 : - 1176 76 : log_tag("summary:error_file:%u\n", error); - 1177 76 : log_tag("summary:error_io:%u\n", io_error); - 1178 76 : log_tag("summary:error_data:%u\n", silent_error); - 1179 76 : if (error + silent_error + io_error == 0) - 1180 64 : log_tag("summary:exit:ok\n"); + 1176 78 : log_tag("summary:error_file:%u\n", error); + 1177 78 : log_tag("summary:error_io:%u\n", io_error); + 1178 78 : log_tag("summary:error_data:%u\n", silent_error); + 1179 78 : if (error + silent_error + io_error == 0) + 1180 66 : log_tag("summary:exit:ok\n"); 1181 : else 1182 12 : log_tag("summary:exit:error\n"); - 1183 76 : log_flush(); + 1183 78 : log_flush(); 1184 : 1185 : bail: - 1186 532 : for (j = 0; j < diskmax; ++j) { - 1187 456 : struct snapraid_file* file = handle[j].file; - 1188 456 : struct snapraid_disk* disk = handle[j].disk; - 1189 456 : ret = handle_close(&handle[j]); - 1190 456 : if (ret == -1) { + 1186 546 : for (j = 0; j < diskmax; ++j) { + 1187 468 : struct snapraid_file* file = handle[j].file; + 1188 468 : struct snapraid_disk* disk = handle[j].disk; + 1189 468 : ret = handle_close(&handle[j]); + 1190 468 : if (ret == -1) { 1191 : /* LCOV_EXCL_START */ 1192 : log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno)); 1193 : log_fatal("DANGER! Unexpected close error in a data disk.\n"); @@ -1259,24 +1259,24 @@ 1197 : } 1198 : } 1199 : - 1200 76 : free(handle); - 1201 76 : free(buffer_alloc); - 1202 76 : free(buffer); - 1203 76 : free(rehandle_alloc); - 1204 76 : free(failed); - 1205 76 : free(failed_map); + 1200 78 : free(handle); + 1201 78 : free(buffer_alloc); + 1202 78 : free(buffer); + 1203 78 : free(rehandle_alloc); + 1204 78 : free(failed); + 1205 78 : free(failed_map); 1206 : - 1207 76 : if (state->opt.expect_recoverable) { + 1207 78 : if (state->opt.expect_recoverable) { 1208 1 : if (error + silent_error + io_error == 0) 1209 0 : return -1; 1210 : } else { - 1211 75 : if (error + silent_error + io_error != 0) + 1211 77 : if (error + silent_error + io_error != 0) 1212 11 : return -1; 1213 : } - 1214 65 : return 0; + 1214 67 : return 0; 1215 : } 1216 : - 1217 80 : int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t blockcount) + 1217 82 : int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t blockcount) 1218 : { 1219 : block_off_t blockmax; 1220 : block_off_t used_paritymax; @@ -1287,23 +1287,23 @@ 1225 : struct snapraid_parity_handle parity[LEV_MAX]; 1226 : /* the following initialization is to avoid clang warnings about */ 1227 : /* potential state->level change, that never happens */ - 1228 80 : struct snapraid_parity_handle* parity_ptr[LEV_MAX] = { 0 }; + 1228 82 : struct snapraid_parity_handle* parity_ptr[LEV_MAX] = { 0 }; 1229 : unsigned unrecoverable_error; 1230 : unsigned l; - 1231 80 : int skip_sync = 0; + 1231 82 : int skip_sync = 0; 1232 : - 1233 80 : msg_progress("Initializing...\n"); + 1233 82 : msg_progress("Initializing...\n"); 1234 : - 1235 80 : blockmax = parity_allocated_size(state); - 1236 80 : size = blockmax * (data_off_t)state->block_size; + 1235 82 : blockmax = parity_allocated_size(state); + 1236 82 : size = blockmax * (data_off_t)state->block_size; 1237 : 1238 : /* minum size of the parity files we expect */ - 1239 80 : used_paritymax = parity_used_size(state); + 1239 82 : used_paritymax = parity_used_size(state); 1240 : 1241 : /* effective size of the parity files */ - 1242 80 : file_paritymax = 0; + 1242 82 : file_paritymax = 0; 1243 : - 1244 80 : if (blockstart > blockmax) { + 1244 82 : if (blockstart > blockmax) { 1245 : /* LCOV_EXCL_START */ 1246 : log_fatal("Error in the starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax); 1247 : exit(EXIT_FAILURE); @@ -1311,17 +1311,17 @@ 1249 : } 1250 : 1251 : /* adjust the number of block to process */ - 1252 80 : if (blockcount != 0 && blockstart + blockcount < blockmax) { + 1252 82 : if (blockcount != 0 && blockstart + blockcount < blockmax) { 1253 6 : blockmax = blockstart + blockcount; 1254 : } 1255 : - 1256 545 : for (l = 0; l < state->level; ++l) { + 1256 559 : for (l = 0; l < state->level; ++l) { 1257 : block_off_t parityblocks; 1258 : 1259 : /* create the file and open for writing */ - 1260 465 : parity_ptr[l] = &parity[l]; - 1261 465 : ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode); - 1262 465 : if (ret == -1) { + 1260 477 : parity_ptr[l] = &parity[l]; + 1261 477 : ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode); + 1262 477 : if (ret == -1) { 1263 : /* LCOV_EXCL_START */ 1264 : log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l)); 1265 : exit(EXIT_FAILURE); @@ -1329,22 +1329,22 @@ 1267 : } 1268 : 1269 : /* number of block in the parity file */ - 1270 465 : parityblocks = out_size / state->block_size; + 1270 477 : parityblocks = out_size / state->block_size; 1271 : 1272 : /* if the file is too small */ - 1273 465 : if (parityblocks < used_paritymax) { + 1273 477 : if (parityblocks < used_paritymax) { 1274 0 : log_fatal("WARNING! The %s file %s has data only %u blocks instead of %u.\n", lev_name(l), state->parity[l].path, parityblocks, used_paritymax); 1275 : } 1276 : 1277 : /* keep the smallest parity number of blocks */ - 1278 465 : if (l == 0 || file_paritymax > parityblocks) - 1279 80 : file_paritymax = parityblocks; + 1278 477 : if (l == 0 || file_paritymax > parityblocks) + 1279 82 : file_paritymax = parityblocks; 1280 : } 1281 : 1282 : /* if we do a full sync, having a wrong parity size is expected */ - 1283 80 : if (!state->opt.force_full) { + 1283 82 : if (!state->opt.force_full) { 1284 : /* if the parities are too small */ - 1285 78 : if (file_paritymax < used_paritymax) { + 1285 80 : if (file_paritymax < used_paritymax) { 1286 : /* LCOV_EXCL_START */ 1287 : log_fatal("DANGER! One or more the parity files are smaller than expected!\n"); 1288 : if (file_paritymax != 0) { @@ -1362,12 +1362,12 @@ 1300 : } 1301 : 1302 : /* now change the size of all parities */ - 1303 545 : for (l = 0; l < state->level; ++l) { + 1303 559 : for (l = 0; l < state->level; ++l) { 1304 : /* change the size of the parity file, truncating or extending it */ 1305 : /* from this point all the DELETED blocks after the end of the parity are invalid */ 1306 : /* and they are automatically removed when we save the new content file */ - 1307 465 : ret = parity_chsize(parity_ptr[l], size, &out_size, state->opt.skip_fallocate); - 1308 465 : if (ret == -1) { + 1307 477 : ret = parity_chsize(parity_ptr[l], size, &out_size, state->opt.skip_fallocate); + 1308 477 : if (ret == -1) { 1309 : /* LCOV_EXCL_START */ 1310 : parity_overflow(state, out_size); 1311 : log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l)); @@ -1377,11 +1377,11 @@ 1315 : } 1316 : 1317 : /* after resizing parity files, refresh again the free info */ - 1318 80 : state_refresh(state); + 1318 82 : state_refresh(state); 1319 : - 1320 80 : unrecoverable_error = 0; + 1320 82 : unrecoverable_error = 0; 1321 : - 1322 80 : if (state->opt.prehash) { + 1322 82 : if (state->opt.prehash) { 1323 7 : msg_progress("Hashing...\n"); 1324 : 1325 7 : ret = state_hash_process(state, blockstart, blockmax, &skip_sync); @@ -1397,13 +1397,13 @@ 1335 2 : state_write(state); 1336 : } 1337 : - 1338 80 : if (!skip_sync) { - 1339 79 : msg_progress("Syncing...\n"); + 1338 82 : if (!skip_sync) { + 1339 81 : msg_progress("Syncing...\n"); 1340 : 1341 : /* skip degenerated cases of empty parity, or skipping all */ - 1342 79 : if (blockstart < blockmax) { - 1343 76 : ret = state_sync_process(state, parity_ptr, blockstart, blockmax); - 1344 76 : if (ret == -1) { + 1342 81 : if (blockstart < blockmax) { + 1343 78 : ret = state_sync_process(state, parity_ptr, blockstart, blockmax); + 1344 78 : if (ret == -1) { 1345 : /* LCOV_EXCL_START */ 1346 : ++unrecoverable_error; 1347 : /* continue, as we are already exiting */ @@ -1414,9 +1414,9 @@ 1352 : } 1353 : } 1354 : - 1355 545 : for (l = 0; l < state->level; ++l) { - 1356 465 : ret = parity_close(parity_ptr[l]); - 1357 465 : if (ret == -1) { + 1355 559 : for (l = 0; l < state->level; ++l) { + 1356 477 : ret = parity_close(parity_ptr[l]); + 1357 477 : if (ret == -1) { 1358 : /* LCOV_EXCL_START */ 1359 : log_fatal("DANGER! Unexpected close error in %s disk.\n", lev_name(l)); 1360 : ++unrecoverable_error; @@ -1426,9 +1426,9 @@ 1364 : } 1365 : 1366 : /* abort if required */ - 1367 80 : if (unrecoverable_error != 0) + 1367 82 : if (unrecoverable_error != 0) 1368 12 : return -1; - 1369 68 : return 0; + 1369 70 : return 0; 1370 : } 1371 : diff --git a/cov/cmdline/unix.c.func-sort-c.html b/cov/cmdline/unix.c.func-sort-c.html index c194779e..c7ac4ed3 100644 --- a/cov/cmdline/unix.c.func-sort-c.html +++ b/cov/cmdline/unix.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -61,11 +61,11 @@ tick - 2214352 + 2215898 open_noatime - 1661733 + 1661805 filephy @@ -73,27 +73,27 @@ fsinfo - 2415 + 2475 devuuid - 2404 + 2428 devuuid_dev - 2404 + 2428 randomize - 271 + 273 os_init - 260 + 262 os_done - 238 + 240 devresolve @@ -112,12 +112,12 @@ 36 - devsmart + thread_smart 25 - thread_smart - 22 + devsmart + 25 thread_spindown diff --git a/cov/cmdline/unix.c.func.html b/cov/cmdline/unix.c.func.html index c3a13d67..bd5a15d0 100644 --- a/cov/cmdline/unix.c.func.html +++ b/cov/cmdline/unix.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -97,7 +97,7 @@ devuuid - 2404 + 2428 devuuid_blkid @@ -105,7 +105,7 @@ devuuid_dev - 2404 + 2428 dirent_hidden @@ -117,23 +117,23 @@ fsinfo - 2415 + 2475 open_noatime - 1661733 + 1661805 os_done - 238 + 240 os_init - 260 + 262 randomize - 271 + 273 stat_desc @@ -141,7 +141,7 @@ thread_smart - 22 + 25 thread_spindown @@ -153,7 +153,7 @@ tick - 2214352 + 2215898 tick_ms diff --git a/cov/cmdline/unix.c.gcov.html b/cov/cmdline/unix.c.gcov.html index 59fb3346..f2ea70e8 100644 --- a/cov/cmdline/unix.c.gcov.html +++ b/cov/cmdline/unix.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 23 @@ -90,15 +90,15 @@ 28 : int exit_failure = 1; 29 : int exit_sync_needed = 2; 30 : - 31 1661733 : int open_noatime(const char* file, int flags) + 31 1661805 : int open_noatime(const char* file, int flags) 32 : { 33 : #ifdef O_NOATIME - 34 1661733 : int f = open(file, flags | O_NOATIME); + 34 1661805 : int f = open(file, flags | O_NOATIME); 35 : 36 : /* only root is allowed to use O_NOATIME, in case retry without it */ - 37 1661733 : if (f == -1 && errno == EPERM) + 37 1661805 : if (f == -1 && errno == EPERM) 38 0 : f = open(file, flags); - 39 1661733 : return f; + 39 1661805 : return f; 40 : #else 41 : return open(file, flags); 42 : #endif @@ -144,7 +144,7 @@ 82 : * in /dev/disk/by-uuid/. 83 : */ 84 : #if HAVE_FSTATAT - 85 2404 : static int devuuid_dev(uint64_t device, char* uuid, size_t uuid_size) + 85 2428 : static int devuuid_dev(uint64_t device, char* uuid, size_t uuid_size) 86 : { 87 : int ret; 88 : DIR* d; @@ -152,47 +152,47 @@ 90 : struct stat st; 91 : 92 : /* scan the UUID directory searching for the device */ - 93 2404 : d = opendir("/dev/disk/by-uuid"); - 94 2404 : if (!d) { + 93 2428 : d = opendir("/dev/disk/by-uuid"); + 94 2428 : if (!d) { 95 0 : log_tag("uuid:by-uuidd:%u:%u: opendir(/dev/disk/by-uuid) failed\n", major(device), minor(device)); 96 : /* directory missing?, likely we are not in Linux */ 97 0 : return -1; 98 : } 99 : - 100 40887 : while ((dd = readdir(d)) != 0) { + 100 41295 : while ((dd = readdir(d)) != 0) { 101 : /* skip "." and ".." files, UUIDs never start with '.' */ - 102 38482 : if (dd->d_name[0] == '.') - 103 4808 : continue; + 102 38866 : if (dd->d_name[0] == '.') + 103 4856 : continue; 104 : - 105 33674 : ret = fstatat(dirfd(d), dd->d_name, &st, 0); - 106 33674 : if (ret != 0) { + 105 34010 : ret = fstatat(dirfd(d), dd->d_name, &st, 0); + 106 34010 : if (ret != 0) { 107 0 : log_tag("uuid:by-uuidd:%u:%u: fstatat(%s) failed\n", major(device), minor(device), dd->d_name); 108 : /* generic error, ignore and continue the search */ 109 0 : continue; 110 : } 111 : 112 : /* if it matches, we have the uuid */ - 113 33674 : if (S_ISBLK(st.st_mode) && st.st_rdev == (dev_t)device) { + 113 34010 : if (S_ISBLK(st.st_mode) && st.st_rdev == (dev_t)device) { 114 : char buf[PATH_MAX]; 115 : char path[PATH_MAX]; 116 : 117 : /* resolve the link */ - 118 2403 : pathprint(path, sizeof(path), "/dev/disk/by-uuid/%s", dd->d_name); - 119 2403 : ret = readlink(path, buf, sizeof(buf)); - 120 2403 : if (ret < 0 || ret == sizeof(buf)) { + 118 2427 : pathprint(path, sizeof(path), "/dev/disk/by-uuid/%s", dd->d_name); + 119 2427 : ret = readlink(path, buf, sizeof(buf)); + 120 2427 : if (ret < 0 || ret == sizeof(buf)) { 121 0 : log_tag("uuid:by-uuidd:%u:%u: readlink(/dev/disk/by-uuid/%s) failed\n", major(device), minor(device), dd->d_name); 122 : /* generic error, ignore and continue the search */ 123 0 : continue; 124 : } - 125 2403 : buf[ret] = 0; + 125 2427 : buf[ret] = 0; 126 : 127 : /* found */ - 128 2403 : pathcpy(uuid, uuid_size, dd->d_name); + 128 2427 : pathcpy(uuid, uuid_size, dd->d_name); 129 : - 130 2403 : log_tag("uuid:by-uuid:%u:%u:%s: found %s\n", major(device), minor(device), uuid, buf); + 130 2427 : log_tag("uuid:by-uuid:%u:%u:%s: found %s\n", major(device), minor(device), uuid, buf); 131 : - 132 2403 : closedir(d); - 133 2403 : return 0; + 132 2427 : closedir(d); + 133 2427 : return 0; 134 : } 135 : } 136 : @@ -241,12 +241,12 @@ 179 : } 180 : #endif 181 : - 182 2404 : int devuuid(uint64_t device, char* uuid, size_t uuid_size) + 182 2428 : int devuuid(uint64_t device, char* uuid, size_t uuid_size) 183 : { 184 : /* first try with the /dev/disk/by-uuid version */ 185 : #if HAVE_FSTATAT - 186 2404 : if (devuuid_dev(device, uuid, uuid_size) == 0) - 187 2403 : return 0; + 186 2428 : if (devuuid_dev(device, uuid, uuid_size) == 0) + 187 2427 : return 0; 188 : #endif 189 : 190 : /* fall back to blkid for other cases */ @@ -357,12 +357,12 @@ 295 0 : return 0; 296 : } 297 : - 298 2415 : int fsinfo(const char* path, int* has_persistent_inode, uint64_t* total_space, uint64_t* free_space) + 298 2475 : int fsinfo(const char* path, int* has_persistent_inode, uint64_t* total_space, uint64_t* free_space) 299 : { 300 : #if HAVE_STATFS && HAVE_STRUCT_STATFS_F_TYPE 301 : struct statfs st; 302 : - 303 2415 : if (statfs(path, &st) != 0) { + 303 2475 : if (statfs(path, &st) != 0) { 304 : char dir[PATH_MAX]; 305 : char* slash; 306 : @@ -389,22 +389,22 @@ 327 : } 328 : 329 : /* to get the fs type check "man stat" or "stat -f -t FILE" */ - 330 2415 : if (has_persistent_inode) - 331 527 : switch (st.f_type) { + 330 2475 : if (has_persistent_inode) + 331 539 : switch (st.f_type) { 332 : case 0x65735546 : /* FUSE, "fuseblk" in the stat command */ 333 : case 0x4d44 : /* VFAT, "msdos" in the stat command */ 334 0 : *has_persistent_inode = 0; 335 0 : break; 336 : default : 337 : /* by default assume yes */ - 338 527 : *has_persistent_inode = 1; - 339 527 : break; + 338 539 : *has_persistent_inode = 1; + 339 539 : break; 340 : } 341 : - 342 2415 : if (total_space) - 343 1888 : *total_space = st.f_bsize * (uint64_t)st.f_blocks; - 344 2415 : if (free_space) - 345 1888 : *free_space = st.f_bsize * (uint64_t)st.f_bfree; + 342 2475 : if (total_space) + 343 1936 : *total_space = st.f_bsize * (uint64_t)st.f_blocks; + 344 2475 : if (free_space) + 345 1936 : *free_space = st.f_bsize * (uint64_t)st.f_bfree; 346 : #else 347 : (void)path; 348 : @@ -417,10 +417,10 @@ 355 : *free_space = 0; 356 : #endif 357 : - 358 2415 : return 0; + 358 2475 : return 0; 359 : } 360 : - 361 2214352 : uint64_t tick(void) + 361 2215898 : uint64_t tick(void) 362 : { 363 : #if HAVE_MACH_ABSOLUTE_TIME 364 : /* for Mac OS X */ @@ -431,14 +431,14 @@ 369 : 370 : /* nanosecond precision with clock_gettime() */ 371 : #if defined(CLOCK_MONOTONIC_RAW) - 372 2214352 : if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) != 0) { + 372 2215898 : if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) != 0) { 373 : #else 374 : if (clock_gettime(CLOCK_MONOTONIC, &tv) != 0) { 375 : #endif 376 0 : return 0; 377 : } 378 : - 379 2214352 : return tv.tv_sec * 1000000000ULL + tv.tv_nsec; + 379 2215898 : return tv.tv_sec * 1000000000ULL + tv.tv_nsec; 380 : #else 381 : /* other platforms */ 382 : struct timeval tv; @@ -462,25 +462,25 @@ 400 36 : return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; 401 : } 402 : - 403 271 : int randomize(void* ptr, size_t size) + 403 273 : int randomize(void* ptr, size_t size) 404 : { 405 : int f; 406 : ssize_t ret; 407 : - 408 271 : f = open("/dev/urandom", O_RDONLY); - 409 271 : if (f == -1) + 408 273 : f = open("/dev/urandom", O_RDONLY); + 409 273 : if (f == -1) 410 0 : return -1; 411 : - 412 271 : ret = read(f, ptr, size); - 413 271 : if (ret < 0 || (size_t)ret != size) { + 412 273 : ret = read(f, ptr, size); + 413 273 : if (ret < 0 || (size_t)ret != size) { 414 0 : close(f); 415 0 : return -1; 416 : } 417 : - 418 271 : if (close(f) != 0) + 418 273 : if (close(f) != 0) 419 0 : return -1; 420 : - 421 271 : return 0; + 421 273 : return 0; 422 : } 423 : 424 : /** @@ -815,7 +815,7 @@ 753 : /* LCOV_EXCL_STOP */ 754 : } 755 : - 756 24 : ret = pclose(f); + 756 25 : ret = pclose(f); 757 : 758 25 : log_tag("smartctl:%s:%s:ret: %x\n", file, name, ret); 759 : @@ -1012,11 +1012,11 @@ 950 : /** 951 : * Thread for getting smart info. 952 : */ - 953 22 : static void* thread_smart(void* arg) + 953 25 : static void* thread_smart(void* arg) 954 : { - 955 22 : devinfo_t* devinfo = arg; + 955 25 : devinfo_t* devinfo = arg; 956 : - 957 22 : if (devsmart(devinfo->device, devinfo->name, devinfo->smartctl, devinfo->smart, devinfo->smart_serial) != 0) { + 957 25 : if (devsmart(devinfo->device, devinfo->name, devinfo->smartctl, devinfo->smart, devinfo->smart_serial) != 0) { 958 : /* LCOV_EXCL_START */ 959 : return (void*)-1; 960 : /* LCOV_EXCL_STOP */ @@ -1161,12 +1161,12 @@ 1099 3 : return device_thread(low, func); 1100 : } 1101 : - 1102 260 : void os_init(int opt) + 1102 262 : void os_init(int opt) 1103 : { 1104 : #if HAVE_BLKID 1105 : int ret; - 1106 260 : ret = blkid_get_cache(&cache, NULL); - 1107 260 : if (ret != 0) { + 1106 262 : ret = blkid_get_cache(&cache, NULL); + 1107 262 : if (ret != 0) { 1108 : /* LCOV_EXCL_START */ 1109 : log_fatal("WARNING Failed to get blkid cache\n"); 1110 : /* LCOV_EXCL_STOP */ @@ -1174,15 +1174,15 @@ 1112 : #endif 1113 : 1114 : (void)opt; - 1115 260 : } + 1115 262 : } 1116 : - 1117 238 : void os_done(void) + 1117 240 : void os_done(void) 1118 : { 1119 : #if HAVE_BLKID - 1120 238 : if (cache != 0) - 1121 238 : blkid_put_cache(cache); + 1120 240 : if (cache != 0) + 1121 240 : blkid_put_cache(cache); 1122 : #endif - 1123 238 : } + 1123 240 : } 1124 : 1125 : /* LCOV_EXCL_START */ 1126 : void os_abort(void) diff --git a/cov/cmdline/util.c.func-sort-c.html b/cov/cmdline/util.c.func-sort-c.html index 83cf470e..812d0a04 100644 --- a/cov/cmdline/util.c.func-sort-c.html +++ b/cov/cmdline/util.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 14 @@ -61,31 +61,31 @@ util_rotl32 - 796761149 + 797483744 util_rotl64 - 511410252 + 511692084 memhash - 5791413 + 5794694 crc32c_x86 - 646616 + 646542 memdiff - 25329 + 25606 malloc_nofail_test - 1905 + 1933 mtest_vector - 1905 + 1933 crc32c_gen @@ -93,23 +93,23 @@ crc32c_init - 276 + 278 lock_lock - 251 + 253 lock_unlock - 231 + 233 malloc_nofail_vector_align - 209 + 211 malloc_nofail_align - 91 + 93 hash_config_name diff --git a/cov/cmdline/util.c.func.html b/cov/cmdline/util.c.func.html index 24210007..9a857309 100644 --- a/cov/cmdline/util.c.func.html +++ b/cov/cmdline/util.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 14 @@ -65,11 +65,11 @@ crc32c_init - 276 + 278 crc32c_x86 - 646616 + 646542 hash_config_name @@ -77,43 +77,43 @@ lock_lock - 251 + 253 lock_unlock - 231 + 233 malloc_nofail_align - 91 + 93 malloc_nofail_test - 1905 + 1933 malloc_nofail_vector_align - 209 + 211 memdiff - 25329 + 25606 memhash - 5791413 + 5794694 mtest_vector - 1905 + 1933 util_rotl32 - 796761149 + 797483744 util_rotl64 - 511410252 + 511692084
diff --git a/cov/cmdline/util.c.gcov.html b/cov/cmdline/util.c.gcov.html index f023adf7..7d3bb213 100644 --- a/cov/cmdline/util.c.gcov.html +++ b/cov/cmdline/util.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 14 @@ -87,59 +87,59 @@ 25 : /****************************************************************************/ 26 : /* memory */ 27 : - 28 91 : void* malloc_nofail_align(size_t size, void** freeptr) + 28 93 : void* malloc_nofail_align(size_t size, void** freeptr) 29 : { 30 : void* ptr; 31 : - 32 91 : ptr = raid_malloc_align(size, freeptr); + 32 93 : ptr = raid_malloc_align(size, freeptr); 33 : - 34 91 : if (!ptr) { + 34 93 : if (!ptr) { 35 : /* LCOV_EXCL_START */ 36 : malloc_fail(size); 37 : exit(EXIT_FAILURE); 38 : /* LCOV_EXCL_STOP */ 39 : } 40 : - 41 91 : return ptr; + 41 93 : return ptr; 42 : } 43 : - 44 209 : void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr) + 44 211 : void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr) 45 : { 46 : void* ptr; 47 : - 48 209 : ptr = raid_malloc_vector(nd, n, size, freeptr); + 48 211 : ptr = raid_malloc_vector(nd, n, size, freeptr); 49 : - 50 209 : if (!ptr) { + 50 211 : if (!ptr) { 51 : /* LCOV_EXCL_START */ 52 : malloc_fail(n * size); 53 : exit(EXIT_FAILURE); 54 : /* LCOV_EXCL_STOP */ 55 : } 56 : - 57 209 : return ptr; + 57 211 : return ptr; 58 : } 59 : - 60 1905 : void* malloc_nofail_test(size_t size) + 60 1933 : void* malloc_nofail_test(size_t size) 61 : { 62 : void* ptr; 63 : - 64 1905 : ptr = malloc_nofail(size); + 64 1933 : ptr = malloc_nofail(size); 65 : - 66 1905 : mtest_vector(1, size, &ptr); + 66 1933 : mtest_vector(1, size, &ptr); 67 : - 68 1905 : return ptr; + 68 1933 : return ptr; 69 : } 70 : - 71 1905 : void mtest_vector(int n, size_t size, void** vv) + 71 1933 : void mtest_vector(int n, size_t size, void** vv) 72 : { - 73 1905 : if (raid_mtest_vector(n, size, vv) != 0) { + 73 1933 : if (raid_mtest_vector(n, size, vv) != 0) { 74 : /* LCOV_EXCL_START */ 75 : log_fatal("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); 76 : log_fatal("Try running a memory test like http://www.memtest86.com/\n"); 77 : exit(EXIT_FAILURE); 78 : /* LCOV_EXCL_STOP */ 79 : } - 80 1905 : } + 80 1933 : } 81 : 82 : /****************************************************************************/ 83 : /* crc */ @@ -428,30 +428,30 @@ 366 : } 367 : 368 : #if HAVE_SSE42 - 369 646616 : uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size) + 369 646542 : uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size) 370 : { - 371 646616 : crc ^= CRC_IV; + 371 646542 : crc ^= CRC_IV; 372 : - 373 646616 : crc = crc32c_x86_plain(crc, ptr, size); + 373 646542 : crc = crc32c_x86_plain(crc, ptr, size); 374 : - 375 646616 : crc ^= CRC_IV; + 375 646542 : crc ^= CRC_IV; 376 : - 377 646616 : return crc; + 377 646542 : return crc; 378 : } 379 : #endif 380 : 381 : uint32_t (*crc32c)(uint32_t crc, const unsigned char* ptr, unsigned size); 382 : - 383 276 : void crc32c_init(void) + 383 278 : void crc32c_init(void) 384 : { - 385 276 : crc32c = crc32c_gen; + 385 278 : crc32c = crc32c_gen; 386 : #if HAVE_SSE42 - 387 276 : if (raid_cpu_has_crc32()) { - 388 274 : crc_x86 = 1; - 389 274 : crc32c = crc32c_x86; + 387 278 : if (raid_cpu_has_crc32()) { + 388 276 : crc_x86 = 1; + 389 276 : crc32c = crc32c_x86; 390 : } 391 : #endif - 392 276 : } + 392 278 : } 393 : 394 : /****************************************************************************/ 395 : /* byte operations */ @@ -460,14 +460,14 @@ 398 : * Rotate left. 399 : * In x86/x64 they are optimized with a single assembler instruction. 400 : */ - 401 796761149 : static inline uint32_t util_rotl32(uint32_t x, int8_t r) + 401 797483744 : static inline uint32_t util_rotl32(uint32_t x, int8_t r) 402 : { - 403 796761149 : return (x << r) | (x >> (32 - r)); + 403 797483744 : return (x << r) | (x >> (32 - r)); 404 : } 405 : - 406 511410252 : static inline uint64_t util_rotl64(uint64_t x, int8_t r) + 406 511692084 : static inline uint64_t util_rotl64(uint64_t x, int8_t r) 407 : { - 408 511410252 : return (x << r) | (x >> (64 - r)); + 408 511692084 : return (x << r) | (x >> (64 - r)); 409 : } 410 : 411 : /** @@ -508,15 +508,15 @@ 446 : #include "murmur3.c" 447 : #include "spooky2.c" 448 : - 449 5791413 : void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t size) + 449 5794694 : void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t size) 450 : { - 451 5791413 : switch (kind) { + 451 5794694 : switch (kind) { 452 : case HASH_MURMUR3 : - 453 1936261 : MurmurHash3_x86_128(src, size, seed, digest); - 454 1936261 : break; + 453 1937706 : MurmurHash3_x86_128(src, size, seed, digest); + 454 1937706 : break; 455 : case HASH_SPOOKY2 : - 456 3855152 : SpookyHash128(src, size, seed, digest); - 457 3855152 : break; + 456 3856988 : SpookyHash128(src, size, seed, digest); + 457 3856988 : break; 458 : default : 459 : /* LCOV_EXCL_START */ 460 : log_fatal("Internal inconsistency in hash function %u\n", kind); @@ -524,7 +524,7 @@ 462 : break; 463 : /* LCOV_EXCL_STOP */ 464 : } - 465 5791413 : } + 465 5794694 : } 466 : 467 42 : const char* hash_config_name(unsigned kind) 468 : { @@ -539,67 +539,67 @@ 477 : } 478 : } 479 : - 480 25329 : unsigned memdiff(const unsigned char* data1, const unsigned char* data2, size_t size) + 480 25606 : unsigned memdiff(const unsigned char* data1, const unsigned char* data2, size_t size) 481 : { 482 : size_t i; 483 : unsigned count; 484 : - 485 25329 : count = 0; - 486 11266593 : for (i = 0; i < size; ++i) { + 485 25606 : count = 0; + 486 11382182 : for (i = 0; i < size; ++i) { 487 : unsigned j; - 488 11241264 : unsigned char diff = data1[i] ^ data2[i]; - 489 101171376 : for (j = 0; j < 8; ++j) { - 490 89930112 : if ((diff & 1) != 0) - 491 39652202 : ++count; - 492 89930112 : diff >>= 1; + 488 11356576 : unsigned char diff = data1[i] ^ data2[i]; + 489 102209184 : for (j = 0; j < 8; ++j) { + 490 90852608 : if ((diff & 1) != 0) + 491 40175513 : ++count; + 492 90852608 : diff >>= 1; 493 : } 494 : } 495 : - 496 25329 : return count; + 496 25606 : return count; 497 : } 498 : 499 : /****************************************************************************/ 500 : /* lock */ 501 : 502 : #if HAVE_LOCKFILE - 503 251 : int lock_lock(const char* file) + 503 253 : int lock_lock(const char* file) 504 : { 505 : int f; 506 : - 507 251 : f = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600); - 508 251 : if (f == -1) { + 507 253 : f = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600); + 508 253 : if (f == -1) { 509 : /* LCOV_EXCL_START */ 510 : return -1; 511 : /* LCOV_EXCL_STOP */ 512 : } 513 : 514 : /* exclusive lock, not blocking */ - 515 251 : if (flock(f, LOCK_EX | LOCK_NB) == -1) { + 515 253 : if (flock(f, LOCK_EX | LOCK_NB) == -1) { 516 : /* LCOV_EXCL_START */ 517 : close(f); 518 : return -1; 519 : /* LCOV_EXCL_STOP */ 520 : } 521 : - 522 251 : return f; + 522 253 : return f; 523 : } 524 : #endif 525 : 526 : #if HAVE_LOCKFILE - 527 231 : int lock_unlock(int f) + 527 233 : int lock_unlock(int f) 528 : { 529 : /* 530 : * Intentionally don't remove the lock file. 531 : * Removing it just introduces race course with other process 532 : * that could have already opened it. 533 : */ - 534 231 : if (close(f) == -1) { + 534 233 : if (close(f) == -1) { 535 : /* LCOV_EXCL_START */ 536 : return -1; 537 : /* LCOV_EXCL_STOP */ 538 : } 539 : - 540 231 : return 0; + 540 233 : return 0; 541 : } 542 : #endif 543 : diff --git a/cov/cmdline/util.h.func-sort-c.html b/cov/cmdline/util.h.func-sort-c.html index d5e05907..dc1fd0f9 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-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ crc32c_x86_plain - 21302165 + 21113444 crc32c_plain - 20655549 + 20466902 crc32c_plain_char - 3794625 + 3760808 crc32c_gen_plain diff --git a/cov/cmdline/util.h.func.html b/cov/cmdline/util.h.func.html index de250087..9a7fb93f 100644 --- a/cov/cmdline/util.h.func.html +++ b/cov/cmdline/util.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -65,15 +65,15 @@ crc32c_plain - 20655549 + 20466902 crc32c_plain_char - 3794625 + 3760808 crc32c_x86_plain - 21302165 + 21113444
diff --git a/cov/cmdline/util.h.gcov.html b/cov/cmdline/util.h.gcov.html index 0023bf5a..589f7408 100644 --- a/cov/cmdline/util.h.gcov.html +++ b/cov/cmdline/util.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -133,12 +133,12 @@ 71 : /** 72 : * Compute CRC-32 (Castagnoli) for a single byte without the IV. 73 : */ - 74 3794625 : static inline uint32_t crc32c_plain_char(uint32_t crc, unsigned char c) + 74 3760808 : static inline uint32_t crc32c_plain_char(uint32_t crc, unsigned char c) 75 : { 76 : #if HAVE_SSE42 - 77 3794625 : if (tommy_likely(crc_x86)) { - 78 3794625 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); - 79 3794625 : return crc; + 77 3760808 : if (tommy_likely(crc_x86)) { + 78 3760808 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); + 79 3760808 : return crc; 80 : } 81 : #endif 82 0 : return CRC32C_0[(crc ^ c) & 0xff] ^ (crc >> 8); @@ -169,7 +169,7 @@ 107 : * Compute the CRC-32 (Castagnoli) without the IV. 108 : */ 109 : #if HAVE_SSE42 - 110 21302165 : static inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, unsigned size) + 110 21113444 : static inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, unsigned size) 111 : { 112 : #ifdef CONFIG_X86_64 113 : uint64_t crc64 = crc; @@ -180,30 +180,30 @@ 118 : } 119 : crc = crc64; 120 : #else - 121 437931649 : while (size >= 4) { - 122 395327319 : asm("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); - 123 395327319 : ptr += 4; - 124 395327319 : size -= 4; + 121 434026831 : while (size >= 4) { + 122 391799943 : asm("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); + 123 391799943 : ptr += 4; + 124 391799943 : size -= 4; 125 : } 126 : #endif - 127 62072231 : while (size) { - 128 19467901 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); - 129 19467901 : ++ptr; - 130 19467901 : --size; + 127 61293566 : while (size) { + 128 19066678 : asm("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); + 129 19066678 : ++ptr; + 130 19066678 : --size; 131 : } 132 : - 133 21302165 : return crc; + 133 21113444 : return crc; 134 : } 135 : #endif 136 : 137 : /** 138 : * Compute CRC-32 (Castagnoli) without the IV. 139 : */ - 140 20655549 : static inline uint32_t crc32c_plain(uint32_t crc, const unsigned char* ptr, unsigned size) + 140 20466902 : static inline uint32_t crc32c_plain(uint32_t crc, const unsigned char* ptr, unsigned size) 141 : { 142 : #if HAVE_SSE42 - 143 20655549 : if (tommy_likely(crc_x86)) { - 144 20655549 : return crc32c_x86_plain(crc, ptr, size); + 143 20466902 : if (tommy_likely(crc_x86)) { + 144 20466902 : return crc32c_x86_plain(crc, ptr, size); 145 : } 146 : #endif 147 0 : return crc32c_gen_plain(crc, ptr, size); diff --git a/cov/index-sort-f.html b/cov/index-sort-f.html index 4839cf1f..3d24930f 100644 --- a/cov/index-sort-f.html +++ b/cov/index-sort-f.html @@ -31,17 +31,17 @@ lcov.info Lines: - 9724 - 10419 - 93.3 % + 9735 + 10428 + 93.4 % Date: - 2016-01-09 + 2016-01-16 Functions: - 555 - 566 + 557 + 568 98.1 % @@ -75,9 +75,9 @@
91.6%91.6%
91.6 % - 7401 / 8084 + 7412 / 8093 97.3 % - 390 / 401 + 392 / 403 tommyds diff --git a/cov/index-sort-l.html b/cov/index-sort-l.html index 1ebddaa3..bebeeb30 100644 --- a/cov/index-sort-l.html +++ b/cov/index-sort-l.html @@ -31,17 +31,17 @@ lcov.info Lines: - 9724 - 10419 - 93.3 % + 9735 + 10428 + 93.4 % Date: - 2016-01-09 + 2016-01-16 Functions: - 555 - 566 + 557 + 568 98.1 % @@ -75,9 +75,9 @@
91.6%91.6%
91.6 % - 7401 / 8084 + 7412 / 8093 97.3 % - 390 / 401 + 392 / 403 raid diff --git a/cov/index.html b/cov/index.html index b78b1c9d..f0978061 100644 --- a/cov/index.html +++ b/cov/index.html @@ -31,17 +31,17 @@ lcov.info Lines: - 9724 - 10419 - 93.3 % + 9735 + 10428 + 93.4 % Date: - 2016-01-09 + 2016-01-16 Functions: - 555 - 566 + 557 + 568 98.1 % @@ -75,9 +75,9 @@
91.6%91.6%
91.6 % - 7401 / 8084 + 7412 / 8093 97.3 % - 390 / 401 + 392 / 403 raid diff --git a/cov/raid/check.c.func-sort-c.html b/cov/raid/check.c.func-sort-c.html index f959d7cc..595f4813 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-01-09 + 2016-01-16 Functions: 3 diff --git a/cov/raid/check.c.func.html b/cov/raid/check.c.func.html index 0521de7f..3bddbfc8 100644 --- a/cov/raid/check.c.func.html +++ b/cov/raid/check.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 diff --git a/cov/raid/check.c.gcov.html b/cov/raid/check.c.gcov.html index adb2d25e..f4aebb08 100644 --- a/cov/raid/check.c.gcov.html +++ b/cov/raid/check.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 diff --git a/cov/raid/combo.h.func-sort-c.html b/cov/raid/combo.h.func-sort-c.html index acdfb314..6f08c20c 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-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/combo.h.func.html b/cov/raid/combo.h.func.html index 38c5a666..761c133f 100644 --- a/cov/raid/combo.h.func.html +++ b/cov/raid/combo.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/combo.h.gcov.html b/cov/raid/combo.h.gcov.html index 2ab1cb73..1585755f 100644 --- a/cov/raid/combo.h.gcov.html +++ b/cov/raid/combo.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 @@ -170,10 +170,10 @@ 108 : int i; 109 : 110 : (void)n; /* unused, but kept for clarity */ - 111 209410 : assert(0 < r && r <= n); + 111 209277 : assert(0 < r && r <= n); 112 : - 113 691629 : for (i = 0; i < r; ++i) - 114 482219 : c[i] = i; + 113 691232 : for (i = 0; i < r; ++i) + 114 481955 : 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 51718 : int i = r - 1; /* present position */ - 124 51718 : int h = n; /* high limit for this position */ + 123 51685 : int i = r - 1; /* present position */ + 124 51685 : int h = n; /* high limit for this position */ 125 : 126 : recurse: 127 : /* next element at position i */ - 128 84591 : ++c[i]; + 128 84558 : ++c[i]; 129 : 130 : /* if the position has reached the max */ - 131 84591 : if (c[i] >= h) { + 131 84558 : if (c[i] >= h) { 132 : 133 : /* if we are at the first level, we have finished */ - 134 44873 : if (i == 0) - 135 12000 : return 0; + 134 44862 : if (i == 0) + 135 11989 : return 0; 136 : 137 : /* increase the previous position */ 138 32873 : --i; @@ -202,16 +202,16 @@ 140 : goto recurse; 141 : } 142 : - 143 39718 : ++i; + 143 39696 : ++i; 144 : 145 : /* initialize all the next positions, if any */ - 146 62263 : while (i < r) { + 146 62241 : 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 39718 : return 1; + 152 39696 : 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 0c37739e..7d884f00 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-01-09 + 2016-01-16 Functions: 12 @@ -61,43 +61,43 @@ raid_cpuid - 2016 + 2030 raid_cpu_match_sse - 1149 + 1157 raid_cpu_has_ssse3 - 569 + 573 raid_cpu_match_avx - 308 + 310 raid_cpu_has_avx2 - 308 + 310 raid_cpu_has_sse2 - 296 + 298 raid_cpu_has_crc32 - 284 + 286 raid_cpu_info - 268 + 270 raid_cpu_is_atom - 264 + 266 raid_cpu_has_slowmult - 260 + 262 raid_xgetbv diff --git a/cov/raid/cpu.h.func.html b/cov/raid/cpu.h.func.html index 738406d1..15117fb0 100644 --- a/cov/raid/cpu.h.func.html +++ b/cov/raid/cpu.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 12 @@ -61,11 +61,11 @@ raid_cpu_has_avx2 - 308 + 310 raid_cpu_has_crc32 - 284 + 286 raid_cpu_has_slowextendedreg @@ -73,35 +73,35 @@ raid_cpu_has_slowmult - 260 + 262 raid_cpu_has_sse2 - 296 + 298 raid_cpu_has_ssse3 - 569 + 573 raid_cpu_info - 268 + 270 raid_cpu_is_atom - 264 + 266 raid_cpu_match_avx - 308 + 310 raid_cpu_match_sse - 1149 + 1157 raid_cpuid - 2016 + 2030 raid_xgetbv diff --git a/cov/raid/cpu.h.gcov.html b/cov/raid/cpu.h.gcov.html index 18c79d61..3d3dc543 100644 --- a/cov/raid/cpu.h.gcov.html +++ b/cov/raid/cpu.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 12 @@ -79,9 +79,9 @@ 17 : 18 : #ifdef CONFIG_X86 19 : - 20 2016 : static inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t *reg) + 20 2030 : static inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t *reg) 21 : { - 22 2016 : asm volatile ( + 22 2030 : 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 2016 : : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) + 32 2030 : : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) 33 : : "0" (func_eax), "2" (sub_ecx) 34 : #endif 35 : ); - 36 2016 : } + 36 2030 : } 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 268 : static inline void raid_cpu_info(char *vendor, unsigned *family, unsigned *model) + 53 270 : 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 268 : raid_cpuid(0, 0, reg); + 58 270 : raid_cpuid(0, 0, reg); 59 : - 60 268 : ((uint32_t*)vendor)[0] = reg[1]; - 61 268 : ((uint32_t*)vendor)[1] = reg[3]; - 62 268 : ((uint32_t*)vendor)[2] = reg[2]; - 63 268 : vendor[12] = 0; + 60 270 : ((uint32_t*)vendor)[0] = reg[1]; + 61 270 : ((uint32_t*)vendor)[1] = reg[3]; + 62 270 : ((uint32_t*)vendor)[2] = reg[2]; + 63 270 : vendor[12] = 0; 64 : - 65 268 : raid_cpuid(1, 0, reg); + 65 270 : raid_cpuid(1, 0, reg); 66 : - 67 268 : f = (reg[0] >> 8) & 0xF; - 68 268 : ef = (reg[0] >> 20) & 0xFF; - 69 268 : m = (reg[0] >> 4) & 0xF; - 70 268 : em = (reg[0] >> 16) & 0xF; + 67 270 : f = (reg[0] >> 8) & 0xF; + 68 270 : ef = (reg[0] >> 20) & 0xFF; + 69 270 : m = (reg[0] >> 4) & 0xF; + 70 270 : em = (reg[0] >> 16) & 0xF; 71 : - 72 268 : if (strcmp(vendor, "AuthenticAMD") == 0) { + 72 270 : 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 268 : *family = f + ef; - 82 268 : *model = m + (em << 4); + 81 270 : *family = f + ef; + 82 270 : *model = m + (em << 4); 83 : } - 84 268 : } + 84 270 : } 85 : - 86 1149 : static inline int raid_cpu_match_sse(uint32_t cpuid_1_ecx, uint32_t cpuid_1_edx) + 86 1157 : 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 1149 : raid_cpuid(1, 0, reg); - 91 1149 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) + 90 1157 : raid_cpuid(1, 0, reg); + 91 1157 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) 92 18 : return 0; - 93 1131 : if ((reg[3] & cpuid_1_edx) != cpuid_1_edx) + 93 1139 : if ((reg[3] & cpuid_1_edx) != cpuid_1_edx) 94 0 : return 0; 95 : - 96 1131 : return 1; + 96 1139 : return 1; 97 : } 98 : - 99 308 : static inline int raid_cpu_match_avx(uint32_t cpuid_1_ecx, uint32_t cpuid_7_ebx, uint32_t xcr0) + 99 310 : 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 308 : raid_cpuid(1, 0, reg); - 104 308 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) - 105 285 : return 0; + 103 310 : raid_cpuid(1, 0, reg); + 104 310 : if ((reg[2] & cpuid_1_ecx) != cpuid_1_ecx) + 105 287 : 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 296 : static inline int raid_cpu_has_sse2(void) + 118 298 : 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 296 : return raid_cpu_match_sse( + 132 298 : return raid_cpu_match_sse( 133 : 0, 134 : 1 << 26); /* SSE2 */ 135 : } 136 : - 137 569 : static inline int raid_cpu_has_ssse3(void) + 137 573 : 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 569 : return raid_cpu_match_sse( + 149 573 : return raid_cpu_match_sse( 150 : 1 << 9, /* SSSE3 */ 151 : 1 << 26); /* SSE2 */ 152 : } 153 : - 154 284 : static inline int raid_cpu_has_crc32(void) + 154 286 : 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 284 : return raid_cpu_match_sse( + 165 286 : return raid_cpu_match_sse( 166 : 1 << 20, /* CRC32 */ 167 : 0); 168 : } 169 : - 170 308 : static inline int raid_cpu_has_avx2(void) + 170 310 : 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 308 : return raid_cpu_match_avx( + 187 310 : 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 264 : static inline int raid_cpu_is_atom(unsigned family, unsigned model) + 218 266 : static inline int raid_cpu_is_atom(unsigned family, unsigned model) 219 : { - 220 264 : if (family != 6) + 220 266 : 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 522 : return model == 28 || model == 38 || model == 54 - 242 261 : || model == 39 || model == 53 || model == 74 - 243 261 : || model == 90 || model == 55 || model == 76 - 244 522 : || model == 93 || model == 77; + 241 526 : return model == 28 || model == 38 || model == 54 + 242 263 : || model == 39 || model == 53 || model == 74 + 243 263 : || model == 90 || model == 55 || model == 76 + 244 526 : || 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 260 : static inline int raid_cpu_has_slowmult(void) + 251 262 : 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 260 : raid_cpu_info(vendor, &family, &model); + 261 262 : raid_cpu_info(vendor, &family, &model); 262 : - 263 260 : if (strcmp(vendor, "GenuineIntel") == 0) { + 263 262 : 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 260 : if (raid_cpu_is_atom(family, model)) + 271 262 : if (raid_cpu_is_atom(family, model)) 272 0 : return 1; 273 : } 274 : - 275 260 : return 0; + 275 262 : 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 7af0ce91..501b4a2c 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-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/gf.h.func.html b/cov/raid/gf.h.func.html index 888e7000..d4ce5498 100644 --- a/cov/raid/gf.h.func.html +++ b/cov/raid/gf.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/gf.h.gcov.html b/cov/raid/gf.h.gcov.html index df951c95..86c231e5 100644 --- a/cov/raid/gf.h.gcov.html +++ b/cov/raid/gf.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 @@ -88,7 +88,7 @@ 26 : */ 27 : static __always_inline uint8_t mul(uint8_t a, uint8_t b) 28 : { - 29 23756618 : return gfmul[a][b]; + 29 23746054 : return gfmul[a][b]; 30 : } 31 : 32 : /* @@ -97,9 +97,9 @@ 35 : */ 36 : static __always_inline uint8_t inv(uint8_t v) 37 : { - 38 634222 : BUG_ON(v == 0); /* division by zero */ + 38 634006 : BUG_ON(v == 0); /* division by zero */ 39 : - 40 634222 : return gfinv[v]; + 40 634006 : return gfinv[v]; 41 : } 42 : 43 : /* @@ -125,7 +125,7 @@ 63 : */ 64 : static __always_inline uint8_t A(int p, int d) 65 : { - 66 2600612 : return gfgen[p][d]; + 66 2599720 : return gfgen[p][d]; 67 : } 68 : 69 : /* diff --git a/cov/raid/helper.c.func-sort-c.html b/cov/raid/helper.c.func-sort-c.html index 108d31b9..e9e3e2f7 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-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/helper.c.func.html b/cov/raid/helper.c.func.html index 0d73260c..9ba2c064 100644 --- a/cov/raid/helper.c.func.html +++ b/cov/raid/helper.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/helper.c.gcov.html b/cov/raid/helper.c.gcov.html index 884204c0..52492935 100644 --- a/cov/raid/helper.c.gcov.html +++ b/cov/raid/helper.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/index-sort-f.html b/cov/raid/index-sort-f.html index c85a5cc2..66295c70 100644 --- a/cov/raid/index-sort-f.html +++ b/cov/raid/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 83 diff --git a/cov/raid/index-sort-l.html b/cov/raid/index-sort-l.html index f03066e7..15c444e4 100644 --- a/cov/raid/index-sort-l.html +++ b/cov/raid/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 83 diff --git a/cov/raid/index.html b/cov/raid/index.html index bf806d40..b6fac4b4 100644 --- a/cov/raid/index.html +++ b/cov/raid/index.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 83 diff --git a/cov/raid/int.c.func-sort-c.html b/cov/raid/int.c.func-sort-c.html index 660780c1..9177a102 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-01-09 + 2016-01-16 Functions: 11 @@ -101,7 +101,7 @@ raid_gen6_int8 - 18 + 17
diff --git a/cov/raid/int.c.func.html b/cov/raid/int.c.func.html index 15c0b92e..4c9ff1f6 100644 --- a/cov/raid/int.c.func.html +++ b/cov/raid/int.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 @@ -89,7 +89,7 @@ raid_gen6_int8 - 18 + 17 raid_rec1_int8 diff --git a/cov/raid/int.c.gcov.html b/cov/raid/int.c.gcov.html index 861cd372..8bd05d64 100644 --- a/cov/raid/int.c.gcov.html +++ b/cov/raid/int.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 @@ -379,9 +379,9 @@ 317 : * But this is only a kind of reference function, and we are not really 318 : * interested in speed. 319 : */ - 320 18 : void raid_gen6_int8(int nd, size_t size, void **vv) + 320 17 : void raid_gen6_int8(int nd, size_t size, void **vv) 321 : { - 322 18 : uint8_t **v = (uint8_t **)vv; + 322 17 : uint8_t **v = (uint8_t **)vv; 323 : uint8_t *p; 324 : uint8_t *q; 325 : uint8_t *r; @@ -393,45 +393,45 @@ 331 : 332 : uint8_t d0, u0, t0, s0, r0, q0, p0; 333 : - 334 18 : l = nd - 1; - 335 18 : p = v[nd]; - 336 18 : q = v[nd + 1]; - 337 18 : r = v[nd + 2]; - 338 18 : s = v[nd + 3]; - 339 18 : t = v[nd + 4]; - 340 18 : u = v[nd + 5]; + 334 17 : l = nd - 1; + 335 17 : p = v[nd]; + 336 17 : q = v[nd + 1]; + 337 17 : r = v[nd + 2]; + 338 17 : s = v[nd + 3]; + 339 17 : t = v[nd + 4]; + 340 17 : u = v[nd + 5]; 341 : - 342 4194834 : for (i = 0; i < size; i += 1) { - 343 4194816 : p0 = q0 = r0 = s0 = t0 = u0 = 0; - 344 33562880 : for (d = l; d > 0; --d) { - 345 29368064 : d0 = v_8(v[d][i]); + 342 3932689 : for (i = 0; i < size; i += 1) { + 343 3932672 : p0 = q0 = r0 = s0 = t0 = u0 = 0; + 344 31465728 : for (d = l; d > 0; --d) { + 345 27533056 : d0 = v_8(v[d][i]); 346 : - 347 29368064 : p0 ^= d0; - 348 29368064 : q0 ^= gfmul[d0][gfgen[1][d]]; - 349 29368064 : r0 ^= gfmul[d0][gfgen[2][d]]; - 350 29368064 : s0 ^= gfmul[d0][gfgen[3][d]]; - 351 29368064 : t0 ^= gfmul[d0][gfgen[4][d]]; - 352 29368064 : u0 ^= gfmul[d0][gfgen[5][d]]; + 347 27533056 : p0 ^= d0; + 348 27533056 : q0 ^= gfmul[d0][gfgen[1][d]]; + 349 27533056 : r0 ^= gfmul[d0][gfgen[2][d]]; + 350 27533056 : s0 ^= gfmul[d0][gfgen[3][d]]; + 351 27533056 : t0 ^= gfmul[d0][gfgen[4][d]]; + 352 27533056 : u0 ^= gfmul[d0][gfgen[5][d]]; 353 : } 354 : 355 : /* first disk with all coefficients at 1 */ - 356 4194816 : d0 = v_8(v[0][i]); + 356 3932672 : d0 = v_8(v[0][i]); 357 : - 358 4194816 : p0 ^= d0; - 359 4194816 : q0 ^= d0; - 360 4194816 : r0 ^= d0; - 361 4194816 : s0 ^= d0; - 362 4194816 : t0 ^= d0; - 363 4194816 : u0 ^= d0; + 358 3932672 : p0 ^= d0; + 359 3932672 : q0 ^= d0; + 360 3932672 : r0 ^= d0; + 361 3932672 : s0 ^= d0; + 362 3932672 : t0 ^= d0; + 363 3932672 : u0 ^= d0; 364 : - 365 4194816 : v_8(p[i]) = p0; - 366 4194816 : v_8(q[i]) = q0; - 367 4194816 : v_8(r[i]) = r0; - 368 4194816 : v_8(s[i]) = s0; - 369 4194816 : v_8(t[i]) = t0; - 370 4194816 : v_8(u[i]) = u0; + 365 3932672 : v_8(p[i]) = p0; + 366 3932672 : v_8(q[i]) = q0; + 367 3932672 : v_8(r[i]) = r0; + 368 3932672 : v_8(s[i]) = s0; + 369 3932672 : v_8(t[i]) = t0; + 370 3932672 : v_8(u[i]) = u0; 371 : } - 372 18 : } + 372 17 : } 373 : 374 : /* 375 : * Recover failure of one data block at index id[0] using parity at index diff --git a/cov/raid/internal.h.func-sort-c.html b/cov/raid/internal.h.func-sort-c.html index 7dd87557..bb644d29 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-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/internal.h.func.html b/cov/raid/internal.h.func.html index 967a0919..95775474 100644 --- a/cov/raid/internal.h.func.html +++ b/cov/raid/internal.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 diff --git a/cov/raid/internal.h.gcov.html b/cov/raid/internal.h.gcov.html index ebbd007d..4243c8f1 100644 --- a/cov/raid/internal.h.gcov.html +++ b/cov/raid/internal.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 0 @@ -159,11 +159,11 @@ 97 : */ 98 : static __always_inline void *__align_ptr(void *ptr, uintptr_t size) 99 : { - 100 706415 : uintptr_t offset = (uintptr_t)ptr; + 100 706971 : uintptr_t offset = (uintptr_t)ptr; 101 : - 102 706415 : offset = (offset + size - 1U) & ~(size - 1U); + 102 706971 : offset = (offset + size - 1U) & ~(size - 1U); 103 : - 104 706415 : return (void *)offset; + 104 706971 : return (void *)offset; 105 : } 106 : 107 : /* @@ -284,7 +284,7 @@ 222 : /* that use a weak memory model. To ensure that other processors */ 223 : /* see correctly the data written, we use a store-store memory */ 224 : /* barrier at the end of the asm code */ - 225 1360449 : asm volatile ("sfence" : : : "memory"); + 225 1361316 : asm volatile ("sfence" : : : "memory"); 226 : 227 : /* clobbers registers used in the asm code */ 228 : /* this is required because in the Windows ABI, */ diff --git a/cov/raid/intz.c.func-sort-c.html b/cov/raid/intz.c.func-sort-c.html index 55b7b56a..0e80bd20 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-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/intz.c.func.html b/cov/raid/intz.c.func.html index 53b342cf..89f9e08d 100644 --- a/cov/raid/intz.c.func.html +++ b/cov/raid/intz.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/intz.c.gcov.html b/cov/raid/intz.c.gcov.html index 5e3bd004..2fee55d4 100644 --- a/cov/raid/intz.c.gcov.html +++ b/cov/raid/intz.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 diff --git a/cov/raid/memory.c.func-sort-c.html b/cov/raid/memory.c.func-sort-c.html index 5c3a69d2..33c8db2c 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-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ raid_mtest_vector - 1908 + 1936 raid_malloc_align - 306 + 310 raid_malloc_vector - 215 + 217 raid_mrand_vector diff --git a/cov/raid/memory.c.func.html b/cov/raid/memory.c.func.html index cc06ef36..531aaa3d 100644 --- a/cov/raid/memory.c.func.html +++ b/cov/raid/memory.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,11 +61,11 @@ raid_malloc_align - 306 + 310 raid_malloc_vector - 215 + 217 raid_mrand_vector @@ -73,7 +73,7 @@ raid_mtest_vector - 1908 + 1936
diff --git a/cov/raid/memory.c.gcov.html b/cov/raid/memory.c.gcov.html index aa6061b4..5468dd0d 100644 --- a/cov/raid/memory.c.gcov.html +++ b/cov/raid/memory.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -77,66 +77,66 @@ 15 : #include "internal.h" 16 : #include "memory.h" 17 : - 18 306 : void *raid_malloc_align(size_t size, void **freeptr) + 18 310 : void *raid_malloc_align(size_t size, void **freeptr) 19 : { 20 : unsigned char *ptr; 21 : uintptr_t offset; 22 : - 23 306 : ptr = malloc(size + RAID_MALLOC_ALIGN); - 24 306 : if (!ptr) { + 23 310 : ptr = malloc(size + RAID_MALLOC_ALIGN); + 24 310 : if (!ptr) { 25 : /* LCOV_EXCL_START */ 26 : return 0; 27 : /* LCOV_EXCL_STOP */ 28 : } 29 : - 30 306 : *freeptr = ptr; + 30 310 : *freeptr = ptr; 31 : - 32 306 : offset = ((uintptr_t)ptr) % RAID_MALLOC_ALIGN; + 32 310 : offset = ((uintptr_t)ptr) % RAID_MALLOC_ALIGN; 33 : - 34 306 : if (offset != 0) - 35 297 : ptr += RAID_MALLOC_ALIGN - offset; + 34 310 : if (offset != 0) + 35 299 : ptr += RAID_MALLOC_ALIGN - offset; 36 : - 37 306 : return ptr; + 37 310 : return ptr; 38 : } 39 : - 40 215 : void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr) + 40 217 : void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr) 41 : { 42 : void **v; 43 : unsigned char *va; 44 : int i; 45 : - 46 215 : BUG_ON(n <= 0 || nd < 0); + 46 217 : BUG_ON(n <= 0 || nd < 0); 47 : - 48 215 : v = malloc(n * sizeof(void *)); - 49 215 : if (!v) { + 48 217 : v = malloc(n * sizeof(void *)); + 49 217 : if (!v) { 50 : /* LCOV_EXCL_START */ 51 : return 0; 52 : /* LCOV_EXCL_STOP */ 53 : } 54 : - 55 215 : va = raid_malloc_align(n * (size + RAID_MALLOC_DISPLACEMENT), freeptr); - 56 215 : if (!va) { + 55 217 : va = raid_malloc_align(n * (size + RAID_MALLOC_DISPLACEMENT), freeptr); + 56 217 : if (!va) { 57 : /* LCOV_EXCL_START */ 58 : free(v); 59 : return 0; 60 : /* LCOV_EXCL_STOP */ 61 : } 62 : - 63 3836 : for (i = 0; i < n; ++i) { - 64 3621 : v[i] = va; - 65 3621 : va += size + RAID_MALLOC_DISPLACEMENT; + 63 3876 : for (i = 0; i < n; ++i) { + 64 3659 : v[i] = va; + 65 3659 : va += size + RAID_MALLOC_DISPLACEMENT; 66 : } 67 : 68 : /* reverse order of the data blocks */ 69 : /* because they are usually accessed from the last one */ - 70 898 : for (i = 0; i < nd / 2; ++i) { - 71 683 : void *ptr = v[i]; + 70 906 : for (i = 0; i < nd / 2; ++i) { + 71 689 : void *ptr = v[i]; 72 : - 73 683 : v[i] = v[nd - 1 - i]; - 74 683 : v[nd - 1 - i] = ptr; + 73 689 : v[i] = v[nd - 1 - i]; + 74 689 : v[nd - 1 - i] = ptr; 75 : } 76 : - 77 215 : return v; + 77 217 : return v; 78 : } 79 : 80 5 : void raid_mrand_vector(unsigned seed, int n, size_t size, void **vv) @@ -154,9 +154,9 @@ 92 : } 93 5 : } 94 : - 95 1908 : int raid_mtest_vector(int n, size_t size, void **vv) + 95 1936 : int raid_mtest_vector(int n, size_t size, void **vv) 96 : { - 97 1908 : unsigned char **v = (unsigned char **)vv; + 97 1936 : unsigned char **v = (unsigned char **)vv; 98 : int i; 99 : size_t j; 100 : unsigned k; @@ -164,44 +164,44 @@ 102 : unsigned char p; 103 : 104 : /* fill with 0 */ - 105 1908 : d = 0; - 106 3908 : for (i = 0; i < n; ++i) - 107 107048920 : for (j = 0; j < size; ++j) - 108 107046920 : v[i][j] = d; + 105 1936 : d = 0; + 106 3964 : for (i = 0; i < n; ++i) + 107 108883956 : for (j = 0; j < size; ++j) + 108 108881928 : v[i][j] = d; 109 : 110 : /* test with all the byte patterns */ - 111 488448 : for (k = 1; k < 256; ++k) { - 112 486540 : p = d; - 113 486540 : d = k; + 111 495616 : for (k = 1; k < 256; ++k) { + 112 493680 : p = d; + 113 493680 : d = k; 114 : 115 : /* forward fill */ - 116 996540 : for (i = 0; i < n; ++i) { - 117 27297474600 : for (j = 0; j < size; ++j) { - 118 27296964600 : if (v[i][j] != p) { + 116 1010820 : for (i = 0; i < n; ++i) { + 117 27765408780 : for (j = 0; j < size; ++j) { + 118 27764891640 : if (v[i][j] != p) { 119 : /* LCOV_EXCL_START */ 120 : return -1; 121 : /* LCOV_EXCL_STOP */ 122 : } - 123 27296964600 : v[i][j] = d; + 123 27764891640 : v[i][j] = d; 124 : } 125 : } 126 : - 127 486540 : p = d; - 128 486540 : d = ~p; + 127 493680 : p = d; + 128 493680 : d = ~p; 129 : /* backward fill with complement */ - 130 996540 : for (i = 0; i < n; ++i) { - 131 27297474600 : for (j = size; j > 0; --j) { - 132 27296964600 : if (v[i][j - 1] != p) { + 130 1010820 : for (i = 0; i < n; ++i) { + 131 27765408780 : for (j = size; j > 0; --j) { + 132 27764891640 : if (v[i][j - 1] != p) { 133 : /* LCOV_EXCL_START */ 134 : return -1; 135 : /* LCOV_EXCL_STOP */ 136 : } - 137 27296964600 : v[i][j - 1] = d; + 137 27764891640 : v[i][j - 1] = d; 138 : } 139 : } 140 : } 141 : - 142 1908 : return 0; + 142 1936 : return 0; 143 : } 144 : diff --git a/cov/raid/module.c.func-sort-c.html b/cov/raid/module.c.func-sort-c.html index 7e3f1ccb..3fd08168 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-01-09 + 2016-01-16 Functions: 7 @@ -61,7 +61,7 @@ raid_init - 260 + 262 raid_test_rec diff --git a/cov/raid/module.c.func.html b/cov/raid/module.c.func.html index b40762dd..c1610094 100644 --- a/cov/raid/module.c.func.html +++ b/cov/raid/module.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 @@ -65,7 +65,7 @@ raid_init - 260 + 262 raid_selftest diff --git a/cov/raid/module.c.gcov.html b/cov/raid/module.c.gcov.html index ffb20426..54fac0af 100644 --- a/cov/raid/module.c.gcov.html +++ b/cov/raid/module.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 @@ -81,34 +81,34 @@ 19 : /* 20 : * Initializes and selects the best algorithm. 21 : */ - 22 260 : void raid_init(void) + 22 262 : void raid_init(void) 23 : { - 24 260 : raid_gen3_ptr = raid_gen3_int8; - 25 260 : raid_gen_ptr[3] = raid_gen4_int8; - 26 260 : raid_gen_ptr[4] = raid_gen5_int8; - 27 260 : raid_gen_ptr[5] = raid_gen6_int8; + 24 262 : raid_gen3_ptr = raid_gen3_int8; + 25 262 : raid_gen_ptr[3] = raid_gen4_int8; + 26 262 : raid_gen_ptr[4] = raid_gen5_int8; + 27 262 : raid_gen_ptr[5] = raid_gen6_int8; 28 : 29 : if (sizeof(void *) == 4) { - 30 260 : raid_gen_ptr[0] = raid_gen1_int32; - 31 260 : raid_gen_ptr[1] = raid_gen2_int32; - 32 260 : raid_genz_ptr = raid_genz_int32; + 30 262 : raid_gen_ptr[0] = raid_gen1_int32; + 31 262 : raid_gen_ptr[1] = raid_gen2_int32; + 32 262 : 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 260 : raid_rec_ptr[0] = raid_rec1_int8; - 40 260 : raid_rec_ptr[1] = raid_rec2_int8; - 41 260 : raid_rec_ptr[2] = raid_recX_int8; - 42 260 : raid_rec_ptr[3] = raid_recX_int8; - 43 260 : raid_rec_ptr[4] = raid_recX_int8; - 44 260 : raid_rec_ptr[5] = raid_recX_int8; + 39 262 : raid_rec_ptr[0] = raid_rec1_int8; + 40 262 : raid_rec_ptr[1] = raid_rec2_int8; + 41 262 : raid_rec_ptr[2] = raid_recX_int8; + 42 262 : raid_rec_ptr[3] = raid_recX_int8; + 43 262 : raid_rec_ptr[4] = raid_recX_int8; + 44 262 : raid_rec_ptr[5] = raid_recX_int8; 45 : 46 : #ifdef CONFIG_X86 47 : #ifdef CONFIG_SSE2 - 48 260 : if (raid_cpu_has_sse2()) { - 49 260 : raid_gen_ptr[0] = raid_gen1_sse2; + 48 262 : if (raid_cpu_has_sse2()) { + 49 262 : 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 260 : raid_gen_ptr[1] = raid_gen2_sse2; - 60 260 : raid_genz_ptr = raid_genz_sse2; + 59 262 : raid_gen_ptr[1] = raid_gen2_sse2; + 60 262 : raid_genz_ptr = raid_genz_sse2; 61 : #endif 62 : } 63 : #endif 64 : 65 : #ifdef CONFIG_SSSE3 - 66 260 : if (raid_cpu_has_ssse3()) { + 66 262 : 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 259 : raid_gen3_ptr = raid_gen3_ssse3; - 81 259 : raid_gen_ptr[3] = raid_gen4_ssse3; - 82 259 : raid_gen_ptr[4] = raid_gen5_ssse3; - 83 259 : raid_gen_ptr[5] = raid_gen6_ssse3; + 80 261 : raid_gen3_ptr = raid_gen3_ssse3; + 81 261 : raid_gen_ptr[3] = raid_gen4_ssse3; + 82 261 : raid_gen_ptr[4] = raid_gen5_ssse3; + 83 261 : raid_gen_ptr[5] = raid_gen6_ssse3; 84 : #endif - 85 259 : raid_rec_ptr[0] = raid_rec1_ssse3; - 86 259 : raid_rec_ptr[1] = raid_rec2_ssse3; - 87 259 : raid_rec_ptr[2] = raid_recX_ssse3; - 88 259 : raid_rec_ptr[3] = raid_recX_ssse3; - 89 259 : raid_rec_ptr[4] = raid_recX_ssse3; - 90 259 : raid_rec_ptr[5] = raid_recX_ssse3; + 85 261 : raid_rec_ptr[0] = raid_rec1_ssse3; + 86 261 : raid_rec_ptr[1] = raid_rec2_ssse3; + 87 261 : raid_rec_ptr[2] = raid_recX_ssse3; + 88 261 : raid_rec_ptr[3] = raid_recX_ssse3; + 89 261 : raid_rec_ptr[4] = raid_recX_ssse3; + 90 261 : raid_rec_ptr[5] = raid_recX_ssse3; 91 : } 92 : #endif 93 : 94 : #ifdef CONFIG_AVX2 - 95 260 : if (raid_cpu_has_avx2()) { + 95 262 : 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 260 : raid_mode(RAID_MODE_CAUCHY); - 117 260 : } + 116 262 : raid_mode(RAID_MODE_CAUCHY); + 117 262 : } 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 aa6d9f7a..0da3ba96 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-01-09 + 2016-01-16 Functions: 9 @@ -61,35 +61,35 @@ raid_gen - 1208170 + 1209124 raid_data - 211361 + 211206 raid_invert - 172152 + 172088 raid_delta_gen - 170824 + 170738 raid_rec1of1 - 98917 + 98849 raid_rec - 869 + 870 raid_mode - 519 + 523 raid_zero - 201 + 203 raid_rec2of2_int8 diff --git a/cov/raid/raid.c.func.html b/cov/raid/raid.c.func.html index 6978ce2b..8b3009ed 100644 --- a/cov/raid/raid.c.func.html +++ b/cov/raid/raid.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 9 @@ -61,31 +61,31 @@ raid_data - 211361 + 211206 raid_delta_gen - 170824 + 170738 raid_gen - 1208170 + 1209124 raid_invert - 172152 + 172088 raid_mode - 519 + 523 raid_rec - 869 + 870 raid_rec1of1 - 98917 + 98849 raid_rec2of2_int8 @@ -93,7 +93,7 @@ raid_zero - 201 + 203
diff --git a/cov/raid/raid.c.gcov.html b/cov/raid/raid.c.gcov.html index ce8ab3b6..4e474170 100644 --- a/cov/raid/raid.c.gcov.html +++ b/cov/raid/raid.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 9 @@ -235,26 +235,26 @@ 173 : */ 174 : const uint8_t (*raid_gfgen)[256]; 175 : - 176 519 : void raid_mode(int mode) + 176 523 : void raid_mode(int mode) 177 : { - 178 519 : if (mode == RAID_MODE_VANDERMONDE) { + 178 523 : if (mode == RAID_MODE_VANDERMONDE) { 179 2 : raid_gen_ptr[2] = raid_genz_ptr; 180 2 : raid_gfgen = gfvandermonde; 181 : } else { - 182 517 : raid_gen_ptr[2] = raid_gen3_ptr; - 183 517 : raid_gfgen = gfcauchy; + 182 521 : raid_gen_ptr[2] = raid_gen3_ptr; + 183 521 : raid_gfgen = gfcauchy; 184 : } - 185 519 : } + 185 523 : } 186 : 187 : /** 188 : * Buffer filled with 0 used in recovering. 189 : */ 190 : static void *raid_zero_block; 191 : - 192 201 : void raid_zero(void *zero) + 192 203 : void raid_zero(void *zero) 193 : { - 194 201 : raid_zero_block = zero; - 195 201 : } + 194 203 : raid_zero_block = zero; + 195 203 : } 196 : 197 : /* 198 : * Forwarders for parity computation. @@ -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 1208170 : void raid_gen(int nd, int np, size_t size, void **v) + 223 1209124 : void raid_gen(int nd, int np, size_t size, void **v) 224 : { 225 : /* enforce limit on size */ - 226 1208170 : BUG_ON(size % 64 != 0); + 226 1209124 : BUG_ON(size % 64 != 0); 227 : 228 : /* enforce limit on number of failures */ - 229 1208170 : BUG_ON(np < 1); - 230 1208170 : BUG_ON(np > RAID_PARITY_MAX); + 229 1209124 : BUG_ON(np < 1); + 230 1209124 : BUG_ON(np > RAID_PARITY_MAX); 231 : - 232 1208170 : raid_gen_ptr[np - 1](nd, size, v); - 233 1208170 : } + 232 1209124 : raid_gen_ptr[np - 1](nd, size, v); + 233 1209124 : } 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 172152 : void raid_invert(uint8_t *M, uint8_t *V, int n) + 246 172088 : 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 796315 : for (i = 0; i < n; ++i) - 252 3214980 : for (j = 0; j < n; ++j) - 253 2590817 : V[i * n + j] = i == j; + 251 796057 : for (i = 0; i < n; ++i) + 252 3213916 : for (j = 0; j < n; ++j) + 253 2589947 : V[i * n + j] = i == j; 254 : 255 : /* for each element in the diagonal */ - 256 796315 : for (k = 0; k < n; ++k) { + 256 796057 : 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 624163 : BUG_ON(M[k * n + k] == 0); + 262 623969 : BUG_ON(M[k * n + k] == 0); 263 : 264 : /* make the diagonal element to be 1 */ - 265 1248326 : f = inv(M[k * n + k]); - 266 3214980 : for (j = 0; j < n; ++j) { - 267 5181634 : M[k * n + j] = mul(f, M[k * n + j]); - 268 5181634 : V[k * n + j] = mul(f, V[k * n + j]); + 265 1247938 : f = inv(M[k * n + k]); + 266 3213916 : for (j = 0; j < n; ++j) { + 267 5179894 : M[k * n + j] = mul(f, M[k * n + j]); + 268 5179894 : 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 3214980 : for (i = 0; i < n; ++i) { - 274 2590817 : if (i == k) - 275 624163 : continue; - 276 1966654 : f = M[i * n + k]; - 277 11254146 : for (j = 0; j < n; ++j) { - 278 18574984 : M[i * n + j] ^= mul(f, M[k * n + j]); - 279 18574984 : V[i * n + j] ^= mul(f, V[k * n + j]); + 273 3213916 : for (i = 0; i < n; ++i) { + 274 2589947 : if (i == k) + 275 623969 : continue; + 276 1965978 : f = M[i * n + k]; + 277 11249058 : for (j = 0; j < n; ++j) { + 278 18566160 : M[i * n + j] ^= mul(f, M[k * n + j]); + 279 18566160 : V[i * n + j] ^= mul(f, V[k * n + j]); 280 : } 281 : } 282 : } - 283 172152 : } + 283 172088 : } 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 170824 : void raid_delta_gen(int nr, int *id, int *ip, int nd, size_t size, void **v) + 291 170738 : 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 170824 : np = ip[nr - 1] + 1; + 301 170738 : np = ip[nr - 1] + 1; 302 : 303 : /* latest missing data block */ - 304 170824 : latest = v[id[nr - 1]]; + 304 170738 : latest = v[id[nr - 1]]; 305 : 306 : /* setup pointers for delta computation */ - 307 870818 : for (i = 0, j = 0; i < np; ++i) { + 307 870494 : for (i = 0, j = 0; i < np; ++i) { 308 : /* keep a copy of the original parity vector */ - 309 699994 : p[i] = v[nd + i]; + 309 699756 : p[i] = v[nd + i]; 310 : - 311 699994 : if (ip[j] == i) { + 311 699756 : 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 604161 : BUG_ON(j >= nr); + 322 603945 : BUG_ON(j >= nr); 323 : 324 : /* buffer for missing data blocks */ - 325 604161 : pa[j] = v[id[j]]; + 325 603945 : pa[j] = v[id[j]]; 326 : 327 : /* set at zero the missing data blocks */ - 328 604161 : v[id[j]] = raid_zero_block; + 328 603945 : v[id[j]] = raid_zero_block; 329 : 330 : /* compute the parity over the missing data blocks */ - 331 604161 : v[nd + i] = pa[j]; + 331 603945 : v[nd + i] = pa[j]; 332 : 333 : /* check for the next used entry */ - 334 604161 : ++j; + 334 603945 : ++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 95833 : v[nd + i] = latest; + 354 95811 : v[nd + i] = latest; 355 : } 356 : } 357 : 358 : /* all the parities have to be processed */ - 359 170824 : BUG_ON(j != nr); + 359 170738 : BUG_ON(j != nr); 360 : 361 : /* recompute the parity, note that np may be smaller than the */ 362 : /* total number of parities available */ - 363 170824 : raid_gen(nd, np, size, v); + 363 170738 : raid_gen(nd, np, size, v); 364 : 365 : /* restore data buffers as before */ - 366 774985 : for (j = 0; j < nr; ++j) - 367 604161 : v[id[j]] = pa[j]; + 366 774683 : for (j = 0; j < nr; ++j) + 367 603945 : v[id[j]] = pa[j]; 368 : 369 : /* restore parity buffers as before */ - 370 870818 : for (i = 0; i < np; ++i) - 371 699994 : v[nd + i] = p[i]; - 372 170824 : } + 370 870494 : for (i = 0; i < np; ++i) + 371 699756 : v[nd + i] = p[i]; + 372 170738 : } 373 : 374 : /** 375 : * Recover failure of one data block for PAR1. @@ -444,29 +444,29 @@ 382 : * 383 : * Dx = Pd 384 : */ - 385 98917 : void raid_rec1of1(int *id, int nd, size_t size, void **v) + 385 98849 : 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 98917 : p = v[nd]; - 393 98917 : pa = v[id[0]]; + 392 98849 : p = v[nd]; + 393 98849 : pa = v[id[0]]; 394 : 395 : /* use the parity as missing data block */ - 396 98917 : v[id[0]] = p; + 396 98849 : v[id[0]] = p; 397 : 398 : /* compute the parity over the missing data block */ - 399 98917 : v[nd] = pa; + 399 98849 : v[nd] = pa; 400 : 401 : /* compute */ - 402 98917 : raid_gen(nd, 1, size, v); + 402 98849 : raid_gen(nd, 1, size, v); 403 : 404 : /* restore as before */ - 405 98917 : v[id[0]] = pa; - 406 98917 : v[nd] = p; - 407 98917 : } + 405 98849 : v[id[0]] = pa; + 406 98849 : v[nd] = p; + 407 98849 : } 408 : 409 : /** 410 : * Recover failure of two data blocks for PAR2. @@ -554,97 +554,97 @@ 492 : void (*raid_rec_ptr[RAID_PARITY_MAX])( 493 : int nr, int *id, int *ip, int nd, size_t size, void **vv); 494 : - 495 869 : void raid_rec(int nr, int *ir, int nd, int np, size_t size, void **v) + 495 870 : void raid_rec(int nr, int *ir, int nd, int np, size_t size, void **v) 496 : { 497 : int nrd; /* number of data blocks to recover */ 498 : int nrp; /* number of parity blocks to recover */ 499 : 500 : /* enforce limit on size */ - 501 869 : BUG_ON(size % 64 != 0); + 501 870 : BUG_ON(size % 64 != 0); 502 : 503 : /* enforce limit on number of failures */ - 504 869 : BUG_ON(nr > np); - 505 869 : BUG_ON(np > RAID_PARITY_MAX); + 504 870 : BUG_ON(nr > np); + 505 870 : BUG_ON(np > RAID_PARITY_MAX); 506 : 507 : /* enforce order in index vector */ - 508 869 : BUG_ON(nr >= 2 && ir[0] >= ir[1]); - 509 869 : BUG_ON(nr >= 3 && ir[1] >= ir[2]); - 510 869 : BUG_ON(nr >= 4 && ir[2] >= ir[3]); - 511 869 : BUG_ON(nr >= 5 && ir[3] >= ir[4]); - 512 869 : BUG_ON(nr >= 6 && ir[4] >= ir[5]); + 508 870 : BUG_ON(nr >= 2 && ir[0] >= ir[1]); + 509 870 : BUG_ON(nr >= 3 && ir[1] >= ir[2]); + 510 870 : BUG_ON(nr >= 4 && ir[2] >= ir[3]); + 511 870 : BUG_ON(nr >= 5 && ir[3] >= ir[4]); + 512 870 : BUG_ON(nr >= 6 && ir[4] >= ir[5]); 513 : 514 : /* enforce limit on index vector */ - 515 869 : BUG_ON(nr > 0 && ir[nr-1] >= nd + np); + 515 870 : BUG_ON(nr > 0 && ir[nr-1] >= nd + np); 516 : 517 : /* count the number of data blocks to recover */ - 518 869 : nrd = 0; - 519 3479 : while (nrd < nr && ir[nrd] < nd) - 520 1741 : ++nrd; + 518 870 : nrd = 0; + 519 3483 : while (nrd < nr && ir[nrd] < nd) + 520 1743 : ++nrd; 521 : 522 : /* all the remaining are parity */ - 523 869 : nrp = nr - nrd; + 523 870 : nrp = nr - nrd; 524 : 525 : /* enforce limit on number of failures */ - 526 869 : BUG_ON(nrd > nd); - 527 869 : BUG_ON(nrp > np); + 526 870 : BUG_ON(nrd > nd); + 527 870 : BUG_ON(nrp > np); 528 : 529 : /* if failed data is present */ - 530 869 : if (nrd != 0) { + 530 870 : if (nrd != 0) { 531 : int ip[RAID_PARITY_MAX]; 532 : int i, j, k; 533 : 534 : /* setup the vector of parities to use */ - 535 6034 : for (i = 0, j = 0, k = 0; i < np; ++i) { - 536 5167 : if (j < nrp && ir[nrd + j] == nd + i) { + 535 6041 : for (i = 0, j = 0, k = 0; i < np; ++i) { + 536 5173 : if (j < nrp && ir[nrd + j] == nd + i) { 537 : /* this parity has to be recovered */ 538 22 : ++j; 539 : } else { 540 : /* this parity is used for recovering */ - 541 5145 : ip[k] = i; - 542 5145 : ++k; + 541 5151 : ip[k] = i; + 542 5151 : ++k; 543 : } 544 : } 545 : 546 : /* recover the nrd data blocks specified in ir[], */ 547 : /* using the first nrd parity in ip[] for recovering */ - 548 867 : raid_rec_ptr[nrd - 1](nrd, ir, ip, nd, size, v); + 548 868 : raid_rec_ptr[nrd - 1](nrd, ir, ip, nd, size, v); 549 : } 550 : 551 : /* recompute all the parities up to the last bad one */ - 552 869 : if (nrp != 0) + 552 870 : if (nrp != 0) 553 12 : raid_gen(nd, ir[nr - 1] - nd + 1, size, v); - 554 869 : } + 554 870 : } 555 : - 556 211361 : void raid_data(int nr, int *id, int *ip, int nd, size_t size, void **v) + 556 211206 : void raid_data(int nr, int *id, int *ip, int nd, size_t size, void **v) 557 : { 558 : /* enforce limit on size */ - 559 211361 : BUG_ON(size % 64 != 0); + 559 211206 : BUG_ON(size % 64 != 0); 560 : 561 : /* enforce limit on number of failures */ - 562 211361 : BUG_ON(nr > nd); - 563 211361 : BUG_ON(nr > RAID_PARITY_MAX); + 562 211206 : BUG_ON(nr > nd); + 563 211206 : BUG_ON(nr > RAID_PARITY_MAX); 564 : 565 : /* enforce order in index vector for data */ - 566 211361 : BUG_ON(nr >= 2 && id[0] >= id[1]); - 567 211361 : BUG_ON(nr >= 3 && id[1] >= id[2]); - 568 211361 : BUG_ON(nr >= 4 && id[2] >= id[3]); - 569 211361 : BUG_ON(nr >= 5 && id[3] >= id[4]); - 570 211361 : BUG_ON(nr >= 6 && id[4] >= id[5]); + 566 211206 : BUG_ON(nr >= 2 && id[0] >= id[1]); + 567 211206 : BUG_ON(nr >= 3 && id[1] >= id[2]); + 568 211206 : BUG_ON(nr >= 4 && id[2] >= id[3]); + 569 211206 : BUG_ON(nr >= 5 && id[3] >= id[4]); + 570 211206 : BUG_ON(nr >= 6 && id[4] >= id[5]); 571 : 572 : /* enforce limit on index vector for data */ - 573 211361 : BUG_ON(nr > 0 && id[nr-1] >= nd); + 573 211206 : BUG_ON(nr > 0 && id[nr-1] >= nd); 574 : 575 : /* enforce order in index vector for parity */ - 576 211361 : BUG_ON(nr >= 2 && ip[0] >= ip[1]); - 577 211361 : BUG_ON(nr >= 3 && ip[1] >= ip[2]); - 578 211361 : BUG_ON(nr >= 4 && ip[2] >= ip[3]); - 579 211361 : BUG_ON(nr >= 5 && ip[3] >= ip[4]); - 580 211361 : BUG_ON(nr >= 6 && ip[4] >= ip[5]); + 576 211206 : BUG_ON(nr >= 2 && ip[0] >= ip[1]); + 577 211206 : BUG_ON(nr >= 3 && ip[1] >= ip[2]); + 578 211206 : BUG_ON(nr >= 4 && ip[2] >= ip[3]); + 579 211206 : BUG_ON(nr >= 5 && ip[3] >= ip[4]); + 580 211206 : BUG_ON(nr >= 6 && ip[4] >= ip[5]); 581 : 582 : /* if failed data is present */ - 583 211361 : if (nr != 0) - 584 211359 : raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v); - 585 211361 : } + 583 211206 : if (nr != 0) + 584 211204 : raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v); + 585 211206 : } 586 : diff --git a/cov/raid/tag.c.func-sort-c.html b/cov/raid/tag.c.func-sort-c.html index 3fd08c9b..4794e41b 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-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/raid/tag.c.func.html b/cov/raid/tag.c.func.html index 3d1d2299..716615ae 100644 --- a/cov/raid/tag.c.func.html +++ b/cov/raid/tag.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/raid/tag.c.gcov.html b/cov/raid/tag.c.gcov.html index 57254a98..5935ef17 100644 --- a/cov/raid/tag.c.gcov.html +++ b/cov/raid/tag.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 diff --git a/cov/raid/test.c.func-sort-c.html b/cov/raid/test.c.func-sort-c.html index 3e30deb8..02762d8b 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-01-09 + 2016-01-16 Functions: 7 diff --git a/cov/raid/test.c.func.html b/cov/raid/test.c.func.html index 3fcc40a8..9fed8e59 100644 --- a/cov/raid/test.c.func.html +++ b/cov/raid/test.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 diff --git a/cov/raid/test.c.gcov.html b/cov/raid/test.c.gcov.html index 46a5ea0a..761f5c8f 100644 --- a/cov/raid/test.c.gcov.html +++ b/cov/raid/test.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 7 diff --git a/cov/raid/x86.c.func-sort-c.html b/cov/raid/x86.c.func-sort-c.html index 576bb3bc..1a021a66 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-01-09 + 2016-01-16 Functions: 14 @@ -61,39 +61,39 @@ raid_gen6_ssse3 - 559030 - - - raid_gen2_sse2 - 267701 + 559501 raid_gen1_sse2 - 267673 + 267886 + + + raid_gen2_sse2 + 267838 raid_rec1_ssse3 - 108422 + 108332 raid_recX_ssse3 - 79451 + 79421 raid_gen5_ssse3 - 50169 + 50284 raid_rec2_ssse3 - 43538 + 43504 raid_gen4_ssse3 - 32723 + 32754 raid_gen3_ssse3 - 29756 + 29742 raid_recX_avx2 diff --git a/cov/raid/x86.c.func.html b/cov/raid/x86.c.func.html index ee9d7e4c..2fee6dc8 100644 --- a/cov/raid/x86.c.func.html +++ b/cov/raid/x86.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 14 @@ -65,7 +65,7 @@ raid_gen1_sse2 - 267673 + 267886 raid_gen2_avx2 @@ -73,23 +73,23 @@ raid_gen2_sse2 - 267701 + 267838 raid_gen3_ssse3 - 29756 + 29742 raid_gen4_ssse3 - 32723 + 32754 raid_gen5_ssse3 - 50169 + 50284 raid_gen6_ssse3 - 559030 + 559501 raid_rec1_avx2 @@ -97,7 +97,7 @@ raid_rec1_ssse3 - 108422 + 108332 raid_rec2_avx2 @@ -105,7 +105,7 @@ raid_rec2_ssse3 - 43538 + 43504 raid_recX_avx2 @@ -113,7 +113,7 @@ raid_recX_ssse3 - 79451 + 79421
diff --git a/cov/raid/x86.c.gcov.html b/cov/raid/x86.c.gcov.html index da2e429e..b8395453 100644 --- a/cov/raid/x86.c.gcov.html +++ b/cov/raid/x86.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 267673 : void raid_gen1_sse2(int nd, size_t size, void **vv) + 36 267886 : void raid_gen1_sse2(int nd, size_t size, void **vv) 37 : { - 38 267673 : uint8_t **v = (uint8_t **)vv; + 38 267886 : uint8_t **v = (uint8_t **)vv; 39 : uint8_t *p; 40 : int d, l; 41 : size_t i; 42 : - 43 267673 : l = nd - 1; - 44 267673 : p = v[nd]; + 43 267886 : l = nd - 1; + 44 267886 : p = v[nd]; 45 : 46 : raid_sse_begin(); 47 : - 48 5827445 : for (i = 0; i < size; i += 64) { - 49 5559772 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); - 50 5559772 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); - 51 5559772 : asm volatile ("movdqa %0,%%xmm2" : : "m" (v[l][i + 32])); - 52 5559772 : asm volatile ("movdqa %0,%%xmm3" : : "m" (v[l][i + 48])); - 53 35922916 : for (d = l - 1; d >= 0; --d) { - 54 30363144 : asm volatile ("pxor %0,%%xmm0" : : "m" (v[d][i])); - 55 30363144 : asm volatile ("pxor %0,%%xmm1" : : "m" (v[d][i + 16])); - 56 30363144 : asm volatile ("pxor %0,%%xmm2" : : "m" (v[d][i + 32])); - 57 30363144 : asm volatile ("pxor %0,%%xmm3" : : "m" (v[d][i + 48])); + 48 5826986 : for (i = 0; i < size; i += 64) { + 49 5559100 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); + 50 5559100 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); + 51 5559100 : asm volatile ("movdqa %0,%%xmm2" : : "m" (v[l][i + 32])); + 52 5559100 : asm volatile ("movdqa %0,%%xmm3" : : "m" (v[l][i + 48])); + 53 35910692 : for (d = l - 1; d >= 0; --d) { + 54 30351592 : asm volatile ("pxor %0,%%xmm0" : : "m" (v[d][i])); + 55 30351592 : asm volatile ("pxor %0,%%xmm1" : : "m" (v[d][i + 16])); + 56 30351592 : asm volatile ("pxor %0,%%xmm2" : : "m" (v[d][i + 32])); + 57 30351592 : asm volatile ("pxor %0,%%xmm3" : : "m" (v[d][i + 48])); 58 : } - 59 5559772 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 60 5559772 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); - 61 5559772 : asm volatile ("movntdq %%xmm2,%0" : "=m" (p[i + 32])); - 62 5559772 : asm volatile ("movntdq %%xmm3,%0" : "=m" (p[i + 48])); + 59 5559100 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 60 5559100 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); + 61 5559100 : asm volatile ("movntdq %%xmm2,%0" : "=m" (p[i + 32])); + 62 5559100 : asm volatile ("movntdq %%xmm3,%0" : "=m" (p[i + 48])); 63 : } 64 : 65 : raid_sse_end(); - 66 267673 : } + 66 267886 : } 67 : #endif 68 : 69 : #if defined(CONFIG_X86) && defined(CONFIG_AVX2) @@ -183,54 +183,54 @@ 121 : /* 122 : * GEN2 (RAID6 with powers of 2) SSE2 implementation 123 : */ - 124 267701 : void raid_gen2_sse2(int nd, size_t size, void **vv) + 124 267838 : void raid_gen2_sse2(int nd, size_t size, void **vv) 125 : { - 126 267701 : uint8_t **v = (uint8_t **)vv; + 126 267838 : uint8_t **v = (uint8_t **)vv; 127 : uint8_t *p; 128 : uint8_t *q; 129 : int d, l; 130 : size_t i; 131 : - 132 267701 : l = nd - 1; - 133 267701 : p = v[nd]; - 134 267701 : q = v[nd + 1]; + 132 267838 : l = nd - 1; + 133 267838 : p = v[nd]; + 134 267838 : q = v[nd + 1]; 135 : 136 : raid_sse_begin(); 137 : - 138 267701 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 138 267838 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 139 : - 140 10816941 : for (i = 0; i < size; i += 32) { - 141 10549240 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); - 142 10549240 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); - 143 10549240 : asm volatile ("movdqa %xmm0,%xmm2"); - 144 10549240 : asm volatile ("movdqa %xmm1,%xmm3"); - 145 67277128 : for (d = l - 1; d >= 0; --d) { - 146 56727888 : asm volatile ("pxor %xmm4,%xmm4"); - 147 56727888 : asm volatile ("pxor %xmm5,%xmm5"); - 148 56727888 : asm volatile ("pcmpgtb %xmm2,%xmm4"); - 149 56727888 : asm volatile ("pcmpgtb %xmm3,%xmm5"); - 150 56727888 : asm volatile ("paddb %xmm2,%xmm2"); - 151 56727888 : asm volatile ("paddb %xmm3,%xmm3"); - 152 56727888 : asm volatile ("pand %xmm7,%xmm4"); - 153 56727888 : asm volatile ("pand %xmm7,%xmm5"); - 154 56727888 : asm volatile ("pxor %xmm4,%xmm2"); - 155 56727888 : asm volatile ("pxor %xmm5,%xmm3"); + 140 10821462 : for (i = 0; i < size; i += 32) { + 141 10553624 : asm volatile ("movdqa %0,%%xmm0" : : "m" (v[l][i])); + 142 10553624 : asm volatile ("movdqa %0,%%xmm1" : : "m" (v[l][i + 16])); + 143 10553624 : asm volatile ("movdqa %xmm0,%xmm2"); + 144 10553624 : asm volatile ("movdqa %xmm1,%xmm3"); + 145 67303432 : for (d = l - 1; d >= 0; --d) { + 146 56749808 : asm volatile ("pxor %xmm4,%xmm4"); + 147 56749808 : asm volatile ("pxor %xmm5,%xmm5"); + 148 56749808 : asm volatile ("pcmpgtb %xmm2,%xmm4"); + 149 56749808 : asm volatile ("pcmpgtb %xmm3,%xmm5"); + 150 56749808 : asm volatile ("paddb %xmm2,%xmm2"); + 151 56749808 : asm volatile ("paddb %xmm3,%xmm3"); + 152 56749808 : asm volatile ("pand %xmm7,%xmm4"); + 153 56749808 : asm volatile ("pand %xmm7,%xmm5"); + 154 56749808 : asm volatile ("pxor %xmm4,%xmm2"); + 155 56749808 : asm volatile ("pxor %xmm5,%xmm3"); 156 : - 157 56727888 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); - 158 56727888 : asm volatile ("movdqa %0,%%xmm5" : : "m" (v[d][i + 16])); - 159 56727888 : asm volatile ("pxor %xmm4,%xmm0"); - 160 56727888 : asm volatile ("pxor %xmm5,%xmm1"); - 161 56727888 : asm volatile ("pxor %xmm4,%xmm2"); - 162 56727888 : asm volatile ("pxor %xmm5,%xmm3"); + 157 56749808 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 158 56749808 : asm volatile ("movdqa %0,%%xmm5" : : "m" (v[d][i + 16])); + 159 56749808 : asm volatile ("pxor %xmm4,%xmm0"); + 160 56749808 : asm volatile ("pxor %xmm5,%xmm1"); + 161 56749808 : asm volatile ("pxor %xmm4,%xmm2"); + 162 56749808 : asm volatile ("pxor %xmm5,%xmm3"); 163 : } - 164 10549240 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 165 10549240 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); - 166 10549240 : asm volatile ("movntdq %%xmm2,%0" : "=m" (q[i])); - 167 10549240 : asm volatile ("movntdq %%xmm3,%0" : "=m" (q[i + 16])); + 164 10553624 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 165 10553624 : asm volatile ("movntdq %%xmm1,%0" : "=m" (p[i + 16])); + 166 10553624 : asm volatile ("movntdq %%xmm2,%0" : "=m" (q[i])); + 167 10553624 : asm volatile ("movntdq %%xmm3,%0" : "=m" (q[i + 16])); 168 : } 169 : 170 : raid_sse_end(); - 171 267701 : } + 171 267838 : } 172 : #endif 173 : 174 : #if defined(CONFIG_X86) && defined(CONFIG_AVX2) @@ -370,93 +370,93 @@ 308 : /* 309 : * GEN3 (triple parity with Cauchy matrix) SSSE3 implementation 310 : */ - 311 29756 : void raid_gen3_ssse3(int nd, size_t size, void **vv) + 311 29742 : void raid_gen3_ssse3(int nd, size_t size, void **vv) 312 : { - 313 29756 : uint8_t **v = (uint8_t **)vv; + 313 29742 : uint8_t **v = (uint8_t **)vv; 314 : uint8_t *p; 315 : uint8_t *q; 316 : uint8_t *r; 317 : int d, l; 318 : size_t i; 319 : - 320 29756 : l = nd - 1; - 321 29756 : p = v[nd]; - 322 29756 : q = v[nd + 1]; - 323 29756 : r = v[nd + 2]; + 320 29742 : l = nd - 1; + 321 29742 : p = v[nd]; + 322 29742 : q = v[nd + 1]; + 323 29742 : r = v[nd + 2]; 324 : 325 : /* special case with only one data disk */ - 326 29756 : if (l == 0) { + 326 29742 : if (l == 0) { 327 4 : for (i = 0; i < 3; ++i) 328 3 : memcpy(v[1 + i], v[0], size); - 329 29757 : return; + 329 29743 : return; 330 : } 331 : 332 : raid_sse_begin(); 333 : 334 : /* generic case with at least two data disks */ - 335 29755 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0])); - 336 29755 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 335 29741 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0])); + 336 29741 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 337 : - 338 4935371 : for (i = 0; i < size; i += 16) { + 338 4934461 : for (i = 0; i < size; i += 16) { 339 : /* last disk without the by two multiplication */ - 340 4905616 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 340 4904720 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 341 : - 342 4905616 : asm volatile ("movdqa %xmm4,%xmm0"); - 343 4905616 : asm volatile ("movdqa %xmm4,%xmm1"); + 342 4904720 : asm volatile ("movdqa %xmm4,%xmm0"); + 343 4904720 : asm volatile ("movdqa %xmm4,%xmm1"); 344 : - 345 4905616 : asm volatile ("movdqa %xmm4,%xmm5"); - 346 4905616 : asm volatile ("psrlw $4,%xmm5"); - 347 4905616 : asm volatile ("pand %xmm7,%xmm4"); - 348 4905616 : asm volatile ("pand %xmm7,%xmm5"); + 345 4904720 : asm volatile ("movdqa %xmm4,%xmm5"); + 346 4904720 : asm volatile ("psrlw $4,%xmm5"); + 347 4904720 : asm volatile ("pand %xmm7,%xmm4"); + 348 4904720 : asm volatile ("pand %xmm7,%xmm5"); 349 : - 350 4905616 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); - 351 4905616 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[l][0][1][0])); - 352 4905616 : asm volatile ("pshufb %xmm4,%xmm2"); - 353 4905616 : asm volatile ("pshufb %xmm5,%xmm6"); - 354 4905616 : asm volatile ("pxor %xmm6,%xmm2"); + 350 4904720 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); + 351 4904720 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[l][0][1][0])); + 352 4904720 : asm volatile ("pshufb %xmm4,%xmm2"); + 353 4904720 : asm volatile ("pshufb %xmm5,%xmm6"); + 354 4904720 : asm volatile ("pxor %xmm6,%xmm2"); 355 : 356 : /* intermediate disks */ - 357 30786544 : for (d = l - 1; d > 0; --d) { - 358 25880928 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 357 30782064 : for (d = l - 1; d > 0; --d) { + 358 25877344 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); 359 : - 360 25880928 : asm volatile ("pxor %xmm5,%xmm5"); - 361 25880928 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 362 25880928 : asm volatile ("paddb %xmm1,%xmm1"); - 363 25880928 : asm volatile ("pand %xmm3,%xmm5"); - 364 25880928 : asm volatile ("pxor %xmm5,%xmm1"); + 360 25877344 : asm volatile ("pxor %xmm5,%xmm5"); + 361 25877344 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 362 25877344 : asm volatile ("paddb %xmm1,%xmm1"); + 363 25877344 : asm volatile ("pand %xmm3,%xmm5"); + 364 25877344 : asm volatile ("pxor %xmm5,%xmm1"); 365 : - 366 25880928 : asm volatile ("pxor %xmm4,%xmm0"); - 367 25880928 : asm volatile ("pxor %xmm4,%xmm1"); + 366 25877344 : asm volatile ("pxor %xmm4,%xmm0"); + 367 25877344 : asm volatile ("pxor %xmm4,%xmm1"); 368 : - 369 25880928 : asm volatile ("movdqa %xmm4,%xmm5"); - 370 25880928 : asm volatile ("psrlw $4,%xmm5"); - 371 25880928 : asm volatile ("pand %xmm7,%xmm4"); - 372 25880928 : asm volatile ("pand %xmm7,%xmm5"); + 369 25877344 : asm volatile ("movdqa %xmm4,%xmm5"); + 370 25877344 : asm volatile ("psrlw $4,%xmm5"); + 371 25877344 : asm volatile ("pand %xmm7,%xmm4"); + 372 25877344 : asm volatile ("pand %xmm7,%xmm5"); 373 : - 374 25880928 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 375 25880928 : asm volatile ("pshufb %xmm4,%xmm6"); - 376 25880928 : asm volatile ("pxor %xmm6,%xmm2"); - 377 25880928 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][1][0])); - 378 25880928 : asm volatile ("pshufb %xmm5,%xmm6"); - 379 25880928 : asm volatile ("pxor %xmm6,%xmm2"); + 374 25877344 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 375 25877344 : asm volatile ("pshufb %xmm4,%xmm6"); + 376 25877344 : asm volatile ("pxor %xmm6,%xmm2"); + 377 25877344 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][1][0])); + 378 25877344 : asm volatile ("pshufb %xmm5,%xmm6"); + 379 25877344 : asm volatile ("pxor %xmm6,%xmm2"); 380 : } 381 : 382 : /* first disk with all coefficients at 1 */ - 383 4905616 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 383 4904720 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); 384 : - 385 4905616 : asm volatile ("pxor %xmm5,%xmm5"); - 386 4905616 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 387 4905616 : asm volatile ("paddb %xmm1,%xmm1"); - 388 4905616 : asm volatile ("pand %xmm3,%xmm5"); - 389 4905616 : asm volatile ("pxor %xmm5,%xmm1"); + 385 4904720 : asm volatile ("pxor %xmm5,%xmm5"); + 386 4904720 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 387 4904720 : asm volatile ("paddb %xmm1,%xmm1"); + 388 4904720 : asm volatile ("pand %xmm3,%xmm5"); + 389 4904720 : asm volatile ("pxor %xmm5,%xmm1"); 390 : - 391 4905616 : asm volatile ("pxor %xmm4,%xmm0"); - 392 4905616 : asm volatile ("pxor %xmm4,%xmm1"); - 393 4905616 : asm volatile ("pxor %xmm4,%xmm2"); + 391 4904720 : asm volatile ("pxor %xmm4,%xmm0"); + 392 4904720 : asm volatile ("pxor %xmm4,%xmm1"); + 393 4904720 : asm volatile ("pxor %xmm4,%xmm2"); 394 : - 395 4905616 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 396 4905616 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); - 397 4905616 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); + 395 4904720 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 396 4904720 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); + 397 4904720 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); 398 : } 399 : 400 : raid_sse_end(); @@ -741,9 +741,9 @@ 679 : /* 680 : * GEN4 (quad parity with Cauchy matrix) SSSE3 implementation 681 : */ - 682 32723 : void raid_gen4_ssse3(int nd, size_t size, void **vv) + 682 32754 : void raid_gen4_ssse3(int nd, size_t size, void **vv) 683 : { - 684 32723 : uint8_t **v = (uint8_t **)vv; + 684 32754 : 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 32723 : l = nd - 1; - 693 32723 : p = v[nd]; - 694 32723 : q = v[nd + 1]; - 695 32723 : r = v[nd + 2]; - 696 32723 : s = v[nd + 3]; + 692 32754 : l = nd - 1; + 693 32754 : p = v[nd]; + 694 32754 : q = v[nd + 1]; + 695 32754 : r = v[nd + 2]; + 696 32754 : s = v[nd + 3]; 697 : 698 : /* special case with only one data disk */ - 699 32723 : if (l == 0) { + 699 32754 : if (l == 0) { 700 5 : for (i = 0; i < 4; ++i) 701 4 : memcpy(v[1 + i], v[0], size); - 702 32724 : return; + 702 32755 : return; 703 : } 704 : 705 : raid_sse_begin(); 706 : 707 : /* generic case with at least two data disks */ - 708 3383954 : for (i = 0; i < size; i += 16) { + 708 3385969 : for (i = 0; i < size; i += 16) { 709 : /* last disk without the by two multiplication */ - 710 3351232 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 711 3351232 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 710 3353216 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 711 3353216 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 712 : - 713 3351232 : asm volatile ("movdqa %xmm4,%xmm0"); - 714 3351232 : asm volatile ("movdqa %xmm4,%xmm1"); + 713 3353216 : asm volatile ("movdqa %xmm4,%xmm0"); + 714 3353216 : asm volatile ("movdqa %xmm4,%xmm1"); 715 : - 716 3351232 : asm volatile ("movdqa %xmm4,%xmm5"); - 717 3351232 : asm volatile ("psrlw $4,%xmm5"); - 718 3351232 : asm volatile ("pand %xmm7,%xmm4"); - 719 3351232 : asm volatile ("pand %xmm7,%xmm5"); + 716 3353216 : asm volatile ("movdqa %xmm4,%xmm5"); + 717 3353216 : asm volatile ("psrlw $4,%xmm5"); + 718 3353216 : asm volatile ("pand %xmm7,%xmm4"); + 719 3353216 : asm volatile ("pand %xmm7,%xmm5"); 720 : - 721 3351232 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); - 722 3351232 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 723 3351232 : asm volatile ("pshufb %xmm4,%xmm2"); - 724 3351232 : asm volatile ("pshufb %xmm5,%xmm7"); - 725 3351232 : asm volatile ("pxor %xmm7,%xmm2"); + 721 3353216 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][0][0][0])); + 722 3353216 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 723 3353216 : asm volatile ("pshufb %xmm4,%xmm2"); + 724 3353216 : asm volatile ("pshufb %xmm5,%xmm7"); + 725 3353216 : asm volatile ("pxor %xmm7,%xmm2"); 726 : - 727 3351232 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][1][0][0])); - 728 3351232 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 729 3351232 : asm volatile ("pshufb %xmm4,%xmm3"); - 730 3351232 : asm volatile ("pshufb %xmm5,%xmm7"); - 731 3351232 : asm volatile ("pxor %xmm7,%xmm3"); + 727 3353216 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][1][0][0])); + 728 3353216 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 729 3353216 : asm volatile ("pshufb %xmm4,%xmm3"); + 730 3353216 : asm volatile ("pshufb %xmm5,%xmm7"); + 731 3353216 : asm volatile ("pxor %xmm7,%xmm3"); 732 : 733 : /* intermediate disks */ - 734 20081408 : for (d = l - 1; d > 0; --d) { - 735 16730176 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); - 736 16730176 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 734 20091328 : for (d = l - 1; d > 0; --d) { + 735 16738112 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 736 16738112 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); 737 : - 738 16730176 : asm volatile ("pxor %xmm5,%xmm5"); - 739 16730176 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 740 16730176 : asm volatile ("paddb %xmm1,%xmm1"); - 741 16730176 : asm volatile ("pand %xmm7,%xmm5"); - 742 16730176 : asm volatile ("pxor %xmm5,%xmm1"); + 738 16738112 : asm volatile ("pxor %xmm5,%xmm5"); + 739 16738112 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 740 16738112 : asm volatile ("paddb %xmm1,%xmm1"); + 741 16738112 : asm volatile ("pand %xmm7,%xmm5"); + 742 16738112 : asm volatile ("pxor %xmm5,%xmm1"); 743 : - 744 16730176 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 744 16738112 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 745 : - 746 16730176 : asm volatile ("pxor %xmm4,%xmm0"); - 747 16730176 : asm volatile ("pxor %xmm4,%xmm1"); + 746 16738112 : asm volatile ("pxor %xmm4,%xmm0"); + 747 16738112 : asm volatile ("pxor %xmm4,%xmm1"); 748 : - 749 16730176 : asm volatile ("movdqa %xmm4,%xmm5"); - 750 16730176 : asm volatile ("psrlw $4,%xmm5"); - 751 16730176 : asm volatile ("pand %xmm7,%xmm4"); - 752 16730176 : asm volatile ("pand %xmm7,%xmm5"); + 749 16738112 : asm volatile ("movdqa %xmm4,%xmm5"); + 750 16738112 : asm volatile ("psrlw $4,%xmm5"); + 751 16738112 : asm volatile ("pand %xmm7,%xmm4"); + 752 16738112 : asm volatile ("pand %xmm7,%xmm5"); 753 : - 754 16730176 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 755 16730176 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 756 16730176 : asm volatile ("pshufb %xmm4,%xmm6"); - 757 16730176 : asm volatile ("pshufb %xmm5,%xmm7"); - 758 16730176 : asm volatile ("pxor %xmm6,%xmm2"); - 759 16730176 : asm volatile ("pxor %xmm7,%xmm2"); + 754 16738112 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 755 16738112 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 756 16738112 : asm volatile ("pshufb %xmm4,%xmm6"); + 757 16738112 : asm volatile ("pshufb %xmm5,%xmm7"); + 758 16738112 : asm volatile ("pxor %xmm6,%xmm2"); + 759 16738112 : asm volatile ("pxor %xmm7,%xmm2"); 760 : - 761 16730176 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 762 16730176 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 763 16730176 : asm volatile ("pshufb %xmm4,%xmm6"); - 764 16730176 : asm volatile ("pshufb %xmm5,%xmm7"); - 765 16730176 : asm volatile ("pxor %xmm6,%xmm3"); - 766 16730176 : asm volatile ("pxor %xmm7,%xmm3"); + 761 16738112 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 762 16738112 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 763 16738112 : asm volatile ("pshufb %xmm4,%xmm6"); + 764 16738112 : asm volatile ("pshufb %xmm5,%xmm7"); + 765 16738112 : asm volatile ("pxor %xmm6,%xmm3"); + 766 16738112 : asm volatile ("pxor %xmm7,%xmm3"); 767 : } 768 : 769 : /* first disk with all coefficients at 1 */ - 770 3351232 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); - 771 3351232 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 770 3353216 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 771 3353216 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); 772 : - 773 3351232 : asm volatile ("pxor %xmm5,%xmm5"); - 774 3351232 : asm volatile ("pcmpgtb %xmm1,%xmm5"); - 775 3351232 : asm volatile ("paddb %xmm1,%xmm1"); - 776 3351232 : asm volatile ("pand %xmm7,%xmm5"); - 777 3351232 : asm volatile ("pxor %xmm5,%xmm1"); + 773 3353216 : asm volatile ("pxor %xmm5,%xmm5"); + 774 3353216 : asm volatile ("pcmpgtb %xmm1,%xmm5"); + 775 3353216 : asm volatile ("paddb %xmm1,%xmm1"); + 776 3353216 : asm volatile ("pand %xmm7,%xmm5"); + 777 3353216 : asm volatile ("pxor %xmm5,%xmm1"); 778 : - 779 3351232 : asm volatile ("pxor %xmm4,%xmm0"); - 780 3351232 : asm volatile ("pxor %xmm4,%xmm1"); - 781 3351232 : asm volatile ("pxor %xmm4,%xmm2"); - 782 3351232 : asm volatile ("pxor %xmm4,%xmm3"); + 779 3353216 : asm volatile ("pxor %xmm4,%xmm0"); + 780 3353216 : asm volatile ("pxor %xmm4,%xmm1"); + 781 3353216 : asm volatile ("pxor %xmm4,%xmm2"); + 782 3353216 : asm volatile ("pxor %xmm4,%xmm3"); 783 : - 784 3351232 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); - 785 3351232 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); - 786 3351232 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); - 787 3351232 : asm volatile ("movntdq %%xmm3,%0" : "=m" (s[i])); + 784 3353216 : asm volatile ("movntdq %%xmm0,%0" : "=m" (p[i])); + 785 3353216 : asm volatile ("movntdq %%xmm1,%0" : "=m" (q[i])); + 786 3353216 : asm volatile ("movntdq %%xmm2,%0" : "=m" (r[i])); + 787 3353216 : 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 50169 : void raid_gen5_ssse3(int nd, size_t size, void **vv) + 1132 50284 : void raid_gen5_ssse3(int nd, size_t size, void **vv) 1133 : { - 1134 50169 : uint8_t **v = (uint8_t **)vv; + 1134 50284 : 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 50169 : uint8_t *pd = __align_ptr(buffer, 16); + 1143 50284 : uint8_t *pd = __align_ptr(buffer, 16); 1144 : - 1145 50169 : l = nd - 1; - 1146 50169 : p = v[nd]; - 1147 50169 : q = v[nd + 1]; - 1148 50169 : r = v[nd + 2]; - 1149 50169 : s = v[nd + 3]; - 1150 50169 : t = v[nd + 4]; + 1145 50284 : l = nd - 1; + 1146 50284 : p = v[nd]; + 1147 50284 : q = v[nd + 1]; + 1148 50284 : r = v[nd + 2]; + 1149 50284 : s = v[nd + 3]; + 1150 50284 : t = v[nd + 4]; 1151 : 1152 : /* special case with only one data disk */ - 1153 50169 : if (l == 0) { + 1153 50284 : if (l == 0) { 1154 6 : for (i = 0; i < 5; ++i) 1155 5 : memcpy(v[1 + i], v[0], size); - 1156 50170 : return; + 1156 50285 : return; 1157 : } 1158 : 1159 : raid_sse_begin(); 1160 : 1161 : /* generic case with at least two data disks */ - 1162 3938632 : for (i = 0; i < size; i += 16) { + 1162 3946107 : for (i = 0; i < size; i += 16) { 1163 : /* last disk without the by two multiplication */ - 1164 3888464 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 1164 3895824 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 1165 : - 1166 3888464 : asm volatile ("movdqa %xmm4,%xmm0"); - 1167 3888464 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); + 1166 3895824 : asm volatile ("movdqa %xmm4,%xmm0"); + 1167 3895824 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); 1168 : - 1169 3888464 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1170 3888464 : asm volatile ("movdqa %xmm4,%xmm5"); - 1171 3888464 : asm volatile ("psrlw $4,%xmm5"); - 1172 3888464 : asm volatile ("pand %xmm7,%xmm4"); - 1173 3888464 : asm volatile ("pand %xmm7,%xmm5"); + 1169 3895824 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1170 3895824 : asm volatile ("movdqa %xmm4,%xmm5"); + 1171 3895824 : asm volatile ("psrlw $4,%xmm5"); + 1172 3895824 : asm volatile ("pand %xmm7,%xmm4"); + 1173 3895824 : asm volatile ("pand %xmm7,%xmm5"); 1174 : - 1175 3888464 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][0][0][0])); - 1176 3888464 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 1177 3888464 : asm volatile ("pshufb %xmm4,%xmm1"); - 1178 3888464 : asm volatile ("pshufb %xmm5,%xmm7"); - 1179 3888464 : asm volatile ("pxor %xmm7,%xmm1"); + 1175 3895824 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][0][0][0])); + 1176 3895824 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 1177 3895824 : asm volatile ("pshufb %xmm4,%xmm1"); + 1178 3895824 : asm volatile ("pshufb %xmm5,%xmm7"); + 1179 3895824 : asm volatile ("pxor %xmm7,%xmm1"); 1180 : - 1181 3888464 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][1][0][0])); - 1182 3888464 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 1183 3888464 : asm volatile ("pshufb %xmm4,%xmm2"); - 1184 3888464 : asm volatile ("pshufb %xmm5,%xmm7"); - 1185 3888464 : asm volatile ("pxor %xmm7,%xmm2"); + 1181 3895824 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][1][0][0])); + 1182 3895824 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 1183 3895824 : asm volatile ("pshufb %xmm4,%xmm2"); + 1184 3895824 : asm volatile ("pshufb %xmm5,%xmm7"); + 1185 3895824 : asm volatile ("pxor %xmm7,%xmm2"); 1186 : - 1187 3888464 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][2][0][0])); - 1188 3888464 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); - 1189 3888464 : asm volatile ("pshufb %xmm4,%xmm3"); - 1190 3888464 : asm volatile ("pshufb %xmm5,%xmm7"); - 1191 3888464 : asm volatile ("pxor %xmm7,%xmm3"); + 1187 3895824 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][2][0][0])); + 1188 3895824 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); + 1189 3895824 : asm volatile ("pshufb %xmm4,%xmm3"); + 1190 3895824 : asm volatile ("pshufb %xmm5,%xmm7"); + 1191 3895824 : asm volatile ("pxor %xmm7,%xmm3"); 1192 : 1193 : /* intermediate disks */ - 1194 23337520 : for (d = l - 1; d > 0; --d) { - 1195 19449056 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); - 1196 19449056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); - 1197 19449056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1194 23374320 : for (d = l - 1; d > 0; --d) { + 1195 19478496 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 1196 19478496 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); + 1197 19478496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1198 : - 1199 19449056 : asm volatile ("pxor %xmm5,%xmm5"); - 1200 19449056 : asm volatile ("pcmpgtb %xmm0,%xmm5"); - 1201 19449056 : asm volatile ("paddb %xmm0,%xmm0"); - 1202 19449056 : asm volatile ("pand %xmm7,%xmm5"); - 1203 19449056 : asm volatile ("pxor %xmm5,%xmm0"); + 1199 19478496 : asm volatile ("pxor %xmm5,%xmm5"); + 1200 19478496 : asm volatile ("pcmpgtb %xmm0,%xmm5"); + 1201 19478496 : asm volatile ("paddb %xmm0,%xmm0"); + 1202 19478496 : asm volatile ("pand %xmm7,%xmm5"); + 1203 19478496 : asm volatile ("pxor %xmm5,%xmm0"); 1204 : - 1205 19449056 : asm volatile ("pxor %xmm4,%xmm0"); - 1206 19449056 : asm volatile ("pxor %xmm4,%xmm6"); - 1207 19449056 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[0])); + 1205 19478496 : asm volatile ("pxor %xmm4,%xmm0"); + 1206 19478496 : asm volatile ("pxor %xmm4,%xmm6"); + 1207 19478496 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[0])); 1208 : - 1209 19449056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1210 19449056 : asm volatile ("movdqa %xmm4,%xmm5"); - 1211 19449056 : asm volatile ("psrlw $4,%xmm5"); - 1212 19449056 : asm volatile ("pand %xmm7,%xmm4"); - 1213 19449056 : asm volatile ("pand %xmm7,%xmm5"); + 1209 19478496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1210 19478496 : asm volatile ("movdqa %xmm4,%xmm5"); + 1211 19478496 : asm volatile ("psrlw $4,%xmm5"); + 1212 19478496 : asm volatile ("pand %xmm7,%xmm4"); + 1213 19478496 : asm volatile ("pand %xmm7,%xmm5"); 1214 : - 1215 19449056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 1216 19449056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 1217 19449056 : asm volatile ("pshufb %xmm4,%xmm6"); - 1218 19449056 : asm volatile ("pshufb %xmm5,%xmm7"); - 1219 19449056 : asm volatile ("pxor %xmm6,%xmm1"); - 1220 19449056 : asm volatile ("pxor %xmm7,%xmm1"); + 1215 19478496 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 1216 19478496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 1217 19478496 : asm volatile ("pshufb %xmm4,%xmm6"); + 1218 19478496 : asm volatile ("pshufb %xmm5,%xmm7"); + 1219 19478496 : asm volatile ("pxor %xmm6,%xmm1"); + 1220 19478496 : asm volatile ("pxor %xmm7,%xmm1"); 1221 : - 1222 19449056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 1223 19449056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 1224 19449056 : asm volatile ("pshufb %xmm4,%xmm6"); - 1225 19449056 : asm volatile ("pshufb %xmm5,%xmm7"); - 1226 19449056 : asm volatile ("pxor %xmm6,%xmm2"); - 1227 19449056 : asm volatile ("pxor %xmm7,%xmm2"); + 1222 19478496 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 1223 19478496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 1224 19478496 : asm volatile ("pshufb %xmm4,%xmm6"); + 1225 19478496 : asm volatile ("pshufb %xmm5,%xmm7"); + 1226 19478496 : asm volatile ("pxor %xmm6,%xmm2"); + 1227 19478496 : asm volatile ("pxor %xmm7,%xmm2"); 1228 : - 1229 19449056 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); - 1230 19449056 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); - 1231 19449056 : asm volatile ("pshufb %xmm4,%xmm6"); - 1232 19449056 : asm volatile ("pshufb %xmm5,%xmm7"); - 1233 19449056 : asm volatile ("pxor %xmm6,%xmm3"); - 1234 19449056 : asm volatile ("pxor %xmm7,%xmm3"); + 1229 19478496 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); + 1230 19478496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); + 1231 19478496 : asm volatile ("pshufb %xmm4,%xmm6"); + 1232 19478496 : asm volatile ("pshufb %xmm5,%xmm7"); + 1233 19478496 : asm volatile ("pxor %xmm6,%xmm3"); + 1234 19478496 : asm volatile ("pxor %xmm7,%xmm3"); 1235 : } 1236 : 1237 : /* first disk with all coefficients at 1 */ - 1238 3888464 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); - 1239 3888464 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); - 1240 3888464 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1238 3895824 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 1239 3895824 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[0])); + 1240 3895824 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1241 : - 1242 3888464 : asm volatile ("pxor %xmm5,%xmm5"); - 1243 3888464 : asm volatile ("pcmpgtb %xmm0,%xmm5"); - 1244 3888464 : asm volatile ("paddb %xmm0,%xmm0"); - 1245 3888464 : asm volatile ("pand %xmm7,%xmm5"); - 1246 3888464 : asm volatile ("pxor %xmm5,%xmm0"); + 1242 3895824 : asm volatile ("pxor %xmm5,%xmm5"); + 1243 3895824 : asm volatile ("pcmpgtb %xmm0,%xmm5"); + 1244 3895824 : asm volatile ("paddb %xmm0,%xmm0"); + 1245 3895824 : asm volatile ("pand %xmm7,%xmm5"); + 1246 3895824 : asm volatile ("pxor %xmm5,%xmm0"); 1247 : - 1248 3888464 : asm volatile ("pxor %xmm4,%xmm0"); - 1249 3888464 : asm volatile ("pxor %xmm4,%xmm1"); - 1250 3888464 : asm volatile ("pxor %xmm4,%xmm2"); - 1251 3888464 : asm volatile ("pxor %xmm4,%xmm3"); - 1252 3888464 : asm volatile ("pxor %xmm4,%xmm6"); + 1248 3895824 : asm volatile ("pxor %xmm4,%xmm0"); + 1249 3895824 : asm volatile ("pxor %xmm4,%xmm1"); + 1250 3895824 : asm volatile ("pxor %xmm4,%xmm2"); + 1251 3895824 : asm volatile ("pxor %xmm4,%xmm3"); + 1252 3895824 : asm volatile ("pxor %xmm4,%xmm6"); 1253 : - 1254 3888464 : asm volatile ("movntdq %%xmm6,%0" : "=m" (p[i])); - 1255 3888464 : asm volatile ("movntdq %%xmm0,%0" : "=m" (q[i])); - 1256 3888464 : asm volatile ("movntdq %%xmm1,%0" : "=m" (r[i])); - 1257 3888464 : asm volatile ("movntdq %%xmm2,%0" : "=m" (s[i])); - 1258 3888464 : asm volatile ("movntdq %%xmm3,%0" : "=m" (t[i])); + 1254 3895824 : asm volatile ("movntdq %%xmm6,%0" : "=m" (p[i])); + 1255 3895824 : asm volatile ("movntdq %%xmm0,%0" : "=m" (q[i])); + 1256 3895824 : asm volatile ("movntdq %%xmm1,%0" : "=m" (r[i])); + 1257 3895824 : asm volatile ("movntdq %%xmm2,%0" : "=m" (s[i])); + 1258 3895824 : 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 559030 : void raid_gen6_ssse3(int nd, size_t size, void **vv) + 1532 559501 : void raid_gen6_ssse3(int nd, size_t size, void **vv) 1533 : { - 1534 559030 : uint8_t **v = (uint8_t **)vv; + 1534 559501 : 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 559030 : uint8_t *pd = __align_ptr(buffer, 16); + 1544 559501 : uint8_t *pd = __align_ptr(buffer, 16); 1545 : - 1546 559030 : l = nd - 1; - 1547 559030 : p = v[nd]; - 1548 559030 : q = v[nd + 1]; - 1549 559030 : r = v[nd + 2]; - 1550 559030 : s = v[nd + 3]; - 1551 559030 : t = v[nd + 4]; - 1552 559030 : u = v[nd + 5]; + 1546 559501 : l = nd - 1; + 1547 559501 : p = v[nd]; + 1548 559501 : q = v[nd + 1]; + 1549 559501 : r = v[nd + 2]; + 1550 559501 : s = v[nd + 3]; + 1551 559501 : t = v[nd + 4]; + 1552 559501 : u = v[nd + 5]; 1553 : 1554 : /* special case with only one data disk */ - 1555 559030 : if (l == 0) { + 1555 559501 : if (l == 0) { 1556 7 : for (i = 0; i < 6; ++i) 1557 6 : memcpy(v[1 + i], v[0], size); - 1558 559031 : return; + 1558 559502 : return; 1559 : } 1560 : 1561 : raid_sse_begin(); 1562 : 1563 : /* generic case with at least two data disks */ - 1564 35763525 : for (i = 0; i < size; i += 16) { + 1564 35794140 : for (i = 0; i < size; i += 16) { 1565 : /* last disk without the by two multiplication */ - 1566 35204496 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); + 1566 35234640 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[l][i])); 1567 : - 1568 35204496 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); - 1569 35204496 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[16])); + 1568 35234640 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[0])); + 1569 35234640 : asm volatile ("movdqa %%xmm4,%0" : "=m" (pd[16])); 1570 : - 1571 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1572 35204496 : asm volatile ("movdqa %xmm4,%xmm5"); - 1573 35204496 : asm volatile ("psrlw $4,%xmm5"); - 1574 35204496 : asm volatile ("pand %xmm7,%xmm4"); - 1575 35204496 : asm volatile ("pand %xmm7,%xmm5"); + 1571 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1572 35234640 : asm volatile ("movdqa %xmm4,%xmm5"); + 1573 35234640 : asm volatile ("psrlw $4,%xmm5"); + 1574 35234640 : asm volatile ("pand %xmm7,%xmm4"); + 1575 35234640 : asm volatile ("pand %xmm7,%xmm5"); 1576 : - 1577 35204496 : asm volatile ("movdqa %0,%%xmm0" : : "m" (gfgenpshufb[l][0][0][0])); - 1578 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); - 1579 35204496 : asm volatile ("pshufb %xmm4,%xmm0"); - 1580 35204496 : asm volatile ("pshufb %xmm5,%xmm7"); - 1581 35204496 : asm volatile ("pxor %xmm7,%xmm0"); + 1577 35234640 : asm volatile ("movdqa %0,%%xmm0" : : "m" (gfgenpshufb[l][0][0][0])); + 1578 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][0][1][0])); + 1579 35234640 : asm volatile ("pshufb %xmm4,%xmm0"); + 1580 35234640 : asm volatile ("pshufb %xmm5,%xmm7"); + 1581 35234640 : asm volatile ("pxor %xmm7,%xmm0"); 1582 : - 1583 35204496 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][1][0][0])); - 1584 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); - 1585 35204496 : asm volatile ("pshufb %xmm4,%xmm1"); - 1586 35204496 : asm volatile ("pshufb %xmm5,%xmm7"); - 1587 35204496 : asm volatile ("pxor %xmm7,%xmm1"); + 1583 35234640 : asm volatile ("movdqa %0,%%xmm1" : : "m" (gfgenpshufb[l][1][0][0])); + 1584 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][1][1][0])); + 1585 35234640 : asm volatile ("pshufb %xmm4,%xmm1"); + 1586 35234640 : asm volatile ("pshufb %xmm5,%xmm7"); + 1587 35234640 : asm volatile ("pxor %xmm7,%xmm1"); 1588 : - 1589 35204496 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][2][0][0])); - 1590 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); - 1591 35204496 : asm volatile ("pshufb %xmm4,%xmm2"); - 1592 35204496 : asm volatile ("pshufb %xmm5,%xmm7"); - 1593 35204496 : asm volatile ("pxor %xmm7,%xmm2"); + 1589 35234640 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfgenpshufb[l][2][0][0])); + 1590 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][2][1][0])); + 1591 35234640 : asm volatile ("pshufb %xmm4,%xmm2"); + 1592 35234640 : asm volatile ("pshufb %xmm5,%xmm7"); + 1593 35234640 : asm volatile ("pxor %xmm7,%xmm2"); 1594 : - 1595 35204496 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][3][0][0])); - 1596 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][3][1][0])); - 1597 35204496 : asm volatile ("pshufb %xmm4,%xmm3"); - 1598 35204496 : asm volatile ("pshufb %xmm5,%xmm7"); - 1599 35204496 : asm volatile ("pxor %xmm7,%xmm3"); + 1595 35234640 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfgenpshufb[l][3][0][0])); + 1596 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[l][3][1][0])); + 1597 35234640 : asm volatile ("pshufb %xmm4,%xmm3"); + 1598 35234640 : asm volatile ("pshufb %xmm5,%xmm7"); + 1599 35234640 : asm volatile ("pxor %xmm7,%xmm3"); 1600 : 1601 : /* intermediate disks */ - 1602 182027376 : for (d = l - 1; d > 0; --d) { - 1603 146822880 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); - 1604 146822880 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); - 1605 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1602 182178096 : for (d = l - 1; d > 0; --d) { + 1603 146943456 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); + 1604 146943456 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); + 1605 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1606 : - 1607 146822880 : asm volatile ("pxor %xmm4,%xmm4"); - 1608 146822880 : asm volatile ("pcmpgtb %xmm6,%xmm4"); - 1609 146822880 : asm volatile ("paddb %xmm6,%xmm6"); - 1610 146822880 : asm volatile ("pand %xmm7,%xmm4"); - 1611 146822880 : asm volatile ("pxor %xmm4,%xmm6"); + 1607 146943456 : asm volatile ("pxor %xmm4,%xmm4"); + 1608 146943456 : asm volatile ("pcmpgtb %xmm6,%xmm4"); + 1609 146943456 : asm volatile ("paddb %xmm6,%xmm6"); + 1610 146943456 : asm volatile ("pand %xmm7,%xmm4"); + 1611 146943456 : asm volatile ("pxor %xmm4,%xmm6"); 1612 : - 1613 146822880 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); + 1613 146943456 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i])); 1614 : - 1615 146822880 : asm volatile ("pxor %xmm4,%xmm5"); - 1616 146822880 : asm volatile ("pxor %xmm4,%xmm6"); - 1617 146822880 : asm volatile ("movdqa %%xmm5,%0" : "=m" (pd[0])); - 1618 146822880 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[16])); + 1615 146943456 : asm volatile ("pxor %xmm4,%xmm5"); + 1616 146943456 : asm volatile ("pxor %xmm4,%xmm6"); + 1617 146943456 : asm volatile ("movdqa %%xmm5,%0" : "=m" (pd[0])); + 1618 146943456 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pd[16])); 1619 : - 1620 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 1621 146822880 : asm volatile ("movdqa %xmm4,%xmm5"); - 1622 146822880 : asm volatile ("psrlw $4,%xmm5"); - 1623 146822880 : asm volatile ("pand %xmm7,%xmm4"); - 1624 146822880 : asm volatile ("pand %xmm7,%xmm5"); + 1620 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 1621 146943456 : asm volatile ("movdqa %xmm4,%xmm5"); + 1622 146943456 : asm volatile ("psrlw $4,%xmm5"); + 1623 146943456 : asm volatile ("pand %xmm7,%xmm4"); + 1624 146943456 : asm volatile ("pand %xmm7,%xmm5"); 1625 : - 1626 146822880 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); - 1627 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); - 1628 146822880 : asm volatile ("pshufb %xmm4,%xmm6"); - 1629 146822880 : asm volatile ("pshufb %xmm5,%xmm7"); - 1630 146822880 : asm volatile ("pxor %xmm6,%xmm0"); - 1631 146822880 : asm volatile ("pxor %xmm7,%xmm0"); + 1626 146943456 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][0][0][0])); + 1627 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][0][1][0])); + 1628 146943456 : asm volatile ("pshufb %xmm4,%xmm6"); + 1629 146943456 : asm volatile ("pshufb %xmm5,%xmm7"); + 1630 146943456 : asm volatile ("pxor %xmm6,%xmm0"); + 1631 146943456 : asm volatile ("pxor %xmm7,%xmm0"); 1632 : - 1633 146822880 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); - 1634 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); - 1635 146822880 : asm volatile ("pshufb %xmm4,%xmm6"); - 1636 146822880 : asm volatile ("pshufb %xmm5,%xmm7"); - 1637 146822880 : asm volatile ("pxor %xmm6,%xmm1"); - 1638 146822880 : asm volatile ("pxor %xmm7,%xmm1"); + 1633 146943456 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][1][0][0])); + 1634 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][1][1][0])); + 1635 146943456 : asm volatile ("pshufb %xmm4,%xmm6"); + 1636 146943456 : asm volatile ("pshufb %xmm5,%xmm7"); + 1637 146943456 : asm volatile ("pxor %xmm6,%xmm1"); + 1638 146943456 : asm volatile ("pxor %xmm7,%xmm1"); 1639 : - 1640 146822880 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); - 1641 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); - 1642 146822880 : asm volatile ("pshufb %xmm4,%xmm6"); - 1643 146822880 : asm volatile ("pshufb %xmm5,%xmm7"); - 1644 146822880 : asm volatile ("pxor %xmm6,%xmm2"); - 1645 146822880 : asm volatile ("pxor %xmm7,%xmm2"); + 1640 146943456 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][2][0][0])); + 1641 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][2][1][0])); + 1642 146943456 : asm volatile ("pshufb %xmm4,%xmm6"); + 1643 146943456 : asm volatile ("pshufb %xmm5,%xmm7"); + 1644 146943456 : asm volatile ("pxor %xmm6,%xmm2"); + 1645 146943456 : asm volatile ("pxor %xmm7,%xmm2"); 1646 : - 1647 146822880 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][3][0][0])); - 1648 146822880 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][3][1][0])); - 1649 146822880 : asm volatile ("pshufb %xmm4,%xmm6"); - 1650 146822880 : asm volatile ("pshufb %xmm5,%xmm7"); - 1651 146822880 : asm volatile ("pxor %xmm6,%xmm3"); - 1652 146822880 : asm volatile ("pxor %xmm7,%xmm3"); + 1647 146943456 : asm volatile ("movdqa %0,%%xmm6" : : "m" (gfgenpshufb[d][3][0][0])); + 1648 146943456 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfgenpshufb[d][3][1][0])); + 1649 146943456 : asm volatile ("pshufb %xmm4,%xmm6"); + 1650 146943456 : asm volatile ("pshufb %xmm5,%xmm7"); + 1651 146943456 : asm volatile ("pxor %xmm6,%xmm3"); + 1652 146943456 : asm volatile ("pxor %xmm7,%xmm3"); 1653 : } 1654 : 1655 : /* first disk with all coefficients at 1 */ - 1656 35204496 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); - 1657 35204496 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); - 1658 35204496 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); + 1656 35234640 : asm volatile ("movdqa %0,%%xmm5" : : "m" (pd[0])); + 1657 35234640 : asm volatile ("movdqa %0,%%xmm6" : : "m" (pd[16])); + 1658 35234640 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0])); 1659 : - 1660 35204496 : asm volatile ("pxor %xmm4,%xmm4"); - 1661 35204496 : asm volatile ("pcmpgtb %xmm6,%xmm4"); - 1662 35204496 : asm volatile ("paddb %xmm6,%xmm6"); - 1663 35204496 : asm volatile ("pand %xmm7,%xmm4"); - 1664 35204496 : asm volatile ("pxor %xmm4,%xmm6"); + 1660 35234640 : asm volatile ("pxor %xmm4,%xmm4"); + 1661 35234640 : asm volatile ("pcmpgtb %xmm6,%xmm4"); + 1662 35234640 : asm volatile ("paddb %xmm6,%xmm6"); + 1663 35234640 : asm volatile ("pand %xmm7,%xmm4"); + 1664 35234640 : asm volatile ("pxor %xmm4,%xmm6"); 1665 : - 1666 35204496 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); - 1667 35204496 : asm volatile ("pxor %xmm4,%xmm0"); - 1668 35204496 : asm volatile ("pxor %xmm4,%xmm1"); - 1669 35204496 : asm volatile ("pxor %xmm4,%xmm2"); - 1670 35204496 : asm volatile ("pxor %xmm4,%xmm3"); - 1671 35204496 : asm volatile ("pxor %xmm4,%xmm5"); - 1672 35204496 : asm volatile ("pxor %xmm4,%xmm6"); + 1666 35234640 : asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i])); + 1667 35234640 : asm volatile ("pxor %xmm4,%xmm0"); + 1668 35234640 : asm volatile ("pxor %xmm4,%xmm1"); + 1669 35234640 : asm volatile ("pxor %xmm4,%xmm2"); + 1670 35234640 : asm volatile ("pxor %xmm4,%xmm3"); + 1671 35234640 : asm volatile ("pxor %xmm4,%xmm5"); + 1672 35234640 : asm volatile ("pxor %xmm4,%xmm6"); 1673 : - 1674 35204496 : asm volatile ("movntdq %%xmm5,%0" : "=m" (p[i])); - 1675 35204496 : asm volatile ("movntdq %%xmm6,%0" : "=m" (q[i])); - 1676 35204496 : asm volatile ("movntdq %%xmm0,%0" : "=m" (r[i])); - 1677 35204496 : asm volatile ("movntdq %%xmm1,%0" : "=m" (s[i])); - 1678 35204496 : asm volatile ("movntdq %%xmm2,%0" : "=m" (t[i])); - 1679 35204496 : asm volatile ("movntdq %%xmm3,%0" : "=m" (u[i])); + 1674 35234640 : asm volatile ("movntdq %%xmm5,%0" : "=m" (p[i])); + 1675 35234640 : asm volatile ("movntdq %%xmm6,%0" : "=m" (q[i])); + 1676 35234640 : asm volatile ("movntdq %%xmm0,%0" : "=m" (r[i])); + 1677 35234640 : asm volatile ("movntdq %%xmm1,%0" : "=m" (s[i])); + 1678 35234640 : asm volatile ("movntdq %%xmm2,%0" : "=m" (t[i])); + 1679 35234640 : 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 108422 : void raid_rec1_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) + 1987 108332 : void raid_rec1_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) 1988 : { - 1989 108422 : uint8_t **v = (uint8_t **)vv; + 1989 108332 : 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 108422 : if (ip[0] == 0) { - 2000 98863 : raid_rec1of1(id, nd, size, vv); - 2001 207285 : return; + 1999 108332 : if (ip[0] == 0) { + 2000 98795 : raid_rec1of1(id, nd, size, vv); + 2001 207127 : return; 2002 : } 2003 : 2004 : /* setup the coefficients matrix */ - 2005 19118 : G = A(ip[0], id[0]); + 2005 19074 : G = A(ip[0], id[0]); 2006 : 2007 : /* invert it to solve the system of linear equations */ - 2008 19118 : V = inv(G); + 2008 19074 : V = inv(G); 2009 : 2010 : /* compute delta parity */ - 2011 9559 : raid_delta_gen(1, id, ip, nd, size, vv); + 2011 9537 : raid_delta_gen(1, id, ip, nd, size, vv); 2012 : - 2013 9559 : p = v[nd + ip[0]]; - 2014 9559 : pa = v[id[0]]; + 2013 9537 : p = v[nd + ip[0]]; + 2014 9537 : pa = v[id[0]]; 2015 : 2016 : raid_sse_begin(); 2017 : - 2018 9559 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); - 2019 9559 : asm volatile ("movdqa %0,%%xmm4" : : "m" (gfmulpshufb[V][0][0])); - 2020 9559 : asm volatile ("movdqa %0,%%xmm5" : : "m" (gfmulpshufb[V][1][0])); + 2018 9537 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 2019 9537 : asm volatile ("movdqa %0,%%xmm4" : : "m" (gfmulpshufb[V][0][0])); + 2020 9537 : asm volatile ("movdqa %0,%%xmm5" : : "m" (gfmulpshufb[V][1][0])); 2021 : - 2022 1531223 : for (i = 0; i < size; i += 16) { - 2023 1521664 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[i])); - 2024 1521664 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[i])); - 2025 1521664 : asm volatile ("movdqa %xmm4,%xmm2"); - 2026 1521664 : asm volatile ("movdqa %xmm5,%xmm3"); - 2027 1521664 : asm volatile ("pxor %xmm0,%xmm1"); - 2028 1521664 : asm volatile ("movdqa %xmm1,%xmm0"); - 2029 1521664 : asm volatile ("psrlw $4,%xmm1"); - 2030 1521664 : asm volatile ("pand %xmm7,%xmm0"); - 2031 1521664 : asm volatile ("pand %xmm7,%xmm1"); - 2032 1521664 : asm volatile ("pshufb %xmm0,%xmm2"); - 2033 1521664 : asm volatile ("pshufb %xmm1,%xmm3"); - 2034 1521664 : asm volatile ("pxor %xmm3,%xmm2"); - 2035 1521664 : asm volatile ("movdqa %%xmm2,%0" : "=m" (pa[i])); + 2022 1529793 : for (i = 0; i < size; i += 16) { + 2023 1520256 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[i])); + 2024 1520256 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[i])); + 2025 1520256 : asm volatile ("movdqa %xmm4,%xmm2"); + 2026 1520256 : asm volatile ("movdqa %xmm5,%xmm3"); + 2027 1520256 : asm volatile ("pxor %xmm0,%xmm1"); + 2028 1520256 : asm volatile ("movdqa %xmm1,%xmm0"); + 2029 1520256 : asm volatile ("psrlw $4,%xmm1"); + 2030 1520256 : asm volatile ("pand %xmm7,%xmm0"); + 2031 1520256 : asm volatile ("pand %xmm7,%xmm1"); + 2032 1520256 : asm volatile ("pshufb %xmm0,%xmm2"); + 2033 1520256 : asm volatile ("pshufb %xmm1,%xmm3"); + 2034 1520256 : asm volatile ("pxor %xmm3,%xmm2"); + 2035 1520256 : asm volatile ("movdqa %%xmm2,%0" : "=m" (pa[i])); 2036 : } 2037 : 2038 : raid_sse_end(); @@ -2105,182 +2105,182 @@ 2043 : /* 2044 : * RAID recovering for two disks SSSE3 implementation 2045 : */ - 2046 43538 : void raid_rec2_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) + 2046 43504 : void raid_rec2_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) 2047 : { - 2048 43538 : uint8_t **v = (uint8_t **)vv; - 2049 43538 : const int N = 2; - 2050 43538 : uint8_t *p[N]; - 2051 43538 : uint8_t *pa[N]; - 2052 43538 : uint8_t G[N * N]; - 2053 43538 : uint8_t V[N * N]; + 2048 43504 : uint8_t **v = (uint8_t **)vv; + 2049 43504 : const int N = 2; + 2050 43504 : uint8_t *p[N]; + 2051 43504 : uint8_t *pa[N]; + 2052 43504 : uint8_t G[N * N]; + 2053 43504 : 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 130614 : for (j = 0; j < N; ++j) - 2061 261228 : for (k = 0; k < N; ++k) - 2062 348304 : G[j * N + k] = A(ip[j], id[k]); + 2060 130512 : for (j = 0; j < N; ++j) + 2061 261024 : for (k = 0; k < N; ++k) + 2062 348032 : G[j * N + k] = A(ip[j], id[k]); 2063 : 2064 : /* invert it to solve the system of linear equations */ - 2065 43538 : raid_invert(G, V, N); + 2065 43504 : raid_invert(G, V, N); 2066 : 2067 : /* compute delta parity */ - 2068 43538 : raid_delta_gen(N, id, ip, nd, size, vv); + 2068 43504 : raid_delta_gen(N, id, ip, nd, size, vv); 2069 : - 2070 130614 : for (j = 0; j < N; ++j) { - 2071 87076 : p[j] = v[nd + ip[j]]; - 2072 87076 : pa[j] = v[id[j]]; + 2070 130512 : for (j = 0; j < N; ++j) { + 2071 87008 : p[j] = v[nd + ip[j]]; + 2072 87008 : pa[j] = v[id[j]]; 2073 : } 2074 : 2075 : raid_sse_begin(); 2076 : - 2077 43538 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 2077 43504 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 2078 : - 2079 3556306 : for (i = 0; i < size; i += 16) { - 2080 3512768 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[0][i])); - 2081 3512768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (pa[0][i])); - 2082 3512768 : asm volatile ("movdqa %0,%%xmm1" : : "m" (p[1][i])); - 2083 3512768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (pa[1][i])); - 2084 3512768 : asm volatile ("pxor %xmm2,%xmm0"); - 2085 3512768 : asm volatile ("pxor %xmm3,%xmm1"); + 2079 3554096 : for (i = 0; i < size; i += 16) { + 2080 3510592 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[0][i])); + 2081 3510592 : asm volatile ("movdqa %0,%%xmm2" : : "m" (pa[0][i])); + 2082 3510592 : asm volatile ("movdqa %0,%%xmm1" : : "m" (p[1][i])); + 2083 3510592 : asm volatile ("movdqa %0,%%xmm3" : : "m" (pa[1][i])); + 2084 3510592 : asm volatile ("pxor %xmm2,%xmm0"); + 2085 3510592 : asm volatile ("pxor %xmm3,%xmm1"); 2086 : - 2087 3512768 : asm volatile ("pxor %xmm6,%xmm6"); + 2087 3510592 : asm volatile ("pxor %xmm6,%xmm6"); 2088 : - 2089 3512768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[0]][0][0])); - 2090 3512768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[0]][1][0])); - 2091 3512768 : asm volatile ("movdqa %xmm0,%xmm4"); - 2092 3512768 : asm volatile ("movdqa %xmm0,%xmm5"); - 2093 3512768 : asm volatile ("psrlw $4,%xmm5"); - 2094 3512768 : asm volatile ("pand %xmm7,%xmm4"); - 2095 3512768 : asm volatile ("pand %xmm7,%xmm5"); - 2096 3512768 : asm volatile ("pshufb %xmm4,%xmm2"); - 2097 3512768 : asm volatile ("pshufb %xmm5,%xmm3"); - 2098 3512768 : asm volatile ("pxor %xmm2,%xmm6"); - 2099 3512768 : asm volatile ("pxor %xmm3,%xmm6"); + 2089 3510592 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[0]][0][0])); + 2090 3510592 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[0]][1][0])); + 2091 3510592 : asm volatile ("movdqa %xmm0,%xmm4"); + 2092 3510592 : asm volatile ("movdqa %xmm0,%xmm5"); + 2093 3510592 : asm volatile ("psrlw $4,%xmm5"); + 2094 3510592 : asm volatile ("pand %xmm7,%xmm4"); + 2095 3510592 : asm volatile ("pand %xmm7,%xmm5"); + 2096 3510592 : asm volatile ("pshufb %xmm4,%xmm2"); + 2097 3510592 : asm volatile ("pshufb %xmm5,%xmm3"); + 2098 3510592 : asm volatile ("pxor %xmm2,%xmm6"); + 2099 3510592 : asm volatile ("pxor %xmm3,%xmm6"); 2100 : - 2101 3512768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[1]][0][0])); - 2102 3512768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[1]][1][0])); - 2103 3512768 : asm volatile ("movdqa %xmm1,%xmm4"); - 2104 3512768 : asm volatile ("movdqa %xmm1,%xmm5"); - 2105 3512768 : asm volatile ("psrlw $4,%xmm5"); - 2106 3512768 : asm volatile ("pand %xmm7,%xmm4"); - 2107 3512768 : asm volatile ("pand %xmm7,%xmm5"); - 2108 3512768 : asm volatile ("pshufb %xmm4,%xmm2"); - 2109 3512768 : asm volatile ("pshufb %xmm5,%xmm3"); - 2110 3512768 : asm volatile ("pxor %xmm2,%xmm6"); - 2111 3512768 : asm volatile ("pxor %xmm3,%xmm6"); + 2101 3510592 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[1]][0][0])); + 2102 3510592 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[1]][1][0])); + 2103 3510592 : asm volatile ("movdqa %xmm1,%xmm4"); + 2104 3510592 : asm volatile ("movdqa %xmm1,%xmm5"); + 2105 3510592 : asm volatile ("psrlw $4,%xmm5"); + 2106 3510592 : asm volatile ("pand %xmm7,%xmm4"); + 2107 3510592 : asm volatile ("pand %xmm7,%xmm5"); + 2108 3510592 : asm volatile ("pshufb %xmm4,%xmm2"); + 2109 3510592 : asm volatile ("pshufb %xmm5,%xmm3"); + 2110 3510592 : asm volatile ("pxor %xmm2,%xmm6"); + 2111 3510592 : asm volatile ("pxor %xmm3,%xmm6"); 2112 : - 2113 3512768 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[0][i])); + 2113 3510592 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[0][i])); 2114 : - 2115 3512768 : asm volatile ("pxor %xmm6,%xmm6"); + 2115 3510592 : asm volatile ("pxor %xmm6,%xmm6"); 2116 : - 2117 3512768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[2]][0][0])); - 2118 3512768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[2]][1][0])); - 2119 3512768 : asm volatile ("movdqa %xmm0,%xmm4"); - 2120 3512768 : asm volatile ("movdqa %xmm0,%xmm5"); - 2121 3512768 : asm volatile ("psrlw $4,%xmm5"); - 2122 3512768 : asm volatile ("pand %xmm7,%xmm4"); - 2123 3512768 : asm volatile ("pand %xmm7,%xmm5"); - 2124 3512768 : asm volatile ("pshufb %xmm4,%xmm2"); - 2125 3512768 : asm volatile ("pshufb %xmm5,%xmm3"); - 2126 3512768 : asm volatile ("pxor %xmm2,%xmm6"); - 2127 3512768 : asm volatile ("pxor %xmm3,%xmm6"); + 2117 3510592 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[2]][0][0])); + 2118 3510592 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[2]][1][0])); + 2119 3510592 : asm volatile ("movdqa %xmm0,%xmm4"); + 2120 3510592 : asm volatile ("movdqa %xmm0,%xmm5"); + 2121 3510592 : asm volatile ("psrlw $4,%xmm5"); + 2122 3510592 : asm volatile ("pand %xmm7,%xmm4"); + 2123 3510592 : asm volatile ("pand %xmm7,%xmm5"); + 2124 3510592 : asm volatile ("pshufb %xmm4,%xmm2"); + 2125 3510592 : asm volatile ("pshufb %xmm5,%xmm3"); + 2126 3510592 : asm volatile ("pxor %xmm2,%xmm6"); + 2127 3510592 : asm volatile ("pxor %xmm3,%xmm6"); 2128 : - 2129 3512768 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[3]][0][0])); - 2130 3512768 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[3]][1][0])); - 2131 3512768 : asm volatile ("movdqa %xmm1,%xmm4"); - 2132 3512768 : asm volatile ("movdqa %xmm1,%xmm5"); - 2133 3512768 : asm volatile ("psrlw $4,%xmm5"); - 2134 3512768 : asm volatile ("pand %xmm7,%xmm4"); - 2135 3512768 : asm volatile ("pand %xmm7,%xmm5"); - 2136 3512768 : asm volatile ("pshufb %xmm4,%xmm2"); - 2137 3512768 : asm volatile ("pshufb %xmm5,%xmm3"); - 2138 3512768 : asm volatile ("pxor %xmm2,%xmm6"); - 2139 3512768 : asm volatile ("pxor %xmm3,%xmm6"); + 2129 3510592 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[V[3]][0][0])); + 2130 3510592 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[V[3]][1][0])); + 2131 3510592 : asm volatile ("movdqa %xmm1,%xmm4"); + 2132 3510592 : asm volatile ("movdqa %xmm1,%xmm5"); + 2133 3510592 : asm volatile ("psrlw $4,%xmm5"); + 2134 3510592 : asm volatile ("pand %xmm7,%xmm4"); + 2135 3510592 : asm volatile ("pand %xmm7,%xmm5"); + 2136 3510592 : asm volatile ("pshufb %xmm4,%xmm2"); + 2137 3510592 : asm volatile ("pshufb %xmm5,%xmm3"); + 2138 3510592 : asm volatile ("pxor %xmm2,%xmm6"); + 2139 3510592 : asm volatile ("pxor %xmm3,%xmm6"); 2140 : - 2141 3512768 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[1][i])); + 2141 3510592 : asm volatile ("movdqa %%xmm6,%0" : "=m" (pa[1][i])); 2142 : } 2143 : 2144 : raid_sse_end(); - 2145 43538 : } + 2145 43504 : } 2146 : #endif 2147 : 2148 : #if defined(CONFIG_X86) && defined(CONFIG_SSSE3) 2149 : /* 2150 : * RAID recovering SSSE3 implementation 2151 : */ - 2152 79451 : void raid_recX_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) + 2152 79421 : void raid_recX_ssse3(int nr, int *id, int *ip, int nd, size_t size, void **vv) 2153 : { - 2154 79451 : uint8_t **v = (uint8_t **)vv; - 2155 79451 : int N = nr; + 2154 79421 : uint8_t **v = (uint8_t **)vv; + 2155 79421 : int N = nr; 2156 : uint8_t *p[RAID_PARITY_MAX]; 2157 : uint8_t *pa[RAID_PARITY_MAX]; 2158 : uint8_t G[RAID_PARITY_MAX * RAID_PARITY_MAX]; 2159 : uint8_t V[RAID_PARITY_MAX * RAID_PARITY_MAX]; 2160 : uint8_t buffer[RAID_PARITY_MAX*16+16]; - 2161 79451 : uint8_t *pd = __align_ptr(buffer, 16); + 2161 79421 : uint8_t *pd = __align_ptr(buffer, 16); 2162 : size_t i; 2163 : int j, k; 2164 : 2165 : /* setup the coefficients matrix */ - 2166 435393 : for (j = 0; j < N; ++j) - 2167 2045022 : for (k = 0; k < N; ++k) - 2168 3378160 : G[j * N + k] = A(ip[j], id[k]); + 2166 435237 : for (j = 0; j < N; ++j) + 2167 2044162 : for (k = 0; k < N; ++k) + 2168 3376692 : G[j * N + k] = A(ip[j], id[k]); 2169 : 2170 : /* invert it to solve the system of linear equations */ - 2171 79451 : raid_invert(G, V, N); + 2171 79421 : raid_invert(G, V, N); 2172 : 2173 : /* compute delta parity */ - 2174 79451 : raid_delta_gen(N, id, ip, nd, size, vv); + 2174 79421 : raid_delta_gen(N, id, ip, nd, size, vv); 2175 : - 2176 435393 : for (j = 0; j < N; ++j) { - 2177 355942 : p[j] = v[nd + ip[j]]; - 2178 355942 : pa[j] = v[id[j]]; + 2176 435237 : for (j = 0; j < N; ++j) { + 2177 355816 : p[j] = v[nd + ip[j]]; + 2178 355816 : pa[j] = v[id[j]]; 2179 : } 2180 : 2181 : raid_sse_begin(); 2182 : - 2183 79451 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); + 2183 79421 : asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); 2184 : - 2185 5880427 : for (i = 0; i < size; i += 16) { + 2185 5878477 : for (i = 0; i < size; i += 16) { 2186 : /* delta */ - 2187 32134032 : for (j = 0; j < N; ++j) { - 2188 26333056 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[j][i])); - 2189 26333056 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[j][i])); - 2190 26333056 : asm volatile ("pxor %xmm1,%xmm0"); - 2191 26333056 : asm volatile ("movdqa %%xmm0,%0" : "=m" (pd[j*16])); + 2187 32124048 : for (j = 0; j < N; ++j) { + 2188 26324992 : asm volatile ("movdqa %0,%%xmm0" : : "m" (p[j][i])); + 2189 26324992 : asm volatile ("movdqa %0,%%xmm1" : : "m" (pa[j][i])); + 2190 26324992 : asm volatile ("pxor %xmm1,%xmm0"); + 2191 26324992 : asm volatile ("movdqa %%xmm0,%0" : "=m" (pd[j*16])); 2192 : } 2193 : 2194 : /* reconstruct */ - 2195 32134032 : for (j = 0; j < N; ++j) { - 2196 26333056 : asm volatile ("pxor %xmm0,%xmm0"); - 2197 26333056 : asm volatile ("pxor %xmm1,%xmm1"); + 2195 32124048 : for (j = 0; j < N; ++j) { + 2196 26324992 : asm volatile ("pxor %xmm0,%xmm0"); + 2197 26324992 : asm volatile ("pxor %xmm1,%xmm1"); 2198 : - 2199 153121344 : for (k = 0; k < N; ++k) { - 2200 126788288 : uint8_t m = V[j * N + k]; + 2199 153066304 : for (k = 0; k < N; ++k) { + 2200 126741312 : uint8_t m = V[j * N + k]; 2201 : - 2202 126788288 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[m][0][0])); - 2203 126788288 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[m][1][0])); - 2204 126788288 : asm volatile ("movdqa %0,%%xmm4" : : "m" (pd[k*16])); - 2205 126788288 : asm volatile ("movdqa %xmm4,%xmm5"); - 2206 126788288 : asm volatile ("psrlw $4,%xmm5"); - 2207 126788288 : asm volatile ("pand %xmm7,%xmm4"); - 2208 126788288 : asm volatile ("pand %xmm7,%xmm5"); - 2209 126788288 : asm volatile ("pshufb %xmm4,%xmm2"); - 2210 126788288 : asm volatile ("pshufb %xmm5,%xmm3"); - 2211 126788288 : asm volatile ("pxor %xmm2,%xmm0"); - 2212 126788288 : asm volatile ("pxor %xmm3,%xmm1"); + 2202 126741312 : asm volatile ("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[m][0][0])); + 2203 126741312 : asm volatile ("movdqa %0,%%xmm3" : : "m" (gfmulpshufb[m][1][0])); + 2204 126741312 : asm volatile ("movdqa %0,%%xmm4" : : "m" (pd[k*16])); + 2205 126741312 : asm volatile ("movdqa %xmm4,%xmm5"); + 2206 126741312 : asm volatile ("psrlw $4,%xmm5"); + 2207 126741312 : asm volatile ("pand %xmm7,%xmm4"); + 2208 126741312 : asm volatile ("pand %xmm7,%xmm5"); + 2209 126741312 : asm volatile ("pshufb %xmm4,%xmm2"); + 2210 126741312 : asm volatile ("pshufb %xmm5,%xmm3"); + 2211 126741312 : asm volatile ("pxor %xmm2,%xmm0"); + 2212 126741312 : asm volatile ("pxor %xmm3,%xmm1"); 2213 : } 2214 : - 2215 26333056 : asm volatile ("pxor %xmm1,%xmm0"); - 2216 26333056 : asm volatile ("movdqa %%xmm0,%0" : "=m" (pa[j][i])); + 2215 26324992 : asm volatile ("pxor %xmm1,%xmm0"); + 2216 26324992 : asm volatile ("movdqa %%xmm0,%0" : "=m" (pa[j][i])); 2217 : } 2218 : } 2219 : 2220 : raid_sse_end(); - 2221 79451 : } + 2221 79421 : } 2222 : #endif 2223 : 2224 : #if defined(CONFIG_X86) && defined(CONFIG_AVX2) diff --git a/cov/raid/x86z.c.func-sort-c.html b/cov/raid/x86z.c.func-sort-c.html index 65751eb9..feba53e1 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-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/raid/x86z.c.func.html b/cov/raid/x86z.c.func.html index 3fb78598..ddcb5ee7 100644 --- a/cov/raid/x86z.c.func.html +++ b/cov/raid/x86z.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/raid/x86z.c.gcov.html b/cov/raid/x86z.c.gcov.html index fb6c8977..a017e415 100644 --- a/cov/raid/x86z.c.gcov.html +++ b/cov/raid/x86z.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/tommyds/index-sort-f.html b/cov/tommyds/index-sort-f.html index 9a76fe79..76b386f3 100644 --- a/cov/tommyds/index-sort-f.html +++ b/cov/tommyds/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 82 diff --git a/cov/tommyds/index-sort-l.html b/cov/tommyds/index-sort-l.html index f9780f3b..604892c6 100644 --- a/cov/tommyds/index-sort-l.html +++ b/cov/tommyds/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 82 diff --git a/cov/tommyds/index.html b/cov/tommyds/index.html index 6fdcec83..c324798d 100644 --- a/cov/tommyds/index.html +++ b/cov/tommyds/index.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 82 diff --git a/cov/tommyds/tommyarray.c.func-sort-c.html b/cov/tommyds/tommyarray.c.func-sort-c.html index 79c98e30..29667f57 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-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ tommy_array_grow - 2134 + 2147 tommy_array_init - 502 + 506 tommy_array_done - 479 + 483 tommy_array_memory_usage diff --git a/cov/tommyds/tommyarray.c.func.html b/cov/tommyds/tommyarray.c.func.html index e35a328c..6780c996 100644 --- a/cov/tommyds/tommyarray.c.func.html +++ b/cov/tommyds/tommyarray.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ tommy_array_done - 479 + 483 tommy_array_grow - 2134 + 2147 tommy_array_init - 502 + 506 tommy_array_memory_usage diff --git a/cov/tommyds/tommyarray.c.gcov.html b/cov/tommyds/tommyarray.c.gcov.html index 86c90ec9..20cb4e49 100644 --- a/cov/tommyds/tommyarray.c.gcov.html +++ b/cov/tommyds/tommyarray.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -92,38 +92,38 @@ 30 : /******************************************************************************/ 31 : /* array */ 32 : - 33 502 : void tommy_array_init(tommy_array* array) + 33 506 : void tommy_array_init(tommy_array* array) 34 : { 35 : tommy_uint_t i; 36 : 37 : /* fixed initial size */ - 38 502 : array->bucket_bit = TOMMY_ARRAY_BIT; - 39 502 : array->bucket_max = 1 << array->bucket_bit; - 40 502 : array->bucket[0] = tommy_cast(void**, tommy_calloc(array->bucket_max, sizeof(void*))); - 41 3012 : for (i = 1; i < TOMMY_ARRAY_BIT; ++i) - 42 2510 : array->bucket[i] = array->bucket[0]; + 38 506 : array->bucket_bit = TOMMY_ARRAY_BIT; + 39 506 : array->bucket_max = 1 << array->bucket_bit; + 40 506 : array->bucket[0] = tommy_cast(void**, tommy_calloc(array->bucket_max, sizeof(void*))); + 41 3036 : for (i = 1; i < TOMMY_ARRAY_BIT; ++i) + 42 2530 : array->bucket[i] = array->bucket[0]; 43 : - 44 502 : array->count = 0; - 45 502 : } + 44 506 : array->count = 0; + 45 506 : } 46 : - 47 479 : void tommy_array_done(tommy_array* array) + 47 483 : void tommy_array_done(tommy_array* array) 48 : { 49 : tommy_uint_t i; 50 : - 51 479 : tommy_free(array->bucket[0]); - 52 481 : for (i = TOMMY_ARRAY_BIT; i < array->bucket_bit; ++i) { + 51 483 : tommy_free(array->bucket[0]); + 52 485 : 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 479 : } + 56 483 : } 57 : - 58 2134 : void tommy_array_grow(tommy_array* array, tommy_count_t count) + 58 2147 : void tommy_array_grow(tommy_array* array, tommy_count_t count) 59 : { - 60 2134 : if (array->count >= count) - 61 2134 : return; - 62 2134 : array->count = count; + 60 2147 : if (array->count >= count) + 61 2147 : return; + 62 2147 : array->count = count; 63 : - 64 4270 : while (count > array->bucket_max) { + 64 4296 : 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 eae84ff6..cbe93e5e 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-01-09 + 2016-01-16 Functions: 5 @@ -61,19 +61,19 @@ tommy_array_ref - 10133914 + 10127992 tommy_array_get - 10131780 + 10125845 tommy_array_size - 1541305 + 1543093 tommy_array_set - 2134 + 2147 tommy_array_insert diff --git a/cov/tommyds/tommyarray.h.func.html b/cov/tommyds/tommyarray.h.func.html index 8232c615..613e1417 100644 --- a/cov/tommyds/tommyarray.h.func.html +++ b/cov/tommyds/tommyarray.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 5 @@ -61,7 +61,7 @@ tommy_array_get - 10131780 + 10125845 tommy_array_insert @@ -69,15 +69,15 @@ tommy_array_ref - 10133914 + 10127992 tommy_array_set - 2134 + 2147 tommy_array_size - 1541305 + 1543093
diff --git a/cov/tommyds/tommyarray.h.gcov.html b/cov/tommyds/tommyarray.h.gcov.html index 43dd4250..00e05220 100644 --- a/cov/tommyds/tommyarray.h.gcov.html +++ b/cov/tommyds/tommyarray.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 10133914 : tommy_inline void** tommy_array_ref(tommy_array* array, tommy_count_t pos) + 93 10127992 : tommy_inline void** tommy_array_ref(tommy_array* array, tommy_count_t pos) 94 : { 95 : tommy_uint_t bsr; 96 : - 97 10133914 : assert(pos < array->count); + 97 10127992 : assert(pos < array->count); 98 : 99 : /* get the highest bit set, in case of all 0, return 0 */ - 100 10133914 : bsr = tommy_ilog2_u32(pos | 1); + 100 10127992 : bsr = tommy_ilog2_u32(pos | 1); 101 : - 102 10133914 : return &array->bucket[bsr][pos]; + 102 10127992 : 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 2134 : tommy_inline void tommy_array_set(tommy_array* array, tommy_count_t pos, void* element) + 110 2147 : tommy_inline void tommy_array_set(tommy_array* array, tommy_count_t pos, void* element) 111 : { - 112 2134 : *tommy_array_ref(array, pos) = element; - 113 2134 : } + 112 2147 : *tommy_array_ref(array, pos) = element; + 113 2147 : } 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 10131780 : tommy_inline void* tommy_array_get(tommy_array* array, tommy_count_t pos) + 120 10125845 : tommy_inline void* tommy_array_get(tommy_array* array, tommy_count_t pos) 121 : { - 122 10131780 : return *tommy_array_ref(array, pos); + 122 10125845 : return *tommy_array_ref(array, pos); 123 : } 124 : 125 : /** @@ -199,9 +199,9 @@ 137 : /** 138 : * Gets the initialized size of the array. 139 : */ - 140 1541305 : tommy_inline tommy_count_t tommy_array_size(tommy_array* array) + 140 1543093 : tommy_inline tommy_count_t tommy_array_size(tommy_array* array) 141 : { - 142 1541305 : return array->count; + 142 1543093 : return array->count; 143 : } 144 : 145 : /** diff --git a/cov/tommyds/tommyarrayblk.c.func-sort-c.html b/cov/tommyds/tommyarrayblk.c.func-sort-c.html index f95f1c5f..aaa0b28e 100644 --- a/cov/tommyds/tommyarrayblk.c.func-sort-c.html +++ b/cov/tommyds/tommyarrayblk.c.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblk.c.func.html b/cov/tommyds/tommyarrayblk.c.func.html index 127cd197..ec37c90e 100644 --- a/cov/tommyds/tommyarrayblk.c.func.html +++ b/cov/tommyds/tommyarrayblk.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblk.c.gcov.html b/cov/tommyds/tommyarrayblk.c.gcov.html index 5de3ddaf..53694521 100644 --- a/cov/tommyds/tommyarrayblk.c.gcov.html +++ b/cov/tommyds/tommyarrayblk.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblk.h.func-sort-c.html b/cov/tommyds/tommyarrayblk.h.func-sort-c.html index c47df152..f562d712 100644 --- a/cov/tommyds/tommyarrayblk.h.func-sort-c.html +++ b/cov/tommyds/tommyarrayblk.h.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblk.h.func.html b/cov/tommyds/tommyarrayblk.h.func.html index c9e1a0b7..78348de5 100644 --- a/cov/tommyds/tommyarrayblk.h.func.html +++ b/cov/tommyds/tommyarrayblk.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblk.h.gcov.html b/cov/tommyds/tommyarrayblk.h.gcov.html index 78cb8df9..5c239dbf 100644 --- a/cov/tommyds/tommyarrayblk.h.gcov.html +++ b/cov/tommyds/tommyarrayblk.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 diff --git a/cov/tommyds/tommyarrayblkof.c.func-sort-c.html b/cov/tommyds/tommyarrayblkof.c.func-sort-c.html index a308945e..10fe4ce8 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-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ tommy_arrayblkof_grow - 1640038 + 1641982 tommy_arrayblkof_init - 257 + 259 tommy_arrayblkof_done - 235 + 237 tommy_arrayblkof_memory_usage diff --git a/cov/tommyds/tommyarrayblkof.c.func.html b/cov/tommyds/tommyarrayblkof.c.func.html index 1549efe9..2a573900 100644 --- a/cov/tommyds/tommyarrayblkof.c.func.html +++ b/cov/tommyds/tommyarrayblkof.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -61,15 +61,15 @@ tommy_arrayblkof_done - 235 + 237 tommy_arrayblkof_grow - 1640038 + 1641982 tommy_arrayblkof_init - 257 + 259 tommy_arrayblkof_memory_usage diff --git a/cov/tommyds/tommyarrayblkof.c.gcov.html b/cov/tommyds/tommyarrayblkof.c.gcov.html index 414b307c..0f07dad3 100644 --- a/cov/tommyds/tommyarrayblkof.c.gcov.html +++ b/cov/tommyds/tommyarrayblkof.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 4 @@ -92,48 +92,48 @@ 30 : /******************************************************************************/ 31 : /* array */ 32 : - 33 257 : void tommy_arrayblkof_init(tommy_arrayblkof* array, tommy_size_t element_size) + 33 259 : void tommy_arrayblkof_init(tommy_arrayblkof* array, tommy_size_t element_size) 34 : { - 35 257 : tommy_array_init(&array->block); + 35 259 : tommy_array_init(&array->block); 36 : - 37 257 : array->element_size = element_size; - 38 257 : array->count = 0; - 39 257 : } + 37 259 : array->element_size = element_size; + 38 259 : array->count = 0; + 39 259 : } 40 : - 41 235 : void tommy_arrayblkof_done(tommy_arrayblkof* array) + 41 237 : void tommy_arrayblkof_done(tommy_arrayblkof* array) 42 : { 43 : tommy_count_t i; 44 : - 45 743 : for (i = 0; i < tommy_array_size(&array->block); ++i) - 46 508 : tommy_free(tommy_array_get(&array->block, i)); + 45 747 : for (i = 0; i < tommy_array_size(&array->block); ++i) + 46 510 : tommy_free(tommy_array_get(&array->block, i)); 47 : - 48 235 : tommy_array_done(&array->block); - 49 235 : } + 48 237 : tommy_array_done(&array->block); + 49 237 : } 50 : - 51 1640038 : void tommy_arrayblkof_grow(tommy_arrayblkof* array, tommy_count_t count) + 51 1641982 : 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 1640038 : if (array->count >= count) - 57 1739774 : return; - 58 1540302 : array->count = count; + 56 1641982 : if (array->count >= count) + 57 1741878 : return; + 58 1542086 : array->count = count; 59 : - 60 1540302 : block_max = (count + TOMMY_ARRAYBLKOF_SIZE - 1) / TOMMY_ARRAYBLKOF_SIZE; - 61 1540302 : block_mac = tommy_array_size(&array->block); + 60 1542086 : block_max = (count + TOMMY_ARRAYBLKOF_SIZE - 1) / TOMMY_ARRAYBLKOF_SIZE; + 61 1542086 : block_mac = tommy_array_size(&array->block); 62 : - 63 1540302 : if (block_mac < block_max) { + 63 1542086 : if (block_mac < block_max) { 64 : /* grow the block array */ - 65 537 : tommy_array_grow(&array->block, block_max); + 65 539 : tommy_array_grow(&array->block, block_max); 66 : 67 : /* allocate new blocks */ - 68 1611 : while (block_mac < block_max) { - 69 537 : void** ptr = tommy_cast(void**, tommy_calloc(TOMMY_ARRAYBLKOF_SIZE, array->element_size)); + 68 1617 : while (block_mac < block_max) { + 69 539 : void** ptr = tommy_cast(void**, tommy_calloc(TOMMY_ARRAYBLKOF_SIZE, array->element_size)); 70 : 71 : /* set the new block */ - 72 537 : tommy_array_set(&array->block, block_mac, ptr); + 72 539 : tommy_array_set(&array->block, block_mac, ptr); 73 : - 74 537 : ++block_mac; + 74 539 : ++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 52261451..b927356f 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-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_arrayblkof_ref - 6481666 + 6475089 tommy_arrayblkof_size - 5104110 + 5095494
diff --git a/cov/tommyds/tommyarrayblkof.h.func.html b/cov/tommyds/tommyarrayblkof.h.func.html index 75b07f3a..abf6e9da 100644 --- a/cov/tommyds/tommyarrayblkof.h.func.html +++ b/cov/tommyds/tommyarrayblkof.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_arrayblkof_ref - 6481666 + 6475089 tommy_arrayblkof_size - 5104110 + 5095494
diff --git a/cov/tommyds/tommyarrayblkof.h.gcov.html b/cov/tommyds/tommyarrayblkof.h.gcov.html index a9b2c14e..01b0aa9d 100644 --- a/cov/tommyds/tommyarrayblkof.h.gcov.html +++ b/cov/tommyds/tommyarrayblkof.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 6481666 : tommy_inline void* tommy_arrayblkof_ref(tommy_arrayblkof* array, tommy_count_t pos) + 89 6475089 : tommy_inline void* tommy_arrayblkof_ref(tommy_arrayblkof* array, tommy_count_t pos) 90 : { 91 : unsigned char* base; 92 : - 93 6481666 : assert(pos < array->count); + 93 6475089 : assert(pos < array->count); 94 : - 95 6481666 : base = tommy_cast(unsigned char*, tommy_array_get(&array->block, pos / TOMMY_ARRAYBLKOF_SIZE)); + 95 6475089 : base = tommy_cast(unsigned char*, tommy_array_get(&array->block, pos / TOMMY_ARRAYBLKOF_SIZE)); 96 : - 97 6481666 : return base + (pos % TOMMY_ARRAYBLKOF_SIZE) * array->element_size; + 97 6475089 : return base + (pos % TOMMY_ARRAYBLKOF_SIZE) * array->element_size; 98 : } 99 : 100 : /** 101 : * Gets the initialized size of the array. 102 : */ - 103 5104110 : tommy_inline tommy_count_t tommy_arrayblkof_size(tommy_arrayblkof* array) + 103 5095494 : tommy_inline tommy_count_t tommy_arrayblkof_size(tommy_arrayblkof* array) 104 : { - 105 5104110 : return array->count; + 105 5095494 : 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 ddbb6bb4..f54fec90 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-01-09 + 2016-01-16 Functions: 5 @@ -61,23 +61,23 @@ tommy_chain_splice - 4261933 + 4268059 tommy_chain_merge_degenerated - 1203475 + 1203713 tommy_chain_concat - 1197191 + 1197416 tommy_chain_merge - 446438 + 446904 tommy_chain_mergesort - 1558 + 1571
diff --git a/cov/tommyds/tommychain.h.func.html b/cov/tommyds/tommychain.h.func.html index 2298e9b8..b5c059fc 100644 --- a/cov/tommyds/tommychain.h.func.html +++ b/cov/tommyds/tommychain.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 5 @@ -61,23 +61,23 @@ tommy_chain_concat - 1197191 + 1197416 tommy_chain_merge - 446438 + 446904 tommy_chain_merge_degenerated - 1203475 + 1203713 tommy_chain_mergesort - 1558 + 1571 tommy_chain_splice - 4261933 + 4268059
diff --git a/cov/tommyds/tommychain.h.gcov.html b/cov/tommyds/tommychain.h.gcov.html index a9d47b12..81285763 100644 --- a/cov/tommyds/tommychain.h.gcov.html +++ b/cov/tommyds/tommychain.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 5 @@ -119,83 +119,83 @@ 57 : /** 58 : * Splices a chain in the middle of another chain. 59 : */ - 60 4261933 : tommy_inline void tommy_chain_splice(tommy_node* first_before, tommy_node* first_after, tommy_node* second_head, tommy_node* second_tail) + 60 4268059 : 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 4261933 : first_after->prev = second_tail; - 64 4261933 : second_head->prev = first_before; + 63 4268059 : first_after->prev = second_tail; + 64 4268059 : second_head->prev = first_before; 65 : 66 : /* set the next list */ - 67 4261933 : first_before->next = second_head; - 68 4261933 : second_tail->next = first_after; - 69 4261933 : } + 67 4268059 : first_before->next = second_head; + 68 4268059 : second_tail->next = first_after; + 69 4268059 : } 70 : 71 : /** 72 : * Concats two chains. 73 : */ - 74 1197191 : tommy_inline void tommy_chain_concat(tommy_node* first_tail, tommy_node* second_head) + 74 1197416 : tommy_inline void tommy_chain_concat(tommy_node* first_tail, tommy_node* second_head) 75 : { 76 : /* set the prev list */ - 77 1197191 : second_head->prev = first_tail; + 77 1197416 : second_head->prev = first_tail; 78 : 79 : /* set the next list */ - 80 1197191 : first_tail->next = second_head; - 81 1197191 : } + 80 1197416 : first_tail->next = second_head; + 81 1197416 : } 82 : 83 : /** 84 : * Merges two chains. 85 : */ - 86 446438 : tommy_inline void tommy_chain_merge(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) + 86 446904 : tommy_inline void tommy_chain_merge(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) 87 : { - 88 446438 : tommy_node* first_i = first->head; - 89 446438 : tommy_node* second_i = second->head; + 88 446904 : tommy_node* first_i = first->head; + 89 446904 : tommy_node* second_i = second->head; 90 : 91 : /* merge */ 92 : while (1) { - 93 9274986 : if (cmp(first_i->data, second_i->data) > 0) { - 94 4482275 : tommy_node* next = second_i->next; - 95 4482275 : if (first_i == first->head) { - 96 220342 : tommy_chain_concat(second_i, first_i); - 97 220342 : first->head = second_i; + 93 9285086 : if (cmp(first_i->data, second_i->data) > 0) { + 94 4488605 : tommy_node* next = second_i->next; + 95 4488605 : if (first_i == first->head) { + 96 220546 : tommy_chain_concat(second_i, first_i); + 97 220546 : first->head = second_i; 98 : } else { - 99 4261933 : tommy_chain_splice(first_i->prev, first_i, second_i, second_i); + 99 4268059 : tommy_chain_splice(first_i->prev, first_i, second_i, second_i); 100 : } - 101 4482275 : if (second_i == second->tail) - 102 226626 : break; - 103 4255649 : second_i = next; + 101 4488605 : if (second_i == second->tail) + 102 226843 : break; + 103 4261762 : second_i = next; 104 : } else { - 105 4792711 : if (first_i == first->tail) { - 106 219812 : tommy_chain_concat(first_i, second_i); - 107 219812 : first->tail = second->tail; - 108 219812 : break; + 105 4796481 : if (first_i == first->tail) { + 106 220061 : tommy_chain_concat(first_i, second_i); + 107 220061 : first->tail = second->tail; + 108 220061 : break; 109 : } - 110 4572899 : first_i = first_i->next; + 110 4576420 : first_i = first_i->next; 111 : } - 112 8828548 : } - 113 446438 : } + 112 8838182 : } + 113 446904 : } 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 1203475 : tommy_inline void tommy_chain_merge_degenerated(tommy_chain* first, tommy_chain* second, tommy_compare_func* cmp) + 119 1203713 : 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 1203475 : if (cmp(first->tail->data, second->head->data) <= 0) { - 123 439434 : tommy_chain_concat(first->tail, second->head); - 124 439434 : first->tail = second->tail; - 125 439434 : return; + 122 1203713 : if (cmp(first->tail->data, second->head->data) <= 0) { + 123 438997 : tommy_chain_concat(first->tail, second->head); + 124 438997 : first->tail = second->tail; + 125 438997 : return; 126 : } 127 : 128 : /* identify the condition second < first */ 129 : /* here we must be strict on comparison to keep the sort stable */ - 130 764041 : if (cmp(second->tail->data, first->head->data) < 0) { - 131 317603 : tommy_chain_concat(second->tail, first->head); - 132 317603 : first->head = second->head; - 133 317603 : return; + 130 764716 : if (cmp(second->tail->data, first->head->data) < 0) { + 131 317812 : tommy_chain_concat(second->tail, first->head); + 132 317812 : first->head = second->head; + 133 317812 : return; 134 : } 135 : - 136 446438 : tommy_chain_merge(first, second, cmp); + 136 446904 : tommy_chain_merge(first, second, cmp); 137 : } 138 : 139 : /** @@ -215,7 +215,7 @@ 153 : * Linux Kernel lib/list_sort.c 154 : * http://lxr.linux.no/#linux+v2.6.36/lib/list_sort.c 155 : */ - 156 1558 : tommy_inline void tommy_chain_mergesort(tommy_chain* chain, tommy_compare_func* cmp) + 156 1571 : tommy_inline void tommy_chain_mergesort(tommy_chain* chain, tommy_compare_func* cmp) 157 : { 158 : /* 159 : * Bit buckets of chains. @@ -230,57 +230,57 @@ 168 : * It's used to know which bucket is empty of full. 169 : */ 170 : tommy_count_t counter; - 171 1558 : tommy_node* node = chain->head; - 172 1558 : tommy_node* tail = chain->tail; + 171 1571 : tommy_node* node = chain->head; + 172 1571 : tommy_node* tail = chain->tail; 173 : tommy_count_t mask; 174 : tommy_count_t i; 175 : - 176 1558 : counter = 0; + 176 1571 : counter = 0; 177 : while (1) { 178 : tommy_node* next; 179 : tommy_chain* last; 180 : 181 : /* carry bit to add */ - 182 1205033 : last = &bit[TOMMY_CHAIN_BIT_MAX]; - 183 1205033 : bit[TOMMY_CHAIN_BIT_MAX].head = node; - 184 1205033 : bit[TOMMY_CHAIN_BIT_MAX].tail = node; - 185 1205033 : next = node->next; + 182 1205284 : last = &bit[TOMMY_CHAIN_BIT_MAX]; + 183 1205284 : bit[TOMMY_CHAIN_BIT_MAX].head = node; + 184 1205284 : bit[TOMMY_CHAIN_BIT_MAX].tail = node; + 185 1205284 : next = node->next; 186 : 187 : /* add the bit, propagating the carry */ - 188 1205033 : i = 0; - 189 1205033 : mask = counter; - 190 3607881 : while ((mask & 1) != 0) { - 191 1197815 : tommy_chain_merge_degenerated(&bit[i], last, cmp); - 192 1197815 : mask >>= 1; - 193 1197815 : last = &bit[i]; - 194 1197815 : ++i; + 188 1205284 : i = 0; + 189 1205284 : mask = counter; + 190 3608647 : while ((mask & 1) != 0) { + 191 1198079 : tommy_chain_merge_degenerated(&bit[i], last, cmp); + 192 1198079 : mask >>= 1; + 193 1198079 : last = &bit[i]; + 194 1198079 : ++i; 195 : } 196 : 197 : /* copy the carry in the first empty bit */ - 198 1205033 : bit[i] = *last; + 198 1205284 : bit[i] = *last; 199 : 200 : /* add the carry in the counter */ - 201 1205033 : ++counter; + 201 1205284 : ++counter; 202 : - 203 1205033 : if (node == tail) - 204 1558 : break; - 205 1203475 : node = next; - 206 1203475 : } + 203 1205284 : if (node == tail) + 204 1571 : break; + 205 1203713 : node = next; + 206 1203713 : } 207 : 208 : /* merge the buckets */ - 209 1558 : i = tommy_ctz_u32(counter); - 210 1558 : mask = counter >> i; - 211 11511 : while (mask != 1) { - 212 8395 : mask >>= 1; - 213 8395 : if (mask & 1) - 214 5660 : tommy_chain_merge_degenerated(&bit[i + 1], &bit[i], cmp); + 209 1571 : i = tommy_ctz_u32(counter); + 210 1571 : mask = counter >> i; + 211 11545 : while (mask != 1) { + 212 8403 : mask >>= 1; + 213 8403 : if (mask & 1) + 214 5634 : tommy_chain_merge_degenerated(&bit[i + 1], &bit[i], cmp); 215 : else - 216 2735 : bit[i + 1] = bit[i]; - 217 8395 : ++i; + 216 2769 : bit[i + 1] = bit[i]; + 217 8403 : ++i; 218 : } 219 : - 220 1558 : *chain = bit[i]; - 221 1558 : } + 220 1571 : *chain = bit[i]; + 221 1571 : } 222 : 223 : #endif 224 : diff --git a/cov/tommyds/tommyhash.c.func-sort-c.html b/cov/tommyds/tommyhash.c.func-sort-c.html index 7a44421b..9f1e8fb1 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-01-09 + 2016-01-16 Functions: 3 @@ -61,11 +61,11 @@ tommy_le_uint32_read - 11379991 + 11375662 tommy_hash_u32 - 3984897 + 3983874 tommy_hash_u64 diff --git a/cov/tommyds/tommyhash.c.func.html b/cov/tommyds/tommyhash.c.func.html index 6e925c33..c3fe660a 100644 --- a/cov/tommyds/tommyhash.c.func.html +++ b/cov/tommyds/tommyhash.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -61,7 +61,7 @@ tommy_hash_u32 - 3984897 + 3983874 tommy_hash_u64 @@ -69,7 +69,7 @@ tommy_le_uint32_read - 11379991 + 11375662
diff --git a/cov/tommyds/tommyhash.c.gcov.html b/cov/tommyds/tommyhash.c.gcov.html index e0683e1f..9b122e3e 100644 --- a/cov/tommyds/tommyhash.c.gcov.html +++ b/cov/tommyds/tommyhash.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -92,12 +92,12 @@ 30 : /******************************************************************************/ 31 : /* hash */ 32 : - 33 11379991 : tommy_inline tommy_uint32_t tommy_le_uint32_read(const void* ptr) + 33 11375662 : 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 11379991 : return *(const tommy_uint32_t*)ptr; + 38 11375662 : 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 3984897 : tommy_uint32_t tommy_hash_u32(tommy_uint32_t init_val, const void* void_key, tommy_size_t key_len) + 69 3983874 : tommy_uint32_t tommy_hash_u32(tommy_uint32_t init_val, const void* void_key, tommy_size_t key_len) 70 : { - 71 3984897 : const unsigned char* key = tommy_cast(const unsigned char*, void_key); + 71 3983874 : const unsigned char* key = tommy_cast(const unsigned char*, void_key); 72 : tommy_uint32_t a, b, c; 73 : - 74 3984897 : a = b = c = 0xdeadbeef + ((tommy_uint32_t)key_len) + init_val; + 74 3983874 : a = b = c = 0xdeadbeef + ((tommy_uint32_t)key_len) + init_val; 75 : - 76 10052462 : while (key_len > 12) { - 77 2082668 : a += tommy_le_uint32_read(key + 0); - 78 2082668 : b += tommy_le_uint32_read(key + 4); - 79 2082668 : c += tommy_le_uint32_read(key + 8); + 76 10049450 : while (key_len > 12) { + 77 2081702 : a += tommy_le_uint32_read(key + 0); + 78 2081702 : b += tommy_le_uint32_read(key + 4); + 79 2081702 : c += tommy_le_uint32_read(key + 8); 80 : - 81 2082668 : tommy_mix(a, b, c); + 81 2081702 : tommy_mix(a, b, c); 82 : - 83 2082668 : key_len -= 12; - 84 2082668 : key += 12; + 83 2081702 : key_len -= 12; + 84 2081702 : key += 12; 85 : } 86 : - 87 3984897 : switch (key_len) { + 87 3983874 : switch (key_len) { 88 : case 0 : 89 1 : return c; /* used only when called with a zero length */ 90 : case 12 : - 91 204266 : c += tommy_le_uint32_read(key + 8); - 92 204266 : b += tommy_le_uint32_read(key + 4); - 93 204266 : a += tommy_le_uint32_read(key + 0); - 94 204266 : break; - 95 213540 : case 11 : c += ((tommy_uint32_t)key[10]) << 16; - 96 628617 : case 10 : c += ((tommy_uint32_t)key[9]) << 8; - 97 1040835 : case 9 : c += key[8]; + 91 204186 : c += tommy_le_uint32_read(key + 8); + 92 204186 : b += tommy_le_uint32_read(key + 4); + 93 204186 : a += tommy_le_uint32_read(key + 0); + 94 204186 : break; + 95 213450 : case 11 : c += ((tommy_uint32_t)key[10]) << 16; + 96 628360 : case 10 : c += ((tommy_uint32_t)key[9]) << 8; + 97 1040399 : case 9 : c += key[8]; 98 : case 8 : - 99 1444224 : b += tommy_le_uint32_read(key + 4); - 100 1444224 : a += tommy_le_uint32_read(key + 0); - 101 1444224 : break; - 102 405262 : case 7 : b += ((tommy_uint32_t)key[6]) << 16; - 103 797887 : case 6 : b += ((tommy_uint32_t)key[5]) << 8; - 104 1206407 : case 5 : b += key[4]; + 99 1443638 : b += tommy_le_uint32_read(key + 4); + 100 1443638 : a += tommy_le_uint32_read(key + 0); + 101 1443638 : break; + 102 405083 : case 7 : b += ((tommy_uint32_t)key[6]) << 16; + 103 797509 : case 6 : b += ((tommy_uint32_t)key[5]) << 8; + 104 1206545 : case 5 : b += key[4]; 105 : case 4 : - 106 1630692 : a += tommy_le_uint32_read(key + 0); - 107 1630692 : break; - 108 295633 : case 3 : a += ((tommy_uint32_t)key[2]) << 16; - 109 499608 : case 2 : a += ((tommy_uint32_t)key[1]) << 8; - 110 705714 : case 1 : a += key[0]; + 106 1630673 : a += tommy_le_uint32_read(key + 0); + 107 1630673 : break; + 108 295523 : case 3 : a += ((tommy_uint32_t)key[2]) << 16; + 109 499392 : case 2 : a += ((tommy_uint32_t)key[1]) << 8; + 110 705376 : case 1 : a += key[0]; 111 : } 112 : - 113 3984896 : tommy_final(a, b, c); + 113 3983873 : tommy_final(a, b, c); 114 : - 115 3984896 : return c; + 115 3983873 : 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 45a1fc87..e872c784 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-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_inthash_u32 - 18594807 + 18597144 tommy_inthash_u64 - 4924816 + 4923043
diff --git a/cov/tommyds/tommyhash.h.func.html b/cov/tommyds/tommyhash.h.func.html index 8e649746..01ea643d 100644 --- a/cov/tommyds/tommyhash.h.func.html +++ b/cov/tommyds/tommyhash.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_inthash_u32 - 18594807 + 18597144 tommy_inthash_u64 - 4924816 + 4923043
diff --git a/cov/tommyds/tommyhash.h.gcov.html b/cov/tommyds/tommyhash.h.gcov.html index ef81f711..3d37dd6c 100644 --- a/cov/tommyds/tommyhash.h.gcov.html +++ b/cov/tommyds/tommyhash.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -139,17 +139,17 @@ 77 : * Implementation of the Robert Jenkins "4-byte Integer Hashing", 78 : * from http://burtleburtle.net/bob/hash/integer.html 79 : */ - 80 18594807 : tommy_inline tommy_uint32_t tommy_inthash_u32(tommy_uint32_t key) + 80 18597144 : tommy_inline tommy_uint32_t tommy_inthash_u32(tommy_uint32_t key) 81 : { - 82 18594807 : key -= key << 6; - 83 18594807 : key ^= key >> 17; - 84 18594807 : key -= key << 9; - 85 18594807 : key ^= key << 4; - 86 18594807 : key -= key << 3; - 87 18594807 : key ^= key << 10; - 88 18594807 : key ^= key >> 15; + 82 18597144 : key -= key << 6; + 83 18597144 : key ^= key >> 17; + 84 18597144 : key -= key << 9; + 85 18597144 : key ^= key << 4; + 86 18597144 : key -= key << 3; + 87 18597144 : key ^= key << 10; + 88 18597144 : key ^= key >> 15; 89 : - 90 18594807 : return key; + 90 18597144 : return key; 91 : } 92 : 93 : /** @@ -157,17 +157,17 @@ 95 : * Implementation of the Thomas Wang "Integer Hash Function", 96 : * from http://www.cris.com/~Ttwang/tech/inthash.htm 97 : */ - 98 4924816 : tommy_inline tommy_uint64_t tommy_inthash_u64(tommy_uint64_t key) + 98 4923043 : tommy_inline tommy_uint64_t tommy_inthash_u64(tommy_uint64_t key) 99 : { - 100 4924816 : key = ~key + (key << 21); - 101 4924816 : key = key ^ (key >> 24); - 102 4924816 : key = key + (key << 3) + (key << 8); - 103 4924816 : key = key ^ (key >> 14); - 104 4924816 : key = key + (key << 2) + (key << 4); - 105 4924816 : key = key ^ (key >> 28); - 106 4924816 : key = key + (key << 31); + 100 4923043 : key = ~key + (key << 21); + 101 4923043 : key = key ^ (key >> 24); + 102 4923043 : key = key + (key << 3) + (key << 8); + 103 4923043 : key = key ^ (key >> 14); + 104 4923043 : key = key + (key << 2) + (key << 4); + 105 4923043 : key = key ^ (key >> 28); + 106 4923043 : key = key + (key << 31); 107 : - 108 4924816 : return key; + 108 4923043 : return key; 109 : } 110 : 111 : #endif diff --git a/cov/tommyds/tommyhashdyn.c.func-sort-c.html b/cov/tommyds/tommyhashdyn.c.func-sort-c.html index cd0ec00e..ba5180c4 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-01-09 + 2016-01-16 Functions: 11 @@ -61,19 +61,19 @@ hashdyn_grow_step - 13012162 + 13012047 tommy_hashdyn_insert - 13012162 + 13012047 hashdyn_shrink_step - 299207 + 296484 tommy_hashdyn_remove_existing - 299079 + 296356 tommy_hashdyn_resize @@ -81,11 +81,11 @@ tommy_hashdyn_init - 8397 + 8463 tommy_hashdyn_done - 7701 + 7767 tommy_hashdyn_remove @@ -93,7 +93,7 @@ tommy_hashdyn_foreach - 238 + 240 tommy_hashdyn_foreach_arg diff --git a/cov/tommyds/tommyhashdyn.c.func.html b/cov/tommyds/tommyhashdyn.c.func.html index d3cc0bca..6672ac71 100644 --- a/cov/tommyds/tommyhashdyn.c.func.html +++ b/cov/tommyds/tommyhashdyn.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 @@ -61,19 +61,19 @@ hashdyn_grow_step - 13012162 + 13012047 hashdyn_shrink_step - 299207 + 296484 tommy_hashdyn_done - 7701 + 7767 tommy_hashdyn_foreach - 238 + 240 tommy_hashdyn_foreach_arg @@ -81,11 +81,11 @@ tommy_hashdyn_init - 8397 + 8463 tommy_hashdyn_insert - 13012162 + 13012047 tommy_hashdyn_memory_usage @@ -97,7 +97,7 @@ tommy_hashdyn_remove_existing - 299079 + 296356 tommy_hashdyn_resize diff --git a/cov/tommyds/tommyhashdyn.c.gcov.html b/cov/tommyds/tommyhashdyn.c.gcov.html index 6e43758a..5d862bee 100644 --- a/cov/tommyds/tommyhashdyn.c.gcov.html +++ b/cov/tommyds/tommyhashdyn.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 11 @@ -93,21 +93,21 @@ 31 : /******************************************************************************/ 32 : /* hashdyn */ 33 : - 34 8397 : void tommy_hashdyn_init(tommy_hashdyn* hashdyn) + 34 8463 : void tommy_hashdyn_init(tommy_hashdyn* hashdyn) 35 : { 36 : /* fixed initial size */ - 37 8397 : hashdyn->bucket_bit = TOMMY_HASHDYN_BIT; - 38 8397 : hashdyn->bucket_max = 1 << hashdyn->bucket_bit; - 39 8397 : hashdyn->bucket_mask = hashdyn->bucket_max - 1; - 40 8397 : hashdyn->bucket = tommy_cast(tommy_hashdyn_node**, tommy_calloc(hashdyn->bucket_max, sizeof(tommy_hashdyn_node*))); + 37 8463 : hashdyn->bucket_bit = TOMMY_HASHDYN_BIT; + 38 8463 : hashdyn->bucket_max = 1 << hashdyn->bucket_bit; + 39 8463 : hashdyn->bucket_mask = hashdyn->bucket_max - 1; + 40 8463 : hashdyn->bucket = tommy_cast(tommy_hashdyn_node**, tommy_calloc(hashdyn->bucket_max, sizeof(tommy_hashdyn_node*))); 41 : - 42 8397 : hashdyn->count = 0; - 43 8397 : } + 42 8463 : hashdyn->count = 0; + 43 8463 : } 44 : - 45 7701 : void tommy_hashdyn_done(tommy_hashdyn* hashdyn) + 45 7767 : void tommy_hashdyn_done(tommy_hashdyn* hashdyn) 46 : { - 47 7701 : tommy_free(hashdyn->bucket); - 48 7701 : } + 47 7767 : tommy_free(hashdyn->bucket); + 48 7767 : } 49 : 50 : /** 51 : * Resize the bucket vector. @@ -148,9 +148,9 @@ 86 15817024 : tommy_hashdyn_node* j_next = j->next; 87 15817024 : tommy_count_t pos = j->key & new_bucket_mask; 88 15817024 : if (new_bucket[pos]) - 89 1907725 : tommy_list_insert_tail_not_empty(new_bucket[pos], j); + 89 1892940 : tommy_list_insert_tail_not_empty(new_bucket[pos], j); 90 : else - 91 13909299 : tommy_list_insert_first(&new_bucket[pos], j); + 91 13924084 : tommy_list_insert_first(&new_bucket[pos], j); 92 15817024 : j = j_next; 93 : } 94 : } @@ -179,47 +179,47 @@ 117 : /** 118 : * Grow. 119 : */ - 120 13012162 : tommy_inline void hashdyn_grow_step(tommy_hashdyn* hashdyn) + 120 13012047 : tommy_inline void hashdyn_grow_step(tommy_hashdyn* hashdyn) 121 : { 122 : /* grow if more than 50% full */ - 123 13012162 : if (hashdyn->count >= hashdyn->bucket_max / 2) + 123 13012047 : if (hashdyn->count >= hashdyn->bucket_max / 2) 124 40334 : tommy_hashdyn_resize(hashdyn, hashdyn->bucket_bit + 1); - 125 13012162 : } + 125 13012047 : } 126 : 127 : /** 128 : * Shrink. 129 : */ - 130 299207 : tommy_inline void hashdyn_shrink_step(tommy_hashdyn* hashdyn) + 130 296484 : tommy_inline void hashdyn_shrink_step(tommy_hashdyn* hashdyn) 131 : { 132 : /* shrink if less than 12.5% full */ - 133 299207 : if (hashdyn->count <= hashdyn->bucket_max / 8 && hashdyn->bucket_bit > TOMMY_HASHDYN_BIT) + 133 296484 : if (hashdyn->count <= hashdyn->bucket_max / 8 && hashdyn->bucket_bit > TOMMY_HASHDYN_BIT) 134 49 : tommy_hashdyn_resize(hashdyn, hashdyn->bucket_bit - 1); - 135 299207 : } + 135 296484 : } 136 : - 137 13012162 : void tommy_hashdyn_insert(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node, void* data, tommy_hash_t hash) + 137 13012047 : void tommy_hashdyn_insert(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node, void* data, tommy_hash_t hash) 138 : { - 139 13012162 : tommy_count_t pos = hash & hashdyn->bucket_mask; + 139 13012047 : tommy_count_t pos = hash & hashdyn->bucket_mask; 140 : - 141 13012162 : tommy_list_insert_tail(&hashdyn->bucket[pos], node, data); + 141 13012047 : tommy_list_insert_tail(&hashdyn->bucket[pos], node, data); 142 : - 143 13012162 : node->key = hash; + 143 13012047 : node->key = hash; 144 : - 145 13012162 : ++hashdyn->count; + 145 13012047 : ++hashdyn->count; 146 : - 147 13012162 : hashdyn_grow_step(hashdyn); - 148 13012162 : } + 147 13012047 : hashdyn_grow_step(hashdyn); + 148 13012047 : } 149 : - 150 299079 : void* tommy_hashdyn_remove_existing(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node) + 150 296356 : void* tommy_hashdyn_remove_existing(tommy_hashdyn* hashdyn, tommy_hashdyn_node* node) 151 : { - 152 299079 : tommy_count_t pos = node->key & hashdyn->bucket_mask; + 152 296356 : tommy_count_t pos = node->key & hashdyn->bucket_mask; 153 : - 154 299079 : tommy_list_remove_existing(&hashdyn->bucket[pos], node); + 154 296356 : tommy_list_remove_existing(&hashdyn->bucket[pos], node); 155 : - 156 299079 : --hashdyn->count; + 156 296356 : --hashdyn->count; 157 : - 158 299079 : hashdyn_shrink_step(hashdyn); + 158 296356 : hashdyn_shrink_step(hashdyn); 159 : - 160 299079 : return node->data; + 160 296356 : 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 238 : void tommy_hashdyn_foreach(tommy_hashdyn* hashdyn, tommy_foreach_func* func) + 185 240 : void tommy_hashdyn_foreach(tommy_hashdyn* hashdyn, tommy_foreach_func* func) 186 : { - 187 238 : tommy_count_t bucket_max = hashdyn->bucket_max; - 188 238 : tommy_hashdyn_node** bucket = hashdyn->bucket; + 187 240 : tommy_count_t bucket_max = hashdyn->bucket_max; + 188 240 : tommy_hashdyn_node** bucket = hashdyn->bucket; 189 : tommy_count_t pos; 190 : - 191 5812382 : for (pos = 0; pos < bucket_max; ++pos) { - 192 5812144 : tommy_hashdyn_node* node = bucket[pos]; + 191 5812416 : for (pos = 0; pos < bucket_max; ++pos) { + 192 5812176 : tommy_hashdyn_node* node = bucket[pos]; 193 : - 194 13484803 : while (node) { - 195 1860515 : void* data = node->data; - 196 1860515 : node = node->next; - 197 1860515 : func(data); + 194 13485558 : while (node) { + 195 1861206 : void* data = node->data; + 196 1861206 : node = node->next; + 197 1861206 : func(data); 198 : } 199 : } - 200 238 : } + 200 240 : } 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 58911c95..b4284515 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-01-09 + 2016-01-16 Functions: 3 @@ -61,11 +61,11 @@ tommy_hashdyn_bucket - 3059036 + 3056605 tommy_hashdyn_search - 3059036 + 3056605 tommy_hashdyn_count diff --git a/cov/tommyds/tommyhashdyn.h.func.html b/cov/tommyds/tommyhashdyn.h.func.html index a87b29ec..99682a92 100644 --- a/cov/tommyds/tommyhashdyn.h.func.html +++ b/cov/tommyds/tommyhashdyn.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -61,7 +61,7 @@ tommy_hashdyn_bucket - 3059036 + 3056605 tommy_hashdyn_count @@ -69,7 +69,7 @@ tommy_hashdyn_search - 3059036 + 3056605
diff --git a/cov/tommyds/tommyhashdyn.h.gcov.html b/cov/tommyds/tommyhashdyn.h.gcov.html index 0751c333..03ddea7e 100644 --- a/cov/tommyds/tommyhashdyn.h.gcov.html +++ b/cov/tommyds/tommyhashdyn.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 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 3059036 : tommy_inline tommy_hashdyn_node* tommy_hashdyn_bucket(tommy_hashdyn* hashdyn, tommy_hash_t hash) + 208 3056605 : tommy_inline tommy_hashdyn_node* tommy_hashdyn_bucket(tommy_hashdyn* hashdyn, tommy_hash_t hash) 209 : { - 210 3059036 : return hashdyn->bucket[hash & hashdyn->bucket_mask]; + 210 3056605 : 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 3059036 : tommy_inline void* tommy_hashdyn_search(tommy_hashdyn* hashdyn, tommy_search_func* cmp, const void* cmp_arg, tommy_hash_t hash) + 223 3056605 : tommy_inline void* tommy_hashdyn_search(tommy_hashdyn* hashdyn, tommy_search_func* cmp, const void* cmp_arg, tommy_hash_t hash) 224 : { - 225 3059036 : tommy_hashdyn_node* i = tommy_hashdyn_bucket(hashdyn, hash); + 225 3056605 : tommy_hashdyn_node* i = tommy_hashdyn_bucket(hashdyn, hash); 226 : - 227 6783670 : while (i) { + 227 6779601 : while (i) { 228 : /* we first check if the hash matches, as in the same bucket we may have multiples hash values */ - 229 1775604 : if (i->key == hash && cmp(cmp_arg, i->data) == 0) - 230 1110006 : return i->data; - 231 665598 : i = i->next; + 229 1775042 : if (i->key == hash && cmp(cmp_arg, i->data) == 0) + 230 1108651 : return i->data; + 231 666391 : i = i->next; 232 : } - 233 1949030 : return 0; + 233 1947954 : 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 b292b5c8..a14f7721 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-01-09 + 2016-01-16 Functions: 3 @@ -65,11 +65,11 @@ tommy_list_sort - 2276 + 2300 tommy_list_set - 1558 + 1571
diff --git a/cov/tommyds/tommylist.c.func.html b/cov/tommyds/tommylist.c.func.html index f3b2b5cb..2cf64696 100644 --- a/cov/tommyds/tommylist.c.func.html +++ b/cov/tommyds/tommylist.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -65,11 +65,11 @@ tommy_list_set - 1558 + 1571 tommy_list_sort - 2276 + 2300
diff --git a/cov/tommyds/tommylist.c.gcov.html b/cov/tommyds/tommylist.c.gcov.html index 200bf008..a84ca371 100644 --- a/cov/tommyds/tommylist.c.gcov.html +++ b/cov/tommyds/tommylist.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 3 @@ -97,53 +97,53 @@ 35 : tommy_node* second_head; 36 : 37 63152 : if (tommy_list_empty(second)) - 38 55862 : return; + 38 55947 : return; 39 : - 40 7290 : if (tommy_list_empty(first)) { - 41 6456 : *first = *second; - 42 6456 : return; + 40 7205 : if (tommy_list_empty(first)) { + 41 6351 : *first = *second; + 42 6351 : return; 43 : } 44 : - 45 834 : first_head = tommy_list_head(first); - 46 834 : second_head = tommy_list_head(second); - 47 834 : first_tail = tommy_list_tail(first); + 45 854 : first_head = tommy_list_head(first); + 46 854 : second_head = tommy_list_head(second); + 47 854 : first_tail = tommy_list_tail(first); 48 : 49 : /* set the "circular" prev list */ - 50 834 : first_head->prev = second_head->prev; - 51 834 : second_head->prev = first_tail; + 50 854 : first_head->prev = second_head->prev; + 51 854 : second_head->prev = first_tail; 52 : 53 : /* set the "0 terminated" next list */ - 54 834 : first_tail->next = second_head; + 54 854 : first_tail->next = second_head; 55 : } 56 : 57 : /** \internal 58 : * Setup a list. 59 : */ - 60 1558 : tommy_inline void tommy_list_set(tommy_list* list, tommy_node* head, tommy_node* tail) + 60 1571 : tommy_inline void tommy_list_set(tommy_list* list, tommy_node* head, tommy_node* tail) 61 : { - 62 1558 : head->prev = tail; - 63 1558 : tail->next = 0; - 64 1558 : *list = head; - 65 1558 : } + 62 1571 : head->prev = tail; + 63 1571 : tail->next = 0; + 64 1571 : *list = head; + 65 1571 : } 66 : - 67 2276 : void tommy_list_sort(tommy_list* list, tommy_compare_func* cmp) + 67 2300 : void tommy_list_sort(tommy_list* list, tommy_compare_func* cmp) 68 : { 69 : tommy_chain chain; 70 : tommy_node* head; 71 : - 72 2276 : if (tommy_list_empty(list)) - 73 2994 : return; + 72 2300 : if (tommy_list_empty(list)) + 73 3029 : return; 74 : - 75 1558 : head = tommy_list_head(list); + 75 1571 : head = tommy_list_head(list); 76 : 77 : /* create a chain from the list */ - 78 1558 : chain.head = head; - 79 1558 : chain.tail = head->prev; + 78 1571 : chain.head = head; + 79 1571 : chain.tail = head->prev; 80 : - 81 1558 : tommy_chain_mergesort(&chain, cmp); + 81 1571 : tommy_chain_mergesort(&chain, cmp); 82 : 83 : /* restore the list */ - 84 1558 : tommy_list_set(list, chain.head, chain.tail); + 84 1571 : tommy_list_set(list, chain.head, chain.tail); 85 : } 86 : diff --git a/cov/tommyds/tommylist.h.func-sort-c.html b/cov/tommyds/tommylist.h.func-sort-c.html index 5d6d527a..6f112011 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-01-09 + 2016-01-16 Functions: 10 @@ -61,43 +61,43 @@ tommy_list_head - 24857398 + 24857091 tommy_list_insert_first - 22927997 + 22958148 tommy_list_insert_tail - 18022355 + 18023178 tommy_list_insert_tail_not_empty - 10911382 + 10882054 tommy_list_remove_existing - 359148 + 356425 tommy_list_empty - 74540 + 74517 tommy_list_init - 11303 + 11415 tommy_list_foreach - 7327 + 7391 tommy_list_tail - 835 + 855 tommy_list_count - 249 + 251
diff --git a/cov/tommyds/tommylist.h.func.html b/cov/tommyds/tommylist.h.func.html index 14b14b56..f6bc537a 100644 --- a/cov/tommyds/tommylist.h.func.html +++ b/cov/tommyds/tommylist.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -61,43 +61,43 @@ tommy_list_count - 249 + 251 tommy_list_empty - 74540 + 74517 tommy_list_foreach - 7327 + 7391 tommy_list_head - 24857398 + 24857091 tommy_list_init - 11303 + 11415 tommy_list_insert_first - 22927997 + 22958148 tommy_list_insert_tail - 18022355 + 18023178 tommy_list_insert_tail_not_empty - 10911382 + 10882054 tommy_list_remove_existing - 359148 + 356425 tommy_list_tail - 835 + 855
diff --git a/cov/tommyds/tommylist.h.gcov.html b/cov/tommyds/tommylist.h.gcov.html index b69a338e..6b7dc568 100644 --- a/cov/tommyds/tommylist.h.gcov.html +++ b/cov/tommyds/tommylist.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 10 @@ -173,32 +173,32 @@ 111 : * Initializes the list. 112 : * The list is completely inplace, so it doesn't need to be deinitialized. 113 : */ - 114 11303 : tommy_inline void tommy_list_init(tommy_list* list) + 114 11415 : tommy_inline void tommy_list_init(tommy_list* list) 115 : { - 116 11303 : *list = 0; - 117 11303 : } + 116 11415 : *list = 0; + 117 11415 : } 118 : 119 : /** 120 : * Gets the head of the list. 121 : * \return The head node. For empty lists 0 is returned. 122 : */ - 123 24857398 : tommy_inline tommy_node* tommy_list_head(tommy_list* list) + 123 24857091 : tommy_inline tommy_node* tommy_list_head(tommy_list* list) 124 : { - 125 24857398 : return *list; + 125 24857091 : return *list; 126 : } 127 : 128 : /** 129 : * Gets the tail of the list. 130 : * \return The tail node. For empty lists 0 is returned. 131 : */ - 132 835 : tommy_inline tommy_node* tommy_list_tail(tommy_list* list) + 132 855 : tommy_inline tommy_node* tommy_list_tail(tommy_list* list) 133 : { - 134 835 : tommy_node* head = tommy_list_head(list); + 134 855 : tommy_node* head = tommy_list_head(list); 135 : - 136 835 : if (!head) + 136 855 : if (!head) 137 1 : return 0; 138 : - 139 834 : return head->prev; + 139 854 : return head->prev; 140 : } 141 : 142 : /** \internal @@ -206,16 +206,16 @@ 144 : * \param list The list to initialize. 145 : * \param node The node to insert. 146 : */ - 147 22927997 : tommy_inline void tommy_list_insert_first(tommy_list* list, tommy_node* node) + 147 22958148 : tommy_inline void tommy_list_insert_first(tommy_list* list, tommy_node* node) 148 : { 149 : /* one element "circular" prev list */ - 150 22927997 : node->prev = node; + 150 22958148 : node->prev = node; 151 : 152 : /* one element "0 terminated" next list */ - 153 22927997 : node->next = 0; + 153 22958148 : node->next = 0; 154 : - 155 22927997 : *list = node; - 156 22927997 : } + 155 22958148 : *list = node; + 156 22958148 : } 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 10911382 : tommy_inline void tommy_list_insert_tail_not_empty(tommy_node* head, tommy_node* node) + 184 10882054 : tommy_inline void tommy_list_insert_tail_not_empty(tommy_node* head, tommy_node* node) 185 : { 186 : /* insert in the "circular" prev list */ - 187 10911382 : node->prev = head->prev; - 188 10911382 : head->prev = node; + 187 10882054 : node->prev = head->prev; + 188 10882054 : head->prev = node; 189 : 190 : /* insert in the "0 terminated" next list */ - 191 10911382 : node->next = 0; - 192 10911382 : node->prev->next = node; - 193 10911382 : } + 191 10882054 : node->next = 0; + 192 10882054 : node->prev->next = node; + 193 10882054 : } 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 18022355 : tommy_inline void tommy_list_insert_tail(tommy_list* list, tommy_node* node, void* data) + 217 18023178 : tommy_inline void tommy_list_insert_tail(tommy_list* list, tommy_node* node, void* data) 218 : { - 219 18022355 : tommy_node* head = tommy_list_head(list); + 219 18023178 : tommy_node* head = tommy_list_head(list); 220 : - 221 18022355 : if (head) - 222 9003657 : tommy_list_insert_tail_not_empty(head, node); + 221 18023178 : if (head) + 222 8989114 : tommy_list_insert_tail_not_empty(head, node); 223 : else - 224 9018698 : tommy_list_insert_first(list, node); + 224 9034064 : tommy_list_insert_first(list, node); 225 : - 226 18022355 : node->data = data; - 227 18022355 : } + 226 18023178 : node->data = data; + 227 18023178 : } 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 359148 : tommy_inline void* tommy_list_remove_existing(tommy_list* list, tommy_node* node) + 255 356425 : tommy_inline void* tommy_list_remove_existing(tommy_list* list, tommy_node* node) 256 : { - 257 359148 : tommy_node* head = tommy_list_head(list); + 257 356425 : tommy_node* head = tommy_list_head(list); 258 : 259 : /* remove from the "circular" prev list */ - 260 359148 : if (node->next) - 261 122485 : node->next->prev = node->prev; + 260 356425 : if (node->next) + 261 121876 : node->next->prev = node->prev; 262 : else - 263 236663 : head->prev = node->prev; /* the last */ + 263 234549 : head->prev = node->prev; /* the last */ 264 : 265 : /* remove from the "0 terminated" next list */ - 266 359148 : if (head == node) - 267 252248 : *list = node->next; /* the new head, in case 0 */ + 266 356425 : if (head == node) + 267 249865 : *list = node->next; /* the new head, in case 0 */ 268 : else - 269 106900 : node->prev->next = node->next; + 269 106560 : node->prev->next = node->next; 270 : - 271 359148 : return node->data; + 271 356425 : return node->data; 272 : } 273 : 274 : /** @@ -355,26 +355,26 @@ 293 : * Checks if empty. 294 : * \return If the list is empty. 295 : */ - 296 74540 : tommy_inline tommy_bool_t tommy_list_empty(tommy_list* list) + 296 74517 : tommy_inline tommy_bool_t tommy_list_empty(tommy_list* list) 297 : { - 298 74540 : return tommy_list_head(list) == 0; + 298 74517 : return tommy_list_head(list) == 0; 299 : } 300 : 301 : /** 302 : * Gets the number of elements. 303 : * \note This operation is O(n). 304 : */ - 305 249 : tommy_inline tommy_count_t tommy_list_count(tommy_list* list) + 305 251 : tommy_inline tommy_count_t tommy_list_count(tommy_list* list) 306 : { - 307 249 : tommy_count_t count = 0; - 308 249 : tommy_node* i = tommy_list_head(list); + 307 251 : tommy_count_t count = 0; + 308 251 : tommy_node* i = tommy_list_head(list); 309 : - 310 1987 : while (i) { - 311 1489 : ++count; - 312 1489 : i = i->next; + 310 2003 : while (i) { + 311 1501 : ++count; + 312 1501 : i = i->next; 313 : } 314 : - 315 249 : return count; + 315 251 : return count; 316 : } 317 : 318 : /** @@ -405,16 +405,16 @@ 343 : * tommy_list_foreach(&list, free); 344 : * \endcode 345 : */ - 346 7327 : tommy_inline void tommy_list_foreach(tommy_list* list, tommy_foreach_func* func) + 346 7391 : tommy_inline void tommy_list_foreach(tommy_list* list, tommy_foreach_func* func) 347 : { - 348 7327 : tommy_node* node = tommy_list_head(list); + 348 7391 : tommy_node* node = tommy_list_head(list); 349 : - 350 3598724 : while (node) { - 351 3584070 : void* data = node->data; - 352 3584070 : node = node->next; - 353 3584070 : func(data); + 350 3599533 : while (node) { + 351 3584751 : void* data = node->data; + 352 3584751 : node = node->next; + 353 3584751 : func(data); 354 : } - 355 7327 : } + 355 7391 : } 356 : 357 : /** 358 : * 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 c432723c..06831b4b 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-01-09 + 2016-01-16 Functions: 19 @@ -61,67 +61,67 @@ tommy_tree_search_node - 125457281 + 125320005 tommy_tree_delta - 109388905 + 109396329 tommy_tree_balance - 102241942 + 102242621 tommy_tree_insert_node - 93986144 + 93968378 tommy_tree_foreach_arg_node - 25770381 + 25708149 tommy_tree_search_compare - 11217144 + 11201790 tommy_tree_insert - 7315111 + 7316331 tommy_tree_rotate_left - 7135360 + 7141514 tommy_tree_foreach_node - 6892468 + 6893662 tommy_tree_remove_node - 838361 + 838251 tommy_tree_rotate_right - 218129 + 220314 tommy_tree_move_right - 192710 + 195835 tommy_tree_remove - 83634 + 83648 tommy_tree_foreach_arg - 5677 + 5761 tommy_tree_init - 3051 + 3075 tommy_tree_foreach - 1400 + 1412 tommy_tree_remove_existing diff --git a/cov/tommyds/tommytree.c.func.html b/cov/tommyds/tommytree.c.func.html index 6d0cebe5..16db15e6 100644 --- a/cov/tommyds/tommytree.c.func.html +++ b/cov/tommyds/tommytree.c.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 19 @@ -61,39 +61,39 @@ tommy_tree_balance - 102241942 + 102242621 tommy_tree_delta - 109388905 + 109396329 tommy_tree_foreach - 1400 + 1412 tommy_tree_foreach_arg - 5677 + 5761 tommy_tree_foreach_arg_node - 25770381 + 25708149 tommy_tree_foreach_node - 6892468 + 6893662 tommy_tree_init - 3051 + 3075 tommy_tree_insert - 7315111 + 7316331 tommy_tree_insert_node - 93986144 + 93968378 tommy_tree_memory_usage @@ -101,11 +101,11 @@ tommy_tree_move_right - 192710 + 195835 tommy_tree_remove - 83634 + 83648 tommy_tree_remove_existing @@ -113,15 +113,15 @@ tommy_tree_remove_node - 838361 + 838251 tommy_tree_rotate_left - 7135360 + 7141514 tommy_tree_rotate_right - 218129 + 220314 tommy_tree_search @@ -129,11 +129,11 @@ tommy_tree_search_compare - 11217144 + 11201790 tommy_tree_search_node - 125457281 + 125320005
diff --git a/cov/tommyds/tommytree.c.gcov.html b/cov/tommyds/tommytree.c.gcov.html index 2035f253..3f117534 100644 --- a/cov/tommyds/tommytree.c.gcov.html +++ b/cov/tommyds/tommytree.c.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 19 @@ -94,104 +94,104 @@ 32 : /******************************************************************************/ 33 : /* tree */ 34 : - 35 3051 : void tommy_tree_init(tommy_tree* tree, tommy_compare_func* cmp) + 35 3075 : void tommy_tree_init(tommy_tree* tree, tommy_compare_func* cmp) 36 : { - 37 3051 : tree->root = 0; - 38 3051 : tree->count = 0; - 39 3051 : tree->cmp = cmp; - 40 3051 : } + 37 3075 : tree->root = 0; + 38 3075 : tree->count = 0; + 39 3075 : tree->cmp = cmp; + 40 3075 : } 41 : - 42 109388905 : static int tommy_tree_delta(tommy_tree_node* root) + 42 109396329 : static int tommy_tree_delta(tommy_tree_node* root) 43 : { - 44 109388905 : int left_height = root->prev ? root->prev->key : 0; - 45 109388905 : int right_height = root->next ? root->next->key : 0; + 44 109396329 : int left_height = root->prev ? root->prev->key : 0; + 45 109396329 : int right_height = root->next ? root->next->key : 0; 46 : - 47 109388905 : return left_height - right_height; + 47 109396329 : return left_height - right_height; 48 : } 49 : 50 : /* AVL tree operations */ 51 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node*); 52 : - 53 7135360 : static tommy_tree_node* tommy_tree_rotate_left(tommy_tree_node* root) + 53 7141514 : static tommy_tree_node* tommy_tree_rotate_left(tommy_tree_node* root) 54 : { - 55 7135360 : tommy_tree_node* next = root->next; + 55 7141514 : tommy_tree_node* next = root->next; 56 : - 57 7135360 : root->next = next->prev; + 57 7141514 : root->next = next->prev; 58 : - 59 7135360 : next->prev = tommy_tree_balance(root); + 59 7141514 : next->prev = tommy_tree_balance(root); 60 : - 61 7135360 : return tommy_tree_balance(next); + 61 7141514 : return tommy_tree_balance(next); 62 : } 63 : - 64 218129 : static tommy_tree_node* tommy_tree_rotate_right(tommy_tree_node* root) + 64 220314 : static tommy_tree_node* tommy_tree_rotate_right(tommy_tree_node* root) 65 : { - 66 218129 : tommy_tree_node* prev = root->prev; + 66 220314 : tommy_tree_node* prev = root->prev; 67 : - 68 218129 : root->prev = prev->next; + 68 220314 : root->prev = prev->next; 69 : - 70 218129 : prev->next = tommy_tree_balance(root); + 70 220314 : prev->next = tommy_tree_balance(root); 71 : - 72 218129 : return tommy_tree_balance(prev); + 72 220314 : return tommy_tree_balance(prev); 73 : } 74 : - 75 192710 : static tommy_tree_node* tommy_tree_move_right(tommy_tree_node* root, tommy_tree_node* node) + 75 195835 : static tommy_tree_node* tommy_tree_move_right(tommy_tree_node* root, tommy_tree_node* node) 76 : { - 77 192710 : if (!root) - 78 83506 : return node; + 77 195835 : if (!root) + 78 83520 : return node; 79 : - 80 109204 : root->next = tommy_tree_move_right(root->next, node); + 80 112315 : root->next = tommy_tree_move_right(root->next, node); 81 : - 82 109204 : return tommy_tree_balance(root); + 82 112315 : return tommy_tree_balance(root); 83 : } 84 : - 85 102241942 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node* root) + 85 102242621 : static tommy_tree_node* tommy_tree_balance(tommy_tree_node* root) 86 : { - 87 102241942 : int delta = tommy_tree_delta(root); + 87 102242621 : int delta = tommy_tree_delta(root); 88 : - 89 102241942 : if (delta < -1) { - 90 6971745 : if (tommy_tree_delta(root->next) > 0) - 91 42911 : root->next = tommy_tree_rotate_right(root->next); - 92 6971745 : return tommy_tree_rotate_left(root); + 89 102242621 : if (delta < -1) { + 90 6977761 : if (tommy_tree_delta(root->next) > 0) + 91 44367 : root->next = tommy_tree_rotate_right(root->next); + 92 6977761 : return tommy_tree_rotate_left(root); 93 : } 94 : - 95 95270197 : if (delta > 1) { - 96 175218 : if (tommy_tree_delta(root->prev) < 0) - 97 163615 : root->prev = tommy_tree_rotate_left(root->prev); - 98 175218 : return tommy_tree_rotate_right(root); + 95 95264860 : if (delta > 1) { + 96 175947 : if (tommy_tree_delta(root->prev) < 0) + 97 163753 : root->prev = tommy_tree_rotate_left(root->prev); + 98 175947 : return tommy_tree_rotate_right(root); 99 : } 100 : 101 : /* recompute key */ - 102 95094979 : root->key = 0; + 102 95088913 : root->key = 0; 103 : - 104 95094979 : if (root->prev && root->prev->key > root->key) - 105 77186914 : root->key = root->prev->key; + 104 95088913 : if (root->prev && root->prev->key > root->key) + 105 77176023 : root->key = root->prev->key; 106 : - 107 95094979 : if (root->next && root->next->key > root->key) - 108 43098001 : root->key = root->next->key; + 107 95088913 : if (root->next && root->next->key > root->key) + 108 43051271 : root->key = root->next->key; 109 : 110 : /* count itself */ - 111 95094979 : root->key += 1; + 111 95088913 : root->key += 1; 112 : - 113 95094979 : return root; + 113 95088913 : return root; 114 : } 115 : - 116 93986144 : static tommy_tree_node* tommy_tree_insert_node(tommy_compare_func* cmp, tommy_tree_node* root, tommy_tree_node** let) + 116 93968378 : 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 93986144 : if (!root) - 121 7315110 : return *let; + 120 93968378 : if (!root) + 121 7316330 : return *let; 122 : - 123 86671034 : c = cmp((*let)->data, root->data); + 123 86652048 : c = cmp((*let)->data, root->data); 124 : - 125 86671034 : if (c < 0) { - 126 2767362 : root->prev = tommy_tree_insert_node(cmp, root->prev, let); - 127 2767362 : return tommy_tree_balance(root); + 125 86652048 : if (c < 0) { + 126 2771238 : root->prev = tommy_tree_insert_node(cmp, root->prev, let); + 127 2771238 : return tommy_tree_balance(root); 128 : } 129 : - 130 83903672 : if (c > 0) { - 131 83903671 : root->next = tommy_tree_insert_node(cmp, root->next, let); - 132 83903671 : return tommy_tree_balance(root); + 130 83880810 : if (c > 0) { + 131 83880809 : root->next = tommy_tree_insert_node(cmp, root->next, let); + 132 83880809 : 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 7315111 : void* tommy_tree_insert(tommy_tree* tree, tommy_tree_node* node, void* data) + 141 7316331 : void* tommy_tree_insert(tommy_tree* tree, tommy_tree_node* node, void* data) 142 : { - 143 7315111 : tommy_tree_node* insert = node; + 143 7316331 : tommy_tree_node* insert = node; 144 : - 145 7315111 : insert->data = data; - 146 7315111 : insert->prev = 0; - 147 7315111 : insert->next = 0; - 148 7315111 : insert->key = 0; + 145 7316331 : insert->data = data; + 146 7316331 : insert->prev = 0; + 147 7316331 : insert->next = 0; + 148 7316331 : insert->key = 0; 149 : - 150 7315111 : tree->root = tommy_tree_insert_node(tree->cmp, tree->root, &insert); + 150 7316331 : tree->root = tommy_tree_insert_node(tree->cmp, tree->root, &insert); 151 : - 152 7315111 : if (insert == node) - 153 7315110 : ++tree->count; + 152 7316331 : if (insert == node) + 153 7316330 : ++tree->count; 154 : - 155 7315111 : return node->data; + 155 7316331 : return node->data; 156 : } 157 : - 158 838361 : static tommy_tree_node* tommy_tree_remove_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data, tommy_tree_node** let) + 158 838251 : 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 838361 : if (!root) + 162 838251 : if (!root) 163 128 : return 0; 164 : - 165 838233 : c = cmp(data, root->data); + 165 838123 : c = cmp(data, root->data); 166 : - 167 838233 : if (c < 0) { - 168 330789 : root->prev = tommy_tree_remove_node(cmp, root->prev, data, let); - 169 330789 : return tommy_tree_balance(root); + 167 838123 : if (c < 0) { + 168 324396 : root->prev = tommy_tree_remove_node(cmp, root->prev, data, let); + 169 324396 : return tommy_tree_balance(root); 170 : } 171 : - 172 507444 : if (c > 0) { - 173 423938 : root->next = tommy_tree_remove_node(cmp, root->next, data, let); - 174 423938 : return tommy_tree_balance(root); + 172 513727 : if (c > 0) { + 173 430207 : root->next = tommy_tree_remove_node(cmp, root->next, data, let); + 174 430207 : return tommy_tree_balance(root); 175 : } 176 : 177 : /* found */ - 178 83506 : *let = root; + 178 83520 : *let = root; 179 : - 180 83506 : return tommy_tree_move_right(root->prev, root->next); + 180 83520 : return tommy_tree_move_right(root->prev, root->next); 181 : } 182 : - 183 83634 : void* tommy_tree_remove(tommy_tree* tree, void* data) + 183 83648 : void* tommy_tree_remove(tommy_tree* tree, void* data) 184 : { - 185 83634 : tommy_tree_node* node = 0; + 185 83648 : tommy_tree_node* node = 0; 186 : - 187 83634 : tree->root = tommy_tree_remove_node(tree->cmp, tree->root, data, &node); + 187 83648 : tree->root = tommy_tree_remove_node(tree->cmp, tree->root, data, &node); 188 : - 189 83634 : if (!node) + 189 83648 : if (!node) 190 128 : return 0; 191 : - 192 83506 : --tree->count; + 192 83520 : --tree->count; 193 : - 194 83506 : return node->data; + 194 83520 : return node->data; 195 : } 196 : - 197 125457281 : static tommy_tree_node* tommy_tree_search_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data) + 197 125320005 : static tommy_tree_node* tommy_tree_search_node(tommy_compare_func* cmp, tommy_tree_node* root, void* data) 198 : { 199 : int c; 200 : - 201 125457281 : if (!root) - 202 1561728 : return 0; + 201 125320005 : if (!root) + 202 1580664 : return 0; 203 : - 204 123895553 : c = cmp(data, root->data); + 204 123739341 : c = cmp(data, root->data); 205 : - 206 123895553 : if (c < 0) - 207 44385963 : return tommy_tree_search_node(cmp, root->prev, data); + 206 123739341 : if (c < 0) + 207 44250308 : return tommy_tree_search_node(cmp, root->prev, data); 208 : - 209 79509590 : if (c > 0) - 210 69854172 : return tommy_tree_search_node(cmp, root->next, data); + 209 79489033 : if (c > 0) + 210 69867905 : return tommy_tree_search_node(cmp, root->next, data); 211 : - 212 9655418 : return root; + 212 9621128 : 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 11217144 : void* tommy_tree_search_compare(tommy_tree* tree, tommy_compare_func* cmp, void* cmp_arg) + 225 11201790 : void* tommy_tree_search_compare(tommy_tree* tree, tommy_compare_func* cmp, void* cmp_arg) 226 : { - 227 11217144 : tommy_tree_node* node = tommy_tree_search_node(cmp, tree->root, cmp_arg); + 227 11201790 : tommy_tree_node* node = tommy_tree_search_node(cmp, tree->root, cmp_arg); 228 : - 229 11217144 : if (!node) - 230 1561727 : return 0; + 229 11201790 : if (!node) + 230 1580663 : return 0; 231 : - 232 9655417 : return node->data; + 232 9621127 : 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 6892468 : static void tommy_tree_foreach_node(tommy_tree_node* root, tommy_foreach_func* func) + 244 6893662 : static void tommy_tree_foreach_node(tommy_tree_node* root, tommy_foreach_func* func) 245 : { 246 : tommy_tree_node* next; 247 : - 248 6892468 : if (!root) - 249 10339402 : return; + 248 6893662 : if (!root) + 249 10341199 : return; 250 : - 251 3445534 : tommy_tree_foreach_node(root->prev, func); + 251 3446125 : tommy_tree_foreach_node(root->prev, func); 252 : 253 : /* make a copy in case func is free() */ - 254 3445534 : next = root->next; + 254 3446125 : next = root->next; 255 : - 256 3445534 : func(root->data); + 256 3446125 : func(root->data); 257 : - 258 3445534 : tommy_tree_foreach_node(next, func); + 258 3446125 : tommy_tree_foreach_node(next, func); 259 : } 260 : - 261 1400 : void tommy_tree_foreach(tommy_tree* tree, tommy_foreach_func* func) + 261 1412 : void tommy_tree_foreach(tommy_tree* tree, tommy_foreach_func* func) 262 : { - 263 1400 : tommy_tree_foreach_node(tree->root, func); - 264 1400 : } + 263 1412 : tommy_tree_foreach_node(tree->root, func); + 264 1412 : } 265 : - 266 25770381 : static void tommy_tree_foreach_arg_node(tommy_tree_node* root, tommy_foreach_arg_func* func, void* arg) + 266 25708149 : 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 25770381 : if (!root) - 271 38658410 : return; + 270 25708149 : if (!root) + 271 38565104 : return; 272 : - 273 12882352 : tommy_tree_foreach_arg_node(root->prev, func, arg); + 273 12851194 : tommy_tree_foreach_arg_node(root->prev, func, arg); 274 : 275 : /* make a copy in case func is free() */ - 276 12882352 : next = root->next; + 276 12851194 : next = root->next; 277 : - 278 12882352 : func(arg, root->data); + 278 12851194 : func(arg, root->data); 279 : - 280 12882352 : tommy_tree_foreach_arg_node(next, func, arg); + 280 12851194 : tommy_tree_foreach_arg_node(next, func, arg); 281 : } 282 : - 283 5677 : void tommy_tree_foreach_arg(tommy_tree* tree, tommy_foreach_arg_func* func, void* arg) + 283 5761 : void tommy_tree_foreach_arg(tommy_tree* tree, tommy_foreach_arg_func* func, void* arg) 284 : { - 285 5677 : tommy_tree_foreach_arg_node(tree->root, func, arg); - 286 5677 : } + 285 5761 : tommy_tree_foreach_arg_node(tree->root, func, arg); + 286 5761 : } 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 6e568820..f5b95c8b 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-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/tommyds/tommytree.h.func.html b/cov/tommyds/tommytree.h.func.html index e8884ad1..85584081 100644 --- a/cov/tommyds/tommytree.h.func.html +++ b/cov/tommyds/tommytree.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/tommyds/tommytree.h.gcov.html b/cov/tommyds/tommytree.h.gcov.html index 637a5c9c..6a284c0f 100644 --- a/cov/tommyds/tommytree.h.gcov.html +++ b/cov/tommyds/tommytree.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 1 diff --git a/cov/tommyds/tommytypes.h.func-sort-c.html b/cov/tommyds/tommytypes.h.func-sort-c.html index 473c3b65..67c4ba0c 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-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_ilog2_u32 - 10133914 + 10127992 tommy_ctz_u32 - 1558 + 1571
diff --git a/cov/tommyds/tommytypes.h.func.html b/cov/tommyds/tommytypes.h.func.html index be1af3e9..7f246b45 100644 --- a/cov/tommyds/tommytypes.h.func.html +++ b/cov/tommyds/tommytypes.h.func.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -61,11 +61,11 @@ tommy_ctz_u32 - 1558 + 1571 tommy_ilog2_u32 - 10133914 + 10127992
diff --git a/cov/tommyds/tommytypes.h.gcov.html b/cov/tommyds/tommytypes.h.gcov.html index 52e2afdd..6646aa46 100644 --- a/cov/tommyds/tommytypes.h.gcov.html +++ b/cov/tommyds/tommytypes.h.gcov.html @@ -37,7 +37,7 @@ Date: - 2016-01-09 + 2016-01-16 Functions: 2 @@ -385,7 +385,7 @@ 323 : * \param value Value to scan. 0 is not allowed. 324 : * \return The index of the most significant bit set. 325 : */ - 326 10133914 : tommy_inline tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value) + 326 10127992 : tommy_inline tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value) 327 : { 328 : #if defined(_MSC_VER) 329 : unsigned long count; @@ -401,7 +401,7 @@ 339 : * So we write "__builtin_clz(x) ^ 31" instead of "31 - __builtin_clz(x)", 340 : * to allow the double xor to be optimized out. 341 : */ - 342 10133914 : return __builtin_clz(value) ^ 31; + 342 10127992 : return __builtin_clz(value) ^ 31; 343 : #else 344 : /* Find the log base 2 of an N-bit integer in O(lg(N)) operations with multiply and lookup */ 345 : /* from http://graphics.stanford.edu/~seander/bithacks.html */ @@ -428,14 +428,14 @@ 366 : * \param value Value to scan. 0 is not allowed. 367 : * \return The index of the least significant bit set. 368 : */ - 369 1558 : tommy_inline tommy_uint_t tommy_ctz_u32(tommy_uint32_t value) + 369 1571 : tommy_inline tommy_uint_t tommy_ctz_u32(tommy_uint32_t value) 370 : { 371 : #if defined(_MSC_VER) 372 : unsigned long count; 373 : _BitScanForward(&count, value); 374 : return count; 375 : #elif defined(__GNUC__) - 376 1558 : return __builtin_ctz(value); + 376 1571 : return __builtin_ctz(value); 377 : #else 378 : /* Count the consecutive zero bits (trailing) on the right with multiply and lookup */ 379 : /* from http://graphics.stanford.edu/~seander/bithacks.html */ diff --git a/download.html b/download.html index dbd82325..a0dc2900 100644 --- a/download.html +++ b/download.html @@ -50,17 +50,17 @@ If you like to use a GUI, you can try E diff --git a/index.html b/index.html index 9bbf94e0..53aa9ee3 100644 --- a/index.html +++ b/index.html @@ -86,7 +86,7 @@ Now go to Download.

-News! Version 9.2 RELEASED! +News! Version 9.3 RELEASED!

FileDescription
-snapraid-9.2.tar.gz +snapraid-9.3.tar.gz Sources for Linux, Mac OS X, BSD, Solaris, OpenIndiana and any other Unix
-snapraid-9.2-windows-x64.zip +snapraid-9.3-windows-x64.zip Binaries for Windows x64 (the most recent Windows versions)
-snapraid-9.2-windows-x86.zip +snapraid-9.3-windows-x86.zip Binaries for Windows x86