mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
More extensive use of data_off_t
This avoids the need of some type cast.
This commit is contained in:
parent
f5d1afaaed
commit
3c6c5c07c7
6 changed files with 31 additions and 31 deletions
|
|
@ -46,18 +46,6 @@
|
|||
*/
|
||||
#define POS_NULL ((block_off_t)-1)
|
||||
|
||||
/**
|
||||
* Basic block position type.
|
||||
* With 32 bits and 128k blocks you can address 256 TB.
|
||||
*/
|
||||
typedef uint32_t block_off_t;
|
||||
|
||||
/**
|
||||
* Basic data position type.
|
||||
* It's signed as file size and offset are usually signed.
|
||||
*/
|
||||
typedef int64_t data_off_t;
|
||||
|
||||
/**
|
||||
* Content file specification.
|
||||
*/
|
||||
|
|
@ -448,7 +436,7 @@ struct snapraid_map {
|
|||
* the new size will be written only at the next
|
||||
* 'sync'.
|
||||
*/
|
||||
#define PARITY_SIZE_INVALID -1ULL
|
||||
#define PARITY_SIZE_INVALID -1LL
|
||||
|
||||
/**
|
||||
* Parity split.
|
||||
|
|
@ -462,7 +450,7 @@ struct snapraid_split {
|
|||
* Only the latest not zero size is allowed to grow.
|
||||
* If the value is unset, it's PARITY_SIZE_INVALID.
|
||||
*/
|
||||
uint64_t size;
|
||||
data_off_t size;
|
||||
|
||||
uint64_t device; /**< Device identifier of the parity. */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void parity_size(struct snapraid_parity_handle* handle, data_off_t* out_size)
|
|||
if (split->st.st_size < 0)
|
||||
break;
|
||||
|
||||
if ((uint64_t)split->st.st_size < split->size) {
|
||||
if (split->st.st_size < split->size) {
|
||||
/* this is a size error, so report only up to this size */
|
||||
/* but don't fail the function */
|
||||
size += split->st.st_size;
|
||||
|
|
@ -184,7 +184,7 @@ void parity_size(struct snapraid_parity_handle* handle, data_off_t* out_size)
|
|||
*out_size = size;
|
||||
}
|
||||
|
||||
int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, uint64_t limit_size)
|
||||
int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, data_off_t limit_size)
|
||||
{
|
||||
unsigned s;
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
data_off_t run;
|
||||
|
||||
if (is_fixed) {
|
||||
if ((uint64_t)size <= split->size) {
|
||||
if (size <= split->size) {
|
||||
is_fixed = 0; /* not fixed anymore */
|
||||
run = size;
|
||||
} else {
|
||||
|
|
@ -511,7 +511,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, uint64_t limit_size)
|
||||
int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, data_off_t limit_size)
|
||||
{
|
||||
unsigned s;
|
||||
|
||||
|
|
@ -642,7 +642,7 @@ struct snapraid_split_handle* parity_split_find(struct snapraid_parity_handle* h
|
|||
for (s = 0;s < handle->split_mac;++s) {
|
||||
struct snapraid_split_handle* split = &handle->split_map[s];
|
||||
|
||||
if ((uint64_t)*offset < split->size)
|
||||
if (*offset < split->size)
|
||||
return split;
|
||||
|
||||
*offset -= split->size;
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ struct snapraid_split_handle {
|
|||
* Only the latest not zero size is allowed to grow.
|
||||
* Note that this value CANNOT be PARITY_SIZE_INVALID.
|
||||
*/
|
||||
uint64_t size;
|
||||
data_off_t size;
|
||||
|
||||
/**
|
||||
* Artificial size limit for testing.
|
||||
* 0 means unlimited.
|
||||
*/
|
||||
uint64_t limit_size;
|
||||
data_off_t limit_size;
|
||||
};
|
||||
|
||||
struct snapraid_parity_handle {
|
||||
|
|
@ -88,7 +88,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* handle, const struct snapraid_parity* parity, unsigned level, int mode, uint64_t limit_size);
|
||||
int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, data_off_t limit_size);
|
||||
|
||||
/**
|
||||
* Change the parity size.
|
||||
|
|
@ -106,7 +106,7 @@ void parity_size(struct snapraid_parity_handle* handle, data_off_t* out_size);
|
|||
/**
|
||||
* Open an already existing parity file.
|
||||
*/
|
||||
int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, uint64_t limit_size);
|
||||
int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_parity* parity, unsigned level, int mode, data_off_t limit_size);
|
||||
|
||||
/**
|
||||
* Flush the parity file in the disk.
|
||||
|
|
|
|||
|
|
@ -267,6 +267,18 @@
|
|||
#define HAVE_LOCKFILE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Basic block position type.
|
||||
* With 32 bits and 128k blocks you can address 256 TB.
|
||||
*/
|
||||
typedef uint32_t block_off_t;
|
||||
|
||||
/**
|
||||
* Basic data position type.
|
||||
* It's signed as file size and offset are usually signed.
|
||||
*/
|
||||
typedef int64_t data_off_t;
|
||||
|
||||
/**
|
||||
* Includes specific support for Windows or Linux.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -937,10 +937,10 @@ int advise_open(struct advise_struct* advise, int f)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int advise_write(struct advise_struct* advise, int f, uint64_t offset, uint64_t size)
|
||||
int advise_write(struct advise_struct* advise, int f, data_off_t offset, data_off_t size)
|
||||
{
|
||||
uint64_t handle_offset;
|
||||
uint64_t handle_size;
|
||||
data_off_t handle_offset;
|
||||
data_off_t handle_size;
|
||||
|
||||
(void)f;
|
||||
|
||||
|
|
@ -1075,7 +1075,7 @@ int advise_write(struct advise_struct* advise, int f, uint64_t offset, uint64_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
int advise_read(struct advise_struct* advise, int f, uint64_t offset, uint64_t size)
|
||||
int advise_read(struct advise_struct* advise, int f, data_off_t offset, data_off_t size)
|
||||
{
|
||||
(void)advise;
|
||||
(void)f;
|
||||
|
|
|
|||
|
|
@ -341,15 +341,15 @@ int fmtime(int f, int64_t mtime_sec, int mtime_nsec);
|
|||
|
||||
struct advise_struct {
|
||||
int mode;
|
||||
uint64_t dirty_begin;
|
||||
uint64_t dirty_end;
|
||||
data_off_t dirty_begin;
|
||||
data_off_t dirty_end;
|
||||
};
|
||||
|
||||
void advise_init(struct advise_struct* advise, int mode);
|
||||
int advise_flags(struct advise_struct* advise);
|
||||
int advise_open(struct advise_struct* advise, int f);
|
||||
int advise_write(struct advise_struct* advise, int f, uint64_t offset, uint64_t size);
|
||||
int advise_read(struct advise_struct* advise, int f, uint64_t offset, uint64_t size);
|
||||
int advise_write(struct advise_struct* advise, int f, data_off_t offset, data_off_t size);
|
||||
int advise_read(struct advise_struct* advise, int f, data_off_t offset, data_off_t size);
|
||||
|
||||
/****************************************************************************/
|
||||
/* memory */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue