From: Christoph Hellwig <hch@lst.de>
To: colyli@suse.de
Cc: kent.overstreet@gmail.com, liangchen.linux@gmail.com,
linux-bcache@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH 2/7] bcache: use a separate data structure for the on-disk super block
Date: Thu, 12 Dec 2019 16:35:59 +0100 [thread overview]
Message-ID: <20191212153604.19540-3-hch@lst.de> (raw)
In-Reply-To: <20191212153604.19540-1-hch@lst.de>
Split out an on-disk version struct cache_sb with the proper endianess
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>
---
drivers/md/bcache/super.c | 6 ++---
include/uapi/linux/bcache.h | 51 +++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index a573ce1d85aa..3045f27e0d67 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -63,14 +63,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
struct page **res)
{
const char *err;
- struct cache_sb *s;
+ struct cache_sb_disk *s;
struct buffer_head *bh = __bread(bdev, 1, SB_SIZE);
unsigned int i;
if (!bh)
return "IO error";
- s = (struct cache_sb *) bh->b_data;
+ s = (struct cache_sb_disk *)bh->b_data;
sb->offset = le64_to_cpu(s->offset);
sb->version = le64_to_cpu(s->version);
@@ -209,7 +209,7 @@ static void write_bdev_super_endio(struct bio *bio)
static void __write_super(struct cache_sb *sb, struct bio *bio)
{
- struct cache_sb *out = page_address(bio_first_page_all(bio));
+ struct cache_sb_disk *out = page_address(bio_first_page_all(bio));
unsigned int i;
bio->bi_iter.bi_sector = SB_SECTOR;
diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index 5d4f58e059fd..1d8b3a9fc080 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -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 */
--
2.20.1
next prev parent reply other threads:[~2019-12-12 15:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 15:35 bcache superblock reading / writing v2 Christoph Hellwig
2019-12-12 15:35 ` [PATCH 1/7] bcache: cached_dev_free needs to put the sb page Christoph Hellwig
2019-12-12 15:35 ` Christoph Hellwig [this message]
2019-12-12 15:36 ` [PATCH 3/7] bcache: rework error unwinding in register_bcache Christoph Hellwig
2019-12-12 15:36 ` [PATCH 4/7] bcache: transfer the sb_page reference to register_{bdev,cache} Christoph Hellwig
2019-12-12 15:36 ` [PATCH 5/7] bcache: return a pointer to the on-disk sb from read_super Christoph Hellwig
2019-12-12 15:36 ` [PATCH 6/7] bcache: store a pointer to the on-disk sb in the cache and cached_dev structures Christoph Hellwig
2019-12-12 15:36 ` [PATCH 7/7] bcache: use read_cache_page_gfp to read the superblock Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2019-12-09 9:38 bcache kbuild cleanups Christoph Hellwig
2019-12-09 9:38 ` [PATCH 2/7] bcache: use a separate data structure for the on-disk super block Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212153604.19540-3-hch@lst.de \
--to=hch@lst.de \
--cc=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=liangchen.linux@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox