Commit Graph

533 Commits

Author SHA1 Message Date
Jaegeuk Kim
7aafb1b5f4 fsck.f2fs: handle IS_VALID_BLK_ADDR
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
f6d1d582e9 fsck.f2fs: clean up codes
Fix wrong coding style.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
6f4106c12b fsck.f2fs: retry to fix corrupted image
This patch adds a facility to retry conducting fsck.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:27 -07:00
Jaegeuk Kim
f46078949b f2fs_dentry_hash: avoid casting unsigned char to singed char
This can hurt when calculating hash value, resulting in false alarm.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 10:52:19 -07:00
Jaegeuk Kim
347e94f4b2 fsck.f2fs: show inode numbers
fsck.f2fs -d 1 [dev]
 : shows inode informations
fsck.f2fs -d -1 [dev]
 : shows directory tree with inode number

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-26 17:30:18 -07:00
Jaegeuk Kim
6cd2c51c20 dump.f2fs: support dump_file from image
This patch adds supporting dump_file, which can extract a file from image.

You can simply select [yes|no] when doing dump.f2fs -i [inode number] [img].

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-26 17:30:15 -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
Jaegeuk Kim
0575dd1c56 libf2fs, fsck, mkfs: call f2fs_finalize_device before exit
The fsck tool should call f2fs_finalize_device before exit to close the device
file.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-13 17:06:02 +09: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
192d979c61 fsck: remove build warnings
This patch casts some variable types to remove build warnings.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-25 08:31:49 +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
Jaegeuk Kim
4f267323a2 f2fs-tools: resolve build warnings
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-01-20 17:42:21 +09:00
Changman Lee
e296161af0 f2fs-tools: move fsck/fibmap.f2fs to tools/
Let's move miscellaneous utilities into tools directory.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-01-16 17:29:13 +09:00
Jaegeuk Kim
1aae03594b fibmap: fix wrong block count
This is an obvious bug fix patch.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-12-27 12:57:51 +09:00
Huajun Li
061ee67915 f2fs-tools: add inline data check
Add inline data check

Signed-off-by: Weihong Xu <weihong.xu@intel.com>
Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-12-16 12:42:43 +09:00
Jaegeuk Kim
f1d452af4a fsck: fix orphan node blocks
Previously, fsck handles only the orphan inode block excpet its indirect node
blocks.
This causes false-alarm, unreachable nat entries [xxx].
This patch fixes to cover indirect node blocks in an orphan inode.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-30 11:16:01 +09:00
Jaegeuk Kim
8e678b2edf fsck: fix checking orphan inodes
This patch fixes bugs in the orphan inode procedure.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-16 13:52:16 +09:00
Jaegeuk Kim
76a069430a fsck: fix to handle file types correctly
The file type is based on the number, not bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-08 19:17:22 +09:00
Jaegeuk Kim
78b795e05d fsck: skip to check block addresses in device files
The device files use i_addr or i_nid fields for their rdev numbers.
So, fsck should skip to check block addresses inside of them.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-10-08 18:17:33 +09:00
Jaegeuk Kim
cd1e4704d0 fsck, lib: support inline xattr
This patch adjusts the modification to handle inline xattrs.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-20 18:12:04 +09:00
Jaegeuk Kim
9455376cd0 fibmap.f2fs: change fibmap to fibmap.f2fs
The fibmap tool is for debugging f2fs especially.

CC: Changman Lee <cm224.lee@samsung.com>
CC: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-09 06:41:02 +09:00
Changman Lee
e23d58533c f2fs-tools: add stat information into fibmap
This patch shows stat information about a file with fragmented state.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-08 14:53:41 +09:00
Changman Lee
6e8f2d5d22 f2fs-tools: add debug message for checking xattr
This patch adds debug message to confirm xattr block is checked.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-07 18:21:24 +09:00
Jaegeuk Kim
2c877a862d libf2fs: check more conditions on mounted filesystem
In the case of lazy umount, "umount -l", some processes are able to use the
file system even if its mountpoint was disconnected.
At this moment, we should not allow mkfs.f2fs.
This patch adds this condition check.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-08-02 17:06:26 +09:00
Changman Lee
57baa23a32 f2fs-tools: add option to display directory tree
This option shows directory tree of f2fs.

Usage: fsck.f2fs -t /dev/sdx

`-- p0
   |-- f4
   `-- d6
        |-- f5e
        |-- cb6
        |-- fdb
        |-- fe8
        `-- l9a

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-30 17:06:44 +09:00
Changman Lee
932f9845f6 f2fs-tools: use either hex or decimal options
This patch supports both hex and decimal when using nid as option.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-30 17:06:44 +09:00
Changman Lee
223fdf3e00 f2fs-tools: cleanup debug statement
The debug message is too verbose therefore decrease message.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-30 17:06:44 +09:00
Changman Lee
c81ded6cf0 f2fs-tools: fix missing function declaration
Explicitly declare function name.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-30 17:06:44 +09:00
Changman Lee
dfe2a3384f f2fs-tools: add fibmap
This is to get physical location of file data.
We can check the percentage of fragmentation on a file.

Note that it uses fsync to get exact blkaddr.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-22 21:52:03 +09:00
Changman Lee
8843554c8c dump: dump inode information from blkaddr
This patch is to dump inode which blkaddr belongs in.
Usage:
  dump.f2fs /dev/sdx -b blk_addr (in 4KB)

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-18 15:45:30 +09:00
Jaegeuk Kim
0307b93ce2 fsck: fix name search
The next name slots should be calculated by F2FS_SLOT_LEN not F2FS_NAME_LEN.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-18 09:19:54 +09:00
Changman Lee
7f35b548d4 f2fs-tools: add fsck.f2fs and dump.f2fs
fsck.f2fs checks file system consistency, but does not repair a broken
file system yet.
dump.f2fs shows the information of a specific inode and makes dump file
of SSA and SIT.
f2fs checks file system consistency as follows:
 o When data about used area and its metadata are identical,
   f2fs is considered consistent. To verify such consistency, we use
   three bitmaps: nat_area_bitmap, sit_area_bitmap, and main_area_bitmap.
   First, each bit in nat_area_bitmap corresponds to a nid in NAT.
   Second, each bit in sit_area_bitmap corresponds to a valid block in a
   segment. This bitmap is same to the total valid_map of f2fs_sit_entries
   in SIT.
   Last, each bit in main_area_bitmap corresponds to a block in main area
   except meta area.
   After a consistency check of each block, we set or clear the
   corresponding bit of each bitmap.
   From the root node, we start consistency check. The verified
   information varies according to block type.
   1. NODE
     - Read information of node block from NAT
     - Check if block address is allocated using node info.
     - Check if the type of f2fs_summary related to nid in SSA is NODE.
     - Update the corresponding bit in nat_area_bitmap.
     - Update the corresponding bit in sit_area_bitmap.
     - Set the corresponding bit in main_area_bitmap to 1.
     - Then, read node block. According to its attribute, explore
       inode/direct node/indirect node/double indirect node
       recursively.
     - If it is an inode block, we also check its xattr and hard link.
   2. DATA
     - Check if the type of f2fs_summary related to nid in SSA is DATA.
     - Set the corresponding bits of sit_area_bitmap and
       main_area_bitmap to visited
     - If it is a dentry block, traverse each dentries that may be
       regular
       file or directory. At this time, it will check inode block again.
   Finally, we verify whether
     - every nat_area_bitmap is visited
     - any unreachable hard link exists
     - values of sit_area_bitmap and main_area_bitmap are identical
     - total_valid_block_count/node_count/inode_count are correct

Usage:
 o fsck.f2fs
   # fsck.f2fs /dev/sdx
   options:
     -d debug level [default:0]
 o dump.f2fs
   # dump.f2fs -i [ino] /dev/sdx
   # dump.f2fs -s 0~-1 /dev/sdx (SIT dump)
   # dump.f2fs -a 0~-1 /dev/sdx (SSA dump)
   options:
     -d debug level [default:0]
     -i inode no (hex)
     -s [SIT dump segno from #1~#2 (decimal), for all 0~-1]
     -a [SSA dump segno from #1~#2 (decimal), for all 0~-1]

Note: To use dump.f2fs, please run make install or ln -s fsck.f2fs
dump.f2fs

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Byoung Geun Kim <bgbg.kim@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-07-04 23:15:25 +09:00