aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-03-26UBI: Fastmap: Introduce ubi_fastmap_init()Richard Weinberger2-7/+8
...and kill another #ifdef in wl.c. :-) Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Wire up WL accessor functionsRichard Weinberger1-16/+12
Use the new WL accessor functions in fastmap. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Add accessor functions for WL data structuresRichard Weinberger1-0/+36
Fastmap need access to various WL data structures as fastmap tightly depends on WL. To make the access less invasive add accessor functions. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Move fastmap specific functions out of wl.cRichard Weinberger3-463/+476
Fastmap is tightly connected to the WL sub-system, many fastmap-specific functionslive in wl.c. To get rid of most #ifdefs in wl.c move this functions into a new file and include it into wl.c Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Add new module parameter fm_debugRichard Weinberger2-0/+10
If fm_debug is set fastmap debugging is enabled by default. This is useful if one wants to debug fastmap on an UBI device with serves the rootfs. The the UBI attach mechanism runs long before debugfs can be mounted and chk_fastmap set. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Make self_check_eba() depend on fastmap self checkingRichard Weinberger1-1/+1
...instead of generic self checking. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Add self check to detect absent PEBsRichard Weinberger1-2/+84
This self check allows Fastmap to detect absent PEBs while writing a new fastmap to the MTD device. It will help to find implementation issues in Fastmap. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fix stale pointers in ubi->lookuptblRichard Weinberger1-16/+31
In some error paths the WL sub-system gives up on a PEB and frees it's ubi_wl_entry struct but does not set the entry in ubi->lookuptbl to NULL. Fastmap can stumble over such a stale pointer as it uses ubi->lookuptbl to find all PEBs. Fix this by introducing a new helper function which free()s a WL entry and removes the reference from the lookup table. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Enhance fastmap checkingRichard Weinberger1-2/+5
Don't update the fastmap upon detach if fastmap checking is enabled. This is poor men's power cut testing feature. :-) Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Add initial support for fastmap self checksRichard Weinberger3-0/+20
Using this debugfs knob fastmap self checks can be controlled. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Tanya Brokhman <[email protected]>
2015-03-26UBI: Fastmap: Rework fastmap error pathsRichard Weinberger1-48/+114
If UBI is unable to write the fastmap to the device we have make sure that upon next attach UBI will fall back to scanning mode. In case we cannot ensure that they only thing we can do is falling back to read-only mode. The current error handling code is not powercut proof. It could happen that a powercut while invalidating would lead to a state where an too old fastmap could be used upon attach. This patch addresses the issue by writing a fake fastmap super block to a fresh PEB instead of reerasing the existing one. The fake fastmap super block will UBI case to do a full scan. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Prepare for variable sized fastmapsRichard Weinberger1-2/+10
The current code assumes that each fastmap has the same amount of PEBs. So far this is true but will change soon. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Locking updatesRichard Weinberger5-44/+50
a) Rename ubi->fm_sem to ubi->fm_eba_sem as this semaphore protects EBA changes. b) Turn ubi->fm_mutex into a rw semaphore. It will still serialize fastmap writes but also ensures that ubi_wl_put_peb() is not interrupted by a fastmap write. We use a rw semaphore to allow ubi_wl_put_peb() still to be executed in parallel if no fastmap write is happening. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Set used_ebs only for static volumesRichard Weinberger1-2/+3
If we set it for dynamic ones we might confuse various self checks. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix race after ubi_wl_get_peb()Richard Weinberger2-6/+25
ubi_wl_get_peb() returns a fresh PEB which can be used by user of UBI. Due to the pool logic fastmap will correctly map this PEB upon attach time because it will be scanned. If a new fastmap is written (due to heavy parallel io) while the before the fresh PEB is assigned to the EBA table it will not be scanned as it is no longer in the pool. So, the race window exists between ubi_wl_get_peb() and the EBA table assignment. We have to make sure that no new fastmap can be written while that. To ensure that ubi_wl_get_peb() will grab ubi->fm_sem in read mode and the user of ubi_wl_get_peb() has to release it after the PEB got assigned. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix leb_count unbalanceRichard Weinberger1-0/+1
If a LEB is unmapped we have to decrement leb_count as well. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Make WL pool size 50% of user pool sizeRichard Weinberger2-3/+1
Don't use a fixed size for the WL pool. Make it instead 50% of the user pool. We don't make it 100% as it is not as heavily used as the user pool. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Switch to ro mode if invalidate_fastmap() failsRichard Weinberger1-1/+3
We have to switch to ro mode to guarantee that upon next UBI attach all data is consistent. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Remove eba_orphans logicRichard Weinberger1-83/+8
This logic is in vain as we treat protected PEBs also as used, so this case must not happen. If a PEB is found which is in the EBA table but not known as used has to be issued as fatal error. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Remove bogus ubi_assert()Richard Weinberger1-1/+3
It is legal to have PEBs left in the used list. This can happen if UBI copies a PEB and a powercut happens between writing a new fastmap and adding this PEB into the EBA table. In this case the old PEB will be used. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix race in ubi_eba_atomic_leb_change()Richard Weinberger1-7/+8
This function a) requests a new PEB, b) writes data to it, c) returns the old PEB and d) registers the new PEB in the EBA table. For the non-fastmap case this works perfectly fine and is powercut safe. Is fastmap enabled this can lead to issues. If a new fastmap is written between a) and c) the freshly requested PEB is no longer in a pool and will not be scanned upon attaching. If now a powercut happens between c) and d) the freshly requested PEB will not be scanned and the old one got already scheduled for erase. After attaching the EBA table will point to a erased PEB. Fix this issue by swapping steps c) and d). Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Remove alloc_ai() slab name from parameter listRichard Weinberger1-6/+6
There is always exactly one ubi_attach_info object allocated, therefore we don't have to care about the name. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix memory leak while attachingRichard Weinberger2-41/+33
Currently we leak a few ubi_ainf_pebs while attaching. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix fastmap usage in ubi_volume_notify()Richard Weinberger1-6/+5
There is no need to switch to ro mode if ubi_update_fastmap() fails. Also get rid of the ifdef. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Tanya Brokhman <[email protected]>
2015-03-26UBI: Fastmap: Wrap fastmap specific function in a ifdefRichard Weinberger1-0/+4
...such that we can implement NOP variants of some functions. This will help to reduce fastmap specific ifdefs in other c files. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Tanya Brokhman <[email protected]>
2015-03-26UBI: Fastmap: Notify user in case of an ubi_update_fastmap() failureRichard Weinberger1-1/+5
If ubi_update_fastmap() fails notify the user. This is not a hard error as ubi_update_fastmap() makes sure that upon failure the current on-flash fastmap will no be used upon next UBI attach. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix memory leaks while closing the WL sub-systemRichard Weinberger1-0/+18
Add a ubi_fastmap_close() to free all resources used by fastmap at WL shutdown. Signed-off-by: Richard Weinberger <[email protected]> Tested-by: Guido Martínez <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
2015-03-26UBI: Fastmap: Don't allocate new ubi_wl_entry objectsRichard Weinberger2-29/+5
There is no need to allocate new ones every time, we can reuse the existing ones. This makes the code cleaner and more easy to follow. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Tanya Brokhman <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
2015-03-26UBI: Fastmap: Make ubi_refill_pools() fairRichard Weinberger1-38/+47
Currently ubi_refill_pools() first fills the first and then the second one. If only very few free PEBs are available the second pool can get zero PEBs. Change ubi_refill_pools() to distribute free PEBs fair between all pools. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
2015-03-26UBI: Split __wl_get_peb()Richard Weinberger1-23/+38
Make it two functions, wl_get_wle() and wl_get_peb(). wl_get_peb() works exactly like __wl_get_peb() but wl_get_wle() does not call produce_free_peb(). While refilling the fastmap user pool we cannot release ubi->wl_lock as produce_free_peb() does. Hence the fastmap logic uses now wl_get_wle(). Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Fix races in ubi_wl_get_peb()Richard Weinberger2-12/+25
ubi_wl_get_peb() has two problems, it reads the pool size and usage counters without any protection. While reading one value would be perfectly fine it reads multiple values and compares them. This is racy and can lead to incorrect pool handling. Furthermore ubi_update_fastmap() is called without wl_lock held, before incrementing the used counter it needs to be checked again. It could happen that another thread consumed all PEBs from the pool and the counter goes beyond ->size. Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: Fastmap: Ensure that all fastmap work is done upon WL shutdownRichard Weinberger1-0/+3
...otherwise the deferred work might run after datastructures got freed and corrupt memory. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
2015-03-26UBI: Fastmap: Ensure that only one fastmap work is scheduledRichard Weinberger2-2/+10
If the WL pool runs out of PEBs we schedule a fastmap write to refill it as soon as possible. Ensure that only one at a time is scheduled otherwise we might end in a fastmap write storm because writing the fastmap can schedule another write if bitflips are detected. Signed-off-by: Richard Weinberger <[email protected]> Reviewed-by: Tanya Brokhman <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
2015-03-26UBI: align comment for readabilityBrian Norris1-1/+1
The kerneldoc for @vid_hdr_aloffset continues onto a second line, but this is not obvious, because the second line isn't indented, and it begins with '@'. Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: fix check for "too many bytes"Brian Norris1-1/+1
The comparison from the previous line seems to have been erroneously (partially) copied-and-pasted onto the next. The second line should be checking req.bytes, not req.lnum. Coverity CID #139400 Cc: stable <[email protected]> Signed-off-by: Brian Norris <[email protected]> [rw: Fixed comparison] Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: initialize LEB number variableBrian Norris1-1/+1
In some of the 'out_not_moved' error paths, lnum may be used uninitialized. Don't ignore the warning; let's fix it. This uninitialized variable doesn't have much visible effect in the end, since we just schedule the PEB for erasure, and its LEB number doesn't really matter (it just gets printed in debug messages). But let's get it straight anyway. Coverity CID #113449 Cc: stable <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: fix out of bounds writeBrian Norris1-1/+2
If aeb->len >= vol->reserved_pebs, we should not be writing aeb into the PEB->LEB mapping. Caught by Coverity, CID #711212. Cc: stable <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
2015-03-26UBI: account for bitflips in both the VID header and dataBrian Norris1-1/+1
We are completely discarding the earlier value of 'bitflips', which could reflect a bitflip found in ubi_io_read_vid_hdr(). Let's use the bitwise OR of header and data 'bitflip' statuses instead. Coverity CID #1226856 Cc: stable <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
2015-03-25UBIFS: extend debug/message capabilitiesSheng Yong25-409/+419
In the case where we have more than one volumes on different UBI devices, it may be not that easy to tell which volume prints the messages. Add ubi number and volume id in ubifs_msg/warn/error to help debug. These two values are passed by struct ubifs_info. For those where ubifs_info is not initialized yet, ubifs_* is replaced by pr_*. For those where ubifs_info is not avaliable, ubifs_info is passed to the calling function as a const parameter. The output looks like, [ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696 [ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1" [ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs) [ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB) [ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model [ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699 [ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2" [ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs) [ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB) [ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model [ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6) [ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1 Signed-off-by: Sheng Yong <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
2015-03-25UBIFS: simplify returnsFabian Frederick1-8/+2
Directly return recover_head() and ubifs_leb_unmap() instead of storing value in err and testing it. Signed-off-by: Fabian Frederick <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
2015-03-25UBIFS: Fix trivial typos in commentsYannick Guerrini1-7/+7
Change 'comress' to 'compress' Change 'inteval' to 'interval' Change 'disabe' to 'disable' Change 'nenver' to 'never' Signed-off-by: Yannick Guerrini <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
2015-03-25UBIFS: do not write master node if need recoverySheng Yong1-1/+1
The commits 781c571 ("UBIFS: intialize LPT earlier") and 0980119 ("UBIFS: fix-up free space earlier") move some initialization before marking the master node dirty. But the modification changes the conditions of writing master. If unclean umount happens, ubifs may fail when mounting. But trying to mount it will write new master nodes on the flash. This is useless but increasing sqnum. So check need_recovery before writing master node, and don't create new master node if filesystem needs recovery. The behavour of the bug shows at: http://lists.infradead.org/pipermail/linux-mtd/2015-February/057712.html Signed-off-by: Sheng Yong <[email protected]> Reviewed-by: Ben Gardiner <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
2015-03-25UBIFS: fix incorrect unlocking handlingTaesoo Kim1-4/+7
When ubifs_init_security() fails, 'ui_mutex' is incorrectly unlocked and incorrectly restores 'i_size'. Fix this. Signed-off-by: Taesoo Kim <[email protected]> Fixes: d7f0b70d30ff ("UBIFS: Add security.* XATTR support for the UBIFS") Reviewed-by: Ben Shelton <[email protected]> Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
2015-03-25Merge tag 'v4.0-rc5' into linux-nextArtem Bityutskiy1510-17224/+38074
Merge the upstream -rc5 tag because we needed a more up-to-date base our further work.
2015-03-22Linux 4.0-rc5Linus Torvalds1-1/+1
2015-03-22Merge tag 'md/4.0-rc4-fix' of git://neil.brown.name/mdLinus Torvalds2-3/+2
Pull bugfix for md from Neil Brown: "One fix for md in 4.0-rc4 Regression in recent patch causes crash on error path" * tag 'md/4.0-rc4-fix' of git://neil.brown.name/md: md: fix problems with freeing private data after ->run failure.
2015-03-22Merge tag 'driver-core-4.0-rc5' of ↵Linus Torvalds2-0/+4
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core fixes from Greg KH: "Here are two bugfixes for things reported. One regression in kernfs, and another issue fixed in the LZ4 code that was fixed in the "upstream" codebase that solves a reported kernel crash Both have been in linux-next for a while" * tag 'driver-core-4.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: LZ4 : fix the data abort issue kernfs: handle poll correctly on 'direct_read' files.
2015-03-22Merge tag 'char-misc-4.0-rc5' of ↵Linus Torvalds3-183/+3
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc fixes from Greg KH: "Here are three fixes for 4.0-rc5 that revert 3 PCMCIA patches that were merged in 4.0-rc1 that cause regressions. So let's revert them for now and they will be reworked and resent sometime in the future. All have been tested in linux-next for a while" * tag 'char-misc-4.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: Revert "pcmcia: add a new resource manager for non ISA systems" Revert "pcmcia: fix incorrect bracketing on a test" Revert "pcmcia: add missing include for new pci resource handler"
2015-03-22Merge tag 'staging-4.0-rc5' of ↵Linus Torvalds3-17/+17
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging driver fixes from Greg KH: "Here are four small staging driver fixes, all for the vt6656 and vt6655 drivers, that resolve some reported issues with them. All of these patches have been in linux next for a while" * tag 'staging-4.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: vt6655: Fix late setting of byRFType. vt6655: RFbSetPower fix missing rate RATE_12M staging: vt6656: vnt_rf_setpower: fix missing rate RATE_12M staging: vt6655: vnt_tx_packet fix dma_idx selection.
2015-03-22Merge tag 'tty-4.0-rc5' of ↵Linus Torvalds1-3/+12
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty Pull tty/serial driver fix from Greg KH: "Here's a single 8250 serial driver that fixes a reported deadlock with the serial console and the tty driver. It's been in linux-next for a while now" * tag 'tty-4.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: 8250_dw: Fix deadlock in LCR workaround