aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lpt_commit.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-10-17 06:31:39 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-03 06:14:33 -0500
commit17c2f9f85c896b48a5d74a9155d99ec5b241a0e6 (patch)
tree9d3e38e673d1d3af650072388a671ec767d3941a /fs/ubifs/lpt_commit.c
parent5dd7cbc083f3a91fa7454125fe992826701b67bc (diff)
UBIFS: separate debugging fields out
Introduce a new data structure which contains all debugging stuff inside. This is cleaner than having debugging stuff directly in 'c'. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/lpt_commit.c')
-rw-r--r--fs/ubifs/lpt_commit.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index a41434b42785..1aefab9f0b5e 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -1602,7 +1602,7 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum)
1602{ 1602{
1603 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; 1603 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len;
1604 int ret; 1604 int ret;
1605 void *buf = c->dbg_buf; 1605 void *buf = c->dbg->buf;
1606 1606
1607 dbg_lp("LEB %d", lnum); 1607 dbg_lp("LEB %d", lnum);
1608 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); 1608 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size);
@@ -1731,15 +1731,16 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
1731 */ 1731 */
1732int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) 1732int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1733{ 1733{
1734 struct ubifs_debug_info *d = c->dbg;
1734 long long chk_lpt_sz, lpt_sz; 1735 long long chk_lpt_sz, lpt_sz;
1735 int err = 0; 1736 int err = 0;
1736 1737
1737 switch (action) { 1738 switch (action) {
1738 case 0: 1739 case 0:
1739 c->chk_lpt_sz = 0; 1740 d->chk_lpt_sz = 0;
1740 c->chk_lpt_sz2 = 0; 1741 d->chk_lpt_sz2 = 0;
1741 c->chk_lpt_lebs = 0; 1742 d->chk_lpt_lebs = 0;
1742 c->chk_lpt_wastage = 0; 1743 d->chk_lpt_wastage = 0;
1743 if (c->dirty_pn_cnt > c->pnode_cnt) { 1744 if (c->dirty_pn_cnt > c->pnode_cnt) {
1744 dbg_err("dirty pnodes %d exceed max %d", 1745 dbg_err("dirty pnodes %d exceed max %d",
1745 c->dirty_pn_cnt, c->pnode_cnt); 1746 c->dirty_pn_cnt, c->pnode_cnt);
@@ -1752,35 +1753,35 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1752 } 1753 }
1753 return err; 1754 return err;
1754 case 1: 1755 case 1:
1755 c->chk_lpt_sz += len; 1756 d->chk_lpt_sz += len;
1756 return 0; 1757 return 0;
1757 case 2: 1758 case 2:
1758 c->chk_lpt_sz += len; 1759 d->chk_lpt_sz += len;
1759 c->chk_lpt_wastage += len; 1760 d->chk_lpt_wastage += len;
1760 c->chk_lpt_lebs += 1; 1761 d->chk_lpt_lebs += 1;
1761 return 0; 1762 return 0;
1762 case 3: 1763 case 3:
1763 chk_lpt_sz = c->leb_size; 1764 chk_lpt_sz = c->leb_size;
1764 chk_lpt_sz *= c->chk_lpt_lebs; 1765 chk_lpt_sz *= d->chk_lpt_lebs;
1765 chk_lpt_sz += len - c->nhead_offs; 1766 chk_lpt_sz += len - c->nhead_offs;
1766 if (c->chk_lpt_sz != chk_lpt_sz) { 1767 if (d->chk_lpt_sz != chk_lpt_sz) {
1767 dbg_err("LPT wrote %lld but space used was %lld", 1768 dbg_err("LPT wrote %lld but space used was %lld",
1768 c->chk_lpt_sz, chk_lpt_sz); 1769 d->chk_lpt_sz, chk_lpt_sz);
1769 err = -EINVAL; 1770 err = -EINVAL;
1770 } 1771 }
1771 if (c->chk_lpt_sz > c->lpt_sz) { 1772 if (d->chk_lpt_sz > c->lpt_sz) {
1772 dbg_err("LPT wrote %lld but lpt_sz is %lld", 1773 dbg_err("LPT wrote %lld but lpt_sz is %lld",
1773 c->chk_lpt_sz, c->lpt_sz); 1774 d->chk_lpt_sz, c->lpt_sz);
1774 err = -EINVAL; 1775 err = -EINVAL;
1775 } 1776 }
1776 if (c->chk_lpt_sz2 && c->chk_lpt_sz != c->chk_lpt_sz2) { 1777 if (d->chk_lpt_sz2 && d->chk_lpt_sz != d->chk_lpt_sz2) {
1777 dbg_err("LPT layout size %lld but wrote %lld", 1778 dbg_err("LPT layout size %lld but wrote %lld",
1778 c->chk_lpt_sz, c->chk_lpt_sz2); 1779 d->chk_lpt_sz, d->chk_lpt_sz2);
1779 err = -EINVAL; 1780 err = -EINVAL;
1780 } 1781 }
1781 if (c->chk_lpt_sz2 && c->new_nhead_offs != len) { 1782 if (d->chk_lpt_sz2 && d->new_nhead_offs != len) {
1782 dbg_err("LPT new nhead offs: expected %d was %d", 1783 dbg_err("LPT new nhead offs: expected %d was %d",
1783 c->new_nhead_offs, len); 1784 d->new_nhead_offs, len);
1784 err = -EINVAL; 1785 err = -EINVAL;
1785 } 1786 }
1786 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; 1787 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz;
@@ -1788,22 +1789,22 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1788 lpt_sz += c->ltab_sz; 1789 lpt_sz += c->ltab_sz;
1789 if (c->big_lpt) 1790 if (c->big_lpt)
1790 lpt_sz += c->lsave_sz; 1791 lpt_sz += c->lsave_sz;
1791 if (c->chk_lpt_sz - c->chk_lpt_wastage > lpt_sz) { 1792 if (d->chk_lpt_sz - d->chk_lpt_wastage > lpt_sz) {
1792 dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld", 1793 dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld",
1793 c->chk_lpt_sz, c->chk_lpt_wastage, lpt_sz); 1794 d->chk_lpt_sz, d->chk_lpt_wastage, lpt_sz);
1794 err = -EINVAL; 1795 err = -EINVAL;
1795 } 1796 }
1796 if (err) 1797 if (err)
1797 dbg_dump_lpt_info(c); 1798 dbg_dump_lpt_info(c);
1798 c->chk_lpt_sz2 = c->chk_lpt_sz; 1799 d->chk_lpt_sz2 = d->chk_lpt_sz;
1799 c->chk_lpt_sz = 0; 1800 d->chk_lpt_sz = 0;
1800 c->chk_lpt_wastage = 0; 1801 d->chk_lpt_wastage = 0;
1801 c->chk_lpt_lebs = 0; 1802 d->chk_lpt_lebs = 0;
1802 c->new_nhead_offs = len; 1803 d->new_nhead_offs = len;
1803 return err; 1804 return err;
1804 case 4: 1805 case 4:
1805 c->chk_lpt_sz += len; 1806 d->chk_lpt_sz += len;
1806 c->chk_lpt_wastage += len; 1807 d->chk_lpt_wastage += len;
1807 return 0; 1808 return 0;
1808 default: 1809 default:
1809 return -EINVAL; 1810 return -EINVAL;