mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-21 23:46:27 -05:00
Track deallocated files in the content file for parity recovery
Add a new 'dealloc' list per disk to record files that were removed or modified during a scan. This list is saved in the content file (new format version SNAPCNT4) so that past parity contributions of those files can be imported from previous snapshots.
This commit is contained in:
parent
cebc9b62f2
commit
1aae44a2a3
9 changed files with 417 additions and 10 deletions
|
|
@ -308,6 +308,21 @@ struct snapraid_dir {
|
|||
tommy_hashdyn_node nodeset;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deallocated file.
|
||||
*/
|
||||
struct snapraid_dealloc {
|
||||
char* sub; /**< Sub path of the file. Without the disk dir. The disk is implicit. */
|
||||
data_off_t size; /**< Size of the file. */
|
||||
int64_t mtime_sec; /**< Modification time. */
|
||||
int mtime_nsec; /**< Modification time nanoseconds. In the range 0 <= x < 1,000,000,000, or STAT_NSEC_INVALID if not present. */
|
||||
block_off_t blockmax; /**< Number of blocks. */
|
||||
unsigned char* blockhash; /**< Hash of all blocks. */
|
||||
|
||||
/* nodes for data structures */
|
||||
tommy_node nodelist;
|
||||
};
|
||||
|
||||
/**
|
||||
* Chunk.
|
||||
*
|
||||
|
|
@ -322,7 +337,6 @@ struct snapraid_extent {
|
|||
tommy_tree_node file_node; /**< Tree sorter by <file,file_pos>. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Other disk.
|
||||
*/
|
||||
|
|
@ -346,9 +360,30 @@ struct snapraid_extra {
|
|||
*/
|
||||
struct snapraid_disk {
|
||||
char name[PATH_MAX]; /**< Name of the disk. */
|
||||
char mount_point[PATH_MAX]; /**< Configured mount point of the disk. It always terminates with /. */
|
||||
char dir[PATH_MAX]; /**< Effective mount point of the disk. It could be either the real mount point or a snapshot. It always terminates with /. */
|
||||
char snapshot_root[PATH_MAX]; /**< Subvolume root directory. It always terminates with /. Empty if not supported. */
|
||||
|
||||
/**
|
||||
* Configured mount point of the disk.
|
||||
*
|
||||
* It always terminates with /
|
||||
*/
|
||||
char mount_point[PATH_MAX];
|
||||
|
||||
/**
|
||||
* Effective mount point of the disk.
|
||||
*
|
||||
* It could be either the real mount point or a snapshot.
|
||||
* It always terminates with /
|
||||
*/
|
||||
char dir[PATH_MAX];
|
||||
|
||||
/**
|
||||
* Subvolumes root directory.
|
||||
*
|
||||
* Empty if disabled.
|
||||
* It always terminates with /
|
||||
*/
|
||||
char snapshot_root[PATH_MAX];
|
||||
|
||||
char smartctl[PATH_MAX]; /**< Custom command for smartctl. Empty means auto. */
|
||||
int smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */
|
||||
char uuid[UUID_MAX]; /**< UUID of the disk. They are probed during the config reading. */
|
||||
|
|
@ -439,6 +474,7 @@ struct snapraid_disk {
|
|||
tommy_hashdyn linkset; /**< Hashtable by name of all the links. */
|
||||
tommy_list dirlist; /**< List of all the empty dirs. */
|
||||
tommy_hashdyn dirset; /**< Hashtable by name of all the empty dirs. */
|
||||
tommy_list dealloclist; /**< List of all the deallocs. */
|
||||
|
||||
/* nodes for data structures */
|
||||
tommy_node node;
|
||||
|
|
@ -1006,6 +1042,21 @@ static inline tommy_uint32_t dir_name_hash(const char* name)
|
|||
return tommy_hash_u32(0, name, strlen(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a dealloc.
|
||||
*/
|
||||
struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec);
|
||||
|
||||
/**
|
||||
* Deallocate a dealloc.
|
||||
*/
|
||||
void dealloc_free(struct snapraid_dealloc* dealloc);
|
||||
|
||||
/**
|
||||
* Import file hash in the dealloc.
|
||||
*/
|
||||
void dealloc_import(struct snapraid_dealloc* dealloc, struct snapraid_file* file);
|
||||
|
||||
/**
|
||||
* Allocate a disk.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue