linux/drivers/staging
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
..
android staging: ion: fix corruption of ion_import_dma_buf 2015-09-17 06:11:04 -07:00
board staging: board: Migrate away from __pm_genpd_name_add_device() 2015-09-09 02:18:25 +02:00
clocking-wizard
comedi mm: mark most vm_operations_struct const 2015-09-10 13:29:01 -07:00
dgap Staging:dgap :Compression of lines for immediate return 2015-07-31 16:14:53 -07:00
dgnc staging: dgnc: Remove unnecessary externs 2015-08-14 18:51:57 -07:00
emxx_udc staging: emxx_udc: add ep capabilities support 2015-08-04 12:25:31 -05:00
fbtft staging: fbtft: replace master->setup() with spi_setup() 2015-09-13 09:33:58 -07:00
fsl-mc staging: fsl-mc: add DPAA2 overview readme 2015-08-07 15:10:58 -07:00
ft1000 staging: ft1000: Remove unnecessary externs 2015-08-14 18:51:57 -07:00
fwserial
gdm72xx Staging: gdm72xx: usb_ids: fix a macro coding style error 2015-08-14 18:56:55 -07:00
gdm724x
goldfish
gs_fpgaboot
iio Staging: iio: trigger: Use braces on both branches of if statement 2015-08-14 17:36:24 -07:00
lustre mm, fs: obey gfp_mapping for add_to_page_cache() 2015-10-16 11:42:28 -07:00
media media updates for v4.3-rc1 2015-09-05 18:21:14 -07:00
most staging: most: Add dependency to HAS_IOMEM 2015-09-17 06:11:03 -07:00
mt29f_spinand staging: mt29f_spinand: Remove unnecessary externs 2015-08-14 18:51:57 -07:00
netlogic staging: netlogic: Remove unnecessary externs 2015-08-14 17:38:15 -07:00
nvec staging: nvec: Remove unnecessary externs 2015-08-14 18:51:56 -07:00
octeon Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2015-09-03 16:55:55 -07:00
octeon-usb
olpc_dcon staging: olpc_dcon: Remove unnecessary externs 2015-08-14 17:38:15 -07:00
panel staging: panel: fix block comment usage 2015-07-31 16:18:43 -07:00
rdma IB/hfi: Properly set permissions for user device files 2015-09-18 11:28:47 -04:00
rtl8188eu staging: rtl8188eu: fix possible NULL dereference 2015-08-14 19:20:39 -07:00
rtl8192e staging: rtl8192e: Fix log spamming in rtl8192_hard_data_xmit 2015-08-14 18:56:55 -07:00
rtl8192u staging: rtl8192u: Remove unnecessary externs 2015-08-14 18:51:57 -07:00
rtl8712 staging: rtl8712: Remove unnecessary externs 2015-08-14 18:51:56 -07:00
rtl8723au staging: rtl8723au: Fix Sparse errors in rtw_security.c 2015-08-14 18:44:45 -07:00
rts5208 Staging: rts5208: Fix code indentation warning as detected by checkpatch.pl 2015-08-03 17:54:04 -07:00
skein
slicoss staging: slicoss: Add blank line after variable declarations. 2015-07-31 16:14:53 -07:00
sm750fb Staging: sm750fb: Fix "foo* bar" should be "foo *bar" errors 2015-08-14 19:20:42 -07:00
speakup staging: speakup: fix speakup-r regression 2015-10-04 19:57:20 +01:00
ste_rmi4 [media] staging: Drop owner assignment from i2c_driver 2015-08-11 13:05:46 -03:00
unisys staging: unisys: remove reference of visorutil 2015-09-17 06:11:03 -07:00
vme staging: vme: devices: add spaces around '-' 2015-08-14 18:56:54 -07:00
vt6655 staging: vt6655: Replace typedef struct tagSTxDesc 2015-08-14 19:31:11 -07:00
vt6656
wilc1000 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-09-03 08:08:17 -07:00
wlan-ng
xgifb staging: xgifb: Remove unnecessary externs 2015-08-14 18:51:56 -07:00
Kconfig Changes for 4.3 2015-09-09 08:33:31 -07:00
Makefile Changes for 4.3 2015-09-09 08:33:31 -07:00
staging.c