https://github.com/torvalds/linux
Revision 9230a0b65b47fe6856c4468ec0175c4987e5bede authored by Dave Chinner on 20 November 2018, 06:50:08 UTC, committed by Darrick J. Wong on 21 November 2018, 18:10:53 UTC
Long saga. There have been days spent following this through dead end
after dead end in multi-GB event traces. This morning, after writing
a trace-cmd wrapper that enabled me to be more selective about XFS
trace points, I discovered that I could get just enough essential
tracepoints enabled that there was a 50:50 chance the fsx config
would fail at ~115k ops. If it didn't fail at op 115547, I stopped
fsx at op 115548 anyway.

That gave me two traces - one where the problem manifested, and one
where it didn't. After refining the traces to have the necessary
information, I found that in the failing case there was a real
extent in the COW fork compared to an unwritten extent in the
working case.

Walking back through the two traces to the point where the CWO fork
extents actually diverged, I found that the bad case had an extra
unwritten extent in it. This is likely because the bug it led me to
had triggered multiple times in those 115k ops, leaving stray
COW extents around. What I saw was a COW delalloc conversion to an
unwritten extent (as they should always be through
xfs_iomap_write_allocate()) resulted in a /written extent/:

xfs_writepage:        dev 259:0 ino 0x83 pgoff 0x17000 size 0x79a00 offset 0 length 0
xfs_iext_remove:      dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/2 offset 32 block 152 count 20 flag 1 caller xfs_bmap_add_extent_delay_real
xfs_bmap_pre_update:  dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/1 offset 1 block 4503599627239429 count 31 flag 0 caller xfs_bmap_add_extent_delay_real
xfs_bmap_post_update: dev 259:0 ino 0x83 state RC|LF|RF|COW cur 0xffff888247b899c0/1 offset 1 block 121 count 51 flag 0 caller xfs_bmap_add_ex

Basically, Cow fork before:

	0 1            32          52
	+H+DDDDDDDDDDDD+UUUUUUUUUUU+
	   PREV		RIGHT

COW delalloc conversion allocates:

	  1	       32
	  +uuuuuuuuuuuu+
	  NEW

And the result according to the xfs_bmap_post_update trace was:

	0 1            32          52
	+H+wwwwwwwwwwwwwwwwwwwwwwww+
	   PREV

Which is clearly wrong - it should be a merged unwritten extent,
not an unwritten extent.

That lead me to look at the LEFT_FILLING|RIGHT_FILLING|RIGHT_CONTIG
case in xfs_bmap_add_extent_delay_real(), and sure enough, there's
the bug.

It takes the old delalloc extent (PREV) and adds the length of the
RIGHT extent to it, takes the start block from NEW, removes the
RIGHT extent and then updates PREV with the new extent.

What it fails to do is update PREV.br_state. For delalloc, this is
always XFS_EXT_NORM, while in this case we are converting the
delayed allocation to unwritten, so it needs to be updated to
XFS_EXT_UNWRITTEN. This LF|RF|RC case does not do this, and so
the resultant extent is always written.

