If a directory has no dot and dotdot dentries, fsck.f2fs sets inline_dots for
the inode so that f2fs module can handle that properly.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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>
This patch is to show the checkpoint flag.
With this flag, we can guess the last status of the partition.
And, this can be used by xfstests.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
include/f2fs_fs.h checks the HAVE_BSWAP_64 conidtional, but configure
nevers checks for it.
Add a check that the function is indeed declared, and fix the variable
name to match the naming scheme of autoconf (and not those of WAF like
is used by samba), and adapt the check as suggested in the autoconf
manual.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch tries to simplify coding style for readability.
Rename shortly
o rename super_block to sb
And, introduce some macros.
o set/get_cp
o set/get_sb
o next/prev_zone, last_zone and last_section
o ALIGN, SEG_ALIGN and ZONE_ALIGN
Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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>
If a dentry has a bad ino (fsck_chk_nod_blk() fails)
and has a name len of 0, then __chk_dentries() will end up stuck:
....
[__chk_dentries: 663] [ 4]-[0x0] name[] len[0x0] ino[0x5f1710dc] type[0xd1]
[ASSERT] (sanity_check_nid: 184) --> nid is not valid. [0x5f1710dc]
[__chk_dentries: 663] [ 4]-[0x0] name[] len[0x0] ino[0x5f1710dc] type[0xd1]
[ASSERT] (sanity_check_nid: 184) --> nid is not valid. [0x5f1710dc]
[__chk_dentries: 663] [ 4]-[0x0] name[] len[0x0] ino[0x5f1710dc] type[0xd1]
[ASSERT] (sanity_check_nid: 184) --> nid is not valid. [0x5f1710dc]
....
This change tries to identify bad dentries:
- is the ino a valid NID?
- is the FILE_TYPE a happy type?
Change-Id: I5fb2f3869c96f2c928baaace148de1af102e558e
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch fixes build failure on big-endian systems.
Reported-and-Tested-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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>
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>
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>
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>
* 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>
Support an fs_io dev_fill().
This helps with devices that actually already return 0 on uninitialized
data. It also helps with in memory devices using sparse libs: don't
allocate a block of 0s.
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This patch synchronizes mkfs with the latest f2fs configuration in which
supports large directory by assigning dir_level.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Would do 64 BITS_PER_LONG when CONFIG_64BIT was NOT defined,
causing BITS_PER_LONG to be wrong on 32bit systems.
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
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>
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>
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>
This patch adds an option to disable trim command at format.
Default operation sends trim command to device.
Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Mkfs copies labels up to 512 characters into a the 16 character buffer
config.vol_label corrupting memory afterwards and causing a core dump.
# mkfs.f2fs -l aaaaaaaaaabbbbbbbbbbcccccccccc /dev/sda12
F2FS-tools: mkfs.f2fs Ver: 1.1.0 (2013-03-08)
Info: Label = aaaaaaaaaabbbbbbbbbbcccccccccc
Info: sector size = 512
Info: total sectors = 2097152 (in 512bytes)
Info: zone aligned segment0 blkaddr: 256
Segmentation fault (core dumped)
Make config.vol_label a pointer to the label in argv, rather than
copying it into a too small buffer.
Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>