Commit Graph

748 Commits

Author SHA1 Message Date
Yunlei He
e9dfbbbce9 mkfs.f2fs: introduce zone align for main area
This patch calculate main area begin from a new zone,
avoid misalign if segments per zone is not 1.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2016-01-08 11:47:41 -08:00
Sheng Yong
2d3ea141cc fsck.f2fs: fix double free invalid checkpoint
The invalid checkpoin is freed in validate_checkpoint().

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-28 14:33:12 -08:00
Jaegeuk Kim
d3258fa034 man: modify mkfs.f2fs man page
This patch adds missing [sectors] option in mkfs.f2fs, and removes
meaningless version.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-22 16:19:44 -08:00
Jaegeuk Kim
52dedc6b2f man: add missing man pages
This patch adds missing man pages.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-22 16:19:44 -08:00
Jaegeuk Kim
ffd8d0514a f2fs-tools: release 1.6.0
This version introduces defrag.f2fs newly, and some major bug fixes too.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-21 09:57:10 -08:00
Liu Xue
e12a3c3a82 mkfs.f2fs: fix check error when calloc sum_compact failure
We should check sum_compact value when deal with sum_compact
calloc failure.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-21 09:48:58 -08:00
Jaegeuk Kim
a828ebb234 fsck.f2fs: fix losing journal entries
If fsck.f2fs reports a bug, move_curseg_info tries to change the current
segment info.
When it changes the new summary block, it overwrites the existing journal
entries.
This patch fixes it not to overwrite journal entry space.

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

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

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-19 03:27:11 -08:00
Chao Yu
dbe78ae529 libf2fs: fix incorrect type define of declaration
When compiling f2fs toolset in 32-bits machine, following error was
reported:

libf2fs.c:342:5: error: conflicting types for 'find_next_bit_le'
../include/f2fs_fs.h:864:22: note: previous declaration of 'find_next_bit_le' was here
libf2fs.c:348:5: error: conflicting types for 'find_next_zero_bit_le'
../include/f2fs_fs.h:865:22: note: previous declaration of 'find_next_zero_bit_le' was here

This is because our type of return value(u64 in define) and (unsigned long
in declaration) of find_next_{,zero_}bit_le were not same in non-64-bits
machine:

extern unsigned long find_next_bit_le(const u8 *, u64, u64);
u64 find_next_bit_le(const u8 *addr, u64 size, u64 offset)

Fix it.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-18 14:13:05 -08:00
Jaegeuk Kim
d6147940b9 defrag.f2fs: return error if there is no space
This patch checks whether there is a space or not to allocate new blocks.

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

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

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-15 18:14:48 -08:00
Jaegeuk Kim
b008605e99 lib: use u8/u32/u64 for bit operations
This cleans up the bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-15 11:15:00 -08:00
Jaegeuk Kim
ee65f6ebf2 lib: fix test_bit_le functions
This patch fixes test_bit_le functions for dentry bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-15 10:40:37 -08:00
Jaegeuk Kim
c8514f82aa mkfs.f2fs: remove extent_cache entry for parent directory
Currently, directory should not have any extent cache entry.
Otherwise, fsck.f2fs will trigger a false-alarmed report.

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

Many conversion codes are copied from exfat-tools.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-14 16:35:39 -08:00
Liu Xue
0ff98a3679 fsck.f2fs: deal with realloc size and realloc failure
Deal with realloc failure to avoid memory leak and memory free,
and assert realloc size to avoid double free for tree_mark.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-14 10:11:48 -08:00
Jaegeuk Kim
25e7128efa Revert "fsck.f2fs: deal with realloc failure"
This reverts commit 43095ca4c2.
2015-12-14 10:11:48 -08:00
Chao Yu
0fddd6e563 mkfs.f2fs: fix to calculate left space of checkpoint page correctly
We reserved one segment for NAT region at least, so when formatting
fs, calculated maximum size of left space in CP page should be:
CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64 (size of
reserved NAT bitmap).

Fix the incorrect calculated size to avoid potential overflow bug here.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-14 10:11:48 -08:00
Jaegeuk Kim
2c1ebe237a defrag.f2fs: introduce defragmentation tool
This tool tries to move the valid blocks ranging from blkaddr to blkaddr + len
to targeted blkaddr with a direction like expand or shrink.

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

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

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

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

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

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-10 19:46:28 -08:00
Jaegeuk Kim
c8ce2bf7b1 mkfs.f2fs: export get_best_overprovision
This patch exports get_best_overprovision() function.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-10 19:46:28 -08:00
Jaegeuk Kim
c605c5eb4c fsck.f2fs: sanity_check for extent_cache entry
This patch adds to check the stored extent_cache entry is consistent or not.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-10 19:46:28 -08:00
Jaegeuk Kim
1ea31c47f4 libf2fs: enhance the bit operations
This patch modifies the existing bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-10 19:46:22 -08:00
Jaegeuk Kim
85aa525057 f2fs-tools: add library version info
This patch gives the version info for two libraries.

mkfs/libf2fs_format.la
lib/libf2fs.la

The versioning rule should be:

1. Start with version information of '0:0:0' for each libtool library.
2. Update the version information only immediately before a public release of
   your software. More frequent updates are unnecessary, and only guarantee
   that the current interface number gets larger faster.
2. If the library source code has changed at all since the last update, then
   increment revision (c:r:a) becomes (c:r+1:a).
3. If any interfaces have been added, removed, or changed since the last update,
   increment current, and set revision to 0.
4. If any interfaces have been added since the last public release, then
   increment age.
5. If any interfaces have been removed or changed since the last public release,
   then set age to 0.

quoted from:
http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-09 11:08:45 -08:00
Kai-Chung Yan
d6b0f7091a mkfs/Makefile.am: add a section to build libf2fs_fmt
libf2fs_fmt is compiled from the same sources of mkfs.f2fs. This library is
required by libf2fs_utils and fastboot from the Android Open Source Project
and we believe the Android SDK maintainers from Debian will greatly benefit
from this change.

Signed-off-by: Kai-Chung Yan <seamlikok@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-09 10:26:26 -08:00
Jaegeuk Kim
3894c697ce mkfs.f2fs: show correct partition size
It needs to consider different sector size when showing the total
size.

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

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 21:36:03 -08:00
Jaegeuk Kim
06a19451ee mkfs.f2fs: export get_{sb|cp} and set_{sb|cp}
This patch exports get_sb, set_sb, get_cp, and set_cp for other tools.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 21:36:03 -08:00
Jaegeuk Kim
c93711f36c mkfs.f2fs: discard obsolete blocks to avoid roll-forward recovery
If there are many obsolete blocks written by previous usage, we can recover
wrong blocks with them.
So, mkfs should discard whole wrong information correctly by removing possible
same checkpoint versions.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 21:34:16 -08:00
Chao Yu
c9274cb646 mkfs.f2fs: skip extension name that is too long
The length of extension name has a limit of 8 bytes. If an extension
exceeds the limitation, it will not be added to the extension_list.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 13:38:02 -08:00
Sheng Yong
1540a28ca9 mkfs.f2fs: avoid dumplicate extensions
Before copying an user specified extension to extension_list, check if it
is already in the list. User specified extensions are delimitted by token
either ',' or ' '.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 13:37:38 -08:00
Liu Xue
43095ca4c2 fsck.f2fs: deal with realloc failure
Deal with realloc failure to avoid memory leak and memory free.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-12-02 13:35:46 -08:00
Jaegeuk Kim
67de42f76a fsck.f2fs: support a readonly filesystem
If f2fs is mounted as ro, we can do fsck.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-11-22 11:26:52 +08:00
Jaegeuk Kim
ee48fd2ced fsck.f2fs: declare static function
This avoids the following warning.

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

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-11-22 11:26:52 +08:00
Jaegeuk Kim
c134e0eb2b f2fs-tools: release 1.5.0
This version includes bug fixes on fsck.f2fs and also support of more precise
overprovision selection and a preen mode.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-11-05 10:47:04 -08:00
Jaegeuk Kim
5489249c23 fsck.f2fs: support a preen mode
Generic fsck uses -p, preen mode, and fsck.f2fs can support it as -a for now.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-10-23 14:03:29 -07:00
Jaegeuk Kim
2cdb04b52f mkfs.f2fs: support <1% overprovision ratio
Big partition size needs uner 1% overprovision space to acquire more space.

    section  ovp ratio  ovp size
For 8TB,
    -s1    : 0.07%     -> 10GB
    -s32   : 0.39%     -> 65GB
    -s64   : 0.55%     -> 92GB
    -s128  : 0.78%     -> 132GB

For 128GB,
    -s1    : 0.55%     -> 1.4GB
    -s32   : 3.14%     -> 8GB
    -s64   : 4.45%     -> 12GB
    -s128  : 6.32%     -> 17GB

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-09-25 10:32:12 -07:00
Jaegeuk Kim
e8766f2887 fsck.f2fs: check sit types for node or data only
Previously, check_sit_types didn't handle different numbers of active logs and
SSR cases. But, it didn't cause any problem since fixing sit types is harmless.
Nevertheless, we still don't need to change them all.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-09-24 09:52:14 -07:00
Jaegeuk Kim
555138c23b man: fix missing description for overprovision ratio
This patch updates mkfs.f2fs man page to indicate the automatic ovp
calculation.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-09-23 15:20:49 -07:00
Jaegeuk Kim
6e2b58dcaf mkfs.f2fs: fix wrong ovp space calculation on large section
If a section consists of multiple segments, we should change the equation
to apply it on reserved space.

On 128GB,

option                 overprovision area         reserved area
-o5 -s128              9094                       6144
-o5 -s64               6179                       3072
-o5 -s1                3309                       48
-o1 -s128              27009                      26624
-o1 -s64               13831                      13312
-o1 -s1                858                        208

-s1                    858                        208
-s64   *               13831                      13312
-s128  *               27009                      26624
: * should be wrong.

After patch,

-s1    (ovp:1%)        858                        208
-s64   (ovp:4%)        6172                       3712
-s128  (ovp:6%)        8721                       5120

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-09-23 14:59:30 -07:00
Jaegeuk Kim
6f9c275125 mkfs.f2fs: don't need to limit MIN_VOLUME SIZE
The minimum volume size is determined while preparing superblock.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-08-10 17:58:40 -07:00
Jaegeuk Kim
0d6d08e3f5 mkfs.f2fs: set overprovision size more precisely
This patch introduces to set the default overprovision space according to the
partition size in order to provide more space.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-08-10 17:57:17 -07:00
Jaegeuk Kim
01219c7b19 mkfs.f2fs: fix wrong documentation
The -s should be the number of segments per a section.

Reported-by: Marc Lehmann <schmorp@schmorp.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-08-10 10:59:36 -07:00
Yunlei He
e9f8ae8b3e fsck.f2fs: add segment type in sit_dump
Add segment type information in sit_dump:

	[sit_dump:  48] SIT[0x12905] : 0x  1 : 0
	[sit_dump:  48] SIT[0x12906] : 0x  1 : 5
	[sit_dump:  48] SIT[0x12907] : 0x  7 : 4
	[sit_dump:  48] SIT[0x12908] : 0x  1 : 3

The last column output message on behalf of segment type like
CURSEG_XXX_TYPE.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-07-16 13:39:55 -07:00
Jaegeuk Kim
ca1436eeef fsck.f2fs: drop extent_info to avoid potential wrong access
This patch avoids wrong extent information modified by fixing block addresses.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-07-01 18:54:00 -07:00
Jaegeuk Kim
7ac070116b fsck.f2fs: select to update the latest valid summary
If two dnode blocks indicate one block address, it needs to keep the latest
valid address selectively.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-07-01 18:53:58 -07:00
Jaegeuk Kim
d24f1bb16d fsck.f2fs: add hash conversion for encrypted dentries
If dentry is encrypted, we should convert its hash value.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-07 15:50:49 -07:00