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 08:11:32 +00:00
|
|
|
/**
|
|
|
|
* fsck.h
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
|
|
|
|
* http://www.samsung.com/
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
#ifndef _FSCK_H_
|
|
|
|
#define _FSCK_H_
|
|
|
|
|
|
|
|
#include "f2fs.h"
|
|
|
|
|
2020-08-07 02:02:31 +00:00
|
|
|
enum {
|
|
|
|
FSCK_SUCCESS = 0,
|
|
|
|
FSCK_ERROR_CORRECTED = 1 << 0,
|
|
|
|
FSCK_SYSTEM_SHOULD_REBOOT = 1 << 1,
|
|
|
|
FSCK_ERRORS_LEFT_UNCORRECTED = 1 << 2,
|
|
|
|
FSCK_OPERATIONAL_ERROR = 1 << 3,
|
|
|
|
FSCK_USAGE_OR_SYNTAX_ERROR = 1 << 4,
|
|
|
|
FSCK_USER_CANCELLED = 1 << 5,
|
|
|
|
FSCK_SHARED_LIB_ERROR = 1 << 7,
|
|
|
|
};
|
|
|
|
|
2017-10-30 23:21:09 +00:00
|
|
|
struct quota_ctx;
|
|
|
|
|
2016-03-16 03:07:07 +00:00
|
|
|
#define FSCK_UNMATCHED_EXTENT 0x00000001
|
2018-07-03 10:10:04 +00:00
|
|
|
#define FSCK_INLINE_INODE 0x00000002
|
2016-03-16 03:07:07 +00:00
|
|
|
|
2016-03-14 06:16:53 +00:00
|
|
|
enum {
|
|
|
|
PREEN_MODE_0,
|
|
|
|
PREEN_MODE_1,
|
2018-11-27 12:36:35 +00:00
|
|
|
PREEN_MODE_2,
|
2016-03-14 06:16:53 +00:00
|
|
|
PREEN_MODE_MAX
|
|
|
|
};
|
|
|
|
|
2017-01-21 05:52:52 +00:00
|
|
|
enum {
|
|
|
|
NOERROR,
|
|
|
|
EWRONG_OPT,
|
|
|
|
ENEED_ARG,
|
|
|
|
EUNKNOWN_OPT,
|
|
|
|
EUNKNOWN_ARG,
|
|
|
|
};
|
|
|
|
|
2018-09-28 12:25:58 +00:00
|
|
|
enum SB_ADDR {
|
|
|
|
SB0_ADDR = 0,
|
|
|
|
SB1_ADDR,
|
|
|
|
SB_MAX_ADDR,
|
|
|
|
};
|
|
|
|
|
2022-11-10 14:07:21 +00:00
|
|
|
#define SB_MASK(i) (1 << (i))
|
2018-09-28 12:25:58 +00:00
|
|
|
#define SB_MASK_ALL (SB_MASK(SB0_ADDR) | SB_MASK(SB1_ADDR))
|
|
|
|
|
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 08:11:32 +00:00
|
|
|
/* fsck.c */
|
|
|
|
struct orphan_info {
|
|
|
|
u32 nr_inodes;
|
|
|
|
u32 *ino_list;
|
|
|
|
};
|
|
|
|
|
2016-03-16 03:07:07 +00:00
|
|
|
struct extent_info {
|
|
|
|
u32 fofs; /* start offset in a file */
|
|
|
|
u32 blk; /* start block address of the extent */
|
|
|
|
u32 len; /* length of the extent */
|
|
|
|
};
|
|
|
|
|
2015-03-30 19:57:10 +00:00
|
|
|
struct child_info {
|
2016-03-16 03:07:07 +00:00
|
|
|
u32 state;
|
2015-03-30 19:57:10 +00:00
|
|
|
u32 links;
|
|
|
|
u32 files;
|
2016-03-16 03:05:14 +00:00
|
|
|
u32 pgofs;
|
2015-03-30 20:09:16 +00:00
|
|
|
u8 dots;
|
2016-03-16 03:05:14 +00:00
|
|
|
u8 dir_level;
|
2021-06-13 03:42:47 +00:00
|
|
|
u32 p_ino; /* parent ino */
|
|
|
|
char p_name[F2FS_NAME_LEN + 1]; /* parent name */
|
|
|
|
u32 pp_ino; /* parent parent ino*/
|
2016-03-16 03:07:07 +00:00
|
|
|
struct extent_info ei;
|
|
|
|
u32 last_blk;
|
2017-12-18 13:25:27 +00:00
|
|
|
u32 i_namelen; /* dentry namelen */
|
2015-12-08 22:53:21 +00:00
|
|
|
};
|
|
|
|
|
2021-06-13 03:42:47 +00:00
|
|
|
struct f2fs_dentry {
|
|
|
|
char name[F2FS_NAME_LEN + 1];
|
|
|
|
int depth;
|
|
|
|
struct f2fs_dentry *next;
|
|
|
|
};
|
|
|
|
|
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 08:11:32 +00:00
|
|
|
struct f2fs_fsck {
|
|
|
|
struct f2fs_sb_info sbi;
|
|
|
|
|
|
|
|
struct orphan_info orphani;
|
|
|
|
struct chk_result {
|
2021-12-30 00:29:42 +00:00
|
|
|
u64 checked_node_cnt;
|
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 08:11:32 +00:00
|
|
|
u64 valid_blk_cnt;
|
|
|
|
u32 valid_nat_entry_cnt;
|
|
|
|
u32 valid_node_cnt;
|
|
|
|
u32 valid_inode_cnt;
|
|
|
|
u32 multi_hard_link_files;
|
|
|
|
u64 sit_valid_blocks;
|
|
|
|
u32 sit_free_segs;
|
fsck: Check write pointer consistency of open zones
On sudden f2fs shutdown, write pointers of zoned block devices can go
further but f2fs meta data keeps current segments at positions before the
write operations. After remounting the f2fs, this inconsistency causes
write operations not at write pointers and "Unaligned write command"
error is reported.
To avoid the error, have f2fs.fsck check consistency of write pointers
of open zones that current segments point to. Compare each current
segment's position and the write pointer position of the open zone. If
inconsistency is found and 'fix_on' flag is set, assign a new zone to the
current segment and check the newly assigned zone has write pointer at
the zone start. Leave the original zone as is to keep data recorded in
it.
To care about fsync data, refer each seg_entry's ckpt_valid_map to get
the last valid block in the zone. If the last valid block is beyond the
current segments position, fsync data exits in the zone. In case fsync
data exists, do not assign a new zone to the current segment not to lose
the fsync data. It is expected that the kernel replay the fsync data and
fix the write pointer inconsistency at mount time.
Also check consistency between write pointer of the zone the current
segment points to with valid block maps of the zone. If the last valid
block is beyond the write pointer position, report to indicate a bug. If
'fix_on' flag is set, assign a new zone to the current segment.
When inconsistencies are found, turn on 'bug_on' flag in fsck_verify() to
ask users to fix them or not. When inconsistencies get fixed, turn on
'force' flag in fsck_verify() to enforce fixes in following checks.
This check and fix is done twice. The first is done at the beginning of
do_fsck() function so that other fixes can reflect the current segment
modification. The second is done in fsck_verify() to reflect updated meta
data by other fixes.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-11-28 07:59:29 +00:00
|
|
|
u32 wp_fixed;
|
|
|
|
u32 wp_inconsistent_zones;
|
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 08:11:32 +00:00
|
|
|
} chk;
|
|
|
|
|
|
|
|
struct hard_link_node *hard_link_list_head;
|
|
|
|
|
|
|
|
char *main_seg_usage;
|
|
|
|
char *main_area_bitmap;
|
|
|
|
char *nat_area_bitmap;
|
|
|
|
char *sit_area_bitmap;
|
|
|
|
|
|
|
|
u64 main_area_bitmap_sz;
|
|
|
|
u32 nat_area_bitmap_sz;
|
|
|
|
u32 sit_area_bitmap_sz;
|
|
|
|
|
|
|
|
u64 nr_main_blks;
|
|
|
|
u32 nr_nat_entries;
|
|
|
|
|
|
|
|
u32 dentry_depth;
|
2021-06-13 03:42:47 +00:00
|
|
|
struct f2fs_dentry *dentry;
|
|
|
|
struct f2fs_dentry *dentry_end;
|
2016-03-14 06:16:55 +00:00
|
|
|
struct f2fs_nat_entry *entries;
|
2016-03-14 06:16:54 +00:00
|
|
|
u32 nat_valid_inode_cnt;
|
2017-10-30 23:21:09 +00:00
|
|
|
|
|
|
|
struct quota_ctx *qctx;
|
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 08:11:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define BLOCK_SZ 4096
|
|
|
|
struct block {
|
|
|
|
unsigned char buf[BLOCK_SZ];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum NODE_TYPE {
|
|
|
|
TYPE_INODE = 37,
|
|
|
|
TYPE_DIRECT_NODE = 43,
|
|
|
|
TYPE_INDIRECT_NODE = 53,
|
2014-08-28 00:06:17 +00:00
|
|
|
TYPE_DOUBLE_INDIRECT_NODE = 67,
|
|
|
|
TYPE_XATTR = 77
|
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 08:11:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hard_link_node {
|
|
|
|
u32 nid;
|
|
|
|
u32 links;
|
2015-03-26 01:26:44 +00:00
|
|
|
u32 actual_links;
|
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 08:11:32 +00:00
|
|
|
struct hard_link_node *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum seg_type {
|
|
|
|
SEG_TYPE_DATA,
|
|
|
|
SEG_TYPE_CUR_DATA,
|
|
|
|
SEG_TYPE_NODE,
|
|
|
|
SEG_TYPE_CUR_NODE,
|
2013-07-18 02:20:05 +00:00
|
|
|
SEG_TYPE_MAX,
|
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 08:11:32 +00:00
|
|
|
};
|
|
|
|
|
2015-12-10 00:18:44 +00:00
|
|
|
struct selabel_handle;
|
|
|
|
|
2019-11-28 07:59:28 +00:00
|
|
|
static inline bool need_fsync_data_record(struct f2fs_sb_info *sbi)
|
|
|
|
{
|
|
|
|
return !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG) ||
|
|
|
|
c.zoned_model == F2FS_ZONED_HM;
|
|
|
|
}
|
|
|
|
|
2016-11-19 13:24:40 +00:00
|
|
|
extern int fsck_chk_orphan_node(struct f2fs_sb_info *);
|
2017-10-30 23:21:09 +00:00
|
|
|
extern int fsck_chk_quota_node(struct f2fs_sb_info *);
|
|
|
|
extern int fsck_chk_quota_files(struct f2fs_sb_info *);
|
2020-04-07 10:01:07 +00:00
|
|
|
extern int fsck_sanity_check_nid(struct f2fs_sb_info *, u32,
|
|
|
|
struct f2fs_node *, enum FILE_TYPE, enum NODE_TYPE,
|
|
|
|
struct node_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
|
2017-06-05 20:44:50 +00:00
|
|
|
enum FILE_TYPE, enum NODE_TYPE, u32 *,
|
2021-05-12 12:50:48 +00:00
|
|
|
struct f2fs_compr_blk_cnt *, struct child_info *);
|
2014-08-28 00:06:17 +00:00
|
|
|
extern void fsck_chk_inode_blk(struct f2fs_sb_info *, u32, enum FILE_TYPE,
|
2021-05-12 12:50:48 +00:00
|
|
|
struct f2fs_node *, u32 *, struct f2fs_compr_blk_cnt *,
|
|
|
|
struct node_info *, struct child_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int fsck_chk_dnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
|
2015-03-30 19:57:10 +00:00
|
|
|
u32, enum FILE_TYPE, struct f2fs_node *, u32 *,
|
2021-05-12 12:50:48 +00:00
|
|
|
struct f2fs_compr_blk_cnt *, struct child_info *,
|
|
|
|
struct node_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int fsck_chk_idnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
|
2021-05-12 12:50:48 +00:00
|
|
|
enum FILE_TYPE, struct f2fs_node *, u32 *,
|
|
|
|
struct f2fs_compr_blk_cnt *, struct child_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int fsck_chk_didnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
|
2021-05-12 12:50:48 +00:00
|
|
|
enum FILE_TYPE, struct f2fs_node *, u32 *,
|
|
|
|
struct f2fs_compr_blk_cnt *, struct child_info *);
|
2019-07-11 20:45:41 +00:00
|
|
|
extern int fsck_chk_data_blk(struct f2fs_sb_info *, int,
|
|
|
|
u32, struct child_info *, int, enum FILE_TYPE, u32, u16, u8, int);
|
|
|
|
extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,
|
|
|
|
u32, struct child_info *, int, int);
|
2014-10-14 22:15:40 +00:00
|
|
|
int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
|
2015-03-30 19:57:10 +00:00
|
|
|
struct child_info *);
|
f2fs-tools: relocate chksum_offset for large_nat_bitmap feature
For large_nat_bitmap feature, there is a design flaw:
Previous:
struct f2fs_checkpoint layout:
+--------------------------+ 0x0000
| checkpoint_ver |
| ...... |
| checksum_offset |------+
| ...... | |
| sit_nat_version_bitmap[] |<-----|-------+
| ...... | | |
| checksum_value |<-----+ |
+--------------------------+ 0x1000 |
| | nat_bitmap + sit_bitmap
| payload blocks | |
| | |
+--------------------------|<-------------+
Obviously, if nat_bitmap size + sit_bitmap size is larger than
MAX_BITMAP_SIZE_IN_CKPT, nat_bitmap or sit_bitmap may overlap
checkpoint checksum's position, once checkpoint() is triggered
from kernel, nat or sit bitmap will be damaged by checksum field.
In order to fix this, let's relocate checksum_value's position
to the head of sit_nat_version_bitmap as below, then nat/sit
bitmap and chksum value update will become safe.
After:
struct f2fs_checkpoint layout:
+--------------------------+ 0x0000
| checkpoint_ver |
| ...... |
| checksum_offset |------+
| ...... | |
| sit_nat_version_bitmap[] |<-----+
| ...... |<-------------+
| | |
+--------------------------+ 0x1000 |
| | nat_bitmap + sit_bitmap
| payload blocks | |
| | |
+--------------------------|<-------------+
Related report and discussion:
https://sourceforge.net/p/linux-f2fs/mailman/message/36642346/
In addition, during writing checkpoint, if large_nat_bitmap feature is
enabled, we need to set CP_LARGE_NAT_BITMAP_FLAG flag in checkpoint.
Reported-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-05-14 09:33:40 +00:00
|
|
|
void fsck_chk_checkpoint(struct f2fs_sb_info *sbi);
|
2016-03-14 06:16:53 +00:00
|
|
|
int fsck_chk_meta(struct f2fs_sb_info *sbi);
|
fsck: Check write pointer consistency of open zones
On sudden f2fs shutdown, write pointers of zoned block devices can go
further but f2fs meta data keeps current segments at positions before the
write operations. After remounting the f2fs, this inconsistency causes
write operations not at write pointers and "Unaligned write command"
error is reported.
To avoid the error, have f2fs.fsck check consistency of write pointers
of open zones that current segments point to. Compare each current
segment's position and the write pointer position of the open zone. If
inconsistency is found and 'fix_on' flag is set, assign a new zone to the
current segment and check the newly assigned zone has write pointer at
the zone start. Leave the original zone as is to keep data recorded in
it.
To care about fsync data, refer each seg_entry's ckpt_valid_map to get
the last valid block in the zone. If the last valid block is beyond the
current segments position, fsync data exits in the zone. In case fsync
data exists, do not assign a new zone to the current segment not to lose
the fsync data. It is expected that the kernel replay the fsync data and
fix the write pointer inconsistency at mount time.
Also check consistency between write pointer of the zone the current
segment points to with valid block maps of the zone. If the last valid
block is beyond the write pointer position, report to indicate a bug. If
'fix_on' flag is set, assign a new zone to the current segment.
When inconsistencies are found, turn on 'bug_on' flag in fsck_verify() to
ask users to fix them or not. When inconsistencies get fixed, turn on
'force' flag in fsck_verify() to enforce fixes in following checks.
This check and fix is done twice. The first is done at the beginning of
do_fsck() function so that other fixes can reflect the current segment
modification. The second is done in fsck_verify() to reflect updated meta
data by other fixes.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-11-28 07:59:29 +00:00
|
|
|
void fsck_chk_and_fix_write_pointers(struct f2fs_sb_info *);
|
2018-06-20 11:12:13 +00:00
|
|
|
int fsck_chk_curseg_info(struct f2fs_sb_info *);
|
2019-04-24 17:59:09 +00:00
|
|
|
void pretty_print_filename(const u8 *raw_name, u32 len,
|
|
|
|
char out[F2FS_PRINT_NAMELEN], int enc_name);
|
2014-08-27 23:16:16 +00:00
|
|
|
|
2015-12-10 00:18:44 +00:00
|
|
|
extern void update_free_segments(struct f2fs_sb_info *);
|
2015-03-20 23:57:47 +00:00
|
|
|
void print_cp_state(u32);
|
2017-11-03 04:25:12 +00:00
|
|
|
extern void print_node_info(struct f2fs_sb_info *, struct f2fs_node *, int);
|
|
|
|
extern void print_inode_info(struct f2fs_sb_info *, struct f2fs_node *, int);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern struct seg_entry *get_seg_entry(struct f2fs_sb_info *, unsigned int);
|
2015-03-27 04:27:56 +00:00
|
|
|
extern struct f2fs_summary_block *get_sum_block(struct f2fs_sb_info *,
|
|
|
|
unsigned int, int *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int get_sum_entry(struct f2fs_sb_info *, u32, struct f2fs_summary *);
|
2015-10-23 18:45:36 +00:00
|
|
|
extern void update_sum_entry(struct f2fs_sb_info *, block_t,
|
|
|
|
struct f2fs_summary *);
|
2014-08-27 23:39:23 +00:00
|
|
|
extern void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
|
2014-08-28 21:55:07 +00:00
|
|
|
extern void nullify_nat_entry(struct f2fs_sb_info *, u32);
|
|
|
|
extern void rewrite_sit_area_bitmap(struct f2fs_sb_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern void build_nat_area_bitmap(struct f2fs_sb_info *);
|
2014-08-28 00:15:55 +00:00
|
|
|
extern void build_sit_area_bitmap(struct f2fs_sb_info *);
|
2017-10-30 23:21:09 +00:00
|
|
|
extern int f2fs_set_main_bitmap(struct f2fs_sb_info *, u32, int);
|
|
|
|
extern int f2fs_set_sit_bitmap(struct f2fs_sb_info *, u32);
|
2014-08-28 00:06:17 +00:00
|
|
|
extern void fsck_init(struct f2fs_sb_info *);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int fsck_verify(struct f2fs_sb_info *);
|
|
|
|
extern void fsck_free(struct f2fs_sb_info *);
|
2019-08-09 10:52:57 +00:00
|
|
|
extern int f2fs_ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern int f2fs_do_mount(struct f2fs_sb_info *);
|
|
|
|
extern void f2fs_do_umount(struct f2fs_sb_info *);
|
2019-05-06 08:58:06 +00:00
|
|
|
extern int f2fs_sparse_initialize_meta(struct f2fs_sb_info *);
|
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 08:11:32 +00:00
|
|
|
|
2015-10-23 18:45:36 +00:00
|
|
|
extern void flush_journal_entries(struct f2fs_sb_info *);
|
2019-05-16 12:40:43 +00:00
|
|
|
extern void update_curseg_info(struct f2fs_sb_info *, int);
|
2015-12-17 01:43:34 +00:00
|
|
|
extern void zero_journal_entries(struct f2fs_sb_info *);
|
2015-10-23 18:45:36 +00:00
|
|
|
extern void flush_sit_entries(struct f2fs_sb_info *);
|
2018-05-09 02:48:33 +00:00
|
|
|
extern void move_curseg_info(struct f2fs_sb_info *, u64, int);
|
2015-12-10 04:30:41 +00:00
|
|
|
extern void write_curseg_info(struct f2fs_sb_info *);
|
2019-11-28 07:59:26 +00:00
|
|
|
extern int find_next_free_block(struct f2fs_sb_info *, u64 *, int, int, bool);
|
2019-07-17 01:28:51 +00:00
|
|
|
extern void duplicate_checkpoint(struct f2fs_sb_info *);
|
2015-10-23 18:45:36 +00:00
|
|
|
extern void write_checkpoint(struct f2fs_sb_info *);
|
2019-07-17 01:28:51 +00:00
|
|
|
extern void write_checkpoints(struct f2fs_sb_info *);
|
2018-09-28 12:25:58 +00:00
|
|
|
extern void update_superblock(struct f2fs_super_block *, int);
|
2015-10-23 18:45:36 +00:00
|
|
|
extern void update_data_blkaddr(struct f2fs_sb_info *, nid_t, u16, block_t);
|
2015-12-10 00:18:44 +00:00
|
|
|
extern void update_nat_blkaddr(struct f2fs_sb_info *, nid_t, nid_t, block_t);
|
2015-12-10 04:30:41 +00:00
|
|
|
|
2015-12-09 01:33:23 +00:00
|
|
|
extern void print_raw_sb_info(struct f2fs_super_block *);
|
2022-10-06 15:17:26 +00:00
|
|
|
extern bool is_checkpoint_stop(struct f2fs_super_block *, bool);
|
2022-10-06 15:17:27 +00:00
|
|
|
extern bool is_inconsistent_error(struct f2fs_super_block *);
|
2018-07-02 09:22:41 +00:00
|
|
|
extern pgoff_t current_nat_addr(struct f2fs_sb_info *, nid_t, int *);
|
2015-12-09 01:33:23 +00:00
|
|
|
|
2016-11-02 10:17:18 +00:00
|
|
|
extern u32 get_free_segments(struct f2fs_sb_info *);
|
2018-01-29 03:22:14 +00:00
|
|
|
extern void get_current_sit_page(struct f2fs_sb_info *,
|
|
|
|
unsigned int, struct f2fs_sit_block *);
|
2016-11-23 12:40:06 +00:00
|
|
|
extern void rewrite_current_sit_page(struct f2fs_sb_info *, unsigned int,
|
|
|
|
struct f2fs_sit_block *);
|
2016-11-02 10:17:18 +00:00
|
|
|
|
2017-02-09 02:55:43 +00:00
|
|
|
extern u32 update_nat_bits_flags(struct f2fs_super_block *,
|
|
|
|
struct f2fs_checkpoint *, u32);
|
|
|
|
extern void write_nat_bits(struct f2fs_sb_info *, struct f2fs_super_block *,
|
|
|
|
struct f2fs_checkpoint *, int);
|
2020-07-21 16:38:11 +00:00
|
|
|
extern unsigned int get_usable_seg_count(struct f2fs_sb_info *);
|
|
|
|
extern bool is_usable_seg(struct f2fs_sb_info *, unsigned int);
|
2017-02-09 02:55:43 +00:00
|
|
|
|
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 08:11:32 +00:00
|
|
|
/* dump.c */
|
|
|
|
struct dump_option {
|
|
|
|
nid_t nid;
|
2018-07-02 09:22:41 +00:00
|
|
|
nid_t start_nat;
|
|
|
|
nid_t end_nat;
|
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 08:11:32 +00:00
|
|
|
int start_sit;
|
|
|
|
int end_sit;
|
|
|
|
int start_ssa;
|
|
|
|
int end_ssa;
|
2014-05-14 00:02:55 +00:00
|
|
|
int32_t blk_addr;
|
2022-06-07 03:40:43 +00:00
|
|
|
nid_t scan_nid;
|
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 08:11:32 +00:00
|
|
|
};
|
|
|
|
|
2018-07-02 09:22:41 +00:00
|
|
|
extern void nat_dump(struct f2fs_sb_info *, nid_t, nid_t);
|
2016-10-12 21:11:19 +00:00
|
|
|
extern void sit_dump(struct f2fs_sb_info *, unsigned int, unsigned int);
|
2014-08-27 23:16:16 +00:00
|
|
|
extern void ssa_dump(struct f2fs_sb_info *, int, int);
|
2021-06-13 03:42:47 +00:00
|
|
|
extern int dump_node(struct f2fs_sb_info *, nid_t, int);
|
2014-12-13 21:55:59 +00:00
|
|
|
extern int dump_info_from_blkaddr(struct f2fs_sb_info *, u32);
|
f2fs-tools: fix to skip block allocation for fsynced data
Previously, we don't allow block allocation on unclean umounted image,
result in failing to repair quota system file.
In this patch, we port most recovery codes from kernel to userspace
tools, so that on unclean image, during fsck initialization, we will
record all data/node block address we may recover in kernel, and
then during allocation of quota file repair, we can skip those blocks
to avoid block use conflict.
Eventually, if free space is enough, we can repair the quota system
file on an unclean umounted image.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
[Jaegeuk Kim: remove unnecessary parameter]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-08-14 08:48:55 +00:00
|
|
|
extern unsigned int start_bidx_of_node(unsigned int, struct f2fs_node *);
|
2022-06-07 03:40:43 +00:00
|
|
|
extern void dump_node_scan_disk(struct f2fs_sb_info *sbi, nid_t nid);
|
f2fs-tools: fix to skip block allocation for fsynced data
Previously, we don't allow block allocation on unclean umounted image,
result in failing to repair quota system file.
In this patch, we port most recovery codes from kernel to userspace
tools, so that on unclean image, during fsck initialization, we will
record all data/node block address we may recover in kernel, and
then during allocation of quota file repair, we can skip those blocks
to avoid block use conflict.
Eventually, if free space is enough, we can repair the quota system
file on an unclean umounted image.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
[Jaegeuk Kim: remove unnecessary parameter]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-08-14 08:48:55 +00:00
|
|
|
|
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 08:11:32 +00:00
|
|
|
|
2015-10-23 18:45:36 +00:00
|
|
|
/* defrag.c */
|
|
|
|
int f2fs_defragment(struct f2fs_sb_info *, u64, u64, u64, int);
|
|
|
|
|
2015-12-09 00:05:09 +00:00
|
|
|
/* resize.c */
|
|
|
|
int f2fs_resize(struct f2fs_sb_info *);
|
2015-12-10 00:18:44 +00:00
|
|
|
|
|
|
|
/* sload.c */
|
2017-11-30 01:21:12 +00:00
|
|
|
int f2fs_sload(struct f2fs_sb_info *);
|
2017-10-30 23:21:09 +00:00
|
|
|
|
|
|
|
/* segment.c */
|
2019-04-15 09:14:38 +00:00
|
|
|
int reserve_new_block(struct f2fs_sb_info *, block_t *,
|
2019-08-05 09:44:06 +00:00
|
|
|
struct f2fs_summary *, int, bool);
|
2018-10-01 01:16:38 +00:00
|
|
|
int new_data_block(struct f2fs_sb_info *, void *,
|
2015-12-10 00:18:44 +00:00
|
|
|
struct dnode_of_data *, int);
|
|
|
|
int f2fs_build_file(struct f2fs_sb_info *, struct dentry *);
|
2019-08-05 09:44:06 +00:00
|
|
|
void f2fs_alloc_nid(struct f2fs_sb_info *, nid_t *);
|
2015-12-10 00:18:44 +00:00
|
|
|
void set_data_blkaddr(struct dnode_of_data *);
|
|
|
|
block_t new_node_block(struct f2fs_sb_info *,
|
|
|
|
struct dnode_of_data *, unsigned int);
|
f2fs-tools: rebuild the quota inode if it is corrupted
commit 1228009520d1d2cb392ae52f8aaf3c6ec42edccf
category: bugfix
issue: #I6VAS0
CVE: NA
Signed-off-by: DongSenhao <dongsenhao2@huawei.com>
---------------------------------------
If the following process returns an error,
the quota inode, not the quota file, is damaged.
(fsck_chk_quota_node-->fsck_chk_node_blk-->sanity_check_nid)
The fsck does not have a process to rebuild the quota inode.
Because sanity_check_nid is not passed, fsck->nat_area_bitmap
can not be cleared, and then the NAT of quota will be nullify
during fix_nat_entries.
During the next fsck check, the quota inode check fails
because the address of the quota inode changes to 0.
In addition, in fsck_chk_quota_files-->f2fs_filesize_update,
data is written to address 0.
Therefore, when the quota inode is corrupted, we need to rebuild it.
Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
2021-07-20 06:41:18 +00:00
|
|
|
int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype);
|
2017-10-30 21:26:30 +00:00
|
|
|
|
|
|
|
/* segment.c */
|
2020-02-05 07:41:57 +00:00
|
|
|
struct quota_file;
|
|
|
|
u64 f2fs_quota_size(struct quota_file *);
|
2017-11-02 17:41:16 +00:00
|
|
|
u64 f2fs_read(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
|
2020-12-08 08:15:54 +00:00
|
|
|
enum wr_addr_type {
|
|
|
|
WR_NORMAL = 1,
|
|
|
|
WR_COMPRESS_DATA = 2,
|
|
|
|
WR_NULL_ADDR = NULL_ADDR, /* 0 */
|
|
|
|
WR_NEW_ADDR = NEW_ADDR, /* -1U */
|
|
|
|
WR_COMPRESS_ADDR = COMPRESS_ADDR, /* -2U */
|
|
|
|
};
|
2017-11-02 17:41:16 +00:00
|
|
|
u64 f2fs_write(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
|
2020-12-08 08:15:54 +00:00
|
|
|
u64 f2fs_write_compress_data(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
|
|
|
|
u64 f2fs_write_addrtag(struct f2fs_sb_info *, nid_t, pgoff_t, unsigned int);
|
2017-10-30 21:26:30 +00:00
|
|
|
void f2fs_filesize_update(struct f2fs_sb_info *, nid_t, u64);
|
|
|
|
|
2018-10-01 01:16:38 +00:00
|
|
|
int get_dnode_of_data(struct f2fs_sb_info *, struct dnode_of_data *,
|
2015-12-10 00:18:44 +00:00
|
|
|
pgoff_t, int);
|
2017-07-26 14:49:57 +00:00
|
|
|
void make_dentry_ptr(struct f2fs_dentry_ptr *, struct f2fs_node *, void *, int);
|
2015-12-10 00:18:44 +00:00
|
|
|
int f2fs_create(struct f2fs_sb_info *, struct dentry *);
|
|
|
|
int f2fs_mkdir(struct f2fs_sb_info *, struct dentry *);
|
|
|
|
int f2fs_symlink(struct f2fs_sb_info *, struct dentry *);
|
|
|
|
int inode_set_selinux(struct f2fs_sb_info *, u32, const char *);
|
|
|
|
int f2fs_find_path(struct f2fs_sb_info *, char *, nid_t *);
|
2018-03-06 03:39:40 +00:00
|
|
|
nid_t f2fs_lookup(struct f2fs_sb_info *, struct f2fs_node *, u8 *, int);
|
|
|
|
int f2fs_add_link(struct f2fs_sb_info *, struct f2fs_node *,
|
|
|
|
const unsigned char *, int, nid_t, int, block_t, int);
|
2020-12-10 15:28:11 +00:00
|
|
|
struct hardlink_cache_entry *f2fs_search_hardlink(struct f2fs_sb_info *sbi,
|
|
|
|
struct dentry *de);
|
2015-12-10 00:18:44 +00:00
|
|
|
|
2017-11-02 03:56:07 +00:00
|
|
|
/* xattr.c */
|
|
|
|
void *read_all_xattrs(struct f2fs_sb_info *, struct f2fs_node *);
|
|
|
|
|
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 08:11:32 +00:00
|
|
|
#endif /* _FSCK_H_ */
|