Commit 9f58d3503a1368673609db1962e4a584261b62eb

Authored by Matthew L. Creech
Committed by Artem Bityutskiy
1 parent e11602ea3e

UBIFS: add a superblock flag for free space fix-up

The 'space_fixup' flag can be set in the superblock of a new filesystem by
mkfs.ubifs to indicate that any eraseblocks with free space remaining should be
fixed-up the first time it's mounted (after which the flag is un-set). This
means that the UBIFS image has been flashed by a "dumb" flasher and the free
space has been actually programmed (writing all 0xFFs), so this free space
cannot be used. UBIFS fixes the free space up by re-writing the contents of all
LEBs with free space using the atomic LEB change UBI operation.

Artem: improved commit message, add some more commentaries to the code.

Signed-off-by: Matthew L. Creech <mlcreech@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Showing 4 changed files with 7 additions and 0 deletions Side-by-side Diff

... ... @@ -316,6 +316,8 @@
316 316 printk(KERN_DEBUG "\tflags %#x\n", sup_flags);
317 317 printk(KERN_DEBUG "\t big_lpt %u\n",
318 318 !!(sup_flags & UBIFS_FLG_BIGLPT));
  319 + printk(KERN_DEBUG "\t space_fixup %u\n",
  320 + !!(sup_flags & UBIFS_FLG_SPACE_FIXUP));
319 321 printk(KERN_DEBUG "\tmin_io_size %u\n",
320 322 le32_to_cpu(sup->min_io_size));
321 323 printk(KERN_DEBUG "\tleb_size %u\n",
... ... @@ -617,6 +617,7 @@
617 617 c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran);
618 618 memcpy(&c->uuid, &sup->uuid, 16);
619 619 c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT);
  620 + c->space_fixup = !!(sup_flags & UBIFS_FLG_SPACE_FIXUP);
620 621  
621 622 /* Automatically increase file system size to the maximum size */
622 623 c->old_leb_cnt = c->leb_cnt;
fs/ubifs/ubifs-media.h
... ... @@ -408,9 +408,11 @@
408 408 * Superblock flags.
409 409 *
410 410 * UBIFS_FLG_BIGLPT: if "big" LPT model is used if set
  411 + * UBIFS_FLG_SPACE_FIXUP: first-mount "fixup" of free space within LEBs needed
411 412 */
412 413 enum {
413 414 UBIFS_FLG_BIGLPT = 0x02,
  415 + UBIFS_FLG_SPACE_FIXUP = 0x04,
414 416 };
415 417  
416 418 /**
... ... @@ -1014,6 +1014,7 @@
1014 1014 * @cmt_wq: wait queue to sleep on if the log is full and a commit is running
1015 1015 *
1016 1016 * @big_lpt: flag that LPT is too big to write whole during commit
  1017 + * @space_fixup: flag indicating that free space in LEBs needs to be cleaned up
1017 1018 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during
1018 1019 * recovery)
1019 1020 * @bulk_read: enable bulk-reads
... ... @@ -1253,6 +1254,7 @@
1253 1254 wait_queue_head_t cmt_wq;
1254 1255  
1255 1256 unsigned int big_lpt:1;
  1257 + unsigned int space_fixup:1;
1256 1258 unsigned int no_chk_data_crc:1;
1257 1259 unsigned int bulk_read:1;
1258 1260 unsigned int default_compr:2;