]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - bcache.h
bucket size must be a power of two
[bcachefs-tools-debian] / bcache.h
index e667cc015690ac985d561b9bedc347009dcdc7d1..69d3edc3da9de70b2bcab589ef05da9b5990cab7 100644 (file)
--- a/bcache.h
+++ b/bcache.h
@@ -1,64 +1,35 @@
+/*
+ * Author: Kent Overstreet <kent.overstreet@gmail.com>
+ *
+ * GPLv2
+ */
+
 #ifndef _BCACHE_H
 #define _BCACHE_H
 
-#define BITMASK(name, type, field, offset, size)               \
-static inline uint64_t name(const type *k)                     \
-{ return (k->field >> offset) & ~(((uint64_t) ~0) << size); }  \
-                                                               \
-static inline void SET_##name(type *k, uint64_t v)             \
-{                                                              \
-       k->field &= ~(~((uint64_t) ~0 << size) << offset);      \
-       k->field |= v << offset;                                \
-}
-
-static const char bcache_magic[] = {
-       0xc6, 0x85, 0x73, 0xf6, 0x4e, 0x1a, 0x45, 0xca,
-       0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81 };
-
-#define SB_SECTOR              8
-#define SB_LABEL_SIZE          32
-
-struct cache_sb {
-       uint64_t                csum;
-       uint64_t                offset; /* sector where this sb was written */
-       uint64_t                version;
-#define CACHE_BACKING_DEV      1
-
-       uint8_t                 magic[16];
-
-       uint8_t                 uuid[16];
-       union {
-               uint8_t         set_uuid[16];
-               uint64_t        set_magic;
-       };
-       uint8_t                 label[SB_LABEL_SIZE];
-
-       uint64_t                flags;
-       uint64_t                seq;
-       uint64_t                pad[8];
-
-       uint64_t                nbuckets;       /* device size */
-       uint16_t                block_size;     /* sectors */
-       uint16_t                bucket_size;    /* sectors */
-
-       uint16_t                nr_in_set;
-       uint16_t                nr_this_dev;
-
-       uint32_t                last_mount;     /* time_t */
+#include "util.h"
 
-       uint16_t                first_bucket;
-       uint16_t                keys;           /* number of journal buckets */
-       uint64_t                d[];            /* journal buckets */
-};
+extern const char * const cache_state[];
+extern const char * const replacement_policies[];
+extern const char * const csum_types[];
+extern const char * const compression_types[];
+extern const char * const error_actions[];
+extern const char * const bdev_cache_mode[];
+extern const char * const bdev_state[];
 
-BITMASK(BDEV_WRITEBACK,        struct cache_sb, flags, 0, 1);
+int cmd_format(int argc, char *argv[]);
 
-inline uint64_t crc64(const void *_data, size_t len);
+int cmd_unlock(int argc, char *argv[]);
+int cmd_assemble(int argc, char *argv[]);
+int cmd_incremental(int argc, char *argv[]);
+int cmd_run(int argc, char *argv[]);
+int cmd_stop(int argc, char *argv[]);
 
-#define node(i, j)             ((void *) ((i)->d + (j)))
-#define end(i)                 node(i, (i)->keys)
+int cmd_fs_show(int argc, char *argv[]);
+int cmd_fs_set(int argc, char *argv[]);
 
-#define csum_set(i)                                                    \
-       crc64(((void *) (i)) + 8, ((void *) end(i)) - (((void *) (i)) + 8))
+int cmd_device_show(int argc, char *argv[]);
+int cmd_device_add(int argc, char *argv[]);
+int cmd_device_remove(int argc, char *argv[]);
 
-#endif
+#endif /* _BCACHE_H */