Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1452006

Re: bcache super block corruption with non 4k pages

From Stefan Bader <stefan.bader@canonical.com>
Newsgroups linux.kernel
Subject Re: bcache super block corruption with non 4k pages
Date 2016-07-28 18:30 +0200
Message-ID <rZWm5-hH-1@gated-at.bofh.it> (permalink)
References (2 earlier) <rZ7MC-L7-17@gated-at.bofh.it> <rZ9Or-1Wx-41@gated-at.bofh.it> <rZ9Y5-206-3@gated-at.bofh.it> <rZyMN-164-27@gated-at.bofh.it> <rZMwp-1Tr-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 28.07.2016 07:55, Kent Overstreet wrote:
> On Wed, Jul 27, 2016 at 05:16:36PM +0200, Stefan Bader wrote:
>> So here is another attempt which does half the proposed changes. And before you
>> point out that it looks still ugly, let me explain some reasons. The goal for me
>> would be to have something as small as possible to be acceptable as stable change.
>> And the part about putting a bio on the stack and using submit_bio_wait: I
>> believe you meant in read_super to replace the __bread. I was thinking about
>> that but in the end it seemed to make the change unnecessary big. Whether using
>> __bread or submit_bio_wait, in both cases and without needing to make more
>> changes on the write side, read_super has to return the in-memory and on-disk
>> variant of the superblock. So as long as nothing that is related to __bread is
>> leaked out of read_super, it is much better than what is there now. And I remain
>> as small as possible for the delta.
> 
> I like that approach much better. I suppose it's not _strictly_ necessary to rip
> out the __bread()...
> 
> Only other comment is that you shouldn't have to pass the buffer to
> __write_super() - I'd just move the bch_bio_map() call to when the struct
> cache/cached_dev is being initialized (or rip it out and initialize the bvec by
> hand) and never touch it after that.

Hm, doing that would save three simple changes to add a new argument to that
private functions at the cost of haven the map call twice and a (more)
complicated calculation of the
> 
>> So there is one part of the patch which I find hard to do in a better manner but
>> is a bit ugly: and that is to sanely free the sb_disk_data blob on all error
>> paths but not on success when it is assigned to either cache or cached_dev.
>> Could possibly pass the address of the pointer and then clear it inside the
>> called functions. Not sure that would be much less strange...
> 
> Yeah that is a hassle - that's why in the 4k superblocks patch in bcache-dev I
> added that "disk_sb" struct - it owns the buffer and random other crap. You
> could read that patch for ideas if you want, look at how it transfers ownership
> of the disk_sb. 
> 

I had a look but it felt like I could get into too much follow-up changes going
that path. But I think I got it simpler now. One note about that area: both
register calls can run into problems but only one actually returns that status.
And both do not seem to free the allocated structures (cache or cache_dev). It
is at least not obvious whether this is ever done.
I working around this by moving the assignment of the buffer page and the
mapping to a place where an error exit no longer is possible. So the release
functions will only see a non NULL pointer if things went well (reality required
to revise that a little bit as one of the register calls that can fail is
actually doing the write).

So now there is just one oddness: when I am testing this (unfortunately right
now I only have a normal 4k case), after calling make-bache with cache and
backing device, this all looks great and debugging shows the __write_super being
called. But reading the from userspace will return the old data until I stop the
bcache device and unregister the cache (which does not show any further writes).
I cannot decide what I should think here...

-Stefan

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: bcache super block corruption with non 4k pages Stefan Bader <stefan.bader@canonical.com> - 2016-07-26 12:00 +0200
  Re: bcache super block corruption with non 4k pages Kent Overstreet <kent.overstreet@gmail.com> - 2016-07-26 12:30 +0200
    Re: bcache super block corruption with non 4k pages Stefan Bader <stefan.bader@canonical.com> - 2016-07-26 14:40 +0200
      Re: bcache super block corruption with non 4k pages Kent Overstreet <kent.overstreet@gmail.com> - 2016-07-26 14:50 +0200
        Re: bcache super block corruption with non 4k pages Stefan Bader <stefan.bader@canonical.com> - 2016-07-27 17:20 +0200
          Re: bcache super block corruption with non 4k pages Kent Overstreet <kent.overstreet@gmail.com> - 2016-07-28 08:00 +0200
            Re: bcache super block corruption with non 4k pages Stefan Bader <stefan.bader@canonical.com> - 2016-07-28 18:30 +0200
              Re: bcache super block corruption with non 4k pages Stefan Bader <stefan.bader@canonical.com> - 2016-08-04 12:30 +0200

csiph-web