summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
Commit message (Collapse)AuthorAgeFilesLines
...
* UBI: get device when opening volumeArtem Bityutskiy2007-12-263-8/+8
| | | | | | | | When a volume is opened, get its kref via get_device() call. And put the reference when closing the volume. With this, we may have a bit saner volume delete. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add some more commentsArtem Bityutskiy2007-12-261-1/+7
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: tweak volumes lockingArtem Bityutskiy2007-12-266-23/+34
| | | | | | | Transform vtbl_mutex to volumes_mutex - this just makes code easier to understand. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: improve internal interfacesArtem Bityutskiy2007-12-2610-72/+68
| | | | | | | | Pass volume description object to the EBA function which makes more sense, and EBA function do not have to find the volume description object by volume ID. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix: dont oops with NULL module parameterArtem Bityutskiy2007-12-261-0/+3
| | | | | | E.g., it oopsed in case of: modprobe ubi mtd = 0 Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove ubi_devices_cntArtem Bityutskiy2007-12-263-21/+27
| | | | | | This global variablea is not really needed, remove it Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: create ubi_wl_entry slab on initializationArtem Bityutskiy2007-12-263-44/+44
| | | | | | | Similarly to ltree_entry_slab, it makes more sense to create and destroy ubi_wl_entry slab on module initialization/exit. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: create ltree_entry slab on initializationArtem Bityutskiy2007-12-263-67/+67
| | | | | | | | Since the ltree_entry slab cache is a global entity, which is used by all UBI devices, it is more logical to create it on module initialization time and destro on module exit time. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: improve error messagesArtem Bityutskiy2007-12-263-8/+19
| | | | | | | Always print error code with error messages, sometimes it is extremely helpful info. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove redundant fieldArtem Bityutskiy2007-12-265-16/+16
| | | | | | | Remove redundant ubi->major field - we have it in ubi->cdev.dev already. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: minor tidy-upsArtem Bityutskiy2007-12-261-3/+4
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: silence a warningJesper Juhl2007-12-261-2/+3
| | | | | | | | | | | | | | | | | This patch silences the following warning : drivers/mtd/ubi/vmt.c:73: warning: 'ret' may be used uninitialized in this function gcc can't see that we always initialize ret in all situations where it is actually used. The one case where it's not initialized is when we BUG(), but gcc doesn't know that we won't then continue and use an uninitialized 'ret'. This patch results in code that does exactely the same as before, but it also makes gcc shut up, so we generate one less line of warning noise. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: add ubi_leb_map interfaceArtem Bityutskiy2007-12-262-5/+53
| | | | | | | | | | | | | | The idea of this interface belongs to Adrian Hunter. The interface is extremely useful when one has to have a guarantee that an LEB will contain all 0xFFs even in case of an unclean reboot. UBI does have an 'ubi_leb_erase()' call which may do this, but it is stupid and ineffecient, because it flushes whole queue. I should be re-worked to just be a pair of unmap, map calls. The user of the interfaci is UBIFS at the moment. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix: allocate mandatory EBs firstArtem Bityutskiy2007-12-261-9/+9
| | | | | | | | | First allocate the necessary eraseblocks, then the optional ones. Otherwise it allocates all PEBs for bad EB handling, and fails on then following EBA LEB allocation. Reported-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix error code in ubi_io_read()Artem Bityutskiy2007-12-261-0/+10
| | | | | | | | | | | | | | | | | | | | When NAND detects an ECC error, it returns -EBADMSG. It does not stop reading requested data if one page has an ECC error, it keeps going and reads all the requested data. If it fails to read all the data, it does not return -EBADMSG, but returns the error code which reflects the reason of the failure. But some drivers may have bugs (e.g., OneNAND had) and stop reading after the first ECC error, so it returns -EBADMSG. In turn, UBI propagates this up to the caller. The caller will treat this as "all the requested data was read, but there was an ECC error". So we change the error code to -EIO if it is -EBADMSG and the read length is less then the requested length. We also add an assertion, so if UBI debugging is enabled, UBI will bug. Pointed-to-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* Use helpers to obtain task pid in printksPavel Emelyanov2007-10-191-1/+1
| | | | | | | | | | | | | | | | The task_struct->pid member is going to be deprecated, so start using the helpers (task_pid_nr/task_pid_vnr/task_pid_nr_ns) in the kernel. The first thing to start with is the pid, printed to dmesg - in this case we may safely use task_pid_nr(). Besides, printks produce more (much more) than a half of all the explicit pid usage. [akpm@linux-foundation.org: git-drm went and changed lots of stuff] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Dave Airlie <airlied@linux.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* Slab API: remove useless ctor parameter and reorder parametersChristoph Lameter2007-10-171-2/+1
| | | | | | | | | | | | | | | | | | | | | Slab constructors currently have a flags parameter that is never used. And the order of the arguments is opposite to other slab functions. The object pointer is placed before the kmem_cache pointer. Convert ctor(void *object, struct kmem_cache *s, unsigned long flags) to ctor(struct kmem_cache *s, void *object) throughout the kernel [akpm@linux-foundation.org: coupla fixes] Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* Merge branch 'master' of git://git.infradead.org/~dedekind/ubi-2.6David Woodhouse2007-10-1412-317/+274
|\
| * UBI: return correct error codeArtem Bityutskiy2007-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | Fix the following warning: drivers/mtd/ubi/eba.c: In function 'ubi_eba_init_scan': drivers/mtd/ubi/eba.c:1116: warning: 'err' may be used uninitialized in this function Pointed-to-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: remove useless inlinesArtem Bityutskiy2007-10-141-81/+38
| | | | | | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: fix atomic LEB change problemsArtem Bityutskiy2007-10-142-21/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the UBI device is nearly full, i.e. all LEBs are mapped, we have only one spare LEB left - the one we reserved for WL purposes. Well, I do not count the LEBs which were reserved for bad PEB handling - suppose NOR flash for simplicity. If an "atomic LEB change operation" is run, and the WL unit is moving a LEB, we have no spare LEBs to finish the operation and fail, which is not good. Moreover, if there are 2 or more simultanious "atomic LEB change" requests, only one of them has chances to succeed, the other will fail with -ENOSPC. Not good either. This patch does 2 things: 1. Reserves one PEB for the "atomic LEB change" operation. 2. Serealize the operations so that only on of them may run at a time (by means of a mutex). Pointed-to-by: Brijesh Singh <brijesh.s.singh@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: use byte hexdumpArtem Bityutskiy2007-10-142-3/+3
| | | | | | | | | | | | More handy since word hexdump prints in host endian. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: do not use vmalloc on I/O pathArtem Bityutskiy2007-10-148-112/+119
| | | | | | | | | | | | | | | | | | | | | | Similar reason as in case of the previous patch: it causes deadlocks if a filesystem with writeback support works on top of UBI. So pre-allocate needed buffers when attaching MTD device. We also need mutexes to protect the buffers, but they do not cause much contantion because they are used in recovery, torture, and WL copy routines, which are called seldom. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: allocate memory with GFP_NOFSArtem Bityutskiy2007-10-146-19/+21
| | | | | | | | | | | | | | | | | | | | | | Use GFP_NOFS flag when allocating memory on I/O path, because otherwise we may deadlock the filesystem which works on top of us. We observed the deadlocks with UBIFS. Example: VFS->FS lock a lock->UBI->kmalloc()->VFS writeback->FS locks the same lock again. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: use linux print_hex_dump(), not home-grown oneArtem Bityutskiy2007-10-143-38/+3
| | | | | | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: don't use array index before testing if it is negativeJesper Juhl2007-10-141-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | I can't find anything guaranteeing that 'ubi_num' cannot be <0 in drivers/mtd/ubi/kapi.c::ubi_open_volume(), and in fact the code even tests for that and errors out if so. Unfortunately the test for "ubi_num < 0" happens after we've already used 'ubi_num' as an array index - bad thing to do if it is negative. This patch moves the test earlier in the function and then moves the indexing using that variable after the check. A bit safer :-) Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: add more printsArtem Bityutskiy2007-10-142-1/+5
| | | | | | | | | | | | | | I hit those situations and found out lack of print messages. Add more prints when erase problems occur. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: fix sparse warningsArtem Bityutskiy2007-10-142-41/+45
| | | | | | | | | | | | | | Fix "symbol shadows an earlier one" warnings. Although they are harmless but it does not hurt to fix them and make sparse happy. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
| * UBI: fix leak in ubi_scan_erase_pebFlorin Malita2007-10-141-4/+4
| | | | | | | | | | | | | | | | | | | | Coverity (1769) found the following problem: if the erase counter overflow check triggers, ec_hdr is leaked. Moving the allocation after the overflow check should take care of it. Signed-off-by: Florin Malita <fmalita@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* | [UBI] drivers/mtd/ubi/scan.c: kmalloc + memset conversion to kzallocMariusz Kozlowski2007-08-011-9/+8
|/ | | | | | | | To be able to convert kmalloc + memset(..., 1, ...) to kzalloc this patch reverses the logic around 'buf'. Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* mm: Remove slab destructors from kmem_cache_create().Paul Mundt2007-07-202-2/+2
| | | | | | | | | | | | | | Slab destructors were no longer supported after Christoph's c59def9f222d44bb7e2f0a559f2906191a0862d7 change. They've been BUGs for both slab and slub, and slob never supported them either. This rips out support for the dtor pointer from kmem_cache_create() completely and fixes up every single callsite in the kernel (there were about 224, not including the slab allocator definitions themselves, or the documentation references). Signed-off-by: Paul Mundt <lethal@linux-sh.org>
* UBI: fix compile warningPaul Mundt2007-07-181-0/+1
| | | | | | | | | | | | cdev.c whines in current git: drivers/mtd/ubi/cdev.c: In function `major_to_device': drivers/mtd/ubi/cdev.c:67: warning: control reaches end of non-void function Shut it up. Signed-off-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix error handling in erase workerArtem Bityutskiy2007-07-181-41/+48
| | | | | | | | | Do not switch to read-only mode in case of -EINTR and some other obvious cases. Switch to RO mode only when we do not know what is the error. Reported-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix commentsArtem Bityutskiy2007-07-181-3/+3
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: remove unneeded error checksArtem Bityutskiy2007-07-182-13/+2
| | | | | | Pointed to by viro. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: cleanup usage of try_module_getFernando Luis Vázquez Cao2007-07-181-5/+0
| | | | | | | | | | | | The use of try_module_get(THIS_MODULE) in ubi_get_device_info does not offer real protection against unexpected driver unloads, since we could be preempted before try_modules_get gets executed. It is the caller who should manipulate the refcounts. Besides, ubi_get_device_info is an exported symbol which guarantees protection when accessed through symbol_get. Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix overflow bugVinit Agnihotri2007-07-182-6/+11
| | | | | | | | | | | | | | | | | | | | I was experiencing overflows in multiplications for volume->used_bytes in vmt.c & vtbl.c, while creating & resizing large volumes. vol->used_bytes is long long however its 2 operands vol->used_ebs & vol->usable_leb_size are int. So their multiplication for larger values causes integer overflows. Typecasting them solves the problem. My machine & flash details: 64Bit dual-core AMD opteron, 1 GB RAM, linux 2.6.18.3. mtd size = 6GB, volume size= 5GB, peb_size = 4MB. heres patch which does the fix. Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix in max_sqnum calculationArtem Bityutskiy2007-07-181-1/+0
| | | | | | Do not zero max_sqnum after a new volume has been found. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix in sqnum calculationBrijesh Singh2007-07-181-3/+3
| | | | | | | | | | | | | Hi,I came across problem of having two leb with same sequence no.This happens when we continuously write one block again and again and reboot machine before background thread erases those blocks. The problem here was,when we find two blocks with same sequence no,we take the higher one,but we were not updating max seq no,so next block may have the same seqnum. This patch solves this problem. Signed-off-by: Brijesh Singh <brijesh.s.singh@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix signed-unsigned multiplicationBrijesh Singh2007-07-181-1/+1
| | | | | | | | | There is signed multiplication assigned to unsigned ei.addr in io.c. This causes wrong addresses for big multiplication.This patch solves the problem. Signed-off-by: Brijesh Singh <brijesh.s.singh@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix bug in atomic_leb_change()Artem Bityutskiy2007-07-181-1/+1
| | | | | | | atomic_leb_change() is only allowed for dynamic volumes, so set the volume type correctly. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix messageVinit Agnihotri2007-07-181-2/+1
| | | | | | | Increase UBI devices couter after the message, not before. Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix debugging stuffArtem Bityutskiy2007-07-181-4/+16
| | | | | | | Do not check volumes which are currently in use because thay may be in inconsistent state. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix in error pathArtem Bityutskiy2007-07-184-10/+7
| | | | | | | | | When volume creation fails, we have to set ubi->volumes[vol_id] back to NULL. This patch also tweaks some debugging stuff. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: use is_power_of_2()Vignesh Babu2007-07-181-2/+2
| | | | | | | | Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2 Signed-off-by: Vignesh Babu <vignesh.babu@wipro.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: fix freeing ubi->vtbl while unloadingVinit Agnihotri2007-07-181-2/+2
| | | | | | | | ubi->vtbl is allocated using vmalloc() in vtbl.c empty_create_lvol(), but it is freed in build.c with kfree() Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: bugfix in ubi_leb_change()Artem Bityutskiy2007-07-181-5/+7
| | | | | | | Do not call 'ubi_wl_put_peb()' if the LEB was unmapped. Reported-by: Gabor Loki <loki@inf.u-szeged.hu> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: kill homegrown endian macrosChristoph Hellwig2007-07-187-132/+132
| | | | | | | | Kill UBI's homegrown endianess handling and replace it with the standard kernel endianess handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: cleanup ioctl handlingChristoph Hellwig2007-07-181-28/+5
| | | | | | | | - don't do access_ok + get/put user but use the proper macro - remove useless checks Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* UBI: error path bugfixArtem Bityutskiy2007-07-181-1/+0
| | | | | | No need to unlock the lock, this will be done at out_unlock. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
OpenPOWER on IntegriCloud