Artem Bityutskiy [Sat, 23 May 2009 10:44:09 +0000 (13:44 +0300)]
UBI: fix race condition
This patch fixes a minor problem where we may fail to wake
upe the UBI background thread. This is not fatal at all,
it may just result at sligtly worse performace for a short
period of time, just because the thread will be woken up
when real I/O on the UBI starts.
Anywey, the issue is the race condition between
'ubi_attach_mtd_dev()' and 'ubi_thread()'. If we do not
serialize them, the 'wake_up_process()' call may be done
before 'ubi_thread()' went seep, but after it checked
'ubi->thread_enabled'.
This issue was spotted by Shin Hong <hongshin@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 13 May 2009 14:05:11 +0000 (17:05 +0300)]
UBI: minor serialization fix
The @vol->upd_marker should be protected by the @ubi->device_mutex,
otherwise 'paranoid_check_volume()' complains sometimes because
vol->upd_marker is 1 while vtbl_rec->upd_marker is 0.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 13 May 2009 11:05:24 +0000 (14:05 +0300)]
UBI: do not panic if volume check fails
If a volume paranoid check fails, do not return an error
code to the caller, but just print error messages and go
forward. The primary reason for this is that it is difficult
to recover and cancel the operation at that stage.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 12 May 2009 17:29:15 +0000 (20:29 +0300)]
UBI: add dump_stack in checking code
I am experiencing an error in 'paranoid_check_volume()'. Add
dump_stack() there to make it easier to identify the reasons
of the error.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 12 May 2009 12:43:44 +0000 (15:43 +0300)]
UBI: fix races in I/O debugging checks
When paranoid checs are enabled, the 'io_paral' test from the
'mtd-utils' package fails. The symptoms are:
UBI error: paranoid_check_all_ff: flash region at PEB 3973:512, length 15872 does not contain all 0xFF bytes
UBI error: paranoid_check_all_ff: paranoid check failed for PEB 3973
UBI: hex dump of the 512-16384 region
It turned out to be a bug in the checking function. Suppose there
are 2 tasks - A and B. Task A is the wear-levelling working
('wear_leveling_worker()'). It is reading the VID header to find
which LEB this PEB belongs to. Say, task A is reading header
of PEB X. Suppose PEB X is unmapped, and has no VID header.
Task B is trying to write to PEB X.
Task A: in 'ubi_io_read_vid_hdr()': reads the VID header from PEB X.
The read data contain all 0xFF bytes.
Task B: writes VID header and some data to PEB X
Task A: assumes PEB X is empty, calls 'paranoid_check_all_ff()', which
fails.
The solution for this problem is to make 'paranoid_check_all_ff()'
re-read the VID header, re-check it, and only if it is not there,
check the rest. This now implemented by the 'paranoid_check_empty()'
function.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 12 May 2009 12:10:03 +0000 (15:10 +0300)]
UBI: small debugging code optimization
The @ubi->dbg_peb_buf is needed only when paranoid checks are
enabled, not when debugging in general is enabled.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 7 May 2009 15:24:14 +0000 (18:24 +0300)]
UBI: improve debugging messages
Various minor improvements to the debugging messages which
I found useful while hunting problems.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 7 May 2009 08:46:49 +0000 (11:46 +0300)]
UBI: re-name volumes_mutex to device_mutex
The mutex essencially protects the entire UBI device, so the
old @volumes_mutex name is a little misleading.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 7 May 2009 08:25:54 +0000 (11:25 +0300)]
UBI: remove redundant mutex
The @mult_mutex does not serve any purpose. We already have
@volumes_mutex and it is enough. The @volume mutex is pushed
down to the 'ubi_rename_volumes()', because we want first
to open all volumes in the exclusive mode, and then lock the
mutex, just like all other ioctl's (remove, re-size, etc) do.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 25 May 2009 16:23:04 +0000 (19:23 +0300)]
UBIFS: use anonymous device
UBIFS has erroneuosly set 'sb->s_dev' to the UBI volume
character device major/minor. This may lead to clashes
if there is another FS mounted to a block device with
the same major/minor numbers. User-space programs which
use 'stat->st_dev' may get confused because of this.
This problem was found by Al Viro. He also pointed the
way to fix the problem - use 'set_anon_super()' and
'kill_anon_super()' VFS helpers.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Corentin Chary [Mon, 25 May 2009 06:49:10 +0000 (08:49 +0200)]
UBIFS: return proper error code if the compr is not present
If the compressor is not present, mount_ubifs need
to return an error code. This way ubifs_fill_super
will stop and handle the error.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Hunter Adrian [Thu, 14 May 2009 04:32:30 +0000 (06:32 +0200)]
UBIFS: return error if link and unlink race
Consider a scenario when 'vfs_link(dirA/fileA)' and
'vfs_unlink(dirA/fileA, dirB/fileB)' race. 'vfs_link()' does not
lock 'dirA->i_mutex', so this is possible. Both of the functions
lock 'fileA->i_mutex' though. Suppose 'vfs_unlink()' wins, and takes
'fileA->i_mutex' mutex first. Suppose 'fileA->i_nlink' is 1. In this
case 'ubifs_unlink()' will drop the last reference, and put 'inodeA'
to the list of orphans. After this, 'vfs_link()' will link
'dirB/fileB' to 'inodeA'. Thir is a problem because, for example,
the subsequent 'vfs_unlink(dirB/fileB)' will add the same inode
to the list of orphans.
This problem was reported by J. R. Okajima <hooanon05@yahoo.co.jp>
[Artem: add more comments, amended commit message]
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Wed, 8 Apr 2009 12:07:57 +0000 (14:07 +0200)]
UBIFS: reset no_space flag after inode deletion
When UBIFS runs out of space it spends a lot of time trying to
find more space before returning ENOSPC. As there is no point
repeating that unless something has changed, UBIFS has an
optimization to record that the file system is 100% full and not
try to find space. That flag was not being reset when a pending
deletion was finally done.
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Reviewed-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Fri, 20 Mar 2009 10:09:04 +0000 (11:09 +0100)]
UBIFS: fix recovery bug
UBIFS did not recovery in a situation in which it could
have. The relevant function assumed there could not be
more nodes in an eraseblock after a corrupted node, but
in fact the last (NAND) page written might contain anything.
The correct approach is to check for empty space (0xFF bytes)
from then on.
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Artem Bityutskiy [Thu, 26 Mar 2009 10:51:21 +0000 (12:51 +0200)]
UBIFS: add R/O compatibility
Now UBIFS is supported by u-boot. If we ever decide to change the
media format, then people will have to upgrade their u-boots to
mount new format images. However, very often it is possible to
preserve R/O forward-compatibility, even though the write
forward-compatibility is not preserved.
This patch introduces a new super-block field which stores the
R/O compatibility version.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Acked-by: Adrian Hunter <Adrian.Hunter@nokia.com>
Hunter Adrian [Wed, 18 Mar 2009 11:29:39 +0000 (12:29 +0100)]
UBIFS: fix compiler warnings
fs/ubifs/super.c: In function ‘ubifs_show_options’:
fs/ubifs/super.c:425: warning: format not a string literal and no format arguments
fs/ubifs/super.c: In function ‘mount_ubifs’:
fs/ubifs/super.c:1204: warning: format not a string literal and no format arguments
fs/ubifs/super.c: In function ‘ubifs_remount_rw’:
fs/ubifs/super.c:1557: warning: format not a string literal and no format arguments
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 8 Mar 2009 13:13:00 +0000 (15:13 +0200)]
UBIFS: fully sort GCed nodes
The 'joinup()' function cannot deal with situations when nodes
go in reverse order - it just leaves them in this order. This
patch implement full nodes sorting using n*log(n) algorithm.
It sorts data nodes for bulk-read, and direntry nodes for
readdir().
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 20 Mar 2009 17:11:12 +0000 (19:11 +0200)]
UBIFS: fix commentaries
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 16 Mar 2009 07:56:57 +0000 (09:56 +0200)]
UBIFS: introduce a helpful variable
This patch introduces a helpful @c->idx_leb_size variable.
The patch also fixes some spelling issues and makes comments
use "LEB" instead of "eraseblock", which is more correct.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 16 Mar 2009 07:42:03 +0000 (09:42 +0200)]
UBIFS: use KERN_CONT
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sat, 14 Mar 2009 14:35:27 +0000 (16:35 +0200)]
UBIFS: fix lprops committing bug
When writing lprop nodes, do not forget to set @from to 0 when
switching the LEB. This fixes the following bug:
UBIFS error (pid 27768): ubifs_leb_write: writing -15456 bytes at 16:15880, error -22
UBIFS error (pid 27768): do_commit: commit failed, error -22
UBIFS warning (pid 27768): ubifs_ro_mode: switched to read-only mode, error -22
Pid: 27768, comm: freespace Not tainted 2.6.29-rc4-ubifs-2.6 #43
Call Trace:
[<
ffffffffa00c46d6>] ubifs_ro_mode+0x54/0x56 [ubifs]
[<
ffffffffa00cfa16>] do_commit+0x4f5/0x50a [ubifs]
[<
ffffffffa00cfae7>] ubifs_run_commit+0xbc/0xdb [ubifs]
[<
ffffffffa00d42b9>] ubifs_budget_space+0x742/0x9ed [ubifs]
[<
ffffffff812daf45>] ? __mutex_lock_common+0x361/0x3ae
[<
ffffffffa00bc437>] ? ubifs_write_begin+0x18d/0x44c [ubifs]
[<
ffffffffa00bc5cb>] ubifs_write_begin+0x321/0x44c [ubifs]
[<
ffffffff8106222b>] ? trace_hardirqs_on_caller+0x1f/0x14d
[<
ffffffff81097ce2>] generic_file_buffered_write+0x12f/0x2d9
[<
ffffffff8109828d>] __generic_file_aio_write_nolock+0x261/0x295
[<
ffffffff81098aff>] generic_file_aio_write+0x69/0xc5
[<
ffffffffa00bb914>] ubifs_aio_write+0x14c/0x19e [ubifs]
[<
ffffffff810c8f42>] do_sync_write+0xe7/0x12d
[<
ffffffff81055378>] ? autoremove_wake_function+0x0/0x38
[<
ffffffff81149edc>] ? security_file_permission+0x11/0x13
[<
ffffffff810c9827>] vfs_write+0xab/0x105
[<
ffffffff810c9945>] sys_write+0x47/0x6f
[<
ffffffff8100c35b>] system_call_fastpath+0x16/0x1b
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 15 Mar 2009 15:20:22 +0000 (17:20 +0200)]
UBIFS: fix bogus assertion
Empty journal head LEBs are accounted as taken empty as well, so
the GC LEB does not have to be the only taken empty LEB when
nounting/remounting.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Mon, 23 Feb 2009 10:47:25 +0000 (12:47 +0200)]
UBIFS: fix bug where page is marked uptodate when out of space
UBIFS fast path in write_begin may mark a page up to date
and then discover that there may not be enough space to do
the write, and so fall back to a slow path. The slow path
tries harder, but may still find no space - leaving the page
marked up to date, when it is not. This patch ensures that
the page is marked not up to date in that case.
The bug that this patch fixes becomes evident when the write
is into a hole (sparse file) or is at the end of the file
and a subsequent read is off the end of the file. In both
cases, the file system should return zeros but was instead
returning the page that had not been written because the
file system was out of space.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sat, 7 Mar 2009 18:53:41 +0000 (20:53 +0200)]
UBIFS: amend key_hash return value
... which should be uint32_t, not int.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 3 Mar 2009 17:22:53 +0000 (19:22 +0200)]
UBIFS: improve find function interface
Make 'ubifs_find_free_space()' return offset where free space starts,
rather than the amount of free space. This is just more appropriat
for its caller.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Eric Sesterhenn [Fri, 13 Feb 2009 08:13:11 +0000 (09:13 +0100)]
UBIFS: list usage cleanup
Trivial cleanup, list_del(); list_add{,_tail}() is equivalent
to list_move{,_tail}(). Semantic patch for coccinelle can be
found at www.cccmz.de/~snakebyte/list_move_tail.spatch
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Thu, 5 Feb 2009 11:08:11 +0000 (13:08 +0200)]
UBIFS: fix dbg_chk_lpt_sz()
The debugging function dbg_chk_lpt_sz() was not working
correctly for small min_io_unit size e.g. NOR flash.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Corentin Chary [Thu, 5 Feb 2009 21:25:52 +0000 (22:25 +0100)]
UBI: add fsync capability
Now, we can call fsync() on an UBI volume.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sidney Amani [Tue, 27 Jan 2009 09:11:46 +0000 (10:11 +0100)]
UBI: allow direct user-space I/O
Introduce a new ioctl UBI_IOCSETPROP to set properties
on a volume. Also add the first property:
UBI_PROP_DIRECT_WRITE, this property is used to set the
ability to use direct writes in userspace
Signed-off-by: Sidney Amani <seed@uffs.org>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 29 Jan 2009 14:34:30 +0000 (16:34 +0200)]
UBIFS: remove fast unmounting
This UBIFS feature has never worked properly, and it was a mistake
to add it because we simply have no use-cases. So, lets still accept
the fast_unmount mount option, but ignore it. This does not change
much, because UBIFS commit in sync_fs anyway, and sync_fs is called
while unmounting.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 29 Jan 2009 14:22:54 +0000 (16:22 +0200)]
UBIFS: return sensible error codes
When mounting/re-mounting, UBIFS returns EINVAL even if the ENOSPC
or EROFS codes are are much better, just because we have not found
references to ENOSPC/EROFS in mount (2) man pages. This patch
changes this behaviour and makes UBIFS return real error code,
because:
1. It is just less confusing and more logical
2. mount is not described in SuSv3, so it seems to be not really
well-standartized
3. we do not cover all cases, and any random undocumented in man
pages error code may be returned anyway
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Thu, 29 Jan 2009 10:59:33 +0000 (12:59 +0200)]
UBIFS: remount ro fixes
- preserve the idx_gc list - it will be needed in the same
state, should UBIFS be remounted rw again
- prevent remounting ro if we have switched to read only
mode (due to a fatal error)
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Thu, 29 Jan 2009 09:53:51 +0000 (11:53 +0200)]
UBIFS: spelling fix 'date' -> 'data'
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Thu, 29 Jan 2009 09:17:24 +0000 (11:17 +0200)]
UBIFS: sync wbufs after syncing inodes and pages
All writes go through wbufs so they must be sync'd
after syncing inodes and pages.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Tue, 27 Jan 2009 13:22:54 +0000 (15:22 +0200)]
UBIFS: fix LPT out-of-space bug (again)
The function to traverse and dirty the LPT was still not
dirtying all nodes, with the result that the LPT could
run out of space.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 27 Jan 2009 14:12:31 +0000 (16:12 +0200)]
UBIFS: fix no_chk_data_crc
When data CRC checking is disabled, UBIFS returns incorrect return
code from the 'try_read_node()' function (0 instead of 1, which means
CRC error), which make the caller re-read the data node again, but using
a different code patch, so the second read is fine. Thus, we read the
same node twice. And the result of this is that UBIFS is slower
with no_chk_data_crc option than it is with chk_data_crc option.
This patches fixes the problem.
Reported-by: Reuben Dowle <Reuben.Dowle@navico.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 26 Jan 2009 14:12:20 +0000 (16:12 +0200)]
UBIFS: fix assertions
I introduce wrong assertions in one of the previous commits, this
patch fixes them.
Also, initialize debugfs after the debugging check. This is a little
nicer because we want the FS data to be accessible to external users
after everything has been initialized.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 26 Jan 2009 11:20:32 +0000 (13:20 +0200)]
UBI: remove lock_kernel
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Adrian Hunter [Mon, 26 Jan 2009 08:55:40 +0000 (10:55 +0200)]
UBIFS: ensure orphan area head is initialized
When mounting read-only the orphan area head is
not initialized. It must be initialized when
remounting read/write, but it was not. This patch
fixes that.
[Artem: sorry, added comment tweaking noise]
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 23 Jan 2009 16:23:03 +0000 (18:23 +0200)]
UBIFS: always clean up GC LEB space
When we mount UBIFS, GC LEB may contain out-of-date information,
and UBIFS should update lprops and set free space for thei LEB.
Currently UBIFS does this only if mounted R/W. But for R/O mount
we have to do the same, because otherwise we will have incorrect
FS free space reported to user-space.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 23 Jan 2009 12:54:59 +0000 (14:54 +0200)]
UBIFS: add re-mount debugging checks
We observe space corrupted accounting when re-mounting. So add some
debbugging checks to catch problems like this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 23 Jan 2009 12:17:36 +0000 (14:17 +0200)]
UBIFS: fix LEB list freeing
When freeing the c->idx_lebs list, we have to release the LEBs as well,
because we might be called from mount to read-only mode code. Otherwise
the LEBs stay taken forever, which may cause problems when we re-mount
back ro RW mode.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 20 Jan 2009 14:46:02 +0000 (16:46 +0200)]
UBIFS: simplify locking
This patch simplifies lock_[23]_inodes functions. We do not have
to care about locking order, because UBIFS does this for @i_mutex
and this is enough. Thanks to Al Viro for suggesting this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 19 Jan 2009 17:57:27 +0000 (19:57 +0200)]
UBIFS: document dark_wm and dead_wm better
Just add more commentaries. Also some commentary fixes for
lprops flags.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 6 Jan 2009 17:54:02 +0000 (19:54 +0200)]
UBIFS: do not treat all data as short term
UBIFS wrongly tells UBI that all data is short term. Use proper
hints instead. Thanks to Xiaochuan-Xu for noticing this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 15 Jan 2009 15:43:23 +0000 (17:43 +0200)]
UBIFS: constify operations
Mark super, file, and inode operation structcutes with 'const'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 9 Jan 2009 19:02:37 +0000 (21:02 +0200)]
UBIFS: do not commit twice
VFS calls '->sync_fs()' twice - first time with @wait = 0, second
time with @wait = 1. As a result, we may commit and synchronize
write-buffers twice. Avoid doing this by returning immediatelly if
@wait = 0.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 20 Jan 2009 16:04:09 +0000 (18:04 +0200)]
UBI: fix resource de-allocation
GregKH asked to fix UBI which has fake device release method. Indeed,
we have to free UBI device description object from the release method,
because otherwise we'll oops is someone opens a UBI device sysfs file,
then the device is removed, and he reads the file. With this fix, he
will get -ENODEV instead of an oops.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 20 Jan 2009 15:48:02 +0000 (17:48 +0200)]
UBI: remove unused variable
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 16 Jan 2009 17:08:43 +0000 (19:08 +0200)]
UBI: use nicer 64-bit math
Get rid of 'do_div()' and use more user-friendly primitives from
'linux/math64.h'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 16 Jan 2009 16:06:55 +0000 (18:06 +0200)]
UBI: add ioctl compatibility
UBI ioctl's do not work when running 64-bit kernel and 32-bit
user-land. Fix this by adding the compat_ioctl method.
Also, UBI serializes all ioctls, so more than one ioctl at a time
is not a problem. Amd UBI does not seem to depend on anything else,
so use unlocked_ioctl instead of ioctl (no BKL needed).
Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Jan Engelhardt [Sun, 11 Jan 2009 22:55:39 +0000 (23:55 +0100)]
UBI: constify file operations
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 16 Jan 2009 16:03:22 +0000 (18:03 +0200)]
UBI: allow all ioctls
Some ioctl's in UBI are enabled only when debugging is switched
on. There is not particular reason for this, just noone needed
them. However, some people need the now for their user-space
development. Thus, allow these ioctl's even if UBI debugging
is disabled.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 16 Jan 2009 16:02:08 +0000 (18:02 +0200)]
UBI: remove unnecessry header inclusion
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 7 Jan 2009 14:10:58 +0000 (16:10 +0200)]
UBI: improve ioctl commentaries
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Corentin Chary [Mon, 5 Jan 2009 13:48:59 +0000 (14:48 +0100)]
UBI: add ioctl for is_mapped operation
This patch adds ioctl to check if an LEB is mapped or not (as a
debugging option so far).
[Re-named ioctl to make it look the same as the other one and made
some minor stylistic changes. Artem Bityutskiy.]
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Corentin Chary [Mon, 5 Jan 2009 13:46:19 +0000 (14:46 +0100)]
UBI: add ioctl for unmap operation
This patch adds ioctl for the LEB unmap operation (as a debugging
option so far).
[Re-named ioctl to make it look the same as the other one and made
some minor stylistic changes. Artem Bityutskiy.]
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Corentin Chary [Mon, 5 Jan 2009 13:44:11 +0000 (14:44 +0100)]
UBI: add ioctl for map operation
This patch adds ioctl for the LEB map operation (as a debugging
option so far).
[Re-named ioctl to make it look the same as the other one and made
some minor stylistic changes. Artem Bityutskiy.]
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 30 Dec 2008 16:37:45 +0000 (18:37 +0200)]
UBIFS: add more useful debugging prints
Print node sizes and maximum node sizes.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 30 Dec 2008 15:58:42 +0000 (17:58 +0200)]
UBIFS: print debugging messages properly
We cannot use ubifs_err() macro with DBGKEY() and DBGKEY1(),
because this is racy and holding dbg_lock is needed. Use
dbg_err() instead, which does have the lock held.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 30 Dec 2008 15:44:02 +0000 (17:44 +0200)]
UBIFS: fix numerous spelling mistakes
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 30 Dec 2008 14:23:34 +0000 (16:23 +0200)]
UBIFS: allow mounting when short of space
It is fine if there is not free space - we should still allow mounting
this FS. This patch relaxes the free space requirements and adds info
dumps.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 23 Dec 2008 12:39:14 +0000 (14:39 +0200)]
UBIFS: fix writing uncompressed files
UBIFS does not disable compression if ui->flags is non-zero, e.g.
if the file has "sync" flag. This is because of the typo which
is fixed by this patch. The patch also adds a couple of useful
debugging prints.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 09:34:26 +0000 (11:34 +0200)]
UBIFS: fix checkpatch.pl warnings
These are mostly long lines and wrong indentation warning
fixes. But also there are two volatile variables and
checkpatch.pl complains about them:
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
+ volatile int gc_seq;
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
+ volatile int gced_lnum;
Well, we anyway use smp_wmb() for c->gc_seq and c->gced_lnum, so
these 'volatile' modifiers can be just dropped.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 09:00:55 +0000 (11:00 +0200)]
UBIFS: fix sparse warnings
fs/ubifs/compress.c:111:8: warning: incorrect type in argument 5 (different signedness)
fs/ubifs/compress.c:111:8: expected unsigned int *dlen
fs/ubifs/compress.c:111:8: got int *out_len
fs/ubifs/compress.c:175:10: warning: incorrect type in argument 5 (different signedness)
fs/ubifs/compress.c:175:10: expected unsigned int *dlen
fs/ubifs/compress.c:175:10: got int *out_len
Fix this by adding a cast to (unsigned int *). We guarantee that
our lengths are small and no overflow is possible.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 9 Dec 2008 16:04:40 +0000 (11:04 -0500)]
UBIFS: simplify make_free_space
The 'make_free_space()' function was too complex and this patch
simplifies it. It also fixes a bug - the freespace test failed
straight away on UBI volumes with 512 bytes LEB size.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 22 Dec 2008 09:21:03 +0000 (11:21 +0200)]
UBIFS: do not lie about used blocks
Do not force UBIFS return 0 used space when it is empty. It leads
to a situation when creating any file immediately produces tens of
used blocks, which looks very weird. It is better to be honest and
say that some blocks are used even if the FS is empty. And ext2
does the same.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 30 Dec 2008 18:06:49 +0000 (20:06 +0200)]
UBIFS: restore budg_uncommitted_idx
UBIFS stores uncommitted index size in c->budg_uncommitted_idx,
and this affect budgeting calculations. When mounting and
replaying, this variable is not updated, so we may end up
with "over-budgeting". This patch fixes the issue.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 07:11:02 +0000 (09:11 +0200)]
UBIFS: always commit on unmount
UBIFS commits on unmount to make the next mount faster. Currently,
it commits only if there is more than LEB size bytes in the
journal. This is not very good, because journal size may be
large (512KiB). And there may be few deletions in the journal
which do not take much journal space, but which do introduce
a lot of TNC changes and make mount slow.
Thus, jurt remove this condition and always commit.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 06:18:43 +0000 (08:18 +0200)]
UBIFS: use ubi_sync
UBI now has (fake for now, though) synchronization call - use
it.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 06:16:32 +0000 (08:16 +0200)]
UBIFS: always commit in sync_fs
Always run commit in sync_fs, because even if the journal seems
to be almost empty, there may be a deletion which removes a large
file, which affects the index greatly. And because we want
better free space predictions after 'sync_fs()', we have to
commit.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 06:04:17 +0000 (08:04 +0200)]
UBIFS: fix file-system synchronization
Argh. The ->sync_fs call is called _before_ all inodes are flushed.
This means we first sync write buffers and commit, then all
inodes are synced, and we end up with unflushed write buffers!
Fix this by forcing synching all indoes from 'ubifs_sync_fs()'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sat, 27 Dec 2008 17:18:00 +0000 (19:18 +0200)]
UBIFS: fix constants initialization
The c->min_idx_lebs constant depends on c->old_idx_sz, which
is read from the master node. This means that we have to
initialize c->min_idx_lebs only after we have read the master
node.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 19 Dec 2008 14:11:13 +0000 (16:11 +0200)]
UBIFS: avoid unnecessary calculations
Do not calculate min_idx_lebs, because it is available in
c->min_idx_lebs
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Mon, 22 Dec 2008 09:09:04 +0000 (11:09 +0200)]
UBIFS: re-calculate min_idx_size after the commit
When we commit, but before we try to write anything to the flash
media, @c->min_idx_size is inaccurate, because we do not re-calculate
it after the commit. Do not forget to do this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 18 Dec 2008 12:06:51 +0000 (14:06 +0200)]
UBIFS: use nicer 64-bit math
Instead of using do_div(), use better primitives from
linux/math64.h.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 19 Dec 2008 17:26:29 +0000 (19:26 +0200)]
UBIFS: fix available blocks count
Take into account that 2 eraseblocks are never available because
they are reserved for the index. This gives more realistic count
of FS blocks.
To avoid future confusions like this, introduce a constant.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 16 Dec 2008 15:52:35 +0000 (17:52 +0200)]
UBIFS: various comment improvements and fixes
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 12 Dec 2008 16:13:17 +0000 (11:13 -0500)]
UBIFS: improve budgeting dump
Dump available space calculated by budgeting subsystem.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 17 Dec 2008 15:45:14 +0000 (17:45 +0200)]
UBIFS: fix tnc dumping
debugfs tnc dumping was broken because of an obvious typo.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Tue, 9 Dec 2008 16:02:51 +0000 (11:02 -0500)]
UBIFS: use PAGE_CACHE_MASK correctly
It has high bits set, not low bits set as the UBIFS code
assumed.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sun, 28 Dec 2008 10:20:51 +0000 (12:20 +0200)]
UBI: fix checkpatch.pl warnings
Just minor indentation and "over 80 characters" fixes.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Xiaochuan-Xu [Mon, 15 Dec 2008 13:07:41 +0000 (21:07 +0800)]
UBI: simplify PEB protection code
UBI has 2 RB-trees to implement PEB protection, which is too
much for simply prevent PEB from being moved for some time.
This patch implements this using lists. The benefits:
1. No need to allocate protection entry on each PEB get.
2. No need to maintain balanced trees and walk them.
Signed-off-by: Xiaochuan-Xu <xiaochuan-xu@cqu.edu.cn>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Xiaochuan-Xu [Tue, 9 Dec 2008 11:44:12 +0000 (19:44 +0800)]
UBI: prepare for protection tree improvements
This patch modifies @struct ubi_wl_entry and adds union which
contains only one element so far. This is just a preparation
for further changes which will kill the protection tree and
make UBI use a list instead.
Signed-off-by: Xiaochuan-Xu <xiaochuan-xu@cqu.edu.cn>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Stefan Roese [Wed, 10 Dec 2008 09:42:54 +0000 (10:42 +0100)]
UBI: return -ENOMEM upon failing vmalloc
Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon
failing vmalloc().
Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 5 Dec 2008 11:37:02 +0000 (13:37 +0200)]
UBI: handle write errors in WL worker
When a PEB is moved and a write error happens, UBI switches
to R/O mode, which is wrong, because we just copy the data
and may select a different PEB and re-try this. This patch
fixes WL worker's behavior.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 5 Dec 2008 10:42:45 +0000 (12:42 +0200)]
UBI: fix error path
Make sure the resources had not already been freed before
freeing them in the error path of the WL worker function.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 5 Dec 2008 10:23:48 +0000 (12:23 +0200)]
UBI: some code re-structuring
Minor code re-structuring and commentaries fixes to improve readability.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 4 Dec 2008 18:52:44 +0000 (20:52 +0200)]
UBI: fix deadlock
We cannot call 'ubi_wl_get_peb()' with @ubi->buf_mutex locked,
because 'ubi_wl_get_peb()' may force erasure, which, in turn,
may call 'torture_peb()' which also locks the @ubi->buf_mutex
and deadlocks.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Alexey Dobriyan [Thu, 4 Dec 2008 14:04:18 +0000 (17:04 +0300)]
UBIFS: fix section mismatch
This patch fixes the following section mismatch:
WARNING: fs/ubifs/ubifs.o(.init.text+0xec): Section mismatch in reference from the function init_module() to the function .exit.text:ubifs_compressors_exit()
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 12 Nov 2008 08:14:10 +0000 (10:14 +0200)]
UBI: fix warnings when debugging is enabled
The 'ubi_io_read_vid_hdr()' and 'ubi_io_read_ec_hdr()' function
have the 'verbose' argument which controls whether they should
print a warning if the VID/EC header was not found or was corrupted.
Some callers require the headers to be OK, and pass 1. Some allow
a corrupted/not present header, and pass 0.
if (UBI_IO_DEBUG)
verbose = 1;
And UBI_IO_DEBUG is 1 if CONFIG_MTD_UBI_DEBUG_MSG_BLD is true. So in
this case the warning is printed all the time. This confuses people.
Thus, do not print the messages as warnings if UBI_IO_DEBUG is true,
but print them as debugging messages instead.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 31 Oct 2008 15:32:30 +0000 (17:32 +0200)]
UBIFS: introduce LPT dump function
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 31 Oct 2008 10:17:42 +0000 (12:17 +0200)]
UBIFS: dump stack in LPT check functions
It is useful to know how we got to the checking function when
hunting the bugs.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 31 Oct 2008 09:42:18 +0000 (11:42 +0200)]
UBIFS: run debugging checks only if they are enabled
Do not forget to check whether lpt debugging is enabled before
running the check functions. This commit also makes some spelling
fixes.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Thu, 23 Oct 2008 08:49:28 +0000 (11:49 +0300)]
UBIFS: add debugfs support
We need to have a possibility to see various UBIFS variables
and ask UBIFS to dump various information. Debugfs is what
we need.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Fri, 17 Oct 2008 10:31:39 +0000 (13:31 +0300)]
UBIFS: separate debugging fields out
Introduce a new data structure which contains all debugging
stuff inside. This is cleaner than having debugging stuff
directly in 'c'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Kukkonen Mika [Tue, 2 Dec 2008 09:32:49 +0000 (11:32 +0200)]
UBIFS: avoid unnecessary checks
I have a habit of compiling kernel with
EXTRA_CFLAGS="-Wextra -Wno-unused -Wno-sign-compare -Wno-missing-field-initializers"
and so fs/ubifs/key.h give lots (~10) of these every time:
CC fs/ubifs/tnc_misc.o
In file included from fs/ubifs/ubifs.h:1725,
from fs/ubifs/tnc_misc.c:30:
fs/ubifs/key.h: In function 'key_r5_hash':
fs/ubifs/key.h:64: warning: comparison of unsigned expression >= 0 is always true
fs/ubifs/key.h: In function 'key_test_hash':
fs/ubifs/key.h:81: warning: comparison of unsigned expression >= 0 is always true
This patch fixes the warnings.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sat, 1 Nov 2008 12:57:49 +0000 (14:57 +0200)]
UBIFS: introduce compression mount options
It is very handy to be able to change default UBIFS compressor
via mount options. Introduce -o compr=<name> mount option support.
Currently only "none", "lzo" and "zlib" compressors are supported.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Sat, 1 Nov 2008 12:20:50 +0000 (14:20 +0200)]
UBIFS: use bit-fields to store compression type
Save a 4 bytes of RAM per 'struct inode' by stroring inode
compression type in bit-filed, instead of using 'int'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy [Wed, 19 Nov 2008 09:53:15 +0000 (11:53 +0200)]
UBIFS: pre-allocate bulk-read buffer
To avoid memory allocation failure during bulk-read, pre-allocate
a bulk-read buffer, so that if there is only one bulk-reader at
a time, it would just use the pre-allocated buffer and would not
do any memory allocation. However, if there are more than 1 bulk-
reader, then only one reader would use the pre-allocated buffer,
while the other reader would allocate the buffer for itself.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>