Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617784 > unrolled thread

[PATCH 4.9 00/72] 4.9.21-stable review

Started byGreg Kroah-Hartman <gregkh@linuxfoundation.org>
First post2017-04-06 11:30 +0200
Last post2017-04-07 00:00 +0200
Articles 9 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 4.9 00/72] 4.9.21-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:30 +0200
    [PATCH 4.9 24/72] xfs: tune down agno asserts in the bmap code Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:30 +0200
    [PATCH 4.9 07/72] xfs: fix eofblocks race with file extending async dio writes Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:40 +0200
    [PATCH 4.9 10/72] xfs: filter out obviously bad btree pointers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:40 +0200
    [PATCH 4.9 01/72] libceph: force GFP_NOIO for socket allocations Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:40 +0200
    [PATCH 4.9 05/72] xfs: pull up iolock from xfs_free_eofblocks() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:40 +0200
    [PATCH 4.9 06/72] xfs: sync eofblocks scans under iolock are livelock prone Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-06 11:40 +0200
    Re: [PATCH 4.9 00/72] 4.9.21-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-04-06 19:50 +0200
    Re: [PATCH 4.9 00/72] 4.9.21-stable review Guenter Roeck <linux@roeck-us.net> - 2017-04-07 00:00 +0200

#1617784 — [PATCH 4.9 00/72] 4.9.21-stable review

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:30 +0200
Subject[PATCH 4.9 00/72] 4.9.21-stable review
Message-ID<ttbh7-6aP-3@gated-at.bofh.it>
This is the start of the stable review cycle for the 4.9.21 release.
There are 72 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sat Apr  8 08:36:01 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.21-rc1.gz
or in the git tree and branch at:
  git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 4.9.21-rc1

Keith Busch <keith.busch@intel.com>
    nvme/pci: Disable on removal when disconnected

Keith Busch <keith.busch@intel.com>
    nvme/core: Fix race kicking freed request_queue

Jason A. Donenfeld <Jason@zx2c4.com>
    padata: avoid race in reordering

NeilBrown <neilb@suse.com>
    blk: Ensure users for current->bio_list can see the full list.

NeilBrown <neilb@suse.com>
    blk: improve order of bio handling in generic_make_request()

Johannes Weiner <hannes@cmpxchg.org>
    mm: workingset: fix premature shadow node shrinking with cgroups

Felix Fietkau <nbd@nbd.name>
    MIPS: Lantiq: Fix cascaded IRQ setup

Jon Mason <jon.mason@broadcom.com>
    ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags

Joe Carnuccio <joe.carnuccio@cavium.com>
    qla2xxx: Allow vref count to timeout on vport delete.

Rafał Miłecki <rafal@milecki.pl>
    ARM: BCM5301X: Add back handler ignoring external imprecise aborts

Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd()

Johannes Weiner <hannes@cmpxchg.org>
    mm: rmap: fix huge file mmap accounting in the memcg stats

Kees Cook <keescook@chromium.org>
    lib/syscall: Clear return values when no stack

Tony Luck <tony.luck@intel.com>
    x86/mce: Fix copy/paste error in exception table entries

Baoquan He <bhe@redhat.com>
    x86/mm/KASLR: Exclude EFI region from KASLR VA space randomization

Lucas Stach <l.stach@pengutronix.de>
    drm/etnaviv: (re-)protect fence allocation with GPU mutex

Eric Anholt <eric@anholt.net>
    drm/vc4: Allocate the right amount of space for boot-time CRTC state.

Michel Dänzer <michel.daenzer@amd.com>
    drm/radeon: Override fpfn for all VRAM placements in radeon_evict_flags

David Hildenbrand <david@redhat.com>
    KVM: kvm_io_bus_unregister_dev() should never fail

Peter Xu <peterx@redhat.com>
    KVM: x86: clear bus pointer when destroyed

Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    serial: mxs-auart: Fix baudrate calculation

Alan Stern <stern@rowland.harvard.edu>
    USB: fix linked-list corruption in rh_call_control()

Nicolas Ferre <nicolas.ferre@microchip.com>
    tty/serial: atmel: fix TX path in atmel_console_write()

Richard Genoud <richard.genoud@gmail.com>
    tty/serial: atmel: fix race condition (TX+DMA)

Joerg Roedel <jroedel@suse.de>
    ACPI: Do not create a platform_device for IOAPIC/IOxAPIC

Josh Poimboeuf <jpoimboe@redhat.com>
    ACPI: Fix incompatibility with mcount-based function graph tracing

Helge Deller <deller@gmx.de>
    parisc: Fix access fault handling in pa_memcpy()

Helge Deller <deller@gmx.de>
    parisc: Avoid stalled CPU warnings after system shutdown

Helge Deller <deller@gmx.de>
    parisc: Clean up fixup routines for get_user()/put_user()

Kinglong Mee <kinglongmee@gmail.com>
    nfsd: map the ENOKEY to nfserr_perm for avoiding warning

Olga Kornievskaia <kolga@netapp.com>
    NFSv4.1 fix infinite loop on IO BAD_STATEID error

Ludovic Desroches <ludovic.desroches@microchip.com>
    mmc: sdhci-of-at91: fix MMC_DDR_52 timing selection

Hans de Goede <hdegoede@redhat.com>
    mmc: sdhci: Disable runtime pm when the sdio_irq is enabled

Aaron Armstrong Skomra <skomra@gmail.com>
    HID: wacom: Don't add ghost interface as shared data

Takashi Sakamoto <takashi.sakamoto@miraclelinux.com>
    ASoC: Intel: Skylake: fix invalid memory access due to wrong reference of pointer

Songjun Wu <songjun.wu@microchip.com>
    ASoC: atmel-classd: fix audio clock rate

Hui Wang <hui.wang@canonical.com>
    ALSA: hda - fix a problem for lineout on a Dell AIO machine

Takashi Iwai <tiwai@suse.de>
    ALSA: seq: Fix race during FIFO resize

Bjorn Helgaas <bhelgaas@google.com>
    PCI: iproc: Save host bridge window resource in struct iproc_pcie

Bart Van Assche <bart.vanassche@sandisk.com>
    scsi: scsi_dh_alua: Ensure that alua_activate() calls the completion function

Bart Van Assche <bart.vanassche@sandisk.com>
    scsi: scsi_dh_alua: Check scsi_device_get() return value

John Garry <john.garry@huawei.com>
    scsi: libsas: fix ata xfer length

peter chang <dpf@google.com>
    scsi: sg: check length passed to SG_NEXT_CMD_LEN

Christoph Hellwig <hch@lst.de>
    xfs: try any AG when allocating the first btree block when reflinking

Brian Foster <bfoster@redhat.com>
    xfs: use iomap new flag for newly allocated delalloc blocks

Chandan Rajendra <chandan@linux.vnet.ibm.com>
    xfs: Use xfs_icluster_size_fsb() to calculate inode alignment mask

Christoph Hellwig <hch@lst.de>
    xfs: fix and streamline error handling in xfs_end_io

Christoph Hellwig <hch@lst.de>
    xfs: only reclaim unwritten COW extents periodically

Christoph Hellwig <hch@lst.de>
    xfs: tune down agno asserts in the bmap code

Chandan Rajendra <chandan@linux.vnet.ibm.com>
    xfs: Use xfs_icluster_size_fsb() to calculate inode chunk alignment

Brian Foster <bfoster@redhat.com>
    xfs: don't reserve blocks for right shift transactions

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: fix uninitialized variable in _reflink_convert_cow

Brian Foster <bfoster@redhat.com>
    xfs: split indlen reservations fairly when under reserved

Brian Foster <bfoster@redhat.com>
    xfs: handle indlen shortage on delalloc extent merge

Christoph Hellwig <hch@lst.de>
    xfs: don't fail xfs_extent_busy allocation

Christoph Hellwig <hch@lst.de>
    xfs: reject all unaligned direct writes to reflinked files

Christoph Hellwig <hch@lst.de>
    xfs: update ctime and mtime on clone destinatation inodes

Hou Tao <houtao1@huawei.com>
    xfs: reset b_first_retry_time when clear the retry status of xfs_buf_t

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: mark speculative prealloc CoW fork extents unwritten

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: allow unwritten extents in the CoW fork

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: verify free block header fields

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: check for obviously bad level values in the bmbt root

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: filter out obviously bad btree pointers

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: fail _dir_open when readahead fails

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: fix toctou race when locking an inode to access the data map

Brian Foster <bfoster@redhat.com>
    xfs: fix eofblocks race with file extending async dio writes

Brian Foster <bfoster@redhat.com>
    xfs: sync eofblocks scans under iolock are livelock prone

Brian Foster <bfoster@redhat.com>
    xfs: pull up iolock from xfs_free_eofblocks()

Christoph Hellwig <hch@lst.de>
    xfs: use per-AG reservations for the finobt

Christoph Hellwig <hch@lst.de>
    xfs: only update mount/resv fields on success in __xfs_ag_resv_init

Ross Lagerwall <ross.lagerwall@citrix.com>
    xen/setup: Don't relocate p2m over existing one

Ilya Dryomov <idryomov@gmail.com>
    libceph: force GFP_NOIO for socket allocations


-------------

Diffstat:

 Makefile                                   |   4 +-
 arch/arm/boot/dts/bcm5301x.dtsi            |   4 +-
 arch/arm/mach-bcm/bcm_5301x.c              |  28 ++
 arch/mips/lantiq/irq.c                     |  38 ++-
 arch/parisc/include/asm/uaccess.h          |  59 ++--
 arch/parisc/kernel/parisc_ksyms.c          |  10 -
 arch/parisc/kernel/process.c               |   2 +
 arch/parisc/lib/Makefile                   |   2 +-
 arch/parisc/lib/fixup.S                    |  98 ------
 arch/parisc/lib/lusercopy.S                | 318 ++++++++++++++++++++
 arch/parisc/lib/memcpy.c                   | 461 +----------------------------
 arch/parisc/mm/fault.c                     |  17 ++
 arch/x86/lib/memcpy_64.S                   |   2 +-
 arch/x86/mm/kaslr.c                        |   4 +-
 arch/x86/xen/setup.c                       |   6 +-
 block/bio.c                                |  12 +-
 block/blk-core.c                           |  39 ++-
 drivers/acpi/Makefile                      |   1 -
 drivers/acpi/acpi_platform.c               |   8 +-
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c      |   4 +-
 drivers/gpu/drm/radeon/radeon_ttm.c        |   4 +-
 drivers/gpu/drm/vc4/vc4_crtc.c             |  13 +-
 drivers/hid/wacom_sys.c                    |  16 +-
 drivers/md/dm.c                            |  29 +-
 drivers/md/raid10.c                        |   3 +-
 drivers/mmc/host/sdhci-of-at91.c           |  11 +-
 drivers/mmc/host/sdhci.c                   |   6 +
 drivers/nvme/host/core.c                   |   6 +-
 drivers/nvme/host/pci.c                    |   4 +-
 drivers/pci/host/pcie-iproc-bcma.c         |  24 +-
 drivers/pci/host/pcie-iproc-platform.c     |  19 +-
 drivers/pci/host/pcie-iproc.h              |   1 +
 drivers/scsi/device_handler/scsi_dh_alua.c |  38 ++-
 drivers/scsi/libsas/sas_ata.c              |   2 +-
 drivers/scsi/qla2xxx/qla_attr.c            |   2 -
 drivers/scsi/qla2xxx/qla_def.h             |   3 +
 drivers/scsi/qla2xxx/qla_init.c            |   1 +
 drivers/scsi/qla2xxx/qla_mid.c             |  14 +-
 drivers/scsi/qla2xxx/qla_os.c              |   1 +
 drivers/scsi/sg.c                          |   2 +
 drivers/tty/serial/atmel_serial.c          |   8 +
 drivers/tty/serial/mxs-auart.c             |   2 +-
 drivers/usb/core/hcd.c                     |   7 +-
 fs/nfs/nfs4proc.c                          |   9 +-
 fs/nfsd/nfsproc.c                          |   1 +
 fs/xfs/libxfs/xfs_ag_resv.c                |  70 ++++-
 fs/xfs/libxfs/xfs_bmap.c                   | 211 +++++++------
 fs/xfs/libxfs/xfs_bmap_btree.c             |   6 +-
 fs/xfs/libxfs/xfs_btree.c                  |   3 +-
 fs/xfs/libxfs/xfs_btree.h                  |   2 +-
 fs/xfs/libxfs/xfs_da_btree.c               |   6 +-
 fs/xfs/libxfs/xfs_da_btree.h               |   2 +-
 fs/xfs/libxfs/xfs_dir2_node.c              |  51 +++-
 fs/xfs/libxfs/xfs_ialloc.c                 |   3 +-
 fs/xfs/libxfs/xfs_ialloc_btree.c           |  90 +++++-
 fs/xfs/libxfs/xfs_ialloc_btree.h           |   3 +
 fs/xfs/libxfs/xfs_inode_fork.c             |   9 +-
 fs/xfs/xfs_aops.c                          | 110 +++----
 fs/xfs/xfs_bmap_util.c                     |  62 ++--
 fs/xfs/xfs_bmap_util.h                     |   3 +-
 fs/xfs/xfs_buf_item.c                      |   1 +
 fs/xfs/xfs_extent_busy.c                   |  13 +-
 fs/xfs/xfs_file.c                          |  26 +-
 fs/xfs/xfs_icache.c                        |  61 ++--
 fs/xfs/xfs_icache.h                        |   2 -
 fs/xfs/xfs_inode.c                         |  76 ++---
 fs/xfs/xfs_iomap.c                         |  18 +-
 fs/xfs/xfs_mount.c                         |   3 +-
 fs/xfs/xfs_mount.h                         |   1 +
 fs/xfs/xfs_reflink.c                       | 151 ++++++++--
 fs/xfs/xfs_reflink.h                       |   6 +-
 fs/xfs/xfs_super.c                         |   2 +-
 fs/xfs/xfs_trace.h                         |  10 +-
 include/linux/kvm_host.h                   |   4 +-
 include/linux/memcontrol.h                 |   6 +
 kernel/padata.c                            |   5 +-
 lib/syscall.c                              |   1 +
 mm/hugetlb.c                               |   6 +-
 mm/rmap.c                                  |   4 +-
 mm/workingset.c                            |   2 +-
 net/ceph/messenger.c                       |   6 +
 sound/core/seq/seq_fifo.c                  |   4 +
 sound/pci/hda/patch_realtek.c              |  12 +-
 sound/soc/atmel/atmel-classd.c             |   2 +-
 sound/soc/intel/skylake/skl-topology.c     |   2 +-
 virt/kvm/eventfd.c                         |   3 +-
 virt/kvm/kvm_main.c                        |  42 ++-
 87 files changed, 1333 insertions(+), 1110 deletions(-)

[toc] | [next] | [standalone]


#1617785 — [PATCH 4.9 24/72] xfs: tune down agno asserts in the bmap code

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:30 +0200
Subject[PATCH 4.9 24/72] xfs: tune down agno asserts in the bmap code
Message-ID<ttbTR-6GC-67@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Christoph Hellwig <hch@lst.de>

commit 410d17f67e583559be3a922f8b6cc336331893f3 upstream.

In various places we currently assert that xfs_bmap_btalloc allocates
from the same as the firstblock value passed in, unless it's either
NULLAGNO or the dop_low flag is set.  But the reflink code does not
fully follow this convention as it passes in firstblock purely as
a hint for the allocator without actually having previous allocations
in the transaction, and without having a minleft check on the current
AG, leading to the assert firing on a very full and heavily used
file system.  As even the reflink code only allocates from equal or
higher AGs for now we can simply the check to always allow for equal
or higher AGs.

Note that we need to eventually split the two meanings of the firstblock
value.  At that point we can also allow the reflink code to allocate
from any AG instead of limiting it in any way.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/xfs/libxfs/xfs_bmap.c |   22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -804,9 +804,7 @@ try_another_ag:
 	 */
 	ASSERT(args.fsbno != NULLFSBLOCK);
 	ASSERT(*firstblock == NULLFSBLOCK ||
-	       args.agno == XFS_FSB_TO_AGNO(mp, *firstblock) ||
-	       (dfops->dop_low &&
-		args.agno > XFS_FSB_TO_AGNO(mp, *firstblock)));
+	       args.agno >= XFS_FSB_TO_AGNO(mp, *firstblock));
 	*firstblock = cur->bc_private.b.firstblock = args.fsbno;
 	cur->bc_private.b.allocated++;
 	ip->i_d.di_nblocks++;
@@ -3923,17 +3921,13 @@ xfs_bmap_btalloc(
 		 * the first block that was allocated.
 		 */
 		ASSERT(*ap->firstblock == NULLFSBLOCK ||
-		       XFS_FSB_TO_AGNO(mp, *ap->firstblock) ==
-		       XFS_FSB_TO_AGNO(mp, args.fsbno) ||
-		       (ap->dfops->dop_low &&
-			XFS_FSB_TO_AGNO(mp, *ap->firstblock) <
-			XFS_FSB_TO_AGNO(mp, args.fsbno)));
+		       XFS_FSB_TO_AGNO(mp, *ap->firstblock) <=
+		       XFS_FSB_TO_AGNO(mp, args.fsbno));
 
 		ap->blkno = args.fsbno;
 		if (*ap->firstblock == NULLFSBLOCK)
 			*ap->firstblock = args.fsbno;
-		ASSERT(nullfb || fb_agno == args.agno ||
-		       (ap->dfops->dop_low && fb_agno < args.agno));
+		ASSERT(nullfb || fb_agno <= args.agno);
 		ap->length = args.len;
 		if (!(ap->flags & XFS_BMAPI_COWFORK))
 			ap->ip->i_d.di_nblocks += args.len;
@@ -4858,13 +4852,9 @@ error0:
 	if (bma.cur) {
 		if (!error) {
 			ASSERT(*firstblock == NULLFSBLOCK ||
-			       XFS_FSB_TO_AGNO(mp, *firstblock) ==
+			       XFS_FSB_TO_AGNO(mp, *firstblock) <=
 			       XFS_FSB_TO_AGNO(mp,
-				       bma.cur->bc_private.b.firstblock) ||
-			       (dfops->dop_low &&
-				XFS_FSB_TO_AGNO(mp, *firstblock) <
-				XFS_FSB_TO_AGNO(mp,
-					bma.cur->bc_private.b.firstblock)));
+				       bma.cur->bc_private.b.firstblock));
 			*firstblock = bma.cur->bc_private.b.firstblock;
 		}
 		xfs_btree_del_cursor(bma.cur,

[toc] | [prev] | [next] | [standalone]


#1617796 — [PATCH 4.9 07/72] xfs: fix eofblocks race with file extending async dio writes

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:40 +0200
Subject[PATCH 4.9 07/72] xfs: fix eofblocks race with file extending async dio writes
Message-ID<ttc3w-6L0-25@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Brian Foster <bfoster@redhat.com>

commit e4229d6b0bc9280f29624faf170cf76a9f1ca60e upstream.

It's possible for post-eof blocks to end up being used for direct I/O
writes. dio write performs an upfront unwritten extent allocation, sends
the dio and then updates the inode size (if necessary) on write
completion. If a file release occurs while a file extending dio write is
in flight, it is possible to mistake the post-eof blocks for speculative
preallocation and incorrectly truncate them from the inode. This means
that the resulting dio write completion can discover a hole and allocate
new blocks rather than perform unwritten extent conversion.

This requires a strange mix of I/O and is thus not likely to reproduce
in real world workloads. It is intermittently reproduced by generic/299.
The error manifests as an assert failure due to transaction overrun
because the aforementioned write completion transaction has only
reserved enough blocks for btree operations:

  XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, \
   file: fs/xfs//xfs_trans.c, line: 309

The root cause is that xfs_free_eofblocks() uses i_size to truncate
post-eof blocks from the inode, but async, file extending direct writes
do not update i_size until write completion, long after inode locks are
dropped. Therefore, xfs_free_eofblocks() effectively truncates the inode
to the incorrect size.

Update xfs_free_eofblocks() to serialize against dio similar to how
extending writes are serialized against i_size updates before post-eof
block zeroing. Specifically, wait on dio while under the iolock. This
ensures that dio write completions have updated i_size before post-eof
blocks are processed.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/xfs/xfs_bmap_util.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -959,6 +959,9 @@ xfs_free_eofblocks(
 		if (error)
 			return error;
 
+		/* wait on dio to ensure i_size has settled */
+		inode_dio_wait(VFS_I(ip));
+
 		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0,
 				&tp);
 		if (error) {

[toc] | [prev] | [next] | [standalone]


#1617797 — [PATCH 4.9 10/72] xfs: filter out obviously bad btree pointers

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:40 +0200
Subject[PATCH 4.9 10/72] xfs: filter out obviously bad btree pointers
Message-ID<ttc3w-6L0-31@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Darrick J. Wong <darrick.wong@oracle.com>

commit d5a91baeb6033c3392121e4d5c011cdc08dfa9f7 upstream.

Don't let anybody load an obviously bad btree pointer.  Since the values
come from disk, we must return an error, not just ASSERT.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/xfs/libxfs/xfs_bmap.c  |    5 +----
 fs/xfs/libxfs/xfs_btree.c |    3 ++-
 fs/xfs/libxfs/xfs_btree.h |    2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1278,7 +1278,6 @@ xfs_bmap_read_extents(
 	/* REFERENCED */
 	xfs_extnum_t		room;	/* number of entries there's room for */
 
-	bno = NULLFSBLOCK;
 	mp = ip->i_mount;
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	exntf = (whichfork != XFS_DATA_FORK) ? XFS_EXTFMT_NOSTATE :
@@ -1291,9 +1290,7 @@ xfs_bmap_read_extents(
 	ASSERT(level > 0);
 	pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes);
 	bno = be64_to_cpu(*pp);
-	ASSERT(bno != NULLFSBLOCK);
-	ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);
-	ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks);
+
 	/*
 	 * Go down the tree until leaf level is reached, following the first
 	 * pointer (leftmost) at each level.
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -810,7 +810,8 @@ xfs_btree_read_bufl(
 	xfs_daddr_t		d;		/* real disk block address */
 	int			error;
 
-	ASSERT(fsbno != NULLFSBLOCK);
+	if (!XFS_FSB_SANITY_CHECK(mp, fsbno))
+		return -EFSCORRUPTED;
 	d = XFS_FSB_TO_DADDR(mp, fsbno);
 	error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d,
 				   mp->m_bsize, lock, &bp, ops);
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -491,7 +491,7 @@ static inline int xfs_btree_get_level(st
 #define	XFS_FILBLKS_MAX(a,b)	max_t(xfs_filblks_t, (a), (b))
 
 #define	XFS_FSB_SANITY_CHECK(mp,fsb)	\
-	(XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
+	(fsb && XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
 		XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
 
 /*

[toc] | [prev] | [next] | [standalone]


#1617798 — [PATCH 4.9 01/72] libceph: force GFP_NOIO for socket allocations

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:40 +0200
Subject[PATCH 4.9 01/72] libceph: force GFP_NOIO for socket allocations
Message-ID<ttc3w-6L0-27@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ilya Dryomov <idryomov@gmail.com>

commit 633ee407b9d15a75ac9740ba9d3338815e1fcb95 upstream.

sock_alloc_inode() allocates socket+inode and socket_wq with
GFP_KERNEL, which is not allowed on the writeback path:

    Workqueue: ceph-msgr con_work [libceph]
    ffff8810871cb018 0000000000000046 0000000000000000 ffff881085d40000
    0000000000012b00 ffff881025cad428 ffff8810871cbfd8 0000000000012b00
    ffff880102fc1000 ffff881085d40000 ffff8810871cb038 ffff8810871cb148
    Call Trace:
    [<ffffffff816dd629>] schedule+0x29/0x70
    [<ffffffff816e066d>] schedule_timeout+0x1bd/0x200
    [<ffffffff81093ffc>] ? ttwu_do_wakeup+0x2c/0x120
    [<ffffffff81094266>] ? ttwu_do_activate.constprop.135+0x66/0x70
    [<ffffffff816deb5f>] wait_for_completion+0xbf/0x180
    [<ffffffff81097cd0>] ? try_to_wake_up+0x390/0x390
    [<ffffffff81086335>] flush_work+0x165/0x250
    [<ffffffff81082940>] ? worker_detach_from_pool+0xd0/0xd0
    [<ffffffffa03b65b1>] xlog_cil_force_lsn+0x81/0x200 [xfs]
    [<ffffffff816d6b42>] ? __slab_free+0xee/0x234
    [<ffffffffa03b4b1d>] _xfs_log_force_lsn+0x4d/0x2c0 [xfs]
    [<ffffffff811adc1e>] ? lookup_page_cgroup_used+0xe/0x30
    [<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa03b4dcf>] xfs_log_force_lsn+0x3f/0xf0 [xfs]
    [<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa03a62c6>] xfs_iunpin_wait+0xc6/0x1a0 [xfs]
    [<ffffffff810aa250>] ? wake_atomic_t_function+0x40/0x40
    [<ffffffffa039a723>] xfs_reclaim_inode+0xa3/0x330 [xfs]
    [<ffffffffa039ac07>] xfs_reclaim_inodes_ag+0x257/0x3d0 [xfs]
    [<ffffffffa039bb13>] xfs_reclaim_inodes_nr+0x33/0x40 [xfs]
    [<ffffffffa03ab745>] xfs_fs_free_cached_objects+0x15/0x20 [xfs]
    [<ffffffff811c0c18>] super_cache_scan+0x178/0x180
    [<ffffffff8115912e>] shrink_slab_node+0x14e/0x340
    [<ffffffff811afc3b>] ? mem_cgroup_iter+0x16b/0x450
    [<ffffffff8115af70>] shrink_slab+0x100/0x140
    [<ffffffff8115e425>] do_try_to_free_pages+0x335/0x490
    [<ffffffff8115e7f9>] try_to_free_pages+0xb9/0x1f0
    [<ffffffff816d56e4>] ? __alloc_pages_direct_compact+0x69/0x1be
    [<ffffffff81150cba>] __alloc_pages_nodemask+0x69a/0xb40
    [<ffffffff8119743e>] alloc_pages_current+0x9e/0x110
    [<ffffffff811a0ac5>] new_slab+0x2c5/0x390
    [<ffffffff816d71c4>] __slab_alloc+0x33b/0x459
    [<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
    [<ffffffff8164bda1>] ? inet_sendmsg+0x71/0xc0
    [<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
    [<ffffffff811a21f2>] kmem_cache_alloc+0x1a2/0x1b0
    [<ffffffff815b906d>] sock_alloc_inode+0x2d/0xd0
    [<ffffffff811d8566>] alloc_inode+0x26/0xa0
    [<ffffffff811da04a>] new_inode_pseudo+0x1a/0x70
    [<ffffffff815b933e>] sock_alloc+0x1e/0x80
    [<ffffffff815ba855>] __sock_create+0x95/0x220
    [<ffffffff815baa04>] sock_create_kern+0x24/0x30
    [<ffffffffa04794d9>] con_work+0xef9/0x2050 [libceph]
    [<ffffffffa04aa9ec>] ? rbd_img_request_submit+0x4c/0x60 [rbd]
    [<ffffffff81084c19>] process_one_work+0x159/0x4f0
    [<ffffffff8108561b>] worker_thread+0x11b/0x530
    [<ffffffff81085500>] ? create_worker+0x1d0/0x1d0
    [<ffffffff8108b6f9>] kthread+0xc9/0xe0
    [<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90
    [<ffffffff816e1b98>] ret_from_fork+0x58/0x90
    [<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90

Use memalloc_noio_{save,restore}() to temporarily force GFP_NOIO here.

Link: http://tracker.ceph.com/issues/19309
Reported-by: Sergey Jerusalimov <wintchester@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/ceph/messenger.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -7,6 +7,7 @@
 #include <linux/kthread.h>
 #include <linux/net.h>
 #include <linux/nsproxy.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/string.h>
@@ -469,11 +470,16 @@ static int ceph_tcp_connect(struct ceph_
 {
 	struct sockaddr_storage *paddr = &con->peer_addr.in_addr;
 	struct socket *sock;
+	unsigned int noio_flag;
 	int ret;
 
 	BUG_ON(con->sock);
+
+	/* sock_create_kern() allocates with GFP_KERNEL */
+	noio_flag = memalloc_noio_save();
 	ret = sock_create_kern(read_pnet(&con->msgr->net), paddr->ss_family,
 			       SOCK_STREAM, IPPROTO_TCP, &sock);
+	memalloc_noio_restore(noio_flag);
 	if (ret)
 		return ret;
 	sock->sk->sk_allocation = GFP_NOFS;

[toc] | [prev] | [next] | [standalone]


#1617807 — [PATCH 4.9 05/72] xfs: pull up iolock from xfs_free_eofblocks()

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:40 +0200
Subject[PATCH 4.9 05/72] xfs: pull up iolock from xfs_free_eofblocks()
Message-ID<ttc3x-6L0-43@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Brian Foster <bfoster@redhat.com>

commit a36b926180cda375ac2ec89e1748b47137cfc51c upstream.

xfs_free_eofblocks() requires the IOLOCK_EXCL lock, but is called from
different contexts where the lock may or may not be held. The
need_iolock parameter exists for this reason, to indicate whether
xfs_free_eofblocks() must acquire the iolock itself before it can
proceed.

This is ugly and confusing. Simplify the semantics of
xfs_free_eofblocks() to require the caller to acquire the iolock
appropriately and kill the need_iolock parameter. While here, the mp
param can be removed as well as the xfs_mount is accessible from the
xfs_inode structure. This patch does not change behavior.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/xfs/xfs_bmap_util.c |   41 +++++++++++++++------------------------
 fs/xfs/xfs_bmap_util.h |    3 --
 fs/xfs/xfs_icache.c    |   24 ++++++++++++++---------
 fs/xfs/xfs_inode.c     |   51 ++++++++++++++++++++++++++-----------------------
 4 files changed, 60 insertions(+), 59 deletions(-)

--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -917,17 +917,18 @@ xfs_can_free_eofblocks(struct xfs_inode
  */
 int
 xfs_free_eofblocks(
-	xfs_mount_t	*mp,
-	xfs_inode_t	*ip,
-	bool		need_iolock)
+	struct xfs_inode	*ip)
 {
-	xfs_trans_t	*tp;
-	int		error;
-	xfs_fileoff_t	end_fsb;
-	xfs_fileoff_t	last_fsb;
-	xfs_filblks_t	map_len;
-	int		nimaps;
-	xfs_bmbt_irec_t	imap;
+	struct xfs_trans	*tp;
+	int			error;
+	xfs_fileoff_t		end_fsb;
+	xfs_fileoff_t		last_fsb;
+	xfs_filblks_t		map_len;
+	int			nimaps;
+	struct xfs_bmbt_irec	imap;
+	struct xfs_mount	*mp = ip->i_mount;
+
+	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
 
 	/*
 	 * Figure out if there are any blocks beyond the end
@@ -944,6 +945,10 @@ xfs_free_eofblocks(
 	error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
 	xfs_iunlock(ip, XFS_ILOCK_SHARED);
 
+	/*
+	 * If there are blocks after the end of file, truncate the file to its
+	 * current size to free them up.
+	 */
 	if (!error && (nimaps != 0) &&
 	    (imap.br_startblock != HOLESTARTBLOCK ||
 	     ip->i_delayed_blks)) {
@@ -954,22 +959,10 @@ xfs_free_eofblocks(
 		if (error)
 			return error;
 
-		/*
-		 * There are blocks after the end of file.
-		 * Free them up now by truncating the file to
-		 * its current size.
-		 */
-		if (need_iolock) {
-			if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL))
-				return -EAGAIN;
-		}
-
 		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0,
 				&tp);
 		if (error) {
 			ASSERT(XFS_FORCED_SHUTDOWN(mp));
-			if (need_iolock)
-				xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 			return error;
 		}
 
@@ -997,8 +990,6 @@ xfs_free_eofblocks(
 		}
 
 		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		if (need_iolock)
-			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 	}
 	return error;
 }
@@ -1415,7 +1406,7 @@ xfs_shift_file_space(
 	 * into the accessible region of the file.
 	 */
 	if (xfs_can_free_eofblocks(ip, true)) {
-		error = xfs_free_eofblocks(mp, ip, false);
+		error = xfs_free_eofblocks(ip);
 		if (error)
 			return error;
 	}
--- a/fs/xfs/xfs_bmap_util.h
+++ b/fs/xfs/xfs_bmap_util.h
@@ -63,8 +63,7 @@ int	xfs_insert_file_space(struct xfs_ino
 
 /* EOF block manipulation functions */
 bool	xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
-int	xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
-			   bool need_iolock);
+int	xfs_free_eofblocks(struct xfs_inode *ip);
 
 int	xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
 			 struct xfs_swapext *sx);
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1324,7 +1324,7 @@ xfs_inode_free_eofblocks(
 	int			flags,
 	void			*args)
 {
-	int ret;
+	int ret = 0;
 	struct xfs_eofblocks *eofb = args;
 	bool need_iolock = true;
 	int match;
@@ -1360,19 +1360,25 @@ xfs_inode_free_eofblocks(
 			return 0;
 
 		/*
-		 * A scan owner implies we already hold the iolock. Skip it in
-		 * xfs_free_eofblocks() to avoid deadlock. This also eliminates
-		 * the possibility of EAGAIN being returned.
+		 * A scan owner implies we already hold the iolock. Skip it here
+		 * to avoid deadlock.
 		 */
 		if (eofb->eof_scan_owner == ip->i_ino)
 			need_iolock = false;
 	}
 
-	ret = xfs_free_eofblocks(ip->i_mount, ip, need_iolock);
-
-	/* don't revisit the inode if we're not waiting */
-	if (ret == -EAGAIN && !(flags & SYNC_WAIT))
-		ret = 0;
+	/*
+	 * If the caller is waiting, return -EAGAIN to keep the background
+	 * scanner moving and revisit the inode in a subsequent pass.
+	 */
+	if (need_iolock && !xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
+		if (flags & SYNC_WAIT)
+			ret = -EAGAIN;
+		return ret;
+	}
+	ret = xfs_free_eofblocks(ip);
+	if (need_iolock)
+		xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 
 	return ret;
 }
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1701,32 +1701,34 @@ xfs_release(
 	if (xfs_can_free_eofblocks(ip, false)) {
 
 		/*
+		 * Check if the inode is being opened, written and closed
+		 * frequently and we have delayed allocation blocks outstanding
+		 * (e.g. streaming writes from the NFS server), truncating the
+		 * blocks past EOF will cause fragmentation to occur.
+		 *
+		 * In this case don't do the truncation, but we have to be
+		 * careful how we detect this case. Blocks beyond EOF show up as
+		 * i_delayed_blks even when the inode is clean, so we need to
+		 * truncate them away first before checking for a dirty release.
+		 * Hence on the first dirty close we will still remove the
+		 * speculative allocation, but after that we will leave it in
+		 * place.
+		 */
+		if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE))
+			return 0;
+		/*
 		 * If we can't get the iolock just skip truncating the blocks
 		 * past EOF because we could deadlock with the mmap_sem
-		 * otherwise.  We'll get another chance to drop them once the
+		 * otherwise. We'll get another chance to drop them once the
 		 * last reference to the inode is dropped, so we'll never leak
 		 * blocks permanently.
-		 *
-		 * Further, check if the inode is being opened, written and
-		 * closed frequently and we have delayed allocation blocks
-		 * outstanding (e.g. streaming writes from the NFS server),
-		 * truncating the blocks past EOF will cause fragmentation to
-		 * occur.
-		 *
-		 * In this case don't do the truncation, either, but we have to
-		 * be careful how we detect this case. Blocks beyond EOF show
-		 * up as i_delayed_blks even when the inode is clean, so we
-		 * need to truncate them away first before checking for a dirty
-		 * release. Hence on the first dirty close we will still remove
-		 * the speculative allocation, but after that we will leave it
-		 * in place.
 		 */
-		if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE))
-			return 0;
-
-		error = xfs_free_eofblocks(mp, ip, true);
-		if (error && error != -EAGAIN)
-			return error;
+		if (xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
+			error = xfs_free_eofblocks(ip);
+			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+			if (error)
+				return error;
+		}
 
 		/* delalloc blocks after truncation means it really is dirty */
 		if (ip->i_delayed_blks)
