linux/drivers
Michal Hocko 063d99b4fa mm, fs: obey gfp_mapping for add_to_page_cache()
Commit 6afdb859b7 ("mm: do not ignore mapping_gfp_mask in page cache
allocation paths") has caught some users of hardcoded GFP_KERNEL used in
the page cache allocation paths.  This, however, wasn't complete and
there were others which went unnoticed.

Dave Chinner has reported the following deadlock for xfs on loop device:
: With the recent merge of the loop device changes, I'm now seeing
: XFS deadlock on my single CPU, 1GB RAM VM running xfs/073.
:
: The deadlocked is as follows:
:
: kloopd1: loop_queue_read_work
:       xfs_file_iter_read
:       lock XFS inode XFS_IOLOCK_SHARED (on image file)
:       page cache read (GFP_KERNEL)
:       radix tree alloc
:       memory reclaim
:       reclaim XFS inodes
:       log force to unpin inodes
:       <wait for log IO completion>
:
: xfs-cil/loop1: <does log force IO work>
:       xlog_cil_push
:       xlog_write
:       <loop issuing log writes>
:               xlog_state_get_iclog_space()
:               <blocks due to all log buffers under write io>
:               <waits for IO completion>
:
: kloopd1: loop_queue_write_work
:       xfs_file_write_iter
:       lock XFS inode XFS_IOLOCK_EXCL (on image file)
:       <wait for inode to be unlocked>
:
: i.e. the kloopd, with it's split read and write work queues, has
: introduced a dependency through memory reclaim. i.e. that writes
: need to be able to progress for reads make progress.
:
: The problem, fundamentally, is that mpage_readpages() does a
: GFP_KERNEL allocation, rather than paying attention to the inode's
: mapping gfp mask, which is set to GFP_NOFS.
:
: The didn't used to happen, because the loop device used to issue
: reads through the splice path and that does:
:
:       error = add_to_page_cache_lru(page, mapping, index,
:                       GFP_KERNEL & mapping_gfp_mask(mapping));

This has changed by commit aa4d86163e ("block: loop: switch to VFS
ITER_BVEC").

This patch changes mpage_readpage{s} to follow gfp mask set for the
mapping.  There are, however, other places which are doing basically the
same.

lustre:ll_dir_filler is doing GFP_KERNEL from the function which
apparently uses GFP_NOFS for other allocations so let's make this
consistent.

cifs:readpages_get_pages is called from cifs_readpages and
__cifs_readpages_from_fscache called from the same path obeys mapping
gfp.

ramfs_nommu_expand_for_mapping is hardcoding GFP_KERNEL as well
regardless it uses mapping_gfp_mask for the page allocation.

ext4_mpage_readpages is the called from the page cache allocation path
same as read_pages and read_cache_pages

As I've noticed in my previous post I cannot say I would be happy about
sprinkling mapping_gfp_mask all over the place and it sounds like we
should drop gfp_mask argument altogether and use it internally in
__add_to_page_cache_locked that would require all the filesystems to use
mapping gfp consistently which I am not sure is the case here.  From a
quick glance it seems that some file system use it all the time while
others are selective.

Signed-off-by: Michal Hocko <mhocko@suse.com>
Reported-by: Dave Chinner <david@fromorbit.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Andreas Dilger <andreas.dilger@intel.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-10-16 11:42:28 -07:00
..
accessibility
acpi Merge branch 'acpi-ec' 2015-10-01 22:30:35 +02:00
amba
android mm: mark most vm_operations_struct const 2015-09-10 13:29:01 -07:00
ata Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2015-09-03 16:55:55 -07:00
atm solos-pci: Increase headroom on received packets 2015-09-17 21:29:07 -07:00
auxdisplay
base regmap: Fixes for v4.3 2015-10-07 14:15:49 +01:00
bcma
block blk-mq: fix racy updates of rq->errors 2015-10-01 10:10:55 +02:00
bluetooth
bus arm-cci500: Don't enable PMU driver by default 2015-09-28 16:31:17 -07:00
cdrom
char Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-09-26 21:05:23 -04:00
clk Merge branch 'for-4.3-rc/ti-clk-fixes' of https://github.com/t-kristo/linux-pm into clk-fixes 2015-10-02 11:22:23 -07:00
clocksource clocksource/drivers/keystone: Fix bad NO_IRQ usage 2015-09-29 14:33:51 +02:00
connector
cpufreq cpufreq: prevent lockup on reading scaling_available_frequencies 2015-10-08 21:47:56 +02:00
cpuidle Additional power management and ACPI material for v4.3-rc1 2015-09-11 19:11:06 -07:00
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-09-26 21:05:23 -04:00
dca
devfreq PM / devfreq: fix double kfree 2015-10-02 11:05:58 +09:00
dio
dma dmaengine fixes for 4.3-rc4 2015-10-02 14:46:15 -04:00
dma-buf
edac edac updates for v4.3-rc1 2015-09-11 16:21:12 -07:00
eisa
extcon extcon: Fix attached value returned by is_extcon_changed 2015-09-21 15:07:19 +09:00
firewire
firmware arm64/efi: Fix boot crash by not padding between EFI_MEMORY_RUNTIME regions 2015-10-01 12:51:28 +02:00
fmc
gpio Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-18 08:11:42 -07:00
gpu Merge branch 'linux-4.3' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-fixes 2015-10-12 13:59:04 +10:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2015-09-04 12:02:11 -07:00
hsi mm: mark most vm_operations_struct const 2015-09-10 13:29:01 -07:00
hv Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc 2015-09-20 22:44:51 -07:00
hwmon hwmon: (pwm-fan) Fix module autoload for OF platform driver 2015-09-20 17:50:19 -07:00
hwspinlock
hwtracing/coresight
i2c Merge branch 'i2c/for-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2015-09-08 16:16:26 -07:00
ide
idle intel_idle: Skylake Client Support - updated 2015-09-10 14:03:44 -04:00
iio This is the bulk of GPIO changes for the v4.3 kernel cycle: 2015-09-04 10:07:45 -07:00
infiniband Changes for 4.3-rc4 2015-10-01 16:38:52 -04:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2015-10-02 17:53:25 -04:00
iommu IOMMU Fixes for Linux v4.3-rc5 2015-10-13 10:09:59 -07:00
ipack
irqchip Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-10-04 11:40:09 +01:00
isdn libnvdimm for 4.3: 2015-09-08 14:35:59 -07:00
leds leds:lp55xx: Correct Kconfig dependency for f/w user helper 2015-09-17 10:02:20 +02:00
lguest
macintosh powerpc updates for 4.3 2015-09-03 16:41:38 -07:00
mailbox Merge branch 'mailbox-for-next' of git://git.linaro.org/landing-teams/working/fujitsu/integration 2015-09-05 18:11:04 -07:00
mcb mcb: Fix error handling in mcb_pci_probe() 2015-10-05 05:10:01 +01:00
md One bug fix for raid1/raid10. 2015-10-11 09:35:51 -07:00
media media updates for v4.3-rc1 2015-09-11 16:42:39 -07:00
memory IOMMU Updates for Linux v4.3 2015-09-08 17:22:35 -07:00
memstick
message
mfd genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
misc mei: hbm: fix error in state check logic 2015-10-04 12:19:23 +01:00
mmc mmc: sdhci-of-at91: use SDHCI_QUIRK2_NEED_DELAY_AFTER_INT_CLK_RST quirk 2015-10-08 19:55:05 +02:00
mtd A few MTD fixes: 2015-10-07 09:35:15 +01:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-10-01 21:55:35 -04:00
nfc This is the bulk of GPIO changes for the v4.3 kernel cycle: 2015-09-04 10:07:45 -07:00
ntb NTB: Fix range check on memory window index 2015-09-07 15:27:12 -04:00
nubus
nvdimm pmem: add proper fencing to pmem_rw_page() 2015-09-17 11:49:28 -04:00
nvmem nvmem: sunxi: Check for memory allocation failure 2015-10-04 12:09:43 +01:00
of Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-09-26 06:01:33 -04:00
oprofile
parisc PCI: Revert "PCI: Call pci_read_bridge_bases() from core instead of arch code" 2015-09-15 13:18:04 -05:00
parport
pci Merge branches 'pm-pci' and 'acpi-pci' 2015-10-01 22:30:12 +02:00
pcmcia pcmcia: soc_common: remove skt_dev_info's clk pointer 2015-09-03 16:01:03 +01:00
perf
phy phy: berlin-sata: Fix module autoload for OF platform driver 2015-09-25 17:01:14 +05:30
pinctrl Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-18 08:11:42 -07:00
platform platform-drivers-x86 for 4.3-2 2015-09-17 21:41:02 -07:00
pnp
power power supply and reset fixes for the v4.3 series 2015-09-17 12:25:42 -07:00
powercap
pps
ps3
ptp
pwm pwm: Changes for v4.3-rc1 2015-09-09 10:55:32 -07:00
rapidio
ras
regulator Merge remote-tracking branch 'regulator/fix/axp20x' into regulator-linus 2015-10-06 12:00:42 +01:00
remoteproc
reset reset: ath79: Fix missing spin_lock_init 2015-09-01 14:48:40 +02:00
rpmsg
rtc rtc: abx80x: fix RTC write bit 2015-09-05 19:37:31 +02:00
s390 virtio: fixes on top of 4.3-rc1 2015-09-18 09:28:20 -07:00
sbus
scsi SCSI fixes on 20151010 2015-10-11 10:02:30 -07:00
sfi
sh SH Drivers Updates for v4.3 2015-09-21 12:02:27 -07:00
sn
soc genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
spi Merge remote-tracking branches 'spi/fix/davinci' and 'spi/fix/sh-msiof' into spi-linus 2015-10-07 11:43:39 +01:00
spmi genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
ssb
staging mm, fs: obey gfp_mapping for add_to_page_cache() 2015-10-16 11:42:28 -07:00
target iscsi-target: Avoid OFMarker + IFMarker negotiation 2015-09-24 23:24:46 -07:00
tc
thermal thermal: avoid division by zero in power allocator 2015-10-01 21:42:35 -04:00
thunderbolt thunderbolt: Allow loading of module on recent Apple MacBooks with thunderbolt 2 controller 2015-09-20 15:20:11 -07:00
tty drivers/tty: require read access for controlling terminal 2015-10-04 19:20:30 +01:00
uio
usb usb: Add device quirk for Logitech PTZ cameras 2015-10-04 11:01:13 +01:00
uwb
vfio
vhost virtio: fixes on top of 4.3-rc1 2015-09-18 09:28:20 -07:00
video video: of: fix memory leak 2015-10-07 14:13:59 +03:00
virt
virtio virtio_balloon: do not change memory amount visible via /proc/meminfo 2015-09-08 13:32:11 +03:00
vlynq
vme
w1 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2015-09-01 18:46:42 -07:00
watchdog watchdog: iTCO: Fix dependencies on I2C 2015-09-28 10:56:10 +02:00
xen Merge branch 'akpm' (patches from Andrew) 2015-09-10 18:19:42 -07:00
zorro
Kconfig Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2015-09-03 16:27:01 -07:00
Makefile This is the bulk of pin control changes for the v4.3 development 2015-09-04 10:22:09 -07:00