[GEDI] Strange data corruption issue with gluster (libgfapi) and ZFS

Kevin Wolf kwolf at redhat.com
Mon Feb 24 13:26:52 UTC 2020


Am 24.02.2020 um 13:35 hat Stefan Ring geschrieben:
> On Thu, Feb 20, 2020 at 10:19 AM Stefan Ring <stefanrin at gmail.com> wrote:
> >
> > Hi,
> >
> > I have a very curious problem on an oVirt-like virtualization host
> > whose storage lives on gluster (as qcow2).
> >
> > The problem is that of the writes done by ZFS, whose sizes according
> > to blktrace are a mixture of 8, 16, 24, ... 256 (512 byte)
> > blocks,sometimes the first 4KB or more, but at least the first 4KB,
> > end up zeroed out when read back later from storage. To clarify: ZFS
> > is only used in the guest. In my current test scenario, I write
> > approx. 3GB to the guest machine, which takes roughly a minute.
> > Actually it’s around 35 GB which gets compressed down to 3GB by lz4.
> > Within that, I end up with close to 100 data errors when I read it
> > back from storage afterwards (zpool scrub).
> >
> > There are quite a few machines running on this host, and we have not
> > experienced other problems so far. So right now, only ZFS is able to
> > trigger this for some reason. The guest has 8 virtual cores. I also
> > tried writing directly to the affected device from user space in
> > patterns mimicking what I see in blktrace, but so far have been unable
> > to trigger the same issue that way. Of the many ZFS knobs, I know at
> > least one that makes a huge difference: When I set
> > zfs_vdev_async_write_max_active to 1 (as opposed to 2 or 10), the
> > error count goes through the roof (11.000).

Wait, that does this setting actually do? Does it mean that QEMU should
never sees more than a single active write request at the same time?
So if this makes the error a lot more prominent, does this mean that
async I/O actually makes the problem _less_ likely to occur?

This sounds weird, so probably I'm misunderstanding the setting?

> > Curiously, when I switch
> > off ZFS compression, the data amount written increases almost
> > 10-fold,while the absolute error amount drops to close to, but not
> > entirely,zero. Which I guess supports my suspicion that this must be
> > somehow related to timing.
> >
> > Switching the guest storage driver between scsi and virtio does not
> > make a difference.
> >
> > Switching the storage backend to file on glusterfs-fuse does make a
> > difference, i.e. the problem disappears.
> >
> > Any hints? I'm still trying to investigate a few things, but what bugs
> > me most that only ZFS seems to trigger this behavior, although I am
> > almost sure that ZFS is not really at fault here.
> >
> > Software versions used:
> >
> > Host
> > kernel 3.10.0-957.12.1.el7.x86_64
> > qemu-kvm-ev-2.12.0-18.el7_6.3.1.x86_64
> > glusterfs-api-5.6-1.el7.x86_64
> >
> > Guest
> > kernel 3.10.0-1062.12.1.el7.x86_64
> > kmod-zfs-0.8.3-1.el7.x86_64 (from the official ZoL binaries)
> 
> I can actually reproduce this on my Fedora 31 home machine with 3 VMs.

This means QEMU 4.1.1, right?

> All 3 running CentOS 7.7. Two for glusterd, one for ZFS. Briefly, I
> also got rid of the 2 glusterd VMs altogether, i.e. running glusterd
> (the Fedora version) directly on the host, and it would still occur.
> So my impression is that the server side of GlusterFS does not matter
> much – I’ve seen it happen on 4.x, 6.x, 7.2 and 7.3. Also, as it
> happens in the same way on a Fedora 31 qemu as well as a CentOS 7 one,
> the qemu version is equally irrelevant.
> 
> The main conclusion so far is that it has to do with growing the qcow2
> image. With a fully pre-populated image, I cannot trigger it.

Ok, that's a good data point.

Is the corruption that you're seeing only in the guest data or is qcow2
metadata also affected (does 'qemu-img check' report errors)?

> I poked around a little in the glfs api integration, but trying to
> make sense of two unknown asynchronous io systems (QEMU's and
> GlusterFS's) interacting with each other is demanding a bit much for a
> single weekend ;). The one thing I did verify so far is that there is
> only one thread ever calling qemu_gluster_co_rw. As already stated in
> the original post, the problem only occurs with multiple parallel
> write requests happening.
> 
> What I plan to do next is look at the block ranges being written in
> the hope of finding overlaps there.

Either that, or other interesting patterns.

Did you try to remove the guest from the equation? If you say that the
problem is with multiple parallel requests, maybe 'qemu-img bench' can
cause the same kind of corruption? (Though if it's only corruption in
the content rather than qcow2 metadata, it may be hard to detect.
Giving qemu-io an explicit list of requests could still be an option
once we have a suspicion what pattern creates the problem.)

Kevin



More information about the integration mailing list