2011-03-04 20:59:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2011 Andrea Mazzoleni
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __STATE_H
|
|
|
|
|
#define __STATE_H
|
|
|
|
|
|
2013-10-22 23:40:05 +02:00
|
|
|
#include "elem.h"
|
|
|
|
|
|
2016-01-20 21:30:00 +01:00
|
|
|
struct snapraid_handle;
|
2016-01-27 20:37:31 +01:00
|
|
|
struct snapraid_io;
|
2016-01-20 21:30:00 +01:00
|
|
|
|
2013-09-15 21:12:41 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
|
/* parity level */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Max level of parity supported.
|
|
|
|
|
*/
|
2013-10-22 23:40:05 +02:00
|
|
|
#define LEV_MAX 6
|
2013-09-15 21:12:41 +02:00
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Return the parity name: Parity, 2-Parity, 3-Parity, 4-Parity, 5-Parity, 6-Parity.
|
2013-09-15 21:12:41 +02:00
|
|
|
*/
|
|
|
|
|
const char* lev_name(unsigned level);
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Return the parity name used in the config file: parity, 2-parity, 3-parity, 4-parity, 5-parity, 6-parity.
|
2013-09-15 21:12:41 +02:00
|
|
|
*/
|
|
|
|
|
const char* lev_config_name(unsigned level);
|
|
|
|
|
|
2011-03-04 20:59:21 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
|
/* state */
|
|
|
|
|
|
2015-03-29 22:18:21 +02:00
|
|
|
/**
|
|
|
|
|
* Units for disk space.
|
|
|
|
|
*/
|
2016-01-16 07:27:28 +01:00
|
|
|
#define KILO (1000)
|
2015-03-29 22:18:21 +02:00
|
|
|
#define MEGA (1000 * 1000)
|
|
|
|
|
#define GIGA (1000 * 1000 * 1000)
|
2026-02-02 11:19:51 +01:00
|
|
|
#define TERA (1000 * 1000 * 1000 * 1000UL)
|
2016-01-16 07:27:28 +01:00
|
|
|
#define KIBI (1024)
|
|
|
|
|
#define MEBI (1024 * 1024)
|
|
|
|
|
#define GIBI (1024 * 1024 * 1024)
|
2026-02-02 11:19:51 +01:00
|
|
|
#define TEBI (1024 * 1024 * 1024 * 1024UL)
|
2015-03-29 22:18:21 +02:00
|
|
|
|
2013-06-25 22:41:10 +02:00
|
|
|
#define SORT_PHYSICAL 1 /**< Sort by physical order. */
|
|
|
|
|
#define SORT_INODE 2 /**< Sort by inode. */
|
|
|
|
|
#define SORT_ALPHA 3 /**< Sort by alphabetic order. */
|
|
|
|
|
#define SORT_DIR 4 /**< Sort by directory order. */
|
|
|
|
|
|
2013-06-29 18:11:36 +02:00
|
|
|
/**
|
|
|
|
|
* Options set only at startup.
|
|
|
|
|
* For all these options a value of 0 means nothing set, and to use the default.
|
|
|
|
|
*/
|
|
|
|
|
struct snapraid_option {
|
2026-01-14 10:35:57 +01:00
|
|
|
int gui; /**< GUI output. */
|
|
|
|
|
int gui_verbose; /**< GUI verbose output. */
|
2014-12-29 08:50:20 +01:00
|
|
|
int auditonly; /**< In check, checks only the hash and not the parity. */
|
2021-07-08 07:38:24 +02:00
|
|
|
int badfileonly; /**< In fix, fixes only files marked as bad. */
|
|
|
|
|
int badblockonly; /**< In fix, fixes only the blocks marked as bad. */
|
2014-12-29 08:50:20 +01:00
|
|
|
int syncedonly; /**< In fix, fixes only files that are synced. */
|
2014-02-12 22:04:14 +01:00
|
|
|
int prehash; /**< Enables the prehash mode for sync. */
|
2014-12-30 09:45:35 +01:00
|
|
|
unsigned io_error_limit; /**< Max number of input/output errors before aborting. */
|
2016-01-02 16:52:20 +01:00
|
|
|
int force_zero; /**< Forced dangerous operations of syncing files now with zero size. */
|
|
|
|
|
int force_empty; /**< Forced dangerous operations of syncing disks now empty. */
|
|
|
|
|
int force_uuid; /**< Forced dangerous operations of syncing disks with uuid changed. */
|
2013-07-26 14:50:52 +02:00
|
|
|
int force_device; /**< Forced dangerous operations of using disks with save device id. */
|
2016-01-02 16:52:20 +01:00
|
|
|
int force_nocopy; /**< Force dangerous operations of syncing files without using copy detection. */
|
2016-10-01 22:19:29 +02:00
|
|
|
int force_full; /**< Force a full parity update. */
|
|
|
|
|
int force_realloc; /**< Force a full reallocation and parity update. */
|
2026-02-03 22:57:55 +01:00
|
|
|
uint64_t parity_tail; /**< Limit the reallocation of the location at the specified parity tail */
|
2011-04-23 21:38:26 +02:00
|
|
|
int expect_unrecoverable; /**< Expect presence of unrecoverable error in checking or fixing. */
|
|
|
|
|
int expect_recoverable; /**< Expect presence of recoverable error in checking. */
|
2013-06-29 18:11:36 +02:00
|
|
|
int skip_device; /**< Skip devices matching checks. */
|
2013-02-28 23:06:42 +01:00
|
|
|
int skip_sign; /**< Skip the sign check for content files. */
|
|
|
|
|
int skip_fallocate; /**< Skip the use of fallocate(). */
|
2016-10-04 23:56:13 +02:00
|
|
|
int skip_space_holder; /**< Skip the use of spaceholder file. */
|
2016-05-15 14:18:44 +02:00
|
|
|
int file_mode; /**< File mode. Mask of ADVISE_* flags. */
|
2013-06-29 18:11:36 +02:00
|
|
|
int skip_lock; /**< Skip the lock file protection. */
|
|
|
|
|
int skip_self; /**< Skip the self-test. */
|
2014-02-22 07:47:34 +01:00
|
|
|
int skip_content_check; /**< Relax some content file checks. */
|
2014-03-10 21:17:10 +01:00
|
|
|
int skip_parity_access; /**< Skip the parity access for commands that don't need it. */
|
2014-11-09 19:14:29 +01:00
|
|
|
int skip_disk_access; /**< Skip the data disk access for commands that don't need it. */
|
2015-10-16 23:17:38 +02:00
|
|
|
int skip_content_access; /**< Skip the content access for commands that don't need it. */
|
2013-06-29 18:11:36 +02:00
|
|
|
int kill_after_sync; /**< Kill the process after sync without saving the final state. */
|
2013-06-15 23:42:11 +02:00
|
|
|
int force_murmur3; /**< Force Murmur3 choice. */
|
|
|
|
|
int force_spooky2; /**< Force Spooky2 choice. */
|
2013-06-29 18:11:36 +02:00
|
|
|
int force_order; /**< Force sorting order. One of the SORT_* defines. */
|
2014-11-10 23:06:14 +01:00
|
|
|
unsigned force_scrub_at; /**< Force scrub for the specified number of blocks. */
|
2013-07-01 23:08:25 +02:00
|
|
|
int force_scrub_even; /**< Force scrub of all the even blocks. */
|
2013-08-09 13:55:02 +02:00
|
|
|
int force_content_write; /**< Force the update of the content file. */
|
2016-05-17 23:17:31 +02:00
|
|
|
int skip_content_write; /**< Skip the update of the content file. */
|
2014-10-03 21:24:19 +02:00
|
|
|
int force_scan_winfind; /**< Force the use of FindFirst/Next in Windows to list directories. */
|
2014-11-04 23:51:45 +01:00
|
|
|
int force_progress; /**< Force the use of the progress status. */
|
2014-11-10 23:06:14 +01:00
|
|
|
unsigned force_autosave_at; /**< Force autosave at the specified block. */
|
2015-03-31 23:47:34 +02:00
|
|
|
int fake_device; /**< Fake device data. */
|
2015-11-24 18:49:20 +01:00
|
|
|
int no_warnings; /**< Remove some warning messages. */
|
2015-04-19 21:21:49 +02:00
|
|
|
int expected_missing; /**< If missing files are expected and should not be reported. */
|
2015-12-04 22:38:43 +01:00
|
|
|
int fake_uuid; /**< Set fakes UUID for testing. */
|
2015-12-28 13:55:22 +01:00
|
|
|
int match_first_uuid; /**< Force the matching of the first UUID. */
|
2016-01-04 10:40:41 +01:00
|
|
|
int force_parity_update; /**< Force parity update even if data is not changed. */
|
2016-01-10 19:39:43 +01:00
|
|
|
unsigned io_cache; /**< Number of IO buffers to use. 0 for default. */
|
2016-01-18 22:36:06 +01:00
|
|
|
int auto_conf; /**< Allow to run without configuration file. */
|
2016-01-27 21:08:59 +01:00
|
|
|
int force_stats; /**< Force stats print during process. */
|
2016-05-16 22:55:19 +02:00
|
|
|
uint64_t parity_limit_size; /**< Test limit for parity files. */
|
2022-01-07 21:03:51 +01:00
|
|
|
int skip_multi_scan; /**< Don't use threads in scan. */
|
2025-03-27 12:57:41 -07:00
|
|
|
uint64_t bwlimit; /**< Bandwidth limit in bytes per second. */
|
2013-06-29 18:11:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct snapraid_state {
|
|
|
|
|
struct snapraid_option opt; /**< Setup options. */
|
|
|
|
|
int filter_hidden; /**< Filter out hidden files. */
|
|
|
|
|
uint64_t autosave; /**< Autosave after the specified amount of data. 0 to disable. */
|
2011-03-19 22:00:08 +01:00
|
|
|
int need_write; /**< If the state is changed. */
|
2025-10-13 00:20:36 +02:00
|
|
|
int written; /**< If the state was written at least one time */
|
2014-06-13 18:23:24 +02:00
|
|
|
int checked_read; /**< If the state was read and checked. */
|
2011-03-16 23:52:10 +01:00
|
|
|
uint32_t block_size; /**< Block size in bytes. */
|
2013-11-04 23:47:49 +01:00
|
|
|
unsigned raid_mode; /**< Raid mode to use. RAID_MODE_DEFAULT or RAID_MODE_ALTERNATE. */
|
2016-05-15 14:18:44 +02:00
|
|
|
int file_mode; /**< File access mode. Combination of ADVISE_* flags. */
|
2014-11-09 10:32:00 +01:00
|
|
|
struct snapraid_parity parity[LEV_MAX]; /**< Parity vector. */
|
2013-12-18 19:26:57 +01:00
|
|
|
char share[PATH_MAX]; /**< Path of the share tree. If !=0 pool links are created in a different way. */
|
2013-02-22 22:17:54 +01:00
|
|
|
char pool[PATH_MAX]; /**< Path of the pool tree. */
|
|
|
|
|
uint64_t pool_device; /**< Device identifier of the pool. */
|
2016-04-07 21:39:02 +02:00
|
|
|
unsigned char hashseed[HASH_MAX]; /**< Hash seed. Just after a uint64 to provide a minimal alignment. */
|
|
|
|
|
unsigned char prevhashseed[HASH_MAX]; /**< Previous hash seed. In case of rehash. */
|
2013-06-18 21:06:31 +02:00
|
|
|
char lockfile[PATH_MAX]; /**< Path of the lock file to use. */
|
2013-11-13 21:35:44 +01:00
|
|
|
unsigned level; /**< Number of parity levels. 1 for PAR1, 2 for PAR2. */
|
2011-04-23 21:38:26 +02:00
|
|
|
unsigned hash; /**< Hash kind used. */
|
2013-07-01 23:08:25 +02:00
|
|
|
unsigned prevhash; /**< Previous hash kind used. In case of rehash. */
|
2013-06-15 23:42:11 +02:00
|
|
|
unsigned besthash; /**< Best hash suggested. */
|
2013-03-03 22:39:46 +01:00
|
|
|
const char* command; /**< Command running. */
|
2025-09-15 16:56:09 +02:00
|
|
|
int smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for all devices. */
|
2026-02-08 22:56:22 +01:00
|
|
|
uint32_t rehash_blocks; /**< Blocks marked rehash */
|
|
|
|
|
uint32_t bad_blocks; /**< Blocks marked bad */
|
2026-02-02 16:32:16 +01:00
|
|
|
uint32_t unsynced_blocks; /**< If the parity is invalid, and a sync is needed. */
|
2026-02-08 22:56:22 +01:00
|
|
|
uint32_t unscrubbed_blocks; /**< Blocks never scrubbed */
|
2026-02-02 15:39:39 +01:00
|
|
|
|
2011-04-25 13:43:51 +02:00
|
|
|
tommy_list contentlist; /**< List of content files. */
|
2011-09-23 21:48:50 +02:00
|
|
|
tommy_list disklist; /**< List of all the disks. */
|
2011-10-01 19:18:32 +02:00
|
|
|
tommy_list maplist; /**< List of all the disk mappings. */
|
2011-04-26 18:51:42 +02:00
|
|
|
tommy_list filterlist; /**< List of inclusion/exclusion. */
|
2013-02-27 21:07:16 +01:00
|
|
|
tommy_list importlist; /**< List of import file. */
|
|
|
|
|
tommy_hashdyn importset; /**< Hashtable by hash of all the import blocks. */
|
2013-07-01 23:08:25 +02:00
|
|
|
tommy_hashdyn previmportset; /**< Hashtable by prevhash of all the import blocks. Valid only if we are in a rehash state. */
|
2014-10-19 21:07:17 +02:00
|
|
|
tommy_hashdyn searchset; /**< Hashtable by timestamp of all the search files. */
|
2013-09-28 09:40:08 +02:00
|
|
|
tommy_arrayblkof infoarr; /**< Block information array. */
|
2026-02-08 22:56:22 +01:00
|
|
|
tommy_list bucketlist; /**< Sorted list of info bucket. Derived from infoarr, but updated only state_read()/state_write() */
|
|
|
|
|
block_off_t bucketcount; /**< Sum of all the counts of the list */
|
2013-10-21 19:52:28 +02:00
|
|
|
|
2025-09-21 19:54:10 +02:00
|
|
|
/* Thermal */
|
|
|
|
|
tommy_list thermallist; /**< List of all thermal state */
|
|
|
|
|
int thermal_stop_gathering; /**< If thermal data gathering is stopped */
|
|
|
|
|
int thermal_ambient_temperature; /**< Ambient themperature. 0 if not available */
|
|
|
|
|
int thermal_highest_temperature; /**< Current highest temperature */
|
|
|
|
|
time_t thermal_first; /**< Time of the first measure */
|
|
|
|
|
time_t thermal_latest; /**< Time of latest measure */
|
|
|
|
|
int thermal_cooldown_time; /**< Cooldown wait time in seconds */
|
|
|
|
|
int thermal_temperature_limit; /**< Upper limit temperature of the operating range */
|
|
|
|
|
|
2014-06-25 22:32:36 +02:00
|
|
|
/**
|
2014-09-09 22:22:46 +02:00
|
|
|
* Cumulative time used for computations.
|
2014-06-25 22:32:36 +02:00
|
|
|
*/
|
2016-01-26 23:25:01 +01:00
|
|
|
uint64_t tick_misc;
|
2016-01-31 16:38:29 +01:00
|
|
|
uint64_t tick_sched;
|
2016-01-26 23:25:01 +01:00
|
|
|
uint64_t tick_raid;
|
|
|
|
|
uint64_t tick_hash;
|
2014-06-25 22:32:36 +02:00
|
|
|
|
|
|
|
|
/**
|
2014-09-09 22:22:46 +02:00
|
|
|
* Cumulative time used for all io operations of disks.
|
2014-06-25 22:32:36 +02:00
|
|
|
*/
|
2014-09-09 22:22:46 +02:00
|
|
|
uint64_t tick_io;
|
|
|
|
|
|
2014-06-25 22:32:36 +02:00
|
|
|
/**
|
|
|
|
|
* Last time used for time measure.
|
|
|
|
|
*/
|
|
|
|
|
uint64_t tick_last;
|
|
|
|
|
|
2014-06-13 20:52:03 +02:00
|
|
|
int clear_past_hash; /**< Clear all the hash from CHG and DELETED blocks when reading the state from an incomplete sync. */
|
2014-09-09 22:15:50 +02:00
|
|
|
|
|
|
|
|
time_t progress_whole_start; /**< Initial start of the whole process. */
|
|
|
|
|
time_t progress_interruption; /**< Time of the start of the progress interruption. */
|
|
|
|
|
time_t progress_wasted; /**< Time wasted in interruptions. */
|
|
|
|
|
|
|
|
|
|
time_t progress_time[PROGRESS_MAX]; /**< Last times of progress. */
|
|
|
|
|
block_off_t progress_pos[PROGRESS_MAX]; /**< Last positions of progress. */
|
|
|
|
|
data_off_t progress_size[PROGRESS_MAX]; /**< Last sizes of progress. */
|
2016-01-26 23:25:01 +01:00
|
|
|
uint64_t progress_tick_misc[PROGRESS_MAX]; /**< Last cpu ticks of progress. */
|
2016-01-31 16:38:29 +01:00
|
|
|
uint64_t progress_tick_sched[PROGRESS_MAX]; /**< Last scheduling ticks of progress. */
|
2016-01-26 23:25:01 +01:00
|
|
|
uint64_t progress_tick_raid[PROGRESS_MAX]; /**< Last raid ticks of progress. */
|
|
|
|
|
uint64_t progress_tick_hash[PROGRESS_MAX]; /**< Last hash ticks of progress. */
|
|
|
|
|
uint64_t progress_tick_io[PROGRESS_MAX]; /**< Last io ticks of progress. */
|
2014-09-09 22:15:50 +02:00
|
|
|
|
|
|
|
|
int progress_ptr; /**< Pointer to the next position to fill. Rolling over. */
|
|
|
|
|
int progress_tick; /**< Number of measures done. */
|
|
|
|
|
|
2013-09-21 15:53:46 +02:00
|
|
|
int no_conf; /**< Automatically add missing info. Used to load content without a configuration file. */
|
2011-03-04 20:59:21 +01:00
|
|
|
};
|
|
|
|
|
|
2011-03-12 23:36:37 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Initialize the state.
|
2011-03-12 23:36:37 +01:00
|
|
|
*/
|
2011-03-04 20:59:21 +01:00
|
|
|
void state_init(struct snapraid_state* state);
|
|
|
|
|
|
2011-03-12 23:36:37 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Deinitialize the state.
|
2011-03-12 23:36:37 +01:00
|
|
|
*/
|
2011-03-04 20:59:21 +01:00
|
|
|
void state_done(struct snapraid_state* state);
|
|
|
|
|
|
2011-03-12 23:36:37 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Read the configuration file.
|
2011-03-12 23:36:37 +01:00
|
|
|
*/
|
2013-10-30 21:45:53 +01:00
|
|
|
void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk);
|
2011-03-04 20:59:21 +01:00
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Read the state.
|
2011-03-04 20:59:21 +01:00
|
|
|
*/
|
|
|
|
|
void state_read(struct snapraid_state* state);
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Write the new state.
|
2011-03-04 20:59:21 +01:00
|
|
|
*/
|
|
|
|
|
void state_write(struct snapraid_state* state);
|
|
|
|
|
|
2015-03-02 23:01:15 +01:00
|
|
|
/**
|
|
|
|
|
* Diff all the disks.
|
|
|
|
|
*/
|
|
|
|
|
int state_diff(struct snapraid_state* state);
|
|
|
|
|
|
2011-03-04 20:59:21 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Scan all the disks to update the state.
|
2011-03-04 20:59:21 +01:00
|
|
|
*/
|
2015-03-02 23:01:15 +01:00
|
|
|
void state_scan(struct snapraid_state* state);
|
2011-03-04 20:59:21 +01:00
|
|
|
|
2014-05-15 23:45:51 +02:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Set the nanosecond timestamp of all files that have a zero value.
|
2014-05-15 23:45:51 +02:00
|
|
|
*/
|
2016-01-18 19:38:42 +01:00
|
|
|
void state_touch(struct snapraid_state* state);
|
2014-05-15 23:45:51 +02:00
|
|
|
|
2015-01-02 15:53:15 +01:00
|
|
|
/**
|
2015-01-11 17:43:31 +01:00
|
|
|
* Devices operations.
|
2015-01-02 15:53:15 +01:00
|
|
|
*/
|
2016-01-23 15:31:30 +01:00
|
|
|
void state_device(struct snapraid_state* state, int operation, tommy_list* filterlist_disk);
|
2015-01-02 15:53:15 +01:00
|
|
|
|
2011-03-04 20:59:21 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Sync the parity data.
|
2011-03-04 20:59:21 +01:00
|
|
|
*/
|
2011-03-23 18:54:08 +01:00
|
|
|
int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t blockcount);
|
2011-03-04 20:59:21 +01:00
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Check (and fixes) all the files and parity data.
|
2014-02-12 22:04:14 +01:00
|
|
|
* \param fix If we have to fix, after checking.
|
2011-03-04 20:59:21 +01:00
|
|
|
*/
|
2014-02-12 22:04:14 +01:00
|
|
|
int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, block_off_t blockcount);
|
2011-03-04 20:59:21 +01:00
|
|
|
|
2011-04-08 22:32:40 +02:00
|
|
|
/**
|
2011-12-08 20:37:27 +01:00
|
|
|
* Dry the files.
|
2011-04-08 22:32:40 +02:00
|
|
|
*/
|
2025-10-17 08:49:11 +02:00
|
|
|
int state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t blockcount);
|
2011-04-08 22:32:40 +02:00
|
|
|
|
2013-06-15 23:42:11 +02:00
|
|
|
/**
|
|
|
|
|
* Rehash the files.
|
|
|
|
|
*/
|
|
|
|
|
void state_rehash(struct snapraid_state* state);
|
|
|
|
|
|
2015-09-13 15:48:05 +02:00
|
|
|
/**
|
|
|
|
|
* Scrub levels.
|
|
|
|
|
*/
|
|
|
|
|
#define SCRUB_AUTO -1 /**< Automatic selection. */
|
|
|
|
|
#define SCRUB_BAD -2 /**< Scrub only the bad blocks. */
|
2020-05-02 14:21:40 +02:00
|
|
|
#define SCRUB_NEW -3 /**< Scrub the new blocks. */
|
2015-09-13 15:48:05 +02:00
|
|
|
#define SCRUB_FULL -4 /**< Scrub everything. */
|
2015-11-09 23:21:39 +01:00
|
|
|
#define SCRUB_EVEN -5 /**< Even blocks. */
|
2015-09-13 15:48:05 +02:00
|
|
|
|
2013-06-29 17:53:40 +02:00
|
|
|
/**
|
|
|
|
|
* Scrub the files.
|
|
|
|
|
*/
|
2015-11-10 19:37:23 +01:00
|
|
|
int state_scrub(struct snapraid_state* state, int plan, int olderthan);
|
2013-06-29 17:53:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Print the status.
|
|
|
|
|
*/
|
|
|
|
|
int state_status(struct snapraid_state* state);
|
|
|
|
|
|
2011-12-08 20:37:27 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Find duplicates.
|
2011-12-08 20:37:27 +01:00
|
|
|
*/
|
|
|
|
|
void state_dup(struct snapraid_state* state);
|
|
|
|
|
|
2013-10-04 21:35:08 +02:00
|
|
|
/**
|
|
|
|
|
* List content.
|
|
|
|
|
*/
|
|
|
|
|
void state_list(struct snapraid_state* state);
|
|
|
|
|
|
2013-02-22 22:17:54 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Create pool tree.
|
2013-02-22 22:17:54 +01:00
|
|
|
*/
|
|
|
|
|
void state_pool(struct snapraid_state* state);
|
|
|
|
|
|
2014-11-09 19:14:29 +01:00
|
|
|
/**
|
|
|
|
|
* Refresh the free space info.
|
|
|
|
|
*
|
|
|
|
|
* Note that it requires disks access.
|
|
|
|
|
*/
|
|
|
|
|
void state_refresh(struct snapraid_state* state);
|
|
|
|
|
|
2015-10-16 23:17:38 +02:00
|
|
|
/**
|
|
|
|
|
* Skip files, symlinks and dirs.
|
|
|
|
|
* Apply any skip access disk.
|
|
|
|
|
*/
|
|
|
|
|
void state_skip(struct snapraid_state* state);
|
|
|
|
|
|
2011-03-30 00:14:43 +02:00
|
|
|
/**
|
2013-01-27 16:44:04 +01:00
|
|
|
* Filter files, symlinks and dirs.
|
|
|
|
|
* Apply an additional filter to the list currently loaded.
|
2011-03-30 00:14:43 +02:00
|
|
|
*/
|
2013-08-18 19:24:55 +02:00
|
|
|
void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tommy_list* filterlist_disk, int filter_missing, int filter_error);
|
2011-03-30 00:14:43 +02:00
|
|
|
|
2011-06-20 20:35:04 +02:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Begin the progress visualization.
|
2011-06-20 20:35:04 +02:00
|
|
|
*/
|
2013-07-10 19:37:58 +02:00
|
|
|
int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax);
|
2011-06-20 20:35:04 +02:00
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* End the progress visualization.
|
2011-06-20 20:35:04 +02:00
|
|
|
*/
|
2025-10-13 11:46:36 +02:00
|
|
|
void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize, const char* msg);
|
2011-06-20 20:35:04 +02:00
|
|
|
|
2011-03-12 23:36:37 +01:00
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Write the progress.
|
2011-03-12 23:36:37 +01:00
|
|
|
*/
|
2016-01-27 20:37:31 +01:00
|
|
|
int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize);
|
2011-03-04 20:59:21 +01:00
|
|
|
|
2012-03-13 23:59:59 +01:00
|
|
|
/**
|
2016-01-02 16:52:20 +01:00
|
|
|
* Stop temporarily the progress.
|
2012-03-13 23:59:59 +01:00
|
|
|
*/
|
|
|
|
|
void state_progress_stop(struct snapraid_state* state);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Restart the progress.
|
|
|
|
|
*/
|
|
|
|
|
void state_progress_restart(struct snapraid_state* state);
|
|
|
|
|
|
2014-06-25 22:32:36 +02:00
|
|
|
/**
|
|
|
|
|
* Set the usage time as wasted one not counted.
|
|
|
|
|
*/
|
2016-01-20 21:30:00 +01:00
|
|
|
void state_usage_waste(struct snapraid_state* state);
|
2014-06-25 22:32:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the usage time for CPU.
|
|
|
|
|
*/
|
2016-01-26 23:25:01 +01:00
|
|
|
void state_usage_misc(struct snapraid_state* state);
|
2016-01-31 16:38:29 +01:00
|
|
|
void state_usage_sched(struct snapraid_state* state);
|
2016-01-26 23:25:01 +01:00
|
|
|
void state_usage_raid(struct snapraid_state* state);
|
|
|
|
|
void state_usage_hash(struct snapraid_state* state);
|
2014-06-25 22:32:36 +02:00
|
|
|
|
2017-11-19 19:33:47 +01:00
|
|
|
/**
|
|
|
|
|
* Set the last file used
|
|
|
|
|
*/
|
|
|
|
|
void state_usage_file(struct snapraid_state* state, struct snapraid_disk* disk, struct snapraid_file* file);
|
|
|
|
|
|
2014-06-25 22:32:36 +02:00
|
|
|
/**
|
2016-01-20 21:30:00 +01:00
|
|
|
* Set the usage time for a set of data disks.
|
2014-06-25 22:32:36 +02:00
|
|
|
*/
|
2016-01-20 21:30:00 +01:00
|
|
|
void state_usage_disk(struct snapraid_state* state, struct snapraid_handle* handle_map, unsigned* waiting_map, unsigned waiting_mac);
|
2014-06-25 22:32:36 +02:00
|
|
|
|
|
|
|
|
/**
|
2016-01-20 21:30:00 +01:00
|
|
|
* Set the usage time for a set of parity disk.
|
2014-06-25 22:32:36 +02:00
|
|
|
*/
|
2016-01-20 21:30:00 +01:00
|
|
|
void state_usage_parity(struct snapraid_state* state, unsigned* waiting_map, unsigned waiting_mac);
|
2014-06-25 22:32:36 +02:00
|
|
|
|
|
|
|
|
/**
|
2015-10-07 22:07:20 +02:00
|
|
|
* Print the stats of the usage time.
|
2014-06-25 22:32:36 +02:00
|
|
|
*/
|
|
|
|
|
void state_usage_print(struct snapraid_state* state);
|
|
|
|
|
|
2015-10-05 21:40:44 +02:00
|
|
|
/**
|
2016-01-02 16:52:20 +01:00
|
|
|
* Check the file-system on all disks.
|
2015-10-05 21:40:44 +02:00
|
|
|
* On error it aborts.
|
|
|
|
|
*/
|
|
|
|
|
void state_fscheck(struct snapraid_state* state, const char* ope);
|
|
|
|
|
|
2025-09-21 19:54:10 +02:00
|
|
|
/**
|
|
|
|
|
* Measure the temperature of all disks
|
|
|
|
|
*/
|
|
|
|
|
void state_thermal(struct snapraid_state* state, time_t now);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the temperature is outside the operating range
|
|
|
|
|
*/
|
|
|
|
|
int state_thermal_alarm(struct snapraid_state* state);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cool down the system
|
|
|
|
|
*/
|
|
|
|
|
void state_thermal_cooldown(struct snapraid_state* state);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Start of thermal processing
|
|
|
|
|
*/
|
|
|
|
|
int state_thermal_begin(struct snapraid_state* state, time_t now);
|
|
|
|
|
|
2026-01-10 16:30:35 +01:00
|
|
|
/**
|
|
|
|
|
* Load the ignore file .snapraidignore
|
|
|
|
|
*/
|
|
|
|
|
void state_load_ignore_file(tommy_list* filter_list, const char* path, const char* sub);
|
|
|
|
|
|
2026-02-08 18:24:48 +01:00
|
|
|
/**
|
|
|
|
|
* Report attributes into the log
|
|
|
|
|
*/
|
|
|
|
|
void state_attr(struct snapraid_state* state, tommy_list* low);
|
|
|
|
|
|
2013-09-21 15:53:46 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
|
/* misc */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a dummy configuration file from a content file.
|
|
|
|
|
*/
|
|
|
|
|
void generate_configuration(const char* content);
|
|
|
|
|
|
2011-03-04 20:59:21 +01:00
|
|
|
#endif
|
2011-03-06 22:52:50 +01:00
|
|
|
|