Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

UBI: do not use vmalloc on I/O path

Similar reason as in case of the previous patch: it causes
deadlocks if a filesystem with writeback support works on top
of UBI. So pre-allocate needed buffers when attaching MTD device.
We also need mutexes to protect the buffers, but they do not
cause much contantion because they are used in recovery, torture,
and WL copy routines, which are called seldom.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

+119 -112
+27 -1
drivers/mtd/ubi/build.c
··· 565 565 } 566 566 567 567 ubi = ubi_devices[ubi_devices_cnt] = kzalloc(sizeof(struct ubi_device), 568 - GFP_KERNEL); 568 + GFP_KERNEL); 569 569 if (!ubi) { 570 570 err = -ENOMEM; 571 571 goto out_mtd; ··· 582 582 err = io_init(ubi); 583 583 if (err) 584 584 goto out_free; 585 + 586 + mutex_init(&ubi->buf_mutex); 587 + ubi->peb_buf1 = vmalloc(ubi->peb_size); 588 + if (!ubi->peb_buf1) 589 + goto out_free; 590 + 591 + ubi->peb_buf2 = vmalloc(ubi->peb_size); 592 + if (!ubi->peb_buf2) 593 + goto out_free; 594 + 595 + #ifdef CONFIG_MTD_UBI_DEBUG 596 + mutex_init(&ubi->dbg_buf_mutex); 597 + ubi->dbg_peb_buf = vmalloc(ubi->peb_size); 598 + if (!ubi->dbg_peb_buf) 599 + goto out_free; 600 + #endif 585 601 586 602 err = attach_by_scanning(ubi); 587 603 if (err) { ··· 646 630 ubi_wl_close(ubi); 647 631 vfree(ubi->vtbl); 648 632 out_free: 633 + vfree(ubi->peb_buf1); 634 + vfree(ubi->peb_buf2); 635 + #ifdef CONFIG_MTD_UBI_DEBUG 636 + vfree(ubi->dbg_peb_buf); 637 + #endif 649 638 kfree(ubi); 650 639 out_mtd: 651 640 put_mtd_device(mtd); ··· 672 651 ubi_wl_close(ubi); 673 652 vfree(ubi->vtbl); 674 653 put_mtd_device(ubi->mtd); 654 + vfree(ubi->peb_buf1); 655 + vfree(ubi->peb_buf2); 656 + #ifdef CONFIG_MTD_UBI_DEBUG 657 + vfree(ubi->dbg_peb_buf); 658 + #endif 675 659 kfree(ubi_devices[ubi_num]); 676 660 ubi_devices[ubi_num] = NULL; 677 661 ubi_devices_cnt -= 1;
+24 -46
drivers/mtd/ubi/eba.c
··· 495 495 int err, idx = vol_id2idx(ubi, vol_id), new_pnum, data_size, tries = 0; 496 496 struct ubi_volume *vol = ubi->volumes[idx]; 497 497 struct ubi_vid_hdr *vid_hdr; 498 - unsigned char *new_buf; 499 498 500 499 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); 501 500 if (!vid_hdr) { 502 501 return -ENOMEM; 503 502 } 504 503 504 + mutex_lock(&ubi->buf_mutex); 505 + 505 506 retry: 506 507 new_pnum = ubi_wl_get_peb(ubi, UBI_UNKNOWN); 507 508 if (new_pnum < 0) { 509 + mutex_unlock(&ubi->buf_mutex); 508 510 ubi_free_vid_hdr(ubi, vid_hdr); 509 511 return new_pnum; 510 512 } ··· 526 524 goto write_error; 527 525 528 526 data_size = offset + len; 529 - new_buf = vmalloc(data_size); 530 - if (!new_buf) { 531 - err = -ENOMEM; 532 - goto out_put; 533 - } 534 - memset(new_buf + offset, 0xFF, len); 527 + memset(ubi->peb_buf1 + offset, 0xFF, len); 535 528 536 529 /* Read everything before the area where the write failure happened */ 537 530 if (offset > 0) { 538 - err = ubi_io_read_data(ubi, new_buf, pnum, 0, offset); 539 - if (err && err != UBI_IO_BITFLIPS) { 540 - vfree(new_buf); 531 + err = ubi_io_read_data(ubi, ubi->peb_buf1, pnum, 0, offset); 532 + if (err && err != UBI_IO_BITFLIPS) 541 533 goto out_put; 542 - } 543 534 } 544 535 545 - memcpy(new_buf + offset, buf, len); 536 + memcpy(ubi->peb_buf1 + offset, buf, len); 546 537 547 - err = ubi_io_write_data(ubi, new_buf, new_pnum, 0, data_size); 548 - if (err) { 549 - vfree(new_buf); 538 + err = ubi_io_write_data(ubi, ubi->peb_buf1, new_pnum, 0, data_size); 539 + if (err) 550 540 goto write_error; 551 - } 552 541 553 - vfree(new_buf); 542 + mutex_unlock(&ubi->buf_mutex); 554 543 ubi_free_vid_hdr(ubi, vid_hdr); 555 544 556 545 vol->eba_tbl[lnum] = new_pnum; ··· 551 558 return 0; 552 559 553 560 out_put: 561 + mutex_unlock(&ubi->buf_mutex); 554 562 ubi_wl_put_peb(ubi, new_pnum, 1); 555 563 ubi_free_vid_hdr(ubi, vid_hdr); 556 564 return err; ··· 564 570 ubi_warn("failed to write to PEB %d", new_pnum); 565 571 ubi_wl_put_peb(ubi, new_pnum, 1); 566 572 if (++tries > UBI_IO_RETRIES) { 573 + mutex_unlock(&ubi->buf_mutex); 567 574 ubi_free_vid_hdr(ubi, vid_hdr); 568 575 return err; 569 576 } ··· 960 965 int err, vol_id, lnum, data_size, aldata_size, pnum, idx; 961 966 struct ubi_volume *vol; 962 967 uint32_t crc; 963 - void *buf, *buf1 = NULL; 964 968 965 969 vol_id = be32_to_cpu(vid_hdr->vol_id); 966 970 lnum = be32_to_cpu(vid_hdr->lnum); ··· 973 979 data_size = aldata_size = 974 980 ubi->leb_size - be32_to_cpu(vid_hdr->data_pad); 975 981 976 - buf = vmalloc(aldata_size); 977 - if (!buf) 978 - return -ENOMEM; 979 - 980 982 /* 981 983 * We do not want anybody to write to this logical eraseblock while we 982 984 * are moving it, so we lock it. 983 985 */ 984 986 err = leb_write_lock(ubi, vol_id, lnum); 985 - if (err) { 986 - vfree(buf); 987 + if (err) 987 988 return err; 988 - } 989 + 990 + mutex_lock(&ubi->buf_mutex); 989 991 990 992 /* 991 993 * But the logical eraseblock might have been put by this time. ··· 1013 1023 /* OK, now the LEB is locked and we can safely start moving it */ 1014 1024 1015 1025 dbg_eba("read %d bytes of data", aldata_size); 1016 - err = ubi_io_read_data(ubi, buf, from, 0, aldata_size); 1026 + err = ubi_io_read_data(ubi, ubi->peb_buf1, from, 0, aldata_size); 1017 1027 if (err && err != UBI_IO_BITFLIPS) { 1018 1028 ubi_warn("error %d while reading data from PEB %d", 1019 1029 err, from); ··· 1032 1042 */ 1033 1043 if (vid_hdr->vol_type == UBI_VID_DYNAMIC) 1034 1044 aldata_size = data_size = 1035 - ubi_calc_data_len(ubi, buf, data_size); 1045 + ubi_calc_data_len(ubi, ubi->peb_buf1, data_size); 1036 1046 1037 1047 cond_resched(); 1038 - crc = crc32(UBI_CRC32_INIT, buf, data_size); 1048 + crc = crc32(UBI_CRC32_INIT, ubi->peb_buf1, data_size); 1039 1049 cond_resched(); 1040 1050 1041 1051 /* ··· 1066 1076 } 1067 1077 1068 1078 if (data_size > 0) { 1069 - err = ubi_io_write_data(ubi, buf, to, 0, aldata_size); 1079 + err = ubi_io_write_data(ubi, ubi->peb_buf1, to, 0, aldata_size); 1070 1080 if (err) 1071 1081 goto out_unlock; 1082 + 1083 + cond_resched(); 1072 1084 1073 1085 /* 1074 1086 * We've written the data and are going to read it back to make 1075 1087 * sure it was written correctly. 1076 1088 */ 1077 - buf1 = vmalloc(aldata_size); 1078 - if (!buf1) { 1079 - err = -ENOMEM; 1080 - goto out_unlock; 1081 - } 1082 1089 1083 - cond_resched(); 1084 - 1085 - err = ubi_io_read_data(ubi, buf1, to, 0, aldata_size); 1090 + err = ubi_io_read_data(ubi, ubi->peb_buf2, to, 0, aldata_size); 1086 1091 if (err) { 1087 1092 if (err != UBI_IO_BITFLIPS) 1088 1093 ubi_warn("cannot read data back from PEB %d", ··· 1087 1102 1088 1103 cond_resched(); 1089 1104 1090 - if (memcmp(buf, buf1, aldata_size)) { 1105 + if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) { 1091 1106 ubi_warn("read data back from PEB %d - it is different", 1092 1107 to); 1093 1108 goto out_unlock; ··· 1097 1112 ubi_assert(vol->eba_tbl[lnum] == from); 1098 1113 vol->eba_tbl[lnum] = to; 1099 1114 1100 - leb_write_unlock(ubi, vol_id, lnum); 1101 - vfree(buf); 1102 - vfree(buf1); 1103 - 1104 - return 0; 1105 - 1106 1115 out_unlock: 1116 + mutex_unlock(&ubi->buf_mutex); 1107 1117 leb_write_unlock(ubi, vol_id, lnum); 1108 - vfree(buf); 1109 - vfree(buf1); 1110 1118 return err; 1111 1119 } 1112 1120
+29 -37
drivers/mtd/ubi/io.c
··· 98 98 static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum); 99 99 static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum, 100 100 const struct ubi_vid_hdr *vid_hdr); 101 - static int paranoid_check_all_ff(const struct ubi_device *ubi, int pnum, 102 - int offset, int len); 101 + static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset, 102 + int len); 103 103 #else 104 104 #define paranoid_check_not_bad(ubi, pnum) 0 105 105 #define paranoid_check_peb_ec_hdr(ubi, pnum) 0 ··· 202 202 * Note, in case of an error, it is possible that something was still written 203 203 * to the flash media, but may be some garbage. 204 204 */ 205 - int ubi_io_write(const struct ubi_device *ubi, const void *buf, int pnum, 206 - int offset, int len) 205 + int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, 206 + int len) 207 207 { 208 208 int err; 209 209 size_t written; ··· 285 285 * zero in case of success and a negative error code in case of failure. If 286 286 * %-EIO is returned, the physical eraseblock most probably went bad. 287 287 */ 288 - static int do_sync_erase(const struct ubi_device *ubi, int pnum) 288 + static int do_sync_erase(struct ubi_device *ubi, int pnum) 289 289 { 290 290 int err, retries = 0; 291 291 struct erase_info ei; ··· 377 377 * test, a positive number of erase operations done if the test was 378 378 * successfully passed, and other negative error codes in case of other errors. 379 379 */ 380 - static int torture_peb(const struct ubi_device *ubi, int pnum) 380 + static int torture_peb(struct ubi_device *ubi, int pnum) 381 381 { 382 - void *buf; 383 382 int err, i, patt_count; 384 - 385 - buf = vmalloc(ubi->peb_size); 386 - if (!buf) 387 - return -ENOMEM; 388 383 389 384 patt_count = ARRAY_SIZE(patterns); 390 385 ubi_assert(patt_count > 0); 391 386 387 + mutex_lock(&ubi->buf_mutex); 392 388 for (i = 0; i < patt_count; i++) { 393 389 err = do_sync_erase(ubi, pnum); 394 390 if (err) 395 391 goto out; 396 392 397 393 /* Make sure the PEB contains only 0xFF bytes */ 398 - err = ubi_io_read(ubi, buf, pnum, 0, ubi->peb_size); 394 + err = ubi_io_read(ubi, ubi->peb_buf1, pnum, 0, ubi->peb_size); 399 395 if (err) 400 396 goto out; 401 397 402 - err = check_pattern(buf, 0xFF, ubi->peb_size); 398 + err = check_pattern(ubi->peb_buf1, 0xFF, ubi->peb_size); 403 399 if (err == 0) { 404 400 ubi_err("erased PEB %d, but a non-0xFF byte found", 405 401 pnum); ··· 404 408 } 405 409 406 410 /* Write a pattern and check it */ 407 - memset(buf, patterns[i], ubi->peb_size); 408 - err = ubi_io_write(ubi, buf, pnum, 0, ubi->peb_size); 411 + memset(ubi->peb_buf1, patterns[i], ubi->peb_size); 412 + err = ubi_io_write(ubi, ubi->peb_buf1, pnum, 0, ubi->peb_size); 409 413 if (err) 410 414 goto out; 411 415 412 - memset(buf, ~patterns[i], ubi->peb_size); 413 - err = ubi_io_read(ubi, buf, pnum, 0, ubi->peb_size); 416 + memset(ubi->peb_buf1, ~patterns[i], ubi->peb_size); 417 + err = ubi_io_read(ubi, ubi->peb_buf1, pnum, 0, ubi->peb_size); 414 418 if (err) 415 419 goto out; 416 420 417 - err = check_pattern(buf, patterns[i], ubi->peb_size); 421 + err = check_pattern(ubi->peb_buf1, patterns[i], ubi->peb_size); 418 422 if (err == 0) { 419 423 ubi_err("pattern %x checking failed for PEB %d", 420 424 patterns[i], pnum); ··· 426 430 err = patt_count; 427 431 428 432 out: 433 + mutex_unlock(&ubi->buf_mutex); 429 434 if (err == UBI_IO_BITFLIPS || err == -EBADMSG) { 430 435 /* 431 436 * If a bit-flip or data integrity error was detected, the test ··· 437 440 pnum); 438 441 err = -EIO; 439 442 } 440 - vfree(buf); 441 443 return err; 442 444 } 443 445 ··· 456 460 * codes in case of other errors. Note, %-EIO means that the physical 457 461 * eraseblock is bad. 458 462 */ 459 - int ubi_io_sync_erase(const struct ubi_device *ubi, int pnum, int torture) 463 + int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture) 460 464 { 461 465 int err, ret = 0; 462 466 ··· 613 617 * o %UBI_IO_PEB_EMPTY if the physical eraseblock is empty; 614 618 * o a negative error code in case of failure. 615 619 */ 616 - int ubi_io_read_ec_hdr(const struct ubi_device *ubi, int pnum, 620 + int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, 617 621 struct ubi_ec_hdr *ec_hdr, int verbose) 618 622 { 619 623 int err, read_err = 0; ··· 719 723 * case of failure. If %-EIO is returned, the physical eraseblock most probably 720 724 * went bad. 721 725 */ 722 - int ubi_io_write_ec_hdr(const struct ubi_device *ubi, int pnum, 726 + int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, 723 727 struct ubi_ec_hdr *ec_hdr) 724 728 { 725 729 int err; ··· 885 889 * header there); 886 890 * o a negative error code in case of failure. 887 891 */ 888 - int ubi_io_read_vid_hdr(const struct ubi_device *ubi, int pnum, 892 + int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, 889 893 struct ubi_vid_hdr *vid_hdr, int verbose) 890 894 { 891 895 int err, read_err = 0; ··· 992 996 * case of failure. If %-EIO is returned, the physical eraseblock probably went 993 997 * bad. 994 998 */ 995 - int ubi_io_write_vid_hdr(const struct ubi_device *ubi, int pnum, 999 + int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, 996 1000 struct ubi_vid_hdr *vid_hdr) 997 1001 { 998 1002 int err; ··· 1215 1219 * @offset of the physical eraseblock @pnum, %1 if not, and a negative error 1216 1220 * code if an error occurred. 1217 1221 */ 1218 - static int paranoid_check_all_ff(const struct ubi_device *ubi, int pnum, 1219 - int offset, int len) 1222 + static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset, 1223 + int len) 1220 1224 { 1221 1225 size_t read; 1222 1226 int err; 1223 - void *buf; 1224 1227 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; 1225 1228 1226 - buf = vmalloc(len); 1227 - if (!buf) 1228 - return -ENOMEM; 1229 - memset(buf, 0, len); 1230 - 1231 - err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); 1229 + mutex_lock(&ubi->dbg_buf_mutex); 1230 + err = ubi->mtd->read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf); 1232 1231 if (err && err != -EUCLEAN) { 1233 1232 ubi_err("error %d while reading %d bytes from PEB %d:%d, " 1234 1233 "read %zd bytes", err, len, pnum, offset, read); 1235 1234 goto error; 1236 1235 } 1237 1236 1238 - err = check_pattern(buf, 0xFF, len); 1237 + err = check_pattern(ubi->dbg_peb_buf, 0xFF, len); 1239 1238 if (err == 0) { 1240 1239 ubi_err("flash region at PEB %d:%d, length %d does not " 1241 1240 "contain all 0xFF bytes", pnum, offset, len); 1242 1241 goto fail; 1243 1242 } 1243 + mutex_unlock(&ubi->dbg_buf_mutex); 1244 1244 1245 - vfree(buf); 1246 1245 return 0; 1247 1246 1248 1247 fail: 1249 1248 ubi_err("paranoid check failed for PEB %d", pnum); 1250 1249 dbg_msg("hex dump of the %d-%d region", offset, offset + len); 1251 - print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1); 1250 + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, 1251 + ubi->dbg_peb_buf, len, 1); 1252 1252 err = 1; 1253 1253 error: 1254 1254 ubi_dbg_dump_stack(); 1255 - vfree(buf); 1255 + mutex_unlock(&ubi->dbg_buf_mutex); 1256 1256 return err; 1257 1257 } 1258 1258
+8 -11
drivers/mtd/ubi/scan.c
··· 45 45 #include "ubi.h" 46 46 47 47 #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 48 - static int paranoid_check_si(const struct ubi_device *ubi, 49 - struct ubi_scan_info *si); 48 + static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); 50 49 #else 51 50 #define paranoid_check_si(ubi, si) 0 52 51 #endif ··· 258 259 * o bit 2 is cleared: the older LEB is not corrupted; 259 260 * o bit 2 is set: the older LEB is corrupted. 260 261 */ 261 - static int compare_lebs(const struct ubi_device *ubi, 262 - const struct ubi_scan_leb *seb, int pnum, 263 - const struct ubi_vid_hdr *vid_hdr) 262 + static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb, 263 + int pnum, const struct ubi_vid_hdr *vid_hdr) 264 264 { 265 265 void *buf; 266 266 int len, err, second_is_newer, bitflips = 0, corrupted = 0; ··· 411 413 * to be picked, while the older one has to be dropped. This function returns 412 414 * zero in case of success and a negative error code in case of failure. 413 415 */ 414 - int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si, 416 + int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, 415 417 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, 416 418 int bitflips) 417 419 { ··· 665 667 * function returns zero in case of success and a negative error code in case 666 668 * of failure. 667 669 */ 668 - int ubi_scan_erase_peb(const struct ubi_device *ubi, 669 - const struct ubi_scan_info *si, int pnum, int ec) 670 + int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, 671 + int pnum, int ec) 670 672 { 671 673 int err; 672 674 struct ubi_ec_hdr *ec_hdr; ··· 710 712 * This function returns scanning physical eraseblock information in case of 711 713 * success and an error code in case of failure. 712 714 */ 713 - struct ubi_scan_leb *ubi_scan_get_free_peb(const struct ubi_device *ubi, 715 + struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi, 714 716 struct ubi_scan_info *si) 715 717 { 716 718 int err = 0, i; ··· 1108 1110 * This function returns zero if the scanning information is all right, %1 if 1109 1111 * not and a negative error code if an error occurred. 1110 1112 */ 1111 - static int paranoid_check_si(const struct ubi_device *ubi, 1112 - struct ubi_scan_info *si) 1113 + static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si) 1113 1114 { 1114 1115 int pnum, err, vols_found = 0; 1115 1116 struct rb_node *rb1, *rb2;
+4 -4
drivers/mtd/ubi/scan.h
··· 147 147 list_add_tail(&seb->u.list, list); 148 148 } 149 149 150 - int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si, 150 + int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, 151 151 int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, 152 152 int bitflips); 153 153 struct ubi_scan_volume *ubi_scan_find_sv(const struct ubi_scan_info *si, ··· 155 155 struct ubi_scan_leb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, 156 156 int lnum); 157 157 void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv); 158 - struct ubi_scan_leb *ubi_scan_get_free_peb(const struct ubi_device *ubi, 158 + struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi, 159 159 struct ubi_scan_info *si); 160 - int ubi_scan_erase_peb(const struct ubi_device *ubi, 161 - const struct ubi_scan_info *si, int pnum, int ec); 160 + int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_scan_info *si, 161 + int pnum, int ec); 162 162 struct ubi_scan_info *ubi_scan(struct ubi_device *ubi); 163 163 void ubi_scan_destroy_si(struct ubi_scan_info *si); 164 164
+22 -8
drivers/mtd/ubi/ubi.h
··· 274 274 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or 275 275 * not 276 276 * @mtd: MTD device descriptor 277 + * 278 + * @peb_buf1: a buffer of PEB size used for different purposes 279 + * @peb_buf2: another buffer of PEB size used for different purposes 280 + * @buf_mutex: proptects @peb_buf1 and @peb_buf2 281 + * @dbg_peb_buf: buffer of PEB size used for debugging 282 + * @dbg_buf_mutex: proptects @dbg_peb_buf 277 283 */ 278 284 struct ubi_device { 279 285 struct cdev cdev; ··· 349 343 int vid_hdr_shift; 350 344 int bad_allowed; 351 345 struct mtd_info *mtd; 346 + 347 + void *peb_buf1; 348 + void *peb_buf2; 349 + struct mutex buf_mutex; 350 + #ifdef CONFIG_MTD_UBI_DEBUG 351 + void *dbg_peb_buf; 352 + struct mutex dbg_buf_mutex; 353 + #endif 352 354 }; 353 355 354 356 extern struct file_operations ubi_cdev_operations; ··· 423 409 /* io.c */ 424 410 int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, 425 411 int len); 426 - int ubi_io_write(const struct ubi_device *ubi, const void *buf, int pnum, 427 - int offset, int len); 428 - int ubi_io_sync_erase(const struct ubi_device *ubi, int pnum, int torture); 412 + int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, 413 + int len); 414 + int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture); 429 415 int ubi_io_is_bad(const struct ubi_device *ubi, int pnum); 430 416 int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum); 431 - int ubi_io_read_ec_hdr(const struct ubi_device *ubi, int pnum, 417 + int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, 432 418 struct ubi_ec_hdr *ec_hdr, int verbose); 433 - int ubi_io_write_ec_hdr(const struct ubi_device *ubi, int pnum, 419 + int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, 434 420 struct ubi_ec_hdr *ec_hdr); 435 - int ubi_io_read_vid_hdr(const struct ubi_device *ubi, int pnum, 421 + int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, 436 422 struct ubi_vid_hdr *vid_hdr, int verbose); 437 - int ubi_io_write_vid_hdr(const struct ubi_device *ubi, int pnum, 423 + int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, 438 424 struct ubi_vid_hdr *vid_hdr); 439 425 440 426 /* ··· 508 494 * the beginning of the logical eraseblock, not to the beginning of the 509 495 * physical eraseblock. 510 496 */ 511 - static inline int ubi_io_write_data(const struct ubi_device *ubi, const void *buf, 497 + static inline int ubi_io_write_data(struct ubi_device *ubi, const void *buf, 512 498 int pnum, int offset, int len) 513 499 { 514 500 ubi_assert(offset >= 0);
+3 -3
drivers/mtd/ubi/vtbl.c
··· 254 254 * This function returns zero in case of success and a negative error code in 255 255 * case of failure. 256 256 */ 257 - static int create_vtbl(const struct ubi_device *ubi, struct ubi_scan_info *si, 257 + static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, 258 258 int copy, void *vtbl) 259 259 { 260 260 int err, tries = 0; ··· 339 339 * not corrupted, and recovering from corruptions if needed. Returns volume 340 340 * table in case of success and a negative error code in case of failure. 341 341 */ 342 - static struct ubi_vtbl_record *process_lvol(const struct ubi_device *ubi, 342 + static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, 343 343 struct ubi_scan_info *si, 344 344 struct ubi_scan_volume *sv) 345 345 { ··· 453 453 * This function returns volume table contents in case of success and a 454 454 * negative error code in case of failure. 455 455 */ 456 - static struct ubi_vtbl_record *create_empty_lvol(const struct ubi_device *ubi, 456 + static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, 457 457 struct ubi_scan_info *si) 458 458 { 459 459 int i;
+2 -2
drivers/mtd/ubi/wl.c
··· 208 208 }; 209 209 210 210 #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 211 - static int paranoid_check_ec(const struct ubi_device *ubi, int pnum, int ec); 211 + static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); 212 212 static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e, 213 213 struct rb_root *root); 214 214 #else ··· 1625 1625 * is equivalent to @ec, %1 if not, and a negative error code if an error 1626 1626 * occurred. 1627 1627 */ 1628 - static int paranoid_check_ec(const struct ubi_device *ubi, int pnum, int ec) 1628 + static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec) 1629 1629 { 1630 1630 int err; 1631 1631 long long read_ec;