<div dir="ltr">To support arbitrary page size for superblock,include 4K/8K/64K currently, the off_set of SB_SECTOR should be a LCM(least common multiple) and that is 64. I redefine macro SB_SECTOR and BDEV_DATA_START_DEFAULT just as bellow patch showed:<br> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c<br> index ef567cd..1622f44 100644<br> --- a/drivers/md/bcache/super.c<br> +++ b/drivers/md/bcache/super.c<br> @@ -74,7 +74,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,<br> {<br> const char *err;<br> struct cache_sb *s;<br> - struct buffer_head *bh = __bread(bdev, 1, SB_SIZE);<br> + <b>struct buffer_head *bh = __bread(bdev, 16, SB_SIZE);</b><br> unsigned i;<br> <br> if (!bh)<br> diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h<br> index 22b6ad3..eb948c8 100644<br> --- a/include/uapi/linux/bcache.h<br> +++ b/include/uapi/linux/bcache.h<br> @@ -144,14 +144,14 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned nr_keys)<br> #define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4<br> #define BCACHE_SB_MAX_VERSION 4<br> <br> -#define SB_SECTOR 8<br> <b>+#define SB_SECTOR 128</b><br> #define SB_SIZE 4096<br> #define SB_LABEL_SIZE 32<br> #define SB_JOURNAL_BUCKETS 256U<br> /* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */<br> #define MAX_CACHES_PER_SET 8<br> <br> -#define BDEV_DATA_START_DEFAULT 16 /* sectors */<br> <b>+#define BDEV_DATA_START_DEFAULT 256 /* sectors */</b><br> <br> struct cache_sb {<br> __u64 csum;<br><div class="gmail_extra"><br></div><div class="gmail_extra">The second arg of <b>__bread(bdev, 16, SB_SIZE) </b>has unit of block size and it need be relocated too.</div><div class="gmail_extra">To suitable this change, bcache-tools need be fixed up too. </div><div class="gmail_extra">As for btree_node_size issues about page size, expecting somebody to commit a patch.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Kent, maybe you could use qemu to simulate ARM64 arch and there is always ubuntu image for ARM64 on the internet. </div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-02 7:16 GMT+08:00 Kent Overstreet <span dir="ltr"><<a href="mailto:kent.overstreet@gmail.com" target="_blank">kent.overstreet@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Wed, Jun 01, 2016 at 11:05:20AM -0700, Eric Wheeler wrote:<br>
> On Wed, 1 Jun 2016, Zhengyuan Liu wrote:<br>
><br>
> > Hi, I have created a mapped block device (bcach0) using make-bcache on<br>
> > ARM64 server which has kernel enable 64K page size. However, the<br>
> > bcach0 disappeared after the server reboot and there is no or dirty<br>
> > metadata on super block of both cache device and back device . The<br>
> > output of command bcache-super-show was as bellow showed:<br>
> > [root@master Linux-4.4-LTS-storage]# bcache-super-show /dev/sdb<br>
> > sb.magic bad magic<br>
> > Invalid superblock (bad magic)<br>
> > /dev/sdb was the backing device and cache device got bad magic too.<br>
> ><br>
> > I tried to traced the written process of super block in bcache source<br>
> > code and found that is the issue of PAGE_SIZE. It seems that the<br>
> > bcache was designed only considering for 4K PAGE_SIZE and it works<br>
> > right only on 4K PAGE_SIZE exactly. To make bcache work correctly on<br>
> > 64K PAGE_SIZE, I committed a patch as bellow showd:<br>
> > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c<br>
> > index 330cd6e..ef567cd 100644<br>
> > --- a/drivers/md/bcache/super.c<br>
> > +++ b/drivers/md/bcache/super.c<br>
> > @@ -224,6 +224,12 @@ static void __write_super(struct cache_sb<br>
> > *sb, struct bio *bio<br>
> > bio->bi_iter.bi_size = SB_SIZE;<br>
> > bch_bio_map(bio, NULL);<br>
> ><br>
> > +#ifdef CONFIG_ARM64_64K_PAGES<br>
> > + out = (struct cache_sb *)((char *)out + (SB_SECTOR<<9));<br>
> > + pr_debug("sb_page_adress %x, sb_address %x,page_size<br>
> > %d\n",page_address(bio<br>
> > + bio->bi_io_vec[0].bv_offset = (SB_SECTOR<<9);<br>
> > +#endif<br>
> ><br>
> > out->offset = cpu_to_le64(sb->offset);<br>
> > out->version = cpu_to_le64(sb->version);<br>
> ><br>
> > Does it not recommend to use bcache on 64K PAGE_SIZE? or it only<br>
> > considers for 4K PAGE_SIZE for bcache currently?<br>
> > Maybe it is more suitable for me to redefine some macro such as<br>
> > SB_SECTOR, BDEV_DATA_START_DEFAULT to make bcache work correctly on<br>
> > both 64K PAGE_SIZE and 4K PAGE_SIZE.<br>
><br>
> I think a patch to support arbitrary page size would be great. Can<br>
> you write the macros in terms of PAGE_SIZE or PAGE_SHIFT?<br>
<br>
</div></div>It shouldn't be referencing PAGE_SIZE at all - creating a new macro<br>
(BCH_SB_SIZE, perhaps) is the correct approach.<br>
<br>
The code that allocates the buffer for the superblock will have to be fixed<br>
too - right now it's probably using __get_free_page(), it should probably just<br>
be switched to kmalloc().<br>
<span class=""><br>
> (Out of curiosity, what ARM64 hardware are you using?)<br>
><br>
> Kent, this may affect bcachefs too. Can you think of any other places<br>
> that might have PAGE_SIZE!=4k issues?<br>
<br>
</span>Oh, there's probably a couple. There's probably some stuff that'll break if<br>
btree_node_size is smaller than PAGE_SIZE, too...<br>
<br>
If it turns out to be too much for Zhengyuan, I can probably fix upstream too<br>
(but I don't have any hardware to test with).<br>
</blockquote></div><br></div></div>