linux/fs/ubifs
Artem Bityutskiy c6727932cf UBIFS: fix a bug in empty space fix-up
UBIFS has a feature called "empty space fix-up" which is a quirk to work-around
limitations of dumb flasher programs. Namely, of those flashers that are unable
to skip NAND pages full of 0xFFs while flashing, resulting in empty space at
the end of half-filled eraseblocks to be unusable for UBIFS. This feature is
relatively new (introduced in v3.0).

The fix-up routine (fixup_free_space()) is executed only once at the very first
mount if the superblock has the 'space_fixup' flag set (can be done with -F
option of mkfs.ubifs). It basically reads all the UBIFS data and metadata and
writes it back to the same LEB. The routine assumes the image is pristine and
does not have anything in the journal.

There was a bug in 'fixup_free_space()' where it fixed up the log incorrectly.
All but one LEB of the log of a pristine file-system are empty. And one
contains just a commit start node. And 'fixup_free_space()' just unmapped this
LEB, which resulted in wiping the commit start node. As a result, some users
were unable to mount the file-system next time with the following symptom:

UBIFS error (pid 1): replay_log_leb: first log node at LEB 3:0 is not CS node
UBIFS error (pid 1): replay_log_leb: log error detected while replaying the log at LEB 3:0

The root-cause of this bug was that 'fixup_free_space()' wrongly assumed
that the beginning of empty space in the log head (c->lhead_offs) was known
on mount. However, it is not the case - it was always 0. UBIFS does not store
in it the master node and finds out by scanning the log on every mount.

The fix is simple - just pass commit start node size instead of 0 to
'fixup_leb()'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Cc: stable@vger.kernel.org [v3.0+]
Reported-by: Iwo Mergler <Iwo.Mergler@netcommwireless.com>
Tested-by: Iwo Mergler <Iwo.Mergler@netcommwireless.com>
Reported-by: James Nute <newten82@gmail.com>
2012-07-20 10:13:27 +03:00
..
Kconfig UBIFS: remove Kconfig debugging option 2012-05-16 19:53:46 +03:00
Makefile UBIFS: remove Kconfig debugging option 2012-05-16 19:53:46 +03:00
budget.c writeback: Add a 'reason' to wb_writeback_work 2011-10-31 00:33:36 +08:00
commit.c UBIFS: get rid of dbg_err 2012-05-16 20:11:23 +03:00
compress.c UBIFS: fix sparse warnings 2008-12-31 14:13:24 +02:00
debug.c UBIFS: correct usage of IS_ENABLED() 2012-06-27 14:22:15 +03:00
debug.h UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
dir.c ubifs: use generic_fillattr() 2012-05-29 23:28:32 -04:00
file.c UBIFS: rename dumping functions 2012-05-16 19:15:56 +03:00
find.c UBIFS: fix assertion 2012-06-18 14:17:08 +03:00
gc.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
io.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
ioctl.c vfs: mnt_drop_write_file() 2012-01-03 22:52:40 -05:00
journal.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
key.h UBIFS: mark unused key objects as invalid 2010-08-30 10:19:08 +03:00
log.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
lprops.c UBIFS: remove Kconfig debugging option 2012-05-16 19:53:46 +03:00
lpt.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
lpt_commit.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
master.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
misc.h UBIFS: introduce more I/O helpers 2011-07-04 10:54:33 +03:00
orphan.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
recovery.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
replay.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
sb.c UBIFS: fix a bug in empty space fix-up 2012-07-20 10:13:27 +03:00
scan.c UBIFS: get rid of dbg_err 2012-05-16 20:11:23 +03:00
shrinker.c UBIFS: fix shrinker object count reports 2011-06-03 18:12:24 +03:00
super.c avoid iput() from flusher thread 2012-05-28 09:54:45 -07:00
tnc.c UBIFS: 2012-05-22 19:30:27 -07:00
tnc_commit.c UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
tnc_misc.c UBIFS: get rid of dbg_err 2012-05-16 20:11:23 +03:00
ubifs-media.h UBIFS: add a superblock flag for free space fix-up 2011-05-16 14:12:14 +03:00
ubifs.h UBI: Kill data type hint 2012-05-20 20:25:59 +03:00
xattr.c UBIFS: 2012-05-22 19:30:27 -07:00