@@ -1913,8 +1915,11 @@ xfs_inactive(
 		 * cache. Post-eof blocks must be freed, lest we end up with
 		 * broken free space accounting.
 		 */
-		if (xfs_can_free_eofblocks(ip, true))
-			xfs_free_eofblocks(mp, ip, false);
+		if (xfs_can_free_eofblocks(ip, true)) {
+			xfs_ilock(ip, XFS_IOLOCK_EXCL);
+			xfs_free_eofblocks(ip);
+			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+		}
 
 		return;
 	}

[toc] | [prev] | [next] | [standalone]


#1617811 — [PATCH 4.9 06/72] xfs: sync eofblocks scans under iolock are livelock prone

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-04-06 11:40 +0200
Subject[PATCH 4.9 06/72] xfs: sync eofblocks scans under iolock are livelock prone
Message-ID<ttc3x-6L0-53@gated-at.bofh.it>
In reply to#1617784
4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Brian Foster <bfoster@redhat.com>

commit c3155097ad89a956579bc305856a1f2878494e52 upstream.

The xfs_eofblocks.eof_scan_owner field is an internal field to
facilitate invoking eofb scans from the kernel while under the iolock.
This is necessary because the eofb scan acquires the iolock of each
inode. Synchronous scans are invoked on certain buffered write failures
while under iolock. In such cases, the scan owner indicates that the
context for the scan already owns the particular iolock and prevents a
double lock deadlock.

