// -- BLOCKMAP.C --- hammer_off_t blockmap_lookup(hammer_off_t zone_offset, struct hammer_blockmap_layer1 *save_layer1, struct hammer_blockmap_layer2 *save_layer2, int *errorp); // -- CACHE.C --- void hammer_cache_set(int bytes); void hammer_cache_add(struct cache_info *cache, enum cache_type type); void hammer_cache_del(struct cache_info *cache); void hammer_cache_used(struct cache_info *cache); void hammer_cache_flush(void); // -- CMD_BLOCKMAP.C -- typedef struct collect { struct collect *hnext; hammer_off_t phys_offset; struct hammer_blockmap_layer2 *track2; struct hammer_blockmap_layer2 *layer2; } *collect_t; static void dump_blockmap(const char *label, int zone); static void check_btree_node(hammer_off_t node_offset, int depth); static void collect_btree_elm(hammer_btree_elm_t elm); static struct hammer_blockmap_layer2 *collect_get_track(collect_t collect, hammer_off_t offset, struct hammer_blockmap_layer2 *layer2); static collect_t collect_get(hammer_off_t phys_offset); static struct hammer_blockmap_layer2 * collect_get_track(collect_t collect, hammer_off_t offset, struct hammer_blockmap_layer2 *layer2); static void dump_collect_table(void); static void dump_collect(collect_t collect); // -- CMD_CLEANUP.C -- struct didpfs { struct didpfs *next; uuid_t uuid; }; static void do_cleanup(const char *path); static void config_init(const char *path, struct hammer_ioc_config *config); static void migrate_config(FILE *fp, struct hammer_ioc_config *config); static void migrate_snapshots(int fd, const char *snapshots_path); static void migrate_one_snapshot(int fd, const char *fpath, struct hammer_ioc_snapshot *snapshot); static int strtosecs(char *ptr); static const char *dividing_slash(const char *path); static int check_period(const char *snapshots_path, const char *cmd, int arg1, time_t *savep); static void save_period(const char *snapshots_path, const char *cmd, time_t savet); static int check_softlinks(int fd, int new_config, const char *snapshots_path); static void cleanup_softlinks(int fd, int new_config, const char *snapshots_path, int arg2, char *arg3); static void delete_snapshots(int fd, struct hammer_ioc_snapshot *dsnapshot); static int check_expired(const char *fpath, int arg2); static int create_snapshot(const char *path, const char *snapshots_path); static int cleanup_prune(const char *path, const char *snapshots_path, int arg1, int arg2, int snapshots_disabled); static int cleanup_rebalance(const char *path, const char *snapshots_path, int arg1, int arg2); static int cleanup_reblock(const char *path, const char *snapshots_path, int arg1, int arg2); static int cleanup_recopy(const char *path, const char *snapshots_path, int arg1, int arg2); static void runcmd(int *resp, const char *ctl, ...); // -- CMD_CONFIG.C -- static void config_get(const char *dirpath, struct hammer_ioc_config *config); static void config_set(const char *dirpath, struct hammer_ioc_config *config); static void config_remove_path(void); // -- CMD_HISTORY.C -- static void hammer_do_history(const char *path, off_t off, int len); static void dumpat(const char *path, off_t off, int len); static const char *timestr32(u_int32_t time32); // -- CMD_INFO.C -- void show_info(char *path); char *find_pfs_mount(int pfsid, uuid_t parentuuid, int ismaster); double percent(int64_t value, int64_t total); u_int32_t count_snapshots(int fd, u_int32_t version, char *pfs_snapshots, char *mountedon); // -- CMD_MIRROR.C -- typedef struct histogram { hammer_tid_t tid; u_int64_t bytes; } *histogram_t; static int read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup); static int generate_histogram(int fd, const char *filesystem, histogram_t *histogram_ary, struct hammer_ioc_mirror_rw *mirror_base, int *repeatp); static void create_pfs(const char *filesystem, uuid_t *s_uuid); static hammer_ioc_mrecord_any_t read_mrecord(int fdin, int *errorp, hammer_ioc_mrecord_head_t pickup); static void write_mrecord(int fdout, u_int32_t type, hammer_ioc_mrecord_any_t mrec, int bytes); static void generate_mrec_header(int fd, int pfs_id, union hammer_ioc_mrecord_any *mrec_tmp); static int validate_mrec_header(int fd, int fdin, int is_target, int pfs_id, struct hammer_ioc_mrecord_head *pickup, hammer_tid_t *tid_begp, hammer_tid_t *tid_endp); static void update_pfs_snapshot(int fd, hammer_tid_t snapshot_tid, int pfs_id); static ssize_t writebw(int fd, const void *buf, size_t nbytes, u_int64_t *bwcount, struct timeval *tv1); static int getyn(void); static void mirror_usage(int code); // -- CMD_PSEUDOFS.C -- static void parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd); int getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path); void relpfs(int fd, struct hammer_ioc_pseudofs_rw *pfs); static void init_pfsd(hammer_pseudofs_data_pfsd, int is_slave); static void dump_pfsd(hammer_pseudofs_data_t pfsd, int fd); static parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd); static void pseudofs_usage(int code); static int getyn(void); static int timetosecs(char *str); // -- CMD_REBALANCE.C -- void hammer_cmd_rebalance(char **av, int ac); // -- CMD_REBLOCK.C -- void hammer_cmd_rebalance(char **av, int ac, int flags); // -- CMD_RECOVER.C -- struct recover_dict { struct recover_dict *next; struct recover_dict *parent; int64_t obj_id; uint8_t obj_type; uint8_t flags; uint16_t llid; int64_t size; char *name; }; struct path_info { enum { PI_FIGURE, PI_LOAD } state; uint16_t llid; char *base; char *next; int len; }; static void recover_top(char *ptr); static void recover_elm(hammer_btree_leaf_elm_t leaf); static struct recover_dict *get_dict(int64_t obj_id, uint16_t llid); static char *recover_path(struct recover_dict *dict); static void recover_path_helper(struct recover_dict *dict, struct path_info *info); static void sanitize_string(char *str); // -- CMD_SHOW.C -- static void print_btree_node(hammer_off_t node_offset, btree_search_t search, int depth, int spike, hammer_tid_t mirror_tid, hammer_base_elm_t left_bound, hammer_base_elm_t right_bound); static const char *check_data_crc(hammer_btree_elm_t elm); static void print_record(hammer_btree_elm_t elm); static void print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type, int flags, const char *label, const char *ext); static int print_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset, hammer_btree_elm_t elm, u_int8_t btype, hammer_base_elm_t left_bound, hammer_base_elm_t right_bound); static void print_bigblock_fill(hammer_off_t offset); static const char * check_data_crc(hammer_btree_elm_t elm); static void print_record(hammer_btree_elm_t elm); // -- CMD_SNAPSHOT.C -- static void snapshot_usage(int exit_code); static void snapshot_add(int fd, const char *fsym, const char *tsym, const char *label, hammer_tid_t tid); static void snapshot_ls(const char *path); static void snapshot_del(int fsfd, hammer_tid_t tid); static char *dirpart(const char *path); // -- CMD_SOFTPRUNE.C -- struct softprune { struct softprune *next; struct statfs fs; char *filesystem; struct hammer_ioc_prune prune; int maxelms; int prune_min; }; static void softprune_usage(int code); static void hammer_softprune_scandir(struct softprune **basep, struct hammer_ioc_prune *template, const char *dirname); static int hammer_softprune_scanmeta(int fd, struct softprune *scan, int delete_all); static void hammer_meta_flushdelete(int fd, struct hammer_ioc_snapshot *dsnap); static struct softprune *hammer_softprune_addentry(struct softprune **basep, struct hammer_ioc_prune *template, const char *dirpath, const char *denname, struct stat *st, const char *linkbuf, const char *tidptr); static void hammer_softprune_addelm(struct softprune *scan, hammer_tid_t tid, time_t ct, time_t mt); static void hammer_softprune_finalize(struct softprune *scan); static int hammer_softprune_qsort_cmp(const void *arg1, const void *arg2); // -- CMD_STATS.C -- void hammer_cmd_bstats(char **av, int ac); void hammer_cmd_iostats(char **av, int ac); static void loaddelay(struct timespec *ts, const char *arg); // -- CMD_STATUS.C -- void hammer_cmd_status(char **av, int ac); // -- CMD_SYNCTID.C -- void hammer_cmd_synctid(char **av, int ac); // -- CMD_VERSION.C -- void hammer_cmd_get_version(char **av, int ac); void hammer_cmd_set_version(char **av, int ac); // -- CMD_VOLUME.C -- void hammer_cmd_volume_add(char **av, int ac); void hammer_cmd_volume_del(char **av, int ac); static uint64_t check_volume(const char *vol_name); // -- CYCLE.C -- void hammer_get_cycle(hammer_base_elm_t base, hammer_tid_t *extra); void hammer_set_cycle(hammer_base_elm_t base, hammer_tid_t extra); void hammer_reset_cycle(void); // -- HAMMER.C -- static void hammer_parsedevs(const char *blkdevs); // -- MISC.C -- int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2); void hammer_key_beg_init(hammer_base_elm_t base); void hammer_key_end_init(hammer_base_elm_t base); int hammer_crc_test_leaf(void *data, hammer_btree_leaf_elm_t leaf); // -- ONDISK.C -- static void *alloc_blockmap(int zone, int bytes, hammer_off_t *result_offp, struct buffer_info **bufferp); static hammer_off_t alloc_bigblock(struct volume_info *volume, int zone); static void get_buffer_readahead(struct buffer_info *base); static void writehammerbuf(struct volume_info *vol, const void *data, int64_t offset); static __inline int buffer_hash(hammer_off_t buf_offset); struct volume_info *setup_volume(int32_t vol_no, const char *filename, int isnew, int oflags); struct volume_info *test_volume(int32_t vol_no); struct volume_info *get_volume(int32_t vol_no); void rel_volume(struct volume_info *volume); struct buffer_info *get_buffer(hammer_off_t buf_offset, int isnew); void rel_buffer(struct buffer_info *buffer); void *get_buffer_data(hammer_off_t buf_offset, struct buffer_info **bufferp, int isnew); void *alloc_btree_element(hammer_off_t *offp); void *alloc_data_element(hammer_off_t *offp, int32_t data_len, struct buffer_info **data_bufferp); void format_freemap(struct volume_info *root_vol, hammer_blockmap_t blockmap); int64_t initialize_freemap(struct volume_info *vol); void format_undomap(hammer_volume_ondisk_t ondisk); void format_blockmap(hammer_blockmap_t blockmap, hammer_off_t zone_base); void flush_all_volumes(void); void flush_volume(struct volume_info *volume); void flush_buffer(struct buffer_info *buffer); void panic(const char *ctl, ...); // -- TEST_DUPKEY.C -- static u_int32_t namekey(const char *name); static void randomname(char *name);