stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Filipe Manana <fdmanana@suse.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Subject: [PATCH 4.14 078/101] btrfs: run delayed items before dropping the snapshot
Date: Mon,  7 Jan 2019 13:33:06 +0100	[thread overview]
Message-ID: <20190107105337.242080339@linuxfoundation.org> (raw)
In-Reply-To: <20190107105330.372621917@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

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

From: Josef Bacik <jbacik@fb.com>

commit 0568e82dbe2510fc1fa664f58e5c997d3f1e649e upstream.

With my delayed refs patches in place we started seeing a large amount
of aborts in __btrfs_free_extent:

 BTRFS error (device sdb1): unable to find ref byte nr 91947008 parent 0 root 35964  owner 1 offset 0
 Call Trace:
  ? btrfs_merge_delayed_refs+0xaf/0x340
  __btrfs_run_delayed_refs+0x6ea/0xfc0
  ? btrfs_set_path_blocking+0x31/0x60
  btrfs_run_delayed_refs+0xeb/0x180
  btrfs_commit_transaction+0x179/0x7f0
  ? btrfs_check_space_for_delayed_refs+0x30/0x50
  ? should_end_transaction.isra.19+0xe/0x40
  btrfs_drop_snapshot+0x41c/0x7c0
  btrfs_clean_one_deleted_snapshot+0xb5/0xd0
  cleaner_kthread+0xf6/0x120
  kthread+0xf8/0x130
  ? btree_invalidatepage+0x90/0x90
  ? kthread_bind+0x10/0x10
  ret_from_fork+0x35/0x40

This was because btrfs_drop_snapshot depends on the root not being
modified while it's dropping the snapshot.  It will unlock the root node
(and really every node) as it walks down the tree, only to re-lock it
when it needs to do something.  This is a problem because if we modify
the tree we could cow a block in our path, which frees our reference to
that block.  Then once we get back to that shared block we'll free our
reference to it again, and get ENOENT when trying to lookup our extent
reference to that block in __btrfs_free_extent.

This is ultimately happening because we have delayed items left to be
processed for our deleted snapshot _after_ all of the inodes are closed
for the snapshot.  We only run the delayed inode item if we're deleting
the inode, and even then we do not run the delayed insertions or delayed
removals.  These can be run at any point after our final inode does its
last iput, which is what triggers the snapshot deletion.  We can end up
with the snapshot deletion happening and then have the delayed items run
on that file system, resulting in the above problem.

This problem has existed forever, however my patches made it much easier
to hit as I wake up the cleaner much more often to deal with delayed
iputs, which made us more likely to start the snapshot dropping work
before the transaction commits, which is when the delayed items would
generally be run.  Before, generally speaking, we would run the delayed
items, commit the transaction, and wakeup the cleaner thread to start
deleting snapshots, which means we were less likely to hit this problem.
You could still hit it if you had multiple snapshots to be deleted and
ended up with lots of delayed items, but it was definitely harder.

Fix for now by simply running all the delayed items before starting to
drop the snapshot.  We could make this smarter in the future by making
the delayed items per-root, and then simply drop any delayed items for
roots that we are going to delete.  But for now just a quick and easy
solution is the safest.

CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/extent-tree.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -9183,6 +9183,10 @@ int btrfs_drop_snapshot(struct btrfs_roo
 		goto out_free;
 	}
 
+	err = btrfs_run_delayed_items(trans);
+	if (err)
+		goto out_end_trans;
+
 	if (block_rsv)
 		trans->block_rsv = block_rsv;
 



  parent reply	other threads:[~2019-01-07 13:13 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-07 12:31 [PATCH 4.14 000/101] 4.14.92-stable review Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 001/101] phonet: af_phonet: Fix Spectre v1 vulnerability Greg Kroah-Hartman
