From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg KH <gregkh@linuxfoundation.org>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk,
Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>,
Iwo Mergler <Iwo.Mergler@netcommwireless.com>,
James Nute <newten82@gmail.com>
Subject: [ 15/23] UBIFS: fix a bug in empty space fix-up
Date: Thu, 26 Jul 2012 14:19:54 -0700 [thread overview]
Message-ID: <20120726211407.256255674@linuxfoundation.org> (raw)
In-Reply-To: <20120726211405.959857593@linuxfoundation.org>
From: Greg KH <gregkh@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
commit c6727932cfdb13501108b16c38463c09d5ec7a74 upstream.
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>
Reported-by: Iwo Mergler <Iwo.Mergler@netcommwireless.com>
Tested-by: Iwo Mergler <Iwo.Mergler@netcommwireless.com>
Reported-by: James Nute <newten82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/ubifs/sb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -724,8 +724,12 @@ static int fixup_free_space(struct ubifs
lnum = ubifs_next_log_lnum(c, lnum);
}
- /* Fixup the current log head */
- err = fixup_leb(c, c->lhead_lnum, c->lhead_offs);
+ /*
+ * Fixup the log head which contains the only a CS node at the
+ * beginning.
+ */
+ err = fixup_leb(c, c->lhead_lnum,
+ ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size));
if (err)
goto out;
next prev parent reply other threads:[~2012-07-26 21:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 21:14 [ 00/23] 3.4.7-stable review Greg KH
2012-07-26 21:19 ` [ 01/23] md: avoid crash when stopping md array races with closing other open fds Greg Kroah-Hartman
2012-07-26 21:19 ` [ 02/23] md/raid1: close some possible races on write errors during resync Greg Kroah-Hartman
2012-07-26 21:19 ` [ 03/23] cifs: always update the inode cache with the results from a FIND_* Greg Kroah-Hartman
2012-07-26 21:19 ` [ 04/23] cifs: on CONFIG_HIGHMEM machines, limit the rsize/wsize to the kmap space Greg Kroah-Hartman
2012-07-26 21:19 ` [ 05/23] target: Clean up returning errors in PR handling code Greg Kroah-Hartman
2012-07-26 21:19 ` [ 06/23] target: Fix range calculation in WRITE SAME emulation when num blocks == 0 Greg Kroah-Hartman
2012-07-26 21:19 ` [ 07/23] ntp: Fix STA_INS/DEL clearing bug Greg Kroah-Hartman
2012-07-26 21:19 ` [ 08/23] tcm_fc: Fix crash seen with aborts and large reads Greg Kroah-Hartman
2012-07-26 21:19 ` [ 09/23] ext4: fix duplicated mnt_drop_write call in EXT4_IOC_MOVE_EXT Greg Kroah-Hartman
2012-07-26 21:19 ` [ 10/23] mm: fix lost kswapd wakeup in kswapd_stop() Greg Kroah-Hartman
2012-07-26 21:19 ` [ 11/23] HID: add battery quirk for Apple Wireless ANSI Greg Kroah-Hartman
2012-07-26 21:19 ` [ 12/23] HID: add Sennheiser BTD500USB device support Greg Kroah-Hartman
2012-07-26 21:19 ` [ 13/23] HID: multitouch: Add support for Baanto touchscreen Greg Kroah-Hartman
2012-07-26 21:19 ` [ 14/23] MIPS: Properly align the .data..init_task section Greg Kroah-Hartman
2012-07-26 21:19 ` Greg Kroah-Hartman [this message]
2012-07-26 21:19 ` [ 16/23] ore: Fix NFS crash by supporting any unaligned RAID IO Greg Kroah-Hartman
2012-07-26 21:19 ` [ 17/23] ore: Remove support of partial IO request (NFS crash) Greg Kroah-Hartman
2012-07-26 21:19 ` [ 18/23] pnfs-obj: dont leak objio_state if ore_write/read fails Greg Kroah-Hartman
2012-07-26 21:19 ` [ 19/23] dm thin: do not send discards to shared blocks Greg Kroah-Hartman
2012-07-26 21:19 ` [ 20/23] dm raid1: fix crash with mirror recovery and discard Greg Kroah-Hartman
2012-07-26 21:20 ` [ 21/23] dm raid1: set discard_zeroes_data_unsupported Greg Kroah-Hartman
2012-07-26 21:20 ` [ 22/23] ARM: SAMSUNG: Update default rate for xusbxti clock Greg Kroah-Hartman
2012-07-26 21:20 ` [ 23/23] cifs: when CONFIG_HIGHMEM is set, serialize the read/write kmaps Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120726211407.256255674@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=Artem.Bityutskiy@linux.intel.com \
--cc=Iwo.Mergler@netcommwireless.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=newten82@gmail.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox