From: Pavel Machek <pavel@ucw.cz>
To: Theodore Ts'o <tytso@mit.edu>,
Reindl Harald <h.reindl@thelounge.net>,
linux-ext4@vger.kernel.org,
kernel list <linux-kernel@vger.kernel.org>,
kent.overstreet@gmail.com, linux-bcache@vger.kernel.org
Subject: Re: bcache with existing ext4 filesystem
Date: Tue, 25 Jul 2017 15:46:04 +0200 [thread overview]
Message-ID: <20170725134604.GA26445@amd> (raw)
In-Reply-To: <20170725045156.kbyaxj4mmi75yyt5@thunk.org>
[-- Attachment #1: Type: text/plain, Size: 3855 bytes --]
Hi!
> > Question for you was... Is the first 1KiB of each ext4 filesystem still
> > free and "reserved for a bootloader"?
>
> Yes.
>
> > If I needed more for bcache superblock (8KiB, IIRC), would that be
> > easy to accomplish on existing filesystem?
>
> Huh? Why would the bcache superblock matter when you're talking about
> the ext4 layout? The bcache superblock will be on the bcache
> device/partition, and the ext4 superblock will be on the ext4
> device/partition.
So this is what I came up with so far. With SSD in USB2 envelope (and
previous version of the patch), git diff goes from 9seconds to
3seconds; not too bad. git diff on (different) ssd is 1.5seconds.
Warning: this is rather dangerous, as it is easy to make cache go
out-of-sync with data partition. To solve that...
Is there some field in ext2 superblock that changes every time
filesystem is changed? Is mtime changed by fsck/badblocks/...?
Best regards,
Pavel
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index e57353e..f8c0aef 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -6,6 +6,7 @@
* Copyright 2012 Google, Inc.
*/
+#define DEBUG
#include "bcache.h"
#include "btree.h"
#include "debug.h"
@@ -67,7 +68,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
{
const char *err;
struct cache_sb *s;
- struct buffer_head *bh = __bread(bdev, 1, SB_SIZE);
+ struct buffer_head *bh = __bread(bdev, SB_SECTOR/8, SB_SIZE);
unsigned i;
if (!bh)
@@ -95,10 +96,11 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
pr_debug("read sb version %llu, flags %llu, seq %llu, journal size %u",
sb->version, sb->flags, sb->seq, sb->keys);
- err = "Not a bcache superblock";
+ err = "Not a bcache superblock: offset";
if (sb->offset != SB_SECTOR)
goto err;
+ err = "Not a bcache superblock: magic";
if (memcmp(sb->magic, bcache_magic, 16))
goto err;
@@ -124,7 +126,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
case BCACHE_SB_VERSION_BDEV:
sb->data_offset = BDEV_DATA_START_DEFAULT;
break;
- case BCACHE_SB_VERSION_BDEV_WITH_OFFSET:
+// case BCACHE_SB_VERSION_BDEV_WITH_OFFSET:
sb->data_offset = le64_to_cpu(s->data_offset);
err = "Bad data offset";
@@ -132,6 +134,15 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
goto err;
break;
+ case BCACHE_SB_VERSION_BDEV_WITH_OFFSET:
+ case BCACHE_SB_VERSION_BDEV_EXT4_LITE:
+ sb->data_offset = le64_to_cpu(s->data_offset);
+ printk("Size of sb is %d\n", sizeof(*sb));
+ WARN_ON(sizeof(*sb) > 1024);
+ if (sizeof(*sb) > 1024)
+ goto err;
+ break;
+
case BCACHE_SB_VERSION_CDEV:
case BCACHE_SB_VERSION_CDEV_WITH_UUID:
sb->nbuckets = le64_to_cpu(s->nbuckets);
diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index e3bb063..b1ef80c 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -142,12 +142,13 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned nr_keys)
#define BCACHE_SB_VERSION_BDEV 1
#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
-#define BCACHE_SB_MAX_VERSION 4
+#define BCACHE_SB_VERSION_BDEV_EXT4_LITE 5
+#define BCACHE_SB_MAX_VERSION 5
-#define SB_SECTOR 8
+#define SB_SECTOR 0
#define SB_SIZE 4096
#define SB_LABEL_SIZE 32
-#define SB_JOURNAL_BUCKETS 256U
+#define SB_JOURNAL_BUCKETS 64U
/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */
#define MAX_CACHES_PER_SET 8
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-07-25 13:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 18:57 bcache with existing ext4 filesystem Pavel Machek
2017-07-24 19:08 ` Reindl Harald
2017-07-24 19:15 ` Pavel Machek
2017-07-24 19:27 ` Theodore Ts'o
2017-07-24 20:04 ` Pavel Machek
2017-07-25 4:51 ` Theodore Ts'o
2017-07-25 6:43 ` Pavel Machek
2017-07-25 10:32 ` Vojtech Pavlik
2017-07-25 11:12 ` Pavel Machek
2017-07-25 16:10 ` Theodore Ts'o
2017-07-25 16:10 ` Theodore Ts'o
2017-07-25 18:13 ` Eric Wheeler
2017-07-25 22:02 ` Pavel Machek
2017-07-26 17:41 ` Eric Wheeler
2017-07-26 18:59 ` Austin S. Hemmelgarn
2017-07-26 19:16 ` Eric Wheeler
2017-07-26 20:01 ` Pavel Machek
2017-07-25 13:46 ` Pavel Machek [this message]
2017-07-25 18:02 ` Theodore Ts'o
2017-07-25 20:55 ` Pavel Machek
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=20170725134604.GA26445@amd \
--to=pavel@ucw.cz \
--cc=h.reindl@thelounge.net \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.