And that's the bug I've been chasing for a week - a bmap btree bug,
not a reflink/dedupe/copy_file_range bug, but a BMBT bug introduced
with the recent in core extent tree scalability enhancements.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent 2c30717
History
Tip revision: 9230a0b65b47fe6856c4468ec0175c4987e5bede authored by Dave Chinner on 20 November 2018, 06:50:08 UTC
xfs: delalloc -> unwritten COW fork allocation can go wrong
Tip revision: 9230a0b
File Mode Size
ac97
ac97_codec.h -rw-r--r-- 15.7 KB
aci.h -rw-r--r-- 2.4 KB
ad1816a.h -rw-r--r-- 5.4 KB
ad1843.h -rw-r--r-- 1.5 KB
adau1373.h -rw-r--r-- 699 bytes
aess.h -rw-r--r-- 1.6 KB
ak4113.h -rw-r--r-- 10.9 KB
ak4114.h -rw-r--r-- 10.2 KB
ak4117.h -rw-r--r-- 9.0 KB
ak4531_codec.h -rw-r--r-- 3.1 KB
ak4641.h -rw-r--r-- 622 bytes
ak4xxx-adda.h -rw-r--r-- 3.3 KB
alc5623.h -rw-r--r-- 536 bytes
asequencer.h -rw-r--r-- 3.6 KB
asound.h -rw-r--r-- 1.3 KB
asoundef.h -rw-r--r-- 16.7 KB
compress_driver.h -rw-r--r-- 5.8 KB
control.h -rw-r--r-- 8.8 KB
core.h -rw-r--r-- 13.6 KB
cs35l33.h -rw-r--r-- 1.0 KB
cs35l34.h -rw-r--r-- 887 bytes
cs35l35.h -rw-r--r-- 2.4 KB
cs4231-regs.h -rw-r--r-- 8.3 KB
cs4271.h -rw-r--r-- 1.4 KB
cs42l52.h -rw-r--r-- 738 bytes
cs42l56.h -rw-r--r-- 1.2 KB
cs42l73.h -rw-r--r-- 507 bytes
cs8403.h -rw-r--r-- 8.6 KB
cs8427.h -rw-r--r-- 10.4 KB
da7213.h -rw-r--r-- 1.2 KB
da7218.h -rw-r--r-- 2.6 KB
da7219-aad.h -rw-r--r-- 2.4 KB
da7219.h -rw-r--r-- 1.1 KB
da9055.h -rw-r--r-- 914 bytes
designware_i2s.h -rw-r--r-- 2.2 KB
dmaengine_pcm.h -rw-r--r-- 6.1 KB
emu10k1.h -rw-r--r-- 89.4 KB
emu10k1_synth.h -rw-r--r-- 1.3 KB
emu8000.h -rw-r--r-- 4.0 KB
emu8000_reg.h -rw-r--r-- 10.2 KB
emux_legacy.h -rw-r--r-- 5.4 KB
emux_synth.h -rw-r--r-- 7.5 KB
es1688.h -rw-r--r-- 3.5 KB
gus.h -rw-r--r-- 20.2 KB
hda_chmap.h -rw-r--r-- 2.6 KB
hda_codec.h -rw-r--r-- 17.2 KB
hda_component.h -rw-r--r-- 1.9 KB
hda_hwdep.h -rw-r--r-- 1.4 KB
hda_i915.h -rw-r--r-- 589 bytes
hda_register.h -rw-r--r-- 10.0 KB
hda_regmap.h -rw-r--r-- 6.6 KB
hda_verbs.h -rw-r--r-- 16.8 KB
hdaudio.h -rw-r--r-- 20.3 KB
hdaudio_ext.h -rw-r--r-- 5.4 KB
hdmi-codec.h -rw-r--r-- 2.4 KB
hwdep.h -rw-r--r-- 2.6 KB
i2c.h -rw-r--r-- 3.5 KB
info.h -rw-r--r-- 7.4 KB
initval.h -rw-r--r-- 3.1 KB
jack.h -rw-r--r-- 3.7 KB
l3.h -rw-r--r-- 524 bytes
max9768.h -rw-r--r-- 729 bytes
max98088.h -rw-r--r-- 1.3 KB
max98090.h -rw-r--r-- 754 bytes
max98095.h -rw-r--r-- 1.5 KB
memalloc.h -rw-r--r-- 4.6 KB
minors.h -rw-r--r-- 4.3 KB
mixer_oss.h -rw-r--r-- 2.4 KB
mpu401.h -rw-r--r-- 4.5 KB
omap-hdmi-audio.h -rw-r--r-- 1.3 KB
opl3.h -rw-r--r-- 12.3 KB
opl4.h -rw-r--r-- 1.1 KB
pcm-indirect.h -rw-r--r-- 5.7 KB
pcm.h -rw-r--r-- 47.9 KB
pcm_drm_eld.h -rw-r--r-- 183 bytes
pcm_iec958.h -rw-r--r-- 332 bytes
pcm_oss.h -rw-r--r-- 2.7 KB
pcm_params.h -rw-r--r-- 9.1 KB
pt2258.h -rw-r--r-- 1.2 KB
pxa2xx-lib.h -rw-r--r-- 1.6 KB
rawmidi.h -rw-r--r-- 6.2 KB
rt286.h -rw-r--r-- 460 bytes
rt298.h -rw-r--r-- 519 bytes
rt5514.h -rw-r--r-- 545 bytes
rt5645.h -rw-r--r-- 811 bytes
rt5659.h -rw-r--r-- 1.0 KB
rt5660.h -rw-r--r-- 724 bytes
rt5663.h -rw-r--r-- 622 bytes
rt5665.h -rw-r--r-- 907 bytes
rt5668.h -rw-r--r-- 792 bytes
rt5670.h -rw-r--r-- 652 bytes
rt5682.h -rw-r--r-- 792 bytes
s3c24xx_uda134x.h -rw-r--r-- 229 bytes
sb.h -rw-r--r-- 11.0 KB
sb16_csp.h -rw-r--r-- 2.7 KB
seq_device.h -rw-r--r-- 2.8 KB
seq_kernel.h -rw-r--r-- 4.0 KB
seq_midi_emul.h -rw-r--r-- 7.3 KB
seq_midi_event.h -rw-r--r-- 2.0 KB
seq_oss.h -rw-r--r-- 2.9 KB
seq_oss_legacy.h -rw-r--r-- 1.0 KB
seq_virmidi.h -rw-r--r-- 2.7 KB
sh_dac_audio.h -rw-r--r-- 587 bytes
sh_fsi.h -rw-r--r-- 693 bytes
simple_card.h -rw-r--r-- 529 bytes
simple_card_utils.h -rw-r--r-- 4.6 KB
snd_wavefront.h -rw-r--r-- 5.6 KB
soc-acpi-intel-match.h -rw-r--r-- 1.2 KB
soc-acpi.h -rw-r--r-- 3.1 KB
soc-dai.h -rw-r--r-- 12.0 KB
soc-dapm.h -rw-r--r-- 30.8 KB
soc-dpcm.h -rw-r--r-- 5.1 KB
soc-topology.h -rw-r--r-- 6.0 KB
soc.h -rw-r--r-- 53.3 KB
soundfont.h -rw-r--r-- 4.5 KB
spear_dma.h -rw-r--r-- 1003 bytes
spear_spdif.h -rw-r--r-- 1010 bytes
sta32x.h -rw-r--r-- 1.2 KB
sta350.h -rw-r--r-- 1.6 KB
tas2552-plat.h -rw-r--r-- 678 bytes
tas5086.h -rw-r--r-- 210 bytes
tea6330t.h -rw-r--r-- 1.1 KB
timer.h -rw-r--r-- 5.6 KB
tlv.h -rw-r--r-- 2.3 KB
tlv320aic32x4.h -rw-r--r-- 1.4 KB
tlv320aic3x.h -rw-r--r-- 1.9 KB
tlv320dac33-plat.h -rw-r--r-- 720 bytes
tpa6130a2-plat.h -rw-r--r-- 900 bytes
uda134x.h -rw-r--r-- 597 bytes
uda1380.h -rw-r--r-- 481 bytes
util_mem.h -rw-r--r-- 2.3 KB
vx_core.h -rw-r--r-- 15.3 KB
wavefront.h -rw-r--r-- 18.8 KB
wm0010.h -rw-r--r-- 679 bytes
wm1250-ev1.h -rw-r--r-- 656 bytes
wm2000.h -rw-r--r-- 625 bytes
wm2200.h -rw-r--r-- 1.5 KB
wm5100.h -rw-r--r-- 1.2 KB
wm8903.h -rw-r--r-- 15.2 KB
wm8904.h -rw-r--r-- 7.4 KB
wm8955.h -rw-r--r-- 662 bytes
wm8960.h -rw-r--r-- 603 bytes
wm8962.h -rw-r--r-- 1.8 KB
wm8993.h -rw-r--r-- 1.2 KB
wm8996.h -rw-r--r-- 1.4 KB
wm9081.h -rw-r--r-- 661 bytes
wm9090.h -rw-r--r-- 780 bytes
wss.h -rw-r--r-- 8.4 KB

back to top