aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-04-11f2fs-tools: upgrade version 1.16.0HEADmasterJaegeuk Kim2-4/+4
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-04-07fsck.f2fs: fix sanity check logic for cp_payloadJuhyung Park2-1/+5
cp_payload is set differently [1] when extended node bitmap feature is enabled. Commit b79c3ba4ea9d 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: b79c3ba4ea9d ("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>
2023-04-03mkfs.f2fs: remove indentationJaegeuk Kim1-1/+1
Show info w/o it. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-04-03fsck.f2fs: don't call report_zone on normal partitionJaegeuk Kim1-0/+3
Report_zone is not supported on normal partition. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-03-08f2fs-tools: relax zone size of power of 2Jaegeuk Kim1-5/+2
Let's relax this for Android support. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-02-15mkfs.f2fs: trim all the devices except the first oneJaegeuk Kim1-0/+4
We need to check the first disk only, and trim the other disks. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-02-13f2fs-tools: fix # of total segmentsJaegeuk Kim4-20/+20
TOTAL_SEGS should include metadata segments and main segments. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-02-07f2fs_io: support AES_256_HCTR2Jaegeuk Kim1-10/+11
Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-02-07f2fs_io: Fix out of tree buildsKhem Raj1-1/+1
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>
2023-02-07fsck.f2fs: relocate chksum verification step during f2fs_do_mount()Chao Yu1-4/+4
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>
2023-02-07f2fs-tools: Remove deprecated f2fstatJaegeuk Kim3-314/+1
Let's remove this. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-11-23Remove sg_write_bufferBart Van Assche31-16188/+1
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>
2022-11-21fsck.f2fs: avoid uncessary recalculationSheng Yong1-10/+9
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>
2022-11-21fsck.f2fs: fix potential overflow of copying i_nameSheng Yong1-2/+4
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>
2022-11-21fsck.f2fs: add parentheses for SB_MASKSheng Yong1-1/+1
Signed-off-by: Sheng Yong <shengyong@oppo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-11-21dump.f2fs: remove unavailable option -gSheng Yong1-9/+3
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>
2022-11-09f2fs-tools: define HAVE_CLOCK_GETTIME properlyJuhyung Park1-0/+1
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>
2022-10-26f2fs-tools: support F2FS_IOC_START_ATOMIC_REPLACEDaeho Jeong2-9/+23
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>
2022-10-26f2fs-tools: give less overprovisioning spaceJaegeuk Kim3-7/+20
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>
2022-10-20f2fs-tools: set host-aware zoned device similar to host-managed oneJaegeuk Kim3-3/+3
It'd be good to generate zone-aware sequential writes to both of HA and HM zoned devices. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-10-20fsck.f2fs: fix missing to assign c.zoned_modelJaegeuk Kim1-0/+8
We need to set the c.zoned_model appropriately for further usages. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-10-10fsck.f2fs: trigger repairing if filesystem has inconsistent errorsChao Yu4-4/+83
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>
2022-10-10fsck.f2fs: trigger repairing if filesystem was forced to stopChao Yu4-1/+73
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>
2022-10-10fsck.f2fs: export valid image sizeChao Yu4-14/+13
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>
2022-10-10mkfs.f2fs: update allocation policy for ro featureChao Yu3-3/+24
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>
2022-10-10fsck.f2fs: fix __end_block_addr()Chao Yu1-2/+3
The calculation is wrong, fix it. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-09-09Always use sparse/sparse.h when building for AndroidRobin Lee1-0/+2
Change-Id: Ic903ce09c93de75d6deb700a5a283638a912a25b Test: fastboot erase userdata
2022-09-07f2fs-tools: fix build error on lz4-1.9.4Jaegeuk Kim1-4/+1
LZ4_STREAMSIZE_U64 is undefined in new lz4 lib. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-09-07Fix format strings in log messagesBart Van Assche2-4/+4
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>
2022-09-07fsck.f2fs: use elapsed_time in checkpoint for period checkWeichao Guo1-43/+42
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>
2022-08-19mkfs.f2fs: catch total_zones=0 instead of crashingEric Biggers1-3/+7
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>
2022-08-08f2fs-tools: use F2FS_BLKSIZE instead of PAGE_*_SIZEJaegeuk Kim4-17/+8
We don't need to check the running kernel configuration. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-30f2fs_io: support triggering filesystem GC via ioctlChao Yu2-0/+31
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>
2022-07-21configure.ac: fix cross compilationNick Hainke1-10/+34
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>
2022-07-21configure.ac: fix AC_ARG_WITHNick Hainke1-14/+30
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: c48335416a09 ("configure.ac: Enable cross-compilation") Signed-off-by: Nick Hainke <vincent@systemli.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-21Use F2FS_BLKSIZE as the size of struct f2fs_summary_blockBart Van Assche1-4/+4
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>
2022-07-21Use F2FS_BLKSIZE for dev_read_block() buffersBart Van Assche1-3/+3
Use F2FS_BLKSIZE instead of PAGE_SIZE for dev_read_block() buffers since dev_read_block() reads F2FS_BLKSIZE bytes. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-21Improve compile-time type checking for f2fs_report_zone()Bart Van Assche2-10/+18
Change the type of the third argument of f2fs_report_zone() from void * into struct blk_zone * to enable type checking. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-21Fix f2fs_report_zone()Bart Van Assche1-1/+2
The definition of struct blk_zone_report is as follows: struct blk_zone_report { __u64 sector; __u32 nr_zones; __u32 flags; struct blk_zone zones[0]; }; Since f2fs_report_zone() allocates the above data structure with malloc() and since f2fs_report_zone() only initializes the sector and nr_zones members, the flags member is not initialized. Modify f2fs_report_zone() such that 0 is passed as flags to the BLKREPORTZONE ioctl instead of a random value. This has been discovered by reading the source code. Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Fixes: 6d7c7b785feb ("libf2fs_zoned: Introduce f2fs_report_zone() helper function") Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-21Fix the struct f2fs_dentry_block definitionBart Van Assche1-2/+2
Fix the struct f2fs_dentry_block definition on systems for which PAGE_SIZE != 4096. This patch does not change the struct f2fs_dentry_block definition if PAGE_SIZE == 4096. Cc: Peter Collingbourne <pcc@google.com> Reported-by: Peter Collingbourne <pcc@google.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> Reviewed-by: Peter Collingbourne <pcc@google.com> Tested-by: Peter Collingbourne <pcc@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-05resize.f2fs: add option to manually specify new overprovisionliuchao123-15/+65
Make.f2fs supports manually specifying overprovision, and we expect resize.f2fs to support it as well. This change add a new '-o' option to manually specify overprovision, and fix to check free space before grow. Otherwise, after grow, kernel may report below error message when we mount the image if -o parameter is specified during resize: F2FS-fs (loop0): invalid crc_offset: 0 F2FS-fs (loop0): Wrong valid_user_blocks: 16404, user_block_count: 13312 F2FS-fs (loop0): Failed to get valid F2FS checkpoint mount(2) system call failed: Structure needs cleaning. Signed-off-by: liuchao12 <liuchao12@xiaomi.com> Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-07-05fsck.f2fs: drop compression bit if inline_data is setJaegeuk Kim1-1/+5
The kernel enforced not to have compression and inline_data bits together, but old kernel created files with them. Let's disable compression in that case. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-06-24f2fs-tools: fix cannot get bdev informationBen Chang1-1/+1
Some device like android phone doesn't show the dev number path in /dev/block/, for example: $ ls /dev/block/ bootdevice dm-6 loop24 loop43 ram13 sda5 sdd4 sde24 sde43 sde62 sdf1 by-name dm-7 loop25 loop44 ram14 sda6 sdd5 sde25 sde44 sde63 sdf10 dm-0 dm-8 loop26 loop45 ram15 sda7 sdd6 sde26 sde45 sde64 sdf11 dm-1 dm-9 loop27 loop46 ram2 sda8 sdd7 sde27 sde46 sde65 sdf12 dm-10 loop0 loop28 loop47 ram3 sda9 sde sde28 sde47 sde66 sdf13 dm-11 loop1 loop29 loop48 ram4 sdb sde1 sde29 sde48 sde67 sdf14 dm-12 loop10 loop3 loop49 ram5 sdb1 sde10 sde3 sde49 sde68 sdf15 dm-13 loop11 loop30 loop5 ram6 sdb2 sde11 sde30 sde5 sde69 sdf16 dm-14 loop12 loop31 loop50 ram7 sdb3 sde12 sde31 sde50 sde7 sdf17 dm-15 loop13 loop32 loop51 ram8 sdb4 sde13 sde32 sde51 sde70 sdf18 dm-16 loop14 loop33 loop6 ram9 sdb5 sde14 sde33 sde52 sde71 sdf19 dm-17 loop15 loop34 loop7 sda sdc sde15 sde34 sde53 sde72 sdf2 dm-18 loop16 loop35 loop8 sda1 sdc1 sde16 sde35 sde54 sde73 sdf3 dm-19 loop17 loop36 loop9 sda10 sdc2 sde17 sde36 sde55 sde74 sdf4 dm-2 loop18 loop37 mapper sda11 sdc3 sde18 sde37 sde56 sde75 sdf5 dm-20 loop19 loop38 platform sda12 sdc4 sde19 sde38 sde57 sde76 sdf6 dm-21 loop2 loop39 ram0 sda13 sdc5 sde2 sde39 sde58 sde77 sdf7 dm-3 loop20 loop4 ram1 sda14 sdd sde20 sde4 sde59 sde78 sdf8 dm-4 loop21 loop40 ram10 sda2 sdd1 sde21 sde40 sde6 sde8 sdf9 dm-5 loop22 loop41 ram11 sda3 sdd2 sde22 sde41 sde60 sde9 vold dm-53 loop23 loop42 ram12 sda4 sdd3 sde23 sde42 sde61 sdf zram0 this will cause stat_bdev cannot show bdev information. But most of devices (include android) show dev number path in /sys/dev/block, for example: $ ls /sys/dev/block 1:0 254:1 254:6 259:21 259:38 259:54 7:104 7:24 7:368 8:11 8:4 8:70 8:87 1:1 254:10 254:7 259:22 259:39 259:55 7:112 7:240 7:376 8:12 8:48 8:71 8:88 1:10 254:11 254:8 259:23 259:4 259:56 7:120 7:248 7:384 8:13 8:49 8:72 8:89 1:11 254:12 254:9 259:24 259:40 259:57 7:128 7:256 7:392 8:14 8:5 8:73 8:9 1:12 254:13 259:0 259:25 259:41 259:58 7:136 7:264 7:40 8:16 8:50 8:74 8:90 1:13 254:14 259:1 259:26 259:42 259:59 7:144 7:272 7:400 8:17 8:51 8:75 8:91 1:14 254:15 259:10 259:27 259:43 259:6 7:152 7:280 7:408 8:18 8:52 8:76 8:92 1:15 254:16 259:11 259:28 259:44 259:60 7:16 7:288 7:48 8:19 8:53 8:77 8:93 1:2 254:17 259:12 259:29 259:45 259:61 7:160 7:296 7:56 8:2 8:54 8:78 8:94 1:3 254:18 259:13 259:3 259:46 259:62 7:168 7:304 7:64 8:20 8:55 8:79 8:95 1:4 254:19 259:14 259:30 259:47 259:63 7:176 7:312 7:72 8:21 8:6 8:8 1:5 254:2 259:15 259:31 259:48 259:64 7:184 7:32 7:8 8:3 8:64 8:80 1:6 254:20 259:16 259:32 259:49 259:65 7:192 7:320 7:80 8:32 8:65 8:81 1:7 254:21 259:17 259:33 259:5 259:66 7:200 7:328 7:88 8:33 8:66 8:82 1:8 254:3 259:18 259:34 259:50 259:7 7:208 7:336 7:96 8:34 8:67 8:83 1:9 254:4 259:19 259:35 259:51 259:8 7:216 7:344 8:0 8:35 8:68 8:84 253:0 254:5 259:2 259:36 259:52 259:9 7:224 7:352 8:1 8:36 8:69 8:85 254:0 254:53 259:20 259:37 259:53 7:0 7:232 7:360 8:10 8:37 8:7 8:86 so change the access path from /dev/block to /sys/dev/block (same method of libudev) Before: $./f2fs.fibmap testfile_4k ----------------file info------------------- testfile_4k : -------------------------------------------- dev [254:53] ino [0x 3dda : 15834] mode [0x 81b6 : 33206] nlink [0x 1 : 1] uid [0x 0 : 0] gid [0x 0 : 0] size [0x 40000 : 262144] blksize [0x 1000 : 4096] blocks [0x 200 : 512] -------------------------------------------- file_pos start_blk end_blk blks 0 2256926 2256987 62 253952 2150337 2150338 2 Patched: $./f2fs.fibmap testfile_4k ----------------bdev info------------------- devname = 254:53 start_lba = 0 ----------------file info------------------- testfile_4k : -------------------------------------------- dev [254:53] ino [0x 3dda : 15834] mode [0x 81b6 : 33206] nlink [0x 1 : 1] uid [0x 0 : 0] gid [0x 0 : 0] size [0x 40000 : 262144] blksize [0x 1000 : 4096] blocks [0x 200 : 512] -------------------------------------------- file_pos start_blk end_blk blks 0 2256926 2256987 62 253952 2150337 2150338 2 Signed-off-by: Ben Chang <ben.chang@sonicsky.net> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-06-24f2fs_io: add dsync option for writeJaegeuk Kim2-1/+7
This adds a write option having O_DIRECT | O_DSYNC. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-06-24tools: fix file too large causing overflowDylan Chang1-4/+4
fibmap: Fix file too large causing file_pos overflow fibmap show file_pos with incorrectly value when passing a large file. Before: ----------------file info------------------- /data/media/0/data1 : -------------------------------------------- dev [254:18] ino [0x 4db1 : 19889] mode [0x 81b0 : 33200] nlink [0x 1 : 1] uid [0x 280e : 10254] gid [0x 3ff : 1023] size [0x1b3dca314 : 7312548628] blksize [0x 1000 : 4096] blocks [0x da2530 : 14296368] -------------------------------------------- file_pos start_blk end_blk blks 0 3197602 3198463 862 3530752 3197509 3197509 1 3534848 3197557 3197578 22 3624960 3198464 3396701 198238 815607808 3396703 3632480 235778 1781354496 3632482 3652095 19614 1861693440 3396702 3396702 1 1861697536 3632481 3632481 1 1861701632 1514948 1514948 1 1861705728 1518774 1518774 1 1861709824 2543104 2543125 22 ... 1862111232 2457813 2457813 1 1862115328 3652096 3878168 226073 -1506856960 3878170 4133725 255556 -460099584 1510048 1510052 5 Patched: ----------------file info------------------- /data/media/0/data1 : -------------------------------------------- dev [254:18] ino [0x 4db1 : 19889] mode [0x 81b0 : 33200] nlink [0x 1 : 1] uid [0x 280e : 10254] gid [0x 3ff : 1023] size [0x1b3dca314 : 7312548628] blksize [0x 1000 : 4096] blocks [0x da2530 : 14296368] -------------------------------------------- file_pos start_blk end_blk blks 0 3197602 3198463 862 3530752 3197509 3197509 1 3534848 3197557 3197578 22 3624960 3198464 3396701 198238 815607808 3396703 3632480 235778 1781354496 3632482 3652095 19614 1861693440 3396702 3396702 1 1861697536 3632481 3632481 1 1861701632 1514948 1514948 1 1861705728 1518774 1518774 1 1861709824 2543104 2543125 22 ... 1862111232 2457813 2457813 1 1862115328 3652096 3878168 226073 2788110336 3878170 4133725 255556 3834867712 1510048 1510052 5 Signed-off-by: Dylan Chang <dylan.chang@oneplus.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-06-19dump.f2fs: add -I nid to dump inode by scan full diskYufen Yu4-1/+55
Usage: dump.f2fs -I [inode nid] /dev/sda This feature can be useful for some bugs caused by system crash. We not only need dump current valid node page, but alse the history data in disk, which can give some clues for status change of the inode. Signed-off-by: Yufen Yu <yuyufen@huawei.com> Reviewed-by: Chao Yu <chao@kernel.org> [Jaegeuk Kim: fix build error] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-28android_config: add time headersJaegeuk Kim1-0/+2
This allows f2fs_io report latency. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-25Check fallthrough in mount.h for MacJaegeuk Kim2-3/+6
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/os/base.h:128:23: error: missing ')' after 'do' ^~~~~~~~~~~ external/f2fs-tools/include/f2fs_fs.h:81:24: note: expanded from macro 'fallthrough' ~~ ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/os/base.h:128:22: note: to match this '(' Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-25avoid unnecessary functionJaegeuk Kim1-0/+2
libf2fs.c:883:12: warning: unused function 'is_power_of_2' [-Wunused-function] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-25Fix dependencies on linux/blkzoned.h when using Bionic.Martin Stjernholm1-2/+1
This reverts commit adcec10b4dee ("Support zoned device if libc exists). Signed-off-by: Martin Stjernholm <mast@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2022-05-25Remove unnecessary config.hJaegeuk Kim11-14/+5
Instead, we should use <config.h> generated by configure. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-25libzone: remove duplicate headerJaegeuk Kim1-2/+0
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-25Support zoned device if libc existsJaegeuk Kim1-2/+6
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-24mkfs.f2fs: fix typoJaegeuk Kim1-0/+1
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-24mkfs.f2fs: split unused parameterJaegeuk Kim1-5/+12
external/f2fs-tools/mkfs/f2fs_format_utils.c:51:28: error: unused parameter 'i' [-Werror,-Wunused-parameter] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-23f2fs-tools: do not use SG_IO in AndroidJaegeuk Kim2-3/+2
Android security team does not allow to use SG_IO. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-21f2fs-tools: move android_config before defining themJaegeuk Kim4-6/+10
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-19f2fscrypt: adjust config file firstJaegeuk Kim1-1/+3
We need to get the definitions first. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-19android_config: add missing uuid libraryJaegeuk Kim1-0/+2
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-13f2fs-tools: upgrade version 1.15.0Jaegeuk Kim2-4/+4
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-13f2fs-tools: build silentlyJaegeuk Kim1-0/+2
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-05-13fsck.f2fs: fix broken file_map outputJaegeuk Kim1-1/+1
The new fsck progress should not be used for file_map. Reported-by: Michael Benedict <michaelbenedicttjahya@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26f2fs-tools: show segment/section layout correctlyJaegeuk Kim2-0/+5
This patch fixes wrong segment/section print-outs. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26f2fs-tools: use android config only if there's no config.hJaegeuk Kim1-2/+3
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26dump.f2fs: compress: fix dstlen of LZ4_compress_fast_extState()Chao Yu1-1/+2
Compressed cluster content includes compress cluster header, so calculation of dstlen parameter in LZ4_compress_fast_extState() should consider this design, otherwise compressed data may overflow destination buffer during compression. Signed-off-by: Chao Yu <chao.yu@oppo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26mkfs.f2fs: check uuid libraryJaegeuk Kim2-3/+4
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26f2fs-tools: use fsync() in AndroidJaegeuk Kim1-0/+1
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-26f2fs-tools: support zoned device in AndroidJaegeuk Kim5-10/+19
This requires to change Android.bp in AOSP. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Change-Id: I28a4a701513cb2420cdf0e0e2aa3f60e712f2fcb
2022-04-22android_config.h: add missing liblz4Jaegeuk Kim1-0/+2
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22libf2fs_io: add unused mactor to avoid build failureJaegeuk Kim1-3/+16
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22ci: Enable -Wall, -Wextra and -WerrorBart Van Assche1-1/+1
Make the Github continuous integration checks more strict. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Fix PowerPC format string warningsBart Van Assche2-3/+7
__SANE_USERSPACE_TYPES__ must be defined before <linux/types.h> is included. Hence this patch that moves the definition of that macro into the source files that need it. Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2022-04-22Suppress a compiler warning about integer truncationBart Van Assche1-12/+12
This patch prevents that older compilers report the following warning: f2fs_format.c: In function ‘f2fs_prepare_super_block’: ../include/f2fs_fs.h:350:26: error: conversion from ‘unsigned int’ to ‘__uint16_t’ {aka ‘short unsigned int’} changes value from ‘4076150800’ to ‘8208’ [-Werror=overflow] 350 | #define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */ | ^~~~~~~~~~ ../include/f2fs_fs.h:574:49: note: in expansion of macro ‘cpu_to_le16’ 574 | #define set_sb_le16(member, val) (sb->member = cpu_to_le16(val)) | ^~~~~~~~~~~ Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Annotate switch/case fallthroughBart Van Assche4-0/+9
Just like in the Linux kernel source code, annotate switch/case fallthrough. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Change #ifdef _WIN32 checks into #ifdef HAVE_.*Bart Van Assche7-9/+22
It is recommended to test a HAVE_* macro instead of directly testing the host type in source code. Hence this patch. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22tools/f2fs_io: Fix the type of 'ret'Bart Van Assche1-1/+9
Make it possible to check whether the return value of ioctl() is negative. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22fsck/segment.c: Remove dead codeBart Van Assche1-1/+0
Since 'remained_blkentries' is unsigned, the assert statement that verifies whether that variable is positive will never fail. Hence remove that assert statement. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22fsck/main.c: Suppress a compiler warningBart Van Assche1-0/+2
Suppress the following compiler warning: main.c:37:14: warning: unused function 'absolute_path' [-Wunused-function] static char *absolute_path(const char *file) ^ Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22tools/f2fscrypt.c: Fix build without uuid/uuid.h header fileBart Van Assche1-0/+6
Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22fsck: Remove a superfluous include directiveBart Van Assche1-5/+0
Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22mkfs/f2fs_format.c: Suppress a compiler warningBart Van Assche1-1/+1
Suppress the following compiler warning: f2fs_format.c:1653:37: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] memcpy(dent_blk->filename[3], LPF + F2FS_SLOT_LEN, ~~~~^~~~~~~~~~~~~~~ f2fs_format.c:1653:37: note: use array indexing to silence this warning memcpy(dent_blk->filename[3], LPF + F2FS_SLOT_LEN, ^ & [ ] Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Detect selinux/android.hBart Van Assche3-2/+4
The selinux/android.h header file is available in Android but not in the Android NDK. Hence this patch that detects presence of that header file at configure time. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Detect the sparse/sparse.h headerBart Van Assche4-6/+8
The <sparse/sparse.h> header is available in Android but not in the Android NDK. Hence this patch that only includes the sparse header file if it is available. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Fix the MinGW buildBart Van Assche14-18/+108
Fix multiple compiler warnings and build errors reported by the MinGW cross-compiler. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Use %zu to format size_tBart Van Assche1-2/+2
Use %zu to format size_t as required by the POSIX standards. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Include <stddef.h> instead of defining offsetof()Bart Van Assche2-5/+2
Prepare for enabling -Wmacro-redefined. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Move the be32_to_cpu() definitionBart Van Assche2-2/+2
Move the be32_to_cpu() definition next to the little endian conversion functions. This patch improves portability since the MinGW ntohl() function exists in another library than the C library. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Remove unnecessary __attribute__((packed)) annotationsBart Van Assche7-40/+37
Applying the __attribute__((packed)) annotation to members that do not need it impacts performance negatively on architectures that do not support efficient unaligned accesses (e.g. ARMv7). Hence minimize the __attribute__((packed)) annotations. See also CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS in the Linux kernel. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22f2fs_fs.h: Use standard fixed width integer typesBart Van Assche2-9/+9
Use uint64_t instead of __u64 in the definitions of the endianness conversion macros. This patch fixes the following compiler warning: dir.c: In function ‘f2fs_create’: dir.c:785:16: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 12 has type ‘long long unsigned int’ [-Wformat=] 785 | MSG(1, "Info: Create %s -> %s\n" | ^~~~~~~~~~~~~~~~~~~~~~~~~ ../include/f2fs_fs.h:252:32: note: in definition of macro ‘MSG’ 252 | printf(fmt, ##__VA_ARGS__); \ | ^~~ Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Suppress a compiler warningBart Van Assche1-1/+1
Suppress the following compiler warning: segment.c:698:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized] 698 | if (n < 0) | ^ Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Verify structure sizes at compile timeBart Van Assche7-0/+77
Before modifying the __attribute__((packed)) annotations, let the compiler verify the sizes of on-disk data structures. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Change one array member into a flexible array memberBart Van Assche2-3/+3
Prepare for verifying structure sizes with static_assert(). Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22ci: Build f2fstools upon push and pull requestsBart Van Assche1-0/+70
For those who use Github to contribute f2fs-tools patches, let the github servers build the f2fs-tools source code upon every push and pull requests. This change does not affect users who do not use Github. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Change the ANDROID_WINDOWS_HOST macro into _WIN32Bart Van Assche7-14/+14
This makes it easier to build f2fs-tools for Windows. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22Switch from the u_int to the uint typesBart Van Assche13-171/+167
Many format strings use one of the PRI* macros. These macros are compatible with the uint types but not with the u_int types. Hence this patch that switches from the u_int to the uint types. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Enable cross-compilationBart Van Assche5-32/+24
Stop using PKG_CHECK_MODULES() since that macro is not compatible with cross-compilation. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Sort header file names alphabeticallyBart Van Assche1-2/+2
Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Enable the automake -Wall optionBart Van Assche1-1/+2
This patch fixes the following automake warnings: /usr/share/automake-1.16/am/ltlibrary.am: warning: 'libf2fs.la': linking libtool libraries using a non-POSIX /usr/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac' lib/Makefile.am:3: while processing Libtool library 'libf2fs.la' /usr/share/automake-1.16/am/ltlibrary.am: warning: 'libf2fs_format.la': linking libtool libraries using a non-POSIX /usr/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac' mkfs/Makefile.am:11: while processing Libtool library 'libf2fs_format.la' Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Remove two prototype testsBart Van Assche1-25/+0
Since no code uses the HAVE_.*_PROTOTYPE macros, remove the code that sets these macros. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-22configure.ac: Stop using obsolete macrosBart Van Assche1-2/+2
Run autoupdate v2.71 to fix the following autogen.sh warnings: configure.ac:33: warning: The macro `AC_CONFIG_HEADER' is obsolete. configure.ac:33: You should run autoupdate. ./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from... configure.ac:33: the top level configure.ac:49: warning: The macro `AC_PROG_LIBTOOL' is obsolete. configure.ac:49: You should run autoupdate. m4/libtool.m4:100: AC_PROG_LIBTOOL is expanded from... configure.ac:49: the top level Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-04-20libf2fs: don't allow mkfs / fsck on non power-of-2 zoned devicesLuis Chamberlain3-14/+38
f2fs currently only work with zoned storage devices with a zone size which is a power of 2 (PO2). So check if a non-power of 2 zoned device is found, and if so disallow its use. This prevents users from incorrectly using these devices. This is a non-issue today given today's kernel does not allow NPO2 zoned devices to exist as a block device. But NPO2 zoned devices do exist so proactively put a stop-gap measure in place to prevent it from being incorrectly used. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-28man: update mkfs.f2fs to give the default android optionJaegeuk Kim1-1/+1
This gives an information of "-g android". Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-01f2fs-tools: use proper 64bit types for PPCRosen Penev1-0/+3
A specific define is needed. Fixes mostly issues with -Wformat. Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-01mkfs.f2fs: fix wrong indentation and clean upJaegeuk Kim3-4/+4
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-01mkfs.f2fs: set project quota by default for -g android for v4.14+Jaegeuk Kim1-2/+33
With this patch, "-g android" enables project quota only by default, if the kernel is over v4.14. Otherwise, it enables usr/grp/proj all together. 1) -O quota : enables usr/grp 2) -O project_quota -O extra_attr : enabled prj 3) -O quota -O project_quota -O extra_attr : enables usr/grp/proj 4) -g android : enables proj (4.14+), usr/grp/proj (old kernel) 5) -g android -O project_quota -O extra_attr : enables usr/grp/proj Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-02-02f2fs-tools: add atomic write related options to f2fs_io write commandDaeho Jeong1-8/+45
Added two option to f2fs_io "write" command. - atomic_commit : atomic write & commit - atomic_abort : atomic write & abort Also, added an optional option {delay}, which is in ms unit and optional only for atomic_commit and atomic_abort. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-01-13mkfs.f2fs: set required quota types onlyJaegeuk Kim3-23/+24
This patch modifies enabling quota options in which enables user/group quotas only if user specifies the "-O quota" especially. 1) -O quota : enables usr/grp 2) -O project_quota -O extra_attr : enabled prj 3) -O quota -O project_quota -O extra_attr : enables usr/grp/proj 4) -g android : enables usr/grp 5) -g android -O project_quota -O extra_attr : enables usr/grp/proj Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-01-11fsck.f2fs: Add progression feedbackAntoine Viallon2-0/+16
On large SSDs filled with lots of data, fsck.f2fs can be very long to finish. For instance, on my 1TB SSD filled at 99%, it takes literally 5 minutes to complete. Currently, the only way to have some feedback is to enable debug output, but it is very verbose and doesn't tell the actual progress. This patch implements a simple progress report in the longest running part of the check (in fsck_chk_node_blk). The number of checked node / total valid nodes is printed every 1000 nodes checked, and the percentage of progress is also calculated and printed. Signed-off-by: Antoine Viallon <antoine@lesviallon.fr> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-11-12fsck.f2fs: do not assert if i_size is missing i_blocks in symlinkJaegeuk Kim1-7/+3
This case is not a bug, so we should fix seamlessly. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-10-29f2fs-tools: separate other bugs in fsck_verifyDaeho Jeong1-19/+16
When we check other corrupted bugs in fsck, we use bug_on. So, if major bugs are already detected in fsck_verify(), fsck will false alarm that there are other bugs, even if there are no other bugs. So, let's fix this. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-10-29f2fs-tools: remove false failure alarm when fixing quotaDaeho Jeong2-2/+5
Even though fsck fixed quota issues, fsck returns failure status and makes the user code misunderstand like errors are still there. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-09-28f2fs-tools: fall back to the original version check when clock_gettime is ↵Daeho Jeong1-0/+11
not supported In lower versions than macOS 10.12, they don't support clock_gettime function. It breaks the build, so we need to fall back to the original kernel version check algorithm, in that case. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-09-20mkfs.f2fs: wipe other FS magics given -fJaegeuk Kim4-7/+38
This patch fixes the below stale magic info. $ mkfs.btrfs -f test.img btrfs-progs v5.10.1 See http://btrfs.wiki.kernel.org for more information. Label: (null) UUID: 941d2db7-3ece-4090-8b22-c4ea548b5dae Node size: 16384 Sector size: 4096 Filesystem size: 1.00GiB Block group profiles: Data: single 8.00MiB Metadata: DUP 51.19MiB System: DUP 8.00MiB SSD detected: no Incompat features: extref, skinny-metadata Runtime features: Checksum: crc32c Number of devices: 1 Devices: ID SIZE PATH 1 1.00GiB test.img $ hexdump -s 0x10000 -n 128 -C test.img 00010000 81 29 94 0a 00 00 00 00 00 00 00 00 00 00 00 00 |.)..............| 00010010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00010020 94 1d 2d b7 3e ce 40 90 8b 22 c4 ea 54 8b 5d ae |..-.>.@.."..T.].| 00010030 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 |................| 00010040 5f 42 48 52 66 53 5f 4d 05 00 00 00 00 00 00 00 |_BHRfS_M........| 00010050 00 40 d2 01 00 00 00 00 00 40 50 01 00 00 00 00 |.@.......@P.....| 00010060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00010070 00 00 00 40 00 00 00 00 00 00 02 00 00 00 00 00 |...@............| 00010080 $ mkfs.f2fs -t 0 -f test.img F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-12-28) Info: Disable heap-based policy Info: Debug level = 0 Info: Trim is disabled Info: Segments per section = 1 Info: Sections per zone = 1 Info: sector size = 512 Info: total sectors = 2097152 (1024 MB) Info: zone aligned segment0 blkaddr: 512 Info: format version with "Linux version 5.10.46-4rodete1-amd64 (glinux-team@google.com) (gcc-10 (Debian 10.2.1-6+build2) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.46-4rodete1 (2021-08-20)" Info: Overprovision ratio = 6.360% Info: Overprovision segments = 68 (GC reserved = 39) Info: format successful $hexdump -s 0x10000 -n 128 -C test.img 00010000 c2 8a c8 26 00 00 00 00 00 00 00 00 00 00 00 00 |...&............| 00010010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00010020 92 ab 3f c6 b7 82 49 5e 93 23 e8 c9 e9 45 7d ac |..?...I^.#...E}.| 00010030 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 |................| 00010040 5f 42 48 52 66 53 5f 4d 05 00 00 00 00 00 00 00 |_BHRfS_M........| 00010050 00 40 d2 01 00 00 00 00 00 40 50 01 00 00 00 00 |.@.......@P.....| 00010060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00010070 00 00 00 40 00 00 00 00 00 00 02 00 00 00 00 00 |...@............| 00010080 --- After this patch --- $ mkfs.f2fs -t 0 -f test.img F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-12-28) Info: Disable heap-based policy Info: Debug level = 0 Info: Trim is disabled test.img appears to contain an existing filesystem (btrfs). Info: Segments per section = 1 Info: Sections per zone = 1 Info: sector size = 512 Info: total sectors = 2097152 (1024 MB) Info: zone aligned segment0 blkaddr: 512 Info: format version with "Linux version 5.10.46-4rodete1-amd64 (glinux-team@google.com) (gcc-10 (Debian 10.2.1-6+build2) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.46-4rodete1 (2021-08-20)" Info: Overprovision ratio = 6.360% Info: Overprovision segments = 68 (GC reserved = 39) Info: format successful $ hexdump -s 0x10000 -n 128 -C test.img 00010000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00010080 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-09-03fsck.f2fS: is_valid_summary(): check whether offset is out of boundsArpad Müller1-0/+4
This adds a check to the is_valid_summary function to prevent a segfault if the calculated offset is out of bounds. Such an offset can for example occur as the result of corruption of the underlying hardware. I encountered this segfault on my own phone's sd card, so this is not just a theoretical concern. Signed-off-by: Arpad Müller <arpad.mueller@uni-bonn.de> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-08-23Avoid redefined ALIGN_UPJaegeuk Kim2-4/+2
This tries to avoid build warning. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-08-23fsck.f2fs: Update the usage about option of preen modeJaehoon Chung1-1/+1
Update the usage about option of preen mode. It's difficult to know about preen mode 2, because there is no description in usage. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-08-23f2fs-tools: change fiemap print out formatDaeho Jeong1-19/+33
Given fiemap way to print out extents in the kernel, we can correctly print the layout of each file in a unit of extent, not block. So, I changed fiemap print out way like below. Fiemap: offset = 0 len = 60 logical addr. physical addr. length flags 0 0000000000000000 00000020032df000 0000000000004000 00001008 1 0000000000004000 00000020032e0000 0000000000004000 00001008 2 0000000000008000 00000020032e1000 0000000000004000 00001008 3 000000000000c000 00000020032e2000 0000000000004000 00001008 Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-08-23f2fs_io: add rename w/ fsync optionJaegeuk Kim1-0/+36
e.g., f2fs_io rename source dest 1 1. open(source) 2. rename(source, dest) 3. fsync(source) 4. close(source) Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2021-08-23fsck.f2fs: add basic compress related check/fixRobin Hsu4-44/+148
* check/fix i_compr_blocks * check/fix compressed flag in i_flags when compression is not supported. Signed-off-by: Robin Hsu <robinhsu@google.com> [Jaegeuk Kim: minor coding style] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-07-22f2fs-tools: make fiemap command in accordance with uapiDaeho Jeong1-4/+5
Made "fiemap" command in accordance with user api manual. So, eliminated NEW_ADDR print out and made it ends in the last extent. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-07-22f2fs-tools: rebuild the quota inode if it is corruptedWang Xiaojun5-33/+91
If the following process returns an error, the quota inode, not the quota file, is damaged. (fsck_chk_quota_node-->fsck_chk_node_blk-->sanity_check_nid) The fsck does not have a process to rebuild the quota inode. Because sanity_check_nid is not passed, fsck->nat_area_bitmap can not be cleared, and then the NAT of quota will be nullify during fix_nat_entries. During the next fsck check, the quota inode check fails because the address of the quota inode changes to 0. In addition, in fsck_chk_quota_files-->f2fs_filesize_update, data is written to address 0. Therefore, when the quota inode is corrupted, we need to rebuild it. Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-07-19f2fs-tools: add periodic check in kernel version checkDaeho Jeong3-16/+44
In previous, we did a full scan right after kernel version is changed and it triggered many unnecessary full scan whenever a newly built kernel is downloaded. Plus, we are lack of a periodic health check of on-disk filesystem images. So, I added a monthly periodic check after a new vesion is updated. Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-07-13dump.f2fs: minor clean upsJaegeuk Kim2-2/+2
This patch cleans up, pointed by Chao. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-07-07f2fs-tools: fix wrong value of reserve_new_block parameter in page_symlinkWang Xiaojun1-1/+1
In page_symlink, reserve_new_block applies address for data block, not for inodes. Therefore, is_inode is set to 0. Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-23f2fs-tools: add extent cache for each fileDaeho Jeong3-8/+113
This patch adds an extent cache for ro partition. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-23f2fs-tools: fix wrong file offsetJaegeuk Kim1-18/+30
This fixes wrong file offset updates, since we should not do (*ofs)++; for indirect node blocks. Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-23fsck|dump.f2fs: add -M to get file mapJaegeuk Kim9-24/+189
This option shows all the file names in the disk. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-23mkfs.f2fs: remove android features for ROJaegeuk Kim1-2/+7
We don't need to enable all android features for RO. Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-22f2fs-tools: fix metadata region overlap with zoned block device zonesAravind Ramesh1-0/+15
For a volume using a zoned block device without conventional zones (e.g. a NVMe ZNS drive), a regular block device must be used to store metadata so that in-place metadata writes can be executed. The zoned block device cannot contain any metadata blocks requiring in-place update (e.g. bitmap blocks). When formatting a volume that contains host managed zoned block devices, make sure that the conventional device used to store metadata is large enough to avoid write errors. Signed-off-by: Aravind Ramesh <aravind.ramesh@wdc.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-06-22sload.f2fs: Reword "IMMUTABLE" in strings/commentsRobin Hsu1-2/+3
Since the IMMUTABLE flag for compression is now changed to F2FS_COMPRESS_RELEASED, some 'IMMUTABLE' words should be changed too: 1. sload help page 2. inline comments Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-26sload.f2fs: use F2FS_COMPRESS_RELEASED instead of IMMUTABLE bitJaegeuk Kim2-3/+5
Let's use F2FS_COMPRESS_RELEASED to disallow writes only. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-26f2fs-tools: support small RO partitionJaegeuk Kim8-54/+169
This patch adds a readonly feature on small partitions by eliminating on-disk layout for data writes such as provisioning/reserved space and SSA. This requires f2fs updates to understand RO feature in superblock. Tested 4 cases: sload.f2fs -c -a lz0 -f kernel/fs $DEV sload.f2fs -c -a lz4 -f kernel/fs $DEV sload.f2fs -c -r -a lz4 -f kernel/fs $DEV sload.f2fs -c -L 3 -r -a lz4 -f kernel/fs $DEV after: mkfs.f2fs -O ro,compression,extra_attr -f $DEV fsck.f2fs $DEV Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-26fsck.f2fs: add "-l" to show the layout informationJaegeuk Kim3-10/+41
This patch add an option to print out superblock and checkpoint only. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-26f2fs_io: add to show immutable bitJaegeuk Kim1-2/+12
Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-24tools: Introduce f2fslabelDongwoo Lee5-1/+116
Although many other filesystems provide a tool for changing volume label, e.g. e2label for ext filesystem, but f2fs has no way to change volume label except set it while formatting with mkfs.f2fs. This introduces f2fslabel, simple tool for changing label of f2fs volume. Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-19f2fs-tools: correct get kernel version logiclijiazi1-1/+1
Current implementation, If define WITH_KERNEL_VERSION get_kernel_uname_version just return release info, not define WITH_KERNEL_VERSION, return release and version info. So remove "!" in get_kernel_uname_version, make logic more clear. Signed-off-by: lijiazi <lijiazi@xiaomi.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10dump.f2fs: fix memory leak caused by dump_node_blk()Seung-Woo Kim1-1/+2
Fix to free node_blk when nid is 0 from dump_node_blk(). Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node()Seung-Woo Kim1-1/+4
With invalid node info from fsck_chk_orphan_node(), orphan_blk and new_blk are not freed. Fix memory leak in the path. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10mkfs.f2fs: fix memory leak in not enough segments error pathSeung-Woo Kim1-1/+1
In not enough segements error path of f2fs_write_check_point_pack(), cp_payload is not freed. Fix the error path. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10resize.f2fs: fix memory leak caused by migrate_nat()Seung-Woo Kim1-0/+1
Alloced nat_block doesn't freed from migrate_nat(). Fix to free nat_block. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10f2fs_io: split definition check for crypto ioctlJaegeuk Kim1-2/+6
This patch fixes undefined FSCRYPT_POLICY_V1 in old distribution. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-05-10fsck.f2fs: update kernel version in superblock on forced checkMichael Lass1-3/+4
In 1126e38 (fsck.f2fs: add --{no-}kernel-check to bypass kernel version diff or not) the automatic check on a kernel version change was made optional and disabled by default on non-Android systems. This also disabled the update of the kernel version stored in the superblock if --kernel-check is not given. Restore the update in case a full check is forced via -y or -f to properly reflect the version in the superblock. Signed-off-by: Michael Lass <bevan@bi-co.net> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-04-22f2fs_io: Add get file name encryption modeRobin Hsu2-0/+99
This patch add an ioctl to get filename encryption mode. Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2021-04-19f2fs-tool: increase debug level from 0 to 1 in migrate_blockJaehoon Chung1-1/+1
Increase debug level from 0 to 1 in migrate_block. It seems that doesn't need to display debug message by default. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-04-12resize.f2fs: fix to check free space before shrinkChao Yu1-0/+14
Otherwise, after shrink, kernel will report below error message when we mount the image: F2FS-fs (loop0): invalid crc_offset: 0 F2FS-fs (loop0): Wrong valid_user_blocks: 16404, user_block_count: 13312 F2FS-fs (loop0): Failed to get valid F2FS checkpoint mount(2) system call failed: Structure needs cleaning. Reported-and-tested-by: beroal <me@beroal.in.ua> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-04-12resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()Chao Yu1-0/+5
As beroal <me@beroal.in.ua> reported: f2fs image can be corrupted after below testcase: 1. truncate -s $((256*1024*1024)) img 2. mkfs.f2fs -f img 3. mount -t f2fs -o loop img /mnt 4. xfs_io -f /mnt/file -c "pwrite 0 2M" -c "fsync" 5. umount /mnt 6. resize.f2fs -s -t 262144 img 7. fsck.f2fs img The root cause is we forgot to copy original sit/nat bitmap to new checkpoint during rebuild_checkpoint(), fix it. Reported-and-testd-by: beroal <me@beroal.in.ua> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-04-01resize.f2fs: add force option to rewrite broken calculationJaegeuk Kim2-3/+8
This patch adds "-f" for resize.f2fs to fix broken resized f2fs. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-04-01resize.f2fs: fix wrong ovp calculationJaegeuk Kim1-0/+3
beroal reported a mount failure due to broken valid_user_blocks. [ 6890.647749] F2FS-fs (loop0): Wrong valid_user_blocks: 16040048, user_block_count: 10016768 From fsck, segment_count_main [0x 9a95 : 39573] -> 39573 * 2MB = 78GB as user space overprov_segment_count [0x 4e29 : 20009] -> 20009 * 2MB = 40GB as overprovisioned space which user can't see. But, [FSCK] valid_block_count matching with CP [Ok..] [0xf4c070] -> 0xf4c070 = 16040048 valid_block_count [0x f4c070 : 16040048] -> So, this is correct. It turns out resize.f2fs gave very large and wrong overprovisioning space result in shortage of user blocks. The root cause was f2fs_get_usable_segments() didn't consider resize case which needs segment_count_main from new superblock. Fixes: f8410857b7a8 ("f2fs-tools: zns zone-capacity support") Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-03-18Add -P option to preserve file ownerDaniel Abrecht4-1/+18
I use user namespaces & debootstrap to bootstrap a system, and then copy that into an image using sload.f2fs. However, without an option to preserve the owner user & group of files, some files end up being owned by the wrong user / group (0:0), which causes all kinds of other issues This patch adds an option -P to preserve the user and group of files. Signed-off-by: Daniel Abrecht <public@danielabrecht.ch> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-03-01libf2fs: fix memory leak caused by get_rootdev()Junyong Sun1-3/+8
memory which malloc for uevent don't free at get_rootdev(), it would cause memory leak, so free it before return. Signed-off-by: Junyong Sun <sunjy516@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-02-23mkfs.f2fs: add VM disk files to hot data typesPark Ju Hyung1-0/+7
Similar to .db files, these are randomly updated extremely frequently. Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-28libzoned: use blk_zone_v2 and blk_zone_report_v2 by defaultJaegeuk Kim1-25/+24
Old blk_zone and blk_zone_report should be compatible with v2. And, old blk_zone_report uses reserved[4] which breaks the build. struct blk_zone_report { __u64 sector; __u32 nr_zones; __u8 reserved[4]; struct blk_zone zones[0]; }; Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23f2fs-tools: fix wrong blk_zone_rep_v2 definitionJaegeuk Kim1-1/+1
If HAVE_BLK_ZONE_REP_V2 id defined, we should set v2. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23mkfs.f2fs: allocate zones together to avoid random accessJaegeuk Kim1-0/+7
This patch allocates zones to initial logs together, if it's on zoned device. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23mkfs.f2fs: adjust zone alignment when using multi-partitionsJaegeuk Kim1-2/+10
When formatting conventional partition with zoned one, we should align the starting block address of next device to the zone size. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23fsck.f2fs: fix alignment on multi-partition supportJaegeuk Kim1-2/+3
- mkfs.f2fs -s 4 -c second_dev first_dev - fsck.f2fs first Info: Segments per section = 1 Info: Sections per zone = 1 Info: sector size = 512 Info: total sectors = 69668488 (34017 MB) Segment count (19128) mismatch with total segments from devices (19130) Can't find a valid F2FS superblock at 0x0 Segment count (19128) mismatch with total segments from devices (19130) Can't find a valid F2FS superblock at 0x1 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23f2fs-tools: Miscellaneous cleanup to README.John A. Leuenhagen1-5/+5
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23mkfs.f2fs.8: Better document the -g argument.John A. Leuenhagen via Linux-f2fs-devel1-2/+9
To use Android defaults, you must use `-g android`. However, the man page previously implied that you need only use `-g`. Since you must specify `android`, I figured it would be appropriate to name that field `default-options` in the man page. If there was ever a reason to have a different set of default options, the `-g` option could be used with a new `default-options` value, i.e. `-g example`. Signed-off-by: John A. Leuenhagen <john@zlima12.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23mkfs.f2fs.8: fix formatting for -l parameter in man pageJohn A. Leuenhagen via Linux-f2fs-devel1-0/+1
Signed-off-by: John A. Leuenhagen <john@zlima12.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23f2fs-tools: Make sload.f2fs reproduce hard linksJordan Webb5-4/+124
If sload.f2fs encounters a file with nr_links > 1, it will mark it as a possible hard link by remembering the original device and inode. When sload.f2fs creates the file, it will check if it has already created a file for the same original device and inode. If so, it will add the original inode to the directory and increment the number of links to it, instead of writing a new inode. This allows sload.f2fs to accurately reproduce a directory tree that contains hard links, such as those created by ostree. Without this patch, directory trees containing hard links result in the content of the files being duplicated. This is version 2 of the patch; it has been rebased against the dev branch and includes a fix from Jaegeuk Kim to avoid building data contents twice on hard linked files. Co-authored-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Jordan Webb <jordan@getseam.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-23f2fs-tools:sload.f2fs compression supportRobin Hsu10-27/+728
Add F2FS compression support for sload * Support file extension filter, either default-accept or default-deny policy * Support choice of compression algorithm, LZO (version 2) or LZ4 (default) * Support custom log of cluster size * Support minimum number of compressed blocks per cluster (default 1). A cluster will not be compressed if the number can not be met. * suuport -r (read-only) option This releases compressed blocks to secure free space in advance. Note that, all compressed files will have the immutable bit. * Added manpage update * Remove unecessary qbuf allocation (Jaegeuk, suggested by Satya) Signed-off-by: Robin Hsu <robinhsu@google.com> [Jaegeuk Kim: fix some bugs and refactor names] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-10f2fs_io: add compress/decompress commandsDaeho Jeong2-0/+48
Added new commands, compress and decompress, to support F2FS_IOC_COMPRESS_FILE and F2FS_IOC_DECOMPRESS_FILE. Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs-tools: Added #ifdef WITH_funcRobin Hsu1-0/+16
Add proprocessor defines (options) 'WITH_func', where func = DUMP, DEFRAG, RESIZE, or SLOAD Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs-tools: fix a few spelling errors in f2fs-toolsVictor Westerhuis5-5/+5
typo fix. Signed-off-by: Victor Westerhuis <victor@westerhu.is> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs-tools: skipped to end on error syntax errorRobin Hsu1-11/+13
When error were found, we won't need to do any initialization but just quit. Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07mkfs.f2fs: show a message when compression is enabledJaegeuk Kim1-0/+3
This patch adds a message when formatting the disk with compression. Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs_io: add get/set compression optionDaeho Jeong2-0/+70
Added new commands, get_coption and set_coption, to support F2FS_IOC_GET_COMPRESS_OPTION and F2FS_IOC_SET_COMPRESS_OPTION. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07Fix ASSERT() macro with '%' in the expressionRobin Hsu1-2/+2
Fix a compiling error triggered by ASSERT(exp), when exp contains '%' (e.g. integer modular operator) Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs-toos: fsck.f2fs Fix bad return valueRobin Hsu1-2/+3
'ret' should not have been used here: otherwise, it would be wrongly used as the error code and then be returned from main(). Signed-off-by: Robin Hsu <robinhsu@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07fsck.f2fs: do xnid sanity check only during fsckChao Yu1-1/+1
As Eric reported: Commit 7a22451bc2b4 ("fsck.f2fs: fix to check validation of i_xattr_nid") This commit caused a regression where 'dump.f2fs -i <inode> <device>' now segfaults if the inode has any extended attributes. It's because read_all_xattrs() now calls fsck_sanity_check_nid(), which eventually dereferences f2fs_fsck::main_area_bitmap, which is NULL. I'm not sure what was intended here. Here's the output from gdb: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7f750fa in f2fs_test_bit (nr=1024, p=0x0) at libf2fs.c:304 304 return (mask & *addr) != 0; (gdb) bt ntype=TYPE_XATTR, ni=0x7fffffffdd20) at fsck.c:449 ntype=TYPE_XATTR, ni=0x7fffffffdd20) at fsck.c:495 fsck_sanity_check_nid() should only called from fsck.f2fs context, rather than dump.f2fs, otherwise it may cause dereferencing structure fields of fsck incorrectly. Signed-off-by: Chao Yu <yuchao0@huawei.com>
2020-12-07f2fs_io: add erase optionOcean Chen1-1/+52
f2fs_io erase [block_device_path] Signed-off-by: Ocean Chen <oceanchen@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07mkfs.f2fs.8: document the verity featureEric Biggers1-1/+1
Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07fsck: clear unexpected casefold flagsEric Biggers1-0/+11
Inodes aren't allowed to have the casefold flag set when they aren't directories, or if the filesystem superblock doesn't have the casefold feature enabled. Clear any such unexpected casefold flags. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07mkfs.f2fs: add -h and --helpJohn A. Leuenhagen2-2/+13
These two arguments would simply print the usage message. Signed-off-by: John A. Leuenhagen <john@zlima12.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-12-07f2fs_io: change fibmap to fiemapDaeho Jeong5-22/+42
Currently we support fiemap command using fibmap. It's simple and easy to use, but we cannot use this for compressed file. To support more different types of files, we need to change this to use fiemap. Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> [Jaegeuk Kim: add Android build] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-24f2fs-tools: release 1.14.0Jaegeuk Kim2-4/+4
This release includes mainly, but not limited to: - add IO cache to speed up fsck.f2fs run - support casefolding - support data compression - support zns zone-capacity - enhance fsck.f2fs for zoned device - enhance f2fs_io tool Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20mkfs.f2fs: add -r (fake_seed) flagTheotime Combes4-2/+13
r flag sets the checkpointing seed to 0 (initially used to remove randomness for apex generation) Signed-off-by: Theotime Combes <tcombes@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20mkfs.f2fs: add -T flagTheotime Combes4-13/+28
T flag sets timestamps to a given value Signed-off-by: Theotime Combes <tcombes@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20sload.f2fs: handle root mount point properly when setting file attributeDaeho Jeong1-2/+10
Need to remove "/" of mount point name from the file path name when mount point is "/". Otherwise, we will transfer file path name whose first two characters are like "//" to fs_config function. Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20f2fs-tools: zns zone-capacity supportAravind Ramesh8-15/+190
NVM Express Zoned Namespace (ZNS) devices can have zone-capacity(zc) less than the zone-size. ZNS defines a per zone capacity which can be equal or less than the zone-size. Zone-capacity is the number of usable blocks in the zone. If zone-capacity is less than zone-size, then the segments which start at/after zone-capacity are considered unusable. Only those segments which start before the zone-capacity are considered as usable and added to the free_segment_count and free_segment_bitmap of the kernel. In such cases, the filesystem should not write/read beyond the zone-capacity. Update the super block with the usable number of blocks and free segment count in the ZNS device zones, if zone-capacity is less than zone-size. Set reserved segment count and overprovision ratio based on the usable segments in the zone. Allow fsck to find the free_segment_count based on the zone-capacity and compare with checkpoint values. Signed-off-by: Aravind Ramesh <aravind.ramesh@wdc.com> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> [Jaegeuk Kim: add UNUSED to is_usable_seg()] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20f2fs_io: measure performance of write()Jaegeuk Kim1-1/+29
Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-20f2fs_io: add OSYNC optionJaegeuk Kim1-0/+3
Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-17fsck.f2fs: correct return valueChao Yu3-12/+40
As Norbert Lange reported: " $ fsck.f2fs -a /dev/mmcblk0p5; echo $? Info: Fix the reported corruption. Info: Mounted device! Info: Check FS only on RO mounted device Error: Failed to open the device! 255 " Michael Laß reminds: " I think the return value is exactly the problem here. See fsck(8) ( https://linux.die.net/man/8/fsck) which specifies the return values. Systemd looks at these and decides how to proceed: https://github.com/systemd/systemd/blob/a859abf062cef1511e4879c4ee39c6036ebeaec8/src/fsck/fsck.c#L407 That means, if fsck.f2fs returns 255, then the FSCK_SYSTEM_SHOULD_REBOOT bit is set and systemd will reboot. " So the problem here is fsck.f2fs didn't return correct value to userspace apps, result in later unexpected behavior of rebooting, let's fix this. Reported-by: Norbert Lange <nolange79@gmail.com> Reported-by: Michael Laß <bevan@bi-co.net> Signed-off-by: Chao Yu <yuchao0@huawei.com> [Jaegeuk Kim: fix FSCK_ERROR_CORRECTED] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-08-04f2fs_io: open file in read only mode for pinning fileDaeho Jeong1-1/+1
To use "pinfile" command even with read only file, changed open mode for it. Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-20mkfs.f2fs: add casefolding and project quota configJaegeuk Kim3-0/+26
This can be used for Android build support. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-20mkfs.f2fs: should initialize sparse file in WindowsJaegeuk Kim1-0/+2
Otherwise it fails to format in Windows. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-20f2fs_io: add mmap read operationJaegeuk Kim1-1/+18
This patch adds an option, mmap, when reading data. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-15fsck.f2fs: avoid randomness in sum_blkTheotime Combes1-2/+2
This patch removes random bytes in sum_blk when loading a new directory. Signed-off-by: Theotime Combes <tcombes@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-15dump.f2fs: check block address first before reading the blockJaegeuk Kim1-2/+2
This should avoid to read out wrong block address. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-15sload.f2fs: fix missing fsck_initJaegeuk Kim1-0/+3
This patch allocates some data structures that will be used for loading files on existing image. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-09mkfs.f2fs: allow setting volume UUID manuallyZoltán Böszörményi3-2/+14
This patch adds an option to assign UUID manually. Usage: # mkfs.f2fs -U uuid_string Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-09fsck.f2fs: Split build_segment_manager() to speed up auto-fixRobin Hsu2-4/+32
Speed up fsck in auto-fix mode by splitting build_segment_manager() into two disjoint parts: early_build_segment_manager(), and late_build_segment_manager(), where in some cases (when !need_fsync_data_record(), or cannot find_fsync_inode()), late_build_segment_manager() won't be needed in auto-fix mode. This speeds up a little bit in those cases. Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-07-06dump.f2fs: dump symlink contents in lost_foundJaegeuk Kim1-1/+2
Let's allow to show symlink path. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-29fsck.f2fs: Fix slow fsck in auto-fix modeRobin Hsu1-26/+43
Split f2fs_init_nid_bitmap() into two disjoint parts: f2fs_early_init_nid_bitmap(), and f2fs_late_init_nid_bitmap(), where f2fs_late_init_nid_bitmap() won't be called in auto-fix mode, when no errors were found. f2fs_late_init_nid_bitmap() contains the loop to create NID bitmap from NAT. which is the main reason for slow fsck. Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-23fsck: prevent buffer overrun in quota codeRobin Hsu8-13/+121
A maliciously corrupted file systems can trigger buffer overruns in the quota code used by fsck. To fix it, quota file sizes are checked against real allocated block index tables (inode, direct nodes, indirect nodes, double indirect nodes). If the size mismatches, the quota file is considered corrupted and will be regenerated. Signed-off-by: Robin Hsu <robinhsu@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-18f2fs-tools: set cold flag for non-dir nodeWuyun Zhao3-0/+13
Signed-off-by: Wuyun Zhao <zhaowuyun@wingtech.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-18lib: pass all needed include paths to libf2fsRolf Eike Beer1-1/+0
Otherwise the paths to uuid and blkid headers extracted from pkg-config are not respected. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-18lib: use ${libuuid_LIBS} instead of -luuid everywhereRolf Eike Beer2-2/+2
Otherwise linking will fail if the library is in an uncommon location or has a non-standard name. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-18lib: fix include path for blkid.hRolf Eike Beer1-1/+1
$ pkg-config --cflags blkid -I/usr/include/blkid The "blkid/" directory is actually part of the include path. This usually still works because most people have the path one level up in their default include path. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2020-06-18lib: fix include path for uuid.hRolf Eike Beer3-3/+3
$ pkg-config --cflags uuid -I/usr/include/uuid The "uuid/" directory is actually part of the include path. This usually still works because most people have the path one level up in their default include path. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>