Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 638206 - sys-kernel/gentoo-sources-4.14.0 - bcache destroys filesystems
Summary: sys-kernel/gentoo-sources-4.14.0 - bcache destroys filesystems
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal critical (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL: https://www.spinics.net/lists/linux-b...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-20 10:15 UTC by bug2017
Modified: 2017-11-26 10:55 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bug2017 2017-11-20 10:15:16 UTC
Using bcache can destroy the filesystem. Mine was gone after 3rd non sucesfull try to mount the rootfs. It was not possible to recover any file. (I had backups...)

Another report on the bcache mailing list:
https://www.spinics.net/lists/linux-bcache/msg05290.html

I would sugest to mask it with a warning that there is an bcache issue.
Comment 1 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 08:02:20 UTC
thanks for the report
Comment 2 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 08:29:57 UTC
masked the package and searching for more informations
Comment 3 xxoo 2017-11-21 09:46:31 UTC
maybe  no need to mask , 4.14.1 released !
Comment 4 Tomáš Mózes 2017-11-21 10:02:48 UTC
Sent to stable list an hour ago:

https://www.spinics.net/lists/stable/msg198707.html:
Hi---

Previously sent to stable was this patch, and it's made it into
Linus's tree for 4.16.  It's a rather urgent data corruption issue
that affects at minimum bcache but possibly other block subsystems.
Several users have lost data.  The issue was introduced in the 4.15
branch by 74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer
and partitions index").

I'd really appreciate anything that can be done to get this into a
stable 4.15 release soon.

Thanks--

Mike

+ update (not yet indexed)

I don't know what I was thinking here, but I meant 4.14/4.15 and not
4.15/4.16.  :P

Mike
Comment 5 Tomáš Mózes 2017-11-21 10:28:30 UTC
Can you please try this patch? Probably a good candidate along with the 4.14.1 bump.

commit 62530ed8b1d07a45dec94d46e521c0c6c2d476e6
Author: Michael Lyle <mlyle@lyle.org>
Date:   Thu Nov 16 23:47:25 2017 -0800

    bio: ensure __bio_clone_fast copies bi_partno
    
    A new field was introduced in 74d46992e0d9, bi_partno, instead of using
    bdev->bd_contains and encoding the partition information in the bi_bdev
    field.  __bio_clone_fast was changed to copy the disk information, but
    not the partition information.  At minimum, this regressed bcache and
    caused data corruption.
    
    Signed-off-by: Michael Lyle <mlyle@lyle.org>
    Fixes: 74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions index")
    Reported-by: Pavel Goran <via-bcache@pvgoran.name>
    Reported-by: Campbell Steven <casteven@gmail.com>
    Reviewed-by: Coly Li <colyli@suse.de>
    Reviewed-by: Ming Lei <ming.lei@redhat.com>
    Cc: <stable@vger.kernel.org> # 4.14
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

diff --git a/block/bio.c b/block/bio.c
index b94a802f8ba3..459cc857f3d9 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -597,6 +597,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
         * so we don't set nor calculate new physical/hw segment counts here
         */
        bio->bi_disk = bio_src->bi_disk;
+       bio->bi_partno = bio_src->bi_partno;
        bio_set_flag(bio, BIO_CLONED);
        bio->bi_opf = bio_src->bi_opf;
        bio->bi_write_hint = bio_src->bi_write_hint;
Comment 7 Mike Pagano gentoo-dev 2017-11-21 11:28:20 UTC
(In reply to Tomáš Mózes from comment #6)
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/
> ?id=62530ed8b1d07a45dec94d46e521c0c6c2d476e6

Thanks for the info. I will add this patch and release with 4.14.1.
Comment 8 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 12:03:08 UTC
added in gentoo-sources-4.14.1
Comment 9 bug2017 2017-11-21 12:15:59 UTC
This bug affects sys-kernel/vanilla-sources-4.14.0 and sys-kernel/vanilla-sources-4.14.1 too.
Comment 10 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 12:29:07 UTC
you are right
Comment 11 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 12:40:07 UTC
masked as well
Comment 12 Tomáš Mózes 2017-11-21 12:45:23 UTC
(In reply to Mike Pagano from comment #7)
> (In reply to Tomáš Mózes from comment #6)
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/
> > ?id=62530ed8b1d07a45dec94d46e521c0c6c2d476e6
> 
> Thanks for the info. I will add this patch and release with 4.14.1.

Thanks. It has been queued up for 4.14 already:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/tree/queue-4.14/bio-ensure-__bio_clone_fast-copies-bi_partno.patch
Comment 13 Mike Pagano gentoo-dev 2017-11-21 12:52:46 UTC
Masked:

commit 3f3676066690d9a176a613f9779360b2030bb4a0
Author: Alice Ferrazzi <alicef@gentoo.org>                                                                                                                                            
Date:   Tue Nov 21 12:33:45 2017 +0000                                                                                                                                                
                                                                                                                                                                                      
    profiles: mask sys-kernel/vanilla-sources-4.14.1.ebuild (bug 638206)                                                                                                              
                                                                                                                                                                                      
commit 1c37d6db7962c1a7db9c1ca63960ab2c8254894b
Author: Alice Ferrazzi <alicef@gentoo.org>                                                                                                                                            
Date:   Tue Nov 21 17:26:28 2017 +0900                                                                                                                                                
                                                                                                                                                                                      
    profiles: mask sys-kernel/gentoo-sources-4.14.0 (bug 638206)


Released new version with patch included:

commit 0a8c30502306c781db8b2c973506e3c62da400e5 (HEAD -> master, origin/master, origin/HEAD)
Author: Mike Pagano <mpagano@gentoo.org>                                                                                                                                              
Date:   Tue Nov 21 07:47:51 2017 -0500                                                                                                                                                
                                                                                                                                                                                      
    sys-kernel/gentoo-sources: Linux patch 4.14.1 including a fix for bcache data corruption bug. See bug #638206.                                                                    

    Package-Manager: Portage-2.3.13, Repoman-2.3.3   


I think we're done, right?
Comment 14 Tomáš Mózes 2017-11-21 12:58:25 UTC
Thanks, it looks good indeed, should be fine :)
Comment 15 Tomáš Mózes 2017-11-21 12:59:38 UTC
(In reply to bug2017 from comment #0)
> Using bcache can destroy the filesystem. Mine was gone after 3rd non
> sucesfull try to mount the rootfs. It was not possible to recover any file.
> (I had backups...)
> 
> Another report on the bcache mailing list:
> https://www.spinics.net/lists/linux-bcache/msg05290.html
> 
> I would sugest to mask it with a warning that there is an bcache issue.

Can you please report back if it helped you? I don't use bcache and 4.14.0 works fine for me (except for one machine).
Comment 16 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 13:07:48 UTC
masked and removed affected kernel
sys-kernel/vanilla-sources-4.14.0
sys-kernel/vanilla-sources-4.14.1
sys-kernel/gentoo-sources-4.14.0
Comment 17 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-21 13:27:27 UTC
masked ck-sources-4.14.0
waiting mainteiner for removal
Comment 18 ᎫᏤᏣ (kuzetsa) 2017-11-21 14:04:24 UTC
Acknowledged. Thanks for the ping.
Comment 19 bug2017 2017-11-21 20:30:09 UTC
System is restored, about 170GB written, everything looks fine. (Btrfs scrub, reboot ...)
Comment 20 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2017-11-22 01:15:51 UTC
@bug2017 thanks for the follow up