2019-10-09 18:06:43 +02:00
|
|
|
#ifndef CBD_H
|
|
|
|
#define CBD_H
|
|
|
|
|
|
|
|
/* Kernel compatibility */
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
2019-11-04 15:14:37 +01:00
|
|
|
#include <stdbool.h>
|
2019-10-09 18:06:43 +02:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
#ifndef BITS_PER_BYTE
|
|
|
|
#define BITS_PER_BYTE 8
|
|
|
|
#endif
|
|
|
|
|
2019-11-12 22:25:46 +01:00
|
|
|
#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
|
|
|
|
|
2019-10-09 18:06:43 +02:00
|
|
|
#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 <linux/dm-compress.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define CBD_DEFAULT_COMPRESSION_FACTOR 2.0
|
2019-11-12 22:25:46 +01:00
|
|
|
#define CBD_DEFAULT_PHYSICAL_BLOCK_SHIFT 3
|
2019-10-09 18:06:43 +02:00
|
|
|
#define CBD_DEFAULT_LOGICAL_BLOCK_SHIFT 4
|
|
|
|
|
|
|
|
/* XXX: move to types.h */
|
|
|
|
typedef enum {
|
|
|
|
t_false,
|
|
|
|
t_true,
|
|
|
|
t_none
|
|
|
|
} tristate_t;
|
|
|
|
|
|
|
|
int cbd_format(const char* dev,
|
2019-11-12 22:25:46 +01:00
|
|
|
enum cbd_alg alg, uint level,
|
2019-11-14 00:13:12 +01:00
|
|
|
uint8_t pshift, uint8_t lshift,
|
|
|
|
uint8_t pbatshift,
|
2019-11-15 19:30:47 +01:00
|
|
|
uint64_t psize, uint64_t lsize,
|
|
|
|
bool full_init);
|
2019-10-09 18:06:43 +02:00
|
|
|
int cbd_open(const char* dev,
|
2019-11-14 18:51:46 +01:00
|
|
|
const char* name,
|
|
|
|
uint64_t cache_pages, bool sync);
|
2019-10-09 18:06:43 +02:00
|
|
|
int cbd_close(const char* name);
|
|
|
|
|
2019-11-04 21:25:54 +01:00
|
|
|
int cbd_stats(const char* dev, struct cbd_stats* stats);
|
2019-10-09 18:06:43 +02:00
|
|
|
|
2019-10-10 22:21:36 +02:00
|
|
|
int cbd_check(const char* dev,
|
2019-11-04 15:14:37 +01:00
|
|
|
bool force,
|
2019-11-11 20:48:46 +01:00
|
|
|
tristate_t auto_response,
|
|
|
|
bool full_check);
|
2019-10-09 18:06:43 +02:00
|
|
|
int cbd_resize(const char* dev,
|
2019-10-10 22:21:36 +02:00
|
|
|
uint64_t lsize);
|
2019-10-09 18:06:43 +02:00
|
|
|
|
|
|
|
#endif
|