From: Greg Kroah-Hartman Date: Sat, 17 Oct 2015 19:19:26 +0000 (-0700) Subject: 3.14-stable patches X-Git-Tag: v3.10.91~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d68cabf4c58a36be872e8b7106397983ac5851a2;p=thirdparty%2Fkernel%2Fstable-queue.git 3.14-stable patches added patches: alsa-hda-apply-spdif-pin-ctl-to-macbookpro-12-1.patch alsa-synth-fix-conflicting-oss-device-registration-on-awe32.patch asoc-dwc-correct-irq-clear-method.patch asoc-fix-broken-pxa-soc-support.patch asoc-pxa-pxa2xx-ac97-fix-dma-requestor-lines.patch btrfs-fix-read-corruption-of-compressed-and-shared-extents.patch btrfs-skip-waiting-on-ordered-range-for-special-files.patch btrfs-update-fix-for-read-corruption-of-compressed-and-shared-extents.patch --- diff --git a/queue-3.14/alsa-hda-apply-spdif-pin-ctl-to-macbookpro-12-1.patch b/queue-3.14/alsa-hda-apply-spdif-pin-ctl-to-macbookpro-12-1.patch new file mode 100644 index 00000000000..7333f26478b --- /dev/null +++ b/queue-3.14/alsa-hda-apply-spdif-pin-ctl-to-macbookpro-12-1.patch @@ -0,0 +1,34 @@ +From e8ff581f7ac2bc3b8886094b7ca635dcc4d1b0e9 Mon Sep 17 00:00:00 2001 +From: John Flatness +Date: Fri, 2 Oct 2015 17:07:49 -0400 +Subject: ALSA: hda - Apply SPDIF pin ctl to MacBookPro 12,1 + +From: John Flatness + +commit e8ff581f7ac2bc3b8886094b7ca635dcc4d1b0e9 upstream. + +The MacBookPro 12,1 has the same setup as the 11 for controlling the +status of the optical audio light. Simply apply the existing workaround +to the subsystem ID for the 12,1. + +[sorted the fixup entry by tiwai] + +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=105401 +Signed-off-by: John Flatness +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_cirrus.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/sound/pci/hda/patch_cirrus.c ++++ b/sound/pci/hda/patch_cirrus.c +@@ -637,6 +637,7 @@ static const struct snd_pci_quirk cs4208 + SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11), + SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6), + SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6), ++ SND_PCI_QUIRK(0x106b, 0x7b00, "MacBookPro 12,1", CS4208_MBP11), + {} /* terminator */ + }; + diff --git a/queue-3.14/alsa-synth-fix-conflicting-oss-device-registration-on-awe32.patch b/queue-3.14/alsa-synth-fix-conflicting-oss-device-registration-on-awe32.patch new file mode 100644 index 00000000000..7dbf8ad7c7c --- /dev/null +++ b/queue-3.14/alsa-synth-fix-conflicting-oss-device-registration-on-awe32.patch @@ -0,0 +1,43 @@ +From 225db5762dc1a35b26850477ffa06e5cd0097243 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 5 Oct 2015 16:55:09 +0200 +Subject: ALSA: synth: Fix conflicting OSS device registration on AWE32 + +From: Takashi Iwai + +commit 225db5762dc1a35b26850477ffa06e5cd0097243 upstream. + +When OSS emulation is loaded on ISA SB AWE32 chip, we get now kernel +warnings like: + WARNING: CPU: 0 PID: 2791 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x51/0x80() + sysfs: cannot create duplicate filename '/devices/isa/sbawe.0/sound/card0/seq-oss-0-0' + +It's because both emux synth and opl3 drivers try to register their +OSS device object with the same static index number 0. This hasn't +been a big problem until the recent rewrite of device management code +(that exposes sysfs at the same time), but it's been an obvious bug. + +This patch works around it just by using a different index number of +emux synth object. There can be a more elegant way to fix, but it's +enough for now, as this code won't be touched so often, in anyway. + +Reported-and-tested-by: Michael Shell +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/synth/emux/emux_oss.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/sound/synth/emux/emux_oss.c ++++ b/sound/synth/emux/emux_oss.c +@@ -69,7 +69,8 @@ snd_emux_init_seq_oss(struct snd_emux *e + struct snd_seq_oss_reg *arg; + struct snd_seq_device *dev; + +- if (snd_seq_device_new(emu->card, 0, SNDRV_SEQ_DEV_ID_OSS, ++ /* using device#1 here for avoiding conflicts with OPL3 */ ++ if (snd_seq_device_new(emu->card, 1, SNDRV_SEQ_DEV_ID_OSS, + sizeof(struct snd_seq_oss_reg), &dev) < 0) + return; + diff --git a/queue-3.14/asoc-dwc-correct-irq-clear-method.patch b/queue-3.14/asoc-dwc-correct-irq-clear-method.patch new file mode 100644 index 00000000000..6311c28c99a --- /dev/null +++ b/queue-3.14/asoc-dwc-correct-irq-clear-method.patch @@ -0,0 +1,35 @@ +From 4873867e5f2bd90faad861dd94865099fc3140f3 Mon Sep 17 00:00:00 2001 +From: Yitian Bu +Date: Fri, 2 Oct 2015 15:18:41 +0800 +Subject: ASoC: dwc: correct irq clear method + +From: Yitian Bu + +commit 4873867e5f2bd90faad861dd94865099fc3140f3 upstream. + +from Designware I2S datasheet, tx/rx XRUN irq is cleared by +reading register TOR/ROR, rather than by writing into them. + +Signed-off-by: Yitian Bu +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + sound/soc/dwc/designware_i2s.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/sound/soc/dwc/designware_i2s.c ++++ b/sound/soc/dwc/designware_i2s.c +@@ -100,10 +100,10 @@ static inline void i2s_clear_irqs(struct + + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { + for (i = 0; i < 4; i++) +- i2s_write_reg(dev->i2s_base, TOR(i), 0); ++ i2s_read_reg(dev->i2s_base, TOR(i)); + } else { + for (i = 0; i < 4; i++) +- i2s_write_reg(dev->i2s_base, ROR(i), 0); ++ i2s_read_reg(dev->i2s_base, ROR(i)); + } + } + diff --git a/queue-3.14/asoc-fix-broken-pxa-soc-support.patch b/queue-3.14/asoc-fix-broken-pxa-soc-support.patch new file mode 100644 index 00000000000..db189298fa4 --- /dev/null +++ b/queue-3.14/asoc-fix-broken-pxa-soc-support.patch @@ -0,0 +1,82 @@ +From 3c8f7710c1c44fb650bc29b6ef78ed8b60cfaa28 Mon Sep 17 00:00:00 2001 +From: Robert Jarzmik +Date: Tue, 15 Sep 2015 20:51:31 +0200 +Subject: ASoC: fix broken pxa SoC support + +From: Robert Jarzmik + +commit 3c8f7710c1c44fb650bc29b6ef78ed8b60cfaa28 upstream. + +The previous fix of pxa library support, which was introduced to fix the +library dependency, broke the previous SoC behavior, where a machine +code binding pxa2xx-ac97 with a coded relied on : + - sound/soc/pxa/pxa2xx-ac97.c + - sound/soc/codecs/XXX.c + +For example, the mioa701_wm9713.c machine code is currently broken. The +"select ARM" statement wrongly selects the soc/arm/pxa2xx-ac97 for +compilation, as per an unfortunate fate SND_PXA2XX_AC97 is both declared +in sound/arm/Kconfig and sound/soc/pxa/Kconfig. + +Fix this by ensuring that SND_PXA2XX_SOC correctly triggers the correct +pxa2xx-ac97 compilation. + +Fixes: 846172dfe33c ("ASoC: fix SND_PXA2XX_LIB Kconfig warning") +Signed-off-by: Robert Jarzmik +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + sound/arm/Kconfig | 15 ++++++++------- + sound/soc/pxa/Kconfig | 2 -- + 2 files changed, 8 insertions(+), 9 deletions(-) + +--- a/sound/arm/Kconfig ++++ b/sound/arm/Kconfig +@@ -9,6 +9,14 @@ menuconfig SND_ARM + Drivers that are implemented on ASoC can be found in + "ALSA for SoC audio support" section. + ++config SND_PXA2XX_LIB ++ tristate ++ select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97 ++ select SND_DMAENGINE_PCM ++ ++config SND_PXA2XX_LIB_AC97 ++ bool ++ + if SND_ARM + + config SND_ARMAACI +@@ -21,13 +29,6 @@ config SND_PXA2XX_PCM + tristate + select SND_PCM + +-config SND_PXA2XX_LIB +- tristate +- select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97 +- +-config SND_PXA2XX_LIB_AC97 +- bool +- + config SND_PXA2XX_AC97 + tristate "AC97 driver for the Intel PXA2xx chip" + depends on ARCH_PXA +--- a/sound/soc/pxa/Kconfig ++++ b/sound/soc/pxa/Kconfig +@@ -1,7 +1,6 @@ + config SND_PXA2XX_SOC + tristate "SoC Audio for the Intel PXA2xx chip" + depends on ARCH_PXA +- select SND_ARM + select SND_PXA2XX_LIB + help + Say Y or M if you want to add support for codecs attached to +@@ -24,7 +23,6 @@ config SND_PXA2XX_AC97 + config SND_PXA2XX_SOC_AC97 + tristate + select AC97_BUS +- select SND_ARM + select SND_PXA2XX_LIB_AC97 + select SND_SOC_AC97_BUS + diff --git a/queue-3.14/asoc-pxa-pxa2xx-ac97-fix-dma-requestor-lines.patch b/queue-3.14/asoc-pxa-pxa2xx-ac97-fix-dma-requestor-lines.patch new file mode 100644 index 00000000000..de55f70b847 --- /dev/null +++ b/queue-3.14/asoc-pxa-pxa2xx-ac97-fix-dma-requestor-lines.patch @@ -0,0 +1,44 @@ +From 8811191fdf7ed02ee07cb8469428158572d355a2 Mon Sep 17 00:00:00 2001 +From: Robert Jarzmik +Date: Tue, 22 Sep 2015 21:20:22 +0200 +Subject: ASoC: pxa: pxa2xx-ac97: fix dma requestor lines + +From: Robert Jarzmik + +commit 8811191fdf7ed02ee07cb8469428158572d355a2 upstream. + +PCM receive and transmit DMA requestor lines were reverted, breaking the +PCM playback interface for PXA platforms using the sound/soc/ variant +instead of the sound/arm variant. + +The commit below shows the inversion in the requestor lines. + +Fixes: d65a14587a9b ("ASoC: pxa: use snd_dmaengine_dai_dma_data") +Signed-off-by: Robert Jarzmik +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + sound/soc/pxa/pxa2xx-ac97.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/sound/soc/pxa/pxa2xx-ac97.c ++++ b/sound/soc/pxa/pxa2xx-ac97.c +@@ -49,7 +49,7 @@ static struct snd_ac97_bus_ops pxa2xx_ac + .reset = pxa2xx_ac97_cold_reset, + }; + +-static unsigned long pxa2xx_ac97_pcm_stereo_in_req = 12; ++static unsigned long pxa2xx_ac97_pcm_stereo_in_req = 11; + static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = { + .addr = __PREG(PCDR), + .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, +@@ -57,7 +57,7 @@ static struct snd_dmaengine_dai_dma_data + .filter_data = &pxa2xx_ac97_pcm_stereo_in_req, + }; + +-static unsigned long pxa2xx_ac97_pcm_stereo_out_req = 11; ++static unsigned long pxa2xx_ac97_pcm_stereo_out_req = 12; + static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = { + .addr = __PREG(PCDR), + .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, diff --git a/queue-3.14/btrfs-fix-read-corruption-of-compressed-and-shared-extents.patch b/queue-3.14/btrfs-fix-read-corruption-of-compressed-and-shared-extents.patch new file mode 100644 index 00000000000..9443b6c2f45 --- /dev/null +++ b/queue-3.14/btrfs-fix-read-corruption-of-compressed-and-shared-extents.patch @@ -0,0 +1,291 @@ +From 005efedf2c7d0a270ffbe28d8997b03844f3e3e7 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +Date: Mon, 14 Sep 2015 09:09:31 +0100 +Subject: Btrfs: fix read corruption of compressed and shared extents + +From: Filipe Manana + +commit 005efedf2c7d0a270ffbe28d8997b03844f3e3e7 upstream. + +If a file has a range pointing to a compressed extent, followed by +another range that points to the same compressed extent and a read +operation attempts to read both ranges (either completely or part of +them), the pages that correspond to the second range are incorrectly +filled with zeroes. + +Consider the following example: + + File layout + [0 - 8K] [8K - 24K] + | | + | | + points to extent X, points to extent X, + offset 4K, length of 8K offset 0, length 16K + + [extent X, compressed length = 4K uncompressed length = 16K] + +If a readpages() call spans the 2 ranges, a single bio to read the extent +is submitted - extent_io.c:submit_extent_page() would only create a new +bio to cover the second range pointing to the extent if the extent it +points to had a different logical address than the extent associated with +the first range. This has a consequence of the compressed read end io +handler (compression.c:end_compressed_bio_read()) finish once the extent +is decompressed into the pages covering the first range, leaving the +remaining pages (belonging to the second range) filled with zeroes (done +by compression.c:btrfs_clear_biovec_end()). + +So fix this by submitting the current bio whenever we find a range +pointing to a compressed extent that was preceded by a range with a +different extent map. This is the simplest solution for this corner +case. Making the end io callback populate both ranges (or more, if we +have multiple pointing to the same extent) is a much more complex +solution since each bio is tightly coupled with a single extent map and +the extent maps associated to the ranges pointing to the shared extent +can have different offsets and lengths. + +The following test case for fstests triggers the issue: + + seq=`basename $0` + seqres=$RESULT_DIR/$seq + echo "QA output created by $seq" + tmp=/tmp/$$ + status=1 # failure is the default! + trap "_cleanup; exit \$status" 0 1 2 3 15 + + _cleanup() + { + rm -f $tmp.* + } + + # get standard environment, filters and checks + . ./common/rc + . ./common/filter + + # real QA test starts here + _need_to_be_root + _supported_fs btrfs + _supported_os Linux + _require_scratch + _require_cloner + + rm -f $seqres.full + + test_clone_and_read_compressed_extent() + { + local mount_opts=$1 + + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount $mount_opts + + # Create a test file with a single extent that is compressed (the + # data we write into it is highly compressible no matter which + # compression algorithm is used, zlib or lzo). + $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 4K" \ + -c "pwrite -S 0xbb 4K 8K" \ + -c "pwrite -S 0xcc 12K 4K" \ + $SCRATCH_MNT/foo | _filter_xfs_io + + # Now clone our extent into an adjacent offset. + $CLONER_PROG -s $((4 * 1024)) -d $((16 * 1024)) -l $((8 * 1024)) \ + $SCRATCH_MNT/foo $SCRATCH_MNT/foo + + # Same as before but for this file we clone the extent into a lower + # file offset. + $XFS_IO_PROG -f -c "pwrite -S 0xaa 8K 4K" \ + -c "pwrite -S 0xbb 12K 8K" \ + -c "pwrite -S 0xcc 20K 4K" \ + $SCRATCH_MNT/bar | _filter_xfs_io + + $CLONER_PROG -s $((12 * 1024)) -d 0 -l $((8 * 1024)) \ + $SCRATCH_MNT/bar $SCRATCH_MNT/bar + + echo "File digests before unmounting filesystem:" + md5sum $SCRATCH_MNT/foo | _filter_scratch + md5sum $SCRATCH_MNT/bar | _filter_scratch + + # Evicting the inode or clearing the page cache before reading + # again the file would also trigger the bug - reads were returning + # all bytes in the range corresponding to the second reference to + # the extent with a value of 0, but the correct data was persisted + # (it was a bug exclusively in the read path). The issue happened + # only if the same readpages() call targeted pages belonging to the + # first and second ranges that point to the same compressed extent. + _scratch_remount + + echo "File digests after mounting filesystem again:" + # Must match the same digests we got before. + md5sum $SCRATCH_MNT/foo | _filter_scratch + md5sum $SCRATCH_MNT/bar | _filter_scratch + } + + echo -e "\nTesting with zlib compression..." + test_clone_and_read_compressed_extent "-o compress=zlib" + + _scratch_unmount + + echo -e "\nTesting with lzo compression..." + test_clone_and_read_compressed_extent "-o compress=lzo" + + status=0 + exit + +Signed-off-by: Filipe Manana +Reviewed-by: Qu Wenruo +Reviewed-by: Liu Bo +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent_io.c | 65 ++++++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 57 insertions(+), 8 deletions(-) + +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -2681,7 +2681,8 @@ static int submit_extent_page(int rw, st + bio_end_io_t end_io_func, + int mirror_num, + unsigned long prev_bio_flags, +- unsigned long bio_flags) ++ unsigned long bio_flags, ++ bool force_bio_submit) + { + int ret = 0; + struct bio *bio; +@@ -2699,6 +2700,7 @@ static int submit_extent_page(int rw, st + contig = bio_end_sector(bio) == sector; + + if (prev_bio_flags != bio_flags || !contig || ++ force_bio_submit || + merge_bio(rw, tree, page, offset, page_size, bio, bio_flags) || + bio_add_page(bio, page, page_size, offset) < page_size) { + ret = submit_one_bio(rw, bio, mirror_num, +@@ -2790,7 +2792,8 @@ static int __do_readpage(struct extent_i + get_extent_t *get_extent, + struct extent_map **em_cached, + struct bio **bio, int mirror_num, +- unsigned long *bio_flags, int rw) ++ unsigned long *bio_flags, int rw, ++ u64 *prev_em_start) + { + struct inode *inode = page->mapping->host; + u64 start = page_offset(page); +@@ -2838,6 +2841,7 @@ static int __do_readpage(struct extent_i + } + while (cur <= end) { + unsigned long pnr = (last_byte >> PAGE_CACHE_SHIFT) + 1; ++ bool force_bio_submit = false; + + if (cur >= last_byte) { + char *userpage; +@@ -2888,6 +2892,49 @@ static int __do_readpage(struct extent_i + block_start = em->block_start; + if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) + block_start = EXTENT_MAP_HOLE; ++ ++ /* ++ * If we have a file range that points to a compressed extent ++ * and it's followed by a consecutive file range that points to ++ * to the same compressed extent (possibly with a different ++ * offset and/or length, so it either points to the whole extent ++ * or only part of it), we must make sure we do not submit a ++ * single bio to populate the pages for the 2 ranges because ++ * this makes the compressed extent read zero out the pages ++ * belonging to the 2nd range. Imagine the following scenario: ++ * ++ * File layout ++ * [0 - 8K] [8K - 24K] ++ * | | ++ * | | ++ * points to extent X, points to extent X, ++ * offset 4K, length of 8K offset 0, length 16K ++ * ++ * [extent X, compressed length = 4K uncompressed length = 16K] ++ * ++ * If the bio to read the compressed extent covers both ranges, ++ * it will decompress extent X into the pages belonging to the ++ * first range and then it will stop, zeroing out the remaining ++ * pages that belong to the other range that points to extent X. ++ * So here we make sure we submit 2 bios, one for the first ++ * range and another one for the third range. Both will target ++ * the same physical extent from disk, but we can't currently ++ * make the compressed bio endio callback populate the pages ++ * for both ranges because each compressed bio is tightly ++ * coupled with a single extent map, and each range can have ++ * an extent map with a different offset value relative to the ++ * uncompressed data of our extent and different lengths. This ++ * is a corner case so we prioritize correctness over ++ * non-optimal behavior (submitting 2 bios for the same extent). ++ */ ++ if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags) && ++ prev_em_start && *prev_em_start != (u64)-1 && ++ *prev_em_start != em->orig_start) ++ force_bio_submit = true; ++ ++ if (prev_em_start) ++ *prev_em_start = em->orig_start; ++ + free_extent_map(em); + em = NULL; + +@@ -2937,7 +2984,8 @@ static int __do_readpage(struct extent_i + bdev, bio, pnr, + end_bio_extent_readpage, mirror_num, + *bio_flags, +- this_bio_flag); ++ this_bio_flag, ++ force_bio_submit); + if (!ret) { + nr++; + *bio_flags = this_bio_flag; +@@ -2969,6 +3017,7 @@ static inline void __do_contiguous_readp + struct inode *inode; + struct btrfs_ordered_extent *ordered; + int index; ++ u64 prev_em_start = (u64)-1; + + inode = pages[0]->mapping->host; + while (1) { +@@ -2984,7 +3033,7 @@ static inline void __do_contiguous_readp + + for (index = 0; index < nr_pages; index++) { + __do_readpage(tree, pages[index], get_extent, em_cached, bio, +- mirror_num, bio_flags, rw); ++ mirror_num, bio_flags, rw, &prev_em_start); + page_cache_release(pages[index]); + } + } +@@ -3052,7 +3101,7 @@ static int __extent_read_full_page(struc + } + + ret = __do_readpage(tree, page, get_extent, NULL, bio, mirror_num, +- bio_flags, rw); ++ bio_flags, rw, NULL); + return ret; + } + +@@ -3078,7 +3127,7 @@ int extent_read_full_page_nolock(struct + int ret; + + ret = __do_readpage(tree, page, get_extent, NULL, &bio, mirror_num, +- &bio_flags, READ); ++ &bio_flags, READ, NULL); + if (bio) + ret = submit_one_bio(READ, bio, mirror_num, bio_flags); + return ret; +@@ -3347,7 +3396,7 @@ static int __extent_writepage(struct pag + sector, iosize, pg_offset, + bdev, &epd->bio, max_nr, + end_bio_extent_writepage, +- 0, 0, 0); ++ 0, 0, 0, false); + if (ret) + SetPageError(page); + } +@@ -3516,7 +3565,7 @@ static int write_one_eb(struct extent_bu + ret = submit_extent_page(rw, tree, p, offset >> 9, + PAGE_CACHE_SIZE, 0, bdev, &epd->bio, + -1, end_bio_extent_buffer_writepage, +- 0, epd->bio_flags, bio_flags); ++ 0, epd->bio_flags, bio_flags, false); + epd->bio_flags = bio_flags; + if (ret) { + set_bit(EXTENT_BUFFER_IOERR, &eb->bflags); diff --git a/queue-3.14/btrfs-skip-waiting-on-ordered-range-for-special-files.patch b/queue-3.14/btrfs-skip-waiting-on-ordered-range-for-special-files.patch new file mode 100644 index 00000000000..2cb88ae710c --- /dev/null +++ b/queue-3.14/btrfs-skip-waiting-on-ordered-range-for-special-files.patch @@ -0,0 +1,49 @@ +From a30e577c96f59b1e1678ea5462432b09bf7d5cbc Mon Sep 17 00:00:00 2001 +From: Jeff Mahoney +Date: Fri, 11 Sep 2015 21:44:17 -0400 +Subject: btrfs: skip waiting on ordered range for special files + +From: Jeff Mahoney + +commit a30e577c96f59b1e1678ea5462432b09bf7d5cbc upstream. + +In btrfs_evict_inode, we properly truncate the page cache for evicted +inodes but then we call btrfs_wait_ordered_range for every inode as well. +It's the right thing to do for regular files but results in incorrect +behavior for device inodes for block devices. + +filemap_fdatawrite_range gets called with inode->i_mapping which gets +resolved to the block device inode before getting passed to +wbc_attach_fdatawrite_inode and ultimately to inode_to_bdi. What happens +next depends on whether there's an open file handle associated with the +inode. If there is, we write to the block device, which is unexpected +behavior. If there isn't, we through normally and inode->i_data is used. +We can also end up racing against open/close which can result in crashes +when i_mapping points to a block device inode that has been closed. + +Since there can't be any page cache associated with special file inodes, +it's safe to skip the btrfs_wait_ordered_range call entirely and avoid +the problem. + +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100911 +Tested-by: Christoph Biedl +Signed-off-by: Jeff Mahoney +Reviewed-by: Filipe Manana +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/inode.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -4668,7 +4668,8 @@ void btrfs_evict_inode(struct inode *ino + goto no_delete; + } + /* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */ +- btrfs_wait_ordered_range(inode, 0, (u64)-1); ++ if (!special_file(inode->i_mode)) ++ btrfs_wait_ordered_range(inode, 0, (u64)-1); + + if (root->fs_info->log_root_recovering) { + BUG_ON(test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, diff --git a/queue-3.14/btrfs-update-fix-for-read-corruption-of-compressed-and-shared-extents.patch b/queue-3.14/btrfs-update-fix-for-read-corruption-of-compressed-and-shared-extents.patch new file mode 100644 index 00000000000..29772015a22 --- /dev/null +++ b/queue-3.14/btrfs-update-fix-for-read-corruption-of-compressed-and-shared-extents.patch @@ -0,0 +1,178 @@ +From 808f80b46790f27e145c72112189d6a3be2bc884 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +Date: Mon, 28 Sep 2015 09:56:26 +0100 +Subject: Btrfs: update fix for read corruption of compressed and shared extents + +From: Filipe Manana + +commit 808f80b46790f27e145c72112189d6a3be2bc884 upstream. + +My previous fix in commit 005efedf2c7d ("Btrfs: fix read corruption of +compressed and shared extents") was effective only if the compressed +extents cover a file range with a length that is not a multiple of 16 +pages. That's because the detection of when we reached a different range +of the file that shares the same compressed extent as the previously +processed range was done at extent_io.c:__do_contiguous_readpages(), +which covers subranges with a length up to 16 pages, because +extent_readpages() groups the pages in clusters no larger than 16 pages. +So fix this by tracking the start of the previously processed file +range's extent map at extent_readpages(). + +The following test case for fstests reproduces the issue: + + seq=`basename $0` + seqres=$RESULT_DIR/$seq + echo "QA output created by $seq" + tmp=/tmp/$$ + status=1 # failure is the default! + trap "_cleanup; exit \$status" 0 1 2 3 15 + + _cleanup() + { + rm -f $tmp.* + } + + # get standard environment, filters and checks + . ./common/rc + . ./common/filter + + # real QA test starts here + _need_to_be_root + _supported_fs btrfs + _supported_os Linux + _require_scratch + _require_cloner + + rm -f $seqres.full + + test_clone_and_read_compressed_extent() + { + local mount_opts=$1 + + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount $mount_opts + + # Create our test file with a single extent of 64Kb that is going to + # be compressed no matter which compression algo is used (zlib/lzo). + $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 64K" \ + $SCRATCH_MNT/foo | _filter_xfs_io + + # Now clone the compressed extent into an adjacent file offset. + $CLONER_PROG -s 0 -d $((64 * 1024)) -l $((64 * 1024)) \ + $SCRATCH_MNT/foo $SCRATCH_MNT/foo + + echo "File digest before unmount:" + md5sum $SCRATCH_MNT/foo | _filter_scratch + + # Remount the fs or clear the page cache to trigger the bug in + # btrfs. Because the extent has an uncompressed length that is a + # multiple of 16 pages, all the pages belonging to the second range + # of the file (64K to 128K), which points to the same extent as the + # first range (0K to 64K), had their contents full of zeroes instead + # of the byte 0xaa. This was a bug exclusively in the read path of + # compressed extents, the correct data was stored on disk, btrfs + # just failed to fill in the pages correctly. + _scratch_remount + + echo "File digest after remount:" + # Must match the digest we got before. + md5sum $SCRATCH_MNT/foo | _filter_scratch + } + + echo -e "\nTesting with zlib compression..." + test_clone_and_read_compressed_extent "-o compress=zlib" + + _scratch_unmount + + echo -e "\nTesting with lzo compression..." + test_clone_and_read_compressed_extent "-o compress=lzo" + + status=0 + exit + +Signed-off-by: Filipe Manana +Tested-by: Timofey Titovets +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent_io.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -3012,12 +3012,12 @@ static inline void __do_contiguous_readp + get_extent_t *get_extent, + struct extent_map **em_cached, + struct bio **bio, int mirror_num, +- unsigned long *bio_flags, int rw) ++ unsigned long *bio_flags, int rw, ++ u64 *prev_em_start) + { + struct inode *inode; + struct btrfs_ordered_extent *ordered; + int index; +- u64 prev_em_start = (u64)-1; + + inode = pages[0]->mapping->host; + while (1) { +@@ -3033,7 +3033,7 @@ static inline void __do_contiguous_readp + + for (index = 0; index < nr_pages; index++) { + __do_readpage(tree, pages[index], get_extent, em_cached, bio, +- mirror_num, bio_flags, rw, &prev_em_start); ++ mirror_num, bio_flags, rw, prev_em_start); + page_cache_release(pages[index]); + } + } +@@ -3043,7 +3043,8 @@ static void __extent_readpages(struct ex + int nr_pages, get_extent_t *get_extent, + struct extent_map **em_cached, + struct bio **bio, int mirror_num, +- unsigned long *bio_flags, int rw) ++ unsigned long *bio_flags, int rw, ++ u64 *prev_em_start) + { + u64 start = 0; + u64 end = 0; +@@ -3064,7 +3065,7 @@ static void __extent_readpages(struct ex + index - first_index, start, + end, get_extent, em_cached, + bio, mirror_num, bio_flags, +- rw); ++ rw, prev_em_start); + start = page_start; + end = start + PAGE_CACHE_SIZE - 1; + first_index = index; +@@ -3075,7 +3076,8 @@ static void __extent_readpages(struct ex + __do_contiguous_readpages(tree, &pages[first_index], + index - first_index, start, + end, get_extent, em_cached, bio, +- mirror_num, bio_flags, rw); ++ mirror_num, bio_flags, rw, ++ prev_em_start); + } + + static int __extent_read_full_page(struct extent_io_tree *tree, +@@ -3967,6 +3969,7 @@ int extent_readpages(struct extent_io_tr + struct page *page; + struct extent_map *em_cached = NULL; + int nr = 0; ++ u64 prev_em_start = (u64)-1; + + for (page_idx = 0; page_idx < nr_pages; page_idx++) { + page = list_entry(pages->prev, struct page, lru); +@@ -3983,12 +3986,12 @@ int extent_readpages(struct extent_io_tr + if (nr < ARRAY_SIZE(pagepool)) + continue; + __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, +- &bio, 0, &bio_flags, READ); ++ &bio, 0, &bio_flags, READ, &prev_em_start); + nr = 0; + } + if (nr) + __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, +- &bio, 0, &bio_flags, READ); ++ &bio, 0, &bio_flags, READ, &prev_em_start); + + if (em_cached) + free_extent_map(em_cached); diff --git a/queue-3.14/series b/queue-3.14/series index e31018fa5c5..299c0a594ba 100644 --- a/queue-3.14/series +++ b/queue-3.14/series @@ -23,3 +23,11 @@ sched-core-fix-task_dead-race-in-finish_task_switch.patch spi-fix-documentation-of-spi_alloc_master.patch spi-spi-pxa2xx-check-status-register-to-determine-if-sssr_tint-is-disabled.patch mm-hugetlbfs-skip-shared-vmas-when-unmapping-private-pages-to-satisfy-a-fault.patch +alsa-synth-fix-conflicting-oss-device-registration-on-awe32.patch +alsa-hda-apply-spdif-pin-ctl-to-macbookpro-12-1.patch +asoc-pxa-pxa2xx-ac97-fix-dma-requestor-lines.patch +asoc-fix-broken-pxa-soc-support.patch +asoc-dwc-correct-irq-clear-method.patch +btrfs-skip-waiting-on-ordered-range-for-special-files.patch +btrfs-fix-read-corruption-of-compressed-and-shared-extents.patch +btrfs-update-fix-for-read-corruption-of-compressed-and-shared-extents.patch