pandora-kernel.git
16 years agoUBI: add fsync capability
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>
16 years agoUBI: allow direct user-space I/O
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>
16 years agoUBIFS: remove fast unmounting
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>
16 years agoUBIFS: return sensible error codes
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>
16 years agoUBIFS: remount ro fixes
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>
16 years agoUBIFS: spelling fix 'date' -> 'data'
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>
16 years agoUBIFS: sync wbufs after syncing inodes and pages
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>
16 years agoUBIFS: fix LPT out-of-space bug (again)
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>
16 years agoUBIFS: fix no_chk_data_crc
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>
16 years agoUBIFS: fix assertions
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>
16 years agoUBI: remove lock_kernel
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>
16 years agoUBIFS: ensure orphan area head is initialized
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>
16 years agoUBIFS: always clean up GC LEB space
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>
16 years agoUBIFS: add re-mount debugging checks
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>
16 years agoUBIFS: fix LEB list freeing
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>
16 years agoUBIFS: simplify locking
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>
16 years agoUBIFS: document dark_wm and dead_wm better
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>
16 years agoUBIFS: do not treat all data as short term
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>
16 years agoUBIFS: constify operations
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>
16 years agoUBIFS: do not commit twice
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>
16 years agoUBI: fix resource de-allocation
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>
16 years agoUBI: remove unused variable
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>
16 years agoUBI: use nicer 64-bit math
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>
16 years agoUBI: add ioctl compatibility
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>
16 years agoUBI: constify file operations
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>
16 years agoUBI: allow all ioctls
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>
16 years agoUBI: remove unnecessry header inclusion
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>
16 years agoUBI: improve ioctl commentaries
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>
16 years agoUBI: add ioctl for is_mapped operation
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>
16 years agoUBI: add ioctl for unmap operation
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>
16 years agoUBI: add ioctl for map operation
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>
16 years agoUBIFS: add more useful debugging prints
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>
16 years agoUBIFS: print debugging messages properly
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>
16 years agoUBIFS: fix numerous spelling mistakes
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>
16 years agoUBIFS: allow mounting when short of space
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>
16 years agoUBIFS: fix writing uncompressed files
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>
16 years agoUBIFS: fix checkpatch.pl warnings
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>
16 years agoUBIFS: fix sparse warnings
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>
16 years agoUBIFS: simplify make_free_space
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>
16 years agoUBIFS: do not lie about used blocks
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>
16 years agoUBIFS: restore budg_uncommitted_idx
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>
16 years agoUBIFS: always commit on unmount
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>
16 years agoUBIFS: use ubi_sync
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>
16 years agoUBIFS: always commit in sync_fs
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>
16 years agoUBIFS: fix file-system synchronization
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>
16 years agoUBIFS: fix constants initialization
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>
16 years agoUBIFS: avoid unnecessary calculations
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>
16 years agoUBIFS: re-calculate min_idx_size after the commit
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>
16 years agoUBIFS: use nicer 64-bit math
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>
16 years agoUBIFS: fix available blocks count
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>
16 years agoUBIFS: various comment improvements and fixes
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>
16 years agoUBIFS: improve budgeting dump
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>
16 years agoUBIFS: fix tnc dumping
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>
16 years agoUBIFS: use PAGE_CACHE_MASK correctly
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>
16 years agoUBI: fix checkpatch.pl warnings
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>
16 years agoUBI: simplify PEB protection code
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>
16 years agoUBI: prepare for protection tree improvements
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>
16 years agoUBI: return -ENOMEM upon failing vmalloc
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>
16 years agoUBI: handle write errors in WL worker
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>
16 years agoUBI: fix error path
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>
16 years agoUBI: some code re-structuring
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>
16 years agoUBI: fix deadlock
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>
16 years agoUBIFS: fix section mismatch
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>
16 years agoUBI: fix warnings when debugging is enabled
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>
16 years agoUBIFS: introduce LPT dump function
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>
16 years agoUBIFS: dump stack in LPT check functions
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>
16 years agoUBIFS: run debugging checks only if they are enabled
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>
16 years agoUBIFS: add debugfs support
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>
16 years agoUBIFS: separate debugging fields out
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>
16 years agoUBIFS: avoid unnecessary checks
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>
16 years agoUBIFS: introduce compression mount options
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>
16 years agoUBIFS: use bit-fields to store compression type
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>
16 years agoUBIFS: pre-allocate bulk-read buffer
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>
16 years agoUBIFS: do not allocate too much
Artem Bityutskiy [Tue, 18 Nov 2008 18:20:05 +0000 (20:20 +0200)]
UBIFS: do not allocate too much

Bulk-read allocates 128KiB or more using kmalloc. The allocation
starts failing often when the memory gets fragmented. UBIFS still
works fine in this case, because it falls-back to standard
(non-optimized) read method, though. This patch teaches bulk-read
to allocate exactly the amount of memory it needs, instead of
allocating 128KiB every time.

This patch is also a preparation to the further fix where we'll
have a pre-allocated bulk-read buffer as well. For example, now
the @bu object is prepared in 'ubifs_bulk_read()', so we could
path either pre-allocated or allocated information to
'ubifs_do_bulk_read()' later. Or teaching 'ubifs_do_bulk_read()'
not to allocate 'bu->buf' if it is already there.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: do not print scary memory allocation warnings
Artem Bityutskiy [Tue, 18 Nov 2008 16:09:49 +0000 (18:09 +0200)]
UBIFS: do not print scary memory allocation warnings

Bulk-read allocates a lot of memory with 'kmalloc()', and when it
is/gets fragmented 'kmalloc()' fails with a scarry warning. But
because bulk-read is just an optimization, UBIFS keeps working fine.
Supress the warning by passing __GFP_NOWARN option to 'kmalloc()'.

This patch also introduces a macro for the magic 128KiB constant.
This is just neater.

Note, this is not really fixes the problem we had, but just hides
the warnings. The further patches fix the problem.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBI: Don't exit from ubi_thread until kthread_should_stop() is true
Vitaliy Gusev [Wed, 5 Nov 2008 15:27:18 +0000 (18:27 +0300)]
UBI: Don't exit from ubi_thread until kthread_should_stop() is true

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>
16 years agoUBI: fix EBADMSG handling
Zoltan Sogor [Wed, 29 Oct 2008 08:50:02 +0000 (09:50 +0100)]
UBI: fix EBADMSG handling

'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>
16 years agoUBIFS: allow for gaps when dirtying the LPT
Adrian Hunter [Wed, 5 Nov 2008 14:09:04 +0000 (16:09 +0200)]
UBIFS: allow for gaps when dirtying the LPT

The LPT may have gaps in it because initially empty LEBs
are not added by mkfs.ubifs - because it does not know how
many there are.  Then UBIFS allocates empty LEBs in the
reverse order that they are discovered i.e. they are
added to, and removed from, the front of a list.  That
creates a gap in the middle of the LPT.

The function dirtying the LPT tree (for the purpose of
small model garbage collection) assumed that a gap could
only occur at the very end of the LPT and stopped dirtying
prematurely, which in turn resulted in the LPT running
out of space - something that is designed to be impossible.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: slight compression optimization
Artem Bityutskiy [Sun, 26 Oct 2008 14:58:25 +0000 (16:58 +0200)]
UBIFS: slight compression optimization

If data does not compress, it is better to leave it uncompressed
because we'll read it faster then. So do not compress data if we
save less than 64 bytes.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: fix compilation warnings
Artem Bityutskiy [Wed, 29 Oct 2008 10:08:43 +0000 (12:08 +0200)]
UBIFS: fix compilation warnings

We print 'ino_t' type using '%lu' printk() placeholder, but this
results in many warnings when compiling for Alpha platform. Fix
this by adding (unsingned long) casts.

Fixes these warnings:

