diff options
-rw-r--r-- | fs/xfs/xfs_error.c | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_error.h | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 5 | ||||
-rw-r--r-- | 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[] = { | |||
56 | XFS_RANDOM_BMAP_FINISH_ONE, | 56 | XFS_RANDOM_BMAP_FINISH_ONE, |
57 | XFS_RANDOM_AG_RESV_CRITICAL, | 57 | XFS_RANDOM_AG_RESV_CRITICAL, |
58 | XFS_RANDOM_DROP_WRITES, | 58 | XFS_RANDOM_DROP_WRITES, |
59 | XFS_RANDOM_LOG_BAD_CRC, | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | struct xfs_errortag_attr { | 62 | struct xfs_errortag_attr { |
@@ -159,6 +160,7 @@ XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE); | |||
159 | XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE); | 160 | XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE); |
160 | XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL); | 161 | XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL); |
161 | XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES); | 162 | XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES); |
163 | XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC); | ||
162 | 164 | ||
163 | static struct attribute *xfs_errortag_attrs[] = { | 165 | static struct attribute *xfs_errortag_attrs[] = { |
164 | XFS_ERRORTAG_ATTR_LIST(noerror), | 166 | XFS_ERRORTAG_ATTR_LIST(noerror), |
@@ -190,6 +192,7 @@ static struct attribute *xfs_errortag_attrs[] = { | |||
190 | XFS_ERRORTAG_ATTR_LIST(bmap_finish_one), | 192 | XFS_ERRORTAG_ATTR_LIST(bmap_finish_one), |
191 | XFS_ERRORTAG_ATTR_LIST(ag_resv_critical), | 193 | XFS_ERRORTAG_ATTR_LIST(ag_resv_critical), |
192 | XFS_ERRORTAG_ATTR_LIST(drop_writes), | 194 | XFS_ERRORTAG_ATTR_LIST(drop_writes), |
195 | XFS_ERRORTAG_ATTR_LIST(log_bad_crc), | ||
193 | NULL, | 196 | NULL, |
194 | }; | 197 | }; |
195 | 198 | ||
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); | |||
105 | * handling sequence. | 105 | * handling sequence. |
106 | */ | 106 | */ |
107 | #define XFS_ERRTAG_DROP_WRITES 28 | 107 | #define XFS_ERRTAG_DROP_WRITES 28 |
108 | #define XFS_ERRTAG_MAX 29 | 108 | #define XFS_ERRTAG_LOG_BAD_CRC 29 |
109 | #define XFS_ERRTAG_MAX 30 | ||
109 | 110 | ||
110 | /* | 111 | /* |
111 | * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. | 112 | * 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); | |||
139 | #define XFS_RANDOM_BMAP_FINISH_ONE 1 | 140 | #define XFS_RANDOM_BMAP_FINISH_ONE 1 |
140 | #define XFS_RANDOM_AG_RESV_CRITICAL 4 | 141 | #define XFS_RANDOM_AG_RESV_CRITICAL 4 |
141 | #define XFS_RANDOM_DROP_WRITES 1 | 142 | #define XFS_RANDOM_DROP_WRITES 1 |
143 | #define XFS_RANDOM_LOG_BAD_CRC 1 | ||
142 | 144 | ||
143 | #ifdef DEBUG | 145 | #ifdef DEBUG |
144 | extern int xfs_errortag_init(struct xfs_mount *mp); | 146 | 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( | |||
1841 | /* calculcate the checksum */ | 1841 | /* calculcate the checksum */ |
1842 | iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, | 1842 | iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, |
1843 | iclog->ic_datap, size); | 1843 | iclog->ic_datap, size); |
1844 | #ifdef DEBUG | ||
1845 | /* | 1844 | /* |
1846 | * Intentionally corrupt the log record CRC based on the error injection | 1845 | * Intentionally corrupt the log record CRC based on the error injection |
1847 | * frequency, if defined. This facilitates testing log recovery in the | 1846 | * frequency, if defined. This facilitates testing log recovery in the |
@@ -1849,15 +1848,13 @@ xlog_sync( | |||
1849 | * write on I/O completion and shutdown the fs. The subsequent mount | 1848 | * write on I/O completion and shutdown the fs. The subsequent mount |
1850 | * detects the bad CRC and attempts to recover. | 1849 | * detects the bad CRC and attempts to recover. |
1851 | */ | 1850 | */ |
1852 | if (log->l_badcrc_factor && | 1851 | if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) { |
1853 | (prandom_u32() % log->l_badcrc_factor == 0)) { | ||
1854 | iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA); | 1852 | iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA); |
1855 | iclog->ic_state |= XLOG_STATE_IOABORT; | 1853 | iclog->ic_state |= XLOG_STATE_IOABORT; |
1856 | xfs_warn(log->l_mp, | 1854 | xfs_warn(log->l_mp, |
1857 | "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.", | 1855 | "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.", |
1858 | be64_to_cpu(iclog->ic_header.h_lsn)); | 1856 | be64_to_cpu(iclog->ic_header.h_lsn)); |
1859 | } | 1857 | } |
1860 | #endif | ||
1861 | 1858 | ||
1862 | bp->b_io_length = BTOBB(count); | 1859 | bp->b_io_length = BTOBB(count); |
1863 | bp->b_fspriv = iclog; | 1860 | 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( | |||
305 | } | 305 | } |
306 | XFS_SYSFS_ATTR_RO(write_grant_head); | 306 | XFS_SYSFS_ATTR_RO(write_grant_head); |
307 | 307 | ||
308 | #ifdef DEBUG | ||
309 | STATIC ssize_t | ||
310 | log_badcrc_factor_store( | ||
311 | struct kobject *kobject, | ||
312 | const char *buf, | ||
313 | size_t count) | ||
314 | { | ||
315 | struct xlog *log = to_xlog(kobject); | ||
316 | int ret; | ||
317 | uint32_t val; | ||
318 | |||
319 | ret = kstrtouint(buf, 0, &val); | ||
320 | if (ret) | ||
321 | return ret; | ||
322 | |||
323 | log->l_badcrc_factor = val; | ||
324 | |||
325 | return count; | ||
326 | } | ||
327 | |||
328 | STATIC ssize_t | ||
329 | log_badcrc_factor_show( | ||
330 | struct kobject *kobject, | ||
331 | char *buf) | ||
332 | { | ||
333 | struct xlog *log = to_xlog(kobject); | ||
334 | |||
335 | return snprintf(buf, PAGE_SIZE, "%d\n", log->l_badcrc_factor); | ||
336 | } | ||
337 | |||
338 | XFS_SYSFS_ATTR_RW(log_badcrc_factor); | ||
339 | #endif /* DEBUG */ | ||
340 | |||
341 | static struct attribute *xfs_log_attrs[] = { | 308 | static struct attribute *xfs_log_attrs[] = { |
342 | ATTR_LIST(log_head_lsn), | 309 | ATTR_LIST(log_head_lsn), |
343 | ATTR_LIST(log_tail_lsn), | 310 | ATTR_LIST(log_tail_lsn), |
344 | ATTR_LIST(reserve_grant_head), | 311 | ATTR_LIST(reserve_grant_head), |
345 | ATTR_LIST(write_grant_head), | 312 | ATTR_LIST(write_grant_head), |
346 | #ifdef DEBUG | ||
347 | ATTR_LIST(log_badcrc_factor), | ||
348 | #endif | ||
349 | NULL, | 313 | NULL, |
350 | }; | 314 | }; |
351 | 315 | ||