mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Migrate block_off_t to 64-bit with updated CLI parsing, VLQ serialization, and format specifiers
This commit is contained in:
parent
76998613da
commit
bbd3c23cd2
13 changed files with 273 additions and 272 deletions
|
|
@ -137,9 +137,9 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
* This one is really an unexpected error, because we are only reading
|
||||
* and closing a descriptor should never fail
|
||||
*/
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
++io_error;
|
||||
|
|
@ -153,7 +153,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
|
||||
ret = handle_open(&handle[j], file, state->file_mode, 0);
|
||||
if (ret == -1) {
|
||||
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
if (errno == ENOENT) {
|
||||
log_error_errno(errno, disk->name);
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
} else {
|
||||
log_fatal(errno, "Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub));
|
||||
|
|
@ -194,14 +194,14 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
|| handle[j].st.st_ino != file->inode
|
||||
) {
|
||||
if (handle[j].st.st_size != file->size) {
|
||||
log_tag("error:%u:%s:%s: Unexpected size change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_tag("error:%" PRIu64 ":%s:%s: Unexpected size change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(ESOFT, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, (uint64_t)handle[j].st.st_size);
|
||||
} else if (handle[j].st.st_mtime != file->mtime_sec
|
||||
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
|
||||
log_tag("error:%u:%s:%s: Unexpected time change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_tag("error:%" PRIu64 ":%s:%s: Unexpected time change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(ESOFT, "Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, STAT_NSEC(&handle[j].st));
|
||||
} else {
|
||||
log_tag("error:%u:%s:%s: Unexpected inode change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_tag("error:%" PRIu64 ":%s:%s: Unexpected inode change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(ESOFT, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
}
|
||||
log_error_errno(ENOENT, disk->name); /* same message for ENOENT */
|
||||
|
|
@ -218,11 +218,11 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
read_size = handle_read(&handle[j], file_pos, buffer, state->block_size, 0);
|
||||
if (read_size == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), file_pos, strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Read error at position %" PRIu64 ". %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), file_pos, strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
} else {
|
||||
log_fatal(errno, "Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub));
|
||||
|
|
@ -252,8 +252,8 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
if (block_state == BLOCK_STATE_REP) {
|
||||
/* compare the hash */
|
||||
if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) {
|
||||
log_tag("error_data:%u:%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(EDATA, "Data change at file '%s' at position '%u'\n", handle[j].path, file_pos);
|
||||
log_tag("error_data:%" PRIu64 ":%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(EDATA, "Data change at file '%s' at position '%" PRIu64 "'\n", handle[j].path, file_pos);
|
||||
log_error(EDATA, "WARNING! Unexpected data modification of a file without parity!\n");
|
||||
|
||||
if (file_flag_has(file, FILE_IS_COPY)) {
|
||||
|
|
@ -305,9 +305,9 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
* This one is really an unexpected error, because we are only reading
|
||||
* and closing a descriptor should never fail
|
||||
*/
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockmax, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockmax, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockmax);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockmax);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
++io_error;
|
||||
|
|
@ -354,7 +354,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
|
|
@ -506,9 +506,9 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
* This one is really an unexpected error, because we are only reading
|
||||
* and closing a descriptor should never fail
|
||||
*/
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
|
|
@ -522,7 +522,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
|
||||
ret = handle_open(handle, task->file, state->file_mode, 0);
|
||||
if (ret == -1) {
|
||||
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), strerror(errno));
|
||||
if (errno == ENOENT) {
|
||||
log_error_errno(errno, disk->name);
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
} else {
|
||||
log_fatal(errno, "Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, task->file->sub));
|
||||
|
|
@ -562,7 +562,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
|| STAT_NSEC(&handle->st) != task->file->mtime_nsec
|
||||
|| handle->st.st_ino != task->file->inode
|
||||
) {
|
||||
log_tag("error:%u:%s:%s: Unexpected attribute change\n", blockcur, disk->name, esc_tag(task->file->sub));
|
||||
log_tag("error:%" PRIu64 ":%s:%s: Unexpected attribute change\n", blockcur, disk->name, esc_tag(task->file->sub));
|
||||
if (handle->st.st_size != task->file->size) {
|
||||
log_error(ESOFT, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle->path, task->file->size, (uint64_t)handle->st.st_size);
|
||||
} else if (handle->st.st_mtime != task->file->mtime_sec
|
||||
|
|
@ -584,7 +584,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, 0);
|
||||
if (task->read_size == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), task->file_pos, strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Read error at position %" PRIu64 ". %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), task->file_pos, strerror(errno));
|
||||
|
||||
if (is_hw(errno)) {
|
||||
log_fatal_errno(errno, disk->name);
|
||||
|
|
@ -619,7 +619,7 @@ static void sync_parity_writer(struct snapraid_worker* worker, struct snapraid_t
|
|||
ret = parity_write(parity_handle, blockcur, buffer, state->block_size);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("parity_%s:%u:%s: Write error. %s.\n", es(errno), blockcur, lev_config_name(level), strerror(errno));
|
||||
log_tag("parity_%s:%" PRIu64 ":%s: Write error. %s.\n", es(errno), blockcur, lev_config_name(level), strerror(errno));
|
||||
|
||||
if (is_hw(errno)) {
|
||||
log_fatal_errno(errno, lev_config_name(level));
|
||||
|
|
@ -627,7 +627,7 @@ static void sync_parity_writer(struct snapraid_worker* worker, struct snapraid_t
|
|||
task->state = TASK_STATE_IOERROR_CONTINUE;
|
||||
} else {
|
||||
log_fatal_errno(errno, lev_config_name(level));
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
task->state = TASK_STATE_ERROR;
|
||||
}
|
||||
return;
|
||||
|
|
@ -906,7 +906,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -943,8 +943,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) {
|
||||
/* if the file has invalid parity, it's a REP changed during the sync */
|
||||
if (block_has_invalid_parity(block)) {
|
||||
log_tag("error:%u:%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(ESOFT, "Data change at file '%s' at position '%u'\n", task->path, file_pos);
|
||||
log_tag("error:%" PRIu64 ":%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub));
|
||||
log_error(ESOFT, "Data change at file '%s' at position '%" PRIu64 "'\n", task->path, file_pos);
|
||||
log_error(ESOFT, "WARNING! Unexpected data modification of a file without parity!\n");
|
||||
|
||||
if (file_flag_has(file, FILE_IS_COPY)) {
|
||||
|
|
@ -966,8 +966,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
continue;
|
||||
} else { /* otherwise it's a BLK with silent error */
|
||||
unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE);
|
||||
log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%zu\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%zu\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_tag("error_data:%" PRIu64 ":%s:%s: Data error at position %" PRIu64 ", diff hash bits %u/%zu\n", blockcur, disk->name, esc_tag(file->sub), file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error(EDATA, "Data error in file '%s' at position '%" PRIu64 "', diff hash bits %u/%zu\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
|
||||
/* save the failed block for the fix */
|
||||
failed[failed_count].index = diskcur;
|
||||
|
|
@ -1117,12 +1117,12 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = parity_read(&parity_handle[l], blockcur, buffer[diskmax + l], state->block_size);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(l), strerror(errno));
|
||||
log_tag("parity_%s:%" PRIu64 ":%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(l), strerror(errno));
|
||||
if (is_hw(errno)) {
|
||||
log_fatal_errno(errno, lev_config_name(l));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
log_fatal(errno, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_config_name(l));
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
|
@ -1133,7 +1133,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
log_fatal_errno(errno, lev_config_name(l));
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++soft_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1313,7 +1313,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in a parity disk. It isn't possible to continue.\n");
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1359,7 +1359,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1396,7 +1396,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1422,7 +1422,7 @@ end:
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %" PRIu64 "\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1485,7 +1485,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (is_hw(errno)) {
|
||||
|
|
@ -1548,7 +1548,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal(EUSER, "Error in the starting block %u. It is larger than the parity size %u.\n", blockstart, blockmax);
|
||||
log_fatal(EUSER, "Error in the starting block %" PRIu64 ". It is larger than the parity size %" PRIu64 ".\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1578,7 +1578,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
/* if the file is too small */
|
||||
if (parityblocks < used_paritymax) {
|
||||
log_fatal(ESOFT, "WARNING! The %s parity has only %u blocks instead of %u.\n", lev_name(l), parityblocks, used_paritymax);
|
||||
log_fatal(ESOFT, "WARNING! The %s parity has only %" PRIu64 " blocks instead of %" PRIu64 ".\n", lev_name(l), parityblocks, used_paritymax);
|
||||
}
|
||||
|
||||
/* keep the smallest parity number of blocks */
|
||||
|
|
@ -1701,7 +1701,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
ret = parity_close(&parity_handle[l]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("parity_%s:%u:%s: Close error. %s.\n", es(errno), blockmax, lev_config_name(l), strerror(errno));
|
||||
log_tag("parity_%s:%" PRIu64 ":%s: Close error. %s.\n", es(errno), blockmax, lev_config_name(l), strerror(errno));
|
||||
log_fatal_errno(errno, lev_config_name(l));
|
||||
|
||||
++process_error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue