diff options
-rw-r--r-- | fs/ubifs/io.c | 15 | ||||
-rw-r--r-- | fs/ubifs/lpt.c | 17 | ||||
-rw-r--r-- | fs/ubifs/lpt_commit.c | 23 | ||||
-rw-r--r-- | fs/ubifs/recovery.c | 17 | ||||
-rw-r--r-- | fs/ubifs/replay.c | 3 | ||||
-rw-r--r-- | fs/ubifs/sb.c | 2 | ||||
-rw-r--r-- | fs/ubifs/scan.c | 2 | ||||
-rw-r--r-- | fs/ubifs/tnc.c | 8 |
8 files changed, 40 insertions, 47 deletions
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 239899d7bf3f..f58f11bed387 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
@@ -941,13 +941,9 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len, | |||
941 | 941 | ||
942 | if (rlen > 0) { | 942 | if (rlen > 0) { |
943 | /* Read everything that goes before write-buffer */ | 943 | /* Read everything that goes before write-buffer */ |
944 | err = ubi_read(c->ubi, lnum, buf, offs, rlen); | 944 | err = ubifs_leb_read(c, lnum, buf, offs, rlen, 0); |
945 | if (err && err != -EBADMSG) { | 945 | if (err && err != -EBADMSG) |
946 | ubifs_err("failed to read node %d from LEB %d:%d, " | ||
947 | "error %d", type, lnum, offs, err); | ||
948 | dbg_dump_stack(); | ||
949 | return err; | 946 | return err; |
950 | } | ||
951 | } | 947 | } |
952 | 948 | ||
953 | if (type != ch->node_type) { | 949 | if (type != ch->node_type) { |
@@ -1002,12 +998,9 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, | |||
1002 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | 998 | ubifs_assert(!(offs & 7) && offs < c->leb_size); |
1003 | ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); | 999 | ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); |
1004 | 1000 | ||
1005 | err = ubi_read(c->ubi, lnum, buf, offs, len); | 1001 | err = ubifs_leb_read(c, lnum, buf, offs, len, 0); |
1006 | if (err && err != -EBADMSG) { | 1002 | if (err && err != -EBADMSG) |
1007 | ubifs_err("cannot read node %d from LEB %d:%d, error %d", | ||
1008 | type, lnum, offs, err); | ||
1009 | return err; | 1003 | return err; |
1010 | } | ||
1011 | 1004 | ||
1012 | if (type != ch->node_type) { | 1005 | if (type != ch->node_type) { |
1013 | ubifs_err("bad node type (%d but expected %d)", | 1006 | ubifs_err("bad node type (%d but expected %d)", |
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index ab91ca628455..8b9ee9fe0a41 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -1222,7 +1222,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) | |||
1222 | if (c->big_lpt) | 1222 | if (c->big_lpt) |
1223 | nnode->num = calc_nnode_num_from_parent(c, parent, iip); | 1223 | nnode->num = calc_nnode_num_from_parent(c, parent, iip); |
1224 | } else { | 1224 | } else { |
1225 | err = ubi_read(c->ubi, lnum, buf, offs, c->nnode_sz); | 1225 | err = ubifs_leb_read(c, lnum, buf, offs, c->nnode_sz, 1); |
1226 | if (err) | 1226 | if (err) |
1227 | goto out; | 1227 | goto out; |
1228 | err = ubifs_unpack_nnode(c, buf, nnode); | 1228 | err = ubifs_unpack_nnode(c, buf, nnode); |
@@ -1291,7 +1291,7 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) | |||
1291 | lprops->flags = ubifs_categorize_lprops(c, lprops); | 1291 | lprops->flags = ubifs_categorize_lprops(c, lprops); |
1292 | } | 1292 | } |
1293 | } else { | 1293 | } else { |
1294 | err = ubi_read(c->ubi, lnum, buf, offs, c->pnode_sz); | 1294 | err = ubifs_leb_read(c, lnum, buf, offs, c->pnode_sz, 1); |
1295 | if (err) | 1295 | if (err) |
1296 | goto out; | 1296 | goto out; |
1297 | err = unpack_pnode(c, buf, pnode); | 1297 | err = unpack_pnode(c, buf, pnode); |
@@ -1333,7 +1333,7 @@ static int read_ltab(struct ubifs_info *c) | |||
1333 | buf = vmalloc(c->ltab_sz); | 1333 | buf = vmalloc(c->ltab_sz); |
1334 | if (!buf) | 1334 | if (!buf) |
1335 | return -ENOMEM; | 1335 | return -ENOMEM; |
1336 | err = ubi_read(c->ubi, c->ltab_lnum, buf, c->ltab_offs, c->ltab_sz); | 1336 | err = ubifs_leb_read(c, c->ltab_lnum, buf, c->ltab_offs, c->ltab_sz, 1); |
1337 | if (err) | 1337 | if (err) |
1338 | goto out; | 1338 | goto out; |
1339 | err = unpack_ltab(c, buf); | 1339 | err = unpack_ltab(c, buf); |
@@ -1356,7 +1356,8 @@ static int read_lsave(struct ubifs_info *c) | |||
1356 | buf = vmalloc(c->lsave_sz); | 1356 | buf = vmalloc(c->lsave_sz); |
1357 | if (!buf) | 1357 | if (!buf) |
1358 | return -ENOMEM; | 1358 | return -ENOMEM; |
1359 | err = ubi_read(c->ubi, c->lsave_lnum, buf, c->lsave_offs, c->lsave_sz); | 1359 | err = ubifs_leb_read(c, c->lsave_lnum, buf, c->lsave_offs, |
1360 | c->lsave_sz, 1); | ||
1360 | if (err) | 1361 | if (err) |
1361 | goto out; | 1362 | goto out; |
1362 | err = unpack_lsave(c, buf); | 1363 | err = unpack_lsave(c, buf); |
@@ -1816,8 +1817,8 @@ static struct ubifs_nnode *scan_get_nnode(struct ubifs_info *c, | |||
1816 | if (c->big_lpt) | 1817 | if (c->big_lpt) |
1817 | nnode->num = calc_nnode_num_from_parent(c, parent, iip); | 1818 | nnode->num = calc_nnode_num_from_parent(c, parent, iip); |
1818 | } else { | 1819 | } else { |
1819 | err = ubi_read(c->ubi, branch->lnum, buf, branch->offs, | 1820 | err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, |
1820 | c->nnode_sz); | 1821 | c->nnode_sz, 1); |
1821 | if (err) | 1822 | if (err) |
1822 | return ERR_PTR(err); | 1823 | return ERR_PTR(err); |
1823 | err = ubifs_unpack_nnode(c, buf, nnode); | 1824 | err = ubifs_unpack_nnode(c, buf, nnode); |
@@ -1885,8 +1886,8 @@ static struct ubifs_pnode *scan_get_pnode(struct ubifs_info *c, | |||
1885 | ubifs_assert(branch->lnum >= c->lpt_first && | 1886 | ubifs_assert(branch->lnum >= c->lpt_first && |
1886 | branch->lnum <= c->lpt_last); | 1887 | branch->lnum <= c->lpt_last); |
1887 | ubifs_assert(branch->offs >= 0 && branch->offs < c->leb_size); | 1888 | ubifs_assert(branch->offs >= 0 && branch->offs < c->leb_size); |
1888 | err = ubi_read(c->ubi, branch->lnum, buf, branch->offs, | 1889 | err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, |
1889 | c->pnode_sz); | 1890 | c->pnode_sz, 1); |
1890 | if (err) | 1891 | if (err) |
1891 | return ERR_PTR(err); | 1892 | return ERR_PTR(err); |
1892 | err = unpack_pnode(c, buf, pnode); | 1893 | err = unpack_pnode(c, buf, pnode); |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index f13addf72e89..cddd6bd214f4 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -1161,11 +1161,11 @@ static int lpt_gc_lnum(struct ubifs_info *c, int lnum) | |||
1161 | void *buf = c->lpt_buf; | 1161 | void *buf = c->lpt_buf; |
1162 | 1162 | ||
1163 | dbg_lp("LEB %d", lnum); | 1163 | dbg_lp("LEB %d", lnum); |
1164 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1164 | |
1165 | if (err) { | 1165 | err = ubifs_leb_read(c, lnum, buf, 0, c->leb_size, 1); |
1166 | ubifs_err("cannot read LEB %d, error %d", lnum, err); | 1166 | if (err) |
1167 | return err; | 1167 | return err; |
1168 | } | 1168 | |
1169 | while (1) { | 1169 | while (1) { |
1170 | if (!is_a_node(c, buf, len)) { | 1170 | if (!is_a_node(c, buf, len)) { |
1171 | int pad_len; | 1171 | int pad_len; |
@@ -1651,11 +1651,11 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | dbg_lp("LEB %d", lnum); | 1653 | dbg_lp("LEB %d", lnum); |
1654 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1654 | |
1655 | if (err) { | 1655 | err = ubifs_leb_read(c, lnum, buf, 0, c->leb_size, 1); |
1656 | dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); | 1656 | if (err) |
1657 | goto out; | 1657 | goto out; |
1658 | } | 1658 | |
1659 | while (1) { | 1659 | while (1) { |
1660 | if (!is_a_node(c, p, len)) { | 1660 | if (!is_a_node(c, p, len)) { |
1661 | int i, pad_len; | 1661 | int i, pad_len; |
@@ -1902,11 +1902,10 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1902 | return; | 1902 | return; |
1903 | } | 1903 | } |
1904 | 1904 | ||
1905 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1905 | err = ubifs_leb_read(c, lnum, buf, 0, c->leb_size, 1); |
1906 | if (err) { | 1906 | if (err) |
1907 | ubifs_err("cannot read LEB %d, error %d", lnum, err); | ||
1908 | goto out; | 1907 | goto out; |
1909 | } | 1908 | |
1910 | while (1) { | 1909 | while (1) { |
1911 | offs = c->leb_size - len; | 1910 | offs = c->leb_size - len; |
1912 | if (!is_a_node(c, p, len)) { | 1911 | if (!is_a_node(c, p, len)) { |
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index c59154980719..f28070cb00c6 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
@@ -117,7 +117,7 @@ static int get_master_node(const struct ubifs_info *c, int lnum, void **pbuf, | |||
117 | if (!sbuf) | 117 | if (!sbuf) |
118 | return -ENOMEM; | 118 | return -ENOMEM; |
119 | 119 | ||
120 | err = ubi_read(c->ubi, lnum, sbuf, 0, c->leb_size); | 120 | err = ubifs_leb_read(c, lnum, sbuf, 0, c->leb_size, 0); |
121 | if (err && err != -EBADMSG) | 121 | if (err && err != -EBADMSG) |
122 | goto out_free; | 122 | goto out_free; |
123 | 123 | ||
@@ -539,8 +539,8 @@ static int fix_unclean_leb(struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
539 | int len = ALIGN(endpt, c->min_io_size); | 539 | int len = ALIGN(endpt, c->min_io_size); |
540 | 540 | ||
541 | if (start) { | 541 | if (start) { |
542 | err = ubi_read(c->ubi, lnum, sleb->buf, 0, | 542 | err = ubifs_leb_read(c, lnum, sleb->buf, 0, |
543 | start); | 543 | start, 1); |
544 | if (err) | 544 | if (err) |
545 | return err; | 545 | return err; |
546 | } | 546 | } |
@@ -819,7 +819,8 @@ static int get_cs_sqnum(struct ubifs_info *c, int lnum, int offs, | |||
819 | return -ENOMEM; | 819 | return -ENOMEM; |
820 | if (c->leb_size - offs < UBIFS_CS_NODE_SZ) | 820 | if (c->leb_size - offs < UBIFS_CS_NODE_SZ) |
821 | goto out_err; | 821 | goto out_err; |
822 | err = ubi_read(c->ubi, lnum, (void *)cs_node, offs, UBIFS_CS_NODE_SZ); | 822 | err = ubifs_leb_read(c, lnum, (void *)cs_node, offs, |
823 | UBIFS_CS_NODE_SZ, 0); | ||
823 | if (err && err != -EBADMSG) | 824 | if (err && err != -EBADMSG) |
824 | goto out_free; | 825 | goto out_free; |
825 | ret = ubifs_scan_a_node(c, cs_node, UBIFS_CS_NODE_SZ, lnum, offs, 0); | 826 | ret = ubifs_scan_a_node(c, cs_node, UBIFS_CS_NODE_SZ, lnum, offs, 0); |
@@ -930,12 +931,12 @@ static int recover_head(struct ubifs_info *c, int lnum, int offs, void *sbuf) | |||
930 | return 0; | 931 | return 0; |
931 | 932 | ||
932 | /* Read at the head location and check it is empty flash */ | 933 | /* Read at the head location and check it is empty flash */ |
933 | err = ubi_read(c->ubi, lnum, sbuf, offs, len); | 934 | err = ubifs_leb_read(c, lnum, sbuf, offs, len, 1); |
934 | if (err || !is_empty(sbuf, len)) { | 935 | if (err || !is_empty(sbuf, len)) { |
935 | dbg_rcvry("cleaning head at %d:%d", lnum, offs); | 936 | dbg_rcvry("cleaning head at %d:%d", lnum, offs); |
936 | if (offs == 0) | 937 | if (offs == 0) |
937 | return ubifs_leb_unmap(c, lnum); | 938 | return ubifs_leb_unmap(c, lnum); |
938 | err = ubi_read(c->ubi, lnum, sbuf, 0, offs); | 939 | err = ubifs_leb_read(c, lnum, sbuf, 0, offs, 1); |
939 | if (err) | 940 | if (err) |
940 | return err; | 941 | return err; |
941 | return ubi_leb_change(c->ubi, lnum, sbuf, offs, UBI_UNKNOWN); | 942 | return ubi_leb_change(c->ubi, lnum, sbuf, offs, UBI_UNKNOWN); |
@@ -1008,7 +1009,7 @@ static int clean_an_unclean_leb(struct ubifs_info *c, | |||
1008 | return 0; | 1009 | return 0; |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | err = ubi_read(c->ubi, lnum, buf, offs, len); | 1012 | err = ubifs_leb_read(c, lnum, buf, offs, len, 0); |
1012 | if (err && err != -EBADMSG) | 1013 | if (err && err != -EBADMSG) |
1013 | return err; | 1014 | return err; |
1014 | 1015 | ||
@@ -1453,7 +1454,7 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e) | |||
1453 | if (i_size >= e->d_size) | 1454 | if (i_size >= e->d_size) |
1454 | return 0; | 1455 | return 0; |
1455 | /* Read the LEB */ | 1456 | /* Read the LEB */ |
1456 | err = ubi_read(c->ubi, lnum, c->sbuf, 0, c->leb_size); | 1457 | err = ubifs_leb_read(c, lnum, c->sbuf, 0, c->leb_size, 1); |
1457 | if (err) | 1458 | if (err) |
1458 | goto out; | 1459 | goto out; |
1459 | /* Change the size field and recalculate the CRC */ | 1460 | /* Change the size field and recalculate the CRC */ |
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index 5e97161ce4d3..ccabaf1164b3 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c | |||
@@ -523,8 +523,7 @@ static int is_last_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
523 | if (!list_is_last(&next->list, &jh->buds_list)) | 523 | if (!list_is_last(&next->list, &jh->buds_list)) |
524 | return 0; | 524 | return 0; |
525 | 525 | ||
526 | err = ubi_read(c->ubi, next->lnum, (char *)&data, | 526 | err = ubifs_leb_read(c, next->lnum, (char *)&data, next->start, 4, 1); |
527 | next->start, 4); | ||
528 | if (err) | 527 | if (err) |
529 | return 0; | 528 | return 0; |
530 | 529 | ||
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index c606f010e8df..701dccc1d6de 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c | |||
@@ -678,7 +678,7 @@ static int fixup_leb(struct ubifs_info *c, int lnum, int len) | |||
678 | } | 678 | } |
679 | 679 | ||
680 | dbg_mnt("fixup LEB %d, data len %d", lnum, len); | 680 | dbg_mnt("fixup LEB %d, data len %d", lnum, len); |
681 | err = ubi_read(c->ubi, lnum, c->sbuf, 0, len); | 681 | err = ubifs_leb_read(c, lnum, c->sbuf, 0, len, 1); |
682 | if (err) | 682 | if (err) |
683 | return err; | 683 | return err; |
684 | 684 | ||
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index c7df916dce97..37383e8011b1 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -148,7 +148,7 @@ struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum, | |||
148 | INIT_LIST_HEAD(&sleb->nodes); | 148 | INIT_LIST_HEAD(&sleb->nodes); |
149 | sleb->buf = sbuf; | 149 | sleb->buf = sbuf; |
150 | 150 | ||
151 | err = ubi_read(c->ubi, lnum, sbuf + offs, offs, c->leb_size - offs); | 151 | err = ubifs_leb_read(c, lnum, sbuf + offs, offs, c->leb_size - offs, 0); |
152 | if (err && err != -EBADMSG) { | 152 | if (err && err != -EBADMSG) { |
153 | ubifs_err("cannot read %d bytes from LEB %d:%d," | 153 | ubifs_err("cannot read %d bytes from LEB %d:%d," |
154 | " error %d", c->leb_size - offs, lnum, offs, err); | 154 | " error %d", c->leb_size - offs, lnum, offs, err); |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 526b63cd3333..066738647685 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -462,7 +462,7 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, | |||
462 | 462 | ||
463 | dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len); | 463 | dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len); |
464 | 464 | ||
465 | err = ubi_read(c->ubi, lnum, buf, offs, len); | 465 | err = ubifs_leb_read(c, lnum, buf, offs, len, 1); |
466 | if (err) { | 466 | if (err) { |
467 | ubifs_err("cannot read node type %d from LEB %d:%d, error %d", | 467 | ubifs_err("cannot read node type %d from LEB %d:%d, error %d", |
468 | type, lnum, offs, err); | 468 | type, lnum, offs, err); |
@@ -1666,7 +1666,7 @@ static int read_wbuf(struct ubifs_wbuf *wbuf, void *buf, int len, int lnum, | |||
1666 | if (!overlap) { | 1666 | if (!overlap) { |
1667 | /* We may safely unlock the write-buffer and read the data */ | 1667 | /* We may safely unlock the write-buffer and read the data */ |
1668 | spin_unlock(&wbuf->lock); | 1668 | spin_unlock(&wbuf->lock); |
1669 | return ubi_read(c->ubi, lnum, buf, offs, len); | 1669 | return ubifs_leb_read(c, lnum, buf, offs, len, 0); |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | /* Don't read under wbuf */ | 1672 | /* Don't read under wbuf */ |
@@ -1680,7 +1680,7 @@ static int read_wbuf(struct ubifs_wbuf *wbuf, void *buf, int len, int lnum, | |||
1680 | 1680 | ||
1681 | if (rlen > 0) | 1681 | if (rlen > 0) |
1682 | /* Read everything that goes before write-buffer */ | 1682 | /* Read everything that goes before write-buffer */ |
1683 | return ubi_read(c->ubi, lnum, buf, offs, rlen); | 1683 | return ubifs_leb_read(c, lnum, buf, offs, rlen, 0); |
1684 | 1684 | ||
1685 | return 0; | 1685 | return 0; |
1686 | } | 1686 | } |
@@ -1767,7 +1767,7 @@ int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu) | |||
1767 | if (wbuf) | 1767 | if (wbuf) |
1768 | err = read_wbuf(wbuf, bu->buf, len, lnum, offs); | 1768 | err = read_wbuf(wbuf, bu->buf, len, lnum, offs); |
1769 | else | 1769 | else |
1770 | err = ubi_read(c->ubi, lnum, bu->buf, offs, len); | 1770 | err = ubifs_leb_read(c, lnum, bu->buf, offs, len, 0); |
1771 | 1771 | ||
1772 | /* Check for a race with GC */ | 1772 | /* Check for a race with GC */ |
1773 | if (maybe_leb_gced(c, lnum, bu->gc_seq)) | 1773 | if (maybe_leb_gced(c, lnum, bu->gc_seq)) |