Re: bcache backing and caching devices not recognized between reboots PPC64EL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

The patch did not apply cleanly, however, the part that was rejected was easy to add in manually. Unfortunately, it did not fix my issue. There appears to be no change in the behavior.

Here's the patch for 4.18.3 if you need to verify. It seems to be identical (other than the offsets of course):

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index fa4058e43202..e7e563c28450 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -56,7 +56,7 @@ struct workqueue_struct *bcache_wq;
 /* Superblock */

 static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
-                  struct page **res)
+                  struct bio_vec *bv)
 {
     const char *err;
     struct cache_sb *s;
@@ -185,7 +185,9 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
     err = NULL;

     get_page(bh->b_page);
-    *res = bh->b_page;
+    bv->bv_page = bh->b_page;
+    bv->bv_len = SB_SIZE;
+    bv->bv_offset = (unsigned long)bh->b_data & ~PAGE_MASK;
 err:
     put_bh(bh);
     return err;
@@ -201,7 +203,8 @@ 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 *out = page_address(bio_first_bvec_all(bio)->bv_page) +
+      bio_first_bvec_all(bio)->bv_offset;
     unsigned i;

     bio->bi_iter.bi_sector    = SB_SECTOR;
@@ -1255,7 +1258,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)

 /* Cached device - bcache superblock */

-static void register_bdev(struct cache_sb *sb, struct page *sb_page,
+static void register_bdev(struct cache_sb *sb, struct bio_vec *bv,
                  struct block_device *bdev,
                  struct cached_dev *dc)
 {
@@ -1268,8 +1271,8 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
     dc->bdev->bd_holder = dc;

     bio_init(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
-    bio_first_bvec_all(&dc->sb_bio)->bv_page = sb_page;
-    get_page(sb_page);
+    memcpy(bio_first_bvec_all(&dc->sb_bio), bv, sizeof(*bv));
+    get_page(bv->bv_page);


     if (cached_dev_init(dc, sb->block_size << 9))
@@ -2057,7 +2060,7 @@ static int cache_alloc(struct cache *ca)
     return 0;
 }

-static int register_cache(struct cache_sb *sb, struct page *sb_page,
+static int register_cache(struct cache_sb *sb, struct bio_vec *bv,
                 struct block_device *bdev, struct cache *ca)
 {
     const char *err = NULL; /* must be set for any error case */
@@ -2069,8 +2072,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
     ca->bdev->bd_holder = ca;

     bio_init(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
-    bio_first_bvec_all(&ca->sb_bio)->bv_page = sb_page;
-    get_page(sb_page);
+    memcpy(bio_first_bvec_all(&ca->sb_bio), bv, sizeof(*bv));
+    get_page(bv->bv_page);

     if (blk_queue_discard(bdev_get_queue(bdev)))
         ca->discard = CACHE_DISCARD(&ca->sb);
@@ -2158,7 +2161,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
     char *path = NULL;
     struct cache_sb *sb = NULL;
     struct block_device *bdev = NULL;
-    struct page *sb_page = NULL;
+    struct bio_vec bv = { NULL };

     if (!try_module_get(THIS_MODULE))
         return -EBUSY;
@@ -2192,7 +2195,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
     if (set_blocksize(bdev, 4096))
         goto err_close;

-    err = read_super(sb, bdev, &sb_page);
+    err = read_super(sb, bdev, &bv);
     if (err)
         goto err_close;

@@ -2203,19 +2206,19 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
             goto err_close;

         mutex_lock(&bch_register_lock);
-        register_bdev(sb, sb_page, bdev, dc);
+        register_bdev(sb, &bv, bdev, dc);
         mutex_unlock(&bch_register_lock);
     } else {
         struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
         if (!ca)
             goto err_close;

-        if (register_cache(sb, sb_page, bdev, ca) != 0)
+        if (register_cache(sb, &bv, bdev, ca) != 0)
             goto err;
     }
 out:
-    if (sb_page)
-        put_page(sb_page);
+    if (bv.bv_page)
+        put_page(bv.bv_page);
     kfree(sb);
     kfree(path);
     module_put(THIS_MODULE);




On 10/12/2018 09:10 AM, guoju fang wrote:
Hi Cameron,

I just submitted a patch for non-4Kb page size, please try it on POWER9.

Best Regards,

Guoju

On 2018/10/12 14:30, Cameron Berkenpas wrote:
Thanks!

Will this allow bcache to work with non-4k page sizes? Or just prevent them from being corrupted?

As it turns out, 4k pages is the direction I want to go in anyway, but it would be good to avoid corruption in case the system is accidentally booted with 64k pages again.

On 10/11/2018 11:28 PM, guoju fang wrote:
It looks like the same problem that superblock will be corrupted when PAGE_SIZE is not 4KB. I will submit a patch today.

On 2018/10/12 14:21, Cameron Berkenpas wrote:
Turns out the default page size is 64k on POWER!

Unfortunately, switching for me is a bit difficult right now... Because I'm using BTRFS. BTRFS formatted for 64k page sizes won't mount on a system configured for 4k page sizes...

I'll be able to try it out this weekend though and report back.

Thanks!

-Cameron

On 10/11/2018 08:07 PM, guoju fang wrote:
I've had a similar problem that superblock is corrupted when PAGE_SIZE is 8KB.

On 2018/10/12 5:23, Cameron Berkenpas wrote:
It's probably important to mention that I'm currently running kernel 4.18.13.

On 10/11/2018 02:18 PM, Cameron Berkenpas wrote:
Hello,

On my POWER9 machine running Debian ppc64EL (little endian), my caching and backing devices mostly aren't recognized between reboots.

The caching device is NEVER recognized between reboots.

The backing device will be recognized between reboots and the filesystem will be accessible/mountable provided I have never attached a caching device to it.

It doesn't matter if I detach the caching device before I reboot, the backing device will not be recognized between reboots if it has ever had a caching device attached.

The caching device after a reboot:
bcache-super-show /dev/sdxy
Invalid superblock (bad magic)
-bash: echo: write error: Invalid argument

If the caching device had been attached to the backing device, the result is the same for the backing device.

-Cameron








[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux