Commit Graph

573 Commits

Author SHA1 Message Date
Chao Yu
1a5588cdfb dump.f2fs: fix incorrect endian conversion
f2fs_inode.i_mode is variable of __le16 type, during endian converison,
it should to use le16_to_cpu instead of le32_to_cpu, fix it.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-01-08 15:44:08 -08:00
Rosen Penev
cec37b066b fsck: Fix big endian platforms
Since "fsck.f2fs: integrate sanity_check_inode to __check_inode_mode",
big endian platforms have been broken due to an endianness bug.

More info: https://github.com/openwrt/openwrt/pull/1575

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-01-03 20:39:13 -08:00
Jaegeuk Kim
bbff9a6d04 tools: add f2fs_io
This is initial commit to support shutdown ioctl.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-01-03 20:38:34 -08:00
Sahitya Tummala
3f6c613444 parse.f2fs: fix parsing of f2fs_trace_ios
It is incorrectly taking blkaddr as len because it missed to parse
op_flags in the trace print of f2fs_trace_ios.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-12-28 12:55:36 -08:00
Chao Yu
4d120f0c13 fsck.f2fs: introduce preen mode 2
As Michael reported:

after updating to f2fs-tools 1.12.0, a routine fsck of my file systems
took quite a while and output ten-thousands instances of the following
line:

> [FIX] (fsck_chk_inode_blk: 954)  --> Regular: 0xXYZ reset i_gc_failures from 0x1 to 0x00

The reason is that:

We start to support reseting .i_gc_failures's value to zero in fsck since
91bb7b21f7 ("f2fs-tools: fix to reset i_gc_failures offline"), this is
because if .i_gc_failures continues increasing and exceed threshold, it
can make f2fs break atomic_write semantics during GC, so I added that
patch to avoid such condition.

But the problem here is even .i_gc_failures's value is one which was
initialized duing inode creation by old kernel, and it never be increased
by GC flow, we will still trigger such fix in fsck. I think it's not
necessary.

As Jaegeuk suggested, we introduce a new preen mode 2 to handle such
condition:
  - 2: same as 0, but skip some checks for old kernel

Suggested-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reported-by: Michael Laß <bevan@bi-co.net>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-28 00:14:30 -08:00
Chao Yu
c4a74535e9 fsck.f2fs: allow to fsck readonly image w/ -f option
To keep line with e2fsprogs, let's allow to fsck mounted image as
readonly w/ -f option.

Reported-by: Perfect Gentleman <perfect007gentleman@gmail.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-26 16:40:39 -08:00
Chao Yu
65f453160f f2fs-tools: fix to check return value of {c,m}alloc()
It needs to fix to handle error case of {c,m}alloc().

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-26 16:09:40 -08:00
Jaegeuk Kim
095ab10899 libf2fs: avoid to use static local string for global f2fs_conf
We don't need to use c.rootdev_name, but do it locally.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-22 03:57:06 -08:00
Jaegeuk Kim
8dac454d5f mkfs.f2fs: enable VERITY by default
This enables VERITY by default for android.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-22 03:25:01 -08:00
Jaegeuk Kim
21d5a11ecb f2fs-tools: release 1.12.0
This release includes:
 - add android default configuration
 - fix resgid/resuid
 - add more sanity checks
 - fix corrupted quota in clean umount
 - add superblock checksum

And, there are several bug fixes in fsck.f2fs/sload.f2fs/mkfs.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:39:05 -08:00
Jaegeuk Kim
5e4da757f9 f2fs-tools: create sparse file first before stat
We must create a sparse file first before calling stat().

Fixes: eb9d8037ed ("f2fs-tools: avoid mounting f2fs if tools already open the device")
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
2367b0e9d2 f2fs-tools: show versions if exist
If it's not defined, we need to skip to show the definition.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
taebum81.kim
946d8f4583 sload.f2fs: fix memory leak
Dynamic memory stored in 'xattr_node' allocated through function 'calloc'
at line 98 can be lost at line 111
Dynamic memory stored in 'inode' allocated through function 'calloc'
at line 144 can be lost at line 227

Signed-off-by: taebum81.kim <taebum81.kim@lge.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Gao Ming
7dfb93ff36 f2fs-tools: add the max chunk size limit in sparse image
Malloc Failure occurs in 32bit Windows, when using fastboot.exe flash the
 f2fs sparse image filling with  up to 2G chunk size.

