Home Home > GIT Browse > openSUSE-15.0
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKernel Build Daemon <kbuild@suse.de>2019-05-19 07:01:18 +0200
committerKernel Build Daemon <kbuild@suse.de>2019-05-19 07:01:18 +0200
commit43788e3f3e89aae9a8057488471a0a99eafe5d9a (patch)
treebd6b36eb8151ba4da3db30603c59b2e156c99385
parent15b7de73f618a937f177ff3f5cba0c384b5fbd3e (diff)
parent437f1ecd76c75d08a208c1273b0c41e23febefe5 (diff)
Merge branch 'SLE15' into openSUSE-15.0
-rw-r--r--patches.fixes/xfs-add-log-item-pinning-error-injection-tag.patch120
-rw-r--r--patches.fixes/xfs-buffer-lru-reference-count-error-injection-tag.patch137
-rw-r--r--patches.fixes/xfs-convert-drop_writes-to-use-the-errortag-mechanis.patch194
-rw-r--r--patches.fixes/xfs-create-inode-pointer-verifiers.patch212
-rw-r--r--patches.fixes/xfs-export-_inobt_btrec_to_irec-and-_ialloc_cluster_.patch111
-rw-r--r--patches.fixes/xfs-expose-errortag-knobs-via-sysfs.patch244
-rw-r--r--patches.fixes/xfs-fix-unused-variable-warning-in-xfs_buf_set_ref.patch45
-rw-r--r--patches.fixes/xfs-force-summary-counter-recalc-at-next-mount.patch131
-rw-r--r--patches.fixes/xfs-move-error-injection-tags-into-their-own-file.patch425
-rw-r--r--patches.fixes/xfs-refactor-unmount-record-write.patch203
-rw-r--r--patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch6
-rw-r--r--patches.fixes/xfs-replace-log_badcrc_factor-knob-with-error-inject.patch158
-rw-r--r--series.conf11
13 files changed, 1994 insertions, 3 deletions
diff --git a/patches.fixes/xfs-add-log-item-pinning-error-injection-tag.patch b/patches.fixes/xfs-add-log-item-pinning-error-injection-tag.patch
new file mode 100644
index 0000000000..47768954c7
--- /dev/null
+++ b/patches.fixes/xfs-add-log-item-pinning-error-injection-tag.patch
@@ -0,0 +1,120 @@
+From 7f4d01f36a3ac16f539f0fd3839de5d58fa4940f Mon Sep 17 00:00:00 2001
+From: Brian Foster <bfoster@redhat.com>
+Date: Tue, 8 Aug 2017 18:21:52 -0700
+Subject: [PATCH] xfs: add log item pinning error injection tag
+Git-commit: 7f4d01f36a3ac16f539f0fd3839de5d58fa4940f
+Patch-mainline: v4.14-rc1
+References: bsc#1114427
+
+Add an error injection tag to force log items in the AIL to the
+pinned state. This option can be used by test infrastructure to
+induce head behind tail conditions. Specifically, this is intended
+to be used by xfstests to reproduce log recovery problems after
+failed/corrupted log writes overwrite the last good tail LSN in the
+log.
+
+When enabled, AIL push attempts see log items in the AIL in the
+pinned state. This stalls metadata writeback and thus prevents the
+current tail of the log from moving forward. When disabled,
+subsequent AIL pushes observe the log items in their appropriate
+state and filesystem operation continues as normal.
+
+Signed-off-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_error.c | 3 +++
+ fs/xfs/xfs_error.h | 4 +++-
+ fs/xfs/xfs_trans_ail.c | 17 ++++++++++++++++-
+ 3 files changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index 2f4feb959bfb..bd786a9ac2c3 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -57,6 +57,7 @@ static unsigned int xfs_errortag_random_default[] = {
+ XFS_RANDOM_AG_RESV_CRITICAL,
+ XFS_RANDOM_DROP_WRITES,
+ XFS_RANDOM_LOG_BAD_CRC,
++ XFS_RANDOM_LOG_ITEM_PIN,
+ };
+
+ struct xfs_errortag_attr {
+@@ -161,6 +162,7 @@ XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
+ XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
+ XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
+ XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
++XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
+
+ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(noerror),
+@@ -193,6 +195,7 @@ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
+ XFS_ERRORTAG_ATTR_LIST(drop_writes),
+ XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
++ XFS_ERRORTAG_ATTR_LIST(log_item_pin),
+ NULL,
+ };
+
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index 7577be5f09bc..7c4bef3bddb7 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -106,7 +106,8 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ */
+ #define XFS_ERRTAG_DROP_WRITES 28
+ #define XFS_ERRTAG_LOG_BAD_CRC 29
+-#define XFS_ERRTAG_MAX 30
++#define XFS_ERRTAG_LOG_ITEM_PIN 30
++#define XFS_ERRTAG_MAX 31
+
+ /*
+ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+@@ -141,6 +142,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_RANDOM_AG_RESV_CRITICAL 4
+ #define XFS_RANDOM_DROP_WRITES 1
+ #define XFS_RANDOM_LOG_BAD_CRC 1
++#define XFS_RANDOM_LOG_ITEM_PIN 1
+
+ #ifdef DEBUG
+ extern int xfs_errortag_init(struct xfs_mount *mp);
+diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
+index 70f5ab017323..354368a906e5 100644
+--- a/fs/xfs/xfs_trans_ail.c
++++ b/fs/xfs/xfs_trans_ail.c
+@@ -325,6 +325,21 @@ xfs_ail_delete(
+ xfs_trans_ail_cursor_clear(ailp, lip);
+ }
+
++static inline uint
++xfsaild_push_item(
++ struct xfs_ail *ailp,
++ struct xfs_log_item *lip)
++{
++ /*
++ * If log item pinning is enabled, skip the push and track the item as
++ * pinned. This can help induce head-behind-tail conditions.
++ */
++ if (XFS_TEST_ERROR(false, ailp->xa_mount, XFS_ERRTAG_LOG_ITEM_PIN))
++ return XFS_ITEM_PINNED;
++
++ return lip->li_ops->iop_push(lip, &ailp->xa_buf_list);
++}
++
+ static long
+ xfsaild_push(
+ struct xfs_ail *ailp)
+@@ -382,7 +397,7 @@ xfsaild_push(
+ * rely on the AIL cursor implementation to be able to deal with
+ * the dropped lock.
+ */
+- lock_result = lip->li_ops->iop_push(lip, &ailp->xa_buf_list);
++ lock_result = xfsaild_push_item(ailp, lip);
+ switch (lock_result) {
+ case XFS_ITEM_SUCCESS:
+ XFS_STATS_INC(mp, xs_push_ail_success);
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-buffer-lru-reference-count-error-injection-tag.patch b/patches.fixes/xfs-buffer-lru-reference-count-error-injection-tag.patch
new file mode 100644
index 0000000000..8f22bc056d
--- /dev/null
+++ b/patches.fixes/xfs-buffer-lru-reference-count-error-injection-tag.patch
@@ -0,0 +1,137 @@
+From 7561d27e90fa0df0aac2a1d6b49c2a28eaae7026 Mon Sep 17 00:00:00 2001
+From: Brian Foster <bfoster@redhat.com>
+Date: Tue, 17 Oct 2017 14:16:29 -0700
+Subject: [PATCH] xfs: buffer lru reference count error injection tag
+Git-commit: 7561d27e90fa0df0aac2a1d6b49c2a28eaae7026
+Patch-mainline: v4.15-rc1
+References: bsc#1114427
+
+XFS uses a fixed reference count for certain types of buffers in the
+internal LRU cache. These reference counts dictate how aggressively
+certain buffers are reclaimed vs. others. While the reference counts
+implements priority across different buffer types, all buffers
+(other than uncached buffers) are typically cached for at least one
+reclaim cycle.
+
+We've had at least one bug recently that has been hidden by a
+released buffer sitting around in the LRU. Users hitting the problem
+were able to reproduce under enough memory pressure to cause
+aggressive reclaim in a particular window of time.
+
+To support future xfstests cases, add an error injection tag to
+hardcode the buffer reference count to zero. When enabled, this
+bypasses caching of associated buffers and facilitates test cases
+that depend on this behavior.
+
+Signed-off-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_buf.c | 16 ++++++++++++++++
+ fs/xfs/xfs_buf.h | 5 +----
+ fs/xfs/xfs_error.c | 3 +++
+ fs/xfs/xfs_error.h | 4 +++-
+ 4 files changed, 23 insertions(+), 5 deletions(-)
+
+diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
+index 2f97c12ca75e..d481dd2b29a6 100644
+--- a/fs/xfs/xfs_buf.c
++++ b/fs/xfs/xfs_buf.c
+@@ -42,6 +42,7 @@
+ #include "xfs_mount.h"
+ #include "xfs_trace.h"
+ #include "xfs_log.h"
++#include "xfs_error.h"
+
+ static kmem_zone_t *xfs_buf_zone;
+
+@@ -2129,3 +2130,18 @@ xfs_buf_terminate(void)
+ {
+ kmem_zone_destroy(xfs_buf_zone);
+ }
++
++void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
++{
++ struct xfs_mount *mp = bp->b_target->bt_mount;
++
++ /*
++ * Set the lru reference count to 0 based on the error injection tag.
++ * This allows userspace to disrupt buffer caching for debug/testing
++ * purposes.
++ */
++ if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BUF_LRU_REF))
++ lru_ref = 0;
++
++ atomic_set(&bp->b_lru_ref, lru_ref);
++}
+diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
+index bf71507ddb16..f873bb786824 100644
+--- a/fs/xfs/xfs_buf.h
++++ b/fs/xfs/xfs_buf.h
+@@ -352,10 +352,7 @@ extern void xfs_buf_terminate(void);
+ #define XFS_BUF_ADDR(bp) ((bp)->b_maps[0].bm_bn)
+ #define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_maps[0].bm_bn = (xfs_daddr_t)(bno))
+
+-static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
+-{
+- atomic_set(&bp->b_lru_ref, lru_ref);
+-}
++void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref);
+
+ static inline int xfs_buf_ispinned(struct xfs_buf *bp)
+ {
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index eaf86f55b7f2..6732b0a0d826 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -58,6 +58,7 @@ static unsigned int xfs_errortag_random_default[] = {
+ XFS_RANDOM_DROP_WRITES,
+ XFS_RANDOM_LOG_BAD_CRC,
+ XFS_RANDOM_LOG_ITEM_PIN,
++ XFS_RANDOM_BUF_LRU_REF,
+ };
+
+ struct xfs_errortag_attr {
+@@ -163,6 +164,7 @@ XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
+ XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
+ XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
+ XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
++XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF);
+
+ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(noerror),
+@@ -196,6 +198,7 @@ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(drop_writes),
+ XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
+ XFS_ERRORTAG_ATTR_LIST(log_item_pin),
++ XFS_ERRORTAG_ATTR_LIST(buf_lru_ref),
+ NULL,
+ };
+
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index 7c4bef3bddb7..78a7f43f8d01 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -107,7 +107,8 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_ERRTAG_DROP_WRITES 28
+ #define XFS_ERRTAG_LOG_BAD_CRC 29
+ #define XFS_ERRTAG_LOG_ITEM_PIN 30
+-#define XFS_ERRTAG_MAX 31
++#define XFS_ERRTAG_BUF_LRU_REF 31
++#define XFS_ERRTAG_MAX 32
+
+ /*
+ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+@@ -143,6 +144,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_RANDOM_DROP_WRITES 1
+ #define XFS_RANDOM_LOG_BAD_CRC 1
+ #define XFS_RANDOM_LOG_ITEM_PIN 1
++#define XFS_RANDOM_BUF_LRU_REF 2
+
+ #ifdef DEBUG
+ extern int xfs_errortag_init(struct xfs_mount *mp);
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-convert-drop_writes-to-use-the-errortag-mechanis.patch b/patches.fixes/xfs-convert-drop_writes-to-use-the-errortag-mechanis.patch
new file mode 100644
index 0000000000..6381bef09e
--- /dev/null
+++ b/patches.fixes/xfs-convert-drop_writes-to-use-the-errortag-mechanis.patch
@@ -0,0 +1,194 @@
+From f8c47250ba46eb221d1ac537266ac65bcf2866d5 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 20 Jun 2017 17:54:48 -0700
+Subject: [PATCH] xfs: convert drop_writes to use the errortag mechanism
+Git-commit: f8c47250ba46eb221d1ac537266ac65bcf2866d5
+Patch-mainline: v4.13-rc1
+References: bsc#1114427
+
+We now have enhanced error injection that can control the frequency
+with which errors happen, so convert drop_writes to use this.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_error.c | 3 +++
+ fs/xfs/xfs_error.h | 12 +++++++++++-
+ fs/xfs/xfs_iomap.c | 2 +-
+ fs/xfs/xfs_mount.h | 24 ------------------------
+ fs/xfs/xfs_sysfs.c | 42 ------------------------------------------
+ 5 files changed, 15 insertions(+), 68 deletions(-)
+
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index e2278af6aed1..a2f23d2bab16 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -55,6 +55,7 @@ static unsigned int xfs_errortag_random_default[] = {
+ XFS_RANDOM_REFCOUNT_FINISH_ONE,
+ XFS_RANDOM_BMAP_FINISH_ONE,
+ XFS_RANDOM_AG_RESV_CRITICAL,
++ XFS_RANDOM_DROP_WRITES,
+ };
+
+ struct xfs_errortag_attr {
+@@ -157,6 +158,7 @@ XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDA
+ XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
+ XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
+ XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
++XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
+
+ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(noerror),
+@@ -187,6 +189,7 @@ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
+ XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
+ XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
++ XFS_ERRORTAG_ATTR_LIST(drop_writes),
+ NULL,
+ };
+
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index ae8935b90a93..e0e4cf776fac 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -96,7 +96,16 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25
+ #define XFS_ERRTAG_BMAP_FINISH_ONE 26
+ #define XFS_ERRTAG_AG_RESV_CRITICAL 27
+-#define XFS_ERRTAG_MAX 28
++/*
++ * DEBUG mode instrumentation to test and/or trigger delayed allocation
++ * block killing in the event of failed writes. When enabled, all
++ * buffered writes are silenty dropped and handled as if they failed.
++ * All delalloc blocks in the range of the write (including pre-existing
++ * delalloc blocks!) are tossed as part of the write failure error
++ * handling sequence.
++ */
++#define XFS_ERRTAG_DROP_WRITES 28
++#define XFS_ERRTAG_MAX 29
+
+ /*
+ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+@@ -129,6 +138,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
+ #define XFS_RANDOM_BMAP_FINISH_ONE 1
+ #define XFS_RANDOM_AG_RESV_CRITICAL 4
++#define XFS_RANDOM_DROP_WRITES 1
+
+ #ifdef DEBUG
+ extern int xfs_errortag_init(struct xfs_mount *mp);
+diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
+index 304b79d681e4..86f1a9fa46d2 100644
+--- a/fs/xfs/xfs_iomap.c
++++ b/fs/xfs/xfs_iomap.c
+@@ -1097,7 +1097,7 @@ xfs_file_iomap_end_delalloc(
+ * Behave as if the write failed if drop writes is enabled. Set the NEW
+ * flag to force delalloc cleanup.
+ */
+- if (xfs_mp_drop_writes(mp)) {
++ if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DROP_WRITES)) {
+ iomap->flags |= IOMAP_F_NEW;
+ written = 0;
+ }
+diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
+index 931e9fc21a1c..e0792d036be2 100644
+--- a/fs/xfs/xfs_mount.h
++++ b/fs/xfs/xfs_mount.h
+@@ -205,16 +205,6 @@ typedef struct xfs_mount {
+ */
+ unsigned int *m_errortag;
+ struct xfs_kobj m_errortag_kobj;
+-
+- /*
+- * DEBUG mode instrumentation to test and/or trigger delayed allocation
+- * block killing in the event of failed writes. When enabled, all
+- * buffered writes are silenty dropped and handled as if they failed.
+- * All delalloc blocks in the range of the write (including pre-existing
+- * delalloc blocks!) are tossed as part of the write failure error
+- * handling sequence.
+- */
+- bool m_drop_writes;
+ #endif
+ } xfs_mount_t;
+
+@@ -333,20 +323,6 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
+ return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
+ }
+
+-#ifdef DEBUG
+-static inline bool
+-xfs_mp_drop_writes(struct xfs_mount *mp)
+-{
+- return mp->m_drop_writes;
+-}
+-#else
+-static inline bool
+-xfs_mp_drop_writes(struct xfs_mount *mp)
+-{
+- return 0;
+-}
+-#endif
+-
+ /* per-AG block reservation data structures*/
+ enum xfs_ag_resv_type {
+ XFS_AG_RESV_NONE = 0,
+diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
+index ec6e0e2f95d6..56610a973593 100644
+--- a/fs/xfs/xfs_sysfs.c
++++ b/fs/xfs/xfs_sysfs.c
+@@ -90,49 +90,7 @@ to_mp(struct kobject *kobject)
+ return container_of(kobj, struct xfs_mount, m_kobj);
+ }
+
+-#ifdef DEBUG
+-
+-STATIC ssize_t
+-drop_writes_store(
+- struct kobject *kobject,
+- const char *buf,
+- size_t count)
+-{
+- struct xfs_mount *mp = to_mp(kobject);
+- int ret;
+- int val;
+-
+- ret = kstrtoint(buf, 0, &val);
+- if (ret)
+- return ret;
+-
+- if (val == 1)
+- mp->m_drop_writes = true;
+- else if (val == 0)
+- mp->m_drop_writes = false;
+- else
+- return -EINVAL;
+-
+- return count;
+-}
+-
+-STATIC ssize_t
+-drop_writes_show(
+- struct kobject *kobject,
+- char *buf)
+-{
+- struct xfs_mount *mp = to_mp(kobject);
+-
+- return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_drop_writes ? 1 : 0);
+-}
+-XFS_SYSFS_ATTR_RW(drop_writes);
+-
+-#endif /* DEBUG */
+-
+ static struct attribute *xfs_mp_attrs[] = {
+-#ifdef DEBUG
+- ATTR_LIST(drop_writes),
+-#endif
+ NULL,
+ };
+
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-create-inode-pointer-verifiers.patch b/patches.fixes/xfs-create-inode-pointer-verifiers.patch
new file mode 100644
index 0000000000..63a7eb4284
--- /dev/null
+++ b/patches.fixes/xfs-create-inode-pointer-verifiers.patch
@@ -0,0 +1,212 @@
+From 91fb9afc0847926ef6ea7695b8125c8fbe7974d6 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 17 Oct 2017 21:37:34 -0700
+Subject: [PATCH] xfs: create inode pointer verifiers
+Git-commit: 91fb9afc0847926ef6ea7695b8125c8fbe7974d6
+Patch-mainline: v4.15-rc1
+References: bsc#1114427
+
+Create some helper functions to check that inode pointers point to
+somewhere within the filesystem and not at the static AG metadata.
+Move xfs_internal_inum and create a directory inode check function.
+We will use these functions in scrub and elsewhere.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Dave Chinner <dchinner@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_dir2.c | 19 ++--------
+ fs/xfs/libxfs/xfs_ialloc.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++
+ fs/xfs/libxfs/xfs_ialloc.h | 7 ++++
+ fs/xfs/xfs_itable.c | 10 ------
+ fs/xfs/xfs_itable.h | 2 --
+ 5 files changed, 100 insertions(+), 28 deletions(-)
+
+diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
+index ccf9783fd3f0..ee5e9160eb01 100644
+--- a/fs/xfs/libxfs/xfs_dir2.c
++++ b/fs/xfs/libxfs/xfs_dir2.c
+@@ -30,6 +30,7 @@
+ #include "xfs_bmap.h"
+ #include "xfs_dir2.h"
+ #include "xfs_dir2_priv.h"
++#include "xfs_ialloc.h"
+ #include "xfs_error.h"
+ #include "xfs_trace.h"
+
+@@ -202,22 +203,8 @@ xfs_dir_ino_validate(
+ xfs_mount_t *mp,
+ xfs_ino_t ino)
+ {
+- xfs_agblock_t agblkno;
+- xfs_agino_t agino;
+- xfs_agnumber_t agno;
+- int ino_ok;
+- int ioff;
+-
+- agno = XFS_INO_TO_AGNO(mp, ino);
+- agblkno = XFS_INO_TO_AGBNO(mp, ino);
+- ioff = XFS_INO_TO_OFFSET(mp, ino);
+- agino = XFS_OFFBNO_TO_AGINO(mp, agblkno, ioff);
+- ino_ok =
+- agno < mp->m_sb.sb_agcount &&
+- agblkno < mp->m_sb.sb_agblocks &&
+- agblkno != 0 &&
+- ioff < (1 << mp->m_sb.sb_inopblog) &&
+- XFS_AGINO_TO_INO(mp, agno, agino) == ino;
++ bool ino_ok = xfs_verify_dir_ino(mp, ino);
++
+ if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE))) {
+ xfs_warn(mp, "Invalid inode number 0x%Lx",
+ (unsigned long long) ino);
+diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
+index dfd643909f85..e11f8af8a725 100644
+--- a/fs/xfs/libxfs/xfs_ialloc.c
++++ b/fs/xfs/libxfs/xfs_ialloc.c
+@@ -2664,3 +2664,93 @@ xfs_ialloc_pagi_init(
+ xfs_trans_brelse(tp, bp);
+ return 0;
+ }
++
++/* Calculate the first and last possible inode number in an AG. */
++void
++xfs_ialloc_agino_range(
++ struct xfs_mount *mp,
++ xfs_agnumber_t agno,
++ xfs_agino_t *first,
++ xfs_agino_t *last)
++{
++ xfs_agblock_t bno;
++ xfs_agblock_t eoag;
++
++ eoag = xfs_ag_block_count(mp, agno);
++
++ /*
++ * Calculate the first inode, which will be in the first
++ * cluster-aligned block after the AGFL.
++ */
++ bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
++ xfs_ialloc_cluster_alignment(mp));
++ *first = XFS_OFFBNO_TO_AGINO(mp, bno, 0);
++
++ /*
++ * Calculate the last inode, which will be at the end of the
++ * last (aligned) cluster that can be allocated in the AG.
++ */
++ bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp));
++ *last = XFS_OFFBNO_TO_AGINO(mp, bno, 0) - 1;
++}
++
++/*
++ * Verify that an AG inode number pointer neither points outside the AG
++ * nor points at static metadata.
++ */
++bool
++xfs_verify_agino(
++ struct xfs_mount *mp,
++ xfs_agnumber_t agno,
++ xfs_agino_t agino)
++{
++ xfs_agino_t first;
++ xfs_agino_t last;
++
++ xfs_ialloc_agino_range(mp, agno, &first, &last);
++ return agino >= first && agino <= last;
++}
++
++/*
++ * Verify that an FS inode number pointer neither points outside the
++ * filesystem nor points at static AG metadata.
++ */
++bool
++xfs_verify_ino(
++ struct xfs_mount *mp,
++ xfs_ino_t ino)
++{
++ xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ino);
++ xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino);
++
++ if (agno >= mp->m_sb.sb_agcount)
++ return false;
++ if (XFS_AGINO_TO_INO(mp, agno, agino) != ino)
++ return false;
++ return xfs_verify_agino(mp, agno, agino);
++}
++
++/* Is this an internal inode number? */
++bool
++xfs_internal_inum(
++ struct xfs_mount *mp,
++ xfs_ino_t ino)
++{
++ return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
++ (xfs_sb_version_hasquota(&mp->m_sb) &&
++ xfs_is_quota_inode(&mp->m_sb, ino));
++}
++
++/*
++ * Verify that a directory entry's inode number doesn't point at an internal
++ * inode, empty space, or static AG metadata.
++ */
++bool
++xfs_verify_dir_ino(
++ struct xfs_mount *mp,
++ xfs_ino_t ino)
++{
++ if (xfs_internal_inum(mp, ino))
++ return false;
++ return xfs_verify_ino(mp, ino);
++}
+diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
+index b32cfb5aeb5b..d2bdcd5e7312 100644
+--- a/fs/xfs/libxfs/xfs_ialloc.h
++++ b/fs/xfs/libxfs/xfs_ialloc.h
+@@ -173,5 +173,12 @@ void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
+ struct xfs_inobt_rec_incore *irec);
+
+ int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
++void xfs_ialloc_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
++ xfs_agino_t *first, xfs_agino_t *last);
++bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
++ xfs_agino_t agino);
++bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
++bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
++bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
+
+ #endif /* __XFS_IALLOC_H__ */
+diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
+index c393a2f6d8c3..0172d0b72c95 100644
+--- a/fs/xfs/xfs_itable.c
++++ b/fs/xfs/xfs_itable.c
+@@ -31,16 +31,6 @@
+ #include "xfs_trace.h"
+ #include "xfs_icache.h"
+
+-int
+-xfs_internal_inum(
+- xfs_mount_t *mp,
+- xfs_ino_t ino)
+-{
+- return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
+- (xfs_sb_version_hasquota(&mp->m_sb) &&
+- xfs_is_quota_inode(&mp->m_sb, ino)));
+-}
+-
+ /*
+ * Return stat information for one inode.
+ * Return 0 if ok, else errno.
+diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
+index 17e86e0541af..6ea8b3912fa4 100644
+--- a/fs/xfs/xfs_itable.h
++++ b/fs/xfs/xfs_itable.h
+@@ -96,6 +96,4 @@ xfs_inumbers(
+ void __user *buffer, /* buffer with inode info */
+ inumbers_fmt_pf formatter);
+
+-int xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
+-
+ #endif /* __XFS_ITABLE_H__ */
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-export-_inobt_btrec_to_irec-and-_ialloc_cluster_.patch b/patches.fixes/xfs-export-_inobt_btrec_to_irec-and-_ialloc_cluster_.patch
new file mode 100644
index 0000000000..3ec898a8d9
--- /dev/null
+++ b/patches.fixes/xfs-export-_inobt_btrec_to_irec-and-_ialloc_cluster_.patch
@@ -0,0 +1,111 @@
+From e936945ee49693f40217db82a7db55c94e34ce4c Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Fri, 16 Jun 2017 11:00:08 -0700
+Subject: [PATCH] xfs: export _inobt_btrec_to_irec and
+ _ialloc_cluster_alignment for scrub
+Git-commit: e936945ee49693f40217db82a7db55c94e34ce4c
+Patch-mainline: v4.13-rc1
+References: bsc#1114427
+
+Create a function to extract an in-core inobt record from a generic
+btree_rec union so that scrub will be able to check inobt records
+and check inode block alignment.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Brian Foster <bfoster@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_ialloc.c | 44 +++++++++++++++++++++++++++-----------------
+ fs/xfs/libxfs/xfs_ialloc.h | 5 +++++
+ 2 files changed, 32 insertions(+), 17 deletions(-)
+
+diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
+index 1e5ed940b84d..c514fe98bbab 100644
+--- a/fs/xfs/libxfs/xfs_ialloc.c
++++ b/fs/xfs/libxfs/xfs_ialloc.c
+@@ -46,7 +46,7 @@
+ /*
+ * Allocation group level functions.
+ */
+-static inline int
++int
+ xfs_ialloc_cluster_alignment(
+ struct xfs_mount *mp)
+ {
+@@ -98,24 +98,15 @@ xfs_inobt_update(
+ return xfs_btree_update(cur, &rec);
+ }
+
+-/*
+- * Get the data from the pointed-to record.
+- */
+-int /* error */
+-xfs_inobt_get_rec(
+- struct xfs_btree_cur *cur, /* btree cursor */
+- xfs_inobt_rec_incore_t *irec, /* btree record */
+- int *stat) /* output: success/failure */
++/* Convert on-disk btree record to incore inobt record. */
++void
++xfs_inobt_btrec_to_irec(
++ struct xfs_mount *mp,
++ union xfs_btree_rec *rec,
++ struct xfs_inobt_rec_incore *irec)
+ {
+- union xfs_btree_rec *rec;
+- int error;
+-
+- error = xfs_btree_get_rec(cur, &rec, stat);
+- if (error || *stat == 0)
+- return error;
+-
+ irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino);
+- if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) {
++ if (xfs_sb_version_hassparseinodes(&mp->m_sb)) {
+ irec->ir_holemask = be16_to_cpu(rec->inobt.ir_u.sp.ir_holemask);
+ irec->ir_count = rec->inobt.ir_u.sp.ir_count;
+ irec->ir_freecount = rec->inobt.ir_u.sp.ir_freecount;
+@@ -130,6 +121,25 @@ xfs_inobt_get_rec(
+ be32_to_cpu(rec->inobt.ir_u.f.ir_freecount);
+ }
+ irec->ir_free = be64_to_cpu(rec->inobt.ir_free);
++}
++
++/*
++ * Get the data from the pointed-to record.
++ */
++int
++xfs_inobt_get_rec(
++ struct xfs_btree_cur *cur,
++ struct xfs_inobt_rec_incore *irec,
++ int *stat)
++{
++ union xfs_btree_rec *rec;
++ int error;
++
++ error = xfs_btree_get_rec(cur, &rec, stat);
++ if (error || *stat == 0)
++ return error;
++
++ xfs_inobt_btrec_to_irec(cur->bc_mp, rec, irec);
+
+ return 0;
+ }
+diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
+index 0bb89669fc07..b32cfb5aeb5b 100644
+--- a/fs/xfs/libxfs/xfs_ialloc.h
++++ b/fs/xfs/libxfs/xfs_ialloc.h
+@@ -168,5 +168,10 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
+ int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
+ xfs_agnumber_t agno, struct xfs_buf **bpp);
+
++union xfs_btree_rec;
++void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
++ struct xfs_inobt_rec_incore *irec);
++
++int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
+
+ #endif /* __XFS_IALLOC_H__ */
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-expose-errortag-knobs-via-sysfs.patch b/patches.fixes/xfs-expose-errortag-knobs-via-sysfs.patch
new file mode 100644
index 0000000000..0b86e0b326
--- /dev/null
+++ b/patches.fixes/xfs-expose-errortag-knobs-via-sysfs.patch
@@ -0,0 +1,244 @@
+From c684010115221978b17968dbddc8e31a09da85e7 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 20 Jun 2017 17:54:47 -0700
+Subject: [PATCH] xfs: expose errortag knobs via sysfs
+Git-commit: c684010115221978b17968dbddc8e31a09da85e7
+Patch-mainline: v4.13-rc1
+References: bsc#1114427
+
+Creates a /sys/fs/xfs/$dev/errortag/ directory to control the errortag
+values directly. This enables us to control the randomness values,
+rather than having to accept the defaults.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_error.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
+ fs/xfs/xfs_error.h | 1 +
+ fs/xfs/xfs_mount.h | 1 +
+ 3 files changed, 157 insertions(+), 1 deletion(-)
+
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index 52f75bc1abac..e2278af6aed1 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -22,6 +22,7 @@
+ #include "xfs_trans_resv.h"
+ #include "xfs_mount.h"
+ #include "xfs_error.h"
++#include "xfs_sysfs.h"
+
+ #ifdef DEBUG
+
+@@ -56,6 +57,145 @@ static unsigned int xfs_errortag_random_default[] = {
+ XFS_RANDOM_AG_RESV_CRITICAL,
+ };
+
++struct xfs_errortag_attr {
++ struct attribute attr;
++ unsigned int tag;
++};
++
++static inline struct xfs_errortag_attr *
++to_attr(struct attribute *attr)
++{
++ return container_of(attr, struct xfs_errortag_attr, attr);
++}
++
++static inline struct xfs_mount *
++to_mp(struct kobject *kobject)
++{
++ struct xfs_kobj *kobj = to_kobj(kobject);
++
++ return container_of(kobj, struct xfs_mount, m_errortag_kobj);
++}
++
++STATIC ssize_t
++xfs_errortag_attr_store(
++ struct kobject *kobject,
++ struct attribute *attr,
++ const char *buf,
++ size_t count)
++{
++ struct xfs_mount *mp = to_mp(kobject);
++ struct xfs_errortag_attr *xfs_attr = to_attr(attr);
++ int ret;
++ unsigned int val;
++
++ if (strcmp(buf, "default") == 0) {
++ val = xfs_errortag_random_default[xfs_attr->tag];
++ } else {
++ ret = kstrtouint(buf, 0, &val);
++ if (ret)
++ return ret;
++ }
++
++ ret = xfs_errortag_set(mp, xfs_attr->tag, val);
++ if (ret)
++ return ret;
++ return count;
++}
++
++STATIC ssize_t
++xfs_errortag_attr_show(
++ struct kobject *kobject,
++ struct attribute *attr,
++ char *buf)
++{
++ struct xfs_mount *mp = to_mp(kobject);
++ struct xfs_errortag_attr *xfs_attr = to_attr(attr);
++
++ return snprintf(buf, PAGE_SIZE, "%u\n",
++ xfs_errortag_get(mp, xfs_attr->tag));
++}
++
++static const struct sysfs_ops xfs_errortag_sysfs_ops = {
++ .show = xfs_errortag_attr_show,
++ .store = xfs_errortag_attr_store,
++};
++
++#define XFS_ERRORTAG_ATTR_RW(_name, _tag) \
++static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \
++ .attr = {.name = __stringify(_name), \
++ .mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \
++ .tag = (_tag), \
++}
++
++#define XFS_ERRORTAG_ATTR_LIST(_name) &xfs_errortag_attr_##_name.attr
++
++XFS_ERRORTAG_ATTR_RW(noerror, XFS_ERRTAG_NOERROR);
++XFS_ERRORTAG_ATTR_RW(iflush1, XFS_ERRTAG_IFLUSH_1);
++XFS_ERRORTAG_ATTR_RW(iflush2, XFS_ERRTAG_IFLUSH_2);
++XFS_ERRORTAG_ATTR_RW(iflush3, XFS_ERRTAG_IFLUSH_3);
++XFS_ERRORTAG_ATTR_RW(iflush4, XFS_ERRTAG_IFLUSH_4);
++XFS_ERRORTAG_ATTR_RW(iflush5, XFS_ERRTAG_IFLUSH_5);
++XFS_ERRORTAG_ATTR_RW(iflush6, XFS_ERRTAG_IFLUSH_6);
++XFS_ERRORTAG_ATTR_RW(dareadbuf, XFS_ERRTAG_DA_READ_BUF);
++XFS_ERRORTAG_ATTR_RW(btree_chk_lblk, XFS_ERRTAG_BTREE_CHECK_LBLOCK);
++XFS_ERRORTAG_ATTR_RW(btree_chk_sblk, XFS_ERRTAG_BTREE_CHECK_SBLOCK);
++XFS_ERRORTAG_ATTR_RW(readagf, XFS_ERRTAG_ALLOC_READ_AGF);
++XFS_ERRORTAG_ATTR_RW(readagi, XFS_ERRTAG_IALLOC_READ_AGI);
++XFS_ERRORTAG_ATTR_RW(itobp, XFS_ERRTAG_ITOBP_INOTOBP);
++XFS_ERRORTAG_ATTR_RW(iunlink, XFS_ERRTAG_IUNLINK);
++XFS_ERRORTAG_ATTR_RW(iunlinkrm, XFS_ERRTAG_IUNLINK_REMOVE);
++XFS_ERRORTAG_ATTR_RW(dirinovalid, XFS_ERRTAG_DIR_INO_VALIDATE);
++XFS_ERRORTAG_ATTR_RW(bulkstat, XFS_ERRTAG_BULKSTAT_READ_CHUNK);
++XFS_ERRORTAG_ATTR_RW(logiodone, XFS_ERRTAG_IODONE_IOERR);
++XFS_ERRORTAG_ATTR_RW(stratread, XFS_ERRTAG_STRATREAD_IOERR);
++XFS_ERRORTAG_ATTR_RW(stratcmpl, XFS_ERRTAG_STRATCMPL_IOERR);
++XFS_ERRORTAG_ATTR_RW(diowrite, XFS_ERRTAG_DIOWRITE_IOERR);
++XFS_ERRORTAG_ATTR_RW(bmapifmt, XFS_ERRTAG_BMAPIFORMAT);
++XFS_ERRORTAG_ATTR_RW(free_extent, XFS_ERRTAG_FREE_EXTENT);
++XFS_ERRORTAG_ATTR_RW(rmap_finish_one, XFS_ERRTAG_RMAP_FINISH_ONE);
++XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE);
++XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
++XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
++XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
++
++static struct attribute *xfs_errortag_attrs[] = {
++ XFS_ERRORTAG_ATTR_LIST(noerror),
++ XFS_ERRORTAG_ATTR_LIST(iflush1),
++ XFS_ERRORTAG_ATTR_LIST(iflush2),
++ XFS_ERRORTAG_ATTR_LIST(iflush3),
++ XFS_ERRORTAG_ATTR_LIST(iflush4),
++ XFS_ERRORTAG_ATTR_LIST(iflush5),
++ XFS_ERRORTAG_ATTR_LIST(iflush6),
++ XFS_ERRORTAG_ATTR_LIST(dareadbuf),
++ XFS_ERRORTAG_ATTR_LIST(btree_chk_lblk),
++ XFS_ERRORTAG_ATTR_LIST(btree_chk_sblk),
++ XFS_ERRORTAG_ATTR_LIST(readagf),
++ XFS_ERRORTAG_ATTR_LIST(readagi),
++ XFS_ERRORTAG_ATTR_LIST(itobp),
++ XFS_ERRORTAG_ATTR_LIST(iunlink),
++ XFS_ERRORTAG_ATTR_LIST(iunlinkrm),
++ XFS_ERRORTAG_ATTR_LIST(dirinovalid),
++ XFS_ERRORTAG_ATTR_LIST(bulkstat),
++ XFS_ERRORTAG_ATTR_LIST(logiodone),
++ XFS_ERRORTAG_ATTR_LIST(stratread),
++ XFS_ERRORTAG_ATTR_LIST(stratcmpl),
++ XFS_ERRORTAG_ATTR_LIST(diowrite),
++ XFS_ERRORTAG_ATTR_LIST(bmapifmt),
++ XFS_ERRORTAG_ATTR_LIST(free_extent),
++ XFS_ERRORTAG_ATTR_LIST(rmap_finish_one),
++ XFS_ERRORTAG_ATTR_LIST(refcount_continue_update),
++ XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
++ XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
++ XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
++ NULL,
++};
++
++struct kobj_type xfs_errortag_ktype = {
++ .release = xfs_sysfs_release,
++ .sysfs_ops = &xfs_errortag_sysfs_ops,
++ .default_attrs = xfs_errortag_attrs,
++};
++
+ int
+ xfs_errortag_init(
+ struct xfs_mount *mp)
+@@ -64,13 +204,16 @@ xfs_errortag_init(
+ KM_SLEEP | KM_MAYFAIL);
+ if (!mp->m_errortag)
+ return -ENOMEM;
+- return 0;
++
++ return xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype,
++ &mp->m_kobj, "errortag");
+ }
+
+ void
+ xfs_errortag_del(
+ struct xfs_mount *mp)
+ {
++ xfs_sysfs_del(&mp->m_errortag_kobj);
+ kmem_free(mp->m_errortag);
+ }
+
+@@ -95,6 +238,17 @@ xfs_errortag_test(
+ return true;
+ }
+
++int
++xfs_errortag_get(
++ struct xfs_mount *mp,
++ unsigned int error_tag)
++{
++ if (error_tag >= XFS_ERRTAG_MAX)
++ return -EINVAL;
++
++ return mp->m_errortag[error_tag];
++}
++
+ int
+ xfs_errortag_set(
+ struct xfs_mount *mp,
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index b4316d39e1ca..8915bdeb6128 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -138,6 +138,7 @@ extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
+ #define XFS_TEST_ERROR(expr, mp, tag, rf) \
+ ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
+
++extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
+ extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
+ unsigned int tag_value);
+ extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
+diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
+index e002ac52a4e6..931e9fc21a1c 100644
+--- a/fs/xfs/xfs_mount.h
++++ b/fs/xfs/xfs_mount.h
+@@ -204,6 +204,7 @@ typedef struct xfs_mount {
+ * error triggers. 1 = always, 2 = half the time, etc.
+ */
+ unsigned int *m_errortag;
++ struct xfs_kobj m_errortag_kobj;
+
+ /*
+ * DEBUG mode instrumentation to test and/or trigger delayed allocation
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-fix-unused-variable-warning-in-xfs_buf_set_ref.patch b/patches.fixes/xfs-fix-unused-variable-warning-in-xfs_buf_set_ref.patch
new file mode 100644
index 0000000000..97eaa8e2b2
--- /dev/null
+++ b/patches.fixes/xfs-fix-unused-variable-warning-in-xfs_buf_set_ref.patch
@@ -0,0 +1,45 @@
+From 4eadcf9a417a4689e596e3c2a99857c2e3603049 Mon Sep 17 00:00:00 2001
+From: Brian Foster <bfoster@redhat.com>
+Date: Fri, 27 Oct 2017 09:20:28 -0700
+Subject: [PATCH] xfs: fix unused variable warning in xfs_buf_set_ref()
+Git-commit: 4eadcf9a417a4689e596e3c2a99857c2e3603049
+Patch-mainline: v4.15-rc1
+References: bsc#1114427
+
+Fix an unused variable warning on non-DEBUG builds introduced by
+commit 7561d27e90 ("xfs: buffer lru reference count error injection
+tag").
+
+Signed-off-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_buf.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
+index d481dd2b29a6..db786bce7c03 100644
+--- a/fs/xfs/xfs_buf.c
++++ b/fs/xfs/xfs_buf.c
+@@ -2133,14 +2133,13 @@ xfs_buf_terminate(void)
+
+ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
+ {
+- struct xfs_mount *mp = bp->b_target->bt_mount;
+-
+ /*
+ * Set the lru reference count to 0 based on the error injection tag.
+ * This allows userspace to disrupt buffer caching for debug/testing
+ * purposes.
+ */
+- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BUF_LRU_REF))
++ if (XFS_TEST_ERROR(false, bp->b_target->bt_mount,
++ XFS_ERRTAG_BUF_LRU_REF))
+ lru_ref = 0;
+
+ atomic_set(&bp->b_lru_ref, lru_ref);
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-force-summary-counter-recalc-at-next-mount.patch b/patches.fixes/xfs-force-summary-counter-recalc-at-next-mount.patch
new file mode 100644
index 0000000000..dc4f88542c
--- /dev/null
+++ b/patches.fixes/xfs-force-summary-counter-recalc-at-next-mount.patch
@@ -0,0 +1,131 @@
+From f467cad95f5e3814fda408dea76eb962ab19685d Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Fri, 20 Jul 2018 09:28:40 -0700
+Subject: [PATCH] xfs: force summary counter recalc at next mount
+Git-commit: f467cad95f5e3814fda408dea76eb962ab19685d
+Patch-mainline: v4.19-rc1
+References: bsc#1114427
+
+Use the "bad summary count" mount flag from the previous patch to skip
+writing the unmount record to force log recovery at the next mount,
+which will recalculate the summary counters for us.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_errortag.h | 4 +++-
+ fs/xfs/xfs_error.c | 3 +++
+ fs/xfs/xfs_log.c | 16 +++++++++++++++-
+ fs/xfs/xfs_mount.c | 13 +++++++++++++
+ fs/xfs/xfs_mount.h | 1 +
+ 5 files changed, 35 insertions(+), 2 deletions(-)
+
+--- a/fs/xfs/libxfs/xfs_errortag.h
++++ b/fs/xfs/libxfs/xfs_errortag.h
+@@ -65,7 +65,8 @@
+ #define XFS_ERRTAG_LOG_BAD_CRC 29
+ #define XFS_ERRTAG_LOG_ITEM_PIN 30
+ #define XFS_ERRTAG_BUF_LRU_REF 31
+-#define XFS_ERRTAG_MAX 32
++#define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33
++#define XFS_ERRTAG_MAX 34
+
+ /*
+ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+@@ -102,5 +103,6 @@
+ #define XFS_RANDOM_LOG_BAD_CRC 1
+ #define XFS_RANDOM_LOG_ITEM_PIN 1
+ #define XFS_RANDOM_BUF_LRU_REF 2
++#define XFS_RANDOM_FORCE_SUMMARY_RECALC 1
+
+ #endif /* __XFS_ERRORTAG_H_ */
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -60,6 +60,7 @@
+ XFS_RANDOM_LOG_BAD_CRC,
+ XFS_RANDOM_LOG_ITEM_PIN,
+ XFS_RANDOM_BUF_LRU_REF,
++ XFS_RANDOM_FORCE_SUMMARY_RECALC,
+ };
+
+ struct xfs_errortag_attr {
+@@ -166,6 +167,7 @@
+ XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
+ XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
+ XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF);
++XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC);
+
+ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(noerror),
+@@ -200,6 +202,7 @@
+ XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
+ XFS_ERRORTAG_ATTR_LIST(log_item_pin),
+ XFS_ERRORTAG_ATTR_LIST(buf_lru_ref),
++ XFS_ERRORTAG_ATTR_LIST(bad_summary),
+ NULL,
+ };
+
+--- a/fs/xfs/xfs_log.c
++++ b/fs/xfs/xfs_log.c
+@@ -845,16 +845,30 @@
+ struct xlog_in_core *iclog;
+ struct xlog_ticket *tic = NULL;
+ xfs_lsn_t lsn;
++ uint flags = XLOG_UNMOUNT_TRANS;
+ int error;
+
+ error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0);
+ if (error)
+ goto out_err;
+
++ /*
++ * If we think the summary counters are bad, clear the unmount header
++ * flag in the unmount record so that the summary counters will be
++ * recalculated during log recovery at next mount. Refer to
++ * xlog_check_unmount_rec for more details.
++ */
++ if (XFS_TEST_ERROR((mp->m_flags & XFS_MOUNT_BAD_SUMMARY), mp,
++ XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
++ xfs_alert(mp, "%s: will fix summary counters at next mount",
++ __func__);
++ flags &= ~XLOG_UNMOUNT_TRANS;
++ }
++
+ /* remove inited flag, and account for space used */
+ tic->t_flags = 0;
+ tic->t_curr_res -= sizeof(magic);
+- error = xlog_write(log, &vec, tic, &lsn, NULL, XLOG_UNMOUNT_TRANS);
++ error = xlog_write(log, &vec, tic, &lsn, NULL, flags);
+ /*
+ * At this point, we're umounting anyway, so there's no point in
+ * transitioning log state to IOERROR. Just continue...
+--- a/fs/xfs/xfs_mount.c
++++ b/fs/xfs/xfs_mount.c
+@@ -1422,3 +1422,16 @@
+ }
+ return 0;
+ }
++
++/* Force the summary counters to be recalculated at next mount. */
++void
++xfs_force_summary_recalc(
++ struct xfs_mount *mp)
++{
++ if (!xfs_sb_version_haslazysbcount(&mp->m_sb))
++ return;
++
++ spin_lock(&mp->m_sb_lock);
++ mp->m_flags |= XFS_MOUNT_BAD_SUMMARY;
++ spin_unlock(&mp->m_sb_lock);
++}
+--- a/fs/xfs/xfs_mount.h
++++ b/fs/xfs/xfs_mount.h
+@@ -447,5 +447,6 @@
+
+ struct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp,
+ int error_class, int error);
++void xfs_force_summary_recalc(struct xfs_mount *mp);
+
+ #endif /* __XFS_MOUNT_H__ */
diff --git a/patches.fixes/xfs-move-error-injection-tags-into-their-own-file.patch b/patches.fixes/xfs-move-error-injection-tags-into-their-own-file.patch
new file mode 100644
index 0000000000..977d054990
--- /dev/null
+++ b/patches.fixes/xfs-move-error-injection-tags-into-their-own-file.patch
@@ -0,0 +1,425 @@
+From e9e899a2a8c3c23b3084b048466f417ed92286d3 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 31 Oct 2017 12:04:49 -0700
+Subject: [PATCH] xfs: move error injection tags into their own file
+Git-commit: e9e899a2a8c3c23b3084b048466f417ed92286d3
+Patch-mainline: v4.15-rc1
+References: bsc#1114427
+
+Move the error injection tag names into a libxfs header so that we can
+share it between kernel and userspace.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Dave Chinner <dchinner@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_ag_resv.c | 1 +
+ fs/xfs/libxfs/xfs_alloc.c | 1 +
+ fs/xfs/libxfs/xfs_bmap.c | 1 +
+ fs/xfs/libxfs/xfs_btree.c | 1 +
+ fs/xfs/libxfs/xfs_dir2.c | 1 +
+ fs/xfs/libxfs/xfs_errortag.h | 106 ++++++++++++++++++++++++++++++++++++++++++
+ fs/xfs/libxfs/xfs_ialloc.c | 1 +
+ fs/xfs/libxfs/xfs_inode_buf.c | 1 +
+ fs/xfs/libxfs/xfs_refcount.c | 1 +
+ fs/xfs/libxfs/xfs_rmap.c | 1 +
+ fs/xfs/xfs_buf.c | 1 +
+ fs/xfs/xfs_error.c | 1 +
+ fs/xfs/xfs_error.h | 83 ---------------------------------
+ fs/xfs/xfs_inode.c | 1 +
+ fs/xfs/xfs_iomap.c | 1 +
+ fs/xfs/xfs_log.c | 1 +
+ fs/xfs/xfs_trans_ail.c | 1 +
+ 17 files changed, 121 insertions(+), 83 deletions(-)
+ create mode 100644 fs/xfs/libxfs/xfs_errortag.h
+
+diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
+index df3e600835e8..2291f4224e24 100644
+--- a/fs/xfs/libxfs/xfs_ag_resv.c
++++ b/fs/xfs/libxfs/xfs_ag_resv.c
+@@ -27,6 +27,7 @@
+ #include "xfs_mount.h"
+ #include "xfs_defer.h"
+ #include "xfs_alloc.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trace.h"
+ #include "xfs_cksum.h"
+diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
+index 11c01e2668bf..0da80019a917 100644
+--- a/fs/xfs/libxfs/xfs_alloc.c
++++ b/fs/xfs/libxfs/xfs_alloc.c
+@@ -31,6 +31,7 @@
+ #include "xfs_alloc_btree.h"
+ #include "xfs_alloc.h"
+ #include "xfs_extent_busy.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_cksum.h"
+ #include "xfs_trace.h"
+diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
+index f45f05c45e15..ebb5958f1c5c 100644
+--- a/fs/xfs/libxfs/xfs_bmap.c
++++ b/fs/xfs/libxfs/xfs_bmap.c
+@@ -38,6 +38,7 @@
+ #include "xfs_bmap_util.h"
+ #include "xfs_bmap_btree.h"
+ #include "xfs_rtalloc.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_quota.h"
+ #include "xfs_trans_space.h"
+diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
+index 848f3713d73c..994fc1c8c7c6 100644
+--- a/fs/xfs/libxfs/xfs_btree.c
++++ b/fs/xfs/libxfs/xfs_btree.c
+@@ -29,6 +29,7 @@
+ #include "xfs_inode_item.h"
+ #include "xfs_buf_item.h"
+ #include "xfs_btree.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trace.h"
+ #include "xfs_cksum.h"
+diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
+index 41ea6d40bbeb..e10778c102ea 100644
+--- a/fs/xfs/libxfs/xfs_dir2.c
++++ b/fs/xfs/libxfs/xfs_dir2.c
+@@ -31,6 +31,7 @@
+ #include "xfs_dir2.h"
+ #include "xfs_dir2_priv.h"
+ #include "xfs_ialloc.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trace.h"
+
+diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
+new file mode 100644
+index 000000000000..bc1789d95152
+--- /dev/null
++++ b/fs/xfs/libxfs/xfs_errortag.h
+@@ -0,0 +1,106 @@
++/*
++ * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
++ * Copyright (C) 2017 Oracle.
++ * All Rights Reserved.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it would be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
++ */
++#ifndef __XFS_ERRORTAG_H_
++#define __XFS_ERRORTAG_H_
++
++/*
++ * error injection tags - the labels can be anything you want
++ * but each tag should have its own unique number
++ */
++
++#define XFS_ERRTAG_NOERROR 0
++#define XFS_ERRTAG_IFLUSH_1 1
++#define XFS_ERRTAG_IFLUSH_2 2
++#define XFS_ERRTAG_IFLUSH_3 3
++#define XFS_ERRTAG_IFLUSH_4 4
++#define XFS_ERRTAG_IFLUSH_5 5
++#define XFS_ERRTAG_IFLUSH_6 6
++#define XFS_ERRTAG_DA_READ_BUF 7
++#define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
++#define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
++#define XFS_ERRTAG_ALLOC_READ_AGF 10
++#define XFS_ERRTAG_IALLOC_READ_AGI 11
++#define XFS_ERRTAG_ITOBP_INOTOBP 12
++#define XFS_ERRTAG_IUNLINK 13
++#define XFS_ERRTAG_IUNLINK_REMOVE 14
++#define XFS_ERRTAG_DIR_INO_VALIDATE 15
++#define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
++#define XFS_ERRTAG_IODONE_IOERR 17
++#define XFS_ERRTAG_STRATREAD_IOERR 18
++#define XFS_ERRTAG_STRATCMPL_IOERR 19
++#define XFS_ERRTAG_DIOWRITE_IOERR 20
++#define XFS_ERRTAG_BMAPIFORMAT 21
++#define XFS_ERRTAG_FREE_EXTENT 22
++#define XFS_ERRTAG_RMAP_FINISH_ONE 23
++#define XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE 24
++#define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25
++#define XFS_ERRTAG_BMAP_FINISH_ONE 26
++#define XFS_ERRTAG_AG_RESV_CRITICAL 27
++/*
++ * DEBUG mode instrumentation to test and/or trigger delayed allocation
++ * block killing in the event of failed writes. When enabled, all
++ * buffered writes are silenty dropped and handled as if they failed.
++ * All delalloc blocks in the range of the write (including pre-existing
++ * delalloc blocks!) are tossed as part of the write failure error
++ * handling sequence.
++ */
++#define XFS_ERRTAG_DROP_WRITES 28
++#define XFS_ERRTAG_LOG_BAD_CRC 29
++#define XFS_ERRTAG_LOG_ITEM_PIN 30
++#define XFS_ERRTAG_BUF_LRU_REF 31
++#define XFS_ERRTAG_MAX 32
++
++/*
++ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
++ */
++#define XFS_RANDOM_DEFAULT 100
++#define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4)
++#define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10)
++#define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10)
++#define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10)
++#define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10)
++#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
++#define XFS_RANDOM_FREE_EXTENT 1
++#define XFS_RANDOM_RMAP_FINISH_ONE 1
++#define XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE 1
++#define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
++#define XFS_RANDOM_BMAP_FINISH_ONE 1
++#define XFS_RANDOM_AG_RESV_CRITICAL 4
++#define XFS_RANDOM_DROP_WRITES 1
++#define XFS_RANDOM_LOG_BAD_CRC 1
++#define XFS_RANDOM_LOG_ITEM_PIN 1
++#define XFS_RANDOM_BUF_LRU_REF 2
++
++#endif /* __XFS_ERRORTAG_H_ */
+diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
+index e11f8af8a725..de3f04a98656 100644
+--- a/fs/xfs/libxfs/xfs_ialloc.c
++++ b/fs/xfs/libxfs/xfs_ialloc.c
+@@ -31,6 +31,7 @@
+ #include "xfs_ialloc_btree.h"
+ #include "xfs_alloc.h"
+ #include "xfs_rtalloc.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_bmap.h"
+ #include "xfs_cksum.h"
+diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
+index 378f8fbc91a7..6b7989038d75 100644
+--- a/fs/xfs/libxfs/xfs_inode_buf.c
++++ b/fs/xfs/libxfs/xfs_inode_buf.c
+@@ -24,6 +24,7 @@
+ #include "xfs_mount.h"
+ #include "xfs_defer.h"
+ #include "xfs_inode.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_cksum.h"
+ #include "xfs_icache.h"
+diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
+index 9d5406b4f663..585b35d34142 100644
+--- a/fs/xfs/libxfs/xfs_refcount.c
++++ b/fs/xfs/libxfs/xfs_refcount.c
+@@ -30,6 +30,7 @@
+ #include "xfs_bmap.h"
+ #include "xfs_refcount_btree.h"
+ #include "xfs_alloc.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trace.h"
+ #include "xfs_cksum.h"
+diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
+index 55c88a732690..dd019cee1b3b 100644
+--- a/fs/xfs/libxfs/xfs_rmap.c
++++ b/fs/xfs/libxfs/xfs_rmap.c
+@@ -34,6 +34,7 @@
+ #include "xfs_rmap_btree.h"
+ #include "xfs_trans_space.h"
+ #include "xfs_trace.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_extent_busy.h"
+ #include "xfs_bmap.h"
+diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
+index db786bce7c03..4db6e8d780f6 100644
+--- a/fs/xfs/xfs_buf.c
++++ b/fs/xfs/xfs_buf.c
+@@ -42,6 +42,7 @@
+ #include "xfs_mount.h"
+ #include "xfs_trace.h"
+ #include "xfs_log.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+
+ static kmem_zone_t *xfs_buf_zone;
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index 6732b0a0d826..92396d5eb259 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -21,6 +21,7 @@
+ #include "xfs_log_format.h"
+ #include "xfs_trans_resv.h"
+ #include "xfs_mount.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_sysfs.h"
+
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index 78a7f43f8d01..ea816c1bf8db 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -63,89 +63,6 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ } \
+ }
+
+-/*
+- * error injection tags - the labels can be anything you want
+- * but each tag should have its own unique number
+- */
+-
+-#define XFS_ERRTAG_NOERROR 0
+-#define XFS_ERRTAG_IFLUSH_1 1
+-#define XFS_ERRTAG_IFLUSH_2 2
+-#define XFS_ERRTAG_IFLUSH_3 3
+-#define XFS_ERRTAG_IFLUSH_4 4
+-#define XFS_ERRTAG_IFLUSH_5 5
+-#define XFS_ERRTAG_IFLUSH_6 6
+-#define XFS_ERRTAG_DA_READ_BUF 7
+-#define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
+-#define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
+-#define XFS_ERRTAG_ALLOC_READ_AGF 10
+-#define XFS_ERRTAG_IALLOC_READ_AGI 11
+-#define XFS_ERRTAG_ITOBP_INOTOBP 12
+-#define XFS_ERRTAG_IUNLINK 13
+-#define XFS_ERRTAG_IUNLINK_REMOVE 14
+-#define XFS_ERRTAG_DIR_INO_VALIDATE 15
+-#define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
+-#define XFS_ERRTAG_IODONE_IOERR 17
+-#define XFS_ERRTAG_STRATREAD_IOERR 18
+-#define XFS_ERRTAG_STRATCMPL_IOERR 19
+-#define XFS_ERRTAG_DIOWRITE_IOERR 20
+-#define XFS_ERRTAG_BMAPIFORMAT 21
+-#define XFS_ERRTAG_FREE_EXTENT 22
+-#define XFS_ERRTAG_RMAP_FINISH_ONE 23
+-#define XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE 24
+-#define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25
+-#define XFS_ERRTAG_BMAP_FINISH_ONE 26
+-#define XFS_ERRTAG_AG_RESV_CRITICAL 27
+-/*
+- * DEBUG mode instrumentation to test and/or trigger delayed allocation
+- * block killing in the event of failed writes. When enabled, all
+- * buffered writes are silenty dropped and handled as if they failed.
+- * All delalloc blocks in the range of the write (including pre-existing
+- * delalloc blocks!) are tossed as part of the write failure error
+- * handling sequence.
+- */
+-#define XFS_ERRTAG_DROP_WRITES 28
+-#define XFS_ERRTAG_LOG_BAD_CRC 29
+-#define XFS_ERRTAG_LOG_ITEM_PIN 30
+-#define XFS_ERRTAG_BUF_LRU_REF 31
+-#define XFS_ERRTAG_MAX 32
+-
+-/*
+- * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+- */
+-#define XFS_RANDOM_DEFAULT 100
+-#define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4)
+-#define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10)
+-#define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10)
+-#define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10)
+-#define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10)
+-#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
+-#define XFS_RANDOM_FREE_EXTENT 1
+-#define XFS_RANDOM_RMAP_FINISH_ONE 1
+-#define XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE 1
+-#define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
+-#define XFS_RANDOM_BMAP_FINISH_ONE 1
+-#define XFS_RANDOM_AG_RESV_CRITICAL 4
+-#define XFS_RANDOM_DROP_WRITES 1
+-#define XFS_RANDOM_LOG_BAD_CRC 1
+-#define XFS_RANDOM_LOG_ITEM_PIN 1
+-#define XFS_RANDOM_BUF_LRU_REF 2
+-
+ #ifdef DEBUG
+ extern int xfs_errortag_init(struct xfs_mount *mp);
+ extern void xfs_errortag_del(struct xfs_mount *mp);
+diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
+index a929ca72fa8e..02497828e993 100644
+--- a/fs/xfs/xfs_inode.c
++++ b/fs/xfs/xfs_inode.c
+@@ -39,6 +39,7 @@
+ #include "xfs_ialloc.h"
+ #include "xfs_bmap.h"
+ #include "xfs_bmap_util.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_quota.h"
+ #include "xfs_filestream.h"
+diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
+index f179bdf1644d..da0abc8a0725 100644
+--- a/fs/xfs/xfs_iomap.c
++++ b/fs/xfs/xfs_iomap.c
+@@ -30,6 +30,7 @@
+ #include "xfs_bmap_btree.h"
+ #include "xfs_bmap.h"
+ #include "xfs_bmap_util.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trans.h"
+ #include "xfs_trans_space.h"
+diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
+index 0c4c9ad3be70..3ce44e6d6639 100644
+--- a/fs/xfs/xfs_log.c
++++ b/fs/xfs/xfs_log.c
+@@ -22,6 +22,7 @@
+ #include "xfs_log_format.h"
+ #include "xfs_trans_resv.h"
+ #include "xfs_mount.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_trans.h"
+ #include "xfs_trans_priv.h"
+diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
+index 4b1669f9d2b2..cef89f7127d3 100644
+--- a/fs/xfs/xfs_trans_ail.c
++++ b/fs/xfs/xfs_trans_ail.c
+@@ -25,6 +25,7 @@
+ #include "xfs_trans.h"
+ #include "xfs_trans_priv.h"
+ #include "xfs_trace.h"
++#include "xfs_errortag.h"
+ #include "xfs_error.h"
+ #include "xfs_log.h"
+
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-refactor-unmount-record-write.patch b/patches.fixes/xfs-refactor-unmount-record-write.patch
new file mode 100644
index 0000000000..6a4a6c6804
--- /dev/null
+++ b/patches.fixes/xfs-refactor-unmount-record-write.patch
@@ -0,0 +1,203 @@
+From 53235f22151ea7229e1251e46e68098bcf74922d Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Fri, 20 Jul 2018 09:28:39 -0700
+Subject: [PATCH] xfs: refactor unmount record write
+Git-commit: 53235f22151ea7229e1251e46e68098bcf74922d
+Patch-mainline: v4.19-rc1
+References: bsc#1114427
+
+Refactor the writing of the unmount record into a separate helper. No
+functionality changes.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_log_format.h | 13 ++++
+ fs/xfs/xfs_log.c | 131 ++++++++++++++++++++++-------------------
+ 2 files changed, 82 insertions(+), 62 deletions(-)
+
+diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
+index 79bb79853c9f..e5f97c69b320 100644
+--- a/fs/xfs/libxfs/xfs_log_format.h
++++ b/fs/xfs/libxfs/xfs_log_format.h
+@@ -77,6 +77,19 @@ static inline uint xlog_get_cycle(char *ptr)
+
+ #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
+
++/*
++ * Log item for unmount records.
++ *
++ * The unmount record used to have a string "Unmount filesystem--" in the
++ * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE).
++ * We just write the magic number now; see xfs_log_unmount_write.
++ */
++struct xfs_unmount_log_format {
++ uint16_t magic; /* XLOG_UNMOUNT_TYPE */
++ uint16_t pad1;
++ uint32_t pad2; /* may as well make it 64 bits */
++};
++
+ /* Region types for iovec's i_type */
+ #define XLOG_REG_TYPE_BFORMAT 1
+ #define XLOG_REG_TYPE_BCHUNK 2
+diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
+index 5e56f3b93d4b..bac586cbc54e 100644
+--- a/fs/xfs/xfs_log.c
++++ b/fs/xfs/xfs_log.c
+@@ -826,6 +826,74 @@ xfs_log_mount_cancel(
+ * deallocation must not be done until source-end.
+ */
+
++/* Actually write the unmount record to disk. */
++static void
++xfs_log_write_unmount_record(
++ struct xfs_mount *mp)
++{
++ /* the data section must be 32 bit size aligned */
++ struct xfs_unmount_log_format magic = {
++ .magic = XLOG_UNMOUNT_TYPE,
++ };
++ struct xfs_log_iovec reg = {
++ .i_addr = &magic,
++ .i_len = sizeof(magic),
++ .i_type = XLOG_REG_TYPE_UNMOUNT,
++ };
++ struct xfs_log_vec vec = {
++ .lv_niovecs = 1,
++ .lv_iovecp = &reg,
++ };
++ struct xlog *log = mp->m_log;
++ struct xlog_in_core *iclog;
++ struct xlog_ticket *tic = NULL;
++ xfs_lsn_t lsn;
++ int error;
++
++ error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0);
++ if (error)
++ goto out_err;
++
++ /* remove inited flag, and account for space used */
++ tic->t_flags = 0;
++ tic->t_curr_res -= sizeof(magic);
++ error = xlog_write(log, &vec, tic, &lsn, NULL, XLOG_UNMOUNT_TRANS);
++ /*
++ * At this point, we're umounting anyway, so there's no point in
++ * transitioning log state to IOERROR. Just continue...
++ */
++out_err:
++ if (error)
++ xfs_alert(mp, "%s: unmount record failed", __func__);
++
++ spin_lock(&log->l_icloglock);
++ iclog = log->l_iclog;
++ atomic_inc(&iclog->ic_refcnt);
++ xlog_state_want_sync(log, iclog);
++ spin_unlock(&log->l_icloglock);
++ error = xlog_state_release_iclog(log, iclog);
++
++ spin_lock(&log->l_icloglock);
++ switch (iclog->ic_state) {
++ default:
++ if (!XLOG_FORCED_SHUTDOWN(log)) {
++ xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);
++ break;
++ }
++ /* fall through */
++ case XLOG_STATE_ACTIVE:
++ case XLOG_STATE_DIRTY:
++ spin_unlock(&log->l_icloglock);
++ break;
++ }
++
++ if (tic) {
++ trace_xfs_log_umount_write(log, tic);
++ xlog_ungrant_log_space(log, tic);
++ xfs_log_ticket_put(tic);
++ }
++}
++
+ /*
+ * Unmount record used to have a string "Unmount filesystem--" in the
+ * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE).
+@@ -842,8 +910,6 @@ xfs_log_unmount_write(xfs_mount_t *mp)
+ #ifdef DEBUG
+ xlog_in_core_t *first_iclog;
+ #endif
+- xlog_ticket_t *tic = NULL;
+- xfs_lsn_t lsn;
+ int error;
+
+ /*
+@@ -870,66 +936,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
+ } while (iclog != first_iclog);
+ #endif
+ if (! (XLOG_FORCED_SHUTDOWN(log))) {
+- error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0);
+- if (!error) {
+- /* the data section must be 32 bit size aligned */
+- struct {
+- uint16_t magic;
+- uint16_t pad1;
+- uint32_t pad2; /* may as well make it 64 bits */
+- } magic = {
+- .magic = XLOG_UNMOUNT_TYPE,
+- };
+- struct xfs_log_iovec reg = {
+- .i_addr = &magic,
+- .i_len = sizeof(magic),
+- .i_type = XLOG_REG_TYPE_UNMOUNT,
+- };
+- struct xfs_log_vec vec = {
+- .lv_niovecs = 1,
+- .lv_iovecp = &reg,
+- };
+-
+- /* remove inited flag, and account for space used */
+- tic->t_flags = 0;
+- tic->t_curr_res -= sizeof(magic);
+- error = xlog_write(log, &vec, tic, &lsn,
+- NULL, XLOG_UNMOUNT_TRANS);
+- /*
+- * At this point, we're umounting anyway,
+- * so there's no point in transitioning log state
+- * to IOERROR. Just continue...
+- */
+- }
+-
+- if (error)
+- xfs_alert(mp, "%s: unmount record failed", __func__);
+-
+-
+- spin_lock(&log->l_icloglock);
+- iclog = log->l_iclog;
+- atomic_inc(&iclog->ic_refcnt);
+- xlog_state_want_sync(log, iclog);
+- spin_unlock(&log->l_icloglock);
+- error = xlog_state_release_iclog(log, iclog);
+-
+- spin_lock(&log->l_icloglock);
+- if (!(iclog->ic_state == XLOG_STATE_ACTIVE ||
+- iclog->ic_state == XLOG_STATE_DIRTY)) {
+- if (!XLOG_FORCED_SHUTDOWN(log)) {
+- xlog_wait(&iclog->ic_force_wait,
+- &log->l_icloglock);
+- } else {
+- spin_unlock(&log->l_icloglock);
+- }
+- } else {
+- spin_unlock(&log->l_icloglock);
+- }
+- if (tic) {
+- trace_xfs_log_umount_write(log, tic);
+- xlog_ungrant_log_space(log, tic);
+- xfs_log_ticket_put(tic);
+- }
++ xfs_log_write_unmount_record(mp);
+ } else {
+ /*
+ * We're already in forced_shutdown mode, couldn't
+--
+2.16.4
+
diff --git a/patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch b/patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch
index 2299b68e7d..0ebf252f9a 100644
--- a/patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch
+++ b/patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch
@@ -203,7 +203,7 @@ Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
/*
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
-@@ -2086,8 +2086,7 @@
+@@ -2087,8 +2087,7 @@
startoff, blockcount, state);
if (XFS_TEST_ERROR(false, mp,
@@ -223,8 +223,8 @@ Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+#define XFS_TEST_ERROR(expr, mp, tag) \
((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
- extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
-@@ -145,7 +145,7 @@
+ extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
+@@ -146,7 +146,7 @@
#else
#define xfs_errortag_init(mp) (0)
#define xfs_errortag_del(mp)
diff --git a/patches.fixes/xfs-replace-log_badcrc_factor-knob-with-error-inject.patch b/patches.fixes/xfs-replace-log_badcrc_factor-knob-with-error-inject.patch
new file mode 100644
index 0000000000..197d0a8b87
--- /dev/null
+++ b/patches.fixes/xfs-replace-log_badcrc_factor-knob-with-error-inject.patch
@@ -0,0 +1,158 @@
+From 3e88a0078ba8ef61816c85d33131827b4a307852 Mon Sep 17 00:00:00 2001
+From: Brian Foster <bfoster@redhat.com>
+Date: Tue, 27 Jun 2017 09:52:32 -0700
+Subject: [PATCH] xfs: replace log_badcrc_factor knob with error injection tag
+Git-commit: 3e88a0078ba8ef61816c85d33131827b4a307852
+Patch-mainline: v4.13-rc1
+References: bsc#1114427
+
+Now that error injection tags support dynamic frequency adjustment,
+replace the debug mode sysfs knob that controls log record CRC error
+injection with an error injection tag.
+
+Signed-off-by: Brian Foster <bfoster@redhat.com>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_error.c | 3 +++
+ fs/xfs/xfs_error.h | 4 +++-
+ fs/xfs/xfs_log.c | 5 +----
+ fs/xfs/xfs_sysfs.c | 36 ------------------------------------
+ 4 files changed, 7 insertions(+), 41 deletions(-)
+
+diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
+index a2f23d2bab16..26c32bc5cd34 100644
+--- a/fs/xfs/xfs_error.c
++++ b/fs/xfs/xfs_error.c
+@@ -56,6 +56,7 @@ static unsigned int xfs_errortag_random_default[] = {
+ XFS_RANDOM_BMAP_FINISH_ONE,
+ XFS_RANDOM_AG_RESV_CRITICAL,
+ XFS_RANDOM_DROP_WRITES,
++ XFS_RANDOM_LOG_BAD_CRC,
+ };
+
+ struct xfs_errortag_attr {
+@@ -159,6 +160,7 @@ XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
+ XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
+ XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
+ XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
++XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
+
+ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(noerror),
+@@ -190,6 +192,7 @@ static struct attribute *xfs_errortag_attrs[] = {
+ XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
+ XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
+ XFS_ERRORTAG_ATTR_LIST(drop_writes),
++ XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
+ NULL,
+ };
+
+diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
+index e0e4cf776fac..7577be5f09bc 100644
+--- a/fs/xfs/xfs_error.h
++++ b/fs/xfs/xfs_error.h
+@@ -105,7 +105,8 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ * handling sequence.
+ */
+ #define XFS_ERRTAG_DROP_WRITES 28
+-#define XFS_ERRTAG_MAX 29
++#define XFS_ERRTAG_LOG_BAD_CRC 29
++#define XFS_ERRTAG_MAX 30
+
+ /*
+ * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
+@@ -139,6 +140,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
+ #define XFS_RANDOM_BMAP_FINISH_ONE 1
+ #define XFS_RANDOM_AG_RESV_CRITICAL 4
+ #define XFS_RANDOM_DROP_WRITES 1
++#define XFS_RANDOM_LOG_BAD_CRC 1
+
+ #ifdef DEBUG
+ extern int xfs_errortag_init(struct xfs_mount *mp);
+diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
+index 2d1112ee1f86..31f11be42f01 100644
+--- a/fs/xfs/xfs_log.c
++++ b/fs/xfs/xfs_log.c
+@@ -1841,7 +1841,6 @@ xlog_sync(
+ /* calculcate the checksum */
+ iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header,
+ iclog->ic_datap, size);
+-#ifdef DEBUG
+ /*
+ * Intentionally corrupt the log record CRC based on the error injection
+ * frequency, if defined. This facilitates testing log recovery in the
+@@ -1849,15 +1848,13 @@ xlog_sync(
+ * write on I/O completion and shutdown the fs. The subsequent mount
+ * detects the bad CRC and attempts to recover.
+ */
+- if (log->l_badcrc_factor &&
+- (prandom_u32() % log->l_badcrc_factor == 0)) {
++ if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
+ iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA);
+ iclog->ic_state |= XLOG_STATE_IOABORT;
+ xfs_warn(log->l_mp,
+ "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.",
+ be64_to_cpu(iclog->ic_header.h_lsn));
+ }
+-#endif
+
+ bp->b_io_length = BTOBB(count);
+ bp->b_fspriv = iclog;
+diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
+index 56610a973593..8b2ccc234f36 100644
+--- a/fs/xfs/xfs_sysfs.c
++++ b/fs/xfs/xfs_sysfs.c
+@@ -305,47 +305,11 @@ write_grant_head_show(
+ }
+ XFS_SYSFS_ATTR_RO(write_grant_head);
+
+-#ifdef DEBUG
+-STATIC ssize_t
+-log_badcrc_factor_store(
+- struct kobject *kobject,
+- const char *buf,
+- size_t count)
+-{
+- struct xlog *log = to_xlog(kobject);
+- int ret;
+- uint32_t val;
+-
+- ret = kstrtouint(buf, 0, &val);
+- if (ret)
+- return ret;
+-
+- log->l_badcrc_factor = val;
+-
+- return count;
+-}
+-
+-STATIC ssize_t
+-log_badcrc_factor_show(
+- struct kobject *kobject,
+- char *buf)
+-{
+- struct xlog *log = to_xlog(kobject);
+-
+- return snprintf(buf, PAGE_SIZE, "%d\n", log->l_badcrc_factor);
+-}
+-
+-XFS_SYSFS_ATTR_RW(log_badcrc_factor);
+-#endif /* DEBUG */
+-
+ static struct attribute *xfs_log_attrs[] = {
+ ATTR_LIST(log_head_lsn),
+ ATTR_LIST(log_tail_lsn),
+ ATTR_LIST(reserve_grant_head),
+ ATTR_LIST(write_grant_head),
+-#ifdef DEBUG
+- ATTR_LIST(log_badcrc_factor),
+-#endif
+ NULL,
+ };
+
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 83eb1a9793..b06ab7a45b 100644
--- a/series.conf
+++ b/series.conf
@@ -3562,10 +3562,14 @@
patches.fixes/xfs-remove-bli-from-AIL-before-release-on-transactio.patch
patches.fixes/xfs-remove-double-underscore-integer-types.patch
patches.fixes/xfs-export-various-function-for-the-online-scrubber.patch
+ patches.fixes/xfs-export-_inobt_btrec_to_irec-and-_ialloc_cluster_.patch
patches.fixes/xfs-check-if-an-inode-is-cached-and-allocated.patch
patches.fixes/xfs-reflink-find-shared-should-take-a-transaction.patch
patches.fixes/xfs-make-errortag-a-per-mountpoint-structure.patch
+ patches.fixes/xfs-expose-errortag-knobs-via-sysfs.patch
patches.fixes/xfs-remove-unneeded-parameter-from-XFS_TEST_ERROR.patch
+ patches.fixes/xfs-convert-drop_writes-to-use-the-errortag-mechanis.patch
+ patches.fixes/xfs-replace-log_badcrc_factor-knob-with-error-inject.patch
patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch
patches.fixes/vfs-Add-page_cache_seek_hole_data-helper.patch
patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch
@@ -5550,6 +5554,7 @@
patches.fixes/xfs-fix-recovery-failure-when-log-record-header-wrap.patch
patches.fixes/xfs-always-verify-the-log-tail-during-recovery.patch
patches.fixes/xfs-fix-log-recovery-corruption-error-due-to-tail-ov.patch
+ patches.fixes/xfs-add-log-item-pinning-error-injection-tag.patch
patches.fixes/xfs-handle-EFSCORRUPTED-during-head-tail-verificatio.patch
patches.fixes/xfs-stop-searching-for-free-slots-in-an-inode-chunk-.patch
patches.fixes/xfs-evict-all-inodes-involved-with-log-redo-item.patch
@@ -8236,10 +8241,12 @@
patches.fixes/0026-xfs-replace-xfs_bmbt_lookup_ge-with-xfs_bmbt_lookup_.patch
patches.fixes/0027-xfs-remove-all-xfs_bmbt_set_-helpers-except-for-xfs_.patch
patches.fixes/0028-xfs-remove-xfs_bmbt_get_state.patch
+ patches.fixes/xfs-buffer-lru-reference-count-error-injection-tag.patch
patches.fixes/xfs-return-a-distinct-error-code-value-for-IGET_INCO.patch
patches.fixes/xfs-create-block-pointer-check-functions.patch
patches.fixes/xfs-refactor-btree-pointer-checks.patch
patches.fixes/xfs-refactor-btree-block-header-checking-functions.patch
+ patches.fixes/xfs-create-inode-pointer-verifiers.patch
patches.fixes/0029-xfs-add-a-xfs_bmap_fork_to_state-helper.patch
patches.fixes/0030-xfs-make-better-use-of-the-state-variable-in-xfs_bma.patch
patches.fixes/0031-xfs-remove-post-bmap-tracing-in-xfs_bmap_local_to_ex.patch
@@ -8260,6 +8267,8 @@
patches.fixes/0046-xfs-add-a-new-xfs_iext_lookup_extent_before-helper.patch
patches.fixes/xfs-fix-log-block-underflow-during-recovery-c.patch
patches.fixes/xfs-validate-sb_logsunit-is-a-multiple-of-the-fs-blo.patch
+ patches.fixes/xfs-fix-unused-variable-warning-in-xfs_buf_set_ref.patch
+ patches.fixes/xfs-move-error-injection-tags-into-their-own-file.patch
patches.fixes/xfs-truncate-pagecache-before-writeback-in-xfs_setat.patch
patches.fixes/0047-xfs-don-t-create-overlapping-extents-in-xfs_bmap_add.patch
patches.fixes/0048-xfs-remove-a-duplicate-assignment-in-xfs_bmap_add_ex.patch
@@ -18047,6 +18056,8 @@
patches.fixes/ext4-check-for-NUL-characters-in-extended-attribute-.patch
patches.fixes/ext4-fix-spectre-gadget-in-ext4_mb_regular_allocator.patch
patches.fixes/xfs-detect-and-fix-bad-summary-counts-at-mount.patch
+ patches.fixes/xfs-refactor-unmount-record-write.patch
+ patches.fixes/xfs-force-summary-counter-recalc-at-next-mount.patch
patches.suse/xfs-fix-a-null-pointer-dereference-in-xfs_bmap_exten.patch
patches.arch/x86-l1tf-01-increase-32bitPAE-__PHYSICAL_PAGE_MASK.patch
patches.arch/x86-l1tf-02-change-order-of-offset-type.patch