mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Add the "maybe" function also to par2file
This commit is contained in:
parent
06c8891b26
commit
83889b4fbb
2 changed files with 22 additions and 4 deletions
|
|
@ -1171,7 +1171,7 @@ static struct snapraid_chunk* fs_file2chunk_get_unlock(struct snapraid_disk* dis
|
|||
return chunk;
|
||||
}
|
||||
|
||||
struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos)
|
||||
struct snapraid_file* fs_par2file_maybe(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos)
|
||||
{
|
||||
struct snapraid_chunk* chunk;
|
||||
struct snapraid_file* file;
|
||||
|
|
@ -1358,8 +1358,8 @@ struct snapraid_block* fs_par2block_get(struct snapraid_disk* disk, block_off_t
|
|||
struct snapraid_file* file;
|
||||
block_off_t file_pos;
|
||||
|
||||
file = fs_par2file_get(disk, parity_pos, &file_pos);
|
||||
if (!file)
|
||||
file = fs_par2file_maybe(disk, parity_pos, &file_pos);
|
||||
if (file == 0)
|
||||
return BLOCK_EMPTY;
|
||||
|
||||
return fs_file2block_get(file, file_pos);
|
||||
|
|
|
|||
|
|
@ -934,7 +934,25 @@ struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t
|
|||
* Get the file position from the parity position.
|
||||
* Return 0 if no file is using it.
|
||||
*/
|
||||
struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos);
|
||||
struct snapraid_file* fs_par2file_maybe(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos);
|
||||
|
||||
/**
|
||||
* Get the file position from the parity position.
|
||||
*/
|
||||
static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk, block_off_t parity_pos, block_off_t* file_pos)
|
||||
{
|
||||
struct snapraid_file* ret;
|
||||
|
||||
ret = fs_par2file_maybe(disk, parity_pos, file_pos);
|
||||
if (ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency when deresolving parity position '%u' in disk '%s'\n", parity_pos, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parity position from the file position.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue