Skip to content

Commit

Permalink
UBIFS: make space fixup work in the remount case
Browse files Browse the repository at this point in the history
The UBIFS space fixup is a useful feature which allows to fixup the "broken"
flash space at the time of the first mount. The "broken" space is usually the
result of using a "dumb" industrial flasher which is not able to skip empty
NAND pages and just writes all 0xFFs to the empty space, which has grave
side-effects for UBIFS when UBIFS trise to write useful data to those empty
pages.

The fix-up feature works roughly like this:
1. mkfs.ubifs sets the fixup flag in UBIFS superblock when creating the image
   (see -F option)
2. when the file-system is mounted for the first time, UBIFS notices the fixup
   flag and re-writes the entire media atomically, which may take really a lot
   of time.
3. UBIFS clears the fixup flag in the superblock.

This works fine when the file system is mounted R/W for the very first time.
But it did not really work in the case when we first mount the file-system R/O,
and then re-mount R/W. The reason was that we started the fixup procedure too
late, which we cannot really do because we have to fixup the space before it
starts being used.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Reported-by: Mark Jackson <mpfj-list@mimc.co.uk>
Cc: stable@vger.kernel.org # 3.0+
  • Loading branch information
Artem Bityutskiy committed Mar 14, 2013
1 parent f6161aa commit 67e753c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/ubifs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,12 @@ static int ubifs_remount_rw(struct ubifs_info *c)
c->remounting_rw = 1;
c->ro_mount = 0;

if (c->space_fixup) {
err = ubifs_fixup_free_space(c);
if (err)
return err;
}

err = check_free_space(c);
if (err)
goto out;
Expand Down Expand Up @@ -1684,12 +1690,6 @@ static int ubifs_remount_rw(struct ubifs_info *c)
err = dbg_check_space_info(c);
}

if (c->space_fixup) {
err = ubifs_fixup_free_space(c);
if (err)
goto out;
}

mutex_unlock(&c->umount_mutex);
return err;

Expand Down

0 comments on commit 67e753c

Please sign in to comment.