mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Add level knownledge to parity handle
This commit is contained in:
parent
a279333c0b
commit
3c00248aa6
6 changed files with 12 additions and 9 deletions
|
|
@ -1942,7 +1942,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
}
|
||||
|
||||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode);
|
||||
ret = parity_create(parity_ptr[l], l, state->parity[l].path, &out_size, state->file_mode);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l));
|
||||
|
|
@ -1963,7 +1963,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
/* it may fail if the file doesn't exist, in this case we continue to check the files */
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
|
||||
ret = parity_open(parity_ptr[l], l, state->parity[l].path, state->file_mode);
|
||||
if (ret == -1) {
|
||||
msg_status("No accessible %s file, only files will be checked.\n", lev_name(l));
|
||||
/* continue anyway */
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
/* it may fail if the file doesn't exist, in this case we continue to dry the files */
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
|
||||
ret = parity_open(parity_ptr[l], l, state->parity[l].path, state->file_mode);
|
||||
if (ret == -1) {
|
||||
msg_status("No accessible %s file.\n", lev_name(l));
|
||||
/* continue anyway */
|
||||
|
|
|
|||
|
|
@ -149,11 +149,12 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
}
|
||||
}
|
||||
|
||||
int parity_create(struct snapraid_parity_handle* parity, const char* path, data_off_t* out_size, int mode)
|
||||
int parity_create(struct snapraid_parity_handle* parity, unsigned level, const char* path, data_off_t* out_size, int mode)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
||||
parity->level = level;
|
||||
pathcpy(parity->path, sizeof(parity->path), path);
|
||||
|
||||
/* opening in sequential mode in Windows */
|
||||
|
|
@ -323,11 +324,12 @@ bail:
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
int parity_open(struct snapraid_parity_handle* parity, const char* path, int mode)
|
||||
int parity_open(struct snapraid_parity_handle* parity, unsigned level, const char* path, int mode)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
||||
parity->level = level;
|
||||
pathcpy(parity->path, sizeof(parity->path), path);
|
||||
|
||||
/* open for read */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
struct snapraid_parity_handle {
|
||||
char path[PATH_MAX]; /**< Path of the file. */
|
||||
unsigned level; /**< Level of the parity. */
|
||||
int f; /**< Handle of the file. */
|
||||
struct stat st; /**< Stat info of the opened file. */
|
||||
data_off_t valid_size; /**< Size of the valid data. */
|
||||
|
|
@ -74,7 +75,7 @@ void parity_overflow(struct snapraid_state* state, data_off_t size);
|
|||
* Create the parity file.
|
||||
* \param out_size Return the size of the parity file.
|
||||
*/
|
||||
int parity_create(struct snapraid_parity_handle* parity, const char* path, data_off_t* out_size, int mode);
|
||||
int parity_create(struct snapraid_parity_handle* parity, unsigned level, const char* path, data_off_t* out_size, int mode);
|
||||
|
||||
/**
|
||||
* Change the parity size.
|
||||
|
|
@ -85,7 +86,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
|
|||
/**
|
||||
* Open an already existing parity file.
|
||||
*/
|
||||
int parity_open(struct snapraid_parity_handle* parity, const char* path, int mode);
|
||||
int parity_open(struct snapraid_parity_handle* parity, unsigned level, const char* path, int mode);
|
||||
|
||||
/**
|
||||
* Flush the parity file in the disk.
|
||||
|
|
|
|||
|
|
@ -723,7 +723,7 @@ int state_scrub(struct snapraid_state* state, int plan, int olderthan)
|
|||
/* open the file for reading */
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
|
||||
ret = parity_open(parity_ptr[l], l, state->parity[l].path, state->file_mode);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("WARNING! Without an accessible %s file, it isn't possible to scrub.\n", lev_name(l));
|
||||
|
|
|
|||
|
|
@ -1258,7 +1258,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
/* create the file and open for writing */
|
||||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode);
|
||||
ret = parity_create(parity_ptr[l], l, state->parity[l].path, &out_size, state->file_mode);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue