Send reset commands to only current zones and finish the others.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Support get_advise command to get i_advise field value and info
in file.
For example:
f2fs_io get_advise /mnt/f2fs/foo.so
i_advise=0x11, advise_type: cold keep_size
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The reserved segments should be aligned to the section boundary.
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This fixes some android build failures due to the missing permission when
checking the loop device. Until we get a better solution, let's ignore
the error with warnings.
Reviewed-by: Huang Jianan <huangjianan@xiaomi.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Add a write_advice command with same behavior as existing write command
with the exception that data should be treated as hot or cold.
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Add a new stop cp reason STOP_CP_REASON_NO_SEGMENT for keeping
consistent with kernel codes.
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Added lseek command to support lseek() for SEEK_DATA and SEEK_HOLE.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When we turn on sparse_mode, stat() will be failed, as the file will be
created afterwards. Let's fix.
Fixes: 14197d546b ("f2fs-tools: fix to check loop device")
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Make to allocate logs after conventional area for HM zoned devices to
spare them for file pinning support.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If sparse files is set along with multiple devices, we initialize
sparse file data multiple times without freeing the previously allocated
data. This skips the initialization for subsequent devices, as sparse
file mode currently only deals with device 0 anyways.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Since we may not know the block size when initializing sparse files, we
should assume that the sparse file's blocksize is correct.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
generic/019 50s ... _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
(see /media/fstests/results//generic/019.full for details)
[FSCK] Max image size: 16196 MB, Free space: 188 MB
[FSCK] Unreachable nat entries [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking [Ok..]
[FSCK] Hard link checking for regular file [Ok..] [0x166]
[FSCK] valid_block_count matching with CP [Ok..] [0x3ecfe7]
[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [0x4c79]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x4c79]
[FSCK] valid_inode_count matched with CP [Ok..] [0xb46]
[FSCK] free segment_count matched with CP [Ok..] [0x9d]
[FSCK] next block offset is free [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs [Ok..]
Error: Could not conduct fsync!!!
Generic/019 will trigger fsync() on a clean image, but it will fail
due to simulated failure on disk, result in testcase failure.
Let's add c.need_fsync to record dirty status of image, and only trigger
fsync() when there is dirty data in image.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
As Kane Ch'in reported in bugzilla [1]
I am using some Debian VMs with f2fs root partition for development.
My host machine crashed for some reason and this caused the f2fs
partitions in the VMs to become corrupted. I tried to boot from Debian
Live and repair the partitions but failed.
do_record_fsync_data: [node] ino = 24573, nid = 0, blkaddr = 2063580
recover_data: ino = 24573, nid = 0, recorded = 0, err = 0
do_record_fsync_data: [node] ino = 471286, nid = 0, blkaddr = 2063581
recover_data: ino = 471286, nid = 0, recorded = 0, err = 0
[ASSERT] (do_record_fsync_data:3475) 0
During do_record_fsync_data(), if dnode in warm node chain is valid in
SIT table, it's better to continue checking rather than triggering
assert().
[1] https://bugzilla.kernel.org/show_bug.cgi?id=218349
Reported-by: Kane Ch'in <qinfd2023@lzu.edu.cn>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Call path:
fsck_chk_orphan_node
fsck_chk_node_blk
fsck_chk_inode_blk
'F2FS_FT_ORPHAN' will pass to fsck_chk_inode_blk(). If the orphan inode
is a DIR, it will be wrongly fixed.
Fixes: 8fd836f ("fsck: clear unexpected casefold flags")
Signed-off-by: Wu Bo <bo.wu@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Describes the block size option -b. This sets the block size, which is
restricted to powers of 2. The linux kernel currently requires that the
block size be equal to the page size to mount.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Do not finishing zones for current zones.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Fixes: 06a25b021d ("f2fs-tools: make six open zone check resilient")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Let's fix any inconsistency until checkpint being enabled back.
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck doesn't support adding inodes to inline dentries. So, need to
convert inline lost+found dentry before adding missing inodes.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The initial sizes for dqblk.dqb_curspace should reflect the block size,
as that's the minimal filesize.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The cache is initialized during the first read, however, it requires the
block size to establish its buffer. This disables the cache until the
block size is known.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The conversion from block size to MB in this debug statement assumes a
block size of 4K. This switches it to properly use the filesystem's
block size.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This issue comes from a static code scanning tool.
When c.sparse_mode is 1, stat_buf will not be initialized,
but it will be used next.
If this issue does not require modification, please ignore this commit.
Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Need to initialize user cache valid values to prevent from providing
false cache entries.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Make nat journal and nat cache have the same content.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If we write CP_UMOUNT_FLAG in fsck, f2fs will not do foll forward recovery
even though it has to do.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We might allocate more node blocks than total_valid_node_count, when we
recreate quota files.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
We need to make sure to finish all the zones except six open zones. In
a case of that the previous mount wasn't successfully unmounted, we have
to change all the current segments.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Make fsck.f2fs zeroize the unused xattr space, i.e. the space after the
end of the zero-terminated xattr list, if it isn't already zeroized.
This is important because the kernel currently does not explicitly
zero-terminate the list when writing xattrs. So, the kernel relies on
the unused space containing zeroes.
Also, add a missing free() to fix a memory leak.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When we detect quota inode corruption, we better deallocate the current
space and allocate new ones for a clean start.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
For direct nodes, we have to use DEF_ADDRS_PER_BLOCK.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Let's say we have 100 nodes to be checked. With post-increment of
checked_node_cnt, when we reach the last node, we cannot print out 100%
progress. So, go with pre-increment.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>