Commit Graph

54 Commits

Author SHA1 Message Date
Sheng Yong
6e225697bd fsck.f2fs: introduce -p option to check meta
This patch introduces a new option '-p' to do more checks on NAT/SIT areas.
'-p' has 2 levels: level 1 has the same sematics as '-a'; level 2 checks
NAT/SIT counters to see if they matches the status in SB and CP.

A new function, fsck_chk_meta, is called by '-p 1' to implement these
comparsion. If errors are detected, fix_on is set, which means fsck will
do a 'fsck -f' immediately.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-03-22 14:10:00 -07:00
Chao Yu
f102ca4c3f f2fs-tools: rebase struct f2fs_summary_block with upstream
Struct f2fs_summary_block has been changed in upstream commits:
 - commit 8f1dbbbbdfe9 ("f2fs: introduce lifetime write IO statistics")
 - commit dfc08a12e49a ("f2fs: introduce f2fs_journal struct to wrap journal info")

This patch does the sync work for f2fs_summary_block structure between
f2fs-utils and f2fs kernel module.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-03-14 09:26:53 -07:00
Junling Zheng
9b09631c8f fsck.f2fs: fix incorrect block_addr of node/meta
Fix incorrect block_addr of node or meta inode into 0x1 during
build_nat_area_bitmap().

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Liu Xue <liuxueliu.liu@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-03-07 15:36:27 -08:00
Junling Zheng
bc6f686893 fsck.f2fs: calculate the total size correctly
Correctly calculate the total FS size in init_sb_info(), for sector
size may not be 512 bytes.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-02-29 09:20:54 -08:00
Sheng Yong
c00fe85bc7 fsck.f2fs: fix corrupted nat entry [0]
The first nat entry must be null. If it is corrupted, we set its bit in
nat_area_bitmap, without increasing valid_nat_entry_cnt, fsck_verify will
nullify it at last.

Reported-by: Cheng Yinchao <chengyinchao@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-02-24 09:56:54 -08:00
Jaegeuk Kim
e92fd42618 fsck.f2fs: nullify raw_super pointer
Otherwise it will cause double free.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-01-21 21:13:56 +08:00
Jaegeuk Kim
231fc70f6e fsck.f2fs: assign checkpoint pointer correctly
This patch fixes a bug that cp pointer is not assigned correctly.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-01-14 20:36:20 -08:00
Sheng Yong
b9eb1dc383 fsck.f2fs: swap checkpoint crc to CPU endian
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-01-14 15:57:06 -08:00
Jaegeuk Kim
25b2e75312 f2fs-tools: avoid failure and warnings for android build
This patch fixes to resolve build failure and warnings when compiling it
under AOSP.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-01-13 17:18:22 -08:00
Sheng Yong
2d3ea141cc fsck.f2fs: fix double free invalid checkpoint
The invalid checkpoin is freed in validate_checkpoint().

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-28 14:33:12 -08:00
Jaegeuk Kim
a828ebb234 fsck.f2fs: fix losing journal entries
If fsck.f2fs reports a bug, move_curseg_info tries to change the current
segment info.
When it changes the new summary block, it overwrites the existing journal
entries.
This patch fixes it not to overwrite journal entry space.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-19 23:42:31 -08:00
Jaegeuk Kim
767a93ea8b defrag.f2fs: fix missing SSA updates
Previously SSA is updated if it is not included in current segment info.
But, defrag.f2fs doesn't handle current segment info during the process, and
instead lastly update the whole current segment info at a time.
So, we need to update summary entries all the time.
Otherwise, we can lose the SSA entry.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-19 03:27:12 -08:00
Jaegeuk Kim
f66104cf3a defrag.f2fs: enhance allocation speed
This patch improves the allocation speed.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-19 03:27:11 -08:00
Jaegeuk Kim
d6147940b9 defrag.f2fs: return error if there is no space
This patch checks whether there is a space or not to allocate new blocks.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-16 18:54:22 -08:00
Jaegeuk Kim
17acba6d3d defrag.f2fs: eliminate unexpected journal entries
When moving data or node blocks, it changes current segment information
dynamtically. Meanwhile, its journal entry space is recovered by old
stale data.
This patch makes sure that its journal space is zeroed out.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-16 17:46:32 -08:00
Jaegeuk Kim
552d6a8f4b defrag.f2fs: fix not to allocate current segment
This patch fixes allocating wrong segment which has zero data but is registered
as a current segment.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-15 18:14:48 -08:00
Jaegeuk Kim
9e5c021b67 mkfs.f2fs: fix storing volume label correctly in utf16
This patch fixes to store volume label as utf16 correctly.

Many conversion codes are copied from exfat-tools.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-14 16:35:39 -08:00
Jaegeuk Kim
2c1ebe237a defrag.f2fs: introduce defragmentation tool
This tool tries to move the valid blocks ranging from blkaddr to blkaddr + len
to targeted blkaddr with a direction like expand or shrink.

The option includes:
 -d debug level [default:0]
 -s start block address [default: main_blkaddr]
 -l length [default:512 (2MB)]
 -t target block address [default: main_blkaddr + 2MB]
 -i set direction as shrink [default: expand]

For example,
 # defrag.f2fs -s 0x100 -l 0x10 -t 0x4000 /dev/sdb1

This will move data blocks between 0x100 and 0x110 to the right side of
0x4000 space.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-11 15:58:50 -08:00
Jaegeuk Kim
003b102d8a fsck.f2fs: LFS alloc_type must have free segment after blkoff
This patch checks alloc_type of current segment type.
If it is LFS, the last of segment should have no valid block.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-11 15:57:51 -08:00
Jaegeuk Kim
1a35b5e29d f2fs-tools: export print_raw_sb_info
This patch exports print_raw_sb_info().

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-10 19:46:28 -08:00
Jaegeuk Kim
0e0b9f2844 fsck.f2fs: use get_{sb|cp} and set_{sb|cp} macros
We can use get_cp, set_cp, get_sb, and set_sb in fsck.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 21:36:03 -08:00
Jaegeuk Kim
ee48fd2ced fsck.f2fs: declare static function
This avoids the following warning.

mount.c:783:27: warning: SM_I is static but used in inline function
check_seg_range which is not static.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-11-22 11:26:52 +08:00
Jaegeuk Kim
641d98f26d fsck.f2fs: avoid build warning
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-07 15:48:18 -07:00
Jaegeuk Kim
4476615d26 dump.f2fs: show i_advise field in inode
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-04-23 18:40:52 -07:00
Jaegeuk Kim
f6eef57a69 fsck.f2fs: show superblock features and encryption info
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-04-23 17:36:21 -07:00
Jaegeuk Kim
65950fc736 fsck.f2fs: show ckeckpoint version info
This patch shows the valid checkpoint version number.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-04-10 10:36:06 -07:00
Jaegeuk Kim
fce2ff183e fsck.f2fs: return summary block pointer and types
This patch adds to return summry_block pointer to callers, which will be used
when fixing them.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-03-27 16:34:48 -07:00
Jaegeuk Kim
fea6162a6d fsck.f2fs: show total sectors consumed by filesystem
This patch shows the information about the number of total sectors composing
filesystem.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-03-20 17:07:48 -07:00
Jaegeuk Kim
7ba9eec293 fsck.f2fs: show cp_state for fsck.f2fs
This patch adds to show cp_state during fsck.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-03-20 17:01:41 -07:00
Chao Yu
37580f1c5b fsck.f2fs: support large sector size
Since f2fs support large sector size in commit 55cf9cb63f0e "f2fs: support large
sector size", block device with sector size of 512/1024/2048/4096 bytes can be
supported.

But fsck.f2fs still use default F2FS_LOG_SECTOR_SIZE/F2FS_LOG_SECTORS_PER_BLOCK to
verify related data in f2fs image, it's wrong, let's fix this issue in this patch.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-02-05 18:42:46 -08:00
Jaegeuk Kim
9c6617d06d dump.f2fs: dump owner of data given block address
This patch introduces a feature to dump owner information of given block
address.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-12-17 18:39:34 -08:00
Jaegeuk Kim
8f521d9172 fsck.f2fs: avoid false alarm on SIT type fix
This patch removed a false alarm when detecting any inconsistency in SIT types.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-11-13 13:31:52 -08:00
Jaegeuk Kim
762eedf87f mkfs.f2fs: give a kernel version for initial format
This is to identify when the format was done.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-11-07 13:36:48 -08:00
Jaegeuk Kim
6fa2547e04 fsck.f2fs: trigger fsck.f2fs when new change was made
This patch remains user specified triggering information in superblock.
Then, if the information was changed, fsck.f2fs is triggered.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-11-07 13:36:45 -08:00
Jaegeuk Kim
232ce7671e fsck.f2fs: fix SIT entry types
Sometimes, SIT entry type is broken, so we need to rebuild it.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-11-06 18:27:11 -08:00
Jaegeuk Kim
5007756839 fsck.f2fs: show inline status of inode
This patch adds to show inline status of each inode.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-10-18 23:56:04 -07:00
Jaegeuk Kim
1dd3bc0a17 fsck.f2fs: fix superblock offset
The second offset should be F2FS_BLKSIZE + F2FS_SUPER_OFFSET.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-10-09 14:58:40 -07:00
Jaegeuk Kim
cfeb015e88 f2fs: rearrange options to remove redundant check
This patch summarizes the usage of options.

-a : auto_fix, fix corruption, only if f2fs reported some potential errors
-f : force,    fix corruption entire partition
None : prompt, if fsck.f2fs detets any corruption

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-03 19:45:42 -07:00
Jaegeuk Kim
7eb6c5a03b fsck.f2fs: add auto_fix feature
This patch adds an auto_fix feature which fixes inconsistency of f2fs images.

E.g.,

With this option, -a, fsck.f2fs tries to fix inconsistency only if its valid
checkpoint has CP_FSCK_FLAG, written by previous bug_on cases.

So, normally it does fix nothing, so that there is no performance regression.
But, if a sort of corruption was reported by the f2fs module, this tries to
fix potential corrupted partition.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-02 18:23:11 -07:00
Jaegeuk Kim
a6b2870ddb fsck.f2fs: check next block is free or not
If block allocation is made to the next block offset, we should drop that
block.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 16:37:46 -07:00
Jaegeuk Kim
b700e313b4 fsck.f2fs: fix checkpoint
- fix nat entries
- fix sit entries
- fix checkpoint

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
1dc1edfbcb fsck.f2fs: handle correctly segment summary entries
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
48863d422e fsck.f2fs: give a chance to recover sit entries
This patch skips initial verfication on SIT entries, which checks the number of
valid blocks from its bitmap.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
1ce70c67e3 fsck.f2fs: cleanup mount.c
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
5cd7001f5d fsck.f2fs: handle error cases
Do sanity check first and then update metadata.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
2701c94ab0 fsck.f2fs: remove return value of get_node_info
We don't need to get the return value.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Mark Salyzyn
58edb106a8 f2fs-tools: 64-bit compile issue
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Change-Id: I9398b877571d3dabbcb29c87a67d59672ea7fbaa
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-03 09:27:47 -07:00
Changman Lee
4ea4f1db27 fsck.f2fs: large volume support
This patch support large volume over about 3TB.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
[Jaegeuk Kim: add missing cp_payload in f2fs_super_block]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-04 13:32:07 +09:00
JP Abgrall
a68ee58a5d Cleanup various build warnings (signed vs unsigned, unused vars,...)
* removed unused includes.
* removed unused parameters.
* Fixed a bunch of warnings around:
    int i;
    if (i < some_uint) ...
  and
    u32 x;
    ...
    if (x < 0) return error;
* Protect BLKDISCARD usage if it is not available.

Change-Id: Iede035b1beb2df01c961589a69aff47a5258ecd2
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-05-15 08:40:55 +09:00
Jaegeuk Kim
858c4039c8 mkfs, fsck: change the results for readability
This patch cleans up several printing formats.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-06 11:09:41 +09:00