mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-25 17:36:26 -05:00
Introduce a new messaging system
This commit is contained in:
parent
fa5f31ddf9
commit
e56de653da
33 changed files with 1642 additions and 1518 deletions
|
|
@ -102,14 +102,14 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
|
||||
if (file->blockmax > 0) {
|
||||
if (file->blockvec[file->blockmax - 1].parity_pos >= blockalloc) {
|
||||
ftag("outofparity:%s:%s\n", disk->name, esc(file->sub));
|
||||
fflush_log();
|
||||
msg_tag("outofparity:%s:%s\n", disk->name, esc(file->sub));
|
||||
msg_flush();
|
||||
if (first) {
|
||||
first = 0;
|
||||
fout("\nYour data requires more parity than the available space.\n");
|
||||
fout("Please move the following files to another data disk:\n");
|
||||
msg_warning("\nYour data requires more parity than the available space.\n");
|
||||
msg_warning("Please move the files 'outofparity' to another data disk:\n");
|
||||
}
|
||||
fout("outofparity %s%s\n", disk->dir, file->sub);
|
||||
msg_warning("outofparity %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
|
|||
parity->f = open(parity->path, flags, 0600);
|
||||
if (parity->f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
|
|||
ret = fstat(parity->f, &parity->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
|
|||
ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
msg_error("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
|
|||
ret = fstat(parity->f, &parity->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -239,9 +239,9 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
|
|||
if (f_ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (f_errno == ENOSPC) {
|
||||
ferr("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
|
||||
msg_error("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
|
||||
} else {
|
||||
ferr("Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
|
||||
msg_error("Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
|
||||
}
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -261,7 +261,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
|
|||
ret = fstat(parity->f, &parity->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
|
|||
/* now check the error */
|
||||
if (f_ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
|
||||
msg_error("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
|
|||
flags |= O_SEQUENTIAL;
|
||||
parity->f = open_noatime(parity->path, flags);
|
||||
if (parity->f == -1) {
|
||||
ferr("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
|
|||
ret = fstat(parity->f, &parity->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
|
|||
ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
msg_error("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ int parity_sync(struct snapraid_parity_handle* parity)
|
|||
ret = fsync(parity->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
ferr("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -379,7 +379,7 @@ int parity_close(struct snapraid_parity_handle* parity)
|
|||
/* This is a serious error, as it may be the result of a failed write */
|
||||
/* identified at later time. */
|
||||
/* In a normal filesystem (not NFS) it should never happen */
|
||||
ferr("Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -404,9 +404,9 @@ int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigne
|
|||
if (lseek(parity->f, offset, SEEK_SET) != offset) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOSPC) {
|
||||
ferr("Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
|
||||
msg_error("Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
|
||||
} else {
|
||||
ferr("Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -417,9 +417,9 @@ int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigne
|
|||
if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOSPC) {
|
||||
ferr("Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
|
||||
msg_error("Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
|
||||
} else {
|
||||
ferr("Error writing file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
msg_error("Error writing file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue