blob: 9866f542e77b18f20689531821856be972c39bdf [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include "xfs.h"
Dave Chinnera4fbe6a2013-10-23 10:51:50 +11007#include "xfs_format.h"
Nathan Scotta844f452005-11-02 14:38:42 +11008#include "xfs_fs.h"
Dave Chinner239880e2013-10-23 10:50:10 +11009#include "xfs_log_format.h"
10#include "xfs_trans_resv.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include "xfs_mount.h"
Darrick J. Wonge9e899a2017-10-31 12:04:49 -070012#include "xfs_errortag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include "xfs_error.h"
Darrick J. Wongc6840102017-06-20 17:54:47 -070014#include "xfs_sysfs.h"
Darrick J. Wong22431bf2018-01-22 18:09:48 -080015#include "xfs_inode.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#ifdef DEBUG
18
Darrick J. Wong31965ef2017-06-20 17:54:46 -070019static unsigned int xfs_errortag_random_default[] = {
20 XFS_RANDOM_DEFAULT,
21 XFS_RANDOM_IFLUSH_1,
22 XFS_RANDOM_IFLUSH_2,
23 XFS_RANDOM_IFLUSH_3,
24 XFS_RANDOM_IFLUSH_4,
25 XFS_RANDOM_IFLUSH_5,
26 XFS_RANDOM_IFLUSH_6,
27 XFS_RANDOM_DA_READ_BUF,
28 XFS_RANDOM_BTREE_CHECK_LBLOCK,
29 XFS_RANDOM_BTREE_CHECK_SBLOCK,
30 XFS_RANDOM_ALLOC_READ_AGF,
31 XFS_RANDOM_IALLOC_READ_AGI,
32 XFS_RANDOM_ITOBP_INOTOBP,
33 XFS_RANDOM_IUNLINK,
34 XFS_RANDOM_IUNLINK_REMOVE,
35 XFS_RANDOM_DIR_INO_VALIDATE,
36 XFS_RANDOM_BULKSTAT_READ_CHUNK,
37 XFS_RANDOM_IODONE_IOERR,
38 XFS_RANDOM_STRATREAD_IOERR,
39 XFS_RANDOM_STRATCMPL_IOERR,
40 XFS_RANDOM_DIOWRITE_IOERR,
41 XFS_RANDOM_BMAPIFORMAT,
42 XFS_RANDOM_FREE_EXTENT,
43 XFS_RANDOM_RMAP_FINISH_ONE,
44 XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE,
45 XFS_RANDOM_REFCOUNT_FINISH_ONE,
46 XFS_RANDOM_BMAP_FINISH_ONE,
47 XFS_RANDOM_AG_RESV_CRITICAL,
Darrick J. Wongf8c47252017-06-20 17:54:48 -070048 XFS_RANDOM_DROP_WRITES,
Brian Foster3e88a002017-06-27 09:52:32 -070049 XFS_RANDOM_LOG_BAD_CRC,
Brian Foster7f4d01f2017-08-08 18:21:52 -070050 XFS_RANDOM_LOG_ITEM_PIN,
Brian Foster7561d272017-10-17 14:16:29 -070051 XFS_RANDOM_BUF_LRU_REF,
Darrick J. Wong84d42ea2018-05-14 06:34:36 -070052 XFS_RANDOM_FORCE_SCRUB_REPAIR,
Darrick J. Wongf467cad2018-07-20 09:28:40 -070053 XFS_RANDOM_FORCE_SUMMARY_RECALC,
Darrick J. Wong31965ef2017-06-20 17:54:46 -070054};
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Darrick J. Wongc6840102017-06-20 17:54:47 -070056struct xfs_errortag_attr {
57 struct attribute attr;
58 unsigned int tag;
59};
60
61static inline struct xfs_errortag_attr *
62to_attr(struct attribute *attr)
63{
64 return container_of(attr, struct xfs_errortag_attr, attr);
65}
66
67static inline struct xfs_mount *
68to_mp(struct kobject *kobject)
69{
70 struct xfs_kobj *kobj = to_kobj(kobject);
71
72 return container_of(kobj, struct xfs_mount, m_errortag_kobj);
73}
74
75STATIC ssize_t
76xfs_errortag_attr_store(
77 struct kobject *kobject,
78 struct attribute *attr,
79 const char *buf,
80 size_t count)
81{
82 struct xfs_mount *mp = to_mp(kobject);
83 struct xfs_errortag_attr *xfs_attr = to_attr(attr);
84 int ret;
85 unsigned int val;
86
87 if (strcmp(buf, "default") == 0) {
88 val = xfs_errortag_random_default[xfs_attr->tag];
89 } else {
90 ret = kstrtouint(buf, 0, &val);
91 if (ret)
92 return ret;
93 }
94
95 ret = xfs_errortag_set(mp, xfs_attr->tag, val);
96 if (ret)
97 return ret;
98 return count;
99}
100
101STATIC ssize_t
102xfs_errortag_attr_show(
103 struct kobject *kobject,
104 struct attribute *attr,
105 char *buf)
106{
107 struct xfs_mount *mp = to_mp(kobject);
108 struct xfs_errortag_attr *xfs_attr = to_attr(attr);
109
110 return snprintf(buf, PAGE_SIZE, "%u\n",
111 xfs_errortag_get(mp, xfs_attr->tag));
112}
113
114static const struct sysfs_ops xfs_errortag_sysfs_ops = {
115 .show = xfs_errortag_attr_show,
116 .store = xfs_errortag_attr_store,
117};
118
119#define XFS_ERRORTAG_ATTR_RW(_name, _tag) \
120static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \
121 .attr = {.name = __stringify(_name), \
122 .mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \
123 .tag = (_tag), \
124}
125
126#define XFS_ERRORTAG_ATTR_LIST(_name) &xfs_errortag_attr_##_name.attr
127
128XFS_ERRORTAG_ATTR_RW(noerror, XFS_ERRTAG_NOERROR);
129XFS_ERRORTAG_ATTR_RW(iflush1, XFS_ERRTAG_IFLUSH_1);
130XFS_ERRORTAG_ATTR_RW(iflush2, XFS_ERRTAG_IFLUSH_2);
131XFS_ERRORTAG_ATTR_RW(iflush3, XFS_ERRTAG_IFLUSH_3);
132XFS_ERRORTAG_ATTR_RW(iflush4, XFS_ERRTAG_IFLUSH_4);
133XFS_ERRORTAG_ATTR_RW(iflush5, XFS_ERRTAG_IFLUSH_5);
134XFS_ERRORTAG_ATTR_RW(iflush6, XFS_ERRTAG_IFLUSH_6);
135XFS_ERRORTAG_ATTR_RW(dareadbuf, XFS_ERRTAG_DA_READ_BUF);
136XFS_ERRORTAG_ATTR_RW(btree_chk_lblk, XFS_ERRTAG_BTREE_CHECK_LBLOCK);
137XFS_ERRORTAG_ATTR_RW(btree_chk_sblk, XFS_ERRTAG_BTREE_CHECK_SBLOCK);
138XFS_ERRORTAG_ATTR_RW(readagf, XFS_ERRTAG_ALLOC_READ_AGF);
139XFS_ERRORTAG_ATTR_RW(readagi, XFS_ERRTAG_IALLOC_READ_AGI);
140XFS_ERRORTAG_ATTR_RW(itobp, XFS_ERRTAG_ITOBP_INOTOBP);
141XFS_ERRORTAG_ATTR_RW(iunlink, XFS_ERRTAG_IUNLINK);
142XFS_ERRORTAG_ATTR_RW(iunlinkrm, XFS_ERRTAG_IUNLINK_REMOVE);
143XFS_ERRORTAG_ATTR_RW(dirinovalid, XFS_ERRTAG_DIR_INO_VALIDATE);
144XFS_ERRORTAG_ATTR_RW(bulkstat, XFS_ERRTAG_BULKSTAT_READ_CHUNK);
145XFS_ERRORTAG_ATTR_RW(logiodone, XFS_ERRTAG_IODONE_IOERR);
146XFS_ERRORTAG_ATTR_RW(stratread, XFS_ERRTAG_STRATREAD_IOERR);
147XFS_ERRORTAG_ATTR_RW(stratcmpl, XFS_ERRTAG_STRATCMPL_IOERR);
148XFS_ERRORTAG_ATTR_RW(diowrite, XFS_ERRTAG_DIOWRITE_IOERR);
149XFS_ERRORTAG_ATTR_RW(bmapifmt, XFS_ERRTAG_BMAPIFORMAT);
150XFS_ERRORTAG_ATTR_RW(free_extent, XFS_ERRTAG_FREE_EXTENT);
151XFS_ERRORTAG_ATTR_RW(rmap_finish_one, XFS_ERRTAG_RMAP_FINISH_ONE);
152XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE);
153XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
154XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
155XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
Darrick J. Wongf8c47252017-06-20 17:54:48 -0700156XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES);
Brian Foster3e88a002017-06-27 09:52:32 -0700157XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
Brian Foster7f4d01f2017-08-08 18:21:52 -0700158XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
Brian Foster7561d272017-10-17 14:16:29 -0700159XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF);
Darrick J. Wong84d42ea2018-05-14 06:34:36 -0700160XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR);
Darrick J. Wongf467cad2018-07-20 09:28:40 -0700161XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC);
Darrick J. Wongc6840102017-06-20 17:54:47 -0700162
163static struct attribute *xfs_errortag_attrs[] = {
164 XFS_ERRORTAG_ATTR_LIST(noerror),
165 XFS_ERRORTAG_ATTR_LIST(iflush1),
166 XFS_ERRORTAG_ATTR_LIST(iflush2),
167 XFS_ERRORTAG_ATTR_LIST(iflush3),
168 XFS_ERRORTAG_ATTR_LIST(iflush4),
169 XFS_ERRORTAG_ATTR_LIST(iflush5),
170 XFS_ERRORTAG_ATTR_LIST(iflush6),
171 XFS_ERRORTAG_ATTR_LIST(dareadbuf),
172 XFS_ERRORTAG_ATTR_LIST(btree_chk_lblk),
173 XFS_ERRORTAG_ATTR_LIST(btree_chk_sblk),
174 XFS_ERRORTAG_ATTR_LIST(readagf),
175 XFS_ERRORTAG_ATTR_LIST(readagi),
176 XFS_ERRORTAG_ATTR_LIST(itobp),
177 XFS_ERRORTAG_ATTR_LIST(iunlink),
178 XFS_ERRORTAG_ATTR_LIST(iunlinkrm),
179 XFS_ERRORTAG_ATTR_LIST(dirinovalid),
180 XFS_ERRORTAG_ATTR_LIST(bulkstat),
181 XFS_ERRORTAG_ATTR_LIST(logiodone),
182 XFS_ERRORTAG_ATTR_LIST(stratread),
183 XFS_ERRORTAG_ATTR_LIST(stratcmpl),
184 XFS_ERRORTAG_ATTR_LIST(diowrite),
185 XFS_ERRORTAG_ATTR_LIST(bmapifmt),
186 XFS_ERRORTAG_ATTR_LIST(free_extent),
187 XFS_ERRORTAG_ATTR_LIST(rmap_finish_one),
188 XFS_ERRORTAG_ATTR_LIST(refcount_continue_update),
189 XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
190 XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
191 XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
Darrick J. Wongf8c47252017-06-20 17:54:48 -0700192 XFS_ERRORTAG_ATTR_LIST(drop_writes),
Brian Foster3e88a002017-06-27 09:52:32 -0700193 XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
Brian Foster7f4d01f2017-08-08 18:21:52 -0700194 XFS_ERRORTAG_ATTR_LIST(log_item_pin),
Brian Foster7561d272017-10-17 14:16:29 -0700195 XFS_ERRORTAG_ATTR_LIST(buf_lru_ref),
Darrick J. Wong84d42ea2018-05-14 06:34:36 -0700196 XFS_ERRORTAG_ATTR_LIST(force_repair),
Darrick J. Wongf467cad2018-07-20 09:28:40 -0700197 XFS_ERRORTAG_ATTR_LIST(bad_summary),
Darrick J. Wongc6840102017-06-20 17:54:47 -0700198 NULL,
199};
200
Christoph Hellwig43711552017-11-06 11:53:59 -0800201static struct kobj_type xfs_errortag_ktype = {
Darrick J. Wongc6840102017-06-20 17:54:47 -0700202 .release = xfs_sysfs_release,
203 .sysfs_ops = &xfs_errortag_sysfs_ops,
204 .default_attrs = xfs_errortag_attrs,
205};
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207int
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700208xfs_errortag_init(
209 struct xfs_mount *mp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700211 mp->m_errortag = kmem_zalloc(sizeof(unsigned int) * XFS_ERRTAG_MAX,
212 KM_SLEEP | KM_MAYFAIL);
213 if (!mp->m_errortag)
214 return -ENOMEM;
Darrick J. Wongc6840102017-06-20 17:54:47 -0700215
216 return xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype,
217 &mp->m_kobj, "errortag");
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700218}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700220void
221xfs_errortag_del(
222 struct xfs_mount *mp)
223{
Darrick J. Wongc6840102017-06-20 17:54:47 -0700224 xfs_sysfs_del(&mp->m_errortag_kobj);
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700225 kmem_free(mp->m_errortag);
226}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700228bool
229xfs_errortag_test(
230 struct xfs_mount *mp,
231 const char *expression,
232 const char *file,
233 int line,
234 unsigned int error_tag)
235{
236 unsigned int randfactor;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
Carlos Maiolinod04c2412017-06-30 09:46:07 -0700238 /*
239 * To be able to use error injection anywhere, we need to ensure error
240 * injection mechanism is already initialized.
241 *
242 * Code paths like I/O completion can be called before the
243 * initialization is complete, but be able to inject errors in such
244 * places is still useful.
245 */
246 if (!mp->m_errortag)
247 return false;
248
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700249 ASSERT(error_tag < XFS_ERRTAG_MAX);
250 randfactor = mp->m_errortag[error_tag];
251 if (!randfactor || prandom_u32() % randfactor)
252 return false;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700254 xfs_warn_ratelimited(mp,
255"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",
256 expression, file, line, mp->m_fsname);
257 return true;
258}
259
260int
Darrick J. Wongc6840102017-06-20 17:54:47 -0700261xfs_errortag_get(
262 struct xfs_mount *mp,
263 unsigned int error_tag)
264{
265 if (error_tag >= XFS_ERRTAG_MAX)
266 return -EINVAL;
267
268 return mp->m_errortag[error_tag];
269}
270
271int
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700272xfs_errortag_set(
273 struct xfs_mount *mp,
274 unsigned int error_tag,
275 unsigned int tag_value)
276{
277 if (error_tag >= XFS_ERRTAG_MAX)
278 return -EINVAL;
279
280 mp->m_errortag[error_tag] = tag_value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 return 0;
282}
283
284int
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700285xfs_errortag_add(
286 struct xfs_mount *mp,
287 unsigned int error_tag)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
Darrick J. Wong128f24d2016-06-21 11:53:28 +1000289 if (error_tag >= XFS_ERRTAG_MAX)
290 return -EINVAL;
291
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700292 return xfs_errortag_set(mp, error_tag,
293 xfs_errortag_random_default[error_tag]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294}
295
296int
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700297xfs_errortag_clearall(
298 struct xfs_mount *mp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299{
Darrick J. Wong31965ef2017-06-20 17:54:46 -0700300 memset(mp->m_errortag, 0, sizeof(unsigned int) * XFS_ERRTAG_MAX);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 return 0;
302}
Christoph Hellwig1550d0b2008-08-13 16:17:37 +1000303#endif /* DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305void
306xfs_error_report(
Alex Eldera0e856b2010-04-13 15:22:08 +1000307 const char *tag,
308 int level,
309 struct xfs_mount *mp,
310 const char *filename,
311 int linenum,
Darrick J. Wongd9418ed2018-01-08 10:51:25 -0800312 xfs_failaddr_t failaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 if (level <= xfs_error_level) {
Dave Chinner6a19d932011-03-07 10:02:35 +1100315 xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT,
Scott Wood65dd2972015-03-25 14:56:21 +1100316 "Internal error %s at line %d of file %s. Caller %pS",
Darrick J. Wongd9418ed2018-01-08 10:51:25 -0800317 tag, linenum, filename, failaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 xfs_stack_trace();
320 }
321}
322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323void
324xfs_corruption_error(
Alex Eldera0e856b2010-04-13 15:22:08 +1000325 const char *tag,
326 int level,
327 struct xfs_mount *mp,
Darrick J. Wong2551a532018-06-04 10:23:54 -0700328 void *buf,
329 size_t bufsize,
Alex Eldera0e856b2010-04-13 15:22:08 +1000330 const char *filename,
331 int linenum,
Darrick J. Wongd9418ed2018-01-08 10:51:25 -0800332 xfs_failaddr_t failaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 if (level <= xfs_error_level)
Darrick J. Wong2551a532018-06-04 10:23:54 -0700335 xfs_hex_dump(buf, bufsize);
Darrick J. Wongd9418ed2018-01-08 10:51:25 -0800336 xfs_error_report(tag, level, mp, filename, linenum, failaddr);
Dave Chinner65333b42011-03-07 10:03:35 +1100337 xfs_alert(mp, "Corruption detected. Unmount and run xfs_repair");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
Eric Sandeenca23f8f2014-02-27 15:21:07 +1100339
340/*
341 * Warnings specifically for verifier errors. Differentiate CRC vs. invalid
342 * values, and omit the stack trace unless the error level is tuned high.
343 */
344void
Darrick J. Wong6edb1812018-03-23 10:06:53 -0700345xfs_buf_verifier_error(
346 struct xfs_buf *bp,
347 int error,
348 const char *name,
349 void *buf,
350 size_t bufsz,
351 xfs_failaddr_t failaddr)
352{
353 struct xfs_mount *mp = bp->b_target->bt_mount;
354 xfs_failaddr_t fa;
355 int sz;
356
357 fa = failaddr ? failaddr : __return_address;
358 __xfs_buf_ioerror(bp, error, fa);
359
360 xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s",
361 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
362 fa, bp->b_ops->name, bp->b_bn, name);
363
364 xfs_alert(mp, "Unmount and run xfs_repair");
365
366 if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
367 sz = min_t(size_t, XFS_CORRUPTION_DUMP_LEN, bufsz);
368 xfs_alert(mp, "First %d bytes of corrupted metadata buffer:",
369 sz);
370 xfs_hex_dump(buf, sz);
371 }
372
373 if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
374 xfs_stack_trace();
375}
376
377/*
378 * Warnings specifically for verifier errors. Differentiate CRC vs. invalid
379 * values, and omit the stack trace unless the error level is tuned high.
380 */
381void
Eric Sandeenca23f8f2014-02-27 15:21:07 +1100382xfs_verifier_error(
Darrick J. Wong31ca03c2018-01-08 10:51:02 -0800383 struct xfs_buf *bp,
Darrick J. Wongbc1a09b2018-01-08 10:51:03 -0800384 int error,
385 xfs_failaddr_t failaddr)
Eric Sandeenca23f8f2014-02-27 15:21:07 +1100386{
Darrick J. Wong6edb1812018-03-23 10:06:53 -0700387 return xfs_buf_verifier_error(bp, error, "", xfs_buf_offset(bp, 0),
388 XFS_CORRUPTION_DUMP_LEN, failaddr);
Eric Sandeenca23f8f2014-02-27 15:21:07 +1100389}
Darrick J. Wong22431bf2018-01-22 18:09:48 -0800390
391/*
392 * Warnings for inode corruption problems. Don't bother with the stack
393 * trace unless the error level is turned up high.
394 */
395void
396xfs_inode_verifier_error(
397 struct xfs_inode *ip,
398 int error,
399 const char *name,
400 void *buf,
401 size_t bufsz,
402 xfs_failaddr_t failaddr)
403{
404 struct xfs_mount *mp = ip->i_mount;
405 xfs_failaddr_t fa;
406 int sz;
407
408 fa = failaddr ? failaddr : __return_address;
409
410 xfs_alert(mp, "Metadata %s detected at %pS, inode 0x%llx %s",
411 error == -EFSBADCRC ? "CRC error" : "corruption",
412 fa, ip->i_ino, name);
413
414 xfs_alert(mp, "Unmount and run xfs_repair");
415
416 if (buf && xfs_error_level >= XFS_ERRLEVEL_LOW) {
417 sz = min_t(size_t, XFS_CORRUPTION_DUMP_LEN, bufsz);
418 xfs_alert(mp, "First %d bytes of corrupted metadata buffer:",
419 sz);
420 xfs_hex_dump(buf, sz);
421 }
422
423 if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
424 xfs_stack_trace();
425}