lpt_commit.c (527491885554002837b5742202adc0ab5f536e54) | lpt_commit.c (17c2f9f85c896b48a5d74a9155d99ec5b241a0e6) |
---|---|
1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 1588 unchanged lines hidden (view full) --- 1597 * @offs: offset where node was written 1598 * 1599 * This function returns %0 on success and a negative error code on failure. 1600 */ 1601static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) 1602{ 1603 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; 1604 int ret; | 1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 1588 unchanged lines hidden (view full) --- 1597 * @offs: offset where node was written 1598 * 1599 * This function returns %0 on success and a negative error code on failure. 1600 */ 1601static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) 1602{ 1603 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; 1604 int ret; |
1605 void *buf = c->dbg_buf; | 1605 void *buf = c->dbg->buf; |
1606 1607 dbg_lp("LEB %d", lnum); 1608 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); 1609 if (err) { 1610 dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); 1611 return err; 1612 } 1613 while (1) { --- 112 unchanged lines hidden (view full) --- 1726 * @c: the UBIFS file-system description object 1727 * @action: action 1728 * @len: length written 1729 * 1730 * This function returns %0 on success and a negative error code on failure. 1731 */ 1732int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) 1733{ | 1606 1607 dbg_lp("LEB %d", lnum); 1608 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); 1609 if (err) { 1610 dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); 1611 return err; 1612 } 1613 while (1) { --- 112 unchanged lines hidden (view full) --- 1726 * @c: the UBIFS file-system description object 1727 * @action: action 1728 * @len: length written 1729 * 1730 * This function returns %0 on success and a negative error code on failure. 1731 */ 1732int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) 1733{ |
1734 struct ubifs_debug_info *d = c->dbg; |
|
1734 long long chk_lpt_sz, lpt_sz; 1735 int err = 0; 1736 1737 switch (action) { 1738 case 0: | 1735 long long chk_lpt_sz, lpt_sz; 1736 int err = 0; 1737 1738 switch (action) { 1739 case 0: |
1739 c->chk_lpt_sz = 0; 1740 c->chk_lpt_sz2 = 0; 1741 c->chk_lpt_lebs = 0; 1742 c->chk_lpt_wastage = 0; | 1740 d->chk_lpt_sz = 0; 1741 d->chk_lpt_sz2 = 0; 1742 d->chk_lpt_lebs = 0; 1743 d->chk_lpt_wastage = 0; |
1743 if (c->dirty_pn_cnt > c->pnode_cnt) { 1744 dbg_err("dirty pnodes %d exceed max %d", 1745 c->dirty_pn_cnt, c->pnode_cnt); 1746 err = -EINVAL; 1747 } 1748 if (c->dirty_nn_cnt > c->nnode_cnt) { 1749 dbg_err("dirty nnodes %d exceed max %d", 1750 c->dirty_nn_cnt, c->nnode_cnt); 1751 err = -EINVAL; 1752 } 1753 return err; 1754 case 1: | 1744 if (c->dirty_pn_cnt > c->pnode_cnt) { 1745 dbg_err("dirty pnodes %d exceed max %d", 1746 c->dirty_pn_cnt, c->pnode_cnt); 1747 err = -EINVAL; 1748 } 1749 if (c->dirty_nn_cnt > c->nnode_cnt) { 1750 dbg_err("dirty nnodes %d exceed max %d", 1751 c->dirty_nn_cnt, c->nnode_cnt); 1752 err = -EINVAL; 1753 } 1754 return err; 1755 case 1: |
1755 c->chk_lpt_sz += len; | 1756 d->chk_lpt_sz += len; |
1756 return 0; 1757 case 2: | 1757 return 0; 1758 case 2: |
1758 c->chk_lpt_sz += len; 1759 c->chk_lpt_wastage += len; 1760 c->chk_lpt_lebs += 1; | 1759 d->chk_lpt_sz += len; 1760 d->chk_lpt_wastage += len; 1761 d->chk_lpt_lebs += 1; |
1761 return 0; 1762 case 3: 1763 chk_lpt_sz = c->leb_size; | 1762 return 0; 1763 case 3: 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 } | 1770 err = -EINVAL; 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 } | 1775 err = -EINVAL; 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 } | 1780 err = -EINVAL; 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 } 1786 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; 1787 lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; 1788 lpt_sz += c->ltab_sz; 1789 if (c->big_lpt) 1790 lpt_sz += c->lsave_sz; | 1785 err = -EINVAL; 1786 } 1787 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; 1788 lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; 1789 lpt_sz += c->ltab_sz; 1790 if (c->big_lpt) 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 } 1796 if (err) 1797 dbg_dump_lpt_info(c); | 1795 err = -EINVAL; 1796 } 1797 if (err) 1798 dbg_dump_lpt_info(c); |
1798 c->chk_lpt_sz2 = c->chk_lpt_sz; 1799 c->chk_lpt_sz = 0; 1800 c->chk_lpt_wastage = 0; 1801 c->chk_lpt_lebs = 0; 1802 c->new_nhead_offs = len; | 1799 d->chk_lpt_sz2 = d->chk_lpt_sz; 1800 d->chk_lpt_sz = 0; 1801 d->chk_lpt_wastage = 0; 1802 d->chk_lpt_lebs = 0; 1803 d->new_nhead_offs = len; |
1803 return err; 1804 case 4: | 1804 return err; 1805 case 4: |
1805 c->chk_lpt_sz += len; 1806 c->chk_lpt_wastage += len; | 1806 d->chk_lpt_sz += len; 1807 d->chk_lpt_wastage += len; |
1807 return 0; 1808 default: 1809 return -EINVAL; 1810 } 1811} 1812 1813#endif /* CONFIG_UBIFS_FS_DEBUG */ | 1808 return 0; 1809 default: 1810 return -EINVAL; 1811 } 1812} 1813 1814#endif /* CONFIG_UBIFS_FS_DEBUG */ |