bcache: use a separate data structure for the on-disk super block

Split out an on-disk version struct cache_sb with the proper endianness
annotations.  This fixes a fair chunk of sparse warnings, but there are
some left due to the way the checksum is defined.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig
2020-01-24 01:01:27 +08:00
committed by Jens Axboe
parent e8547d4209
commit a702a692cd
2 changed files with 54 additions and 3 deletions

View File

@@ -156,6 +156,57 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
#define BDEV_DATA_START_DEFAULT 16 /* sectors */
struct cache_sb_disk {
__le64 csum;
__le64 offset; /* sector where this sb was written */
__le64 version;
__u8 magic[16];
__u8 uuid[16];
union {
__u8 set_uuid[16];
__le64 set_magic;
};
__u8 label[SB_LABEL_SIZE];
__le64 flags;
__le64 seq;
__le64 pad[8];
union {
struct {
/* Cache devices */
__le64 nbuckets; /* device size */
__le16 block_size; /* sectors */
__le16 bucket_size; /* sectors */
__le16 nr_in_set;
__le16 nr_this_dev;
};
struct {
/* Backing devices */
__le64 data_offset;
/*
* block_size from the cache device section is still used by
* backing devices, so don't add anything here until we fix
* things to not need it for backing devices anymore
*/
};
};
__le32 last_mount; /* time overflow in y2106 */
__le16 first_bucket;
union {
__le16 njournal_buckets;
__le16 keys;
};
__le64 d[SB_JOURNAL_BUCKETS]; /* journal buckets */
};
struct cache_sb {
__u64 csum;
__u64 offset; /* sector where this sb was written */