This avoids the below warnings.
libf2fs_zoned.c:39:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
fscanf(file, "%s", str);
^
libf2fs_zoned.c: In function 'f2fs_get_zone_blocks':
libf2fs_zoned.c:72:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
fscanf(file, "%s", str);
^
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The BLKZONED feature is mandatory for host-managed zoned block
devices. So check that it is set.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Make sure the drive has enough randomly writeable zones from
the beginning of the partition to hold the meta data sections.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
For a zoned blocks device, trim must reset all sequential zones
of the device.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Trim must not be disabled with zoned mode.
For host-managed zoned block devices, the zoned mode is mandatory.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
With the availability of the BLKREPORTZONE and BLKRESETZONE
ioctls, there is no need for using SG_IO to discover zoned
block devices characteristics. This simplifies the code.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
SMR stands for "Shingled Magnetic Recording" which makes sense
only for hard disk drives (spinning rust). The ZBC/ZAC standards
enable management of SMR disks, but solid state drives may also
support those standards. So replace "SMR" with "zoned block device"
to avoid a HDD centric terminology.
In particular, rename the HMSMR feature to BLKZONED.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Git ignore executables fsck.f2fs, f2fstat, fibmap.f2fs
and parse.f2fs.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
The first segment is already checked, so there is no need to check it
again if we want to make sure the whole section is freed.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If fscrypt is enabled, we need to convert the encrypted file name before
printing it. So let's export convert_encrypted_name for other functions,
and make it returns the length of converted string.
This patch also changes the parameter of file_is_encrypt to f2fs_inode.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Some systems do not have libselinux. Allow to build sload.f2fs without
support for selinux.
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch adds to support restoring lost files into ./lost_found/.
For example,
# fsck.f2fs /dev/sdXX
...
NID[0x87d7] is unreachable
NID[0x87d8] is unreachable
NID[0x87d9] is unreachable
[FSCK] Unreachable nat entries [Fail] [0x4988]
[FSCK] SIT valid block bitmap checking [Fail]
[FSCK] Hard link checking for regular file [Ok..] [0x0]
[FSCK] valid_block_count matching with CP [Fail] [0x2]
[FSCK] valid_node_count matcing with CP (de lookup) [Fail] [0x1]
[FSCK] valid_node_count matcing with CP (nat lookup) [Ok..] [0x4989]
[FSCK] valid_inode_count matched with CP [Fail] [0x1]
[FSCK] free segment_count matched with CP [Ok..] [0x1f7]
[FSCK] next block offset is free [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs [Fail]
Do you want to restore lost files into ./lost_found/? [Y/N] y
Then, you can restore unreachable files from ./lost_found/ in its best effort.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch should fix the below bug.
Info: checkpoint state = 4 : compacted_summary sudden-power-off
[FIX] (is_valid_ssa_data_blk: 301) --> Set data summary 0x1039 -> [0x3] [0x0] [0x0]
[ASSERT] (fsck_chk_data_blk:1459) --> SIT bitmap is 0x0. blk_addr[0x20b6d8]
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x2 with invalid NID/ino 0x1644b164
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x2 with bad ino 0x1644b164
[ASSERT] (__chk_dentries:1269) --> Bad dentry 0x0 with unexpected ftype 0x2c
[FIX] (__chk_dentries:1272) --> Clear bad dentry 0x4 with bad ftype 0x2c
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x5 with invalid NID/ino 0x49000000
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x5 with bad ino 0x49000000
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x7 with invalid NID/ino 0x67706a2e
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x7 with bad ino 0x67706a2e
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x8 with invalid NID/ino 0x4a437044
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x8 with bad ino 0x4a437044
[ASSERT] (__chk_dentries:1269) --> Bad dentry 0x0 with unexpected ftype 0x0
[FIX] (__chk_dentries:1272) --> Clear bad dentry 0xf with bad ftype 0x0
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x20 with invalid NID/ino 0x4a150009
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x20 with bad ino 0x4a150009
[ASSERT] (__chk_dentries:1255) --> Bad dentry 0x21 with invalid NID/ino 0x1800094a
[FIX] (__chk_dentries:1258) --> Clear bad dentry 0x21 with bad ino 0x1800094a
*** buffer overflow detected ***: fsck.f2fs terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7338f)[0x7fa56b17b38f]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7fa56b212c9c]
/lib/x86_64-linux-gnu/libc.so.6(+0x109b60)[0x7fa56b211b60]
fsck.f2fs[0x4032f6]
fsck.f2fs[0x4063f7]
fsck.f2fs[0x406d09]
fsck.f2fs[0x4046b8]
fsck.f2fs[0x405378]
fsck.f2fs[0x405d86]
fsck.f2fs[0x402071]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fa56b129ec5]
Reported-by: Mirh <mirh@protonmail.ch>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>