aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-02-23UBI: fix missing brace control flowBrian Norris1-1/+2
commit 0e707ae79ba3 ("UBI: do propagate positive error codes up") seems to have produced an unintended change in the control flow here. Completely untested, but it looks obvious. Caught by Coverity, which didn't like the indentation. CID 1271184. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-02-12UBI: block: Fix checking for NULL instead of IS_ERR()Dan Carpenter1-2/+2
We recently switched from allocating ->rq using blk_init_queue() to use blk_mq_init_queue() so we need to update the error handling to check for IS_ERR() instead of NULL. Fixes: ff1f48ee3bb3 ('UBI: Block: Add blk-mq support') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-02-12UBI: block: Continue creating ubiblocks after an initialization errorDan Ehrenberg1-15/+22
If one ubi volume is corrupted but another is not, it should be possible to initialize that ubiblock from a kernel commandline which includes both of them. This patch changes the error handling behavior in initializing ubiblock to ensure that all parameters are attempted even if one fails. If there is a failure, it is logged on dmesg. It also makes error messages more descriptive by including the name of the UBI volume that failed. Tested: Formatted ubi volume /dev/ubi5_0 in a corrupt way and dev/ubi3_0 properly and included "ubi.block=5,0 ubi.block=3,0" on the kernel command line. At boot, I see the following in the console: [ 21.082420] UBI error: ubiblock_create_from_param: block: can't open volume on ubi5_0, err=-19 [ 21.084268] UBI: ubiblock3_0 created from ubi3:0(rootfs) Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-01-28UBI: Block: Explain usage of blk_rq_map_sg()Richard Weinberger1-0/+6
Signed-off-by: Richard Weinberger <richard@nod.at>
2015-01-28UBI: fix soft lockup in ubi_check_volume()hujianyang1-0/+2
Running mtd-utils/tests/ubi-tests/io_basic.c could cause soft lockup or watchdog reset. It is because *updatevol* will perform ubi_check_volume() after updating finish and this function will full scan the updated lebs if the volume is initialized as STATIC_VOLUME. This patch adds *cond_resched()* in the loop of lebs scan to avoid soft lockup. Helped by Richard Weinberger <richard@nod.at> [ 2158.067096] INFO: rcu_sched self-detected stall on CPU { 1} (t=2101 jiffies g=1606 c=1605 q=56) [ 2158.172867] CPU: 1 PID: 2073 Comm: io_basic Tainted: G O 3.10.53 #21 [ 2158.172898] [<c000f624>] (unwind_backtrace+0x0/0x120) from [<c000c294>] (show_stack+0x10/0x14) [ 2158.172918] [<c000c294>] (show_stack+0x10/0x14) from [<c008ac3c>] (rcu_check_callbacks+0x1c0/0x660) [ 2158.172936] [<c008ac3c>] (rcu_check_callbacks+0x1c0/0x660) from [<c002b480>] (update_process_times+0x38/0x64) [ 2158.172953] [<c002b480>] (update_process_times+0x38/0x64) from [<c005ff38>] (tick_sched_handle+0x54/0x60) [ 2158.172966] [<c005ff38>] (tick_sched_handle+0x54/0x60) from [<c00601ac>] (tick_sched_timer+0x44/0x74) [ 2158.172978] [<c00601ac>] (tick_sched_timer+0x44/0x74) from [<c003f348>] (__run_hrtimer+0xc8/0x1b8) [ 2158.172992] [<c003f348>] (__run_hrtimer+0xc8/0x1b8) from [<c003fd9c>] (hrtimer_interrupt+0x128/0x2a4) [ 2158.173007] [<c003fd9c>] (hrtimer_interrupt+0x128/0x2a4) from [<c0246f1c>] (arch_timer_handler_virt+0x28/0x30) [ 2158.173022] [<c0246f1c>] (arch_timer_handler_virt+0x28/0x30) from [<c0086214>] (handle_percpu_devid_irq+0x9c/0x124) [ 2158.173036] [<c0086214>] (handle_percpu_devid_irq+0x9c/0x124) from [<c0082bd8>] (generic_handle_irq+0x20/0x30) [ 2158.173049] [<c0082bd8>] (generic_handle_irq+0x20/0x30) from [<c000969c>] (handle_IRQ+0x64/0x8c) [ 2158.173060] [<c000969c>] (handle_IRQ+0x64/0x8c) from [<c0008544>] (gic_handle_irq+0x3c/0x60) [ 2158.173074] [<c0008544>] (gic_handle_irq+0x3c/0x60) from [<c02f0f80>] (__irq_svc+0x40/0x50) [ 2158.173083] Exception stack(0xc4043c98 to 0xc4043ce0) [ 2158.173092] 3c80: c4043ce4 00000019 [ 2158.173102] 3ca0: 1f8a865f c050ad10 1f8a864c 00000031 c04b5970 0003ebce 00000000 f3550000 [ 2158.173113] 3cc0: bf00bc68 00000800 0003ebce c4043ce0 c0186d14 c0186cb8 80000013 ffffffff [ 2158.173130] [<c02f0f80>] (__irq_svc+0x40/0x50) from [<c0186cb8>] (read_current_timer+0x4/0x38) [ 2158.173145] [<c0186cb8>] (read_current_timer+0x4/0x38) from [<1f8a865f>] (0x1f8a865f) [ 2183.927097] BUG: soft lockup - CPU#1 stuck for 22s! [io_basic:2073] [ 2184.002229] Modules linked in: nandflash(O) [last unloaded: nandflash] Signed-off-by: Wang Kai <morgan.wang@huawei.com> Signed-off-by: hujianyang <hujianyang@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-01-28UBI: Fastmap: Care about the protection queueRichard Weinberger1-0/+13
Fastmap can miss a PEB if it is in the protection queue and not jet in the used tree. Treat every protected PEB as used. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-01-28UBI: do propagate positive error codes upArtem Bityutskiy1-0/+1
UBI uses positive function return codes internally, and should not propagate them up, except in the place this path fixes. Here is the original bug report from Dan Carpenter: The problem is really in ubi_eba_read_leb(). drivers/mtd/ubi/eba.c 412 err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1); 413 if (err && err != UBI_IO_BITFLIPS) { 414 if (err > 0) { 415 /* 416 * The header is either absent or corrupted. 417 * The former case means there is a bug - 418 * switch to read-only mode just in case. 419 * The latter case means a real corruption - we 420 * may try to recover data. FIXME: but this is 421 * not implemented. 422 */ 423 if (err == UBI_IO_BAD_HDR_EBADMSG || 424 err == UBI_IO_BAD_HDR) { 425 ubi_warn("corrupted VID header at PEB %d, LEB %d:%d", 426 pnum, vol_id, lnum); 427 err = -EBADMSG; 428 } else 429 ubi_ro_mode(ubi); On this path we return UBI_IO_FF and UBI_IO_FF_BITFLIPS and it eventually gets passed to ERR_PTR(). We probably dereference the bad pointer and oops. At that point we've gone read only so it was already a bad situation... 430 } 431 goto out_free; 432 } else if (err == UBI_IO_BITFLIPS) 433 scrub = 1; 434 Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-01-28UBI: clean-up printing helpersArtem Bityutskiy1-4/+4
Let's prefix UBI messages with 'ubiX' instead of 'UBI-X' - this is more consistent with the way we name UBI devices. Also, commit "32608703 UBI: Extend UBI layer debug/messaging capabilities" added the function name print to 'ubi_msg()' - lets revert this change, since these messages are supposed to be just informative messages, and not debugging messages. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-01-28UBI: extend UBI layer debug/messaging capabilities - cosmeticsTanya Brokhman5-22/+13
Some cosmetic fixes to the patch "UBI: Extend UBI layer debug/messaging capabilities". Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-01-28UBI: Block: Add blk-mq supportRichard Weinberger1-108/+94
Convert the driver to blk-mq. Beside of moving to the modern block interface this change boosts also the performance of the driver. nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda nand: Micron NAND 256MiB 3,3V 8-bit nand: 256MiB, SLC, page size: 2048, OOB size: 64 root@debian-armhf:~# dd if=/dev/ubiblock0_0 of=/dev/zero bs=1M 243+1 records in 243+1 records out 255080448 bytes (255 MB) copied, 4.39295 s, 58.1 MB/s vs. root@debian-armhf:~# dd if=/dev/ubiblock0_0 of=/dev/zero bs=1M 243+1 records in 243+1 records out 255080448 bytes (255 MB) copied, 2.87676 s, 88.7 MB/s Cc: hch@infradead.org Cc: axboe@fb.com Cc: tom.leiming@gmail.com Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Reviewed-by: Jens Axboe <axboe@fb.com> Acked-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
2015-01-28UBI: Add initial support for scatter gatherRichard Weinberger3-15/+138
Adds a new set of functions to deal with scatter gather. ubi_eba_read_leb_sg() will read from a LEB into a scatter gather list. The new data structure struct ubi_sgl will be used within UBI to hold the scatter gather list itself and metadata to have a cursor within the list. Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
2015-01-28UBI: rename_volumes: Use UBI_METAONLYRichard Weinberger1-1/+1
By using UBI_METAONLY in rename_volumes() it is now possible to rename an UBI volume atomically while it is open for writing. This is useful for firmware upgrades. Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Cc: Andrew Murray <amurray@embedded-bits.co.uk> Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Guido Martínez <guido@vanguardiasur.com.ar> Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar> Tested-by: Christoph Fritz <chf.fritz@googlemail.com> Tested-by: Andrew Murray <amurray@embedded-bits.co.uk>
2015-01-28UBI: Implement UBI_METAONLYRichard Weinberger3-7/+24
UBI_METAONLY is a new open mode for UBI volumes, it indicates that only meta data is being changed. Meta data in terms of UBI volumes means data which is stored in the UBI volume table but not on the volume itself. While it does not interfere with UBI_READONLY and UBI_READWRITE it is not allowed to use UBI_METAONLY together with UBI_EXCLUSIVE. Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Cc: Andrew Murray <amurray@embedded-bits.co.uk> Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Guido Martínez <guido@vanguardiasur.com.ar> Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar> Tested-by: Christoph Fritz <chf.fritz@googlemail.com> Tested-by: Andrew Murray <amurray@embedded-bits.co.uk>
2014-11-07UBI: Fix invalid vfree()Richard Weinberger1-4/+6
The logic of vfree()'ing vol->upd_buf is tied to vol->updating. In ubi_start_update() vol->updating is set long before vmalloc()'ing vol->upd_buf. If we encounter a write failure in ubi_start_update() before vmalloc() the UBI device release function will try to vfree() vol->upd_buf because vol->updating is set. Fix this by allocating vol->upd_buf directly after setting vol->updating. Fixes: [ 31.559338] UBI warning: vol_cdev_release: update of volume 2 not finished, volume is damaged [ 31.559340] ------------[ cut here ]------------ [ 31.559343] WARNING: CPU: 1 PID: 2747 at mm/vmalloc.c:1446 __vunmap+0xe3/0x110() [ 31.559344] Trying to vfree() nonexistent vm area (ffffc90001f2b000) [ 31.559345] Modules linked in: [ 31.565620] 0000000000000bba ffff88002a0cbdb0 ffffffff818f0497 ffff88003b9ba148 [ 31.566347] ffff88002a0cbde0 ffffffff8156f515 ffff88003b9ba148 0000000000000bba [ 31.567073] 0000000000000000 0000000000000000 ffff88002a0cbe88 ffffffff8156c10a [ 31.567793] Call Trace: [ 31.568034] [<ffffffff818f0497>] dump_stack+0x4e/0x7a [ 31.568510] [<ffffffff8156f515>] ubi_io_write_vid_hdr+0x155/0x160 [ 31.569084] [<ffffffff8156c10a>] ubi_eba_write_leb+0x23a/0x870 [ 31.569628] [<ffffffff81569b36>] vol_cdev_write+0x226/0x380 [ 31.570155] [<ffffffff81179265>] vfs_write+0xb5/0x1f0 [ 31.570627] [<ffffffff81179f8a>] SyS_pwrite64+0x6a/0xa0 [ 31.571123] [<ffffffff818fde12>] system_call_fastpath+0x16/0x1b Cc: <stable@vger.kernel.org> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-11-07UBI: Fix double free after do_sync_erase()Richard Weinberger1-7/+3
If the erase worker is unable to erase a PEB it will free the ubi_wl_entry itself. The failing ubi_wl_entry must not free()'d again after do_sync_erase() returns. Cc: <stable@vger.kernel.org> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-11-07UBI: vtbl: Use ubi_eba_atomic_leb_change()Richard Weinberger1-14/+9
This is more a cosmetic change than a fix. By using ubi_eba_atomic_leb_change() we can guarantee that the first VTBL record is always correct and we don't really need the second one anymore. But we have to keep the second one to not break anything. Artem: add a comment Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-11-07UBI: Extend UBI layer debug/messaging capabilitiesTanya Brokhman14-407/+441
If there is more then one UBI device mounted, there is no way to distinguish between messages from different UBI devices. Add device number to all ubi layer message types. The R/O block driver messages were replaced by pr_* since ubi_device structure is not used by it. Amended a bit by Artem. Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-10-03UBI: Fastmap: Calc fastmap size correctlyRichard Weinberger1-1/+2
We need to add fm_sb too. Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-30UBI: Fix trivial typo in __schedule_ubi_workRichard Weinberger1-1/+1
s/of/if/ Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-26UBI: wl: Rename cancel flag to shutdownRichard Weinberger2-15/+18
It confused me more than once that the cancel flag of the work function does not indicate the cancellation of a single work. In fact it indicates the WL sub-system shutdown and therefore worker functions have to free their wl_entries too. That's why you cannot cancel a single work, you can only shutdown all works. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-26UBI: ubi_eba_read_leb: Remove in vain variable assignmentRichard Weinberger1-3/+2
There is no need to set err, it will be overwritten in any case later at: if (scrub) err = ubi_wl_scrub_peb(ubi, pnum); Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-24UBI: Fix livelock in produce_free_peb()Richard Weinberger1-1/+1
The while loop in produce_free_peb() assumes that each work will produce a free PEB. This is not true. If ubi->works_count is 1 and the only scheduled work is the wear_leveling_worker() produce_free_peb() can loop forever in case nobody schedules an erase work. Fix this issue by checking in the while loop whether work is scheduled. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-19UBI: return on error in rename_volumes()Dan Carpenter1-1/+1
I noticed this during a code review. We are checking that the strlen() of ->name is not less than the ->name_len which the user gave us. I believe this bug is harmless but clearly we meant to return here instead of setting an error code and then not using it. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-19UBI: Improve comment on work_semRichard Weinberger1-1/+2
Make clear what work_sem really does. Suggested-by: Artem Bityutskiy <dedekind1@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-16UBI: Dispatch update notification if the volume is updatedEzequiel Garcia1-1/+3
The UBI_IOCVOLUP ioctl is used to start an update and also to truncate a volume. In the first case, a "volume updated" notification is dispatched when the update is done. This commit adds the "volume updated" notification to be also sent when the volume is truncated. This is required for UBI block and gluebi to get notified about the new volume size. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@vger.kernel.org # v3.15+
2014-09-16UBI: block: Add support for the UBI_VOLUME_UPDATED notificationEzequiel Garcia1-2/+14
Static volumes can change its 'used_bytes' when they get updated, and so the block interface must listen to the UBI_VOLUME_UPDATED notification to resize the block device accordingly. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@vger.kernel.org # v3.15+
2014-09-16UBI: block: Fix block device size settingEzequiel Garcia1-5/+6
We are currently taking the block device size from the ubi_volume_info.size field. However, this is not the amount of data in the volume, but the number of reserved physical eraseblocks, and hence leads to an incorrect representation of the volume. In particular, this produces I/O errors on static volumes as the block interface may attempt to read unmapped PEBs: $ cat /dev/ubiblock0_0 > /dev/null UBI error: ubiblock_read_to_buf: ubiblock0_0 ubi_read error -22 end_request: I/O error, dev ubiblock0_0, sector 9536 Buffer I/O error on device ubiblock0_0, logical block 2384 [snip] Fix this by using the ubi_volume_info.used_bytes field which is set to the actual number of data bytes for both static and dynamic volumes. While here, improve the error message to be less stupid and more useful: UBI error: ubiblock_read_to_buf: ubiblock0_1 ubi_read error -9 on LEB=0, off=15872, len=512 It's worth noticing that the 512-byte sector representation of the volume is only correct if the volume size is multiple of 512-bytes. This is true for virtually any NAND device, given eraseblocks and pages are 512-byte multiple and hence so is the LEB size. Artem: tweak the error message and make it look more like other UBI error messages. Fixes: 9d54c8a33eec ("UBI: R/O block driver on top of UBI volumes") Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@vger.kernel.org # v3.15+
2014-09-16UBI: block: fix dereference on uninitialized devColin Ian King1-5/+6
commit 4df38926f337 ("UBI: block: Avoid disk size integer overflow") introduced a dereference on dev (which is not initialized at that point) when printing a warning message. Re-order disk_capacity check after the dev is found. Found by cppcheck: [drivers/mtd/ubi/block.c:509]: (error) Uninitialized variable: dev Artem: tweak the error message a bit Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-09-16UBI: add missing kmem_cache_free() in process_pool_aeb error pathRichard Genoud1-0/+1
I ran into this error after a ubiupdatevol, because I forgot to backport e9110361a9a4 UBI: fix the volumes tree sorting criteria. UBI error: process_pool_aeb: orphaned volume in fastmap pool UBI error: ubi_scan_fastmap: Attach by fastmap failed, doing a full scan! kmem_cache_destroy ubi_ainf_peb_slab: Slab cache still has objects CPU: 0 PID: 1 Comm: swapper Not tainted 3.14.18-00053-gf05cac8dbf85 #1 [<c000d298>] (unwind_backtrace) from [<c000baa8>] (show_stack+0x10/0x14) [<c000baa8>] (show_stack) from [<c01b7a68>] (destroy_ai+0x230/0x244) [<c01b7a68>] (destroy_ai) from [<c01b8fd4>] (ubi_attach+0x98/0x1ec) [<c01b8fd4>] (ubi_attach) from [<c01ade90>] (ubi_attach_mtd_dev+0x2b8/0x868) [<c01ade90>] (ubi_attach_mtd_dev) from [<c038b510>] (ubi_init+0x1dc/0x2ac) [<c038b510>] (ubi_init) from [<c0008860>] (do_one_initcall+0x94/0x140) [<c0008860>] (do_one_initcall) from [<c037aadc>] (kernel_init_freeable+0xe8/0x1b0) [<c037aadc>] (kernel_init_freeable) from [<c02730ac>] (kernel_init+0x8/0xe4) [<c02730ac>] (kernel_init) from [<c00093f0>] (ret_from_fork+0x14/0x24) UBI: scanning is finished Freeing the cache in the error path fixes the Slab error. Tested on at91sam9g35 (3.14.18+fastmap backports) Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Cc: stable <stable@vger.kernel.org> # 3.10+
2014-07-28UBI: bugfix in ubi_wl_flush()Richard Weinberger1-2/+2
Use the _safe variant because we're iterating over a list where items get deleted and freed. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-28UBI: block: Avoid disk size integer overflowRichard Weinberger1-2/+9
This patch fixes the issue that on very large UBI volumes UBI block does not work correctly. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-28UBI: block: Set disk_capacity out of the mutexEzequiel Garcia1-4/+2
There's no need to set the disk capacity with the mutex held, so this commit takes the variable setting out of the mutex. This simplifies the disk capacity fix for very large volumes in a follow up commit. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-28UBI: block: Make ubiblock_resize return somethingEzequiel Garcia1-2/+3
Currently, ubiblock_resize() can fail if the device is not found in the list. This commit changes the return type, so the function can return something meaningful on error paths. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-19UBI: init_volumes: Ignore volumes with no LEBsRichard Weinberger1-1/+1
UBI assumes that ubi_attach_info will only contain ubi_ainf_volume structures for volumes with at least one LEB. In scanning mode this is true because UBI can nicely create a ubi_ainf_volume on demand while creating the EBA table. For fastmap this is not true, the fastmap on-flash structure has a list of all volumes, the ubi_ainf_volume structures are created from this list. So it can happen that an empty volume ends up in init_volumes(). We can easely deal with that by looking into ->leb_count too. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-16UBI: fastmap: do not miss bit-flipsBrian Norris1-1/+1
The return value from 'ubi_io_read_ec_hdr()' was stored in 'err', not in 'ret'. This fix makes sure Fastmap-enabled UBI does not miss bit-flip while reading EC headers, events and scrubs the affected PEBs. This issue was reported by Coverity Scan. Artem: improved the commit message. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-07-01UBI: fix the volumes tree sorting criteriaHeiko Schocher1-1/+1
Commig "604b592 UBI: fix rb_tree node comparison in add_map" broke fastmap backward compatibility and older fastmap images cannot be mounted anymore. The reason is that it changes the volumes RB-tree sorting criteria. This patch fixes the problem. Artem: re-write the commit message Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-06-10Merge tag 'upstream-3.16-rc1-v2' of git://git.infradead.org/linux-ubifsLinus Torvalds3-4/+6
Pull UBIFS updates from Artem Bityutskiy: "This contains several UBIFS fixes. One of them fixes a race condition between the mmap page fault path and fsync. Another just removes a bogus assertion from the UBIFS memory shrinker. UBIFS also started honoring the MS_SILENT mount flag, so now it won't print many I/O errors when user-space just tries to probe for the FS. Rest of the changes are rather minor UBI/UBIFS fixes, improvements, and clean-ups" * tag 'upstream-3.16-rc1-v2' of git://git.infradead.org/linux-ubifs: UBIFS: Add an assertion for clean_zn_cnt UBIFS: respect MS_SILENT mount flag UBIFS: Remove incorrect assertion in shrink_tnc() UBIFS: fix debugging check UBIFS: add missing ui pointer in debugging code UBI: block: Fix error path on alloc_workqueue failure UBIFS: Fix dump messages in ubifs_dump_lprops UBI: fix rb_tree node comparison in add_map UBIFS: Remove unused variables in ubifs_budget_space UBI: weaken the 'exclusive' constraint when opening volumes to rename UBIFS: fix an mmap and fsync race condition
2014-06-02Merge branch 'for-3.16/core' of git://git.kernel.dk/linux-block into nextLinus Torvalds1-1/+1
Pull block core updates from Jens Axboe: "It's a big(ish) round this time, lots of development effort has gone into blk-mq in the last 3 months. Generally we're heading to where 3.16 will be a feature complete and performant blk-mq. scsi-mq is progressing nicely and will hopefully be in 3.17. A nvme port is in progress, and the Micron pci-e flash driver, mtip32xx, is converted and will be sent in with the driver pull request for 3.16. This pull request contains: - Lots of prep and support patches for scsi-mq have been integrated. All from Christoph. - API and code cleanups for blk-mq from Christoph. - Lots of good corner case and error handling cleanup fixes for blk-mq from Ming Lei. - A flew of blk-mq updates from me: * Provide strict mappings so that the driver can rely on the CPU to queue mapping. This enables optimizations in the driver. * Provided a bitmap tagging instead of percpu_ida, which never really worked well for blk-mq. percpu_ida relies on the fact that we have a lot more tags available than we really need, it fails miserably for cases where we exhaust (or are close to exhausting) the tag space. * Provide sane support for shared tag maps, as utilized by scsi-mq * Various fixes for IO timeouts. * API cleanups, and lots of perf tweaks and optimizations. - Remove 'buffer' from struct request. This is ancient code, from when requests were always virtually mapped. Kill it, to reclaim some space in struct request. From me. - Remove 'magic' from blk_plug. Since we store these on the stack and since we've never caught any actual bugs with this, lets just get rid of it. From me. - Only call part_in_flight() once for IO completion, as includes two atomic reads. Hopefully we'll get a better implementation soon, as the part IO stats are now one of the more expensive parts of doing IO on blk-mq. From me. - File migration of block code from {mm,fs}/ to block/. This includes bio.c, bio-integrity.c, bounce.c, and ioprio.c. From me, from a discussion on lkml. That should describe the meat of the pull request. Also has various little fixes and cleanups from Dave Jones, Shaohua Li, Duan Jiong, Fengguang Wu, Fabian Frederick, Randy Dunlap, Robert Elliott, and Sam Bradshaw" * 'for-3.16/core' of git://git.kernel.dk/linux-block: (100 commits) blk-mq: push IPI or local end_io decision to __blk_mq_complete_request() blk-mq: remember to start timeout handler for direct queue block: ensure that the timer is always added blk-mq: blk_mq_unregister_hctx() can be static blk-mq: make the sysfs mq/ layout reflect current mappings blk-mq: blk_mq_tag_to_rq should handle flush request block: remove dead code in scsi_ioctl:blk_verify_command blk-mq: request initialization optimizations block: add queue flag for disabling SG merging block: remove 'magic' from struct blk_plug blk-mq: remove alloc_hctx and free_hctx methods blk-mq: add file comments and update copyright notices blk-mq: remove blk_mq_alloc_request_pinned blk-mq: do not use blk_mq_alloc_request_pinned in blk_mq_map_request blk-mq: remove blk_mq_wait_for_tags blk-mq: initialize request in __blk_mq_alloc_request blk-mq: merge blk_mq_alloc_reserved_request into blk_mq_alloc_request blk-mq: add helper to insert requests from irq context blk-mq: remove stale comment for blk_mq_complete_request() blk-mq: allow non-softirq completions ...
2014-05-27UBI: block: Fix error path on alloc_workqueue failureHelmut Schaa1-1/+3
Otherwise we'd return a random value if allocation of the workqueue fails. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Acked-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-05-13UBI: fix rb_tree node comparison in add_mapMike Snitzer1-2/+2
The comparisons used in add_vol() shouldn't be identical. Pretty sure the following is correct but it is completely untested. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-05-13UBI: weaken the 'exclusive' constraint when opening volumes to renameEzequiel Garcia1-1/+1
The UBI volume rename ioctl (UBI_IOCRNVOL) open the volumes in exclusive mode. The volumes are opened for two reasons: to build a volume rename list, and a volume remove list. However, the first open constraint is excessive and can be replaced by a 'read-write' open mode. The second open constraint is properly set as 'exclusive' given the volume is opened for removal and we don't want any users around. By weakening the former 'exclusive' mode, we allow 'read-only' users to keep the volume open, while a rename is taking place. This is useful to perform an atomic rename, in a firmware upgrade scenario, while keeping the volume in read-only use (for instance, if a ubiblock is mounted as rootfs). It's worth mention this is not the case of UBIFS, which keeps the volume opened as 'read-write' despite mounted as read-write or read-only mode. This change was suggested at least twice by Artem: http://lists.infradead.org/pipermail/linux-mtd/2012-September/044175.html http://permalink.gmane.org/gmane.linux.drivers.mtd/39866 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-05-05UBI: avoid workqueue format string leakKees Cook1-1/+1
When building the name for the workqueue thread, make sure a format string cannot leak in from the disk name. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-05-05UBI: fix ubi free PEBs count calculationTanya Brokhman1-0/+3
The ubi->free_count should be updated with every insert/remove to/from the ubi->free list. Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org> Reviewed-by: Dolev Raviv <draviv@codeaurora.org> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-05-05UBI: fix error path in __wl_get_pebTanya Brokhman1-0/+3
In case of an error (if there are not free PEB's for example), __wl_get_peb will return a negative value. In order to prevent access violation we need to test the returned value prior to using it later on. Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> Reviewed-by: Dolev Raviv <draviv@codeaurora.org> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-04-15block: remove struct request buffer memberJens Axboe1-1/+1
This was used in the olden days, back when onions were proper yellow. Basically it mapped to the current buffer to be transferred. With highmem being added more than a decade ago, most drivers map pages out of a bio, and rq->buffer isn't pointing at anything valid. Convert old style drivers to just use bio_data(). For the discard payload use case, just reference the page in the bio. Signed-off-by: Jens Axboe <axboe@fb.com>
2014-04-07Merge tag 'for-linus-20140405' of git://git.infradead.org/linux-mtdLinus Torvalds1-1/+0
Pull MTD updates from Brian Norris: - A few SPI NOR ID definitions - Kill the NAND "max pagesize" restriction - Fix some x16 bus-width NAND support - Add NAND JEDEC parameter page support - DT bindings for NAND ECC - GPMI NAND updates (subpage reads) - More OMAP NAND refactoring - New STMicro SPI NOR driver (now in 40 patches!) - A few other random bugfixes * tag 'for-linus-20140405' of git://git.infradead.org/linux-mtd: (120 commits) Fix index regression in nand_read_subpage mtd: diskonchip: mem resource name is not optional mtd: nand: fix mention to CONFIG_MTD_NAND_ECC_BCH mtd: nand: fix GET/SET_FEATURES address on 16-bit devices mtd: omap2: Use devm_ioremap_resource() mtd: denali_dt: Use devm_ioremap_resource() mtd: devices: elm: update DRIVER_NAME as "omap-elm" mtd: devices: elm: configure parallel channels based on ecc_steps mtd: devices: elm: clean elm_load_syndrome mtd: devices: elm: check for hardware engine's design constraints mtd: st_spi_fsm: Succinctly reorganise .remove() mtd: st_spi_fsm: Allow loop to run at least once before giving up CPU mtd: st_spi_fsm: Correct vendor name spelling issue - missing "M" mtd: st_spi_fsm: Avoid duplicating MTD core code mtd: st_spi_fsm: Remove useless consts from function arguments mtd: st_spi_fsm: Convert ST SPI FSM (NOR) Flash driver to new DT partitions mtd: st_spi_fsm: Move runtime configurable msg sequences into device's struct mtd: st_spi_fsm: Supply the W25Qxxx chip specific configuration call-back mtd: st_spi_fsm: Supply the S25FLxxx chip specific configuration call-back mtd: st_spi_fsm: Supply the MX25xxx chip specific configuration call-back ...
2014-03-21UBI: block: Remove __initdata from ubiblock_param_opsRichard Weinberger1-1/+1
You cannot mark these parameters as __initdata. Otherwise the data is gone upon module exit. Fixes: [ 172.045465] BUG: unable to handle kernel paging request at ffffffffa001db38 [ 172.046020] IP: [<ffffffff81067aa4>] destroy_params+0x24/0x50 Signed-off-by: Richard Weinberger <richard@nod.at> Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-03-10mtd: delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Cc: David Woodhouse <dwmw2@infradead.org> Cc: Brian Norris <computersforpeace@gmail.com> Cc: linux-mtd@lists.infradead.org Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> [Brian: dropped one incorrect hunk] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-03-05UBI: rename block device ioctlsArtem Bityutskiy2-5/+5
Rename the UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK to UBI_IOCVOLCRBLK and UBI_IOCVOLRMBLK, because we do not use terms "attach" and "detach" for the R/O block devices on top of UBI volumes. Instead, we use terms "create" and "remove". This patch also amends the related commentaries. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
2014-03-05UBI: block: Use ENOSYS as return value when CONFIG_UBIBLOCK=nEzequiel Garcia1-2/+2
In order to have a way of distinguishing an invalid ioctl from a not supported (but otherwise valid) ioctl, this commit changes the return value of the ioctl stubs from ENOTTY to ENOSYS. This will be useful to report more accurate error messages from userspace tools. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>