Signed-off-by: Gao Ming <gaoming20@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Sotirios-Efstathios Maneas
bdcf700f71 mkfs.f2fs: Added missing statements related to error checking.
The following patch adds a few missing statements related to error checking.

Signed-off-by: Sotirios-Efstathios Maneas <smaneas@cs.toronto.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
69b8087b55 f2fs-tools: give WITH_KERNEL_VERSION to check kernel version only
This patch adds a build option to relax kernel version and release string to
trigger full scan.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Chao Yu
e599deb238 mkfs.f2fs: support formating large size file in 32-bits platform
In 32-bits platform, {f,}stat on a large size file during mkfs, it will
cause EOVERFLOW error, this patch fixes to add macro definition
_FILE_OFFSET_BITS to avoid that error.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Randall Huang
0057a8c5c2 fsck.f2fs: do not hard-code encrypted filename length to avoid heap buffer overflow
If the len is less than 24, heap buffer overflow is reported.

Signed-off-by: Randall Huang <huangrandall@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Tiezhu Yang
3b65c5771a mkfs.f2fs: show the info of volume label only when specify it
Currently, when format disk used with mkfs.f2fs, even if the volume label
is not specified, it still shows the info of volume label with no content
due to the check condition is always true, this patch fixes it.

[root@localhost home]# mkfs.f2fs -f /dev/sdb1

	F2FS-tools: mkfs.f2fs Ver: 1.12.0 (2018-10-08)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Label =
Info: Trim is enabled

Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
83c64019e8 fsck.f2fs: don't allocate new blocks on unclean shutdown
We have to keep data for roll-forward recovery. Without this patch, we're
able to lose there-in data by quota overwrites.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Chao Yu
dfede78aa9 fsck.f2fs: detect and recover corrupted quota file
Once quota file is corrupted, kernel will set CP_QUOTA_NEED_FSCK_FLAG
into checkpoint pack, this patch makes fsck supporting to detect the flag
and try to rebuild corrupted quota file.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
2018-11-21 11:38:23 -08:00
Chao Yu
7aab50d895 fsck.f2fs: try to recover cp_payload from valid cp pack
If sb checksum is not enabled, and cp pack is valid due to no
crc inconsistence, let's try to recover cp_payload based on
cp_pack_start_sum in cp pack.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Junling Zheng
886a924bfa f2fs-tools: introduce sb checksum
This patch introduced crc for superblock.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Junling Zheng
238fa8ccf1 fsck.f2fs: unify the updating of superblocks
Rename write_superblock() to update_superblock() and make it support updating
specified one superblock or both two superblocks, then unify all places where
sb needs to be updated.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Daniel Rosenberg
1ccd8313ba WIP: Add partial shrinking support to f2fs
allow 'safe' resizing leaving the metadata nearly unchanged.

Will likely need to adjust growing for the case where a fs
had previously shrunk without altering data, and the newly grown
fs would be smaller than the original. Probably makes sense to
case it out into metadata size changes, instead of fs size changes

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-11-21 11:38:23 -08:00
Chao Yu
38e47ce596 dump.f2fs: allow dump data on mounted image
xfstests assumes it's allow to dump data on mounted image, for example,
some common functions call dumpe2fs on mounted ext[2|3|4] image to check
feature lists. To adapt such requirement, let's follow that rule in
dump.f2fs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
a48bda057a fsck.f2fs: support checkpoint=disable
This patch shows checkpoint is disabled and keeps the flag for next mount.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Junling Zheng
a6cbb57192 f2fs-tools: rename CHECKSUM_OFFSET to CP_CHKSUM_OFFSET
This patch renamed CHECKSUM_OFFSET to CP_CHKSUM_OFFSET.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
e37d372300 doc: add versioning rule
Ted wrote a very useful versioning rule that newbies must read.
Let me remain it in the tree.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-11-21 11:38:23 -08:00
Jaegeuk Kim
d3012901c5 f2fs-tools: release 1.11.1
This release includes:
 - add android default configuration
 - fix resgid/resuid
 - add more sanity checks

And, there are several bug fixes in fsck.f2fs/sload.f2fs/mkfs.f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:59:01 -07:00
Helmut Grohne
e034e7627a f2fs-tools: Fix cross-build problem caused by AC_CHECK_FILE abuse
f2fs-tools fails to cross build from source, because its upstream
build system wrongly uses AC_CHECK_FILE. The purpose of the macro is
checking for files on the host system. However here it is used to
check whether a .git directory exists, which is a property of the
build place. A simple "test -d" should be used here. After doing so,
f2fs-tools cross builds successfully.

Addresses-Debian-Bug: #896909

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:59:01 -07:00
Junling Zheng
767ac306c8 fsck.f2fs: supply more check entries for checkpoint
Supply some more check entries for checkpoint in sanity_check_ckpt()
and validate_checkpoint() to sync them with kernel.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:52:39 -07:00
Chao Yu
1ab72dec87 fsck.f2fs: print node block address
Print block address of unreachable node id in fsck_verify() for better
debugging.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:52:39 -07:00
Chao Yu
91bb7b21f7 f2fs-tools: fix to reset i_gc_failures offline
This patch synchronize f2fs_inode structure from kernel side, in
addition, it adds to check .i_gc_failures and do resetting in fsck.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:52:39 -07:00
Sotirios-Efstathios Maneas
fae19d8200 mkfs.f2fs: Fixed typos in several printed messages.
Fixed typos in several printed messages.

Signed-off-by: Sotirios-Efstathios Maneas <smaneas@cs.toronto.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:52:39 -07:00
Theodore Ts'o
d56232bc16 build: declare that libf2fs_format uses the blkid library
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Theodore Ts'o
b067004c92 add configure option --with-root-libdir
This allows the development link libraries to be installed in
/usr/lib, while the run-libraries are installed in /lib, which is
required by Debian policy.  This can be done via:

    configure --prefix=/ --libdir=/usr/lib --with-root-libdir=/lib

The technique of working around libtool's inflexibility is borrowed
from util-linux.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Jaegeuk Kim
0ba902b378 mkfs.f2fs: add -R 0:0 by default for android
This patch sets "-R 0:0" for android by default.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Jaegeuk Kim
bdd39ce73b mkfs.f2fs: add root_owner to give uid/gid
This patch adds an option to mkfs.f2fs in order for user to assign uid/gid
to the target partition.
This requires when vold in android formats a sdcard partition.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Rosen Penev
e52f0a82f9 mkfs.f2fs: Add several media formats + exe
These media formats are currently in use.

exe is useful if storing various Windows utilities on the drive.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
d31e1a0d52 f2fs-tools: set namelen parameter of convert_encrypted_name as unsigned
To avoid overflow, set namelen parameter of convert_encrypted_name as
unsigned int. convert_encrypted_name() will check if namelen exceeds the
limitation.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
e64292caeb fsck.f2fs: init quota_file before re-create quota file
`quota_handle->qh_qf->filesize' is not initialized by quota_create_file().
It contains random value, which is updated to quota file's i_size in
quota_file_close(). Since quota file is re-created, `filesize' can be
initialized as 0.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Chao Yu
ee0cb1c45e fsck.f2fs: fix to do sanity check with extra_attr feature
This patch tries to fix incorrect extra_attr bit or i_extra_isize value
in fsck.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
eb9d8037ed f2fs-tools: avoid mounting f2fs if tools already open the device
If the block device is opened by tools, F2FS should not be mounted.
Especially when fsck is running, errors unexpected may happen. So if
tools open a block device, we give it the O_EXCL flag to make sure
the block device is opened exclusivly.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
356f8627c4 fsck.f2fs: check extent of inline data/dentry inode
Check extent for inline data/dentry inode. If an inode contains inline
data/dentry, it should have no extent.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=200175
Reported-by: Wen Xu <wen.xu@gatech.edu>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Junling Zheng
ddb87f568f dump.f2fs: only dump nat inside the specified nid range
Only dump nat info of nids inside the specified range.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Yunlei He
ffd0179558 fsck.f2fs: fix wrong err message of check quota node
This patch fix wrong err message of check quota node.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Junling Zheng
8af586d3a2 f2fs-tools: fix compile errors on AOSP
Include needed header files directly to fix compile errors on AOSP.

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
e2819f24bd f2fs-tools: do not count free_segs in flush_sit_entries
flush_sit_entries() is always called before write_checkpoint(). Since
free_segs is counted in write_checkpoint, there is no need to do that
in flush_sit_entries. Besides, the value of free_segs may be not
correct if we skip uptodate seg_entries.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00
Sheng Yong
df8065e529 fsck.f2fs: introduce fsck_chk_curseg_info
If curseg is an empty segment, it will not be checked. This patch
introduces fsck_chk_curseg_info() to check SIT/SSA type of cursegs
to avoid curseg corruption.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2018-08-27 23:49:26 -07:00