use f2fs_is_valid_blkaddr() instead of IS_VALID_BLK_ADDR() to
check validity of data/node's block address.
use is_valid_data_blkaddr() in sanity_check_nid() to check NULL_ADDR
as NEW_ADDR, and print the value in error path explicitly.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
read_all_xattrs() is the only user of fsck_sanity_check_nid(), wrap
openned codes of read_all_xattrs() into fsck_sanity_check_nid().
Then fsck_sanity_check_nid() can be reused later.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'move_range' in f2fs_io
to move a range of data blocks from source file to destination
file via F2FS_IOC_MOVE_RANGE ioctl.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Introduce DISP_u8(), and use DISP_u16() and DISP_u8() to print below fields:
- i_compress_algorithm
- i_log_cluster_size
- i_compress_flag
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Otherwise, it may trigger static assert below when the structure
updates.
static_assert(sizeof(struct f2fs_super_block) == 3072, "")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'precache_extents' in f2fs_io
to trigger precache extents via F2FS_IOC_PRECACHE_EXTENTS ioctl.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'checkpoint' in f2fs_io to
trigger filesystem checkpoint via F2FS_IOC_WRITE_CHECKPOINT ioctl.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Overview
========
This option allows zoned block device users to configure GC reserved and
overprovision area manually according to their demands on performance of
sustained write latency and WAF.
Problem
=======
The overprovision segments that mkfs generates are mostly occupied by GC
reserved. This degrades WAF performance.
Experiment
==========
The following experiment evaluated the application of configurable reserved.
The experimental environment is as follows.
System info
- 4.2Ghz, 8 core CPU
- 64GiB Memory
Device info
- a conventional null_blk with 448MiB capacity(meta area) and
- a sequential null_blk with 953 zones of 64MiB
Format
- as-is (find out ovp ratio): mkfs.f2fs <conv null_blk> -c <seq null_blk> -m
Info: Overprovision ratio = 3.700%
Info: Overprovision segments = 1152 (GC reserved = 1088)
- config rsvd: mkfs.f2fs <conv null_blk> -c <seq null_blk> -m -Z 8 -o 2.965
Info: Overprovision ratio = 2.965%
Info: Overprovision segments = 1152 (GC reserved = 256)
Mount
- mount <conv null_blk> <mount point>
Fio script
- fio --rw=randwrite --bs=4k --ba=4k --filesize=58630m --norandommap --overwrite=1 --name=job1 --filename=<mount point>/sustain --time_based --runtime=2h
WAF calculation
- (IOs on conv. null_blk + IOs on seq. null_blk) / random write IOs
Conclusion
==========
In the experiment, it can be shown that reducing the reserved segments
decreases WAF to 10% (from 222 to 23) although it triggers checkpoint more
frequently during gc. With direct IO, the WAF of as-is gets much higher.
In other words, a user can configure more reserved segments for lower GC
latency or allocate less reserved segments for lower WAF on the same number
of OP segments.
Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
cp_payload is set differently [1] when extended node bitmap feature is
enabled. Commit b79c3ba4ea broke fsck on f2fs file systems created on
2+ TB device with extended node bitmap feature enabled.
As the sanity check is for checking overflows, fix this to assume the max
possible cp_payload size under the extended node bitmap.
Link: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/tree/mkfs/f2fs_format.c?h=v1.15.0#n372 [1]
Fixes: b79c3ba4ea ("fsck.f2fs: sanity check cp_payload before reading checkpoint")
Reported-by: Alexander Koskovich <akoskovich@pm.me>
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Relative path does not work when searching for include files
when srcdir != builddir
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Keep sanity_check_raw_super flow in fsck.f2fs being consistent w/
sanity_check_raw_super() in f2fs kernel module, otherwise, it outputs
different error information when mounting/fscking the same image which
contains corrupted superblock.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Remove the sg_write_buffer source code and build rules now that the
sg3_utils project has been imported.
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK,
especially in a for loop.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If i_namelen is corrupted, there may be an overflow when doing memcpy.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Option "-g" for dump.f2fs is unavailable and not used in dump.f2fs.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
HAVE_CLOCK_GETTIME wasn't defined during autoconf, leading to
messages like "Done: 0.000000 secs" on Linux distros.
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Added options in f2fs_io write command to support
F2FS_IOC_START_ATOMIC_REPLACE.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
As f2fs becomes more resilient for GCs, let's give the marginal overprovision
space back to user.
Fix an issue where reserved_space > ovp_space, reported by Shinichiro.
Signed-off-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
In auto/preen mode, let's trigger repairing if filesystem has
inconsistent errors.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
In auto/preen mode, let's trigger repairing if filesystem was forced
to stop.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Change to calculate and export max image size with valid blocks
used of image rather than last used block of image.
[FSCK] Max image size: xx MB, Free space: xx MB
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Make the argument list match the format string. Use PRIu64 for uint64_t
and %zu for size_t.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We now use walltime for monthly period check. However the walltime is:
* unstable(timestamp register reset) and settable(modified by user)
* unreasonable(e.g: device power-off for one month, no data changed)
When the walltime changes to the past before one month or the future
after one month, the period check in next fsck will fail to skip or
start a full scan. So, let's use the elapsed_time in checkpoint as
current time for period check.
Signed-off-by: Weichao Guo <guoweichao@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Cleanly report an error instead of dividing by 0 (causing a floating
point exception) in the following case:
truncate -s 16M img && mkfs.f2fs img
Note that this is a minimal fix; it appears that overly-small images
still cause various integer overflows in f2fs_prepare_super_block().
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Support 'gc' sub command to trigger filesystem GC via ioctl in f2fs.
Signed-off-by: Chao Yu <chao.yu@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
AC_CHECK_LIB seems to not work correctly with OpenWrt. Add possibility
to disable lz4 and lzo2 manually.
Fixes errors in the form of:
Package f2fsck is missing dependencies for the following libraries:
liblz4.so.1
liblzo2.so.2
Signed-off-by: Nick Hainke <vincent@systemli.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
In the new version the configuration no longer respects the
--without/--with blkid/selinux parameters. Add the tests for
"with_blkid" and "with_selinux" back to configure.ac as described
in the manual.
Link: https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/External-Software.html
Fixes: c48335416a ("configure.ac: Enable cross-compilation")
Signed-off-by: Nick Hainke <vincent@systemli.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Since the size of struct f2fs_summary_block equals F2FS_BLKSIZE, use
F2FS_BLKSIZE instead of PAGE_CACHE_SIZE as the size of struct
f2fs_summary_block.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>