summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
Commit message (Collapse)AuthorAgeFilesLines
* UBI: Don't exit from ubi_thread until kthread_should_stop() is trueVitaliy Gusev2008-11-061-1/+2
| | | | | | | | | If ubi_thread() exits but kthread_should_stop() is not true then kthread_stop() will never return and cleanup thread will forever stay in "D" state. Signed-off-by: Vitaliy Gusev <vgusev@openvz.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix EBADMSG handlingZoltan Sogor2008-11-062-2/+2
| | | | | | | | | | | 'ubi_io_read_data()' may return EBADMSG in case of an ECC error, and we should not panic because of this. We have CRC32 checksum and may check the data. So just ignore the EBADMSG error. This patch also fixes a minor spelling error at the same time. Signed-off-by: Zoltan Sogor <weth@inf.u-szeged.hu> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: print reserved_peb when it is too largeDeepak Saxena2008-10-091-2/+2
| | | | | | | | This patch makes debugging a missconfigured UBI a bit easier by providing the needed information in the boot log. Signed-off-by: Deepak Saxena <dsaxena@laptop.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix IS_ERR testJulien Brunel2008-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case of error, the function add_volume returns an ERR pointer. The result of IS_ERR, which is supposed to be used in a test as it is, is here checked to be less than zero, which seems odd. We suggest to replace this test by a simple IS_ERR test. A simplified version of the semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @def0@ expression x; position p0; @@ x@p0 = add_volume(...) @protected@ expression def0.x,E; position def0.p0; position p; statement S; @@ x@p0 ... when != x = E if (!IS_ERR(x) && ...) {<... x@p ...>} else S @unprotected@ expression def0.x,E; identifier fld; position def0.p0; position p != protected.p; @@ x@p0 ... when != x = E * x@p->fld // </smpl> Signed-off-by: Julien Brunel <brunel@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove BKLArtem Bityutskiy2008-09-051-5/+1Star
| | | | | | | We do not need BKL in UBI because we serialize things properly. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: always start the background threadArtem Bityutskiy2008-07-251-4/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix only affects UBI debugging. If the the background thread is disabled for debugging purposes, start it anyway, because otherwise we see tonns of kernel debugging complaints like this: INFO: task ubi_bgt0d:26857 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. ubi_bgt0d D dd37bf94 0 26857 2 dd37bfcc 00000086 f8e17cea dd37bf94 00000046 00000000 00000000 f5c62430 f5c62430 f5c62590 c2a09c80 f6cbd498 dd8e9cbc 00000296 dd37bfb0 00000296 dd8e9cb8 dd8e9cbc dd37bfcc c0119774 00000000 00000000 c0132e89 f6961560 Call Trace: [<f8e17cea>] ? ubi_thread+0x0/0x127 [ubi] [<c0119774>] ? complete+0x43/0x4b [<c0132e89>] ? kthread+0x0/0x5b [<f8e17cea>] ? ubi_thread+0x0/0x127 [ubi] [<c0132eae>] kthread+0x25/0x5b [<c0132e89>] ? kthread+0x0/0x5b [<c0104953>] kernel_thread_helper+0x7/0x14 ======================= So start it, and go sleep inside it, instead of creating it and never start. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix gcc warningArtem Bityutskiy2008-07-241-1/+1
| | | | | | | | | Fix the following warning: drivers/mtd/ubi/vmt.c: In function 'ubi_rename_volumes': drivers/mtd/ubi/vmt.c:642: warning: statement with no effect Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove pre-sqnum images supportArtem Bityutskiy2008-07-245-79/+30Star
| | | | | | | | | | | | | | | | | | | | Before UBI got into mainline, there was a slight flash format change - we did not have sequence number support, then added it. We have carried full support of those ancient images till this moment. Now the support is removed, well, not fully removed. Now UBI will support only _clean_ old images, which were cleanly detached last time (just before kernel upgrade). This is most likely the case. But we will not support unclean ancient images. Surprisingly, this allows us to remove a big chunk of legacy code. And the same should be true for downgrading: clean images should downgrade fine, but unclean ones will not. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix kernel-doc errors and warningsArtem Bityutskiy2008-07-248-35/+23Star
| | | | | | | No functional changes, just tweak comments to make kernel-doc work fine and stop complaining. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix checkpatch.pl errors and warningsArtem Bityutskiy2008-07-2411-81/+78Star
| | | | | | | | Just out or curiousity ran checkpatch.pl for whole UBI, and discovered there are quite a few of stylistic issues. Fix them. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix - do not torture PEB needlesslyArtem Bityutskiy2008-07-241-1/+1
| | | | | | | This is probably a copy-paste bug - we torture the old PEB in the atomic LEB change function, but we should not do this. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: rework scrubbing messagesArtem Bityutskiy2008-07-242-2/+12
| | | | | | | | If bit-flips happen often, UBI prints to many messages. Lessen the amount by only printing the messages when the PEB has been scrubbed. Also, print torturing messages. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: implement multiple volumes renameArtem Bityutskiy2008-07-245-12/+318
| | | | | | | Quite useful ioctl which allows to make atomic system upgrades. The idea belongs to Richard Titmuss <richard_titmuss@logitech.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix and re-work debugging stuffArtem Bityutskiy2008-07-2411-177/+206
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: amend commentariesArtem Bityutskiy2008-07-249-126/+127
| | | | | | | Hch asked not to use "unit" for sub-systems, let it be so. Also some other commentaries modifications. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix error messageArtem Bityutskiy2008-07-241-1/+1
| | | | | | The ubi_err() macro will add \n. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: improve mkvol request validationArtem Bityutskiy2008-07-242-4/+7
| | | | | | | | | Check that volume name is not shorter than 'name_len'. No need to copy the trailing zero byte because whole array was zeroed earlier. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add ubi_sync() interfaceArtem Bityutskiy2008-07-241-0/+24
| | | | | | To flush MTD device caches. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix 64-bit calculationsBruce Leonard2008-07-241-1/+2
| | | | | Signed-off-by: Bruce Leonard <brucle@selinc.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix LEB lockingArtem Bityutskiy2008-07-241-20/+7Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | leb_read_unlock() may be called simultaniously by several tasks. The would race at the following code: up_read(&le->mutex); if (free) kfree(le); And it is possible that one task frees 'le' before the other tasks do 'up_read()'. Fix this by doing up_read and free inside the 'ubi->ltree' lock. Below it the oops we had because of this: BUG: spinlock bad magic on CPU#0, integck/7504 BUG: unable to handle kernel paging request at 6b6b6c4f IP: [<c0211221>] spin_bug+0x5c/0xdb *pde = 00000000 Oops: 0000 [#1] PREEMPT SMP Modules linked in: ubifs ubi nandsim nand nand_ids nand_ecc video output Pid: 7504, comm: integck Not tainted (2.6.26-rc3ubifs26 #8) EIP: 0060:[<c0211221>] EFLAGS: 00010002 CPU: 0 EIP is at spin_bug+0x5c/0xdb EAX: 00000032 EBX: 6b6b6b6b ECX: 6b6b6b6b EDX: f7f7ce30 ESI: f76491dc EDI: c044f51f EBP: e8a736cc ESP: e8a736a8 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 Process integck (pid: 7504, ti=e8a72000 task=f7f7ce30 task.ti=e8a72000) Stack: c044f754 c044f51f 00000000 f7f7d024 00001d50 00000001 f76491dc 00000296 f6df50e0 e8a736d8 c02112f0 f76491dc e8a736e8 c039157a f7d9e830 f76491d8 e8a7370c c020b975 f76491dc 00000296 f76491f8 00000000 f76491d8 00000000 Call Trace: [<c02112f0>] ? _raw_spin_unlock+0x50/0x7c [<c039157a>] ? _spin_unlock_irqrestore+0x20/0x58 [<c020b975>] ? rwsem_wake+0x4b/0x122 [<c0390e0a>] ? call_rwsem_wake+0xa/0xc [<c0139ee7>] ? up_read+0x28/0x31 [<f8873b3c>] ? leb_read_unlock+0x73/0x7b [ubi] [<f88742a3>] ? ubi_eba_read_leb+0x195/0x2b0 [ubi] [<f8872a04>] ? ubi_leb_read+0xaf/0xf8 [ubi] Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix memory leak on error pathArtem Bityutskiy2008-07-241-4/+30
| | | | | | | | | Normally UBI volumes are freed in the release function of the struct device object. However, on error path they may have to be freed before the struct device objects have been initialized. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: do not forget to free internal volumesArtem Bityutskiy2008-07-241-3/+25
| | | | | | | | UBI forgets to free internal volumes when detaching MTD device. Fix this. Pointed-out-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix memory leakArtem Bityutskiy2008-07-244-29/+9Star
| | | | | | | | | ubi_free_volume() function sets ubi->volumes[] to NULL, so ubi_eba_close() is useless, it does not free what has to be freed. So zap it and free vol->eba_tbl at the volume release function. Pointed-out-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: avoid unnecessary division operationsKyungmin Park2008-07-248-16/+18
| | | | | | | | UBI already checks that @min io size is the power of 2 at io_init. It is save to use bit operations then. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix buffer paddingKyungmin Park2008-07-241-3/+3
| | | | | | | | | | | | Instead of correctly pad the buffer wich we are writing to the eraseblock during update, we used weird construct: memset(buf + len, 0xFF, len - len); Fix this. Signed-off-by: Kyungmin Park <kmpark@infradead.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add a commentArtem Bityutskiy2008-07-241-1/+10
| | | | | | | | It is not clear why we schedule PEB for scrubbing in case of -EBADMSG. Elaborate. Requested-by: Kyungmin Park <kmpark@infradead.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: print error codeArtem Bityutskiy2008-07-241-18/+21
| | | | | | | Print error code if checking failed which is very useful to identify problems. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: cdev lock_kernel() pushdownJonathan Corbet2008-06-201-1/+6
| | | | Signed-off-by: Jonathan Corbet <corbet@lwn.net>
* UBI: add a messageArtem Bityutskiy2008-04-231-2/+1Star
| | | | | | | | UBI scan takes quite a time on some systems, so it is nice to print a message that we started attaching an MTD device. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* Merge git://git.infradead.org/~dedekind/ubi-2.6David Woodhouse2008-04-239-59/+416
|\
| * UBI: print media information earlierArtem Bityutskiy2008-04-201-9/+10
| | | | | | | | | | | | | | | | | | | | Print information about logicale eraseblock size, sub-page size and so on at early stage, befor an attempt to attach the MTD device was made. This is more convenient to do so because the attempt to attach may fail, and the information is never printed then. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: fix mean EC calculationArtem Bityutskiy2008-04-192-34/+9Star
| | | | | | | | | | | | | | | | | | | | | | (a + b) / (c + d) != a / c + b / d. The old code errornously assumed this incorrect formuld. Instead, just sum all erase counters in a 64-bit variable and divide to the number of EBs at the end. Thanks to Adrian Hunter for pointing this out. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: initialize static volumes with vol->used_bytesJan Altenberg2008-04-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | I came across a problem which seems to be present since: commit 941dfb07ed91451b1c58626a0d258dfdf468b593 UBI: set correct gluebi device size ubi_create_gluebi() leaves mtd->size = 0 for static volumes. So even existing static volumes are initialized with a size of 0. Signed-off-by: Jan Altenberg <jan.altenberg@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: improve Kconfig documentationArtem Bityutskiy2008-04-171-2/+7
| | | | | | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: fix error printingArtem Bityutskiy2008-04-171-10/+8Star
| | | | | | | | | | | | Use existing ubi_err() as the rest of the code does. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: make ubi-header.h localArtem Bityutskiy2008-04-172-2/+373
| | | | | | | | | | | | | | | | | | | | | | The new trend in linux is not to store headers which define on-media format in the include/ directory, but instead, store them locally. This is because these headers "do not define any kernel<->userspace interface". Do so for UBI as well. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: be verbose when debuggin is enabledArtem Bityutskiy2008-04-172-0/+6
| | | | | | | | | | | | | | Make I/O function to be always verbose when about CRC errors and magic number errors when I/O debugging is enabled. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* | [MTD] replace remaining __FUNCTION__ occurrencesHarvey Harrison2008-04-222-3/+3
|/ | | | | | | | __FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* UBI: mtd/ubi/vtbl.c: fix memory leakAdrian Bunk2008-03-041-0/+1
| | | | | | | | | This patch fixes a memory leak introduced by commit 4ccf8cffa963c7b5bdc6d455ea9417084ee49aa8 and spotted by the Coverity checker. Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix sparse errors in ubi.hHarvey Harrison2008-03-041-5/+5
| | | | | | | | | | | | | | | | | In C, signed 1-bit bitfields can only take the values 0 and -1, only 0 and 1 are ever assigned in current code. Make them unsigned bitfields. Fixes the (repeated) sparse errors: drivers/mtd/ubi/ubi.h:220:15: error: dubious one-bit signed bitfield drivers/mtd/ubi/ubi.h:221:17: error: dubious one-bit signed bitfield drivers/mtd/ubi/ubi.h:222:18: error: dubious one-bit signed bitfield drivers/mtd/ubi/ubi.h:223:16: error: dubious one-bit signed bitfield drivers/mtd/ubi/ubi.h:224:20: error: dubious one-bit signed bitfield Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Cc: Artem Bityutskiy <dedekind@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix error messageArtem Bityutskiy2008-03-041-2/+2
| | | | | | | Make it print "UBI error: cannot attach mtd4" instead of "UBI error: cannot attach 4" Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: silence warningS.Çağlar Onur2008-03-041-1/+3
| | | | | | | | drivers/mtd/ubi/vmt.c: In function `ubi_create_volume': drivers/mtd/ubi/vmt.c:379: warning: statement with no effect Signed-off-by: S.Çağlar Onur <caglar@pardus.org.tr> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: do not flush queue on each vtbl changeArtem Bityutskiy2008-02-011-1/+1
| | | | | | | | This is just not necessary. We re-write whole layout copy, so the old contents cannot show up again sice scan process will drop it. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: implement atomic LEB change ioctlArtem Bityutskiy2008-01-253-28/+183
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: handle zero-length caseArtem Bityutskiy2008-01-251-0/+11
| | | | | | | ubi_eba_atomic_leb_change() has to just map the LEB to a free PEB if data length is zero. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: simplify internal interfacesArtem Bityutskiy2008-01-253-36/+36
| | | | | | | Instead of passing vol_id to all functions and then find struct ubi_volume, pass struct ubi_volume pointer. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: do not change file pointer while updatingArtem Bityutskiy2008-01-252-4/+1Star
| | | | | | | Since we do not change semantics of seek(), changing the file pointer while updating does not make much sense. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add layout volume informationArtem Bityutskiy2008-01-253-7/+7
| | | | | | | | Add more information about layout volume to make userspace tools use the macros instead of constants. Also rename UBI_LAYOUT_VOL_ID to make it consistent with other macros. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix warningsArtem Bityutskiy2008-01-252-2/+2
| | | | | | | | | | | | | | Old gcc complains: CC drivers/mtd/ubi/wl.o drivers/mtd/ubi/wl.c: In function 'wear_leveling_worker': drivers/mtd/ubi/wl.c:746: warning: 'pe' may be used uninitialized in this function CC drivers/mtd/ubi/scan.o drivers/mtd/ubi/scan.c: In function 'ubi_scan': drivers/mtd/ubi/scan.c:772: warning: 'ec' may be used uninitialized in this function drivers/mtd/ubi/scan.c:772: note: 'ec' was declared here Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add sanity checkArtem Bityutskiy2008-01-251-1/+6
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>