OpenCloudOS-Kernel/drivers
Darrick J. Wong 37527b8692 dm io: reject unsupported DISCARD requests with EOPNOTSUPP
I created a dm-raid1 device backed by a device that supports DISCARD
and another device that does NOT support DISCARD with the following
dm configuration:

 #  echo '0 2048 mirror core 1 512 2 /dev/sda 0 /dev/sdb 0' | dmsetup create moo
 # lsblk -D
 NAME         DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
 sda                 0        4K       1G         0
 `-moo (dm-0)        0        4K       1G         0
 sdb                 0        0B       0B         0
 `-moo (dm-0)        0        4K       1G         0

Notice that the mirror device /dev/mapper/moo advertises DISCARD
support even though one of the mirror halves doesn't.

If I issue a DISCARD request (via fstrim, mount -o discard, or ioctl
BLKDISCARD) through the mirror, kmirrord gets stuck in an infinite
loop in do_region() when it tries to issue a DISCARD request to sdb.
The problem is that when we call do_region() against sdb, num_sectors
is set to zero because q->limits.max_discard_sectors is zero.
Therefore, "remaining" never decreases and the loop never terminates.

To fix this: before entering the loop, check for the combination of
REQ_DISCARD and no discard and return -EOPNOTSUPP to avoid hanging up
the mirror device.

