summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
Commit message (Collapse)AuthorAgeFilesLines
...
| * ubi: Deal with interrupted erasures in WLRichard Weinberger2016-10-021-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | When Fastmap is used we can face here an -EBADMSG since Fastmap cannot know about unmaps. If the erasure was interrupted the PEB may show ECC errors and UBI would go to ro-mode as it assumes that the PEB was check during attach time, which is not the case with Fastmap. Cc: <stable@vger.kernel.org> Fixes: dbb7d2a88d ("UBI: Add fastmap core") Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: introduce the VID buffer conceptBoris Brezillon2016-10-027-142/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, all VID headers are allocated and freed using the ubi_zalloc_vid_hdr() and ubi_free_vid_hdr() function. These functions make sure to align allocation on ubi->vid_hdr_alsize and adjust the vid_hdr pointer to match the ubi->vid_hdr_shift requirements. This works fine, but is a bit convoluted. Moreover, the future introduction of LEB consolidation (needed to support MLC/TLC NANDs) will allows a VID buffer to contain more than one VID header. Hence the creation of a ubi_vid_io_buf struct to attach extra information to the VID header. We currently only store the actual pointer of the underlying buffer, but will soon add the number of VID headers contained in the buffer. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: hide EBA internalsBoris Brezillon2016-10-024-51/+165
| | | | | | | | | | | | | | | | | | | | | | | | Create a private ubi_eba_table struct to hide EBA internals and provide helpers to allocate, destroy, copy and assing an EBA table to a volume. Now that external EBA users are using helpers to query/modify the EBA state we can safely change the internal representation, which will be needed to support the LEB consolidation concept. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: provide an helper to query LEB informationBoris Brezillon2016-10-023-2/+40
| | | | | | | | | | | | | | | | | | | | | | This is part of our attempt to hide EBA internals from other part of the implementation in order to easily adapt it to the MLC needs. Here we are creating an ubi_eba_leb_desc struct to hide the way we keep track of the LEB to PEB mapping. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: provide an helper to check whether a LEB is mapped or notBoris Brezillon2016-10-023-2/+15
| | | | | | | | | | | | | | | | | | This is part of the process of hiding UBI EBA's internal to other part of the UBI implementation, so that we can add new information to the EBA table without having to patch different places in the UBI code. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: add an helper to check lnum validityBoris Brezillon2016-10-023-8/+13
| | | | | | | | | | | | | | | | ubi_leb_valid() is here to replace the lnum < 0 || lnum >= vol->reserved_pebs checks. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: simplify LEB write and atomic LEB change codeBoris Brezillon2016-10-021-170/+115
| | | | | | | | | | | | | | | | | | | | | | ubi_eba_write_leb(), ubi_eba_write_leb_st() and ubi_eba_atomic_leb_change() are using a convoluted retry/exit path. Add the try_write_vid_and_data() function to simplify the retry logic and make sure we have a single exit path instead of manually releasing the resources in each error path. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: simplify recover_peb() codeBoris Brezillon2016-10-021-53/+77
| | | | | | | | | | | | | | | | | | recover_peb() is using a convoluted retry/exit path. Add try_recover_peb() to simplify the retry logic and make sure we have a single exit path instead of manually releasing the resource in each error path. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: move the global ech and vidh variables into struct ubi_attach_infoBoris Brezillon2016-10-022-20/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Even if it works fine with those global variables, attaching the temporary ech and vidh objects used during UBI scan to the ubi_attach_info object sounds like a more future-proof option. For example, attaching several UBI devices in parallel is prevented by this use of global variable. And also because global variables should be avoided in general. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: provide helpers to allocate and free aeb elementsBoris Brezillon2016-10-024-38/+66
| | | | | | | | | | | | | | | | | | This not only hides the aeb allocation internals (which is always good in case we ever want to change the allocation system), but also helps us factorize the initialization of some common fields (ec and pnum). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fastmap: use ubi_io_{read, write}_data() instead of ubi_io_{read, write}()Boris Brezillon2016-10-021-5/+5
| | | | | | | | | | | | | | | | | | ubi_io_{read,write}_data() are wrappers around ubi_io_{read/write}() that are used to read/write eraseblock payload data, which is exactly what fastmap does when calling ubi_io_{read,write}(). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fastmap: use ubi_rb_for_each_entry() in unmap_peb()Boris Brezillon2016-10-021-6/+2
| | | | | | | | | | | | | | Use the ubi_rb_for_each_entry() macro instead of open-coding it. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: factorize destroy_av() and ubi_remove_av() codeBoris Brezillon2016-10-021-13/+12
| | | | | | | | | | | | | | | | | | | | | | Those functions are pretty much doing the same thing, except ubi_remove_av() is putting the aeb elements attached to the volume into the ai->erase list and the destroy_av() is freeing them. Rework destroy_av() to handle both cases. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: factorize code used to manipulate volumes at attach timeBoris Brezillon2016-10-023-67/+112
| | | | | | | | | | | | | | | | Volume creation/search code is duplicated in a few places (fastmap and non fastmap code). Create some helpers to factorize the code. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: use vol->usable_leb_size instead of (ubi->leb_size - vol->data_pad)Boris Brezillon2016-10-021-1/+1
| | | | | | | | | | | | | | | | vol->usable_size is already set to ubi->leb_size - vol->data_pad. Use vol->usable_size instead of recalculating it. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fastmap: scrub PEB when bitflips are detected in a free PEB EC headerBoris Brezillon2016-10-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | scan_pool() does not mark the PEB for scrubing when bitflips are detected in the EC header of a free PEB (VID header region left to 0xff). Make sure we scrub the PEB in this case. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Fixes: dbb7d2a88d2a ("UBI: Add fastmap core") Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fastmap: avoid multiple be32_to_cpu() when unneccesaryBoris Brezillon2016-10-021-4/+4
| | | | | | | | | | | | | | | | process_pool_aeb() does several times the be32_to_cpu(new_vh->vol_id) operation. Create a temporary variable and do it once. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fix add_fastmap() to use the vid_hdr passed in argumentBoris Brezillon2016-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | add_fastmap() is passed a ubi_vid_hdr pointer in argument, but is referencing the global vidh pointer. Even if this is correct from a functional point of view (vidh and vid_hdr point to the same object), it is confusing. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: fastmap: use ubi_find_volume() instead of open coding itBoris Brezillon2016-10-021-20/+3
| | | | | | | | | | | | | | | | process_pool_aeb() re-implements the logic found in ubi_find_volume(). Call ubi_find_volume() to avoid this duplication. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* | blk-mq: remove ->map_queueChristoph Hellwig2016-09-151-1/+0
|/ | | | | | | | | | | | | All drivers use the default, so provide an inline version of it. If we ever need other queue mapping we can add an optional method back, although supporting will also require major changes to the queue setup code. This provides better code generation, and better debugability as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
* ubi: Use bitmaps in Fastmap self-check codeRichard Weinberger2016-07-291-9/+11
| | | | | | | ...don't waste memory by allocating one sizeof(int) per PEB. Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Be more paranoid while seaching for the most recent FastmapRichard Weinberger2016-07-292-4/+27
| | | | | | | | | | | | | | | | | | | Since PEB erasure is asynchornous it can happen that there is more than one Fastmap on the MTD. This is fine because the attach logic will pick the Fastmap data structure with the highest sequence number. On a not so well configured MTD stack spurious ECC errors are common. Causes can be different, bad hardware, wrong operating modes, etc... If the most current Fastmap renders bad due to ECC errors UBI might pick an older Fastmap to attach from. While this can only happen on an anyway broken setup it will show completely different sympthoms and makes finding the root cause much more difficult. So, be debug friendly and fall back to scanning mode of we're facing an ECC error while scanning for Fastmap. Cc: <stable@vger.kernel.org> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Check whether the Fastmap anchor matches the super blockRichard Weinberger2016-07-291-0/+7
| | | | | | | This helps to detect cases where an user copies an UBI image to another target with different bad blocks. Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Rework Fastmap attach base codeRichard Weinberger2016-07-294-42/+162
| | | | | | | | | Introduce a new list to the UBI attach information object to be able to deal better with old and corrupted Fastmap eraseblocks. Also move more Fastmap specific code into fastmap.c. Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Fix whitespace issue in count_fastmap_pebs()Richard Weinberger2016-07-291-1/+1
| | | | Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Introduce vol_ignored()Richard Weinberger2016-07-292-6/+33
| | | | | | This makes the logic more easy to follow. Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Fix scan_fast() commentRichard Weinberger2016-07-291-1/+1
| | | | Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Make volume resize power cut awareRichard Weinberger2016-07-291-7/+18
| | | | | | | | | | | | | | | | | When the volume resize operation shrinks a volume, LEBs will be unmapped. Since unmapping will not erase these LEBs immediately we have to wait for that operation to finish. Otherwise in case of a power cut right after writing the new volume table the UBI attach process can find more LEBs than the volume table knows. This will render the UBI image unattachable. Fix this issue by waiting for erase to complete and write the new volume table afterward. Cc: <stable@vger.kernel.org> Reported-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Fix early loggingRichard Weinberger2016-07-291-4/+4
| | | | | | | | | We cannot use ubi_* logging functions before the UBI object is initialized. Cc: <stable@vger.kernel.org> Fixes: 3260870331 ("UBI: Extend UBI layer debug/messaging capabilities") Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: gluebi: Fix double refcountingRichard Weinberger2016-07-291-5/+0
| | | | | | | | | | | There is no need to call get/put on the module reference in gluebi_get/put_device() callbacks. Since mtd->owner is the gluebi module itself mtdcore.c will take care of proper refcounting in __get/put_mtd_device() before executing the callbacks. Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Fix race condition between ubi device creation and udevIosif Harutyunov2016-07-291-1/+4
| | | | | | | | | | | Install the UBI device object before we arm sysfs. Otherwise udev tries to read sysfs attributes before UBI is ready and udev rules will not match. Cc: <stable@vger.kernel.org> Signed-off-by: Iosif Harutyunov <iharutyunov@sonicwall.com> [rw: massaged commit message] Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Only read necessary size when reading the VID headerSascha Hauer2016-07-291-1/+1
| | | | | | | | | | | | | | When reading the vid hdr from the device UBI always reads a whole page. Instead, read only the data we actually need and speed up attachment of UBI devices by potentially making use of reading subpages if the NAND driver supports it. Since the VID header may be at offset vid_hdr_shift in the page and we can only read from the beginning of a page we have to add that offset to the read size. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Make recover_peb power cut awareRichard Weinberger2016-06-231-7/+15
| | | | | | | | | | | | | | | | | | | recover_peb() was never power cut aware, if a power cut happened right after writing the VID header upon next attach UBI would blindly use the new partial written PEB and all data from the old PEB is lost. In order to make recover_peb() power cut aware, write the new VID with a proper crc and copy_flag set such that the UBI attach process will detect whether the new PEB is completely written or not. We cannot directly use ubi_eba_atomic_leb_change() since we'd have to unlock the LEB which is facing a write error. Cc: stable@vger.kernel.org Reported-by: Jörg Pfähler <pfaehler@isse.de> Reviewed-by: Jörg Pfähler <pfaehler@isse.de> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Don't bypass ->getattr()Richard Weinberger2016-06-142-13/+20
| | | | | | | | | | | | | Directly accessing inode fields bypasses ->getattr() and can cause problems when the underlying filesystem does not have the default ->getattr() implementation. So instead of obtaining the backing inode via d_backing_inode() use vfs_getattr() and obtain what we need from the kstat struct. Cc: Al Viro <viro@zeniv.linux.org.uk> Reported-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
* Revert "mtd: switch open_mtd_by_chdev() to use of vfs_stat()"Richard Weinberger2016-06-141-5/+8
| | | | | | | | | This reverts commit 87f15d4add758fb7fc76655721af94be57a4c17d. vfs_stat() can only be used on user supplied buffers. Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
* Revert "mtd: switch ubi_open_volume_path() to vfs_stat()"Richard Weinberger2016-06-141-8/+11
| | | | | | | | | | | | | | This reverts commit 322ea0bbf3003df17b6253f76e572c37d79a6810. vfs_stat() can only be used on user supplied buffers. UBI's kapi.c is the API to the kernel and therefore vfs_stat() is inappropriate. This solves the problem that mounting any UBIFS will immediately fail with -EINVAL. Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
* Merge tag 'upstream-4.7-rc1' of git://git.infradead.org/linux-ubifsLinus Torvalds2016-05-278-32/+32
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull UBI/UBIFS updates from Richard Weinberger: "This contains mostly cleanups and minor improvements of UBI and UBIFS" * tag 'upstream-4.7-rc1' of git://git.infradead.org/linux-ubifs: ubifs: ubifs_dump_inode: Fix dumping field bulk_read UBI: Fix static volume checks when Fastmap is used UBI: Set free_count to zero before walking through erase list UBI: Silence an unintialized variable warning UBI: Clean up return in ubi_remove_volume() UBI: Modify wrong comment in ubi_leb_map function. UBI: Don't read back all data in ubi_eba_copy_leb() UBI: Add ro-mode sysfs attribute
| * UBI: Fix static volume checks when Fastmap is usedRichard Weinberger2016-05-243-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ezequiel reported that he's facing UBI going into read-only mode after power cut. It turned out that this behavior happens only when updating a static volume is interrupted and Fastmap is used. A possible trace can look like: ubi0 warning: ubi_io_read_vid_hdr [ubi]: no VID header found at PEB 2323, only 0xFF bytes ubi0 warning: ubi_eba_read_leb [ubi]: switch to read-only mode CPU: 0 PID: 833 Comm: ubiupdatevol Not tainted 4.6.0-rc2-ARCH #4 Hardware name: SAMSUNG ELECTRONICS CO., LTD. 300E4C/300E5C/300E7C/NP300E5C-AD8AR, BIOS P04RAP 10/15/2012 0000000000000286 00000000eba949bd ffff8800c45a7b38 ffffffff8140d841 ffff8801964be000 ffff88018eaa4800 ffff8800c45a7bb8 ffffffffa003abf6 ffffffff850e2ac0 8000000000000163 ffff8801850e2ac0 ffff8801850e2ac0 Call Trace: [<ffffffff8140d841>] dump_stack+0x63/0x82 [<ffffffffa003abf6>] ubi_eba_read_leb+0x486/0x4a0 [ubi] [<ffffffffa00453b3>] ubi_check_volume+0x83/0xf0 [ubi] [<ffffffffa0039d97>] ubi_open_volume+0x177/0x350 [ubi] [<ffffffffa00375d8>] vol_cdev_open+0x58/0xb0 [ubi] [<ffffffff8124b08e>] chrdev_open+0xae/0x1d0 [<ffffffff81243bcf>] do_dentry_open+0x1ff/0x300 [<ffffffff8124afe0>] ? cdev_put+0x30/0x30 [<ffffffff81244d36>] vfs_open+0x56/0x60 [<ffffffff812545f4>] path_openat+0x4f4/0x1190 [<ffffffff81256621>] do_filp_open+0x91/0x100 [<ffffffff81263547>] ? __alloc_fd+0xc7/0x190 [<ffffffff812450df>] do_sys_open+0x13f/0x210 [<ffffffff812451ce>] SyS_open+0x1e/0x20 [<ffffffff81a99e32>] entry_SYSCALL_64_fastpath+0x1a/0xa4 UBI checks static volumes for data consistency and reads the whole volume upon first open. If the volume is found erroneous users of UBI cannot read from it, but another volume update is possible to fix it. The check is performed by running ubi_eba_read_leb() on every allocated LEB of the volume. For static volumes ubi_eba_read_leb() computes the checksum of all data stored in a LEB. To verify the computed checksum it has to read the LEB's volume header which stores the original checksum. If the volume header is not found UBI treats this as fatal internal error and switches to RO mode. If the UBI device was attached via a full scan the assumption is correct, the volume header has to be present as it had to be there while scanning to get known as mapped. If the attach operation happened via Fastmap the assumption is no longer correct. When attaching via Fastmap UBI learns the mapping table from Fastmap's snapshot of the system state and not via a full scan. It can happen that a LEB got unmapped after a Fastmap was written to the flash. Then UBI can learn the LEB still as mapped and accessing it returns only 0xFF bytes. As UBI is not a FTL it is allowed to have mappings to empty PEBs, it assumes that the layer above takes care of LEB accounting and referencing. UBIFS does so using the LEB property tree (LPT). For static volumes UBI blindly assumes that all LEBs are present and therefore special actions have to be taken. The described situation can happen when updating a static volume is interrupted, either by a user or a power cut. The volume update code first unmaps all LEBs of a volume and then writes LEB by LEB. If the sequence of operations is interrupted UBI detects this either by the absence of LEBs, no volume header present at scan time, or corrupted payload, detected via checksum. In the Fastmap case the former method won't trigger as no scan happened and UBI automatically thinks all LEBs are present. Only by reading data from a LEB it detects that the volume header is missing and incorrectly treats this as fatal error. To deal with the situation ubi_eba_read_leb() from now on checks whether we attached via Fastmap and handles the absence of a volume header like a data corruption error. This way interrupted static volume updates will correctly get detected also when Fastmap is used. Cc: <stable@vger.kernel.org> Reported-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Set free_count to zero before walking through erase listHeiko Schocher2016-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set free_count to zero before walking through ai->erase list in wl_init(). Found in U-Boot as U-Boot has no workqueue/threads, it immediately calls erase_worker(), which increase for each erased block free_count. Without this patch, free_count gets after this initialized to zero in wl_init(), so the free_count variable always has the maybe wrong value 0 in U-Boot. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Silence an unintialized variable warningDan Carpenter2016-05-241-1/+2
| | | | | | | | | | | | | | | | My static checker complains that "val" is uninitialized when kstrtoint() fails. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Clean up return in ubi_remove_volume()Dan Carpenter2016-05-241-1/+1
| | | | | | | | | | | | | | | | | | My static checker says that "err" can be uninitialized if "vol->reserved_pebs" is <= 0. I don't think that can happen but returning a literal is cleaner anyway. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Modify wrong comment in ubi_leb_map function.z001895122016-05-241-1/+1
| | | | | | | | | | Signed-off-by: z00189512 <abc.zhangliang@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Don't read back all data in ubi_eba_copy_leb()Richard Weinberger2016-05-241-26/+0
| | | | | | | | | | | | | | | | | | | | | | Drop this paranoia check from the old days. If our MTD driver or the flash is so bad that we even cannot trust it to write data we have bigger problems. If one really does not trust the flash and wants write-verify she can enable UBI io checks using debugfs. Signed-off-by: Richard Weinberger <richard@nod.at>
| * UBI: Add ro-mode sysfs attributeEzequiel Garcia2016-05-241-0/+5
| | | | | | | | | | | | | | | | | | | | On serious situations, UBI may detect serious device corruption, and switch to read-only mode to protect the data and allow debugging. This commit exposes this ro-mode on sysfs, so it can be obtained by userspace tools. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Richard Weinberger <richard@nod.at>
* | mtd: switch ubi_open_volume_path() to vfs_stat()Al Viro2016-03-271-11/+8
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | mtd: switch open_mtd_by_chdev() to use of vfs_stat()Al Viro2016-03-271-8/+5
|/ | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* mtd: ubi: Add logging functions ubi_msg, ubi_warn and ubi_errJoe Perches2016-03-202-6/+59
| | | | | | | | | | | | | | Using logging functions instead of macros can reduce overall object size. $ size drivers/mtd/ubi/built-in.o* text data bss dec hex filename 271620 163364 73696 508680 7c308 drivers/mtd/ubi/built-in.o.allyesconfig.new 287638 165380 73504 526522 808ba drivers/mtd/ubi/built-in.o.allyesconfig.old 87728 3780 504 92012 1676c drivers/mtd/ubi/built-in.o.defconfig.new 97084 3780 504 101368 18bf8 drivers/mtd/ubi/built-in.o.defconfig.old Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* ubi: Fix out of bounds write in volume update codeRichard Weinberger2016-03-051-1/+1
| | | | | | | | | | ubi_start_leb_change() allocates too few bytes. ubi_more_leb_change_data() will write up to req->upd_bytes + ubi->min_io_size bytes. Cc: stable@vger.kernel.org Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
* wrappers for ->i_mutex accessAl Viro2016-01-221-2/+2
| | | | | | | | | | | parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested}, inode_foo(inode) being mutex_foo(&inode->i_mutex). Please, use those for access to ->i_mutex; over the coming cycle ->i_mutex will become rwsem, with ->lookup() done with it held only shared. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* mtd: ubi: wl: avoid erasing a PEB which is emptySebastian Siewior2016-01-101-3/+18
| | | | | | | | | | | | | | | | | wear_leveling_worker() currently unconditionally puts a PEB on erase in the error case even it just been taken from the free_list and never used. In case the PEB was never used it can be put back on the free list saving a precious erase cycle. v1…v2: - to_leb_clean -> dst_leb_clean - use the nested option for ensure_wear_leveling() - do_sync_erase() can't go -ENOMEM so we can just go into RO-mode now. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
OpenPOWER on IntegriCloud