#ifndef _LIBHAMMER_H_
#define _LIBHAMMER_H_
#include <sys/queue.h>
#include <sys/param.h>
#include <vfs/hammer/hammer_disk.h>
#include <vfs/hammer/hammer_ioctl.h>
#define TXTLEN 64
#define SNAPSHOTS_BASE "/var/hammer"
struct libhammer_head {
int32_t error;
int32_t flags;
int32_t rsv[2];
};
typedef struct libhammer_snapinfo {
struct libhammer_head head;
TAILQ_ENTRY(libhammer_snapinfo) entries;
hammer_tid_t tid;
u_int64_t ts;
char label[64];
u_int64_t rsv;
} *libhammer_snapinfo_t;
typedef struct libhammer_pfsinfo {
struct libhammer_head head;
uint32_t snapcount;
u_int32_t version;
char *mountedon;
int ismaster;
int pfs_id;
int mirror_flags;
char snapshots[64];
uuid_t unique_uuid;
TAILQ_ENTRY(libhammer_pfsinfo) entries;
TAILQ_HEAD(snaplist, libhammer_snapinfo) list_snap;
hammer_tid_t beg_tid;
hammer_tid_t end_tid;
uint64_t rsv[4];
} *libhammer_pfsinfo_t;
typedef struct libhammer_fsinfo {
struct libhammer_head head;
char vol_name[TXTLEN];
uuid_t vol_fsid;
int version;
int nvolumes;
int64_t inodes;
int64_t bigblocks;
int64_t freebigblocks;
int64_t rsvbigblocks;
int32_t rootvol;
int32_t rsv[7];
TAILQ_HEAD(pfslist, libhammer_pfsinfo) list_pseudo;
} *libhammer_fsinfo_t;
struct libhammer_btree_stats {
int64_t elements;
int64_t iterations;
int64_t splits;
int64_t inserts;
int64_t deletes;
int64_t lookups;
int64_t searches;
};
struct libhammer_io_stats {
int64_t undo;
int64_t dev_writes;
int64_t dev_reads;
int64_t file_writes;
int64_t file_reads;
int64_t file_iop_writes;
int64_t file_iop_reads;
int64_t inode_flushes;
int64_t commits;
};
__BEGIN_DECLS
libhammer_fsinfo_t libhammer_get_fsinfo(const char *);
void libhammer_free_fsinfo(libhammer_fsinfo_t);
int libhammer_stats_redo(int64_t *);
int libhammer_stats_undo(int64_t *);
int libhammer_stats_commits(int64_t *);
int libhammer_stats_inode_flushes(int64_t *);
int libhammer_stats_disk_write(int64_t *);
int libhammer_stats_disk_read(int64_t *);
int libhammer_stats_file_iopsw(int64_t *);
int libhammer_stats_file_iopsr(int64_t *);
int libhammer_stats_file_write(int64_t *);
int libhammer_stats_file_read(int64_t *);
int libhammer_stats_record_iterations(int64_t *);
int libhammer_stats_root_iterations(int64_t *);
int libhammer_stats_btree_iterations(int64_t *);
int libhammer_stats_btree_splits(int64_t *);
int libhammer_stats_btree_elements(int64_t *);
int libhammer_stats_btree_deletes(int64_t *);
int libhammer_stats_btree_inserts(int64_t *);
int libhammer_stats_btree_lookups(int64_t *);
int libhammer_stats_btree_searches(int64_t *);
int libhammer_btree_stats(struct libhammer_btree_stats *);
int libhammer_io_stats(struct libhammer_io_stats *);
int libhammer_pfs_get_snapshots(libhammer_fsinfo_t, libhammer_pfsinfo_t);
void libhammer_pfs_free_snapshots(libhammer_pfsinfo_t);
char *libhammer_find_pfs_mount(uuid_t *);
void libhammer_pfs_canonical_path(char *, libhammer_pfsinfo_t, char **);
void *_libhammer_malloc(size_t);
void libhammer_compat_old_snapcount(libhammer_pfsinfo_t);
__END_DECLS
static __inline libhammer_pfsinfo_t
libhammer_get_next_pfs(libhammer_pfsinfo_t pfsinfo)
{
return TAILQ_NEXT(pfsinfo, entries);
}
static __inline libhammer_pfsinfo_t
libhammer_get_prev_pfs(libhammer_pfsinfo_t pfsinfo)
{
return TAILQ_PREV(pfsinfo, pfslist, entries);
}
static __inline libhammer_pfsinfo_t
libhammer_get_first_pfs(libhammer_fsinfo_t fip)
{
return TAILQ_FIRST(&fip->list_pseudo);
}
static __inline libhammer_pfsinfo_t
libhammer_get_last_pfs(libhammer_fsinfo_t fip)
{
return TAILQ_LAST(&fip->list_pseudo, pfslist);
}
static __inline libhammer_snapinfo_t
libhammer_get_next_snap(libhammer_snapinfo_t sip)
{
return TAILQ_NEXT(sip, entries);
}
static __inline libhammer_snapinfo_t
libhammer_get_prev_snap(libhammer_snapinfo_t sip)
{
return TAILQ_PREV(sip, snaplist, entries);
}
static __inline libhammer_snapinfo_t
libhammer_get_first_snap(libhammer_pfsinfo_t pip)
{
return TAILQ_FIRST(&pip->list_snap);
}
static __inline libhammer_snapinfo_t
libhammer_get_last_snap(libhammer_pfsinfo_t pip)
{
return TAILQ_LAST(&pip->list_snap, snaplist);
}
#endif