platform/upstream/f2fs-tools.git
8 years agofsck.f2fs: free cp_page_1 in validate_checkpoint
Junling Zheng [Thu, 29 Sep 2016 10:38:34 +0000 (18:38 +0800)]
fsck.f2fs: free cp_page_1 in validate_checkpoint

Free cp_page_1 in validate_checkpoint to avoid memory leak.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolibf2fs: increase robustness when called on root device
Tobias Jakobi [Wed, 28 Sep 2016 17:28:03 +0000 (19:28 +0200)]
libf2fs: increase robustness when called on root device

On some systems '/proc/mounts' contains the entry '/dev/root'
as alias for the root device, while that alias doesn't actually
exist as symlink in /dev.

/proc/mounts:
/dev/root / f2fs rw,noatime,background_gc=on,user_xattr,acl,inline_data,extent_cache,active_logs=6 0 0

mount:
/dev/mmcblk1p1 on / type f2fs (rw,noatime,background_gc=on,user_xattr,acl,inline_data,extent_cache,active_logs=6)

If the root device is mounted RO, and we try to scan it, via
'fsck.f2fs /dev/mmcblk1p1', then fsck.f2fs exits because it can't
find the entry in /proc/mounts.

Try harder to identify the root device of the system first, and
in case we are operating on it, check also for '/dev/root' in mounts.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck: porting avoid unneeded loop in build_sit_entries to fsck
Yunlei He [Sat, 24 Sep 2016 04:29:17 +0000 (12:29 +0800)]
fsck: porting avoid unneeded loop in build_sit_entries to fsck

This patch porting avoid unneeded loop in build_sit_entries to fsck

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: use shorter config variable name
Jaegeuk Kim [Sat, 17 Sep 2016 01:41:00 +0000 (18:41 -0700)]
f2fs-tools: use shorter config variable name

This patch has no functional change.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolibf2fs: use dev_read_block and dev_write_block
Jaegeuk Kim [Fri, 16 Sep 2016 01:44:41 +0000 (18:44 -0700)]
libf2fs: use dev_read_block and dev_write_block

This patche tries to use dev_read_block and dev_write_block as much as possible.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs: get fd for f2fs_trim_device
Jaegeuk Kim [Fri, 2 Sep 2016 17:33:44 +0000 (10:33 -0700)]
mkfs: get fd for f2fs_trim_device

This patch is to get a parameter for fd in f2fs_trim_device.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: free node_blk to avoid memory leak
Yunlong Song [Wed, 21 Sep 2016 13:01:55 +0000 (21:01 +0800)]
fsck.f2fs: free node_blk to avoid memory leak

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: do not need strdup for parse_feature
Yunlong Song [Wed, 21 Sep 2016 10:09:18 +0000 (18:09 +0800)]
mkfs.f2fs: do not need strdup for parse_feature

strdup is useless here, with no free op with its return value.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck: clear useless "continue" in __chk_dentries
Yunlong Song [Tue, 20 Sep 2016 12:43:48 +0000 (20:43 +0800)]
fsck: clear useless "continue" in __chk_dentries

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolibf2fs: show disk information
Jaegeuk Kim [Fri, 5 Aug 2016 02:30:02 +0000 (19:30 -0700)]
libf2fs: show disk information

This adds to show disk information.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: release 1.7.0 v1.7.0
Jaegeuk Kim [Thu, 28 Jul 2016 20:10:46 +0000 (13:10 -0700)]
f2fs-tools: release 1.7.0

This version adds Host-managed SMR detection code.

libf2fs_format_la
 - changed its body

libf2fs_la
 - added zbc_scsi_report_zones()

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck: recover symlink with zero i_size
Jaegeuk Kim [Fri, 15 Jul 2016 17:27:23 +0000 (10:27 -0700)]
fsck: recover symlink with zero i_size

If we have i_blocks, we can recover i_size.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: clean up duplicated code
Xue Liu [Fri, 15 Jul 2016 12:01:25 +0000 (20:01 +0800)]
fsck.f2fs: clean up duplicated code

Call current_nat_addr() to calculate nat block address.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: update the format of output message
Sheng Yong [Fri, 15 Jul 2016 12:01:24 +0000 (20:01 +0800)]
f2fs-tools: update the format of output message

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: free nat entry cache
Sheng Yong [Fri, 15 Jul 2016 12:01:23 +0000 (20:01 +0800)]
fsck.f2fs: free nat entry cache

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: fix typo
Sheng Yong [Fri, 15 Jul 2016 12:01:22 +0000 (20:01 +0800)]
fsck.f2fs: fix typo

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: correct variable type and name
Sheng Yong [Fri, 15 Jul 2016 12:01:21 +0000 (20:01 +0800)]
fsck.f2fs: correct variable type and name

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs.fsck: fix endianess
Sheng Yong [Fri, 15 Jul 2016 12:01:20 +0000 (20:01 +0800)]
f2fs.fsck: fix endianess

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agodump.f2fs: show inode->i_dir_level
Sheng Yong [Fri, 15 Jul 2016 12:01:19 +0000 (20:01 +0800)]
dump.f2fs: show inode->i_dir_level

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs: define DISCARD/SECDISCARD macro
Jaegeuk Kim [Thu, 16 Jun 2016 21:39:18 +0000 (14:39 -0700)]
mkfs: define DISCARD/SECDISCARD macro

If SECDISCARD/DISCARD is not defined, we can set it.
In Android, we must set -DWITH_BLKDISCARD to discard the partition.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs/fsck: add host-managed smr feature
Jaegeuk Kim [Mon, 13 Jun 2016 16:36:38 +0000 (09:36 -0700)]
mkfs/fsck: add host-managed smr feature

This feature flag will be used by f2fs to detect HMSMR device.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: allow zero link count for orphan inode
Jaegeuk Kim [Thu, 9 Jun 2016 21:16:18 +0000 (14:16 -0700)]
fsck.f2fs: allow zero link count for orphan inode

This will be zeroed by f2fs during the mount time.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: ZBC device support
Jaegeuk Kim [Fri, 27 May 2016 21:20:43 +0000 (14:20 -0700)]
mkfs.f2fs: ZBC device support

This patch adds "-m" option to configure ZBC device.

This is to support host-managed SMR device and configure some major features
and on-disk layout in f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: modify sit dump && add nat dump
Yunlei He [Sat, 4 Jun 2016 10:03:56 +0000 (18:03 +0800)]
fsck.f2fs: modify sit dump && add nat dump

modify sit dump && add nat dump like this:

dump_sit:

segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)

segno:      13  vblocks:512     seg_type:2      sit_pack:2

  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff
  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff
  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff
  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff  ff

dump_nat:

nid:    3       ino:    3       offset:    0    blkaddr:   2076417      pack:2
nid: 1042       ino: 1042       offset:    0    blkaddr:   2087156      pack:2
nid:57076       ino:57076       offset:    0    blkaddr:   2071232      pack:2
nid:57118       ino:57118       offset:    0    blkaddr:   2071233      pack:2
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check sector size if formatted from a regular file
Yunlei He [Wed, 18 May 2016 10:00:37 +0000 (18:00 +0800)]
fsck.f2fs: check sector size if formatted from a regular file

This patch check sector size if formatted from a regular file,
write the sector info to superblock from device info.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: reset fsck flag if there is no bug
Jaegeuk Kim [Tue, 3 May 2016 23:58:57 +0000 (16:58 -0700)]
fsck.f2fs: reset fsck flag if there is no bug

Let's update checkpoint, if fsck is set without any bug.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: remove duplicated codes in sanity_check_raw_super
Junling Zheng [Tue, 26 Apr 2016 02:23:32 +0000 (10:23 +0800)]
fsck.f2fs: remove duplicated codes in sanity_check_raw_super

Remove duplicated codes in sanity_check_raw_super().

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agoresize.f2fs: replace the overprovision calculation method
Yunlei He [Tue, 26 Apr 2016 05:25:08 +0000 (13:25 +0800)]
resize.f2fs: replace the overprovision calculation method

This patch replace the overprovision calculation method from
mkfs tool.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agoscript: add simple test script
Jaegeuk Kim [Thu, 17 Dec 2015 00:47:23 +0000 (16:47 -0800)]
script: add simple test script

This patch adds a script to test sload.f2fs, defrag.f2fs, and resize.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agosload.f2fs: support loading files into partition directly
Jaegeuk Kim [Thu, 10 Dec 2015 00:18:44 +0000 (16:18 -0800)]
sload.f2fs: support loading files into partition directly

This patch implements loading files into the existing partition.
For example,
 # sload.f2fs -f ./ /dev/sdb1

Then, all the directories and files will be loaded into /dev/sdb1.
By default, newly files should have inline_data and inline_xattr, if possible.

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Signed-off-by: Liu Shuoran <liushuoran@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agoresize.f2fs: support to expand partition size
Jaegeuk Kim [Wed, 9 Dec 2015 00:05:09 +0000 (16:05 -0800)]
resize.f2fs: support to expand partition size

Now user can expand existing partition with resize.f2fs.
Currently, it doesn't support shrink an image.

For example,
 # resize.f2fs -t [# of sectors] [image]

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofibmap: pull in sys/sysmacros.h for major/minor
Mike Frysinger [Mon, 18 Apr 2016 22:19:53 +0000 (18:19 -0400)]
fibmap: pull in sys/sysmacros.h for major/minor

These funcs are provided by sys/sysmacros.h, so include the header
directly.  Building with alternative C libraries can fail otherwise
like so:

fibmap.c: In function 'print_stat':
fibmap.c:36:32: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration]
  printf("dev       [%d:%d]\n", major(st->st_dev), minor(st->st_dev));
                                ^
fibmap.c:36:51: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration]
  printf("dev       [%d:%d]\n", major(st->st_dev), minor(st->st_dev));
                                                   ^
fibmap.o: In function 'print_stat':
tools/fibmap.c:36: undefined reference to 'minor'
tools/fibmap.c:36: undefined reference to 'major'
fibmap.o: In function 'stat_bdev':
tools/fibmap.c:59: undefined reference to 'minor'
tools/fibmap.c:59: undefined reference to 'major'

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check sanity of superblock and fix any misalignment
Jaegeuk Kim [Wed, 23 Mar 2016 18:50:39 +0000 (11:50 -0700)]
fsck.f2fs: check sanity of superblock and fix any misalignment

This patch detects any corrupted superblock and fix misalignment when it finds,
which is synced with the f2fs kernel module.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: nullify the freed ckpt pointer
Jaegeuk Kim [Wed, 23 Mar 2016 18:19:20 +0000 (11:19 -0700)]
fsck.f2fs: nullify the freed ckpt pointer

Otherwise, we get a double free error by:

In fsck/main.c,

545 out_err:
546         if (sbi->ckpt)
547                 free(sbi->ckpt);

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: set fix_on if error is detected
Sheng Yong [Mon, 14 Mar 2016 06:16:59 +0000 (14:16 +0800)]
fsck.f2fs: set fix_on if error is detected

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check ino in nat entry and node footer
Sheng Yong [Mon, 14 Mar 2016 06:16:57 +0000 (14:16 +0800)]
fsck.f2fs: check ino in nat entry and node footer

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: cache all nat entries and check each of them
Sheng Yong [Mon, 14 Mar 2016 06:16:55 +0000 (14:16 +0800)]
fsck.f2fs: cache all nat entries and check each of them

All nat entries are cached during building nat_area_bitmap, so that, in
fsck_chk_meta, we can get and check blk_addr and ino directly, to see if
they are in the valid range. Also, blk_addr is checked to see if the block
is valid in sit's valid maps.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: count the number of inodes during building nat_area_bitmap
Sheng Yong [Mon, 14 Mar 2016 06:16:54 +0000 (14:16 +0800)]
fsck.f2fs: count the number of inodes during building nat_area_bitmap

The nid and ino of an inode are the same. So during building
nat_area_bitmap, we can know which nat entry represents an
inode, thus, we can count the number of inodes.

Then in fsck_chk_meta, the amount of inodes can be compared
with that recorded in CP.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: introduce -p option to check meta
Sheng Yong [Mon, 14 Mar 2016 06:16:53 +0000 (14:16 +0800)]
fsck.f2fs: introduce -p option to check meta

This patch introduces a new option '-p' to do more checks on NAT/SIT areas.
'-p' has 2 levels: level 1 has the same sematics as '-a'; level 2 checks
NAT/SIT counters to see if they matches the status in SB and CP.

A new function, fsck_chk_meta, is called by '-p 1' to implement these
comparsion. If errors are detected, fix_on is set, which means fsck will
do a 'fsck -f' immediately.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: release 1.6.1 v1.6.1
Jaegeuk Kim [Tue, 22 Mar 2016 20:37:44 +0000 (13:37 -0700)]
f2fs-tools: release 1.6.1

This version mostly fixes the bugs in fsck.f2fs.
Especially, this fixes a segfault bug when executing "fsck.f2fs -a".

Note that, some body codes (not interfaces) in libf2fs_format.la and libf2fs.la
were changed.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: calculate orphan_blkaddr correctly
Junling Zheng [Wed, 16 Mar 2016 10:03:05 +0000 (18:03 +0800)]
fsck.f2fs: calculate orphan_blkaddr correctly

Commit 4ea4f1db ("fsck.f2fs: large volume support") added the support
for large volume over about 3TB. The "cp_payload" is added to start_blk,
but not removed from orphan_blkaddr.

Fixes: 4ea4f1db ("fsck.f2fs: large volume support")
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: refactor extent info verification flow
Chao Yu [Wed, 16 Mar 2016 03:07:07 +0000 (11:07 +0800)]
fsck.f2fs: refactor extent info verification flow

There are some issues in original approach:
- memory allocated in i_extent.map will leak
- do not convert fields in i_ext from on-disk format to cpu format
- do not support checking file offset with extent info

This patch refactors the flow for fixing above issues and supporting
file offset check.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check dirent position
Chao Yu [Wed, 16 Mar 2016 03:05:14 +0000 (11:05 +0800)]
fsck.f2fs: check dirent position

This patch enables fsck.f2fs to detect incorrect position where dirent
locates in an hierarchical hash structure directory.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: set segment_count in super block correctly
Fan Li [Wed, 16 Mar 2016 02:25:36 +0000 (10:25 +0800)]
mkfs.f2fs: set segment_count in super block correctly

Now f2fs will check statistics recorded in super block in
sanity_check_area_boundary() during mount. If the number of segments
per zone is greater than 1, and the disk space isn't aligned with zone,
mount will fail due to following condition:

main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
segment0_blkaddr + (segment_count << log_blocks_per_seg)

This is because when the length of main area isn't aligned with zone,
mkfs doesn't add those excess segments to segment_count_main, but adds
them to segment_count.

Here align segment_count with zone size as well as segment_count_main
to prevent such problem.

Signed-off-by: Fan Li <fanofcode.li@samsung.com>
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check nat_entry->ino for all nodes
Sheng Yong [Mon, 22 Feb 2016 17:01:15 +0000 (17:01 +0000)]
fsck.f2fs: check nat_entry->ino for all nodes

Commit 843f5b9388c4652a ("fsck.f2fs: check ino of an inode") checks
nat_entry->ino for inode. However, the checking is irrelevant to node
type, and if ino of other kinds of nodes gets corrupted, fsck.f2fs
cannot detect it. This patch fixes the commit.

Fixes: 843f5b9388c4652a ("fsck.f2fs: check ino of an inode")
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: rebase struct f2fs_summary_block with upstream
Chao Yu [Fri, 11 Mar 2016 08:43:54 +0000 (16:43 +0800)]
f2fs-tools: rebase struct f2fs_summary_block with upstream

Struct f2fs_summary_block has been changed in upstream commits:
 - commit 8f1dbbbbdfe9 ("f2fs: introduce lifetime write IO statistics")
 - commit dfc08a12e49a ("f2fs: introduce f2fs_journal struct to wrap journal info")

This patch does the sync work for f2fs_summary_block structure between
f2fs-utils and f2fs kernel module.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: fix incorrect block_addr of node/meta
Junling Zheng [Thu, 3 Mar 2016 02:32:31 +0000 (10:32 +0800)]
fsck.f2fs: fix incorrect block_addr of node/meta

Fix incorrect block_addr of node or meta inode into 0x1 during
build_nat_area_bitmap().

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Liu Xue <liuxueliu.liu@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: calculate the total size correctly
Junling Zheng [Sat, 27 Feb 2016 02:43:08 +0000 (10:43 +0800)]
fsck.f2fs: calculate the total size correctly

Correctly calculate the total FS size in init_sb_info(), for sector
size may not be 512 bytes.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check valid values for dot dentries
Liu Xue [Fri, 26 Feb 2016 06:42:13 +0000 (06:42 +0000)]
fsck.f2fs: check valid values for dot dentries

Check valid values for '.' and '..', such as ino, hash_code, and the
number of dot or dotdot in the directory.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Yong Sheng <shengyong1@huawei.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: redefine MAX_SIT_BITMAP_SIZE
Junling Zheng [Tue, 23 Feb 2016 13:43:42 +0000 (21:43 +0800)]
f2fs-tools: redefine MAX_SIT_BITMAP_SIZE

During mkfs, segment_count_sit is calculated using ALIGN and
SEG_ALIGN, which are both upward. Then, in some extreme scenarios,
such as 16TB, sit_ver_bitmap_bytesize got from segment_count_sit
will exceed MAX_SIT_BITMAP_SIZE, which is calculated in a downward
method.

Unify the two calculating methods and redefine MAX_SIT_BITMAP_SIZE
to prevent sit_ver_bitmap_bytesize overflowing.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolibf2fs: limit the total size up to 16T
Junling Zheng [Tue, 23 Feb 2016 13:43:41 +0000 (21:43 +0800)]
libf2fs: limit the total size up to 16T

F2FS can support 16T bytes at most. Limit the config.total_sectors
so that most parameters calculated according to it in sb/cp can be
limited correctly too.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: fix corrupted nat entry [0]
Sheng Yong [Tue, 23 Feb 2016 11:45:32 +0000 (19:45 +0800)]
fsck.f2fs: fix corrupted nat entry [0]

The first nat entry must be null. If it is corrupted, we set its bit in
nat_area_bitmap, without increasing valid_nat_entry_cnt, fsck_verify will
nullify it at last.

Reported-by: Cheng Yinchao <chengyinchao@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: remove corrupted nid entry from indirect/double-indirect node
Sheng Yong [Fri, 19 Feb 2016 17:14:58 +0000 (17:14 +0000)]
fsck.f2fs: remove corrupted nid entry from indirect/double-indirect node

For indirect/double-indirect node, if the blk_addr in its nat entry is
corrupted, fsck could figure this out and nullify the nat entry. However,
the indirect/double-indirect node still keeps the corrupted nid. As a
result, fsck reports valid blkaddr but fixes nothing each time during
scanning all nodes, like:

=============================
[ASSERT] (sanity_check_nid: 356)  --> blkaddres is not valid. [0x0]
delete in.nid[i] = 0;
[ASSERT] (sanity_check_nid: 356)  --> blkaddres is not valid. [0x0]
delete in.nid[i] = 0;

[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x0]
[FSCK] valid_block_count matching with CP             [Ok..] [0xa51b]
[FSCK] valid_node_count matcing with CP (de lookup)   [Ok..] [0x98]
[FSCK] valid_node_count matcing with CP (nat lookup)  [Ok..] [0x98]
[FSCK] valid_inode_count matched with CP              [Ok..] [0x7b]
[FSCK] free segment_count matched with CP             [Ok..] [0x1a]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Fail]
=============================

So let's clean it.

Reported-by: Chen Yinchao <chengyinchao@huawei.com>
Signed-off-by: Liu Xue <liuxueliu.liu@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check /proc/mounts first to detect readonly
Jaegeuk Kim [Fri, 19 Feb 2016 01:37:14 +0000 (17:37 -0800)]
fsck.f2fs: check /proc/mounts first to detect readonly

Once f2fs_stop_checkpoint makes f2fs as readonly, only /proc/mounts shows
RDONLY whereas /etc/mtab does not.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: show encrypted filenames matched with kernel
Jaegeuk Kim [Wed, 10 Feb 2016 21:20:25 +0000 (13:20 -0800)]
fsck.f2fs: show encrypted filenames matched with kernel

This patch follows the kernel's encrypted name resolution.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check ino of an inode
Sheng Yong [Sat, 30 Jan 2016 09:16:39 +0000 (09:16 +0000)]
fsck.f2fs: check ino of an inode

If the node is an inode, its ino in the nat entry should be equal to the
ino in its node footer. Otherwise, we drop the file.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: check ino of an used nat entry
Sheng Yong [Sat, 30 Jan 2016 09:16:38 +0000 (09:16 +0000)]
fsck.f2fs: check ino of an used nat entry

If a nid is valid, the ino in its nat entry should record its parent nid.
However if the ino is zero, we should drop the node.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: fix endianness of on-disk check_sum in summary_footer
Sheng Yong [Sat, 30 Jan 2016 09:16:37 +0000 (09:16 +0000)]
f2fs-tools: fix endianness of on-disk check_sum in summary_footer

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: avoid fix ssa in some case
Yunlei He [Sat, 30 Jan 2016 02:26:29 +0000 (10:26 +0800)]
fsck.f2fs: avoid fix ssa in some case

In some case, we need confirm node or data blkaddr is ok at first,
and then fix the conflict in ssa block. If the node blkaddr happen to
locate in data type segment caused by something error, may be we 'd
better ignore it, and it's same with data blkaddr.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: reset dnode with zeros
Jaegeuk Kim [Sat, 23 Jan 2016 14:29:36 +0000 (22:29 +0800)]
mkfs.f2fs: reset dnode with zeros

This patch fixes resetting dnode blocks recursively.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: nullify raw_super pointer
Jaegeuk Kim [Thu, 21 Jan 2016 01:13:14 +0000 (09:13 +0800)]
fsck.f2fs: nullify raw_super pointer

Otherwise it will cause double free.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: return 0 for no error was reported
Jaegeuk Kim [Fri, 15 Jan 2016 04:44:13 +0000 (20:44 -0800)]
fsck.f2fs: return 0 for no error was reported

When skipping fsck, return 0 with message.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: assign checkpoint pointer correctly
Jaegeuk Kim [Fri, 15 Jan 2016 04:36:20 +0000 (20:36 -0800)]
fsck.f2fs: assign checkpoint pointer correctly

This patch fixes a bug that cp pointer is not assigned correctly.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: swap checkpoint crc to CPU endian
Sheng Yong [Thu, 14 Jan 2016 09:13:04 +0000 (09:13 +0000)]
fsck.f2fs: swap checkpoint crc to CPU endian

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: avoid failure and warnings for android build
Jaegeuk Kim [Wed, 13 Jan 2016 19:51:33 +0000 (11:51 -0800)]
f2fs-tools: avoid failure and warnings for android build

This patch fixes to resolve build failure and warnings when compiling it
under AOSP.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: introduce zone align for main area
Yunlei He [Fri, 8 Jan 2016 02:25:29 +0000 (10:25 +0800)]
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>
8 years agofsck.f2fs: fix double free invalid checkpoint
Sheng Yong [Mon, 28 Dec 2015 11:33:22 +0000 (11:33 +0000)]
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>
8 years agoman: modify mkfs.f2fs man page
Jaegeuk Kim [Wed, 23 Dec 2015 00:14:36 +0000 (16:14 -0800)]
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>
8 years agoman: add missing man pages
Jaegeuk Kim [Tue, 22 Dec 2015 23:55:34 +0000 (15:55 -0800)]
man: add missing man pages

This patch adds missing man pages.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: release 1.6.0 v1.6.0
Jaegeuk Kim [Mon, 21 Dec 2015 17:57:10 +0000 (09:57 -0800)]
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>
8 years agomkfs.f2fs: fix check error when calloc sum_compact failure
Liu Xue [Mon, 21 Dec 2015 07:44:41 +0000 (07:44 +0000)]
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>
8 years agofsck.f2fs: fix losing journal entries
Jaegeuk Kim [Sun, 20 Dec 2015 07:17:11 +0000 (23:17 -0800)]
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>
8 years agodefrag.f2fs: fix missing SSA updates
Jaegeuk Kim [Sat, 19 Dec 2015 01:49:29 +0000 (17:49 -0800)]
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>
8 years agodefrag.f2fs: enhance allocation speed
Jaegeuk Kim [Thu, 17 Dec 2015 23:37:24 +0000 (15:37 -0800)]
defrag.f2fs: enhance allocation speed

This patch improves the allocation speed.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolibf2fs: fix incorrect type define of declaration
Chao Yu [Fri, 18 Dec 2015 07:57:10 +0000 (15:57 +0800)]
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>
8 years agodefrag.f2fs: return error if there is no space
Jaegeuk Kim [Thu, 17 Dec 2015 02:31:38 +0000 (18:31 -0800)]
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>
8 years agodefrag.f2fs: eliminate unexpected journal entries
Jaegeuk Kim [Thu, 17 Dec 2015 01:43:34 +0000 (17:43 -0800)]
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>
8 years agodefrag.f2fs: fix not to allocate current segment
Jaegeuk Kim [Wed, 16 Dec 2015 02:13:08 +0000 (18:13 -0800)]
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>
8 years agolib: use u8/u32/u64 for bit operations
Jaegeuk Kim [Tue, 15 Dec 2015 19:13:25 +0000 (11:13 -0800)]
lib: use u8/u32/u64 for bit operations

This cleans up the bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agolib: fix test_bit_le functions
Jaegeuk Kim [Tue, 15 Dec 2015 18:10:15 +0000 (10:10 -0800)]
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>
8 years agomkfs.f2fs: remove extent_cache entry for parent directory
Jaegeuk Kim [Tue, 15 Dec 2015 02:39:00 +0000 (18:39 -0800)]
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>
8 years agomkfs.f2fs: fix storing volume label correctly in utf16
Jaegeuk Kim [Mon, 14 Dec 2015 22:29:41 +0000 (14:29 -0800)]
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>
8 years agofsck.f2fs: deal with realloc size and realloc failure
Liu Xue [Mon, 14 Dec 2015 11:31:28 +0000 (11:31 +0000)]
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>
8 years agoRevert "fsck.f2fs: deal with realloc failure"
Jaegeuk Kim [Mon, 14 Dec 2015 17:37:30 +0000 (09:37 -0800)]
Revert "fsck.f2fs: deal with realloc failure"

This reverts commit 43095ca4c293249affc29a975c151c92d24b13b5.

8 years agomkfs.f2fs: fix to calculate left space of checkpoint page correctly
Chao Yu [Mon, 14 Dec 2015 10:06:59 +0000 (18:06 +0800)]
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>
8 years agodefrag.f2fs: introduce defragmentation tool
Jaegeuk Kim [Fri, 23 Oct 2015 18:45:36 +0000 (11:45 -0700)]
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>
8 years agofsck.f2fs: LFS alloc_type must have free segment after blkoff
Jaegeuk Kim [Thu, 10 Dec 2015 04:30:41 +0000 (20:30 -0800)]
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>
8 years agof2fs-tools: export print_raw_sb_info
Jaegeuk Kim [Wed, 9 Dec 2015 01:33:23 +0000 (17:33 -0800)]
f2fs-tools: export print_raw_sb_info

This patch exports print_raw_sb_info().

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agomkfs.f2fs: export get_best_overprovision
Jaegeuk Kim [Wed, 9 Dec 2015 01:30:38 +0000 (17:30 -0800)]
mkfs.f2fs: export get_best_overprovision

This patch exports get_best_overprovision() function.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agofsck.f2fs: sanity_check for extent_cache entry
Jaegeuk Kim [Tue, 8 Dec 2015 22:53:21 +0000 (14:53 -0800)]
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>
8 years agolibf2fs: enhance the bit operations
Jaegeuk Kim [Wed, 9 Dec 2015 19:44:31 +0000 (11:44 -0800)]
libf2fs: enhance the bit operations

This patch modifies the existing bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
8 years agof2fs-tools: add library version info
Jaegeuk Kim [Wed, 9 Dec 2015 18:30:25 +0000 (10:30 -0800)]
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>
8 years agomkfs/Makefile.am: add a section to build libf2fs_fmt
Kai-Chung Yan [Wed, 9 Dec 2015 18:14:32 +0000 (10:14 -0800)]
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>
8 years agomkfs.f2fs: show correct partition size
Jaegeuk Kim [Mon, 7 Dec 2015 23:50:26 +0000 (15:50 -0800)]
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>
8 years agofsck.f2fs: use get_{sb|cp} and set_{sb|cp} macros
Jaegeuk Kim [Sun, 22 Nov 2015 04:02:18 +0000 (20:02 -0800)]
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>
8 years agomkfs.f2fs: export get_{sb|cp} and set_{sb|cp}
Jaegeuk Kim [Sun, 22 Nov 2015 03:44:29 +0000 (19:44 -0800)]
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>
8 years agomkfs.f2fs: discard obsolete blocks to avoid roll-forward recovery
Jaegeuk Kim [Thu, 3 Dec 2015 05:33:21 +0000 (21:33 -0800)]
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>
8 years agomkfs.f2fs: skip extension name that is too long
Chao Yu [Mon, 30 Nov 2015 10:41:07 +0000 (10:41 +0000)]
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>
8 years agomkfs.f2fs: avoid dumplicate extensions
Sheng Yong [Mon, 30 Nov 2015 10:41:06 +0000 (10:41 +0000)]
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>
8 years agofsck.f2fs: deal with realloc failure
Liu Xue [Tue, 1 Dec 2015 08:34:43 +0000 (08:34 +0000)]
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>