Merge tag 'upstream-3.14-rc1' of git://git.infradead.org/linux-ubifs

Pull ubifs updates from Artem Bityutskiy:

- Improve the NOR erasure quirk - now it tries to do as little writes
as possible, because the eraseblock may be in an "unstable" state and
write operation sometimes causes NOR chip lock-ups.

- Both UBI and UBIFS changes are now maintainer in one single tree,
because the amount of changes dropped significantly.

* tag 'upstream-3.14-rc1' of git://git.infradead.org/linux-ubifs:
UBI: avoid program operation on NOR flash after erasure interrupted
MAINTAINERS: keep UBI and UBIFS stuff in the same tree
UBI: fix error return code

+30 -36
+1 -1
MAINTAINERS
··· 8960 8960 M: Artem Bityutskiy <dedekind1@gmail.com> 8961 8961 W: http://www.linux-mtd.infradead.org/ 8962 8962 L: linux-mtd@lists.infradead.org 8963 - T: git git://git.infradead.org/ubi-2.6.git 8963 + T: git git://git.infradead.org/ubifs-2.6.git 8964 8964 S: Maintained 8965 8965 F: drivers/mtd/ubi/ 8966 8966 F: include/linux/mtd/ubi.h
+3 -1
drivers/mtd/ubi/attach.c
··· 1453 1453 struct ubi_attach_info *scan_ai; 1454 1454 1455 1455 scan_ai = alloc_ai("ubi_ckh_aeb_slab_cache"); 1456 - if (!scan_ai) 1456 + if (!scan_ai) { 1457 + err = -ENOMEM; 1457 1458 goto out_wl; 1459 + } 1458 1460 1459 1461 err = scan_all(ubi, scan_ai, 0); 1460 1462 if (err) {
+3 -1
drivers/mtd/ubi/build.c
··· 1245 1245 ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab", 1246 1246 sizeof(struct ubi_wl_entry), 1247 1247 0, 0, NULL); 1248 - if (!ubi_wl_entry_slab) 1248 + if (!ubi_wl_entry_slab) { 1249 + err = -ENOMEM; 1249 1250 goto out_dev_unreg; 1251 + } 1250 1252 1251 1253 err = ubi_debugfs_init(); 1252 1254 if (err)
+23 -33
drivers/mtd/ubi/io.c
··· 495 495 */ 496 496 static int nor_erase_prepare(struct ubi_device *ubi, int pnum) 497 497 { 498 - int err, err1; 498 + int err; 499 499 size_t written; 500 500 loff_t addr; 501 501 uint32_t data = 0; 502 + struct ubi_ec_hdr ec_hdr; 503 + 502 504 /* 503 505 * Note, we cannot generally define VID header buffers on stack, 504 506 * because of the way we deal with these buffers (see the header ··· 511 509 struct ubi_vid_hdr vid_hdr; 512 510 513 511 /* 512 + * If VID or EC is valid, we have to corrupt them before erasing. 514 513 * It is important to first invalidate the EC header, and then the VID 515 514 * header. Otherwise a power cut may lead to valid EC header and 516 515 * invalid VID header, in which case UBI will treat this PEB as 517 516 * corrupted and will try to preserve it, and print scary warnings. 518 517 */ 519 518 addr = (loff_t)pnum * ubi->peb_size; 520 - err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); 521 - if (!err) { 519 + err = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0); 520 + if (err != UBI_IO_BAD_HDR_EBADMSG && err != UBI_IO_BAD_HDR && 521 + err != UBI_IO_FF){ 522 + err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); 523 + if(err) 524 + goto error; 525 + } 526 + 527 + err = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0); 528 + if (err != UBI_IO_BAD_HDR_EBADMSG && err != UBI_IO_BAD_HDR && 529 + err != UBI_IO_FF){ 522 530 addr += ubi->vid_hdr_aloffset; 523 531 err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); 524 - if (!err) 525 - return 0; 532 + if (err) 533 + goto error; 526 534 } 535 + return 0; 527 536 537 + error: 528 538 /* 529 - * We failed to write to the media. This was observed with Spansion 530 - * S29GL512N NOR flash. Most probably the previously eraseblock erasure 531 - * was interrupted at a very inappropriate moment, so it became 532 - * unwritable. In this case we probably anyway have garbage in this 533 - * PEB. 539 + * The PEB contains a valid VID or EC header, but we cannot invalidate 540 + * it. Supposedly the flash media or the driver is screwed up, so 541 + * return an error. 534 542 */ 535 - err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0); 536 - if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR || 537 - err1 == UBI_IO_FF) { 538 - struct ubi_ec_hdr ec_hdr; 539 - 540 - err1 = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0); 541 - if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR || 542 - err1 == UBI_IO_FF) 543 - /* 544 - * Both VID and EC headers are corrupted, so we can 545 - * safely erase this PEB and not afraid that it will be 546 - * treated as a valid PEB in case of an unclean reboot. 547 - */ 548 - return 0; 549 - } 550 - 551 - /* 552 - * The PEB contains a valid VID header, but we cannot invalidate it. 553 - * Supposedly the flash media or the driver is screwed up, so return an 554 - * error. 555 - */ 556 - ubi_err("cannot invalidate PEB %d, write returned %d read returned %d", 557 - pnum, err, err1); 543 + ubi_err("cannot invalidate PEB %d, write returned %d", pnum, err); 558 544 ubi_dump_flash(ubi, pnum, 0, ubi->peb_size); 559 545 return -EIO; 560 546 }