2016-08-18 00:23:03 +03:00
|
|
|
#ifndef _LIBBCACHE_H
|
|
|
|
#define _LIBBCACHE_H
|
|
|
|
|
2017-02-02 06:16:42 +03:00
|
|
|
#include <linux/uuid.h>
|
2017-03-20 02:56:34 +03:00
|
|
|
#include <stdbool.h>
|
2016-08-18 00:23:03 +03:00
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
#include "bcachefs_format.h"
|
2017-02-02 06:16:42 +03:00
|
|
|
#include "tools-util.h"
|
2017-03-20 02:56:34 +03:00
|
|
|
#include "vstructs.h"
|
2017-02-02 06:16:42 +03:00
|
|
|
|
|
|
|
struct cache_sb;
|
|
|
|
|
|
|
|
enum fsck_err_opts {
|
|
|
|
FSCK_ERR_ASK,
|
|
|
|
FSCK_ERR_YES,
|
|
|
|
FSCK_ERR_NO,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern enum fsck_err_opts fsck_err_opt;
|
2016-10-04 12:10:24 +03:00
|
|
|
|
2017-03-01 13:45:15 +03:00
|
|
|
struct format_opts {
|
|
|
|
char *label;
|
|
|
|
uuid_le uuid;
|
|
|
|
|
|
|
|
unsigned on_error_action;
|
|
|
|
unsigned max_journal_entry_size; /* will be removed */
|
|
|
|
|
|
|
|
unsigned block_size;
|
|
|
|
unsigned btree_node_size;
|
|
|
|
|
|
|
|
unsigned meta_replicas;
|
|
|
|
unsigned data_replicas;
|
|
|
|
|
2017-03-09 20:27:30 +03:00
|
|
|
unsigned meta_replicas_required;
|
|
|
|
unsigned data_replicas_required;
|
|
|
|
|
2017-03-01 13:45:15 +03:00
|
|
|
unsigned meta_csum_type;
|
|
|
|
unsigned data_csum_type;
|
|
|
|
unsigned compression_type;
|
|
|
|
|
|
|
|
bool encrypted;
|
|
|
|
char *passphrase;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct format_opts format_opts_default()
|
|
|
|
{
|
|
|
|
return (struct format_opts) {
|
|
|
|
.on_error_action = BCH_ON_ERROR_RO,
|
|
|
|
.meta_csum_type = BCH_CSUM_CRC32C,
|
|
|
|
.data_csum_type = BCH_CSUM_CRC32C,
|
|
|
|
.meta_replicas = 1,
|
|
|
|
.data_replicas = 1,
|
2017-03-09 20:27:30 +03:00
|
|
|
.meta_replicas_required = 1,
|
|
|
|
.data_replicas_required = 1,
|
2017-03-01 13:45:15 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-08-18 00:23:03 +03:00
|
|
|
struct dev_opts {
|
|
|
|
int fd;
|
2017-03-01 13:45:15 +03:00
|
|
|
char *path;
|
2016-08-18 00:23:03 +03:00
|
|
|
u64 size; /* 512 byte sectors */
|
|
|
|
unsigned bucket_size;
|
|
|
|
unsigned tier;
|
|
|
|
bool discard;
|
|
|
|
|
|
|
|
u64 nbuckets;
|
2017-03-01 13:45:15 +03:00
|
|
|
|
|
|
|
u64 sb_offset;
|
|
|
|
u64 sb_end;
|
2016-08-18 00:23:03 +03:00
|
|
|
};
|
|
|
|
|
2017-03-01 13:45:15 +03:00
|
|
|
struct bch_sb *bcache_format(struct format_opts, struct dev_opts *, size_t);
|
2016-08-18 00:23:03 +03:00
|
|
|
|
2017-03-01 13:45:15 +03:00
|
|
|
void bcache_super_write(int, struct bch_sb *);
|
|
|
|
struct bch_sb *__bcache_super_read(int, u64);
|
2016-10-04 06:22:17 +03:00
|
|
|
struct bch_sb *bcache_super_read(const char *);
|
2016-10-04 12:10:24 +03:00
|
|
|
|
2016-10-04 06:22:17 +03:00
|
|
|
void bcache_super_print(struct bch_sb *, int);
|
2016-08-18 00:23:03 +03:00
|
|
|
|
|
|
|
#endif /* _LIBBCACHE_H */
|