fs/ubifs/journal.c:693: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/journal.c:1131: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/dir.c:163: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/tnc.c:2680: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/tnc.c:2700: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/replay.c:1066: warning: format '%lu' expects type 'long unsigned int', but argument 7 has type 'ino_t'
fs/ubifs/orphan.c:108: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:135: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:142: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:154: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:159: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:451: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:539: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:612: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:843: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/orphan.c:856: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/recovery.c:1438: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/recovery.c:1443: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/recovery.c:1475: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/recovery.c:1495: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:105: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:105: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:110: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:110: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:114: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:114: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:118: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:118: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'ino_t'
fs/ubifs/debug.c:1591: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1671: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1674: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:1680: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1699: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:1788: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:1821: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:1833: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:1924: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1932: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1938: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1945: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1953: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1960: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1967: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1973: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1988: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'ino_t'
fs/ubifs/debug.c:1991: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'ino_t'
fs/ubifs/debug.c:2009: warning: format '%lu' expects type 'long unsigned int', but argument 2 has type 'ino_t'

Reported-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoMAINTAINERS: change UBI/UBIFS git tree URLs
Artem Bityutskiy [Sat, 25 Oct 2008 15:54:04 +0000 (18:54 +0300)]
MAINTAINERS: change UBI/UBIFS git tree URLs

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: endian handling fixes and annotations
Harvey Harrison [Fri, 24 Oct 2008 17:52:57 +0000 (10:52 -0700)]
UBIFS: endian handling fixes and annotations

Noticed by sparse:
fs/ubifs/file.c:75:2: warning: restricted __le64 degrades to integer
fs/ubifs/file.c:629:4: warning: restricted __le64 degrades to integer
fs/ubifs/dir.c:431:3: warning: restricted __le64 degrades to integer

This should be checked to ensure the ubifs_assert is working as
intended, I've done the suggested annotation in this patch.

fs/ubifs/sb.c:298:6: warning: incorrect type in assignment (different base types)
fs/ubifs/sb.c:298:6:    expected int [signed] [assigned] tmp
fs/ubifs/sb.c:298:6:    got restricted __le64 [usertype] <noident>
fs/ubifs/sb.c:299:19: warning: incorrect type in assignment (different base types)
fs/ubifs/sb.c:299:19:    expected restricted __le64 [usertype] atime_sec
fs/ubifs/sb.c:299:19:    got int [signed] [assigned] tmp
fs/ubifs/sb.c:300:19: warning: incorrect type in assignment (different base types)
fs/ubifs/sb.c:300:19:    expected restricted __le64 [usertype] ctime_sec
fs/ubifs/sb.c:300:19:    got int [signed] [assigned] tmp
fs/ubifs/sb.c:301:19: warning: incorrect type in assignment (different base types)
fs/ubifs/sb.c:301:19:    expected restricted __le64 [usertype] mtime_sec
fs/ubifs/sb.c:301:19:    got int [signed] [assigned] tmp

This looks like a bugfix as your tmp was a u32 so there was truncation in
the atime, mtime, ctime value, probably not intentional, add a tmp_le64
and use it here.

fs/ubifs/key.h:348:9: warning: cast to restricted __le32
fs/ubifs/key.h:348:9: warning: cast to restricted __le32
fs/ubifs/key.h:419:9: warning: cast to restricted __le32

Read from the annotated union member instead.

fs/ubifs/recovery.c:175:13: warning: incorrect type in assignment (different base types)
fs/ubifs/recovery.c:175:13:    expected unsigned int [unsigned] [usertype] save_flags
fs/ubifs/recovery.c:175:13:    got restricted __le32 [usertype] flags
fs/ubifs/recovery.c:186:13: warning: incorrect type in assignment (different base types)
fs/ubifs/recovery.c:186:13:    expected restricted __le32 [usertype] flags
fs/ubifs/recovery.c:186:13:    got unsigned int [unsigned] [usertype] save_flags

Do byteshifting at compile time of the flag value.  Annotate the saved_flags
as le32.

fs/ubifs/debug.c:368:10: warning: cast to restricted __le32
fs/ubifs/debug.c:368:10: warning: cast from restricted __le64

Should be checked if the truncation was intentional, I've changed the
printk to print the full width.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: remove printk
Artem Bityutskiy [Tue, 21 Oct 2008 09:56:31 +0000 (12:56 +0300)]
UBIFS: remove printk

Remove the "UBIFS background thread ubifs_bgd0_0 started" message.
We kill the background thread when we switch to R/O mode, and
start it again whan we switch to R/W mode. OLPC is doing this
many times during boot, and we see this message many times as
well, which is irritating. So just kill the message.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: fix ubifs_compress commentary
Geert Uytterhoeven [Fri, 17 Oct 2008 14:16:10 +0000 (16:16 +0200)]
UBIFS: fix ubifs_compress commentary

Update the comment for ubifs_compress(), which incorrectly states that it
returnsa success/failure indicator.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: amend printk
Artem Bityutskiy [Fri, 17 Oct 2008 15:49:23 +0000 (18:49 +0300)]
UBIFS: amend printk

It is better to print "Reserved for root" than
"Reserved pool size", because it is more obvious for users
what this means.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: do not read unnecessary bytes when unpacking bits
Adrian Hunter [Fri, 17 Oct 2008 13:52:10 +0000 (16:52 +0300)]
UBIFS: do not read unnecessary bytes when unpacking bits

Fixes the following Oops:

BUG: unable to handle kernel paging request at f8d24000
IP: [<f8ff0657>] :ubifs:ubifs_unpack_bits+0xcd/0x231
*pde = 34333067 *pte = 00000000
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: deflate zlib_deflate lzo lzo_decompress lzo_compress
ubifs ubi nandsim nand nand_ids nand_ecc mtd nfsd lockd sunrpc exportfs
[last unloaded: nand_ecc]

Pid: 7450, comm: sync Not tainted (2.6.27-rc8-ubifs-2.6 #27)
EIP: 0060:[<f8ff0657>] EFLAGS: 00010206 CPU: 0
EIP is at ubifs_unpack_bits+0xcd/0x231 [ubifs]
EAX: 00000000 EBX: 00000000 ECX: d7e43dc0 EDX: 0000ff00
ESI: 00000004 EDI: f8d23ffe EBP: d7e43db4 ESP: d7e43d8c
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process sync (pid: 7450, ti=d7e42000 task=eb6f9530 task.ti=d7e42000)
Stack: 00000400 c0103db4 dc5e8090 d7e43dc0 d7e43dc0 d7e43dc4 0000001c 00000004
      f496d1e0 f8d23ffc d7e43dd4 f8ffac7e f8d23ffe 00000000 f8d23ffe f2b7af68
      f496d1e0 f8d23ffc d7e43e2c f8ffadc5 00000000 0001f000 00000000 c03b10a7
Call Trace:
[<c0103db4>] ? restore_nocheck_notrace+0x0/0xe
[<f8ffac7e>] ? is_a_node+0x43/0x92 [ubifs]
[<f8ffadc5>] ? dbg_check_ltab+0xf8/0x5c9 [ubifs]
[<c03b10a7>] ? mutex_lock_nested+0x1b2/0x2a0
[<f8ffc86e>] ? ubifs_lpt_start_commit+0x49/0xecb [ubifs]
[<c03b0ef3>] ? mutex_unlock+0xd/0xf
[<f8fef017>] ? ubifs_tnc_start_commit+0x1cf/0xef8 [ubifs]
[<f8fe65d8>] ? do_commit+0x18f/0x52d [ubifs]
[<f8fe69f6>] ? ubifs_run_commit+0x80/0xca [ubifs]
[<f8fd8d35>] ? ubifs_sync_fs+0xdb/0xf6 [ubifs]
[<c0181a07>] ? sync_filesystems+0xc6/0x10c
[<c019f279>] ? do_sync+0x3b/0x6a
[<c019f2ba>] ? sys_sync+0x12/0x18
[<c0103ced>] ? sysenter_do_call+0x12/0x35
=======================
Code: 4d ec 89 01 8b 45 e8 89 10 89 d8 89 f1 d3 e8 85 c0 74 07 29 d6 83 fe
20 75 2a 89 d8 83 c4 1c 5b 5e 5f 5d c3 0f b6 57 01 c1 e2 08 <0f> b6 47 02
c1 e0 10 09 c2 0f b6 07 09 c2 0f b
EIP: [<f8ff0657>] ubifs_unpack_bits+0xcd/0x231 [ubifs] SS:ESP 0068:d7e43d8c
---[ end trace 1bbb4c407a6dd816 ]---

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBI: print reserved_peb when it is too large
Deepak Saxena [Wed, 8 Oct 2008 19:56:24 +0000 (12:56 -0700)]
UBI: print reserved_peb when it is too large

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>
16 years agoUBI: fix IS_ERR test
Julien Brunel [Fri, 26 Sep 2008 13:27:25 +0000 (15:27 +0200)]
UBI: fix IS_ERR test

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>
16 years agoUBIFS: check buffer length when scanning for LPT nodes
Adrian Hunter [Fri, 26 Sep 2008 09:52:21 +0000 (12:52 +0300)]
UBIFS: check buffer length when scanning for LPT nodes

'is_a_node()' function was reading from a buffer before
checking the buffer length, resulting in an OOPS as
follows:

BUG: unable to handle kernel paging request at f8f74002
IP: [<f8f9783f>] :ubifs:ubifs_unpack_bits+0xca/0x233
*pde = 19e95067 *pte = 00000000
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: ubifs ubi mtdchar bio2mtd mtd brd video output
[last unloaded: mtd]

Pid: 6414, comm: integck Not tainted (2.6.27-rc6ubifs34 #23)
EIP: 0060:[<f8f9783f>] EFLAGS: 00010246 CPU: 0
EIP is at ubifs_unpack_bits+0xca/0x233 [ubifs]
EAX: 00000000 EBX: f6090630 ECX: d9badcfc EDX: 00000000
ESI: 00000004 EDI: f8f74002 EBP: d9badcec ESP: d9badcc0
 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process integck (pid: 6414, ti=d9bac000 task=f727dae0 task.ti=d9bac000)
Stack: 00000006 f7306240 00000002 00000000 d9badcfc d9badd00 0000001c 00000000
       f6090630 f6090630 f8f74000 d9badd10 f8fa1cc9 00000000 f8f74002 00000000
       f8f74002 f60fe128 f6090630 f8f74000 d9badd68 f8fa1e46 00000000 0001e000
Call Trace:
 [<f8fa1cc9>] ? is_a_node+0x30/0x90 [ubifs]
 [<f8fa1e46>] ? dbg_check_ltab+0x11d/0x5bd [ubifs]
 [<f8fa388f>] ? ubifs_lpt_start_commit+0x42/0xed3 [ubifs]
 [<c038e76a>] ? mutex_unlock+0x8/0xa
 [<f8f9625d>] ? ubifs_tnc_start_commit+0x1c8/0xedb [ubifs]
 [<f8f8d90b>] ? do_commit+0x187/0x523 [ubifs]
 [<c038e76a>] ? mutex_unlock+0x8/0xa
 [<f8f7ca17>] ? bud_wbuf_callback+0x22/0x28 [ubifs]
 [<f8f8dd1d>] ? ubifs_run_commit+0x76/0xc0 [ubifs]
 [<f8f8032c>] ? ubifs_sync_fs+0xd2/0xe6 [ubifs]
 [<c01a2e97>] ? vfs_quota_sync+0x0/0x17e
 [<c01a5ba6>] ? quota_sync_sb+0x26/0xbb
 [<c01a2e97>] ? vfs_quota_sync+0x0/0x17e
 [<c01a5c5d>] ? sync_dquots+0x22/0x12c
 [<c0173d1b>] ? __fsync_super+0x19/0x68
 [<c0173d75>] ? fsync_super+0xb/0x19
 [<c0174065>] ? generic_shutdown_super+0x22/0xe7
 [<c01a31fc>] ? vfs_quota_off+0x0/0x5fd
 [<f8f7cf4d>] ? ubifs_kill_sb+0x31/0x35 [ubifs]
 [<c01741f9>] ? deactivate_super+0x5e/0x71
 [<c0187610>] ? mntput_no_expire+0x82/0xe4
 [<c0187905>] ? sys_umount+0x4c/0x2f6
 [<c0187bc8>] ? sys_oldumount+0x19/0x1b
 [<c0103b71>] ? sysenter_do_call+0x12/0x25
 =======================
Code: c1 f8 03 8d 04 07 8b 4d e8 89 01 8b 45 e4 89 10 89 d8 89 f1 d3 e8 85 c0
      74 07 29 d6 83 fe 20 75 2a 89 d8 83 c4 20 5b 5e 5f 5d
EIP: [<f8f9783f>] ubifs_unpack_bits+0xca/0x233 [ubifs] SS:ESP 0068:d9badcc0
---[ end trace 1f02572436518c13 ]---

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: correct condition to eliminate unecessary assignment
Adrian Hunter [Wed, 17 Sep 2008 09:11:13 +0000 (12:11 +0300)]
UBIFS: correct condition to eliminate unecessary assignment

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: add more debugging messages for LPT
Adrian Hunter [Fri, 12 Sep 2008 15:13:31 +0000 (18:13 +0300)]
UBIFS: add more debugging messages for LPT

Also add debugging checks for LPT size and separate
out c->check_lpt_free from unrelated bitfields.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: fix bulk-read handling uptodate pages
Adrian Hunter [Fri, 12 Sep 2008 07:34:51 +0000 (10:34 +0300)]
UBIFS: fix bulk-read handling uptodate pages

Bulk-read skips uptodate pages but this was putting its
array index out and causing it to treat subsequent pages
as holes.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: improve garbage collection
Adrian Hunter [Thu, 11 Sep 2008 09:57:49 +0000 (12:57 +0300)]
UBIFS: improve garbage collection

Make garbage collection try to keep data nodes from the same
inode together and in ascending order.  This improves
performance when reading those nodes especially when bulk-read
is used.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: allow for sync_fs when read-only
Adrian Hunter [Thu, 11 Sep 2008 11:25:44 +0000 (14:25 +0300)]
UBIFS: allow for sync_fs when read-only

sync_fs can be called even if the file system is mounted
read-only.  Ensure the commit is not run in that case.

Reported-by: Zoltan Sogor <weth@inf.u-szeged.hu>
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
16 years agoUBIFS: commit on sync_fs
Artem Bityutskiy [Tue, 9 Sep 2008 09:31:37 +0000 (12:31 +0300)]
UBIFS: commit on sync_fs

Commit the journal when the FS is sync'ed. This will make
statfs provide better free space report. And we anyway
advice our users to sync the FS if they want better statfs
report.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: correct comment for commit_on_unmount
Artem Bityutskiy [Tue, 9 Sep 2008 09:23:50 +0000 (12:23 +0300)]
UBIFS: correct comment for commit_on_unmount

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: update dbg_dump_inode
Artem Bityutskiy [Tue, 9 Sep 2008 08:20:35 +0000 (11:20 +0300)]
UBIFS: update dbg_dump_inode

'dbg_dump_inode()' is quite outdated and does not print all
the fileds.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: fix commentary
Artem Bityutskiy [Mon, 8 Sep 2008 15:08:39 +0000 (18:08 +0300)]
UBIFS: fix commentary

Znode may refer both data nodes and indexing nodes

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: fix races in bit-fields
Artem Bityutskiy [Mon, 8 Sep 2008 13:38:01 +0000 (16:38 +0300)]
UBIFS: fix races in bit-fields

We cannot store bit-fields together if the processes which
change them may race, unless we serialize them.

Thus, move the nospc and nospc_rp bit-fields eway from
the mount option/constant bit-fields, to avoid races.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoUBIFS: ensure data read beyond i_size is zeroed out correctly
Adrian Hunter [Fri, 5 Sep 2008 13:17:42 +0000 (16:17 +0300)]
UBIFS: ensure data read beyond i_size is zeroed out correctly

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>