#ifndef CBD_H #define CBD_H /* Kernel compatibility */ #include #include #include #include #ifndef BITS_PER_BYTE #define BITS_PER_BYTE 8 #endif #ifndef SECTOR_SHIFT #define SECTOR_SHIFT 9 #endif #ifndef SECTOR_SIZE #define SECTOR_SIZE (1 << SECTOR_SHIFT) #endif #ifndef PAGE_SHIFT #define PAGE_SHIFT 12 #endif #ifndef PAGE_SIZE #define PAGE_SIZE (1 << PAGE_SHIFT) #endif #ifndef PBLK_SHIFT #define PBLK_SHIFT 12 #endif #ifndef PBLK_SIZE #define PBLK_SIZE (1 << PBLK_SHIFT) #endif #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef max #define max(a, b) ((a) < (b) ? (b) : (a)) #endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif #ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #endif #ifndef ROUND_UP #define ROUND_UP(n, d) (DIV_ROUND_UP(n, d) * (n)) #endif typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; #include #include #define CBD_DEFAULT_COMPRESSION_FACTOR 1.5 #define CBD_DEFAULT_LOGICAL_BLOCK_SHIFT 4 /* XXX: move to types.h */ typedef enum { t_false, t_true, t_none } tristate_t; struct cbd_info { u64 lbatpblk_r; u64 lbatpblk_w; u64 lbd_r; u64 lbd_w; u64 lblk_size; u64 lblk_total; u64 lblk_used; u64 pbat_r; u64 pbat_w; u64 pblk_total; u64 pblk_used; u64 zone_init; u64 zone_total; }; int cbd_format(const char* dev, uint16_t flags, enum cbd_alg alg, uint level, uint8_t lshift, uint64_t psize, uint64_t lsize, bool full_init); int cbd_open(const char* dev, const char* name, uint64_t cache_pages, bool sync); int cbd_close(const char* name); int cbd_stats(const char* dev, struct cbd_stats* stats); int cbd_info(const char* dev, struct cbd_info* info); int cbd_check(const char* dev, bool force, tristate_t auto_response, bool full_check); int cbd_resize(const char* dev, uint64_t lsize); int cbd_tune(const char* dev, tristate_t zero_detect, uint level, bool repack); #endif