提交 25886a36 编写于 作者: A Artem Bityutskiy 提交者: Artem Bityutskiy

UBI: always dump the stack on error

UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to
link as few as possible when debugging is disabled, but the downside is
that most people produce bug reports which are difficult to understand.

This patch weeds out the 'ubi_dbg_dump_stack()' function and turns it
into 'dump_stack()' - it is always useful to have stack dump in case of
an error.
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
上级 56b04e3e
...@@ -28,14 +28,12 @@ ...@@ -28,14 +28,12 @@
if (unlikely(!(expr))) { \ if (unlikely(!(expr))) { \
printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
__func__, __LINE__, current->pid); \ __func__, __LINE__, current->pid); \
ubi_dbg_dump_stack(); \ dump_stack(); \
} \ } \
} while (0) } while (0)
#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) #define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
#define ubi_dbg_dump_stack() dump_stack()
#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \ #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
print_hex_dump(l, ps, pt, r, g, b, len, a) print_hex_dump(l, ps, pt, r, g, b, len, a)
...@@ -194,7 +192,6 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) ...@@ -194,7 +192,6 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
#define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) #define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) #define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
static inline void ubi_dbg_dump_stack(void) { return; }
static inline void static inline void
ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { return; } ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { return; }
static inline void static inline void
......
...@@ -198,7 +198,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, ...@@ -198,7 +198,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
ubi_err("error %d%s while reading %d bytes from PEB %d:%d, " ubi_err("error %d%s while reading %d bytes from PEB %d:%d, "
"read %zd bytes", err, errstr, len, pnum, offset, read); "read %zd bytes", err, errstr, len, pnum, offset, read);
ubi_dbg_dump_stack(); dump_stack();
/* /*
* The driver should never return -EBADMSG if it failed to read * The driver should never return -EBADMSG if it failed to read
...@@ -284,7 +284,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -284,7 +284,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
if (ubi_dbg_is_write_failure(ubi)) { if (ubi_dbg_is_write_failure(ubi)) {
dbg_err("cannot write %d bytes to PEB %d:%d " dbg_err("cannot write %d bytes to PEB %d:%d "
"(emulated)", len, pnum, offset); "(emulated)", len, pnum, offset);
ubi_dbg_dump_stack(); dump_stack();
return -EIO; return -EIO;
} }
...@@ -293,7 +293,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -293,7 +293,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
if (err) { if (err) {
ubi_err("error %d while writing %d bytes to PEB %d:%d, written " ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
"%zd bytes", err, len, pnum, offset, written); "%zd bytes", err, len, pnum, offset, written);
ubi_dbg_dump_stack(); dump_stack();
ubi_dbg_dump_flash(ubi, pnum, offset, len); ubi_dbg_dump_flash(ubi, pnum, offset, len);
} else } else
ubi_assert(written == len); ubi_assert(written == len);
...@@ -370,7 +370,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -370,7 +370,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
goto retry; goto retry;
} }
ubi_err("cannot erase PEB %d, error %d", pnum, err); ubi_err("cannot erase PEB %d, error %d", pnum, err);
ubi_dbg_dump_stack(); dump_stack();
return err; return err;
} }
...@@ -388,7 +388,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -388,7 +388,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
goto retry; goto retry;
} }
ubi_err("cannot erase PEB %d", pnum); ubi_err("cannot erase PEB %d", pnum);
ubi_dbg_dump_stack(); dump_stack();
return -EIO; return -EIO;
} }
...@@ -722,7 +722,7 @@ static int validate_ec_hdr(const struct ubi_device *ubi, ...@@ -722,7 +722,7 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
bad: bad:
ubi_err("bad EC header"); ubi_err("bad EC header");
ubi_dbg_dump_ec_hdr(ec_hdr); ubi_dbg_dump_ec_hdr(ec_hdr);
ubi_dbg_dump_stack(); dump_stack();
return 1; return 1;
} }
...@@ -998,7 +998,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi, ...@@ -998,7 +998,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
bad: bad:
ubi_err("bad VID header"); ubi_err("bad VID header");
ubi_dbg_dump_vid_hdr(vid_hdr); ubi_dbg_dump_vid_hdr(vid_hdr);
ubi_dbg_dump_stack(); dump_stack();
return 1; return 1;
} }
...@@ -1153,7 +1153,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum) ...@@ -1153,7 +1153,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
return err; return err;
ubi_err("paranoid check failed for PEB %d", pnum); ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_stack(); dump_stack();
return err > 0 ? -EINVAL : err; return err > 0 ? -EINVAL : err;
} }
...@@ -1192,7 +1192,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1192,7 +1192,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
fail: fail:
ubi_dbg_dump_ec_hdr(ec_hdr); ubi_dbg_dump_ec_hdr(ec_hdr);
ubi_dbg_dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
} }
...@@ -1227,7 +1227,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1227,7 +1227,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc); ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc);
ubi_err("paranoid check failed for PEB %d", pnum); ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_ec_hdr(ec_hdr); ubi_dbg_dump_ec_hdr(ec_hdr);
ubi_dbg_dump_stack(); dump_stack();
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
...@@ -1275,7 +1275,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1275,7 +1275,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
fail: fail:
ubi_err("paranoid check failed for PEB %d", pnum); ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_vid_hdr(vid_hdr); ubi_dbg_dump_vid_hdr(vid_hdr);
ubi_dbg_dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
} }
...@@ -1315,7 +1315,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1315,7 +1315,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
"read %#08x", pnum, crc, hdr_crc); "read %#08x", pnum, crc, hdr_crc);
ubi_err("paranoid check failed for PEB %d", pnum); ubi_err("paranoid check failed for PEB %d", pnum);
ubi_dbg_dump_vid_hdr(vid_hdr); ubi_dbg_dump_vid_hdr(vid_hdr);
ubi_dbg_dump_stack(); dump_stack();
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
...@@ -1380,7 +1380,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum, ...@@ -1380,7 +1380,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
i, i + dump_len); i, i + dump_len);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
buf1 + i, dump_len, 1); buf1 + i, dump_len, 1);
ubi_dbg_dump_stack(); dump_stack();
err = -EINVAL; err = -EINVAL;
goto out_free; goto out_free;
} }
...@@ -1443,7 +1443,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -1443,7 +1443,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
err = -EINVAL; err = -EINVAL;
error: error:
ubi_dbg_dump_stack(); dump_stack();
vfree(buf); vfree(buf);
return err; return err;
} }
......
...@@ -1598,7 +1598,7 @@ static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) ...@@ -1598,7 +1598,7 @@ static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)
ubi_dbg_dump_vid_hdr(vidh); ubi_dbg_dump_vid_hdr(vidh);
out: out:
ubi_dbg_dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
} }
......
...@@ -667,7 +667,7 @@ static inline void ubi_ro_mode(struct ubi_device *ubi) ...@@ -667,7 +667,7 @@ static inline void ubi_ro_mode(struct ubi_device *ubi)
if (!ubi->ro_mode) { if (!ubi->ro_mode) {
ubi->ro_mode = 1; ubi->ro_mode = 1;
ubi_warn("switch to read-only mode"); ubi_warn("switch to read-only mode");
ubi_dbg_dump_stack(); dump_stack();
} }
} }
......
...@@ -1603,7 +1603,7 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec) ...@@ -1603,7 +1603,7 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
if (ec != read_ec) { if (ec != read_ec) {
ubi_err("paranoid check failed for PEB %d", pnum); ubi_err("paranoid check failed for PEB %d", pnum);
ubi_err("read EC is %lld, should be %d", read_ec, ec); ubi_err("read EC is %lld, should be %d", read_ec, ec);
ubi_dbg_dump_stack(); dump_stack();
err = 1; err = 1;
} else } else
err = 0; err = 0;
...@@ -1634,7 +1634,7 @@ static int paranoid_check_in_wl_tree(const struct ubi_device *ubi, ...@@ -1634,7 +1634,7 @@ static int paranoid_check_in_wl_tree(const struct ubi_device *ubi,
ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ", ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ",
e->pnum, e->ec, root); e->pnum, e->ec, root);
ubi_dbg_dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
} }
...@@ -1662,7 +1662,7 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi, ...@@ -1662,7 +1662,7 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi,
ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue", ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue",
e->pnum, e->ec); e->pnum, e->ec);
ubi_dbg_dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册