From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Steven Whitehouse <swhiteho@redhat.com>
Subject: [PATCH 3.10 082/129] GFS2: Fix incorrect invalidation for DIO/buffered I/O
Date: Mon, 6 Jan 2014 14:38:31 -0800 [thread overview]
Message-ID: <20140106223901.954596421@linuxfoundation.org> (raw)
In-Reply-To: <20140106223859.589799655@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Whitehouse <swhiteho@redhat.com>
commit dfd11184d894cd0a92397b25cac18831a1a6a5bc upstream.
In patch 209806aba9d540dde3db0a5ce72307f85f33468f we allowed
local deferred locks to be granted against a cached exclusive
lock. That opened up a corner case which this patch now
fixes.
The solution to the problem is to check whether we have cached
pages each time we do direct I/O and if so to unmap, flush
and invalidate those pages. Since the glock state machine
normally does that for us, mostly the code will be a no-op.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/gfs2/aops.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -999,6 +999,7 @@ static ssize_t gfs2_direct_IO(int rw, st
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
+ struct address_space *mapping = inode->i_mapping;
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_holder gh;
int rv;
@@ -1019,6 +1020,35 @@ static ssize_t gfs2_direct_IO(int rw, st
if (rv != 1)
goto out; /* dio not valid, fall back to buffered i/o */
+ /*
+ * Now since we are holding a deferred (CW) lock at this point, you
+ * might be wondering why this is ever needed. There is a case however
+ * where we've granted a deferred local lock against a cached exclusive
+ * glock. That is ok provided all granted local locks are deferred, but
+ * it also means that it is possible to encounter pages which are
+ * cached and possibly also mapped. So here we check for that and sort
+ * them out ahead of the dio. The glock state machine will take care of
+ * everything else.
+ *
+ * If in fact the cached glock state (gl->gl_state) is deferred (CW) in
+ * the first place, mapping->nr_pages will always be zero.
+ */
+ if (mapping->nrpages) {
+ loff_t lstart = offset & (PAGE_CACHE_SIZE - 1);
+ loff_t len = iov_length(iov, nr_segs);
+ loff_t end = PAGE_ALIGN(offset + len) - 1;
+
+ rv = 0;
+ if (len == 0)
+ goto out;
+ if (test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
+ unmap_shared_mapping_range(ip->i_inode.i_mapping, offset, len);
+ rv = filemap_write_and_wait_range(mapping, lstart, end);
+ if (rv)
+ return rv;
+ truncate_inode_pages_range(mapping, lstart, end);
+ }
+
rv = __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, gfs2_get_block_direct,
NULL, NULL, 0);
next prev parent reply other threads:[~2014-01-06 22:38 UTC|newest]
Thread overview: 131+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 22:37 [PATCH 3.10 000/129] 3.10.26-stable review Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 001/129] USB: serial: fix race in generic write Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 002/129] ceph: cleanup aborted requests when re-sending requests Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 003/129] ceph: wake up safe waiters when unregistering request Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 004/129] powerpc: kvm: fix rare but potential deadlock scene Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 005/129] TTY: pmac_zilog, check existence of ports in pmz_console_init() Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 006/129] staging: comedi: 8255_pci: fix for newer PCI-DIO48H Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 007/129] ASoC: tegra: fix uninitialized variables in set_fmt Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 008/129] ASoC: wm8904: fix DSP mode B configuration Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 009/129] ASoC: wm_adsp: Add small delay while polling DSP RAM start Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 010/129] ASoC: wm5110: Correct HPOUT3 DAPM route typo Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 011/129] ALSA: Add SNDRV_PCM_STATE_PAUSED case in wait_for_avail function Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 012/129] ALSA: hda - Add enable_msi=0 workaround for four HP machines Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 013/129] iio:imu:adis16400 fix pressure channel scan type Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 014/129] iio:adc:ad7887 Fix channel reported endianness from cpu to big endian Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 015/129] serial: 8250_dw: add new ACPI IDs Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 016/129] usb: serial: zte_ev: move support for ZTE AC2726 from zte_ev back to option Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 017/129] can: peak_usb: fix mem leak in pcan_usb_pro_init() Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 019/129] selinux: fix broken peer recv check Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 020/129] selinux: selinux_setprocattr()->ptrace_parent() needs rcu_read_lock() Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 021/129] iser-target: fix error return code in isert_create_device_ib_res() Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 022/129] iscsi-target: Fix-up all zero data-length CDBs with R/W_BIT set Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 023/129] target/file: Update hw_max_sectors based on current block_size Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 024/129] ftrace: Initialize the ftrace profiler for each possible cpu Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 025/129] arm64: ptrace: avoid using HW_BREAKPOINT_EMPTY for disabled events Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 026/129] arm64: spinlock: retry trylock operation if strex fails on free lock Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 027/129] ARM: OMAP2+: hwmod_data: fix missing OMAP_INTC_START in irq data Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 028/129] x86 idle: Repair large-server 50-watt idle-power regression Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 029/129] ext4: call ext4_error_inode() if jbd2_journal_dirty_metadata() fails Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 030/129] ext4: fix use-after-free in ext4_mb_new_blocks Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 032/129] ext4: Do not reserve clusters when fs doesnt support extents Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 033/129] ext4: fix deadlock when writing in ENOSPC conditions Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 034/129] ext4: add explicit casts when masking cluster sizes Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 036/129] sched: numa: skip inaccessible VMAs Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 037/129] sched/rt: Fix rqs cpupri leak while enqueue/dequeue child RT entities Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 038/129] firewire: sbp2: bring back WRITE SAME support Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 039/129] net_dma: mark broken Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 041/129] drm/radeon: Fix sideport problems on certain RS690 boards Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 042/129] drm/radeon: add missing display tiling setup for oland Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 044/129] drm/i915: Hold mutex across i915_gem_release Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 045/129] drm/i915: dont update the dri1 breadcrumb with modesetting Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 046/129] drm/radeon: fix asic gfx values for scrapper asics Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 049/129] drm/radeon: 0x9649 is SUMO2 not SUMO Greg Kroah-Hartman
2014-01-06 22:37 ` [PATCH 3.10 050/129] ceph: Avoid data inconsistency due to d-cache aliasing in readpage() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 051/129] tg3: Expand 4g_overflow_test workaround to skb fragments of any size Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 052/129] auxvec.h: account for AT_HWCAP2 in AT_VECTOR_SIZE_BASE Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 053/129] dm9601: fix reception of full size ethernet frames on dm9620/dm9621a Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 054/129] dm9601: work around tx fifo sync issue on dm962x Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 055/129] ath9k: Fix interrupt handling for the AR9002 family Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 056/129] ath9k_htc: properly set MAC address and BSSID mask Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 057/129] KVM: x86: Fix APIC map calculation after re-enabling Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 058/129] powerpc: Fix bad stack check in exception entry Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 059/129] powerpc: Align p_end Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 060/129] cpupower: Fix segfault due to incorrect getopt_long arugments Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 061/129] libata: add ATA_HORKAGE_BROKEN_FPDMA_AA quirk for Seagate Momentus SpinPoint M8 Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 062/129] libata: Add atapi_dmadir force flag Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 063/129] libata: disable a disk via libata.force params Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 065/129] radiotap: fix bitmap-end-finding buffer overrun Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 066/129] rtlwifi: pci: Fix oops on driver unload Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 067/129] intel_pstate: Fail initialization if P-state information is missing Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 068/129] Revert "of/address: Handle #address-cells > 2 specially" Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 069/129] mm: clear pmd_numa before invalidating Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 070/129] mm: numa: ensure anon_vma is locked to prevent parallel THP splits Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 071/129] mm: numa: avoid unnecessary work on the failure path Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 072/129] sched: fix the theoretical signal_wake_up() vs schedule() race Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 073/129] mm: fix TLB flush race between migration, and change_protection_range Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 074/129] mm: numa: guarantee that tlb_flush_pending updates are visible before page table updates Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 075/129] mm/mempolicy: correct putback method for isolate pages if failed Greg Kroah-Hartman
2014-01-07 17:26 ` Luis Henriques
2014-01-07 18:48 ` Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 076/129] mm/compaction: respect ignore_skip_hint in update_pageblock_skip Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 077/129] mm/hugetlb: check for pte NULL pointer in __page_check_address() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 078/129] mm: fix use-after-free in sys_remap_file_pages Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 079/129] mm/memory-failure.c: transfer page count from head page to tail page after split thp Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 080/129] Input: allocate absinfo data when setting ABS capability Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 081/129] GFS2: dont hold s_umount over blkdev_put Greg Kroah-Hartman
2014-01-06 22:38 ` Greg Kroah-Hartman [this message]
2014-01-06 22:38 ` [PATCH 3.10 083/129] memcg: fix memcg_size() calculation Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 084/129] s390/3270: fix allocation of tty3270_screen structure Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 085/129] jbd2: dont BUG but return ENOSPC if a handle runs out of space Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 086/129] gpio: twl4030: Fix regression for twl gpio LED output Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 087/129] gpio: msm: Fix irq mask/unmask by writing bits instead of numbers Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 088/129] sh: always link in helper functions extracted from libgcc Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 089/129] selinux: look for IPsec labels on both inbound and outbound packets Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 090/129] selinux: process labeled IPsec TCP SYN-ACK packets properly in selinux_ip_postroute() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 091/129] clocksource: dw_apb_timer_of: Fix read_sched_clock Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 092/129] ceph: improve error handling in ceph_mdsmap_decode Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 093/129] libceph: add lingering request reference when registered Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 094/129] rbd: flush dcache after zeroing page data Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 095/129] rbd: set removing flag while holding list lock Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 096/129] rbd: protect against concurrent unmaps Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 097/129] libceph: fix safe completion Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 098/129] libceph: fix truncate size calculation Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 099/129] rbd: fix a couple warnings Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 100/129] ceph: Free mdsc if alloc mdsc->mdsmap failed Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 101/129] ceph: avoid accessing invalid memory Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 102/129] libceph: call r_unsafe_callback when unsafe reply is received Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 103/129] ceph: fix null pointer dereference Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 104/129] ceph: cleanup types in striped_read() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 105/129] ceph: Add check returned value on func ceph_calc_ceph_pg Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 106/129] libceph: fix error handling in handle_reply() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 107/129] libceph: potential NULL dereference in ceph_osdc_handle_map() Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 108/129] libceph: create_singlethread_workqueue() doesnt return ERR_PTRs Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 109/129] ceph: fix bugs about handling short-read for sync read mode Greg Kroah-Hartman
2014-01-06 22:38 ` [PATCH 3.10 110/129] ceph: allow sync_read/write return partial successed size of read/write Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 111/129] rbd: fix buffer size for writes to images with snapshots Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 112/129] rbd: fix null dereference in dout Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 113/129] libceph: add function to ensure notifies are complete Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 114/129] rbd: complete notifies before cleaning up osd_client and rbd_dev Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 115/129] rbd: make rbd_obj_notify_ack() synchronous Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 116/129] rbd: fix use-after free of rbd_dev->disk Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 117/129] rbd: ignore unmapped snapshots that no longer exist Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 118/129] rbd: fix error handling from rbd_snap_name() Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 119/129] arm64: Only enable local interrupts after the CPU is marked online Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 120/129] arm64: virt: ensure visibility of __boot_cpu_mode Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 121/129] arm64: Change kernel stack size to 16K Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 122/129] arm64: fix possible invalid FPSIMD initialization state Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 123/129] arm64: check for number of arguments in syscall_get/set_arguments() Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 124/129] arm64: dts: Reserve the memory used for secondary CPU release address Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 125/129] arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 126/129] clocksource: arch_timer: use virtual counters Greg Kroah-Hartman
2014-01-07 10:09 ` Mark Rutland
2014-01-07 18:50 ` Greg Kroah-Hartman
2014-01-08 9:25 ` Mark Rutland
2014-01-06 22:39 ` [PATCH 3.10 127/129] arm64: Avoid cache flushing in flush_dcache_page() Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 128/129] arm64: Do not flush the D-cache for anonymous pages Greg Kroah-Hartman
2014-01-06 22:39 ` [PATCH 3.10 129/129] arm64: Use Normal NonCacheable memory for writecombine Greg Kroah-Hartman
2014-01-07 5:02 ` [PATCH 3.10 000/129] 3.10.26-stable review Guenter Roeck
2014-01-07 15:22 ` Greg Kroah-Hartman
2014-01-07 19:05 ` Greg Kroah-Hartman
2014-01-07 19:09 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140106223901.954596421@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).