eofblocks scans while under iolock are still livelock prone in the event
of multiple parallel scans, however. If multiple buffered writes to
different inodes fail and invoke eofblocks scans at the same time, each
scan avoids a deadlock with its own inode by virtue of the
eof_scan_owner field, but will never be able to acquire the iolock of
the inode from the parallel scan. Because the low free space scans are
invoked with SYNC_WAIT, the scan will not return until it has processed
every tagged inode and thus both scans will spin indefinitely on the
iolock being held across the opposite scan. This problem can be
reproduced reliably by generic/224 on systems with higher cpu counts
(x16).

To avoid this problem, simplify the semantics of eofblocks scans to
never invoke a scan while under iolock. This means that the buffered
write context must drop the iolock before the scan. It must reacquire
the lock before the write retry and also repeat the initial write
checks, as the original state might no longer be valid once the iolock
was dropped.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 fs/xfs/xfs_file.c   |   13 +++++++++----
 fs/xfs/xfs_icache.c |   45 +++++++--------------------------------------
 fs/xfs/xfs_icache.h |    2 --
 3 files changed, 16 insertions(+), 44 deletions(-)

--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -675,8 +675,10 @@ xfs_file_buffered_aio_write(
 	struct xfs_inode	*ip = XFS_I(inode);
 	ssize_t			ret;
 	int			enospc = 0;
-	int			iolock = XFS_IOLOCK_EXCL;
+	int			iolock;
 
+write_retry:
+	iolock = XFS_IOLOCK_EXCL;
 	xfs_rw_ilock(ip, iolock);
 
 	ret = xfs_file_aio_write_checks(iocb, from, &iolock);
@@ -686,7 +688,6 @@ xfs_file_buffered_aio_write(
 	/* We can write back this queue in page reclaim */
 	current->backing_dev_info = inode_to_bdi(inode);
 
-write_retry:
 	trace_xfs_file_buffered_write(ip, iov_iter_count(from), iocb->ki_pos);
 	ret = iomap_file_buffered_write(iocb, from, &xfs_iomap_ops);
 	if (likely(ret >= 0))
@@ -702,18 +703,21 @@ write_retry:
 	 * running at the same time.
 	 */
 	if (ret == -EDQUOT && !enospc) {
+		xfs_rw_iunlock(ip, iolock);
 		enospc = xfs_inode_free_quota_eofblocks(ip);
 		if (enospc)
 			goto write_retry;
 		enospc = xfs_inode_free_quota_cowblocks(ip);
 		if (enospc)
 			goto write_retry;
+		iolock = 0;
 	} else if (ret == -ENOSPC && !enospc) {
 		struct xfs_eofblocks eofb = {0};
 
 		enospc = 1;
 		xfs_flush_inodes(ip->i_mount);
-		eofb.eof_scan_owner = ip->i_ino; /* for locking */
+
+		xfs_rw_iunlock(ip, iolock);
 		eofb.eof_flags = XFS_EOF_FLAGS_SYNC;
 		xfs_icache_free_eofblocks(ip->i_mount, &eofb);
 		goto write_retry;
@@ -721,7 +725,8 @@ write_retry:
 
 	current->backing_dev_info = NULL;
 out:
-	xfs_rw_iunlock(ip, iolock);
+	if (iolock)
+		xfs_rw_iunlock(ip, iolock);
 	return ret;
 }
 
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1326,11 +1326,8 @@ xfs_inode_free_eofblocks(
 {
 	int ret = 0;
 	struct xfs_eofblocks *eofb = args;
-	bool need_iolock = true;
 	int match;
 
-	ASSERT(!eofb || (eofb && eofb->eof_scan_owner != 0));
-
 	if (!xfs_can_free_eofblocks(ip, false)) {
 		/* inode could be preallocated or append-only */
 		trace_xfs_inode_free_eofblocks_invalid(ip);
@@ -1358,27 +1355,19 @@ xfs_inode_free_eofblocks(
 		if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
 		    XFS_ISIZE(ip) < eofb->eof_min_file_size)
 			return 0;
-
-		/*
-		 * A scan owner implies we already hold the iolock. Skip it here
-		 * to avoid deadlock.
-		 */
-		if (eofb->eof_scan_owner == ip->i_ino)
-			need_iolock = false;
 	}
 
 	/*
 	 * If the caller is waiting, return -EAGAIN to keep the background
 	 * scanner moving and revisit the inode in a subsequent pass.
 	 */
-	if (need_iolock && !xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
+	if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
 		if (flags & SYNC_WAIT)
 			ret = -EAGAIN;
 		return ret;
 	}
 	ret = xfs_free_eofblocks(ip);
-	if (need_iolock)
-		xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 
 	return ret;
 }
@@ -1425,15 +1414,10 @@ __xfs_inode_free_quota_eofblocks(
 	struct xfs_eofblocks eofb = {0};
 	struct xfs_dquot *dq;
 
-	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
-
 	/*
-	 * Set the scan owner to avoid a potential livelock. Otherwise, the scan
-	 * can repeatedly trylock on the inode we're currently processing. We
-	 * run a sync scan to increase effectiveness and use the union filter to
+	 * Run a sync scan to increase effectiveness and use the union filter to
 	 * cover all applicable quotas in a single scan.
 	 */
-	eofb.eof_scan_owner = ip->i_ino;
 	eofb.eof_flags = XFS_EOF_FLAGS_UNION|XFS_EOF_FLAGS_SYNC;
 
 	if (XFS_IS_UQUOTA_ENFORCED(ip->i_mount)) {
@@ -1585,12 +1569,9 @@ xfs_inode_free_cowblocks(
 {
 	int ret;
 	struct xfs_eofblocks *eofb = args;
-	bool need_iolock = true;
 	int match;
 	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
 
-	ASSERT(!eofb || (eofb && eofb->eof_scan_owner != 0));
-
 	/*
 	 * Just clear the tag if we have an empty cow fork or none at all. It's
 	 * possible the inode was fully unshared since it was originally tagged.
@@ -1623,28 +1604,16 @@ xfs_inode_free_cowblocks(
 		if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
 		    XFS_ISIZE(ip) < eofb->eof_min_file_size)
 			return 0;
-
-		/*
-		 * A scan owner implies we already hold the iolock. Skip it in
-		 * xfs_free_eofblocks() to avoid deadlock. This also eliminates
-		 * the possibility of EAGAIN being returned.
-		 */
-		if (eofb->eof_scan_owner == ip->i_ino)
-			need_iolock = false;
 	}
 
 	/* Free the CoW blocks */
-	if (need_iolock) {
-		xfs_ilock(ip, XFS_IOLOCK_EXCL);
-		xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
-	}
+	xfs_ilock(ip, XFS_IOLOCK_EXCL);
+	xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
 
 	ret = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF);
 
-	if (need_iolock) {
-		xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
-		xfs_iunlock(ip, XFS_IOLOCK_EXCL);
-	}
+	xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
+	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 
 	return ret;
 }
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -27,7 +27,6 @@ struct xfs_eofblocks {
 	kgid_t		eof_gid;
 	prid_t		eof_prid;
 	__u64		eof_min_file_size;
-	xfs_ino_t	eof_scan_owner;
 };
 
 #define SYNC_WAIT		0x0001	/* wait for i/o to complete */
@@ -102,7 +101,6 @@ xfs_fs_eofblocks_from_user(
 	dst->eof_flags = src->eof_flags;
 	dst->eof_prid = src->eof_prid;
 	dst->eof_min_file_size = src->eof_min_file_size;
-	dst->eof_scan_owner = NULLFSINO;
 
 	dst->eof_uid = INVALID_UID;
 	if (src->eof_flags & XFS_EOF_FLAGS_UID) {

[toc] | [prev] | [next] | [standalone]


#1618226

FromShuah Khan <shuahkh@osg.samsung.com>
Date2017-04-06 19:50 +0200
Message-ID<ttjHI-3XQ-19@gated-at.bofh.it>
In reply to#1617784
On 04/06/2017 02:37 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.21 release.
> There are 72 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat Apr  8 08:36:01 UTC 2017.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.21-rc1.gz
> or in the git tree and branch at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

[toc] | [prev] | [next] | [standalone]


#1618365

FromGuenter Roeck <linux@roeck-us.net>
Date2017-04-07 00:00 +0200
Message-ID<ttnBD-6sT-1@gated-at.bofh.it>
In reply to#1617784
On Thu, Apr 06, 2017 at 10:37:47AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.21 release.
> There are 72 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat Apr  8 08:36:01 UTC 2017.
> Anything received after that time might be too late.
> 
Build results:
	total: 149 pass: 149 fail: 0
Qemu test results:
	total: 122 pass: 122 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web