Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0
  2
  3#include "fs.h"
  4#include "messages.h"
  5#include "discard.h"
  6#include "transaction.h"
  7#include "space-info.h"
  8#include "super.h"
  9
 10#ifdef CONFIG_PRINTK
 11
 12#define STATE_STRING_PREFACE	": state "
 13#define STATE_STRING_BUF_LEN	(sizeof(STATE_STRING_PREFACE) + BTRFS_FS_STATE_COUNT)
 14
 15/*
 16 * Characters to print to indicate error conditions or uncommon filesystem state.
 17 * RO is not an error.
 18 */
 19static const char fs_state_chars[] = {
 20	[BTRFS_FS_STATE_ERROR]			= 'E',
 21	[BTRFS_FS_STATE_REMOUNTING]		= 'M',
 22	[BTRFS_FS_STATE_RO]			= 0,
 23	[BTRFS_FS_STATE_TRANS_ABORTED]		= 'A',
 24	[BTRFS_FS_STATE_DEV_REPLACING]		= 'R',
 25	[BTRFS_FS_STATE_DUMMY_FS_INFO]		= 0,
 26	[BTRFS_FS_STATE_NO_CSUMS]		= 'C',
 27	[BTRFS_FS_STATE_LOG_CLEANUP_ERROR]	= 'L',
 28};
 29
 30static void btrfs_state_to_string(const struct btrfs_fs_info *info, char *buf)
 31{
 32	unsigned int bit;
 33	bool states_printed = false;
 34	unsigned long fs_state = READ_ONCE(info->fs_state);
 35	char *curr = buf;
 36
 37	memcpy(curr, STATE_STRING_PREFACE, sizeof(STATE_STRING_PREFACE));
 38	curr += sizeof(STATE_STRING_PREFACE) - 1;
 39
 
 
 
 
 
 40	for_each_set_bit(bit, &fs_state, sizeof(fs_state)) {
 41		WARN_ON_ONCE(bit >= BTRFS_FS_STATE_COUNT);
 42		if ((bit < BTRFS_FS_STATE_COUNT) && fs_state_chars[bit]) {
 43			*curr++ = fs_state_chars[bit];
 44			states_printed = true;
 45		}
 46	}
 47
 48	/* If no states were printed, reset the buffer */
 49	if (!states_printed)
 50		curr = buf;
 51
 52	*curr++ = 0;
 53}
 54#endif
 55
 56/*
 57 * Generally the error codes correspond to their respective errors, but there
 58 * are a few special cases.
 59 *
 60 * EUCLEAN: Any sort of corruption that we encounter.  The tree-checker for
 61 *          instance will return EUCLEAN if any of the blocks are corrupted in
 62 *          a way that is problematic.  We want to reserve EUCLEAN for these
 63 *          sort of corruptions.
 64 *
 65 * EROFS: If we check BTRFS_FS_STATE_ERROR and fail out with a return error, we
 66 *        need to use EROFS for this case.  We will have no idea of the
 67 *        original failure, that will have been reported at the time we tripped
 68 *        over the error.  Each subsequent error that doesn't have any context
 69 *        of the original error should use EROFS when handling BTRFS_FS_STATE_ERROR.
 70 */
 71const char * __attribute_const__ btrfs_decode_error(int errno)
 72{
 73	char *errstr = "unknown";
 74
 75	switch (errno) {
 76	case -ENOENT:		/* -2 */
 77		errstr = "No such entry";
 78		break;
 79	case -EIO:		/* -5 */
 80		errstr = "IO failure";
 81		break;
 82	case -ENOMEM:		/* -12*/
 83		errstr = "Out of memory";
 84		break;
 85	case -EEXIST:		/* -17 */
 86		errstr = "Object already exists";
 87		break;
 88	case -ENOSPC:		/* -28 */
 89		errstr = "No space left";
 90		break;
 91	case -EROFS:		/* -30 */
 92		errstr = "Readonly filesystem";
 93		break;
 94	case -EOPNOTSUPP:	/* -95 */
 95		errstr = "Operation not supported";
 96		break;
 97	case -EUCLEAN:		/* -117 */
 98		errstr = "Filesystem corrupted";
 99		break;
100	case -EDQUOT:		/* -122 */
101		errstr = "Quota exceeded";
102		break;
103	}
104
105	return errstr;
106}
107
108/*
109 * __btrfs_handle_fs_error decodes expected errors from the caller and
110 * invokes the appropriate error response.
111 */
112__cold
113void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
114		       unsigned int line, int errno, const char *fmt, ...)
115{
116	struct super_block *sb = fs_info->sb;
117#ifdef CONFIG_PRINTK
118	char statestr[STATE_STRING_BUF_LEN];
119	const char *errstr;
120#endif
121
122#ifdef CONFIG_PRINTK_INDEX
123	printk_index_subsys_emit(
124		"BTRFS: error (device %s%s) in %s:%d: errno=%d %s", KERN_CRIT, fmt);
125#endif
126
127	/*
128	 * Special case: if the error is EROFS, and we're already under
129	 * SB_RDONLY, then it is safe here.
130	 */
131	if (errno == -EROFS && sb_rdonly(sb))
132		return;
133
134#ifdef CONFIG_PRINTK
135	errstr = btrfs_decode_error(errno);
136	btrfs_state_to_string(fs_info, statestr);
137	if (fmt) {
138		struct va_format vaf;
139		va_list args;
140
141		va_start(args, fmt);
142		vaf.fmt = fmt;
143		vaf.va = &args;
144
145		pr_crit("BTRFS: error (device %s%s) in %s:%d: errno=%d %s (%pV)\n",
146			sb->s_id, statestr, function, line, errno, errstr, &vaf);
147		va_end(args);
148	} else {
149		pr_crit("BTRFS: error (device %s%s) in %s:%d: errno=%d %s\n",
150			sb->s_id, statestr, function, line, errno, errstr);
151	}
152#endif
153
154	/*
155	 * Today we only save the error info to memory.  Long term we'll also
156	 * send it down to the disk.
157	 */
158	set_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state);
159
160	/* Don't go through full error handling during mount. */
161	if (!(sb->s_flags & SB_BORN))
162		return;
163
164	if (sb_rdonly(sb))
165		return;
166
167	btrfs_discard_stop(fs_info);
168
169	/* Handle error by forcing the filesystem readonly. */
170	btrfs_set_sb_rdonly(sb);
171	btrfs_info(fs_info, "forced readonly");
172	/*
173	 * Note that a running device replace operation is not canceled here
174	 * although there is no way to update the progress. It would add the
175	 * risk of a deadlock, therefore the canceling is omitted. The only
176	 * penalty is that some I/O remains active until the procedure
177	 * completes. The next time when the filesystem is mounted writable
178	 * again, the device replace operation continues.
179	 */
180}
181
182#ifdef CONFIG_PRINTK
183static const char * const logtypes[] = {
184	"emergency",
185	"alert",
186	"critical",
187	"error",
188	"warning",
189	"notice",
190	"info",
191	"debug",
192};
193
194/*
195 * Use one ratelimit state per log level so that a flood of less important
196 * messages doesn't cause more important ones to be dropped.
197 */
198static struct ratelimit_state printk_limits[] = {
199	RATELIMIT_STATE_INIT(printk_limits[0], DEFAULT_RATELIMIT_INTERVAL, 100),
200	RATELIMIT_STATE_INIT(printk_limits[1], DEFAULT_RATELIMIT_INTERVAL, 100),
201	RATELIMIT_STATE_INIT(printk_limits[2], DEFAULT_RATELIMIT_INTERVAL, 100),
202	RATELIMIT_STATE_INIT(printk_limits[3], DEFAULT_RATELIMIT_INTERVAL, 100),
203	RATELIMIT_STATE_INIT(printk_limits[4], DEFAULT_RATELIMIT_INTERVAL, 100),
204	RATELIMIT_STATE_INIT(printk_limits[5], DEFAULT_RATELIMIT_INTERVAL, 100),
205	RATELIMIT_STATE_INIT(printk_limits[6], DEFAULT_RATELIMIT_INTERVAL, 100),
206	RATELIMIT_STATE_INIT(printk_limits[7], DEFAULT_RATELIMIT_INTERVAL, 100),
207};
208
209void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
210{
211	char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = "\0";
212	struct va_format vaf;
213	va_list args;
214	int kern_level;
215	const char *type = logtypes[4];
216	struct ratelimit_state *ratelimit = &printk_limits[4];
217
218#ifdef CONFIG_PRINTK_INDEX
219	printk_index_subsys_emit("%sBTRFS %s (device %s): ", NULL, fmt);
220#endif
221
222	va_start(args, fmt);
223
224	while ((kern_level = printk_get_level(fmt)) != 0) {
225		size_t size = printk_skip_level(fmt) - fmt;
226
227		if (kern_level >= '0' && kern_level <= '7') {
228			memcpy(lvl, fmt,  size);
229			lvl[size] = '\0';
230			type = logtypes[kern_level - '0'];
231			ratelimit = &printk_limits[kern_level - '0'];
232		}
233		fmt += size;
234	}
235
236	vaf.fmt = fmt;
237	vaf.va = &args;
238
239	if (__ratelimit(ratelimit)) {
240		if (fs_info) {
241			char statestr[STATE_STRING_BUF_LEN];
242
243			btrfs_state_to_string(fs_info, statestr);
244			_printk("%sBTRFS %s (device %s%s): %pV\n", lvl, type,
245				fs_info->sb->s_id, statestr, &vaf);
246		} else {
247			_printk("%sBTRFS %s: %pV\n", lvl, type, &vaf);
248		}
249	}
250
251	va_end(args);
252}
253#endif
254
255#ifdef CONFIG_BTRFS_ASSERT
256void __cold btrfs_assertfail(const char *expr, const char *file, int line)
257{
258	pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
259	BUG();
260}
261#endif
262
263void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info)
264{
265	btrfs_err(fs_info,
266"Unsupported V0 extent filesystem detected. Aborting. Please re-create your filesystem with a newer kernel");
267}
268
269#if BITS_PER_LONG == 32
270void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
271{
272	if (!test_and_set_bit(BTRFS_FS_32BIT_WARN, &fs_info->flags)) {
273		btrfs_warn(fs_info, "reaching 32bit limit for logical addresses");
274		btrfs_warn(fs_info,
275"due to page cache limit on 32bit systems, btrfs can't access metadata at or beyond %lluT",
276			   BTRFS_32BIT_MAX_FILE_SIZE >> 40);
277		btrfs_warn(fs_info,
278			   "please consider upgrading to 64bit kernel/hardware");
279	}
280}
281
282void __cold btrfs_err_32bit_limit(struct btrfs_fs_info *fs_info)
283{
284	if (!test_and_set_bit(BTRFS_FS_32BIT_ERROR, &fs_info->flags)) {
285		btrfs_err(fs_info, "reached 32bit limit for logical addresses");
286		btrfs_err(fs_info,
287"due to page cache limit on 32bit systems, metadata beyond %lluT can't be accessed",
288			  BTRFS_32BIT_MAX_FILE_SIZE >> 40);
289		btrfs_err(fs_info,
290			   "please consider upgrading to 64bit kernel/hardware");
291	}
292}
293#endif
294
295/*
296 * We only mark the transaction aborted and then set the file system read-only.
297 * This will prevent new transactions from starting or trying to join this
298 * one.
299 *
300 * This means that error recovery at the call site is limited to freeing
301 * any local memory allocations and passing the error code up without
302 * further cleanup. The transaction should complete as it normally would
303 * in the call path but will return -EIO.
304 *
305 * We'll complete the cleanup in btrfs_end_transaction and
306 * btrfs_commit_transaction.
307 */
308__cold
309void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
310			       const char *function,
311			       unsigned int line, int errno, bool first_hit)
312{
313	struct btrfs_fs_info *fs_info = trans->fs_info;
314
315	WRITE_ONCE(trans->aborted, errno);
316	WRITE_ONCE(trans->transaction->aborted, errno);
317	if (first_hit && errno == -ENOSPC)
318		btrfs_dump_space_info_for_trans_abort(fs_info);
319	/* Wake up anybody who may be waiting on this transaction */
320	wake_up(&fs_info->transaction_wait);
321	wake_up(&fs_info->transaction_blocked_wait);
322	__btrfs_handle_fs_error(fs_info, function, line, errno, NULL);
323}
324
325/*
326 * __btrfs_panic decodes unexpected, fatal errors from the caller, issues an
327 * alert, and either panics or BUGs, depending on mount options.
328 */
329__cold
330void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
331		   unsigned int line, int errno, const char *fmt, ...)
332{
333	char *s_id = "<unknown>";
334	const char *errstr;
335	struct va_format vaf = { .fmt = fmt };
336	va_list args;
337
338	if (fs_info)
339		s_id = fs_info->sb->s_id;
340
341	va_start(args, fmt);
342	vaf.va = &args;
343
344	errstr = btrfs_decode_error(errno);
345	if (fs_info && (btrfs_test_opt(fs_info, PANIC_ON_FATAL_ERROR)))
346		panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n",
347			s_id, function, line, &vaf, errno, errstr);
348
349	btrfs_crit(fs_info, "panic in %s:%d: %pV (errno=%d %s)",
350		   function, line, &vaf, errno, errstr);
351	va_end(args);
352	/* Caller calls BUG() */
353}
v6.9.4
  1// SPDX-License-Identifier: GPL-2.0
  2
  3#include "fs.h"
  4#include "messages.h"
  5#include "discard.h"
 
 
  6#include "super.h"
  7
  8#ifdef CONFIG_PRINTK
  9
 10#define STATE_STRING_PREFACE	" state "
 11#define STATE_STRING_BUF_LEN	(sizeof(STATE_STRING_PREFACE) + BTRFS_FS_STATE_COUNT + 1)
 12
 13/*
 14 * Characters to print to indicate error conditions or uncommon filesystem state.
 15 * RO is not an error.
 16 */
 17static const char fs_state_chars[] = {
 
 18	[BTRFS_FS_STATE_REMOUNTING]		= 'M',
 19	[BTRFS_FS_STATE_RO]			= 0,
 20	[BTRFS_FS_STATE_TRANS_ABORTED]		= 'A',
 21	[BTRFS_FS_STATE_DEV_REPLACING]		= 'R',
 22	[BTRFS_FS_STATE_DUMMY_FS_INFO]		= 0,
 23	[BTRFS_FS_STATE_NO_CSUMS]		= 'C',
 24	[BTRFS_FS_STATE_LOG_CLEANUP_ERROR]	= 'L',
 25};
 26
 27static void btrfs_state_to_string(const struct btrfs_fs_info *info, char *buf)
 28{
 29	unsigned int bit;
 30	bool states_printed = false;
 31	unsigned long fs_state = READ_ONCE(info->fs_state);
 32	char *curr = buf;
 33
 34	memcpy(curr, STATE_STRING_PREFACE, sizeof(STATE_STRING_PREFACE));
 35	curr += sizeof(STATE_STRING_PREFACE) - 1;
 36
 37	if (BTRFS_FS_ERROR(info)) {
 38		*curr++ = 'E';
 39		states_printed = true;
 40	}
 41
 42	for_each_set_bit(bit, &fs_state, sizeof(fs_state)) {
 43		WARN_ON_ONCE(bit >= BTRFS_FS_STATE_COUNT);
 44		if ((bit < BTRFS_FS_STATE_COUNT) && fs_state_chars[bit]) {
 45			*curr++ = fs_state_chars[bit];
 46			states_printed = true;
 47		}
 48	}
 49
 50	/* If no states were printed, reset the buffer */
 51	if (!states_printed)
 52		curr = buf;
 53
 54	*curr++ = 0;
 55}
 56#endif
 57
 58/*
 59 * Generally the error codes correspond to their respective errors, but there
 60 * are a few special cases.
 61 *
 62 * EUCLEAN: Any sort of corruption that we encounter.  The tree-checker for
 63 *          instance will return EUCLEAN if any of the blocks are corrupted in
 64 *          a way that is problematic.  We want to reserve EUCLEAN for these
 65 *          sort of corruptions.
 66 *
 67 * EROFS: If we check BTRFS_FS_STATE_ERROR and fail out with a return error, we
 68 *        need to use EROFS for this case.  We will have no idea of the
 69 *        original failure, that will have been reported at the time we tripped
 70 *        over the error.  Each subsequent error that doesn't have any context
 71 *        of the original error should use EROFS when handling BTRFS_FS_STATE_ERROR.
 72 */
 73const char * __attribute_const__ btrfs_decode_error(int error)
 74{
 75	char *errstr = "unknown";
 76
 77	switch (error) {
 78	case -ENOENT:		/* -2 */
 79		errstr = "No such entry";
 80		break;
 81	case -EIO:		/* -5 */
 82		errstr = "IO failure";
 83		break;
 84	case -ENOMEM:		/* -12*/
 85		errstr = "Out of memory";
 86		break;
 87	case -EEXIST:		/* -17 */
 88		errstr = "Object already exists";
 89		break;
 90	case -ENOSPC:		/* -28 */
 91		errstr = "No space left";
 92		break;
 93	case -EROFS:		/* -30 */
 94		errstr = "Readonly filesystem";
 95		break;
 96	case -EOPNOTSUPP:	/* -95 */
 97		errstr = "Operation not supported";
 98		break;
 99	case -EUCLEAN:		/* -117 */
100		errstr = "Filesystem corrupted";
101		break;
102	case -EDQUOT:		/* -122 */
103		errstr = "Quota exceeded";
104		break;
105	}
106
107	return errstr;
108}
109
110/*
111 * Decodes expected errors from the caller and invokes the appropriate error
112 * response.
113 */
114__cold
115void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
116		       unsigned int line, int error, const char *fmt, ...)
117{
118	struct super_block *sb = fs_info->sb;
119#ifdef CONFIG_PRINTK
120	char statestr[STATE_STRING_BUF_LEN];
121	const char *errstr;
122#endif
123
124#ifdef CONFIG_PRINTK_INDEX
125	printk_index_subsys_emit(
126		"BTRFS: error (device %s%s) in %s:%d: errno=%d %s", KERN_CRIT, fmt);
127#endif
128
129	/*
130	 * Special case: if the error is EROFS, and we're already under
131	 * SB_RDONLY, then it is safe here.
132	 */
133	if (error == -EROFS && sb_rdonly(sb))
134		return;
135
136#ifdef CONFIG_PRINTK
137	errstr = btrfs_decode_error(error);
138	btrfs_state_to_string(fs_info, statestr);
139	if (fmt) {
140		struct va_format vaf;
141		va_list args;
142
143		va_start(args, fmt);
144		vaf.fmt = fmt;
145		vaf.va = &args;
146
147		pr_crit("BTRFS: error (device %s%s) in %s:%d: errno=%d %s (%pV)\n",
148			sb->s_id, statestr, function, line, error, errstr, &vaf);
149		va_end(args);
150	} else {
151		pr_crit("BTRFS: error (device %s%s) in %s:%d: errno=%d %s\n",
152			sb->s_id, statestr, function, line, error, errstr);
153	}
154#endif
155
156	/*
157	 * Today we only save the error info to memory.  Long term we'll also
158	 * send it down to the disk.
159	 */
160	WRITE_ONCE(fs_info->fs_error, error);
161
162	/* Don't go through full error handling during mount. */
163	if (!(sb->s_flags & SB_BORN))
164		return;
165
166	if (sb_rdonly(sb))
167		return;
168
169	btrfs_discard_stop(fs_info);
170
171	/* Handle error by forcing the filesystem readonly. */
172	btrfs_set_sb_rdonly(sb);
173	btrfs_info(fs_info, "forced readonly");
174	/*
175	 * Note that a running device replace operation is not canceled here
176	 * although there is no way to update the progress. It would add the
177	 * risk of a deadlock, therefore the canceling is omitted. The only
178	 * penalty is that some I/O remains active until the procedure
179	 * completes. The next time when the filesystem is mounted writable
180	 * again, the device replace operation continues.
181	 */
182}
183
184#ifdef CONFIG_PRINTK
185static const char * const logtypes[] = {
186	"emergency",
187	"alert",
188	"critical",
189	"error",
190	"warning",
191	"notice",
192	"info",
193	"debug",
194};
195
196/*
197 * Use one ratelimit state per log level so that a flood of less important
198 * messages doesn't cause more important ones to be dropped.
199 */
200static struct ratelimit_state printk_limits[] = {
201	RATELIMIT_STATE_INIT(printk_limits[0], DEFAULT_RATELIMIT_INTERVAL, 100),
202	RATELIMIT_STATE_INIT(printk_limits[1], DEFAULT_RATELIMIT_INTERVAL, 100),
203	RATELIMIT_STATE_INIT(printk_limits[2], DEFAULT_RATELIMIT_INTERVAL, 100),
204	RATELIMIT_STATE_INIT(printk_limits[3], DEFAULT_RATELIMIT_INTERVAL, 100),
205	RATELIMIT_STATE_INIT(printk_limits[4], DEFAULT_RATELIMIT_INTERVAL, 100),
206	RATELIMIT_STATE_INIT(printk_limits[5], DEFAULT_RATELIMIT_INTERVAL, 100),
207	RATELIMIT_STATE_INIT(printk_limits[6], DEFAULT_RATELIMIT_INTERVAL, 100),
208	RATELIMIT_STATE_INIT(printk_limits[7], DEFAULT_RATELIMIT_INTERVAL, 100),
209};
210
211void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
212{
213	char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = "\0";
214	struct va_format vaf;
215	va_list args;
216	int kern_level;
217	const char *type = logtypes[4];
218	struct ratelimit_state *ratelimit = &printk_limits[4];
219
220#ifdef CONFIG_PRINTK_INDEX
221	printk_index_subsys_emit("%sBTRFS %s (device %s): ", NULL, fmt);
222#endif
223
224	va_start(args, fmt);
225
226	while ((kern_level = printk_get_level(fmt)) != 0) {
227		size_t size = printk_skip_level(fmt) - fmt;
228
229		if (kern_level >= '0' && kern_level <= '7') {
230			memcpy(lvl, fmt,  size);
231			lvl[size] = '\0';
232			type = logtypes[kern_level - '0'];
233			ratelimit = &printk_limits[kern_level - '0'];
234		}
235		fmt += size;
236	}
237
238	vaf.fmt = fmt;
239	vaf.va = &args;
240
241	if (__ratelimit(ratelimit)) {
242		if (fs_info) {
243			char statestr[STATE_STRING_BUF_LEN];
244
245			btrfs_state_to_string(fs_info, statestr);
246			_printk("%sBTRFS %s (device %s%s): %pV\n", lvl, type,
247				fs_info->sb->s_id, statestr, &vaf);
248		} else {
249			_printk("%sBTRFS %s: %pV\n", lvl, type, &vaf);
250		}
251	}
252
253	va_end(args);
254}
255#endif
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257#if BITS_PER_LONG == 32
258void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
259{
260	if (!test_and_set_bit(BTRFS_FS_32BIT_WARN, &fs_info->flags)) {
261		btrfs_warn(fs_info, "reaching 32bit limit for logical addresses");
262		btrfs_warn(fs_info,
263"due to page cache limit on 32bit systems, btrfs can't access metadata at or beyond %lluT",
264			   BTRFS_32BIT_MAX_FILE_SIZE >> 40);
265		btrfs_warn(fs_info,
266			   "please consider upgrading to 64bit kernel/hardware");
267	}
268}
269
270void __cold btrfs_err_32bit_limit(struct btrfs_fs_info *fs_info)
271{
272	if (!test_and_set_bit(BTRFS_FS_32BIT_ERROR, &fs_info->flags)) {
273		btrfs_err(fs_info, "reached 32bit limit for logical addresses");
274		btrfs_err(fs_info,
275"due to page cache limit on 32bit systems, metadata beyond %lluT can't be accessed",
276			  BTRFS_32BIT_MAX_FILE_SIZE >> 40);
277		btrfs_err(fs_info,
278			   "please consider upgrading to 64bit kernel/hardware");
279	}
280}
281#endif
282
283/*
284 * Decode unexpected, fatal errors from the caller, issue an alert, and either
285 * panic or BUGs, depending on mount options.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286 */
287__cold
288void __btrfs_panic(const struct btrfs_fs_info *fs_info, const char *function,
289		   unsigned int line, int error, const char *fmt, ...)
290{
291	char *s_id = "<unknown>";
292	const char *errstr;
293	struct va_format vaf = { .fmt = fmt };
294	va_list args;
295
296	if (fs_info)
297		s_id = fs_info->sb->s_id;
298
299	va_start(args, fmt);
300	vaf.va = &args;
301
302	errstr = btrfs_decode_error(error);
303	if (fs_info && (btrfs_test_opt(fs_info, PANIC_ON_FATAL_ERROR)))
304		panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n",
305			s_id, function, line, &vaf, error, errstr);
306
307	btrfs_crit(fs_info, "panic in %s:%d: %pV (errno=%d %s)",
308		   function, line, &vaf, error, errstr);
309	va_end(args);
310	/* Caller calls BUG() */
311}