diff options
Diffstat (limited to 'fs/ubifs/lpt_commit.c')
-rw-r--r-- | fs/ubifs/lpt_commit.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 5c90dec5db0b..0a3c2c3f5c4a 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -1628,29 +1628,35 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1628 | { | 1628 | { |
1629 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; | 1629 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; |
1630 | int ret; | 1630 | int ret; |
1631 | void *buf = c->dbg->buf; | 1631 | void *buf, *p; |
1632 | 1632 | ||
1633 | if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) | 1633 | if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) |
1634 | return 0; | 1634 | return 0; |
1635 | 1635 | ||
1636 | buf = p = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); | ||
1637 | if (!buf) { | ||
1638 | ubifs_err("cannot allocate memory for ltab checking"); | ||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1636 | dbg_lp("LEB %d", lnum); | 1642 | dbg_lp("LEB %d", lnum); |
1637 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1643 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); |
1638 | if (err) { | 1644 | if (err) { |
1639 | dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); | 1645 | dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); |
1640 | return err; | 1646 | goto out; |
1641 | } | 1647 | } |
1642 | while (1) { | 1648 | while (1) { |
1643 | if (!is_a_node(c, buf, len)) { | 1649 | if (!is_a_node(c, p, len)) { |
1644 | int i, pad_len; | 1650 | int i, pad_len; |
1645 | 1651 | ||
1646 | pad_len = get_pad_len(c, buf, len); | 1652 | pad_len = get_pad_len(c, p, len); |
1647 | if (pad_len) { | 1653 | if (pad_len) { |
1648 | buf += pad_len; | 1654 | p += pad_len; |
1649 | len -= pad_len; | 1655 | len -= pad_len; |
1650 | dirty += pad_len; | 1656 | dirty += pad_len; |
1651 | continue; | 1657 | continue; |
1652 | } | 1658 | } |
1653 | if (!dbg_is_all_ff(buf, len)) { | 1659 | if (!dbg_is_all_ff(p, len)) { |
1654 | dbg_msg("invalid empty space in LEB %d at %d", | 1660 | dbg_msg("invalid empty space in LEB %d at %d", |
1655 | lnum, c->leb_size - len); | 1661 | lnum, c->leb_size - len); |
1656 | err = -EINVAL; | 1662 | err = -EINVAL; |
@@ -1668,16 +1674,21 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1668 | lnum, dirty, c->ltab[i].dirty); | 1674 | lnum, dirty, c->ltab[i].dirty); |
1669 | err = -EINVAL; | 1675 | err = -EINVAL; |
1670 | } | 1676 | } |
1671 | return err; | 1677 | goto out; |
1672 | } | 1678 | } |
1673 | node_type = get_lpt_node_type(c, buf, &node_num); | 1679 | node_type = get_lpt_node_type(c, p, &node_num); |
1674 | node_len = get_lpt_node_len(c, node_type); | 1680 | node_len = get_lpt_node_len(c, node_type); |
1675 | ret = dbg_is_node_dirty(c, node_type, lnum, c->leb_size - len); | 1681 | ret = dbg_is_node_dirty(c, node_type, lnum, c->leb_size - len); |
1676 | if (ret == 1) | 1682 | if (ret == 1) |
1677 | dirty += node_len; | 1683 | dirty += node_len; |
1678 | buf += node_len; | 1684 | p += node_len; |
1679 | len -= node_len; | 1685 | len -= node_len; |
1680 | } | 1686 | } |
1687 | |||
1688 | err = 0; | ||
1689 | out: | ||
1690 | vfree(buf); | ||
1691 | return err; | ||
1681 | } | 1692 | } |
1682 | 1693 | ||
1683 | /** | 1694 | /** |
@@ -1870,25 +1881,31 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | |||
1870 | static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | 1881 | static void dump_lpt_leb(const struct ubifs_info *c, int lnum) |
1871 | { | 1882 | { |
1872 | int err, len = c->leb_size, node_type, node_num, node_len, offs; | 1883 | int err, len = c->leb_size, node_type, node_num, node_len, offs; |
1873 | void *buf = c->dbg->buf; | 1884 | void *buf, *p; |
1874 | 1885 | ||
1875 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", | 1886 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", |
1876 | current->pid, lnum); | 1887 | current->pid, lnum); |
1888 | buf = p = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL); | ||
1889 | if (!buf) { | ||
1890 | ubifs_err("cannot allocate memory to dump LPT"); | ||
1891 | return; | ||
1892 | } | ||
1893 | |||
1877 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1894 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); |
1878 | if (err) { | 1895 | if (err) { |
1879 | ubifs_err("cannot read LEB %d, error %d", lnum, err); | 1896 | ubifs_err("cannot read LEB %d, error %d", lnum, err); |
1880 | return; | 1897 | goto out; |
1881 | } | 1898 | } |
1882 | while (1) { | 1899 | while (1) { |
1883 | offs = c->leb_size - len; | 1900 | offs = c->leb_size - len; |
1884 | if (!is_a_node(c, buf, len)) { | 1901 | if (!is_a_node(c, p, len)) { |
1885 | int pad_len; | 1902 | int pad_len; |
1886 | 1903 | ||
1887 | pad_len = get_pad_len(c, buf, len); | 1904 | pad_len = get_pad_len(c, p, len); |
1888 | if (pad_len) { | 1905 | if (pad_len) { |
1889 | printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n", | 1906 | printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n", |
1890 | lnum, offs, pad_len); | 1907 | lnum, offs, pad_len); |
1891 | buf += pad_len; | 1908 | p += pad_len; |
1892 | len -= pad_len; | 1909 | len -= pad_len; |
1893 | continue; | 1910 | continue; |
1894 | } | 1911 | } |
@@ -1898,7 +1915,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1898 | break; | 1915 | break; |
1899 | } | 1916 | } |
1900 | 1917 | ||
1901 | node_type = get_lpt_node_type(c, buf, &node_num); | 1918 | node_type = get_lpt_node_type(c, p, &node_num); |
1902 | switch (node_type) { | 1919 | switch (node_type) { |
1903 | case UBIFS_LPT_PNODE: | 1920 | case UBIFS_LPT_PNODE: |
1904 | { | 1921 | { |
@@ -1923,7 +1940,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1923 | else | 1940 | else |
1924 | printk(KERN_DEBUG "LEB %d:%d, nnode, ", | 1941 | printk(KERN_DEBUG "LEB %d:%d, nnode, ", |
1925 | lnum, offs); | 1942 | lnum, offs); |
1926 | err = ubifs_unpack_nnode(c, buf, &nnode); | 1943 | err = ubifs_unpack_nnode(c, p, &nnode); |
1927 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 1944 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
1928 | printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, | 1945 | printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, |
1929 | nnode.nbranch[i].offs); | 1946 | nnode.nbranch[i].offs); |
@@ -1944,15 +1961,18 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1944 | break; | 1961 | break; |
1945 | default: | 1962 | default: |
1946 | ubifs_err("LPT node type %d not recognized", node_type); | 1963 | ubifs_err("LPT node type %d not recognized", node_type); |
1947 | return; | 1964 | goto out; |
1948 | } | 1965 | } |
1949 | 1966 | ||
1950 | buf += node_len; | 1967 | p += node_len; |
1951 | len -= node_len; | 1968 | len -= node_len; |
1952 | } | 1969 | } |
1953 | 1970 | ||
1954 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", | 1971 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", |
1955 | current->pid, lnum); | 1972 | current->pid, lnum); |
1973 | out: | ||
1974 | vfree(buf); | ||
1975 | return; | ||
1956 | } | 1976 | } |
1957 | 1977 | ||
1958 | /** | 1978 | /** |