2019-01-07 21:11   ` Sudip Mukherjee
2019-01-08  0:36     ` David Miller
2019-01-08  7:44       ` Greg KH
2019-01-07 12:31 ` [PATCH 4.14 002/101] net: core: " Greg Kroah-Hartman
2019-01-07 21:13   ` Sudip Mukherjee
2019-01-08  0:36     ` David Miller
2019-01-08  7:44       ` Greg KH
2019-01-07 12:31 ` [PATCH 4.14 003/101] ipv4: Fix potential " Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 004/101] ip6mr: " Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 005/101] ax25: fix a use-after-free in ax25_fillin_cb() Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 006/101] gro_cell: add napi_disable in gro_cells_destroy Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 007/101] ibmveth: fix DMA unmap error in ibmveth_xmit_start error path Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 008/101] ieee802154: lowpan_header_create check must check daddr Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 009/101] ipv6: explicitly initialize udp6_addr in udp_sock_create6() Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 010/101] ipv6: tunnels: fix two use-after-free Greg Kroah-Hartman
2019-01-07 12:31 ` [PATCH 4.14 011/101] isdn: fix kernel-infoleak in capi_unlocked_ioctl Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 012/101] net: ipv4: do not handle duplicate fragments as overlapping Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 013/101] net: macb: restart tx after tx used bit read Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 014/101] net: phy: Fix the issue that netif always links up after resuming Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 015/101] netrom: fix locking in nr_find_socket() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 016/101] net/wan: fix a double free in x25_asy_open_tty() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 017/101] packet: validate address length Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 018/101] packet: validate address length if non-zero Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 019/101] ptr_ring: wrap back ->producer in __ptr_ring_swap_queue() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 020/101] qmi_wwan: Added support for Telit LN940 series Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 021/101] sctp: initialize sin6_flowinfo for ipv6 addrs in sctp_inet6addr_event Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 022/101] tcp: fix a race in inet_diag_dump_icsk() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 023/101] tipc: fix a double kfree_skb() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 024/101] vhost: make sure used idx is seen before log in vhost_add_used_n() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 025/101] VSOCK: Send reset control packet when socket is partially bound Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 026/101] xen/netfront: tolerate frags with no data Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 027/101] net/mlx5: Typo fix in del_sw_hw_rule Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 028/101] net/mlx5e: RX, Fix wrong early return in receive queue poll Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 029/101] mlxsw: core: Increase timeout during firmware flash process Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 030/101] net/mlx5e: Remove the false indication of software timestamping support Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 031/101] tipc: use lock_sock() in tipc_sk_reinit() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 032/101] tipc: compare remote and local protocols in tipc_udp_enable() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 033/101] qmi_wwan: Added support for Fibocom NL668 series Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 034/101] qmi_wwan: Add support for Fibocom NL678 series Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 035/101] net/smc: fix TCP fallback socket release Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 036/101] sock: Make sock->sk_stamp thread-safe Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 037/101] IB/hfi1: Incorrect sizing of sge for PIO will OOPs Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 038/101] ALSA: rme9652: Fix potential Spectre v1 vulnerability Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 039/101] ALSA: emu10k1: Fix potential Spectre v1 vulnerabilities Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 040/101] ALSA: pcm: Fix potential Spectre v1 vulnerability Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 041/101] ALSA: emux: Fix potential Spectre v1 vulnerabilities Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 042/101] mtd: atmel-quadspi: disallow building on ebsa110 Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 043/101] ALSA: hda: add mute LED support for HP EliteBook 840 G4 Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 044/101] ALSA: fireface: fix for state to fetch PCM frames Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 045/101] ALSA: firewire-lib: fix wrong handling payload_length as payload_quadlet Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 046/101] ALSA: firewire-lib: fix wrong assignment for out_packet_without_header tracepoint Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 047/101] ALSA: firewire-lib: use the same print format for without_header tracepoints Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 048/101] ALSA: hda/tegra: clear pending irq handlers Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 049/101] USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 050/101] USB: serial: option: add Fibocom NL678 series Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 051/101] usb: r8a66597: Fix a possible concurrency use-after-free bug in r8a66597_endpoint_disable() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 052/101] staging: wilc1000: fix missing read_write setting when reading data Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 053/101] qmi_wwan: apply SET_DTR quirk to the SIMCOM shared device ID Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 054/101] s390/pci: fix sleeping in atomic during hotplug Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 055/101] Input: elan_i2c - add ACPI ID for touchpad in ASUS Aspire F5-573G Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 056/101] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 057/101] x86/mm: Drop usage of __flush_tlb_all() in kernel_physical_mapping_init() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 058/101] KVM: x86: Use jmp to invoke kvm_spurious_fault() from .fixup Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 059/101] KVM: nVMX: Free the VMREAD/VMWRITE bitmaps if alloc_kvm_area() fails Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 060/101] platform-msi: Free descriptors in platform_msi_domain_free() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 061/101] perf pmu: Suppress potential format-truncation warning Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 062/101] ext4: add ext4_sb_bread() to disambiguate ENOMEM cases Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 063/101] ext4: fix possible use after free in ext4_quota_enable Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 064/101] ext4: missing unlock/put_page() in ext4_try_to_write_inline_data() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 065/101] ext4: fix EXT4_IOC_GROUP_ADD ioctl Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 066/101] ext4: include terminating u32 in size of xattr entries when expanding inodes Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 067/101] ext4: force inode writes when nfsd calls commit_metadata() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 068/101] ext4: check for shutdown and r/o file system in ext4_write_inode() Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 069/101] spi: bcm2835: Fix race on DMA termination Greg Kroah-Hartman
2019-01-07 21:15   ` Sudip Mukherjee
2019-01-08  7:37     ` Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 070/101] spi: bcm2835: Fix book-keeping of " Greg Kroah-Hartman
2019-01-07 12:32 ` [PATCH 4.14 071/101] spi: bcm2835: Avoid finishing transfer prematurely in IRQ mode Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 072/101] clk: rockchip: fix typo in rk3188 spdif_frac parent Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 073/101] crypto: cavium/nitrox - fix a DMA pool free failure Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 074/101] crypto: testmgr - add AES-CFB tests Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 075/101] cgroup: fix CSS_TASK_ITER_PROCS Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 076/101] cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 077/101] Btrfs: fix fsync of files with multiple hard links in new directories Greg Kroah-Hartman
2019-01-07 12:33 ` Greg Kroah-Hartman [this message]
2019-01-07 12:33 ` [PATCH 4.14 079/101] powerpc/tm: Set MSR[TS] just prior to recheckpoint Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 080/101] netfilter: xt_connlimit: dont store address in the conn nodes Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 081/101] netfilter: nf_conncount: expose connection list interface Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 082/101] netfilter: nf_conncount: Fix garbage collection with zones Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 083/101] netfilter: nf_conncount: fix garbage collection confirm race Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 084/101] netfilter: nf_conncount: dont skip eviction when age is negative Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 085/101] f2fs: fix validation of the block count in sanity_check_raw_super Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 086/101] serial: uartps: Fix interrupt mask issue to handle the RX interrupts properly Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 087/101] media: vivid: free bitmap_cap when updating std/timings/etc Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 088/101] media: v4l2-tpg: array index could become negative Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 089/101] MIPS: math-emu: Write-protect delay slot emulation pages Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 090/101] MIPS: c-r4k: Add r4k_blast_scache_node for Loongson-3 Greg Kroah-Hartman
2019-01-07 21:17   ` Sudip Mukherjee
2019-01-08  7:38     ` Greg Kroah-Hartman
2019-01-08  9:54       ` Sudip Mukherjee
2019-01-08 12:03         ` Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 091/101] MIPS: Ensure pmd_present() returns false after pmd_mknotpresent() Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 092/101] MIPS: Align kernel load address to 64KB Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 093/101] MIPS: Expand MIPS32 ASIDs to 64 bits Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 094/101] MIPS: OCTEON: mark RGMII interface disabled on OCTEON III Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 095/101] CIFS: Fix error mapping for SMB2_LOCK command which caused OFD lock problem Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 096/101] arm64: KVM: Avoid setting the upper 32 bits of VTCR_EL2 to 1 Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 097/101] arm/arm64: KVM: vgic: Force VM halt when changing the active state of GICv3 PPIs/SGIs Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 098/101] rtc: m41t80: Correct alarm month range with RTC reads Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 099/101] tpm: tpm_try_transmit() refactor error flow Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 100/101] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Greg Kroah-Hartman
2019-01-07 12:33 ` [PATCH 4.14 101/101] ARM: dts: exynos: Specify I2S assigned clocks in proper node Greg Kroah-Hartman
2019-01-07 14:39 ` [PATCH 4.14 000/101] 4.14.92-stable review Daniel Díaz
2019-01-07 14:47   ` Greg Kroah-Hartman
2019-01-07 14:51     ` Greg Kroah-Hartman
2019-01-07 14:52 ` Greg Kroah-Hartman
2019-01-08  9:20   ` Naresh Kamboju
2019-01-07 22:34 ` shuah
2019-01-07 22:38   ` shuah
2019-01-08  4:59 ` Guenter Roeck
2019-01-08 12:25   ` Greg Kroah-Hartman
2019-01-09 11:40     ` Jinpu Wang
2019-01-09 14:46       ` Greg Kroah-Hartman
2019-01-09 15:47         ` Guenter Roeck
2019-01-08 12:19 ` Greg Kroah-Hartman
2019-01-09 10:47   ` Jon Hunter
2019-01-09 14:40     ` Greg Kroah-Hartman
2019-01-08 23:05 ` Guenter Roeck

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=20190107105337.242080339@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dsterba@suse.com \
    --cc=fdmanana@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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).