Home Home > GIT Browse > SLE12-SP3-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlaf Hering <ohering@suse.de>2019-05-21 15:07:19 +0200
committerOlaf Hering <ohering@suse.de>2019-05-21 15:07:19 +0200
commit5bf998f2f3052d2f5c0393538e5b3f7ec230630a (patch)
tree283f14f3499ef708a71776259af50470842b3cad
parent10cda424285ec635106806860ec2ccaf3e5c298e (diff)
parent71a9773b4506bf012a1836eaec680820b1395e26 (diff)
Merge remote-tracking branch 'kerncvs/SLE12-SP3' into SLE12-SP3-AZURESLE12-SP3-AZURE
-rw-r--r--blacklist.conf2
-rw-r--r--patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch2
-rw-r--r--patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch2
-rw-r--r--patches.arch/locking-static_keys-provide-declare-and-well-as-define-macros.patch2
-rw-r--r--patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch2
-rw-r--r--patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch2
-rw-r--r--patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch2
-rw-r--r--patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch2
-rw-r--r--patches.arch/x86-msr-index-cleanup-bit-defines.patch2
-rw-r--r--patches.arch/x86-speculation-consolidate-cpu-whitelists.patch2
-rw-r--r--patches.arch/x86-speculation-enable-cross-hyperthread-spectre-v2-stibp-mitigation.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-bug_msbds_only.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-smt-warning-message.patch2
-rw-r--r--patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch2
-rw-r--r--patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch2
-rw-r--r--patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch2
-rw-r--r--patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch2
-rw-r--r--patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch2
-rw-r--r--patches.arch/x86-speculation-rework-smt-state-change.patch2
-rw-r--r--patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch2
-rw-r--r--patches.arch/x86-stop-exporting-msr-index-h-to-userland.patch2
-rw-r--r--patches.fixes/0001-PCI-Mark-Atheros-AR9462-to-avoid-bus-reset.patch37
-rw-r--r--patches.fixes/0001-backlight-lm3630a-Return-0-on-success-in-update_stat.patch49
-rw-r--r--patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch72
-rw-r--r--patches.fixes/0001-clk-fix-mux-clock-documentation.patch41
-rw-r--r--patches.fixes/0001-cpupower-remove-stringop-truncation-waring.patch48
-rw-r--r--patches.fixes/0001-dt-bindings-rcar-dmac-Document-missing-error-interru.patch44
-rw-r--r--patches.fixes/0001-kconfig-display-recursive-dependency-resolution-hint.patch68
-rw-r--r--patches.fixes/0001-keys-Timestamp-new-keys.patch28
-rw-r--r--patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch61
-rw-r--r--patches.fixes/0001-tools-lib-traceevent-Fix-missing-equality-check-for-.patch60
-rw-r--r--patches.fixes/0002-drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch72
-rw-r--r--patches.fixes/0003-drm-bridge-adv7511-Fix-low-refresh-rate-selection.patch45
-rw-r--r--patches.kernel.org/4.4.99-010-tun-call-dev_get_valid_name-before-register_ne.patch2
-rw-r--r--patches.kernel.org/4.4.99-016-tun-allow-positive-return-values-on-dev_get_va.patch2
-rw-r--r--patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch187
-rw-r--r--patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch82
-rw-r--r--patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch205
-rw-r--r--patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch127
-rw-r--r--patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch72
-rw-r--r--patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch370
-rw-r--r--patches.suse/0008-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_fr.patch258
-rw-r--r--patches.suse/0009-btrfs-qgroup-Don-t-scan-leaf-if-we-re-modifying-relo.patch67
-rw-r--r--series.conf20
50 files changed, 2043 insertions, 28 deletions
diff --git a/blacklist.conf b/blacklist.conf
index 201a8afbe5..8766bb1cc8 100644
--- a/blacklist.conf
+++ b/blacklist.conf
@@ -653,3 +653,5 @@ c15562c0dcb2c7f26e891923b784cf1926b8c833 # we don't provide libusbip from here
b68f3cc7d978943fcf85148165b00594c38db776 # We're not building 32bit x86 kernels from this branch
bd99f9a159b072be743c6681f81e06b9ebd370a4 # not needed for bsc#1126040 backport
250854eed5d45a73d81e4137dfd85180af6f2ec3 # falsely attributed
+f741494363c6c90e6744117d2771bbdf0fb3c455 # our backport of 287980e49ffc0f6d911601e7e352a812ed27768e is only partial, kernel not affected
+579bebe5dd522580019e7b10b07daaf500f9fb1e # kAPI change
diff --git a/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch b/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
index 19579911aa..f0d3ab6d6a 100644
--- a/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
+++ b/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
@@ -3,7 +3,7 @@ Date: Wed, 5 Dec 2018 17:19:56 -0200
Subject: kvm: x86: Report STIBP on GET_SUPPORTED_CPUID
Git-commit: d7b09c827a6cf291f66637a36f46928dd1423184
Patch-mainline: v5.0-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Months ago, we have added code to allow direct access to MSR_IA32_SPEC_CTRL
to the guest, which makes STIBP available to guests. This was implemented
diff --git a/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch b/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
index e431bdf60d..cec803db31 100644
--- a/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
+++ b/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
@@ -4,7 +4,7 @@ Subject: locking/atomics, asm-generic: Move some macros from <linux/bitops.h>
to a new <linux/bits.h> file
Git-commit: 8bd9cb51daac89337295b6f037b0486911e1b408
Patch-mainline: v4.19-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
In preparation for implementing the asm-generic atomic bitops in terms
of atomic_long_*(), we need to prevent <asm/atomic.h> implementations from
diff --git a/patches.arch/locking-static_keys-provide-declare-and-well-as-define-macros.patch b/patches.arch/locking-static_keys-provide-declare-and-well-as-define-macros.patch
index 2c9148245a..642a89eefb 100644
--- a/patches.arch/locking-static_keys-provide-declare-and-well-as-define-macros.patch
+++ b/patches.arch/locking-static_keys-provide-declare-and-well-as-define-macros.patch
@@ -3,7 +3,7 @@ Date: Thu, 1 Sep 2016 11:39:33 -0700
Subject: locking/static_keys: Provide DECLARE and well as DEFINE macros
Git-commit: b8fb03785d4de097507d0cf45873525e0ac4d2b2
Patch-mainline: v4.9-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
We will need to provide declarations of static keys in header
files. Provide DECLARE_STATIC_KEY_{TRUE,FALSE} macros.
diff --git a/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch b/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
index 347287039e..a93b2ab89a 100644
--- a/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
+++ b/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
@@ -3,7 +3,7 @@ Date: Fri, 1 Jun 2018 10:59:19 -0400
Subject: x86/bugs: Add AMD's variant of SSB_NO
Git-commit: 24809860012e0130fbafe536709e08a22b3e959e
Patch-mainline: v4.18-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
The AMD document outlining the SSBD handling
124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
diff --git a/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch b/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
index 65434c22c3..f39119a4e5 100644
--- a/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
+++ b/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
@@ -3,7 +3,7 @@ Date: Tue, 7 Aug 2018 10:17:27 -0700
Subject: x86/cpu: Sanitize FAM6_ATOM naming
Git-commit: f2c4db1bd80720cd8cb2a5aa220d9bc9f374f04e
Patch-mainline: v5.1-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
commit f2c4db1bd80720cd8cb2a5aa220d9bc9f374f04e upstream
diff --git a/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch b/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
index f9834feff3..30e0210324 100644
--- a/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
+++ b/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
@@ -3,7 +3,7 @@ Date: Fri, 18 Jan 2019 16:50:23 -0800
Subject: x86/kvm: Expose X86_FEATURE_MD_CLEAR to guests
Git-commit: 6c4dbbd14730c43f4ed808a9c42ca41625925c22
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
X86_FEATURE_MD_CLEAR is a new CPUID bit which is set when microcode
provides the mechanism to invoke a flush of various exploitable CPU buffers
diff --git a/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch b/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
index 1c122d5c34..9704f0aeb3 100644
--- a/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
+++ b/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
@@ -3,7 +3,7 @@ Date: Wed, 27 Feb 2019 12:48:14 +0100
Subject: x86/kvm/vmx: Add MDS protection when L1D Flush is not active
Git-commit: 650b68a0622f933444a6d66936abb3103029413b
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
CPUs which are affected by L1TF and MDS mitigate MDS with the L1D Flush on
VMENTER when updated microcode is installed.
diff --git a/patches.arch/x86-msr-index-cleanup-bit-defines.patch b/patches.arch/x86-msr-index-cleanup-bit-defines.patch
index 0230508def..6a75436ce5 100644
--- a/patches.arch/x86-msr-index-cleanup-bit-defines.patch
+++ b/patches.arch/x86-msr-index-cleanup-bit-defines.patch
@@ -3,7 +3,7 @@ Date: Thu, 21 Feb 2019 12:36:50 +0100
Subject: x86/msr-index: Cleanup bit defines
Git-commit: d8eabc37310a92df40d07c5a8afc53cebf996716
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Greg pointed out that speculation related bit defines are using (1 << N)
format instead of BIT(N). Aside of that (1 << N) is wrong as it should use
diff --git a/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch b/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
index 8747432b2d..ec5509ebf0 100644
--- a/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
+++ b/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
@@ -3,7 +3,7 @@ Date: Wed, 27 Feb 2019 10:10:23 +0100
Subject: x86/speculation: Consolidate CPU whitelists
Git-commit: 36ad35131adacc29b328b9c8b6277a8bf0d6fd5d
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
The CPU vulnerability whitelists have some overlap and there are more
whitelists coming along.
diff --git a/patches.arch/x86-speculation-enable-cross-hyperthread-spectre-v2-stibp-mitigation.patch b/patches.arch/x86-speculation-enable-cross-hyperthread-spectre-v2-stibp-mitigation.patch
index c2cc78cf8a..012503effe 100644
--- a/patches.arch/x86-speculation-enable-cross-hyperthread-spectre-v2-stibp-mitigation.patch
+++ b/patches.arch/x86-speculation-enable-cross-hyperthread-spectre-v2-stibp-mitigation.patch
@@ -3,7 +3,7 @@ Date: Tue, 25 Sep 2018 14:38:55 +0200
Subject: x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation
Git-commit: 53c613fe6349994f023245519265999eed75957f
Patch-mainline: v4.20-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
STIBP is a feature provided by certain Intel ucodes / CPUs. This feature
(once enabled) prevents cross-hyperthread control of decisions made by
diff --git a/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch b/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
index 5faf4ea22b..e1b36c7e10 100644
--- a/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
+++ b/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
@@ -3,7 +3,7 @@ Date: Fri, 18 Jan 2019 16:50:16 -0800
Subject: x86/speculation/mds: Add basic bug infrastructure for MDS
Git-commit: ed5194c2732c8084af9fd159c146ea92bf137128
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Microarchitectural Data Sampling (MDS), is a class of side channel attacks
on internal buffers in Intel CPUs. The variants are:
diff --git a/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch b/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
index 46951b49f1..4f2ebb3a17 100644
--- a/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
+++ b/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
@@ -3,7 +3,7 @@ Date: Fri, 1 Mar 2019 20:21:08 +0100
Subject: x86/speculation/mds: Add BUG_MSBDS_ONLY
Git-commit: e261f209c3666e842fd645a1e31f001c3a26def9
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
This bug bit is set on CPUs which are only affected by Microarchitectural
Store Buffer Data Sampling (MSBDS) and not by any other MDS variant.
diff --git a/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch b/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
index 7d546ff73f..baa12f47e5 100644
--- a/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
+++ b/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
@@ -3,7 +3,7 @@ Date: Tue, 2 Apr 2019 09:59:33 -0500
Subject: x86/speculation/mds: Add mds=full,nosmt cmdline option
Git-commit: d71eb0ce109a124b0fa714832823b9452f2762cf
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Add the mds=full,nosmt cmdline option. This is like mds=full, but with
SMT disabled if the CPU is vulnerable.
diff --git a/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch b/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
index f33bb44fbd..147c99c173 100644
--- a/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
+++ b/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
@@ -3,7 +3,7 @@ Date: Mon, 18 Feb 2019 23:13:06 +0100
Subject: x86/speculation/mds: Add mds_clear_cpu_buffers()
Git-commit: 6a9e529272517755904b7afa639f6db59ddb793e
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
The Microarchitectural Data Sampling (MDS) vulernabilities are mitigated by
clearing the affected CPU buffers. The mechanism for clearing the buffers
diff --git a/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch b/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
index 5d8c1e417b..5b0f4b088c 100644
--- a/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
+++ b/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
@@ -3,7 +3,7 @@ Date: Mon, 18 Feb 2019 22:04:08 +0100
Subject: x86/speculation/mds: Add mitigation control for MDS
Git-commit: bc1241700acd82ec69fde98c5763ce51086269f8
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Now that the mitigations are in place, add a command line parameter to
control the mitigation, a mitigation selector function and a SMT update
diff --git a/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch b/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
index e49ee553f8..55c7c53b20 100644
--- a/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
+++ b/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
@@ -3,7 +3,7 @@ Date: Wed, 20 Feb 2019 09:40:40 +0100
Subject: x86/speculation/mds: Add mitigation mode VMWERV
Git-commit: 22dd8365088b6403630b82423cf906491859b65e
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
In virtualized environments it can happen that the host has the microcode
update which utilizes the VERW instruction to clear CPU buffers, but the
diff --git a/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch b/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
index 04f5da2967..f6b39321a6 100644
--- a/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
+++ b/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
@@ -3,7 +3,7 @@ Date: Wed, 17 Apr 2019 16:39:02 -0500
Subject: x86/speculation/mds: Add 'mitigations=' support for MDS
Git-commit: 5c14068f87d04adc73ba3f41c2a303d3c3d1fa12
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Add MDS to the new 'mitigations=' cmdline option.
diff --git a/patches.arch/x86-speculation-mds-add-smt-warning-message.patch b/patches.arch/x86-speculation-mds-add-smt-warning-message.patch
index 16dd7fac43..cfe1090c71 100644
--- a/patches.arch/x86-speculation-mds-add-smt-warning-message.patch
+++ b/patches.arch/x86-speculation-mds-add-smt-warning-message.patch
@@ -3,7 +3,7 @@ Date: Tue, 2 Apr 2019 10:00:51 -0500
Subject: x86/speculation/mds: Add SMT warning message
Git-commit: 39226ef02bfb43248b7db12a4fdccb39d95318e3
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
MDS is vulnerable with SMT. Make that clear with a one-time printk
whenever SMT first gets enabled.
diff --git a/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch b/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
index 853fcf4564..2e0bd0f9ce 100644
--- a/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
+++ b/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
@@ -3,7 +3,7 @@ Date: Mon, 18 Feb 2019 22:51:43 +0100
Subject: x86/speculation/mds: Add sysfs reporting for MDS
Git-commit: 8a4b06d391b0a42a373808979b5028f5c84d9c6a
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Add the sysfs reporting file for MDS. It exposes the vulnerability and
mitigation state similar to the existing files for the other speculative
diff --git a/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch b/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
index 07963f29f3..a9e4d2bd50 100644
--- a/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
+++ b/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
@@ -3,7 +3,7 @@ Date: Mon, 18 Feb 2019 23:42:51 +0100
Subject: x86/speculation/mds: Clear CPU buffers on exit to user
Git-commit: 04dcbdb8057827b043b3c71aa397c4c63e67d086
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Add a static key which controls the invocation of the CPU buffer clear
mechanism on exit to user space and add the call into
diff --git a/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch b/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
index bbb5b23c7c..8909383985 100644
--- a/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
+++ b/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
@@ -3,7 +3,7 @@ Date: Mon, 18 Feb 2019 23:04:01 +0100
Subject: x86/speculation/mds: Conditionally clear CPU buffers on idle entry
Git-commit: 07f07f55a29cb705e221eda7894dd67ab81ef343
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Add a static key which controls the invocation of the CPU buffer clear
mechanism on idle entry. This is independent of other MDS mitigations
diff --git a/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch b/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
index 8ad7e115fb..080d53e2d0 100644
--- a/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
+++ b/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
@@ -3,7 +3,7 @@ Date: Fri, 12 Apr 2019 17:50:58 -0400
Subject: x86/speculation/mds: Print SMT vulnerable on MSBDS with mitigations off
Git-commit: e2c3c94788b08891dcf3dbe608f9880523ecd71b
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
This code is only for CPUs which are affected by MSBDS, but are *not*
affected by the other two MDS issues.
diff --git a/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch b/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
index 6a36aef5d6..2bf15edecd 100644
--- a/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
+++ b/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
@@ -3,7 +3,7 @@ Date: Tue, 2 Apr 2019 10:00:14 -0500
Subject: x86/speculation: Move arch_smt_update() call to after mitigation decisions
Git-commit: 7c3658b20194a5b3209a143f63bc9c643c6a3ae2
Patch-mainline: v5.2-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
arch_smt_update() now has a dependency on both Spectre v2 and MDS
mitigations. Move its initial call to after all the mitigation decisions
diff --git a/patches.arch/x86-speculation-rework-smt-state-change.patch b/patches.arch/x86-speculation-rework-smt-state-change.patch
index 77f965b543..e1c0c521bf 100644
--- a/patches.arch/x86-speculation-rework-smt-state-change.patch
+++ b/patches.arch/x86-speculation-rework-smt-state-change.patch
@@ -3,7 +3,7 @@ Date: Sun, 25 Nov 2018 19:33:39 +0100
Subject: x86/speculation: Rework SMT state change
Git-commit: a74cfffb03b73d41e08f84c2e5c87dec0ce3db9f
Patch-mainline: v4.20-rc5
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
arch_smt_update() is only called when the sysfs SMT control knob is
changed. This means that when SMT is enabled in the sysfs control knob the
diff --git a/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch b/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
index 2ca003db81..1182e16ed4 100644
--- a/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
+++ b/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
@@ -3,7 +3,7 @@ Date: Tue, 22 May 2018 11:05:39 +0200
Subject: x86/speculation: Simplify the CPU bug detection logic
Git-commit: 8ecc4979b1bd9c94168e6fc92960033b7a951336
Patch-mainline: v4.17-rc7
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Only CPUs which speculate can speculate. Therefore, it seems prudent
to test for cpu_no_speculation first and only then determine whether
diff --git a/patches.arch/x86-stop-exporting-msr-index-h-to-userland.patch b/patches.arch/x86-stop-exporting-msr-index-h-to-userland.patch
index c2e6a69e86..fdd1aef21b 100644
--- a/patches.arch/x86-stop-exporting-msr-index-h-to-userland.patch
+++ b/patches.arch/x86-stop-exporting-msr-index-h-to-userland.patch
@@ -3,7 +3,7 @@ Date: Mon, 27 Mar 2017 14:20:08 +0200
Subject: x86: stop exporting msr-index.h to userland
Git-commit: 25dc1d6cc3082aab293e5dad47623b550f7ddd2a
Patch-mainline: v4.12-rc1
-References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091
Even if this file was not in an uapi directory, it was exported because
it was listed in the Kbuild file.
diff --git a/patches.fixes/0001-PCI-Mark-Atheros-AR9462-to-avoid-bus-reset.patch b/patches.fixes/0001-PCI-Mark-Atheros-AR9462-to-avoid-bus-reset.patch
new file mode 100644
index 0000000000..3a75d80983
--- /dev/null
+++ b/patches.fixes/0001-PCI-Mark-Atheros-AR9462-to-avoid-bus-reset.patch
@@ -0,0 +1,37 @@
+From 6afb7e26978da5e86e57e540fdce65c8b04f398a Mon Sep 17 00:00:00 2001
+From: James Prestwood <james.prestwood@linux.intel.com>
+Date: Mon, 7 Jan 2019 13:32:48 -0800
+Subject: [PATCH] PCI: Mark Atheros AR9462 to avoid bus reset
+Git-commit: 6afb7e26978da5e86e57e540fdce65c8b04f398a
+Patch-mainline: v5.2-rc1
+References: bsc#1135642
+
+When using PCI passthrough with this device, the host machine locks up
+completely when starting the VM, requiring a hard reboot. Add a quirk to
+avoid bus resets on this device.
+
+Fixes: c3e59ee4e766 ("PCI: Mark Atheros AR93xx to avoid bus reset")
+Link: https://lore.kernel.org/linux-pci/20190107213248.3034-1-james.prestwood@linux.intel.com
+Signed-off-by: James Prestwood <james.prestwood@linux.intel.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+CC: stable@vger.kernel.org # v3.14+
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+---
+ drivers/pci/quirks.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
+index 68bee35fcafa..9b9e28854a58 100644
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -3408,6 +3408,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0030, quirk_no_bus_reset);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset);
++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset);
+
+ /*
+ * Root port on some Cavium CN8xxx chips do not successfully complete a bus
+--
+2.16.4
+
diff --git a/patches.fixes/0001-backlight-lm3630a-Return-0-on-success-in-update_stat.patch b/patches.fixes/0001-backlight-lm3630a-Return-0-on-success-in-update_stat.patch
new file mode 100644
index 0000000000..35793cc006
--- /dev/null
+++ b/patches.fixes/0001-backlight-lm3630a-Return-0-on-success-in-update_stat.patch
@@ -0,0 +1,49 @@
+From d3f48ec0954c6aac736ab21c34a35d7554409112 Mon Sep 17 00:00:00 2001
+From: Brian Masney <masneyb@onstation.org>
+Date: Wed, 24 Apr 2019 05:25:03 -0400
+Subject: backlight: lm3630a: Return 0 on success in update_status functions
+Git-commit: d3f48ec0954c6aac736ab21c34a35d7554409112
+Patch-mainline: v5.2-rc1
+References: bsc#1106929
+
+lm3630a_bank_a_update_status() and lm3630a_bank_b_update_status()
+both return the brightness value if the brightness was successfully
+updated. Writing to these attributes via sysfs would cause a 'Bad
+address' error to be returned. These functions should return 0 on
+success, so let's change it to correct that error.
+
+Fixes: 28e64a68a2ef ("backlight: lm3630: apply chip revision")
+Signed-off-by: Brian Masney <masneyb@onstation.org>
+Acked-by: Pavel Machek <pavel@ucw.cz>
+Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
+Signed-off-by: Lee Jones <lee.jones@linaro.org>
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/video/backlight/lm3630a_bl.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
+index 2030a6b77a09..ef2553f452ca 100644
+--- a/drivers/video/backlight/lm3630a_bl.c
++++ b/drivers/video/backlight/lm3630a_bl.c
+@@ -201,7 +201,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
+ LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE);
+ if (ret < 0)
+ goto out_i2c_err;
+- return bl->props.brightness;
++ return 0;
+
+ out_i2c_err:
+ dev_err(pchip->dev, "i2c failed to access\n");
+@@ -278,7 +278,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
+ LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE);
+ if (ret < 0)
+ goto out_i2c_err;
+- return bl->props.brightness;
++ return 0;
+
+ out_i2c_err:
+ dev_err(pchip->dev, "i2c failed to access REG_CTRL\n");
+--
+2.21.0
+
diff --git a/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch b/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
new file mode 100644
index 0000000000..7e11b1bc2f
--- /dev/null
+++ b/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
@@ -0,0 +1,72 @@
+From 14ae4ec1ee1466b701e0518f9acbb0bbd8ab0684 Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Fri, 10 May 2019 12:45:05 +0800
+Patch-mainline: Submitted, linux-btrfs
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH] btrfs: extent-tree: Fix a bug that btrfs is unable to add
+ pinned bytes
+
+Commit ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor
+add_pinned_bytes()") refactored add_pinned_bytes(), but during that
+refactor, there are two callers which add the pinned bytes instead
+of subtracting.
+
+That refactor misses those two caller, causing incorrect pinned bytes
+calculation and resulting unexpected ENOSPC error.
+
+Fix it by adding a new parameter @sign to restore the original behavior.
+
+Reported-by: kernel test robot <rong.a.chen@intel.com>
+Fixes: ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor add_pinned_bytes()")
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -756,12 +756,14 @@ static struct btrfs_space_info *__find_s
+ }
+
+ static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
+- struct btrfs_ref *ref)
++ struct btrfs_ref *ref, int sign)
+ {
+ struct btrfs_space_info *space_info;
+- s64 num_bytes = -ref->len;
++ s64 num_bytes;
+ u64 flags;
+
++ ASSERT(sign == 1 || sign == -1);
++ num_bytes = sign * ref->len;
+ if (ref->type == BTRFS_REF_METADATA) {
+ if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
+ flags = BTRFS_BLOCK_GROUP_SYSTEM;
+@@ -2114,7 +2116,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ generic_ref, 0, NULL,
+ &old_ref_mod, &new_ref_mod);
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, generic_ref);
++ add_pinned_bytes(fs_info, generic_ref, -1);
+
+ return ret;
+ }
+@@ -7228,7 +7230,7 @@ void btrfs_free_tree_block(struct btrfs_
+ }
+ out:
+ if (pin)
+- add_pinned_bytes(root->fs_info, &generic_ref);
++ add_pinned_bytes(root->fs_info, &generic_ref, 1);
+
+ if (last_ref) {
+
+@@ -7270,7 +7272,7 @@ int btrfs_free_extent(struct btrfs_trans
+ }
+
+ if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
+- add_pinned_bytes(fs_info, ref);
++ add_pinned_bytes(fs_info, ref, 1);
+
+ return ret;
+ }
diff --git a/patches.fixes/0001-clk-fix-mux-clock-documentation.patch b/patches.fixes/0001-clk-fix-mux-clock-documentation.patch
new file mode 100644
index 0000000000..a1cc3df15c
--- /dev/null
+++ b/patches.fixes/0001-clk-fix-mux-clock-documentation.patch
@@ -0,0 +1,41 @@
+From fe3f338f0cb2ed4d4f06da054c21ae2f8a36ef2d Mon Sep 17 00:00:00 2001
+From: Jerome Brunet <jbrunet@baylibre.com>
+Date: Wed, 14 Feb 2018 14:43:38 +0100
+Subject: [PATCH] clk: fix mux clock documentation
+Git-commit: fe3f338f0cb2ed4d4f06da054c21ae2f8a36ef2d
+Patch-mainline: v4.17
+References: bsc#1090888
+
+The mux documentation mentions the non-existing parameter width instead
+of mask, so just sed this.
+
+The table field is missing in the documentation of clk_mux.
+Add a small blurb explaining what it is
+
+Fixes: 9d9f78ed9af0 ("clk: basic clock hardware types")
+Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
+Signed-off-by: Michael Turquette <mturquette@baylibre.com>
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ include/linux/clk-provider.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
+index fe720d679c31..cb18526d69cb 100644
+--- a/include/linux/clk-provider.h
++++ b/include/linux/clk-provider.h
+@@ -450,8 +450,9 @@ void clk_hw_unregister_divider(struct clk_hw *hw);
+ *
+ * @hw: handle between common and hardware-specific interfaces
+ * @reg: register controlling multiplexer
++ * @table: array of register values corresponding to the parent index
+ * @shift: shift to multiplexer bit field
+- * @width: width of mutliplexer bit field
++ * @mask: mask of mutliplexer bit field
+ * @flags: hardware-specific flags
+ * @lock: register lock
+ *
+--
+2.16.4
+
diff --git a/patches.fixes/0001-cpupower-remove-stringop-truncation-waring.patch b/patches.fixes/0001-cpupower-remove-stringop-truncation-waring.patch
new file mode 100644
index 0000000000..5014e4673a
--- /dev/null
+++ b/patches.fixes/0001-cpupower-remove-stringop-truncation-waring.patch
@@ -0,0 +1,48 @@
+From 8a7e2d2ea080d10a189a1d611344b0330468ebc3 Mon Sep 17 00:00:00 2001
+From: Anders Roxell <anders.roxell@linaro.org>
+Date: Tue, 28 Aug 2018 11:31:18 +0200
+Subject: [PATCH] cpupower: remove stringop-truncation waring
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Git-commit: 8a7e2d2ea080d10a189a1d611344b0330468ebc3
+Patch-mainline: v4.20
+References: bsc#1119086
+
+The strncpy doesn't null terminate the string because the size is too
+short by one byte.
+
+parse.c: In function ‘prepare_default_config’:
+parse.c:148:2: warning: ‘strncpy’ output truncated before terminating
+ nul copying 8 bytes from a string of the same length
+ [-Wstringop-truncation]
+ strncpy(config->governor, "ondemand", 8);
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The normal method of passing the length of the destination buffer works
+correctly here.
+
+Fixes: 7fe2f6399a84 ("cpupowerutils - cpufrequtils extended with quite some features")
+Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
+Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ tools/power/cpupower/bench/parse.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
+index 9ba8a44ad2a7..84caee38418f 100644
+--- a/tools/power/cpupower/bench/parse.c
++++ b/tools/power/cpupower/bench/parse.c
+@@ -145,7 +145,7 @@ struct config *prepare_default_config()
+ config->cpu = 0;
+ config->prio = SCHED_HIGH;
+ config->verbose = 0;
+- strncpy(config->governor, "ondemand", 8);
++ strncpy(config->governor, "ondemand", sizeof(config->governor));
+
+ config->output = stdout;
+
+--
+2.16.4
+
diff --git a/patches.fixes/0001-dt-bindings-rcar-dmac-Document-missing-error-interru.patch b/patches.fixes/0001-dt-bindings-rcar-dmac-Document-missing-error-interru.patch
new file mode 100644
index 0000000000..c9bff70b76
--- /dev/null
+++ b/patches.fixes/0001-dt-bindings-rcar-dmac-Document-missing-error-interru.patch
@@ -0,0 +1,44 @@
+From 5466c34f8425ccd24124ebdae6e3b6552195956d Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+Date: Fri, 19 May 2017 09:27:47 +0200
+Subject: [PATCH] dt-bindings: rcar-dmac: Document missing error interrupt
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Git-commit: 5466c34f8425ccd24124ebdae6e3b6552195956d
+Patch-mainline: v4.13
+References: bsc#1085535
+
+The documentation for the "interrupt-names" property only mentions the
+per-channel interrupts, while the error interrupt has always been
+mandatory, too.
+
+Fixes: 10f5c8438475909a ("dmaengine: rcar-dmac: Add device tree bindings
+documentation")
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+Signed-off-by: Vinod Koul <vinod.koul@intel.com>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
+index 3316a9c2e638..79a204d50234 100644
+--- a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
++++ b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
+@@ -30,8 +30,9 @@ Required Properties:
+
+ - interrupts: interrupt specifiers for the DMAC, one for each entry in
+ interrupt-names.
+-- interrupt-names: one entry per channel, named "ch%u", where %u is the
+- channel number ranging from zero to the number of channels minus one.
++- interrupt-names: one entry for the error interrupt, named "error", plus one
++ entry per channel, named "ch%u", where %u is the channel number ranging from
++ zero to the number of channels minus one.
+
+ - clock-names: "fck" for the functional clock
+ - clocks: a list of phandle + clock-specifier pairs, one for each entry
+--
+2.16.4
+
diff --git a/patches.fixes/0001-kconfig-display-recursive-dependency-resolution-hint.patch b/patches.fixes/0001-kconfig-display-recursive-dependency-resolution-hint.patch
new file mode 100644
index 0000000000..432820cfe5
--- /dev/null
+++ b/patches.fixes/0001-kconfig-display-recursive-dependency-resolution-hint.patch
@@ -0,0 +1,68 @@
+From e3b03bf29d6b99fab7001fb20c33fe54928c157a Mon Sep 17 00:00:00 2001
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Sat, 16 Dec 2017 00:28:42 +0900
+Subject: [PATCH] kconfig: display recursive dependency resolution hint just
+ once
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Git-commit: e3b03bf29d6b99fab7001fb20c33fe54928c157a
+Patch-mainline: v4.18
+References: bsc#1100132
+
+Commit 1c199f2878f6 ("kbuild: document recursive dependency limitation
+/ resolution") probably intended to show a hint along with "recursive
+dependency detected!" error, but it missed to add {...} guard, and the
+hint is displayed in every loop of the dep_stack traverse, annoyingly.
+
+This error was detected by GCC's -Wmisleading-indentation when switching
+to build-time generation of lexer/parser.
+
+scripts/kconfig/symbol.c: In function ‘sym_check_print_recursive’:
+scripts/kconfig/symbol.c:1150:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
+ if (stack->sym == last_sym)
+ ^~
+scripts/kconfig/symbol.c:1153:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
+ fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
+ ^~~~~~~
+
+I could simply add {...} to surround the three fprintf(), but I rather
+chose to move the hint after the loop to make the whole message readable.
+
+Fixes: 1c199f2878f6 ("kbuild: document recursive dependency limitation / resolution"
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ scripts/kconfig/symbol.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
+index 3c8bd9bb4267..35e0937aa6a6 100644
+--- a/scripts/kconfig/symbol.c
++++ b/scripts/kconfig/symbol.c
+@@ -1150,8 +1150,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
+ if (stack->sym == last_sym)
+ fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
+ prop->file->name, prop->lineno);
+- fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
+- fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n");
++
+ if (stack->expr) {
+ fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
+ prop->file->name, prop->lineno,
+@@ -1181,6 +1180,11 @@ static void sym_check_print_recursive(struct symbol *last_sym)
+ }
+ }
+
++ fprintf(stderr,
++ "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
++ "subsection \"Kconfig recursive dependency limitations\"\n"
++ "\n");
++
+ if (check_top == &cv_stack)
+ dep_stack_remove();
+ }
+--
+2.16.4
+
diff --git a/patches.fixes/0001-keys-Timestamp-new-keys.patch b/patches.fixes/0001-keys-Timestamp-new-keys.patch
new file mode 100644
index 0000000000..8eceed12e9
--- /dev/null
+++ b/patches.fixes/0001-keys-Timestamp-new-keys.patch
@@ -0,0 +1,28 @@
+From 7c1857bdbdf1e4c541e45eab477ee23ed4333ea4 Mon Sep 17 00:00:00 2001
+From: David Howells <dhowells@redhat.com>
+Date: Thu, 14 Feb 2019 16:20:37 +0000
+Subject: [PATCH] keys: Timestamp new keys
+Git-commit: 7c1857bdbdf1e4c541e45eab477ee23ed4333ea4
+Patch-mainline: v5.0
+References: bsc#1120902
+
+Set the timestamp on new keys rather than leaving it unset.
+
+Fixes: 31d5a79d7f3d ("KEYS: Do LRU discard in full keyrings")
+Signed-off-by: David Howells <dhowells@redhat.com>
+Signed-off-by: James Morris <james.morris@microsoft.com>
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+---
+ security/keys/key.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/security/keys/key.c
++++ b/security/keys/key.c
+@@ -291,6 +291,7 @@ struct key *key_alloc(struct key_type *t
+ key->uid = uid;
+ key->gid = gid;
+ key->perm = perm;
++ key->last_used_at = ktime_get_real_seconds();
+
+ if (!(flags & KEY_ALLOC_NOT_IN_QUOTA))
+ key->flags |= 1 << KEY_FLAG_IN_QUOTA;
diff --git a/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch b/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
new file mode 100644
index 0000000000..5c60aa313c
--- /dev/null
+++ b/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
@@ -0,0 +1,61 @@
+From c1ced46c7b49ad7bc064e68d966e0ad303f917fb Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Mon, 8 Apr 2019 05:52:38 -0400
+Subject: [PATCH] media: pvrusb2: Prevent a buffer overflow
+Git-commit: c1ced46c7b49ad7bc064e68d966e0ad303f917fb
+Patch-mainline: v5.2-rc1
+References: bsc#1135642
+
+The ctrl_check_input() function is called from pvr2_ctrl_range_check().
+It's supposed to validate user supplied input and return true or false
+depending on whether the input is valid or not. The problem is that
+negative shifts or shifts greater than 31 are undefined in C. In
+practice with GCC they result in shift wrapping so this function returns
+true for some inputs which are not valid and this could result in a
+buffer overflow:
+
+ drivers/media/usb/pvrusb2/pvrusb2-ctrl.c:205 pvr2_ctrl_get_valname()
+ warn: uncapped user index 'names[val]'
+
+The cptr->hdw->input_allowed_mask mask is configured in pvr2_hdw_create()
+and the highest valid bit is BIT(4).
+
+Fixes: 7fb20fa38caa ("V4L/DVB (7299): pvrusb2: Improve logic which handles input choice availability")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+---
+ drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 2 ++
+ drivers/media/usb/pvrusb2/pvrusb2-hdw.h | 1 +
+ 2 files changed, 3 insertions(+)
+
+diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+index 51112b7988e4..816c85786c2a 100644
+--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+@@ -666,6 +666,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
+
+ static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
+ {
++ if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
++ return 0;
+ return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
+ }
+
+diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+index 25648add77e5..bd2b7a67b732 100644
+--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+@@ -50,6 +50,7 @@
+ #define PVR2_CVAL_INPUT_COMPOSITE 2
+ #define PVR2_CVAL_INPUT_SVIDEO 3
+ #define PVR2_CVAL_INPUT_RADIO 4
++#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
+
+ enum pvr2_config {
+ pvr2_config_empty, /* No configuration */
+--
+2.16.4
+
diff --git a/patches.fixes/0001-tools-lib-traceevent-Fix-missing-equality-check-for-.patch b/patches.fixes/0001-tools-lib-traceevent-Fix-missing-equality-check-for-.patch
new file mode 100644
index 0000000000..9cbd9afd6c
--- /dev/null
+++ b/patches.fixes/0001-tools-lib-traceevent-Fix-missing-equality-check-for-.patch
@@ -0,0 +1,60 @@
+From f32c2877bcb068a718bb70094cd59ccc29d4d082 Mon Sep 17 00:00:00 2001
+From: Rikard Falkeborn <rikard.falkeborn@gmail.com>
+Date: Tue, 9 Apr 2019 11:15:29 +0200
+Subject: [PATCH] tools lib traceevent: Fix missing equality check for strcmp
+Git-commit: f32c2877bcb068a718bb70094cd59ccc29d4d082
+Patch-mainline: v5.1
+References: bsc#1129770
+
+There was a missing comparison with 0 when checking if type is "s64" or
+"u64". Therefore, the body of the if-statement was entered if "type" was
+"u64" or not "s64", which made the first strcmp() redundant since if
+type is "u64", it's not "s64".
+
+If type is "s64", the body of the if-statement is not entered but since
+the remainder of the function consists of if-statements which will not
+be entered if type is "s64", we will just return "val", which is
+correct, albeit at the cost of a few more calls to strcmp(), i.e., it
+will behave just as if the if-statement was entered.
+
+If type is neither "s64" or "u64", the body of the if-statement will be
+entered incorrectly and "val" returned. This means that any type that is
+checked after "s64" and "u64" is handled the same way as "s64" and
+"u64", i.e., the limiting of "val" to fit in for example "s8" is never
+reached.
+
+This was introduced in the kernel tree when the sources were copied from
+trace-cmd in commit f7d82350e597 ("tools/events: Add files to create
+libtraceevent.a"), and in the trace-cmd repo in 1cdbae6035cei
+("Implement typecasting in parser") when the function was introduced,
+i.e., it has always behaved the wrong way.
+
+Detected by cppcheck.
+
+Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
+Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
+Fixes: f7d82350e597 ("tools/events: Add files to create libtraceevent.a")
+Link: http://lkml.kernel.org/r/20190409091529.2686-1-rikard.falkeborn@gmail.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ tools/lib/traceevent/event-parse.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
+index 87494c7c619d..981c6ce2da2c 100644
+--- a/tools/lib/traceevent/event-parse.c
++++ b/tools/lib/traceevent/event-parse.c
+@@ -2233,7 +2233,7 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
+ return val & 0xffffffff;
+
+ if (strcmp(type, "u64") == 0 ||
+- strcmp(type, "s64"))
++ strcmp(type, "s64") == 0)
+ return val;
+
+ if (strcmp(type, "s8") == 0)
+--
+2.16.4
+
diff --git a/patches.fixes/0002-drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch b/patches.fixes/0002-drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
new file mode 100644
index 0000000000..634671be21
--- /dev/null
+++ b/patches.fixes/0002-drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
@@ -0,0 +1,72 @@
+From b8f9d7f37b6af829c34c49d1a4f73ce6ed58e403 Mon Sep 17 00:00:00 2001
+From: Vicente Bergas <vicencb@gmail.com>
+Date: Tue, 2 Apr 2019 13:37:53 +0200
+Subject: drm/rockchip: shutdown drm subsystem on shutdown
+Git-commit: b8f9d7f37b6af829c34c49d1a4f73ce6ed58e403
+Patch-mainline: v5.2-rc1
+References: bsc#1106929
+
+As explained by Robin Murphy:
+> the IOMMU shutdown disables paging, so if the VOP is still
+> scanning out then that will result in whatever IOVAs it was using now going
+> straight out onto the bus as physical addresses.
+
+We had a more radical approach before in commit
+7f3ef5dedb14 ("drm/rockchip: Allow driver to be shutdown on reboot/kexec")
+but that resulted in new warnings and oopses on shutdown on rk3399
+chromeos devices.
+
+So second try is resurrecting Vicentes shutdown change which should
+achieve the same result but in a less drastic way.
+
+Fixes: 63238173b2fa ("Revert "drm/rockchip: Allow driver to be shutdown on reboot/kexec"")
+Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
+Cc: Robin Murphy <robin.murphy@arm.com>
+Cc: Marc Zyngier <marc.zyngier@arm.com>
+Cc: Brian Norris <briannorris@chromium.org>
+Cc: Doug Anderson <dianders@chromium.org>
+Cc: stable@vger.kernel.org
+Suggested-by: JeffyChen <jeffy.chen@rock-chips.com>
+Suggested-by: Robin Murphy <robin.murphy@arm.com>
+Signed-off-by: Vicente Bergas <vicencb@gmail.com>
+[adapted commit message to explain the history]
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Tested-by: Brian Norris <briannorris@chromium.org>
+Tested-by: Douglas Anderson <dianders@chromium.org>
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190402113753.10118-1-heiko@sntech.de
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+index 8d7a634c12c2..cb938d3cd3c2 100644
+--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
++++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+@@ -448,6 +448,14 @@ static int rockchip_drm_platform_remove(struct platform_device *pdev)
+ return 0;
+ }
+
++static void rockchip_drm_platform_shutdown(struct platform_device *pdev)
++{
++ struct drm_device *drm = platform_get_drvdata(pdev);
++
++ if (drm)
++ drm_atomic_helper_shutdown(drm);
++}
++
+ static const struct of_device_id rockchip_drm_dt_ids[] = {
+ { .compatible = "rockchip,display-subsystem", },
+ { /* sentinel */ },
+@@ -457,6 +465,7 @@ MODULE_DEVICE_TABLE(of, rockchip_drm_dt_ids);
+ static struct platform_driver rockchip_drm_platform_driver = {
+ .probe = rockchip_drm_platform_probe,
+ .remove = rockchip_drm_platform_remove,
++ .shutdown = rockchip_drm_platform_shutdown,
+ .driver = {
+ .name = "rockchip-drm",
+ .of_match_table = rockchip_drm_dt_ids,
+--
+2.21.0
+
diff --git a/patches.fixes/0003-drm-bridge-adv7511-Fix-low-refresh-rate-selection.patch b/patches.fixes/0003-drm-bridge-adv7511-Fix-low-refresh-rate-selection.patch
new file mode 100644
index 0000000000..a432353486
--- /dev/null
+++ b/patches.fixes/0003-drm-bridge-adv7511-Fix-low-refresh-rate-selection.patch
@@ -0,0 +1,45 @@
+From 67793bd3b3948dc8c8384b6430e036a30a0ecb43 Mon Sep 17 00:00:00 2001
+From: Matt Redfearn <matt.redfearn@thinci.com>
+Date: Wed, 24 Apr 2019 13:22:27 +0000
+Subject: drm/bridge: adv7511: Fix low refresh rate selection
+Git-commit: 67793bd3b3948dc8c8384b6430e036a30a0ecb43
+Patch-mainline: v5.2-rc1
+References: bsc#1106929
+
+The driver currently sets register 0xfb (Low Refresh Rate) based on the
+value of mode->vrefresh. Firstly, this field is specified to be in Hz,
+but the magic numbers used by the code are Hz * 1000. This essentially
+leads to the low refresh rate always being set to 0x01, since the
+vrefresh value will always be less than 24000. Fix the magic numbers to
+be in Hz.
+Secondly, according to the comment in drm_modes.h, the field is not
+supposed to be used in a functional way anyway. Instead, use the helper
+function drm_mode_vrefresh().
+
+Fixes: 9c8af882bf12 ("drm: Add adv7511 encoder driver")
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Matt Redfearn <matt.redfearn@thinci.com>
+Signed-off-by: Sean Paul <seanpaul@chromium.org>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190424132210.26338-1-matt.redfearn@thinci.com
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/i2c/adv7511.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/gpu/drm/i2c/adv7511.c
++++ b/drivers/gpu/drm/i2c/adv7511.c
+@@ -781,11 +781,11 @@ static void adv7511_encoder_mode_set(str
+ vsync_polarity = 1;
+ }
+
+- if (mode->vrefresh <= 24000)
++ if (drm_mode_vrefresh(mode) <= 24)
+ low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
+- else if (mode->vrefresh <= 25000)
++ else if (drm_mode_vrefresh(mode) <= 25)
+ low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
+- else if (mode->vrefresh <= 30000)
++ else if (drm_mode_vrefresh(mode) <= 30)
+ low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
+ else
+ low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;
diff --git a/patches.kernel.org/4.4.99-010-tun-call-dev_get_valid_name-before-register_ne.patch b/patches.kernel.org/4.4.99-010-tun-call-dev_get_valid_name-before-register_ne.patch
index 6e96ee9b26..029d5bd8af 100644
--- a/patches.kernel.org/4.4.99-010-tun-call-dev_get_valid_name-before-register_ne.patch
+++ b/patches.kernel.org/4.4.99-010-tun-call-dev_get_valid_name-before-register_ne.patch
@@ -1,7 +1,7 @@
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri, 13 Oct 2017 11:58:53 -0700
Subject: [PATCH] tun: call dev_get_valid_name() before register_netdevice()
-References: bnc#1012382
+References: bnc#1012382, CVE-2018-7191, bsc#1135603
Patch-mainline: 4.4.99
Git-commit: 0ad646c81b2182f7fa67ec0c8c825e0ee165696d
diff --git a/patches.kernel.org/4.4.99-016-tun-allow-positive-return-values-on-dev_get_va.patch b/patches.kernel.org/4.4.99-016-tun-allow-positive-return-values-on-dev_get_va.patch
index 7b677aa7e9..42977a5ca7 100644
--- a/patches.kernel.org/4.4.99-016-tun-allow-positive-return-values-on-dev_get_va.patch
+++ b/patches.kernel.org/4.4.99-016-tun-allow-positive-return-values-on-dev_get_va.patch
@@ -2,7 +2,7 @@ From: Julien Gomes <julien@arista.com>
Date: Wed, 25 Oct 2017 11:50:50 -0700
Subject: [PATCH] tun: allow positive return values on dev_get_valid_name()
call
-References: bnc#1012382
+References: bnc#1012382, CVE-2018-7191, bsc#1135603
Patch-mainline: 4.4.99
Git-commit: 5c25f65fd1e42685f7ccd80e0621829c105785d9
diff --git a/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch b/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
new file mode 100644
index 0000000000..28d84692fd
--- /dev/null
+++ b/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
@@ -0,0 +1,187 @@
+From b28b1f0ce44c1b9ebc1c43e3eba18c1f1f5d9cec Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Git-commit: b28b1f0ce44c1b9ebc1c43e3eba18c1f1f5d9cec
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Date: Thu, 4 Apr 2019 14:45:29 +0800
+Subject: [PATCH 1/9] btrfs: delayed-ref: Introduce better documented delayed
+ ref structures
+
+Current delayed ref interface has several problems:
+
+- Longer and longer parameter lists
+ bytenr
+ num_bytes
+ parent
+ ---------- so far so good
+ ref_root
+ owner
+ offset
+ ---------- I don't feel good now
+
+- Different interpretation of the same parameter
+
+ Above @owner for data ref is inode number (u64),
+ while for tree ref, it's level (int).
+
+ They are even in different size range.
+ For level we only need 0 ~ 8, while for ino it's
+ BTRFS_FIRST_FREE_OBJECTID ~ BTRFS_LAST_FREE_OBJECTID.
+
+ And @offset doesn't even make sense for tree ref.
+
+ Such parameter reuse may look clever as an hidden union, but it
+ destroys code readability.
+
+To solve both problems, we introduce a new structure, btrfs_ref to solve
+them:
+
+- Structure instead of long parameter list
+ This makes later expansion easier, and is better documented.
+
+- Use btrfs_ref::type to distinguish data and tree ref
+
+- Use proper union to store data/tree ref specific structures.
+
+- Use separate functions to fill data/tree ref data, with a common generic
+ function to fill common bytenr/num_bytes members.
+
+All parameters will find its place in btrfs_ref, and an extra member,
+@real_root, inspired by ref-verify code, is newly introduced for later
+qgroup code, to record which tree is triggered by this extent modification.
+
+This patch doesn't touch any code, but provides the basis for further
+refactoring.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.h | 109 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 109 insertions(+)
+
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -192,6 +192,83 @@ struct btrfs_delayed_ref_root {
+ u64 qgroup_to_skip;
+ };
+
++enum btrfs_ref_type {
++ BTRFS_REF_NOT_SET,
++ BTRFS_REF_DATA,
++ BTRFS_REF_METADATA,
++ BTRFS_REF_LAST,
++};
++
++struct btrfs_data_ref {
++ /* For EXTENT_DATA_REF */
++
++ /* Root which refers to this data extent */
++ u64 ref_root;
++
++ /* Inode which refers to this data extent */
++ u64 ino;
++
++ /*
++ * file_offset - extent_offset
++ *
++ * file_offset is the key.offset of the EXTENT_DATA key.
++ * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
++ */
++ u64 offset;
++};
++
++struct btrfs_tree_ref {
++ /*
++ * Level of this tree block
++ *
++ * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
++ */
++ int level;
++
++ /*
++ * Root which refers to this tree block.
++ *
++ * For TREE_BLOCK_REF (skinny metadata, either inline or keyed)
++ */
++ u64 root;
++
++ /* For non-skinny metadata, no special member needed */
++};
++
++struct btrfs_ref {
++ enum btrfs_ref_type type;
++ int action;
++
++ /*
++ * Whether this extent should go through qgroup record.
++ *
++ * Normally false, but for certain cases like delayed subtree scan,
++ * setting this flag can hugely reduce qgroup overhead.
++ */
++ bool skip_qgroup;
++
++ /*
++ * Optional. For which root is this modification.
++ * Mostly used for qgroup optimization.
++ *
++ * When unset, data/tree ref init code will populate it.
++ * In certain cases, we're modifying reference for a different root.
++ * E.g. COW fs tree blocks for balance.
++ * In that case, tree_ref::root will be fs tree, but we're doing this
++ * for reloc tree, then we should set @real_root to reloc tree.
++ */
++ u64 real_root;
++ u64 bytenr;
++ u64 len;
++
++ /* Bytenr of the parent tree block */
++ u64 parent;
++ union {
++ struct btrfs_data_ref data_ref;
++ struct btrfs_tree_ref tree_ref;
++ };
++};
++
+ extern struct kmem_cache *btrfs_delayed_ref_head_cachep;
+ extern struct kmem_cache *btrfs_delayed_tree_ref_cachep;
+ extern struct kmem_cache *btrfs_delayed_data_ref_cachep;
+@@ -200,6 +277,38 @@ extern struct kmem_cache *btrfs_delayed_
+ int btrfs_delayed_ref_init(void);
+ void btrfs_delayed_ref_exit(void);
+
++static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref,
++ int action, u64 bytenr, u64 len, u64 parent)
++{
++ generic_ref->action = action;
++ generic_ref->bytenr = bytenr;
++ generic_ref->len = len;
++ generic_ref->parent = parent;
++}
++
++static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref,
++ int level, u64 root)
++{
++ /* If @real_root not set, use @root as fallback */
++ if (!generic_ref->real_root)
++ generic_ref->real_root = root;
++ generic_ref->tree_ref.level = level;
++ generic_ref->tree_ref.root = root;
++ generic_ref->type = BTRFS_REF_METADATA;
++}
++
++static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref,
++ u64 ref_root, u64 ino, u64 offset)
++{
++ /* If @real_root not set, use @root as fallback */
++ if (!generic_ref->real_root)
++ generic_ref->real_root = ref_root;
++ generic_ref->data_ref.ref_root = ref_root;
++ generic_ref->data_ref.ino = ino;
++ generic_ref->data_ref.offset = offset;
++ generic_ref->type = BTRFS_REF_DATA;
++}
++
+ static inline struct btrfs_delayed_extent_op *
+ btrfs_alloc_delayed_extent_op(void)
+ {
diff --git a/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch b/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
new file mode 100644
index 0000000000..58694bc648
--- /dev/null
+++ b/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
@@ -0,0 +1,82 @@
+From dd28b6a5aad306c417477db700ed0848c923a31c Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Git-commit: dd28b6a5aad306c417477db700ed0848c923a31c
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Date: Thu, 4 Apr 2019 14:45:30 +0800
+Subject: [PATCH 2/9] btrfs: extent-tree: Open-code process_func in
+ __btrfs_mod_ref
+
+The process_func function pointer is local to __btrfs_mod_ref() and
+points to either btrfs_inc_extent_ref() or btrfs_free_extent().
+
+Open code it to make later delayed ref refactor easier, so we can
+refactor btrfs_inc_extent_ref() and btrfs_free_extent() in different
+patches.
+
+Reviewed-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 29 ++++++++++++++++-------------
+ 1 file changed, 16 insertions(+), 13 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -3246,9 +3246,6 @@ static int __btrfs_mod_ref(struct btrfs_
+ int i;
+ int level;
+ int ret = 0;
+- int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
+- u64, u64, u64, u64, u64, u64);
+-
+
+ if (btrfs_test_is_dummy_root(root))
+ return 0;
+@@ -3260,11 +3257,6 @@ static int __btrfs_mod_ref(struct btrfs_
+ if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) && level == 0)
+ return 0;
+
+- if (inc)
+- process_func = btrfs_inc_extent_ref;
+- else
+- process_func = btrfs_free_extent;
+-
+ if (full_backref)
+ parent = buf->start;
+ else
+@@ -3286,16 +3278,27 @@ static int __btrfs_mod_ref(struct btrfs_
+
+ num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
+ key.offset -= btrfs_file_extent_offset(buf, fi);
+- ret = process_func(trans, root, bytenr, num_bytes,
+- parent, ref_root, key.objectid,
+- key.offset);
++ if (inc)
++ ret = btrfs_inc_extent_ref(trans, root, bytenr,
++ num_bytes, parent, ref_root,
++ key.objectid, key.offset);
++ else
++ ret = btrfs_free_extent(trans, root, bytenr,
++ num_bytes, parent, ref_root,
++ key.objectid, key.offset);
+ if (ret)
+ goto fail;
+ } else {
+ bytenr = btrfs_node_blockptr(buf, i);
+ num_bytes = root->nodesize;
+- ret = process_func(trans, root, bytenr, num_bytes,
+- parent, ref_root, level - 1, 0);
++ if (inc)
++ ret = btrfs_inc_extent_ref(trans, root, bytenr,
++ num_bytes, parent, ref_root,
++ level - 1, 0);
++ else
++ ret = btrfs_free_extent(trans, root, bytenr,
++ num_bytes, parent, ref_root,
++ level - 1, 0);
+ if (ret)
+ goto fail;
+ }
diff --git a/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch b/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
new file mode 100644
index 0000000000..dda9e67942
--- /dev/null
+++ b/patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
@@ -0,0 +1,205 @@
+From ed4f255b9bacb774c99ded17647f138c3f61546d Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:31 +0800
+Git-commit: ed4f255b9bacb774c99ded17647f138c3f61546d
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 3/9] btrfs: delayed-ref: Use btrfs_ref to refactor
+ btrfs_add_delayed_tree_ref()
+
+btrfs_add_delayed_tree_ref() has a longer and longer parameter list, and
+some callers like btrfs_inc_extent_ref() are using @owner as level for
+delayed tree ref.
+
+Instead of making the parameter list longer, use btrfs_ref to refactor
+it, so each parameter assignment should be self-explaining without dirty
+level/owner trick, and provides the basis for later refactoring.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 24 +++++++++++++++++-------
+ fs/btrfs/delayed-ref.h | 3 +--
+ fs/btrfs/extent-tree.c | 42 +++++++++++++++++++++++++++---------------
+ 3 files changed, 45 insertions(+), 24 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -720,8 +720,7 @@ static void init_delayed_ref_common(stru
+ */
+ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 ref_root, int level, int action,
++ struct btrfs_ref *generic_ref,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod)
+ {
+@@ -729,10 +728,18 @@ int btrfs_add_delayed_tree_ref(struct bt
+ struct btrfs_delayed_ref_head *head_ref;
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_qgroup_extent_record *record = NULL;
+- bool is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
++ bool is_system;
++ int action = generic_ref->action;
++ int level = generic_ref->tree_ref.level;
+ int ret;
++ u64 bytenr = generic_ref->bytenr;
++ u64 num_bytes = generic_ref->len;
++ u64 parent = generic_ref->parent;
+ u8 ref_type;
+
++ is_system = (generic_ref->real_root == BTRFS_CHUNK_TREE_OBJECTID);
++
++ ASSERT(generic_ref->type == BTRFS_REF_METADATA && generic_ref->action);
+ BUG_ON(extent_op && extent_op->is_data);
+ ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
+ if (!ref)
+@@ -743,8 +750,8 @@ int btrfs_add_delayed_tree_ref(struct bt
+ else
+ ref_type = BTRFS_TREE_BLOCK_REF_KEY;
+ init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes,
+- ref_root, action, ref_type);
+- ref->root = ref_root;
++ generic_ref->tree_ref.root, action, ref_type);
++ ref->root = generic_ref->tree_ref.root;
+ ref->parent = parent;
+ ref->level = level;
+
+@@ -753,14 +760,17 @@ int btrfs_add_delayed_tree_ref(struct bt
+ goto free_ref;
+
+ if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
+- is_fstree(ref_root)) {
++ is_fstree(generic_ref->real_root) &&
++ is_fstree(generic_ref->tree_ref.root) &&
++ !generic_ref->skip_qgroup) {
+ record = kzalloc(sizeof(*record), GFP_NOFS);
+ if (!record)
+ goto free_head_ref;
+ }
+
+ init_delayed_ref_head(head_ref, record, bytenr, num_bytes,
+- ref_root, 0, action, false, is_system);
++ generic_ref->tree_ref.root, 0, action, false,
++ is_system);
+ head_ref->extent_op = extent_op;
+
+ delayed_refs = &trans->transaction->delayed_refs;
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -350,8 +350,7 @@ static inline void btrfs_put_delayed_ref
+
+ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 ref_root, int level, int action,
++ struct btrfs_ref *generic_ref,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod);
+ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2099,16 +2099,19 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ {
+ int old_ref_mod, new_ref_mod;
+ int ret;
++ struct btrfs_ref generic_ref = { 0 };
+ struct btrfs_fs_info *fs_info = root->fs_info;
+
+ BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID &&
+ root_objectid == BTRFS_TREE_LOG_OBJECTID);
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_REF, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root->root_key.objectid;
+ if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+- num_bytes,
+- parent, root_objectid, (int)owner,
+- BTRFS_ADD_DELAYED_REF, NULL,
++ btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans,
++ &generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ } else {
+ ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+@@ -7176,17 +7179,20 @@ void btrfs_free_tree_block(struct btrfs_
+ struct extent_buffer *buf,
+ u64 parent, int last_ref)
+ {
++ struct btrfs_ref generic_ref = { 0 };
+ int pin = 1;
+ int ret;
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF,
++ buf->start, buf->len, parent);
++ btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf),
++ root->root_key.objectid);
++
+ if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
+ int old_ref_mod, new_ref_mod;
+
+ ret = btrfs_add_delayed_tree_ref(root->fs_info, trans,
+- buf->start, buf->len,
+- parent, root->root_key.objectid,
+- btrfs_header_level(buf),
+- BTRFS_DROP_DELAYED_REF, NULL,
++ &generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ BUG_ON(ret); /* -ENOMEM */
+ pin = old_ref_mod >= 0 && new_ref_mod < 0;
+@@ -7240,10 +7246,14 @@ int btrfs_free_extent(struct btrfs_trans
+ int old_ref_mod, new_ref_mod;
+ int ret;
+ struct btrfs_fs_info *fs_info = root->fs_info;
++ struct btrfs_ref generic_ref = { 0 };
+
+ if (btrfs_test_is_dummy_root(root))
+ return 0;
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root->root_key.objectid;
+ /*
+ * tree log blocks never actually go into the extent allocation
+ * tree, just update pinning info and exit early.
+@@ -7255,10 +7265,9 @@ int btrfs_free_extent(struct btrfs_trans
+ old_ref_mod = new_ref_mod = 0;
+ ret = 0;
+ } else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+- num_bytes,
+- parent, root_objectid, (int)owner,
+- BTRFS_DROP_DELAYED_REF, NULL,
++ btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ ret = btrfs_add_delayed_tree_ref(fs_info, trans,
++ &generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ } else {
+ ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+@@ -8389,6 +8398,7 @@ struct extent_buffer *btrfs_alloc_tree_b
+ struct btrfs_block_rsv *block_rsv;
+ struct extent_buffer *buf;
+ struct btrfs_delayed_extent_op *extent_op;
++ struct btrfs_ref generic_ref = { 0 };
+ u64 flags = 0;
+ int ret;
+ u32 blocksize = root->nodesize;
+@@ -8443,10 +8453,12 @@ struct extent_buffer *btrfs_alloc_tree_b
+ extent_op->is_data = false;
+ extent_op->level = level;
+
++ btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
++ ins.objectid, ins.offset, parent);
++ generic_ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&generic_ref, level, root_objectid);
+ ret = btrfs_add_delayed_tree_ref(root->fs_info, trans,
+- ins.objectid, ins.offset,
+- parent, root_objectid, level,
+- BTRFS_ADD_DELAYED_EXTENT,
++ &generic_ref,
+ extent_op, NULL, NULL);
+ if (ret)
+ goto out_free_delayed;
diff --git a/patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch b/patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
new file mode 100644
index 0000000000..493e407029
--- /dev/null
+++ b/patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
@@ -0,0 +1,127 @@
+From 76675593b69f2fcd57e24d9dd2a9b278f0130d0b Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:32 +0800
+Git-commit: 76675593b69f2fcd57e24d9dd2a9b278f0130d0b
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 4/9] btrfs: delayed-ref: Use btrfs_ref to refactor
+ btrfs_add_delayed_data_ref()
+
+Just like btrfs_add_delayed_tree_ref(), use btrfs_ref to refactor
+btrfs_add_delayed_data_ref().
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 16 ++++++++++++----
+ fs/btrfs/delayed-ref.h | 4 +---
+ fs/btrfs/extent-tree.c | 25 ++++++++++++-------------
+ 3 files changed, 25 insertions(+), 20 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -807,9 +807,7 @@ free_ref:
+ */
+ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes,
+- u64 parent, u64 ref_root,
+- u64 owner, u64 offset, u64 reserved, int action,
++ struct btrfs_ref *generic_ref, u64 reserved,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod)
+ {
+@@ -817,9 +815,17 @@ int btrfs_add_delayed_data_ref(struct bt
+ struct btrfs_delayed_ref_head *head_ref;
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_qgroup_extent_record *record = NULL;
++ int action = generic_ref->action;
+ int ret;
++ u64 bytenr = generic_ref->bytenr;
++ u64 num_bytes = generic_ref->len;
++ u64 parent = generic_ref->parent;
++ u64 ref_root = generic_ref->data_ref.ref_root;
++ u64 owner = generic_ref->data_ref.ino;
++ u64 offset = generic_ref->data_ref.offset;
+ u8 ref_type;
+
++ ASSERT(generic_ref->type == BTRFS_REF_DATA && action);
+ BUG_ON(extent_op && !extent_op->is_data);
+ ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS);
+ if (!ref)
+@@ -843,7 +849,9 @@ int btrfs_add_delayed_data_ref(struct bt
+ }
+
+ if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
+- is_fstree(ref_root)) {
++ is_fstree(ref_root) &&
++ is_fstree(generic_ref->real_root) &&
++ !generic_ref->skip_qgroup) {
+ record = kzalloc(sizeof(*record), GFP_NOFS);
+ if (!record) {
+ kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -355,9 +355,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ int *old_ref_mod, int *new_ref_mod);
+ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- u64 bytenr, u64 num_bytes,
+- u64 parent, u64 ref_root,
+- u64 owner, u64 offset, u64 reserved, int action,
++ struct btrfs_ref *generic_ref, u64 reserved,
+ struct btrfs_delayed_extent_op *extent_op,
+ int *old_ref_mod, int *new_ref_mod);
+ int btrfs_add_delayed_qgroup_reserve(struct btrfs_fs_info *fs_info,
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2114,10 +2114,9 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ &generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ } else {
+- ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+- num_bytes, parent, root_objectid,
+- owner, offset, 0,
+- BTRFS_ADD_DELAYED_REF, NULL,
++ btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
++ ret = btrfs_add_delayed_data_ref(fs_info, trans,
++ &generic_ref, 0, NULL,
+ &old_ref_mod, &new_ref_mod);
+ }
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+@@ -7270,11 +7269,9 @@ int btrfs_free_extent(struct btrfs_trans
+ &generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ } else {
+- ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+- num_bytes,
+- parent, root_objectid, owner,
+- offset, 0,
+- BTRFS_DROP_DELAYED_REF, NULL,
++ btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
++ ret = btrfs_add_delayed_data_ref(fs_info, trans,
++ &generic_ref, 0, NULL,
+ &old_ref_mod, &new_ref_mod);
+ }
+
+@@ -8215,14 +8212,16 @@ int btrfs_alloc_reserved_file_extent(str
+ u64 offset, u64 ram_bytes,
+ struct btrfs_key *ins)
+ {
++ struct btrfs_ref generic_ref = { 0 };
+ int ret;
+
+ BUG_ON(root_objectid == BTRFS_TREE_LOG_OBJECTID);
+
+- ret = btrfs_add_delayed_data_ref(root->fs_info, trans, ins->objectid,
+- ins->offset, 0,
+- root_objectid, owner, offset,
+- ram_bytes, BTRFS_ADD_DELAYED_EXTENT,
++ btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
++ ins->objectid, ins->offset, 0);
++ btrfs_init_data_ref(&generic_ref, root->root_key.objectid, owner, offset);
++ ret = btrfs_add_delayed_data_ref(root->fs_info, trans,
++ &generic_ref, ram_bytes,
+ NULL, NULL, NULL);
+ return ret;
+ }
diff --git a/patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch b/patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch
new file mode 100644
index 0000000000..3cc3688f1a
--- /dev/null
+++ b/patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch
@@ -0,0 +1,72 @@
+From ddf30cf03fb53b9a0ad0f355a69dbedf416edde9 Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:34 +0800
+Git-commit: ddf30cf03fb53b9a0ad0f355a69dbedf416edde9
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 6/9] btrfs: extent-tree: Use btrfs_ref to refactor
+ add_pinned_bytes()
+
+Since add_pinned_bytes() only needs to know if the extent is metadata
+and if it's a chunk tree extent, btrfs_ref is a perfect match for it, as
+we don't need various owner/level trick to determine extent type.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: Nikolay Borisov <nborisov@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -755,14 +755,15 @@ static struct btrfs_space_info *__find_s
+ return NULL;
+ }
+
+-static void add_pinned_bytes(struct btrfs_fs_info *fs_info, s64 num_bytes,
+- u64 owner, u64 root_objectid)
++static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
++ struct btrfs_ref *ref)
+ {
+ struct btrfs_space_info *space_info;
++ s64 num_bytes = -ref->len;
+ u64 flags;
+
+- if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- if (root_objectid == BTRFS_CHUNK_TREE_OBJECTID)
++ if (ref->type == BTRFS_REF_METADATA) {
++ if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
+ flags = BTRFS_BLOCK_GROUP_SYSTEM;
+ else
+ flags = BTRFS_BLOCK_GROUP_METADATA;
+@@ -2120,7 +2121,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ &old_ref_mod, &new_ref_mod);
+ }
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, -num_bytes, owner, root_objectid);
++ add_pinned_bytes(fs_info, &generic_ref);
+
+ return ret;
+ }
+@@ -7224,9 +7225,8 @@ void btrfs_free_tree_block(struct btrfs_
+ }
+ out:
+ if (pin)
+- add_pinned_bytes(root->fs_info, buf->len,
+- btrfs_header_level(buf),
+- root->root_key.objectid);
++ add_pinned_bytes(root->fs_info, &generic_ref);
++
+ if (last_ref) {
+
+ /*
+@@ -7276,7 +7276,7 @@ int btrfs_free_extent(struct btrfs_trans
+ }
+
+ if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
+- add_pinned_bytes(fs_info, num_bytes, owner, root_objectid);
++ add_pinned_bytes(fs_info, &generic_ref);
+
+ return ret;
+ }
diff --git a/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch b/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
new file mode 100644
index 0000000000..d895a0d7ef
--- /dev/null
+++ b/patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
@@ -0,0 +1,370 @@
+From 82fa113fccc41fe5204b4ce35341d69ebde0020f Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:35 +0800
+Git-commit: 82fa113fccc41fe5204b4ce35341d69ebde0020f
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 7/9] btrfs: extent-tree: Use btrfs_ref to refactor
+ btrfs_inc_extent_ref()
+
+Use the new btrfs_ref structure and replace parameter list to clean up
+the usage of owner and level to distinguish the extent types.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/ctree.h | 5 +---
+ fs/btrfs/extent-tree.c | 55 +++++++++++++++++++++++++++----------------------
+ fs/btrfs/file.c | 17 ++++++++++-----
+ fs/btrfs/inode.c | 10 +++++---
+ fs/btrfs/ioctl.c | 15 ++++++++-----
+ fs/btrfs/relocation.c | 42 ++++++++++++++++++++++++-------------
+ fs/btrfs/tree-log.c | 11 +++++++--
+ 7 files changed, 96 insertions(+), 59 deletions(-)
+
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -51,6 +51,7 @@ extern struct kmem_cache *btrfs_bit_radi
+ extern struct kmem_cache *btrfs_path_cachep;
+ extern struct kmem_cache *btrfs_free_space_cachep;
+ struct btrfs_ordered_sum;
++struct btrfs_ref;
+
+ #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+ #define STATIC noinline
+@@ -2679,9 +2680,7 @@ void btrfs_prepare_extent_commit(struct
+ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root);
+ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+- struct btrfs_root *root,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 root_objectid, u64 owner, u64 offset);
++ struct btrfs_ref *generic_ref);
+
+ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root);
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2094,34 +2094,27 @@ int btrfs_discard_extent(struct btrfs_ro
+
+ /* Can return -ENOMEM */
+ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+- struct btrfs_root *root,
+- u64 bytenr, u64 num_bytes, u64 parent,
+- u64 root_objectid, u64 owner, u64 offset)
++ struct btrfs_ref *generic_ref)
+ {
+ int old_ref_mod, new_ref_mod;
+ int ret;
+- struct btrfs_ref generic_ref = { 0 };
+- struct btrfs_fs_info *fs_info = root->fs_info;
++ struct btrfs_fs_info *fs_info = trans->fs_info;
+
+- BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID &&
+- root_objectid == BTRFS_TREE_LOG_OBJECTID);
++ ASSERT(generic_ref->type != BTRFS_REF_NOT_SET &&
++ generic_ref->action);
++ BUG_ON(generic_ref->type == BTRFS_REF_METADATA &&
++ generic_ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID);
+
+- btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_REF, bytenr,
+- num_bytes, parent);
+- generic_ref.real_root = root->root_key.objectid;
+- if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ if (generic_ref->type == BTRFS_REF_METADATA)
+ ret = btrfs_add_delayed_tree_ref(fs_info, trans,
+- &generic_ref, NULL,
++ generic_ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+- } else {
+- btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
++ else
+ ret = btrfs_add_delayed_data_ref(fs_info, trans,
+- &generic_ref, 0, NULL,
++ generic_ref, 0, NULL,
+ &old_ref_mod, &new_ref_mod);
+- }
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ add_pinned_bytes(fs_info, generic_ref);
+
+ return ret;
+ }
+@@ -3246,7 +3239,10 @@ static int __btrfs_mod_ref(struct btrfs_
+ u32 nritems;
+ struct btrfs_key key;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref generic_ref = { 0 };
++ bool for_reloc = btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC);
+ int i;
++ int action;
+ int level;
+ int ret = 0;
+
+@@ -3264,6 +3260,10 @@ static int __btrfs_mod_ref(struct btrfs_
+ parent = buf->start;
+ else
+ parent = 0;
++ if (inc)
++ action = BTRFS_ADD_DELAYED_REF;
++ else
++ action = BTRFS_DROP_DELAYED_REF;
+
+ for (i = 0; i < nritems; i++) {
+ if (level == 0) {
+@@ -3281,10 +3281,14 @@ static int __btrfs_mod_ref(struct btrfs_
+
+ num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
+ key.offset -= btrfs_file_extent_offset(buf, fi);
++ btrfs_init_generic_ref(&generic_ref, action, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root->root_key.objectid;
++ btrfs_init_data_ref(&generic_ref, ref_root, key.objectid,
++ key.offset);
++ generic_ref.skip_qgroup = for_reloc;
+ if (inc)
+- ret = btrfs_inc_extent_ref(trans, root, bytenr,
+- num_bytes, parent, ref_root,
+- key.objectid, key.offset);
++ ret = btrfs_inc_extent_ref(trans, &generic_ref);
+ else
+ ret = btrfs_free_extent(trans, root, bytenr,
+ num_bytes, parent, ref_root,
+@@ -3294,10 +3298,13 @@ static int __btrfs_mod_ref(struct btrfs_
+ } else {
+ bytenr = btrfs_node_blockptr(buf, i);
+ num_bytes = root->nodesize;
++ btrfs_init_generic_ref(&generic_ref, action, bytenr,
++ num_bytes, parent);
++ generic_ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&generic_ref, level - 1, ref_root);
++ generic_ref.skip_qgroup = for_reloc;
+ if (inc)
+- ret = btrfs_inc_extent_ref(trans, root, bytenr,
+- num_bytes, parent, ref_root,
+- level - 1, 0);
++ ret = btrfs_inc_extent_ref(trans, &generic_ref);
+ else
+ ret = btrfs_free_extent(trans, root, bytenr,
+ num_bytes, parent, ref_root,
+--- a/fs/btrfs/file.c
++++ b/fs/btrfs/file.c
+@@ -698,6 +698,7 @@ int __btrfs_drop_extents(struct btrfs_tr
+ {
+ struct extent_buffer *leaf;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ struct btrfs_key new_key;
+ u64 ino = btrfs_ino(inode);
+@@ -851,11 +852,14 @@ next_slot:
+ btrfs_mark_buffer_dirty(leaf);
+
+ if (update_refs && disk_bytenr > 0) {
+- ret = btrfs_inc_extent_ref(trans, root,
+- disk_bytenr, num_bytes, 0,
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF,
++ disk_bytenr, num_bytes, 0);
++ btrfs_init_data_ref(&ref,
+ root->root_key.objectid,
+ new_key.objectid,
+ start - extent_offset);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ BUG_ON(ret); /* -ENOMEM */
+ }
+ key.offset = start;
+@@ -1077,6 +1081,7 @@ int btrfs_mark_extent_written(struct btr
+ struct extent_buffer *leaf;
+ struct btrfs_path *path;
+ struct btrfs_file_extent_item *fi;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ struct btrfs_key new_key;
+ u64 bytenr;
+@@ -1222,9 +1227,11 @@ again:
+ extent_end - split);
+ btrfs_mark_buffer_dirty(leaf);
+
+- ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
+- root->root_key.objectid,
+- ino, orig_offset);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, bytenr,
++ num_bytes, 0);
++ btrfs_init_data_ref(&ref, root->root_key.objectid, ino,
++ orig_offset);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -2507,6 +2507,7 @@ static noinline int relink_extent_backre
+ struct btrfs_file_extent_item *item;
+ struct btrfs_ordered_extent *ordered;
+ struct btrfs_trans_handle *trans;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_fs_info *fs_info;
+ struct btrfs_root *root;
+ struct btrfs_key key;
+@@ -2679,10 +2680,11 @@ again:
+ inode_add_bytes(inode, len);
+ btrfs_release_path(path);
+
+- ret = btrfs_inc_extent_ref(trans, root, new->bytenr,
+- new->disk_len, 0,
+- backref->root_id, backref->inum,
+- new->file_pos); /* start - extent_offset */
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new->bytenr,
++ new->disk_len, 0);
++ btrfs_init_data_ref(&ref, backref->root_id, backref->inum,
++ new->file_pos); /* start - extent_offset */
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out_free_path;
+--- a/fs/btrfs/ioctl.c
++++ b/fs/btrfs/ioctl.c
+@@ -3830,12 +3830,17 @@ process_slot:
+ datal);
+
+ if (disko) {
++ struct btrfs_ref ref = { 0 };
++
+ inode_add_bytes(inode, datal);
+- ret = btrfs_inc_extent_ref(trans, root,
+- disko, diskl, 0,
+- root->root_key.objectid,
+- btrfs_ino(inode),
+- new_key.offset - datao);
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF, disko,
++ diskl, 0);
++ btrfs_init_data_ref(&ref,
++ root->root_key.objectid,
++ btrfs_ino(inode),
++ new_key.offset - datao);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans,
+ ret);
+--- a/fs/btrfs/relocation.c
++++ b/fs/btrfs/relocation.c
+@@ -1680,6 +1680,8 @@ int replace_file_extents(struct btrfs_tr
+
+ nritems = btrfs_header_nritems(leaf);
+ for (i = 0; i < nritems; i++) {
++ struct btrfs_ref ref = { 0 };
++
+ cond_resched();
+ btrfs_item_key_to_cpu(leaf, &key, i);
+ if (key.type != BTRFS_EXTENT_DATA_KEY)
+@@ -1740,10 +1742,12 @@ int replace_file_extents(struct btrfs_tr
+ dirty = 1;
+
+ key.offset -= btrfs_file_extent_offset(leaf, fi);
+- ret = btrfs_inc_extent_ref(trans, root, new_bytenr,
+- num_bytes, parent,
+- btrfs_header_owner(leaf),
+- key.objectid, key.offset);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
++ num_bytes, parent);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
++ key.objectid, key.offset);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ break;
+@@ -1792,6 +1796,7 @@ int replace_path(struct btrfs_trans_hand
+ {
+ struct extent_buffer *eb;
+ struct extent_buffer *parent;
++ struct btrfs_ref ref = { 0 };
+ struct btrfs_key key;
+ u64 old_bytenr;
+ u64 new_bytenr;
+@@ -1950,13 +1955,17 @@ again:
+ path->slots[level], old_ptr_gen);
+ btrfs_mark_buffer_dirty(path->nodes[level]);
+
+- ret = btrfs_inc_extent_ref(trans, src, old_bytenr, blocksize,
+- path->nodes[level]->start,
+- src->root_key.objectid, level - 1, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, old_bytenr,
++ blocksize, path->nodes[level]->start);
++ ref.skip_qgroup = true;
++ btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ BUG_ON(ret);
+- ret = btrfs_inc_extent_ref(trans, dest, new_bytenr, blocksize,
+- 0, dest->root_key.objectid, level - 1,
+- 0);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
++ blocksize, 0);
++ ref.skip_qgroup = true;
++ btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ BUG_ON(ret);
+
+ ret = btrfs_free_extent(trans, src, new_bytenr, blocksize,
+@@ -2758,6 +2767,7 @@ static int do_relocation(struct btrfs_tr
+ rc->backref_cache.path[node->level] = node;
+ list_for_each_entry(edge, &node->upper, list[LOWER]) {
+ struct btrfs_key first_key;
++ struct btrfs_ref ref = { 0 };
+
+ cond_resched();
+
+@@ -2855,11 +2865,13 @@ static int do_relocation(struct btrfs_tr
+ trans->transid);
+ btrfs_mark_buffer_dirty(upper->eb);
+
+- ret = btrfs_inc_extent_ref(trans, root,
+- node->eb->start, blocksize,
+- upper->eb->start,
+- btrfs_header_owner(upper->eb),
+- node->level, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF,
++ node->eb->start, blocksize,
++ upper->eb->start);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_tree_ref(&ref, node->level,
++ btrfs_header_owner(upper->eb));
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ BUG_ON(ret);
+
+ ret = btrfs_drop_subtree(trans, root, eb, upper->eb);
+--- a/fs/btrfs/tree-log.c
++++ b/fs/btrfs/tree-log.c
+@@ -698,9 +698,11 @@ static noinline int replay_one_extent(st
+ goto out;
+
+ if (ins.objectid > 0) {
++ struct btrfs_ref ref = { 0 };
+ u64 csum_start;
+ u64 csum_end;
+ LIST_HEAD(ordered_sums);
++
+ /*
+ * is this extent already allocated in the extent
+ * allocation tree? If so, just add a reference
+@@ -708,10 +710,13 @@ static noinline int replay_one_extent(st
+ ret = btrfs_lookup_data_extent(root, ins.objectid,
+ ins.offset);
+ if (ret == 0) {
+- ret = btrfs_inc_extent_ref(trans, root,
+- ins.objectid, ins.offset,
+- 0, root->root_key.objectid,
++ btrfs_init_generic_ref(&ref,
++ BTRFS_ADD_DELAYED_REF,
++ ins.objectid, ins.offset, 0);
++ btrfs_init_data_ref(&ref,
++ root->root_key.objectid,
+ key->objectid, offset);
++ ret = btrfs_inc_extent_ref(trans, &ref);
+ if (ret)
+ goto out;
+ } else {
diff --git a/patches.suse/0008-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_fr.patch b/patches.suse/0008-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_fr.patch
new file mode 100644
index 0000000000..a03ffdbdd3
--- /dev/null
+++ b/patches.suse/0008-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_fr.patch
@@ -0,0 +1,258 @@
+From ffd4bb2a19cd29681f5b70a200654ab92619de8a Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:36 +0800
+Git-commit: ffd4bb2a19cd29681f5b70a200654ab92619de8a
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 8/9] btrfs: extent-tree: Use btrfs_ref to refactor
+ btrfs_free_extent()
+
+Similar to btrfs_inc_extent_ref(), use btrfs_ref to replace the long
+parameter list and the confusing @owner parameter.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/ctree.h | 5 +----
+ fs/btrfs/extent-tree.c | 46 ++++++++++++++++++----------------------------
+ fs/btrfs/file.c | 22 ++++++++++++----------
+ fs/btrfs/inode.c | 12 ++++++++----
+ fs/btrfs/relocation.c | 25 ++++++++++++++++---------
+ 5 files changed, 55 insertions(+), 55 deletions(-)
+
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -2666,10 +2666,7 @@ int btrfs_set_disk_extent_flags(struct b
+ struct btrfs_root *root,
+ u64 bytenr, u64 num_bytes, u64 flags,
+ int level, int is_data);
+-int btrfs_free_extent(struct btrfs_trans_handle *trans,
+- struct btrfs_root *root,
+- u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
+- u64 owner, u64 offset);
++int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
+
+ int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len,
+ int delalloc);
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -3290,9 +3290,7 @@ static int __btrfs_mod_ref(struct btrfs_
+ if (inc)
+ ret = btrfs_inc_extent_ref(trans, &generic_ref);
+ else
+- ret = btrfs_free_extent(trans, root, bytenr,
+- num_bytes, parent, ref_root,
+- key.objectid, key.offset);
++ ret = btrfs_free_extent(trans, &generic_ref);
+ if (ret)
+ goto fail;
+ } else {
+@@ -3306,9 +3304,7 @@ static int __btrfs_mod_ref(struct btrfs_
+ if (inc)
+ ret = btrfs_inc_extent_ref(trans, &generic_ref);
+ else
+- ret = btrfs_free_extent(trans, root, bytenr,
+- num_bytes, parent, ref_root,
+- level - 1, 0);
++ ret = btrfs_free_extent(trans, &generic_ref);
+ if (ret)
+ goto fail;
+ }
+@@ -7245,45 +7241,36 @@ out:
+ }
+
+ /* Can return -ENOMEM */
+-int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+- u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
+- u64 owner, u64 offset)
++int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
+ {
+ int old_ref_mod, new_ref_mod;
+ int ret;
+- struct btrfs_fs_info *fs_info = root->fs_info;
+- struct btrfs_ref generic_ref = { 0 };
+-
+- if (btrfs_test_is_dummy_root(root))
+- return 0;
++ struct btrfs_fs_info *fs_info = trans->fs_info;
+
+- btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, bytenr,
+- num_bytes, parent);
+- generic_ref.real_root = root->root_key.objectid;
+ /*
+ * tree log blocks never actually go into the extent allocation
+ * tree, just update pinning info and exit early.
+ */
+- if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
+- WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);
++ if ((ref->type == BTRFS_REF_METADATA &&
++ ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID) ||
++ (ref->type == BTRFS_REF_DATA &&
++ ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)) {
+ /* unlocks the pinned mutex */
+- btrfs_pin_extent(root, bytenr, num_bytes, 1);
++ btrfs_pin_extent(fs_info->tree_root, ref->bytenr, ref->len, 1);
+ old_ref_mod = new_ref_mod = 0;
+ ret = 0;
+- } else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
+- btrfs_init_tree_ref(&generic_ref, (int)owner, root_objectid);
++ } else if (ref->type == BTRFS_REF_METADATA) {
+ ret = btrfs_add_delayed_tree_ref(fs_info, trans,
+- &generic_ref, NULL,
++ ref, NULL,
+ &old_ref_mod, &new_ref_mod);
+ } else {
+- btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
+ ret = btrfs_add_delayed_data_ref(fs_info, trans,
+- &generic_ref, 0, NULL,
++ ref, 0, NULL,
+ &old_ref_mod, &new_ref_mod);
+ }
+
+ if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ add_pinned_bytes(fs_info, ref);
+
+ return ret;
+ }
+@@ -8680,6 +8667,7 @@ static noinline int do_walk_down(struct
+ u32 blocksize;
+ struct btrfs_key key;
+ struct btrfs_key first_key;
++ struct btrfs_ref ref = { 0 };
+ struct extent_buffer *next;
+ int level = wc->level;
+ int reada = 0;
+@@ -8826,8 +8814,10 @@ skip:
+ ret);
+ }
+ }
+- ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent,
+- root->root_key.objectid, level - 1, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr,
++ root->nodesize, parent);
++ btrfs_init_tree_ref(&ref, level - 1, root->root_key.objectid);
++ ret = btrfs_free_extent(trans, &ref);
+ if (ret)
+ goto out_unlock;
+ }
+--- a/fs/btrfs/file.c
++++ b/fs/btrfs/file.c
+@@ -933,11 +933,14 @@ delete_extent_item:
+ extent_end = ALIGN(extent_end,
+ root->sectorsize);
+ } else if (update_refs && disk_bytenr > 0) {
+- ret = btrfs_free_extent(trans, root,
+- disk_bytenr, num_bytes, 0,
++ btrfs_init_generic_ref(&ref,
++ BTRFS_DROP_DELAYED_REF,
++ disk_bytenr, num_bytes, 0);
++ btrfs_init_data_ref(&ref,
+ root->root_key.objectid,
+- key.objectid, key.offset -
+- extent_offset);
++ key.objectid,
++ key.offset - extent_offset);
++ ret = btrfs_free_extent(trans, &ref);
+ BUG_ON(ret); /* -ENOMEM */
+ inode_sub_bytes(inode,
+ extent_end - key.offset);
+@@ -1253,6 +1256,9 @@ again:
+
+ other_start = end;
+ other_end = 0;
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr,
++ num_bytes, 0);
++ btrfs_init_data_ref(&ref, root->root_key.objectid, ino, orig_offset);
+ if (extent_mergeable(leaf, path->slots[0] + 1,
+ ino, bytenr, orig_offset,
+ &other_start, &other_end)) {
+@@ -1263,9 +1269,7 @@ again:
+ extent_end = other_end;
+ del_slot = path->slots[0] + 1;
+ del_nr++;
+- ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
+- 0, root->root_key.objectid,
+- ino, orig_offset);
++ ret = btrfs_free_extent(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+@@ -1283,9 +1287,7 @@ again:
+ key.offset = other_start;
+ del_slot = path->slots[0];
+ del_nr++;
+- ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
+- 0, root->root_key.objectid,
+- ino, orig_offset);
++ ret = btrfs_free_extent(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -4643,12 +4643,16 @@ delete:
+ if (found_extent &&
+ (test_bit(BTRFS_ROOT_REF_COWS, &root->state) ||
+ root == root->fs_info->tree_root)) {
++ struct btrfs_ref ref = { 0 };
++
+ btrfs_set_path_blocking(path);
+ bytes_deleted += extent_num_bytes;
+- ret = btrfs_free_extent(trans, root, extent_start,
+- extent_num_bytes, 0,
+- btrfs_header_owner(leaf),
+- ino, extent_offset);
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF,
++ extent_start, extent_num_bytes, 0);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
++ ino, extent_offset);
++ ret = btrfs_free_extent(trans, &ref);
+ BUG_ON(ret);
+ if (btrfs_should_throttle_delayed_refs(trans, root))
+ btrfs_async_run_delayed_refs(root,
+--- a/fs/btrfs/relocation.c
++++ b/fs/btrfs/relocation.c
+@@ -1753,9 +1753,12 @@ int replace_file_extents(struct btrfs_tr
+ break;
+ }
+
+- ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
+- parent, btrfs_header_owner(leaf),
+- key.objectid, key.offset);
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr,
++ num_bytes, parent);
++ ref.real_root = root->root_key.objectid;
++ btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
++ key.objectid, key.offset);
++ ret = btrfs_free_extent(trans, &ref);
+ if (ret) {
+ btrfs_abort_transaction(trans, ret);
+ break;
+@@ -1968,14 +1971,18 @@ again:
+ ret = btrfs_inc_extent_ref(trans, &ref);
+ BUG_ON(ret);
+
+- ret = btrfs_free_extent(trans, src, new_bytenr, blocksize,
+- path->nodes[level]->start,
+- src->root_key.objectid, level - 1, 0);
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, new_bytenr,
++ blocksize, path->nodes[level]->start);
++ btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid);
++ ref.skip_qgroup = true;
++ ret = btrfs_free_extent(trans, &ref);
+ BUG_ON(ret);
+
+- ret = btrfs_free_extent(trans, dest, old_bytenr, blocksize,
+- 0, dest->root_key.objectid, level - 1,
+- 0);
++ btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, old_bytenr,
++ blocksize, 0);
++ btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid);
++ ref.skip_qgroup = true;
++ ret = btrfs_free_extent(trans, &ref);
+ BUG_ON(ret);
+
+ btrfs_unlock_up_safe(path, 0);
diff --git a/patches.suse/0009-btrfs-qgroup-Don-t-scan-leaf-if-we-re-modifying-relo.patch b/patches.suse/0009-btrfs-qgroup-Don-t-scan-leaf-if-we-re-modifying-relo.patch
new file mode 100644
index 0000000000..a036863c8e
--- /dev/null
+++ b/patches.suse/0009-btrfs-qgroup-Don-t-scan-leaf-if-we-re-modifying-relo.patch
@@ -0,0 +1,67 @@
+From c4140cbf35b90422be6589024f47e132eb2298b1 Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:37 +0800
+Git-commit: c4140cbf35b90422be6589024f47e132eb2298b1
+Patch-mainline: v5.2-rc1
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH 9/9] btrfs: qgroup: Don't scan leaf if we're modifying reloc
+ tree
+
+Since reloc tree doesn't contribute to qgroup numbers, just skip them.
+
+This should catch the final cause of unnecessary data ref processing
+when running balance of metadata with qgroups on.
+
+The 4G data 16 snapshots test (*) should explain it pretty well:
+
+ | delayed subtree | refactor delayed ref | this patch
+---------------------------------------------------------------------
+relocated | 22653 | 22673 | 22744
+qgroup dirty | 122792 | 48360 | 70
+time | 24.494 | 11.606 | 3.944
+
+Finally, we're at the stage where qgroup + metadata balance cost no
+obvious overhead.
+
+Test environment:
+
+Test VM:
+- vRAM 8G
+- vCPU 8
+- block dev vitrio-blk, 'unsafe' cache mode
+- host block 850evo
+
+Test workload:
+- Copy 4G data from /usr/ to one subvolume
+- Create 16 snapshots of that subvolume, and modify 3 files in each
+ snapshot
+- Enable quota, rescan
+- Time "btrfs balance start -m"
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -8906,11 +8906,13 @@ static noinline int walk_up_proc(struct
+ else
+ ret = btrfs_dec_ref(trans, root, eb, 0);
+ BUG_ON(ret); /* -ENOMEM */
+- ret = btrfs_qgroup_trace_leaf_items(trans, root, eb);
+- if (ret) {
+- btrfs_err_rl(root->fs_info,
+- "error %d accounting leaf items. Quota is out of sync, rescan required.",
+- ret);
++ if (is_fstree(root->root_key.objectid)) {
++ ret = btrfs_qgroup_trace_leaf_items(trans, root, eb);
++ if (ret) {
++ btrfs_err_rl(root->fs_info,
++ "error %d accounting leaf items. Quota is out of sync, rescan required.",
++ ret);
++ }
+ }
+ }
+ /* make block locked assertion in clean_tree_block happy */
diff --git a/series.conf b/series.conf
index 860b60d4cb..471f79594e 100644
--- a/series.conf
+++ b/series.conf
@@ -22419,6 +22419,7 @@
patches.drivers/tpm-179-crb-fix-priv-cmd_size-initialisation.patch
patches.fixes/CIFS-fix-circular-locking-dependency.patch
patches.drivers/hns-0005-net-hns-Fix-a-skb-used-after-free-bug.patch
+ patches.fixes/0001-dt-bindings-rcar-dmac-Document-missing-error-interru.patch
patches.fixes/0001-md-use-a-separate-bio_set-for-synchronous-IO.patch
patches.fixes/md-fix-a-null-dereference.patch
patches.fixes/0001-MD-fix-sleep-in-atomic.patch
@@ -23979,6 +23980,7 @@
patches.suse/msft-hv-1580-uio_hv_generic-add-rescind-support.patch
patches.suse/msft-hv-1581-uio_hv_generic-fix-type-mismatch-warnings.patch
patches.suse/msft-hv-1583-uio_hv_generic-fix-new-type-mismatch-warnings.patch
+ patches.fixes/0001-kconfig-display-recursive-dependency-resolution-hint.patch
patches.suse/powerpc-modules-don-t-try-to-restore-r2-after-a-sibling-call.patch
patches.arch/powerpc-make-use-of-for_each_node_by_type-instead-of.patch
patches.arch/powerpc-crash-Remove-the-test-for-cpu_online-in-the-.patch
@@ -24447,6 +24449,7 @@
patches.fixes/0003-watchdog-hpwdt-Update-nmi_panic-message.patch
patches.fixes/0004-watchdog-hpwdt-Modify-to-use-watchdog-core.patch
patches.fixes/0005-watchdog-hpwdt-condition-early-return-of-NMI-handler.patch
+ patches.fixes/0001-clk-fix-mux-clock-documentation.patch
patches.suse/powerpc-64s-Fix-section-mismatch-warnings-from-setup.patch
patches.drivers/scsi-qla2xxx-Fix-small-memory-leak-in-qla2x00_probe_.patch
patches.drivers/scsi-qla2xxx-Avoid-double-completion-of-abort-comman.patch
@@ -25134,6 +25137,7 @@
patches.suse/0125-bcache-split-combined-if-condition-code-into-separat.patch
patches.suse/0126-bcache-panic-fix-for-making-cache-device.patch
patches.drivers/0001-ipmi-ssif-Add-support-for-multi-part-transmit-messag.patch
+ patches.fixes/0001-cpupower-remove-stringop-truncation-waring.patch
patches.suse/ACPI-processor-Fix-the-return-value-of-acpi_processor_ids_walk.patch
patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
patches.fixes/x86-kexec-correct-kexec_backup_src_end-off-by-one-error.patch
@@ -25386,6 +25390,7 @@
patches.suse/floppy-check_events-callback-should-not-return-a-neg.patch
patches.fixes/md-raid1-don-t-clear-bitmap-bits-on-interrupted-reco.patch
patches.suse/0001-net-dsa-bcm_sf2-Do-not-assume-DSA-master-supports-Wo.patch
+ patches.fixes/0001-keys-Timestamp-new-keys.patch
patches.suse/mm-memory_hotplug-fix-off-by-one-in-is_pageblock_rem.patch
patches.suse/kallsyms-handle-too-long-symbols-in-kallsyms-c.patch
patches.fixes/copy_mount_string-Limit-string-length-to-PATH_MAX.patch
@@ -25484,6 +25489,7 @@
patches.drivers/ibmvnic-Enable-GRO.patch
patches.drivers/ibmvnic-Fix-netdev-feature-clobbering-during-a-reset.patch
patches.fixes/CIFS-keep-FileInfo-handle-live-during-oplock-break.patch
+ patches.fixes/0001-tools-lib-traceevent-Fix-missing-equality-check-for-.patch
patches.arch/perf-x86-amd-add-event-map-for-amd-family-17h.patch
patches.fixes/sunrpc-don-t-mark-uninitialised-items-as-VALID.patch
patches.suse/ipv4-add-sanity-checks-in-ipv4_link_failure.patch
@@ -25498,6 +25504,14 @@
patches.arch/s390-speculation-support-mitigations-cmdline-option.patch
patches.fixes/0001-btrfs-Don-t-panic-when-we-can-t-find-a-root-key.patch
patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
+ patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
+ patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
+ patches.suse/0003-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
+ patches.suse/0004-btrfs-delayed-ref-Use-btrfs_ref-to-refactor-btrfs_ad.patch
+ patches.suse/0006-btrfs-extent-tree-Use-btrfs_ref-to-refactor-add_pinn.patch
+ patches.suse/0007-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_in.patch
+ patches.suse/0008-btrfs-extent-tree-Use-btrfs_ref-to-refactor-btrfs_fr.patch
+ patches.suse/0009-btrfs-qgroup-Don-t-scan-leaf-if-we-re-modifying-relo.patch
patches.fixes/block-disk_events-introduce-event-flags.patch
patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch
patches.fixes/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for-le.patch
@@ -25506,8 +25520,10 @@
patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch
patches.fixes/0001-UAS-fix-alignment-of-scatter-gather-segments.patch
patches.fixes/ipmi-ssif-compare-block-number-correctly-for-multi-p.patch
+ patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
patches.fixes/0001-drm-i915-Fix-I915_EXEC_RING_MASK.patch
patches.fixes/0002-drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch
+ patches.fixes/0002-drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
patches.arch/powerpc-numa-improve-control-of-topology-updates.patch
patches.arch/powerpc-numa-document-topology_updates_enabled-disab.patch
patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock
@@ -25532,10 +25548,14 @@
patches.arch/x86-speculation-mds-add-smt-warning-message.patch
patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
+ patches.fixes/0001-PCI-Mark-Atheros-AR9462-to-avoid-bus-reset.patch
+ patches.fixes/0001-backlight-lm3630a-Return-0-on-success-in-update_stat.patch
+ patches.fixes/0003-drm-bridge-adv7511-Fix-low-refresh-rate-selection.patch
# out-of-tree patches
patches.kabi/0001-move-power_up_on_resume-flag-to-end-of-structure-for.patch
patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
+ patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
########################################################
# end of sorted patches