This bug was found by the unfortunate coincidence of pvmove and a
discard operation in the RHEL 6.5 kernel; upstream is also affected.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
2015-02-13 19:51:09 -05:00
..
accessibility
acpi Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-02-10 20:01:30 -08:00
amba ARM: 8256/1: driver coamba: add device binding path 'driver_override' 2015-02-10 10:23:15 +00:00
android
ata Merge branch 'for-3.20/drivers' of git://git.kernel.dk/linux-block 2015-02-12 14:30:53 -08:00
atm atm: remove deprecated use of pci api 2015-01-18 00:28:41 -05:00
auxdisplay
base ACPI and power management updates for v3.20-rc1 2015-02-10 15:09:41 -08:00
bcma bcma: implement host code support for PCIe Gen 2 devices 2015-01-29 10:54:43 +02:00
block Merge branch 'for-3.20/drivers' of git://git.kernel.dk/linux-block 2015-02-12 14:30:53 -08:00
bluetooth Bluetooth: btusb: Add support for Lite-On (04ca) Broadcom based, BCM43142 2015-02-03 08:57:14 +01:00
bus mvebu fixes for 3.19. (Part 4) 2015-01-23 14:08:13 -08:00
cdrom
char Merge branch 'for-3.20/bdi' of git://git.kernel.dk/linux-block 2015-02-12 13:50:21 -08:00
clk Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-02-10 20:01:30 -08:00
clocksource Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2015-02-12 08:51:56 -08:00
connector
coresight
cpufreq ACPI and power management updates for v3.20-rc1 2015-02-10 15:09:41 -08:00
cpuidle arm64 updates for 3.20: 2015-02-11 18:03:54 -08:00
crypto Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
dca
devfreq ACPI and power management updates for v3.20-rc1 2015-02-10 15:09:41 -08:00
dio
dma resources: Move struct resource_list_entry from ACPI into resource core 2015-02-05 15:09:25 +01:00
dma-buf
edac EDAC, mv64x60_edac: Fix an error code in probe() 2015-01-30 17:00:43 +01:00
eisa
extcon Char/Misc driver patches for 3.19-rc1 2014-12-14 16:43:47 -08:00
firewire firewire: sbp2: replace card lock by target lock 2014-12-10 20:53:21 +01:00
firmware arm64 updates for 3.20: 2015-02-11 18:03:54 -08:00
fmc
gpio Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2015-02-12 08:51:56 -08:00
gpu sound updates for 3.20-rc1 2015-02-11 08:51:59 -08:00
hid Merge branches 'for-3.19/upstream-fixes', 'for-3.20/apple', 'for-3.20/betop', 'for-3.20/lenovo', 'for-3.20/logitech', 'for-3.20/rmi', 'for-3.20/upstream' and 'for-3.20/wacom' into for-linus 2015-02-09 11:17:45 +01:00
hsi hsi: nokia-modem: fix uninitialized device pointer 2015-01-04 20:19:30 +01:00
hv ACPICA: Resources: Provide common part for struct acpi_resource_address structures. 2015-01-26 16:09:56 +01:00
hwmon hwmon: (tmp102) add hibernation callbacks 2015-02-03 12:17:12 -08:00
hwspinlock
i2c i2c: sh_mobile: terminate DMA reads properly 2015-01-30 17:58:43 +01:00
ide Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
idle
iio Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2015-02-11 09:32:08 -08:00
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-02-10 20:01:30 -08:00
input Merge branch 'next' into for-linus 2015-02-10 11:35:36 -08:00
iommu IOMMU Updates for Linux v3.20 2015-02-12 09:16:56 -08:00
ipack
irqchip Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2015-02-06 08:28:54 -08:00
isdn drivers: isdn: isdnloop: isdnloop.c: Remove parenthesis around return values, as specified in CodingStyle. 2015-02-05 15:40:23 -08:00
leds leds: netxbig: fix oops at probe time 2015-01-13 13:49:01 -08:00
lguest virtio: allow finalize_features to fail 2014-12-09 16:32:32 +02:00
macintosh macintosh: therm_pm72: delete deprecated driver 2014-12-19 19:32:47 +01:00
mailbox Merge branch 'mailbox-devel' of git://git.linaro.org/landing-teams/working/fujitsu/integration 2015-02-11 12:56:40 -08:00
mcb mcb: mcb-pci: Only remap the 1st 0x200 bytes of BAR 0 2015-01-09 15:46:37 -08:00
md dm io: reject unsupported DISCARD requests with EOPNOTSUPP 2015-02-13 19:51:09 -05:00
media mm: gup: use get_user_pages_unlocked 2015-02-11 17:06:05 -08:00
memory memory/fsl-corenet-cf: Add t1040 support 2015-01-29 22:57:43 -06:00
memstick
message
mfd - Avoid platform ID collision in da9052 2015-01-21 18:29:44 +12:00
misc powerpc updates for 3.20 2015-02-11 18:15:38 -08:00
mmc mmc: sdhci-s3c: solve problem with sleeping in atomic context 2015-02-04 13:39:14 +01:00
mtd mtd: export new mtd_mmap_capabilities 2015-01-28 11:09:20 -07:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-02-10 20:01:30 -08:00
nfc NFC: nci: Move NFCEE discovery logic 2015-02-04 09:15:18 +01:00
ntb
nubus
of DeviceTree changes for 3.20: 2015-02-12 08:58:43 -08:00
oprofile
parisc parisc/PCI: Clip bridge windows to fit in upstream windows 2015-01-16 10:04:43 -06:00
parport parport: parport_atari: Remove obsolete IRQ_TYPE_SLOW 2015-01-15 13:44:50 +01:00
pci ACPI and power management updates for v3.20-rc1 2015-02-10 15:09:41 -08:00
pcmcia Char/Misc driver patches for 3.19-rc1 2014-12-14 16:43:47 -08:00
phy SCSI misc on 20150209 2015-02-11 10:28:45 -08:00
pinctrl This is the bulk of pin control changes for the v3.20 cycle: 2015-02-11 11:23:13 -08:00
platform Revert "platform: x86: dell-laptop: Add support for keyboard backlight" 2015-01-23 11:10:32 -08:00
pnp ACPI: Return translation offset when parsing ACPI address space resources 2015-02-03 22:27:21 +01:00
power power_supply: 88pm860x: Fix leaked power supply on probe fail 2015-01-28 15:08:10 +01:00
powercap powercap / RAPL: add IDs for future Xeon CPUs 2014-12-17 02:35:42 +01:00
pps
ps3 powerpc/ps3: Fix sys-manager-core sparse warnings 2015-01-22 17:31:21 +11:00
ptp
pwm pwm: Changes for v3.19-rc1 2014-12-17 10:10:51 -08:00
rapidio rapidio/tsi721: use PCI define for Max_Read_Request_Size 2015-01-27 08:14:26 -06:00
ras
regulator Merge remote-tracking branches 'regulator/topic/rk808', 'regulator/topic/rpm', 'regulator/topic/rt5033' and 'regulator/topic/tps65023' into regulator-next 2015-02-08 11:16:30 +08:00
remoteproc Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
reset reset: sunxi: fix spinlock initialization 2015-01-16 19:11:31 -08:00
rpmsg
rtc Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-02-09 17:53:53 -08:00
s390 Merge branch 'for-3.20/core' of git://git.kernel.dk/linux-block 2015-02-12 14:13:23 -08:00
sbus
scsi Merge branch 'for-3.20/core' of git://git.kernel.dk/linux-block 2015-02-12 14:13:23 -08:00
sfi
sh
sn
soc Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2014-12-15 15:52:01 -08:00
spi Merge remote-tracking branch 'spi/topic/xilinx' into spi-next 2015-02-08 11:17:01 +08:00
spmi
ssb ssb: Fix Sparse error in main 2015-01-29 10:17:56 +02:00
staging Merge branch 'for-3.20/bdi' of git://git.kernel.dk/linux-block 2015-02-12 13:50:21 -08:00
target netlink: make nlmsg_end() and genlmsg_end() void 2015-01-18 01:03:45 -05:00
tc
thermal Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-01-27 16:59:56 -08:00
thunderbolt
tty Merge branch 'akpm' (patches from Andrew) 2015-02-11 18:23:28 -08:00
uio Char/Misc driver patches for 3.19-rc1 2014-12-14 16:43:47 -08:00
usb xilinx usb2 gadget: get rid of incredibly annoying compile warning 2015-02-11 10:52:56 -08:00
uwb
vfio vfio-pci: Fix the check on pci device type in vfio_pci_probe() 2015-01-07 10:29:11 -07:00
vhost Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-02-05 14:33:28 -08:00
video mm: gup: use get_user_pages_unlocked 2015-02-11 17:06:05 -08:00
virt
virtio virtio_pci: document why we defer kfree 2015-01-06 16:35:36 +02:00
vlynq
vme
w1 Char/Misc driver patches for 3.19-rc1 2014-12-14 16:43:47 -08:00
watchdog watchdog: drop owner assignment from platform_drivers 2015-01-21 14:52:34 +01:00
xen SCSI misc on 20150209 2015-02-11 10:28:45 -08:00
zorro
Kconfig drivers/Kconfig: remove duplicate entry for soc 2015-01-25 20:26:42 +08:00
Makefile drivers: Move iommu/ before gpu/ in Makefile 2014-12-22 11:47:37 +02:00