Commit Graph

395 Commits

Author SHA1 Message Date
Jin Qian
b79c3ba4ea fsck.f2fs: sanity check cp_payload before reading checkpoint
cp_payload is not sanity checked from input image. A invalid size
can cause buffer overflow when reading checkpoint blks into memory.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-27 12:51:09 -07:00
Jin Qian
d87fc37b02 fsck.f2fs: sanity check blk_off for summary block entries
crafted malicious f2fs partition can fill an out of bound blk_off,
which cause overflow when accessing summary block entries.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-27 12:42:58 -07:00
Jaegeuk Kim
33ddf01c79 mkfs.f2fs: fix wrong segment assignment
We must guarantee that current segments should be different between different
logs.
This should resolve xfstests/generic/015 panic.

Fixes: 8f9327c0c0 ("mkfs.f2fs: use noheap by default")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-25 17:53:21 -07:00
Jin Qian
6ab50775fa f2fs-tools: sanity check segment count
make sure segment count in super block doesn't exceed F2FS_MAX_SEGMENT.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-25 16:37:37 -07:00
Jin Qian
8a51985120 fsck.f2fs: fix cur_valid_map buffer overflow
blk_off is read from image. Attacker can construct an image with big
blk_off that trigger overflow on se->cur_valid_map.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:59 -07:00
Yong, Jonathan
0f9e1e23da Fix mkfs out of tree builds
Libraries are built in builddir, not srcdir, fix Makefile.am
accordingly.

Signed-off-by: Yong, Jonathan <jonathan.yong@intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:59 -07:00
Jaegeuk Kim
8f9327c0c0 mkfs.f2fs: use noheap by default
Let's set noheap by default.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:56 -07:00
Kinglong Mee
f57dee09fb libf2fs: avoid overwrite the c.start_sector by non-root device
For multiple devices, the c.start_sector will be overwrite by the non-root devices.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 23:14:23 -04:00
Kinglong Mee
0f3045d3e8 sload.f2fs: support sload files into directory includes inline dentry
It seems the new created directory always includes inline dentries,
let sload.f2fs supporting it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:46:10 -04:00
Kinglong Mee
9a4df3c466 sload.f2fs: let dir_buckets/dir_block_index supports dir_level
The dir_level in the filesystem maybe larger than zero,
supports it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:47 -04:00
Kinglong Mee
7b03ccbb9b fsck.f2fs: check encrypted filename depends FADVISE_ENC_NAME_BIT
An encrypted directory under an unencrypted directory, the filename isn't encrypted.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:37 -04:00
Kinglong Mee
5e6526940e fsck.f2fs: fix bad notice of missing device
The following messages is better than before.

Before,
# fsck.f2fs -d 1
    Error: Need argument for -d

Now,
# fsck.f2fs -d 1
Info: Debug level = 1
        Error: Device not specified

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:21 -04:00
Kinglong Mee
8e710d1d71 sload.f2fs: fix missing SSA updates
If sload many larger files to disk, the SSA that doesn't cached will be missed.

Mar 17 12:04:39 localhost kernel: ------------[ cut here ]------------
Mar 17 12:04:39 localhost kernel: kernel BUG at fs/f2fs/gc.c:899!
Mar 17 12:04:39 localhost kernel: invalid opcode: 0000 [#1] SMP
Mar 17 12:04:39 localhost kernel: Modules linked in: f2fs tun bridge stp llc fuse ip_set nfnetlink vmw_vsock_vmci_transport vsock snd_seq_midi snd_seq_midi_event snd_ens1371 gameport snd_ac97_codec coretemp ac97_bus crct10dif_pclmul crc32_pclmul ppdev snd_seq snd_pcm ghash_clmulni_intel intel_rapl_perf vmw_balloon snd_rawmidi joydev snd_timer snd_seq_device snd soundcore parport_pc parport nfit acpi_cpufreq tpm_tis tpm_tis_core shpchp vmw_vmci tpm i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc xfs libcrc32c vmwgfx drm_kms_helper ttm drm e1000 crc32c_intel mptspi scsi_transport_spi serio_raw mptscsih mptbase ata_generic pata_acpi fjes
Mar 17 12:04:39 localhost kernel: CPU: 0 PID: 6427 Comm: f2fs_gc-8:33 Tainted: G        W       4.10.0-f2fs+ #25
Mar 17 12:04:39 localhost kernel: Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/02/2015
Mar 17 12:04:39 localhost kernel: task: ffff94ba7d998000 task.stack: ffffb6e4c2e50000
Mar 17 12:04:39 localhost kernel: RIP: 0010:do_garbage_collect+0xa39/0xb60 [f2fs]
Mar 17 12:04:39 localhost kernel: RSP: 0018:ffffb6e4c2e53cc0 EFLAGS: 00010213
Mar 17 12:04:39 localhost kernel: RAX: ffff94baa0427000 RBX: 0000000000000001 RCX: 0000000000000002
Mar 17 12:04:39 localhost kernel: RDX: 0000000000000000 RSI: fffff5e2c28109c0 RDI: fffff5e2c28109c0
Mar 17 12:04:39 localhost kernel: RBP: ffffb6e4c2e53dc0 R08: ffff94ba7dfc72f0 R09: fffff5e2c28109dc
Mar 17 12:04:39 localhost kernel: R10: 0000000000000040 R11: ffff94ba7dfc7238 R12: 0000000000000418
Mar 17 12:04:39 localhost kernel: R13: fffff5e2c28109c0 R14: 0000000000000417 R15: ffff94ba3c021000
Mar 17 12:04:39 localhost kernel: FS:  0000000000000000(0000) GS:ffff94babb600000(0000) knlGS:0000000000000000
Mar 17 12:04:39 localhost kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Mar 17 12:04:39 localhost kernel: CR2: 00007fc42a0d7000 CR3: 00000000a7e94000 CR4: 00000000001406f0
Mar 17 12:04:39 localhost kernel: Call Trace:
Mar 17 12:04:39 localhost kernel: ? find_next_bit+0xb/0x10
Mar 17 12:04:39 localhost kernel: f2fs_gc+0x111/0x480 [f2fs]
Mar 17 12:04:39 localhost kernel: ? prepare_to_wait_event+0x79/0x160
Mar 17 12:04:39 localhost kernel: gc_thread_func+0x2d0/0x3f0 [f2fs]
Mar 17 12:04:39 localhost kernel: ? __schedule+0x273/0x860
Mar 17 12:04:39 localhost kernel: ? remove_wait_queue+0x70/0x70
Mar 17 12:04:39 localhost kernel: kthread+0x101/0x140
Mar 17 12:04:39 localhost kernel: ? f2fs_gc+0x480/0x480 [f2fs]
Mar 17 12:04:39 localhost kernel: ? kthread_park+0x90/0x90
Mar 17 12:04:39 localhost kernel: ret_from_fork+0x2c/0x40
Mar 17 12:04:39 localhost kernel: Code: 48 8d 84 24 90 00 00 00 48 89 c7 48 89 44 24 28 e8 7d cc ba e6 e9 17 fa ff ff 48 c7 c6 48 3f 84 c0 48 89 c7 e8 59 8d 9d e6 0f 0b <0f> 0b 48 c7 c6 48 3f 84 c0 4c 89 ff e8 46 8d 9d e6 0f 0b 8b b4
Mar 17 12:04:39 localhost kernel: RIP: do_garbage_collect+0xa39/0xb60 [f2fs] RSP: ffffb6e4c2e53cc0
Mar 17 12:04:39 localhost kernel: ---[ end trace 926d61b064ed1f2d ]---

Fixes: 767a93ea8b ("defrag.f2fs: fix missing SSA updates")
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-17 20:47:08 +08:00
Kinglong Mee
6fb673abc0 fsck.f2fs: a separate option for showing directory tree
Showing directory tree reuses dbg_lv that if setting "-t",
fsck.f2fs does not show any others.
Users may want much information include the debug info and directory tree.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:16:39 +08:00
Kinglong Mee
7f00dd441c f2fscrypt: add a tool for encryption management in the f2fs filesystem
It's migrated from e4crypt.
Adds an example to the f2fscrypt manpages.

v3, add /tools/f2fscrypt to .gitignore
v2, migrate those micro defines for encrypt to f2fs internal,
    drop unless of libsha etc.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:15:37 +08:00
Kinglong Mee
802b6499bd fsck.f2fs: sanity check of crc_offset from raw checkpoint
The crc_offset towards or beyond the end of block is wrong,
sanity check it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:15:12 +08:00
Yunlei He
78ad88d1d2 resize.f2fs: fix a resize fail for sector size mismatch
This patch fix a resize faill for sector size mismatch.
The initial fs comes from an image file, with sector size
512KB, and the block device sector size is equal to block
size.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:13:58 +08:00
Kinglong Mee
52a3a273d1 mkfs.f2fs: check overwrite before make filesystem
Mkfs.f2fs doesn't check the overwrite of exist filesystem.
Avoid formatting an exist filesystem by mistake, a notice is important.
The code is modified from xfsprogs.

v3, add the missing update of SYNOPSIS
v2, add the manpages description of -f.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-06 17:15:26 -08:00
Kinglong Mee
2f52fcf698 mkfs.f2fs: clearfiy the help message and manpages
Add some missing options in manpages, also order those options.

v3, add the missing update of SYNOPSIS

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-06 17:14:42 -08:00
Jaegeuk Kim
191573e71b mkfs.f2fs: support nat_bits feature
This patch adds nat_bits in the last one ore two 4KB-sized blocks of first
checkpoint segment. So, now a set of checkpoint *segment* consists of:

< checkpoint segment >
----------------------
| cp page #1         | 4KB
----------------------
| compacted data sum | 4KB
----------------------
| node sum  #1       | 4KB
----------------------
| node sum  #2       | 4KB
----------------------
| node sum  #3       | 4KB
----------------------
| cp page #2         | 4KB
----------------------
...
----------------------
| crc|cpver          | 8 bytes
----------------------
| full NAT bits      | # of NAT segments / 2 * 512 / 8 bytes
----------------------
| empty NAT bits     | # of NAT segments / 2 * 512 / 8 bytes
----------------------

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Jaegeuk Kim
f081d54ba8 fsck.f2fs: fix wrong usage out
This fixes wrong messages for error out.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Jaegeuk Kim
a0bd5b9822 f2fs-tools: catch up up-to-date checkpoint flag
It needs to use up-to-date ckpt flag.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Kinglong Mee
9edcda5ec7 mkfs.f2fs: make sure clean all reset dnodes
memset(raw_node, 0, F2FS_BLKSIZE) sets the next_blkaddr to zero,
so that, only one reset dnode is cleaned always.

Fixes: ad042d9194 "mkfs.f2fs: reset dnode with zeros",
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:35 -08:00
Kinglong Mee
a2b7afa16d mkfs.f2fs: check the c.overprovision with zero before using it
The using of c.overprovision when it equal zero as,

        c.reserved_segments =
                        (2 * (100 / c.overprovision + 1) + 6)
                        * c.segs_per_sec;

may cause problem, although it doesn't happen.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-06 14:49:50 -08:00
Sheng Yong
2b4b86066b resize.f2fs: correct checkpoint_ver of new checkpoint
resize.f2fs rebuilds a new checkpoint at the new position. Its
checkpoint_ver should be increased.

Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Signed-off-by: Weichao Guo <guoweichao@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-06 14:49:39 -08:00
Jaegeuk Kim
1e7aedf99b f2fs-tools: release 1.8.0
This release includes:
 - enhance fsck.f2fs mostly.
 - retrieve lost files from dump.f2fs.
 - support zoned device and multiple devices.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-03 16:10:17 -08:00
Kinglong Mee
ad1bb005b9 mkfs.f2fs: fix bad assignment of total_sectors for f2fs_configuration
wanted_total_sectors is introduced instead total_sectors,
so that, the initialize is a fault, drop it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-03 10:29:44 -08:00
Jaegeuk Kim
b4436b086e fsck.f2fs: remove wrong dentry due to hash conversion
This patch removes stale dentries remained by hash conversion issue which
happened long time ago.

Fixes: aafe2ca3dc ("fsck.f2fs: fix wrong hash_code made by previous buggy code")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-01 10:33:54 -08:00
Liu Xue
5d9032fd1b fsck.f2fs: always fix seg entry type if it is not DATA
If the segment type and sum footer type are node, but its
sit type is corrupted as cold data, this will always trigger
type error crash in do_garbage_collect but not get fixed by fsck,
so fix seg entry type when it is not DATA.

Reported-by: KARBOWSKI Piotr <piotr.karbowski@gmail.com>
Signed-off-by: Liu Xue <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-24 13:38:17 +09:00
Kinglong Mee
ada65254f6 mkfs.f2fs: fix a segfault when setting more than 7 devices
[root@localhost f2fs-tools]# mkfs.f2fs -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 -c /dev/sdb1 /dev/sdb1

kernel: mkfs.f2fs[9047]: segfault at 2b78a60f ip 0000000000401356 sp 00007fffde05c9c0 error 6 in mkfs.f2fs[400000+5000]

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-24 09:31:39 +09:00
Jaegeuk Kim
88753dbcf3 fsck.f2fs: show parse errors neatly
This patch is just to clean up.

Cc: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-21 14:00:15 +08:00
Jaegeuk Kim
ed031d6b24 fsck.f2fs: support -p without argument
This patch allows fsck run -p without argument. So we could use -p as
-p, -p 0, -p 1. '-p' and '-p 0' have the same meaning as '-a'. '-p 1'
check more meta data than '-a'.

Reported-by: KARBOWSKI Piotr <piotr.karbowski@gmail.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-21 13:28:18 +08:00
Sheng Yong
9deb6fd9f2 f2fs-tools: correct endianness
It is reported that fsck.f2fs behaves abnormally when running on MIPS32
rel 2 big endian cpu, since incorrect endianness. So let's correct all
endianess issues of f2fs-tools.

Reported-by: <k@vodka.home.kg>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-19 15:29:08 +08:00
Sergey Kvachonok
0d6ce1f566 Add a configure option for SELinux support
./configure --without-selinux :: unconditionally disable SELinux support

./configure --with-selinux :: enable SELinux support and abort if
libselinux is not found

When no configure option is specified the current libselinux
autodetection behaviour is preserved.

Signed-off-by: Sergey Kvachonok <ravenexp@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-01-13 11:01:19 -08:00
Jaegeuk Kim
33dacab9a8 fsck.f2fs: fix wrong i_name check for directory
We should not check the consistency between i_name and its dentry for directory.
The i_name is used only for normal file recovery when conducting roll-forward
recovery.

Moreover, this condition was totally missing encryption case which is breaking by

1. encrypt ./test
2. mkdir ./test/a
3. mkdir ./test/b
4. rename ./test/a ./test/b

-> fsck.f2fs reports wrong inconsistency in terms of i_name.

Reported-by: liushuoran <liushuoran@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-12-22 13:53:18 -08:00
Yunlei He
d466dea52f resize.f2fs: remove unused parameters
This patch remove unused parameters in these three functions:
get_new_sb, migrate_main and rebuild_superblock

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-12-12 11:09:30 -08:00
Junling Zheng
e8768a998d resize.f2fs: fix the number of moved ssa blocks in migrate_ssa
If the offset passed in migrate_ssa is not zero, it means that there're
offset segments of old main will disappear after migrating, then there're
offset blocks of old ssa should be invalidated and removed accordingly.
So, the number of moved ssa blocks should be: TOTAL_SEGS(sbi) - offset,
and the expanded summary, which is filled with zero_blocks, should start
from: new_sum_blkaddr + TOTAL_SEGS(sbi) - offset.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-12-01 15:12:46 -08:00
Sheng Yong
361b0185ed fsck.f2fs: remove duplicated header files
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-28 21:26:15 -08:00
Junling Zheng
1d81a373bd resize.f2fs: correct the max segno in migrate_main
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-28 21:26:15 -08:00
Jaegeuk Kim
0a48220641 mkfs.f2fs: detect small partition by overprovision ratio and # of segments
We should avoid zero overprovision ratio or # of segments caused by too small
device.

Reported-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-28 21:26:15 -08:00
Jaegeuk Kim
8399a29df9 mkfs.f2fs: give random checkpoint version
This is to avoid wrong recovery during xfstests.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-28 21:26:12 -08:00
Liu Xue
b88767e606 fsck.f2fs: flush curseg sit entries
Flush curseg sit entries, since type of sit entries may
be changed after move_curseg_info.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-23 10:12:56 -08:00
Yunlei He
b5e7d4449d dump.f2fs: fix an error in dump nat pack num
This patch fix an error in dump nat pack num

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-21 17:02:33 -08:00
Yunlei He
4f1ded4ad2 fsck.f2fs add a simple check orphan inodes in -p 1 mode
This patch add a simple check orphan inodes in -p 1 mode

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-21 17:02:26 -08:00
Jaegeuk Kim
bb91228318 README: revisit README to fix typos and so on
This patch fixes typos and enhance description.

Suggested-by: Rob Maris <rob@maris-ee.eu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-14 16:31:38 -08:00
Jaegeuk Kim
f407393385 f2fs-tools: initialize and avoid build warning for android
This patch initialize one variable for android build.
In addition, it avoids there-in build warnings.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-10 14:17:16 -08:00
Jaegeuk Kim
de7e07e011 f2fs-tools: support multiple devices
This patch adds an option to specify multiple devices for an f2fs instance.

Up to 7 devices in addition to the default device can be added.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-09 18:03:47 -08:00
Junling Zheng
ea1bd1ce31 fsck.f2fs: refactor build_nat_area_bitmap to speed up fsck
Refactor build_nat_area_bitmap, move out lookup_nat_in_journal from the
dual loops. Instead of looking up all nids in journals, we traverse nat
journals, whose entries are used to replace the NAT entries with the
corresponding nid to reduce the time build_nat_area_bitmap costs.

For "fsck -p 1", it reduces over half of the time.

		Empty		Fragmented Entirely
32G(ms):
  original	625.8		727.3
  improved	226.3		298.2
64G(ms):
  original	1159		1637.7
  improved	515.8		676.7

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-07 17:05:51 -08:00
Yunlei He
5e056bef17 resize.f2fs: modify condition for resize
it better to decide resize or not by sector num.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-07 09:57:52 -08:00
Yunlei He
890e9b325d fsck.f2fs: add a judgment after calloc
This patch add a judgment after calloc avoid memory alloc
failure

Signed-off-by: Yunlei He <heyunlei@huawei.com>
[Jaegeuk Kim: remove unneeded memset to avoid build warning]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-11-04 16:08:19 -07:00