aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ubifs/debug.c22
-rw-r--r--fs/ubifs/debug.h10
-rw-r--r--fs/ubifs/ubifs.h14
3 files changed, 42 insertions, 4 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 1a626484f8ae..564e330d05b1 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -3081,6 +3081,28 @@ void dbg_debugfs_exit(void)
3081 debugfs_remove_recursive(dfs_rootdir); 3081 debugfs_remove_recursive(dfs_rootdir);
3082} 3082}
3083 3083
3084void ubifs_assert_failed(struct ubifs_info *c, const char *expr,
3085 const char *file, int line)
3086{
3087 ubifs_err(c, "UBIFS assert failed: %s, in %s:%u", expr, file, line);
3088
3089 switch (c->assert_action) {
3090 case ASSACT_PANIC:
3091 BUG();
3092 break;
3093
3094 case ASSACT_RO:
3095 ubifs_ro_mode(c, -EINVAL);
3096 break;
3097
3098 case ASSACT_REPORT:
3099 default:
3100 dump_stack();
3101 break;
3102
3103 }
3104}
3105
3084/** 3106/**
3085 * ubifs_debugging_init - initialize UBIFS debugging. 3107 * ubifs_debugging_init - initialize UBIFS debugging.
3086 * @c: UBIFS file-system description object 3108 * @c: UBIFS file-system description object
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 981a3fa081f3..64c6977c189b 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -148,18 +148,20 @@ struct ubifs_global_debug_info {
148 unsigned int tst_rcvry:1; 148 unsigned int tst_rcvry:1;
149}; 149};
150 150
151void ubifs_assert_failed(struct ubifs_info *c, const char *expr,
152 const char *file, int line);
153
151#define ubifs_assert(c, expr) do { \ 154#define ubifs_assert(c, expr) do { \
152 if (unlikely(!(expr))) { \ 155 if (unlikely(!(expr))) { \
153 pr_crit("UBIFS assert failed in %s at %u (pid %d)\n", \ 156 ubifs_assert_failed((struct ubifs_info *)c, #expr, __FILE__, \
154 __func__, __LINE__, current->pid); \ 157 __LINE__); \
155 dump_stack(); \
156 } \ 158 } \
157} while (0) 159} while (0)
158 160
159#define ubifs_assert_cmt_locked(c) do { \ 161#define ubifs_assert_cmt_locked(c) do { \
160 if (unlikely(down_write_trylock(&(c)->commit_sem))) { \ 162 if (unlikely(down_write_trylock(&(c)->commit_sem))) { \
161 up_write(&(c)->commit_sem); \ 163 up_write(&(c)->commit_sem); \
162 pr_crit("commit lock is not locked!\n"); \ 164 ubifs_err(c, "commit lock is not locked!\n"); \
163 ubifs_assert(c, 0); \ 165 ubifs_assert(c, 0); \
164 } \ 166 } \
165} while (0) 167} while (0)
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index d17e895ee87f..4368cde476b0 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -258,6 +258,18 @@ enum {
258 LEB_RETAINED, 258 LEB_RETAINED,
259}; 259};
260 260
261/*
262 * Action taken upon a failed ubifs_assert().
263 * @ASSACT_REPORT: just report the failed assertion
264 * @ASSACT_RO: switch to read-only mode
265 * @ASSACT_PANIC: call BUG() and possible panic the kernel
266 */
267enum {
268 ASSACT_REPORT = 0,
269 ASSACT_RO,
270 ASSACT_PANIC,
271};
272
261/** 273/**
262 * struct ubifs_old_idx - index node obsoleted since last commit start. 274 * struct ubifs_old_idx - index node obsoleted since last commit start.
263 * @rb: rb-tree node 275 * @rb: rb-tree node
@@ -1015,6 +1027,7 @@ struct ubifs_debug_info;
1015 * @bulk_read: enable bulk-reads 1027 * @bulk_read: enable bulk-reads
1016 * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc) 1028 * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc)
1017 * @rw_incompat: the media is not R/W compatible 1029 * @rw_incompat: the media is not R/W compatible
1030 * @assert_action: action to take when a ubifs_assert() fails
1018 * 1031 *
1019 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and 1032 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and
1020 * @calc_idx_sz 1033 * @calc_idx_sz
@@ -1256,6 +1269,7 @@ struct ubifs_info {
1256 unsigned int bulk_read:1; 1269 unsigned int bulk_read:1;
1257 unsigned int default_compr:2; 1270 unsigned int default_compr:2;
1258 unsigned int rw_incompat:1; 1271 unsigned int rw_incompat:1;
1272 unsigned int assert_action:2;
1259 1273
1260 struct mutex tnc_mutex; 1274 struct mutex tnc_mutex;
1261 struct ubifs_zbranch zroot; 1275 struct ubifs_zbranch zroot;