F2FS_BLKSIZE and 4096 are both used in f2fs_io for
IO/buffer size, but F2FS_BLKSIZE may confuse user becasue
it may be 4KB, 16KB, so use macro F2FS_DEFAULT_BLKSIZE
to unify F2FS_BLKSIZE and 4096 in f2fs_io, also adjust
"-c" parameters in mkfs man, to be consistent with commit
c35fa8cd75 ("mkfs.f2fs: change -c option description").
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Hand over immutable flag clearing functionality from setflags to
clearflags, since the flag name is immutable rather than noimmutable.
And support setting functionality in subcommand setflags.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When using the f2fs_io tool to set_verity, it will fail as follows:
unisc:/data # ./f2fs_io set_verity file
FS_IOC_ENABLE_VERITY: Inappropriate ioctl for device
this is because commit: 95ae251fe828 ("f2fs: add fs-verity support"),
the passed parameters do not match the latest kernel version.
After patch:
unisoc:/data # ./f2fs_io set_verity file
Set fsverity bit to file
unisoc:/data # ./f2fs_io getflags file
get a flag on file ret=0, flags=verity
Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
If input exceeds int range, data will be truncated, such as lseek:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=2147483647
The offset is truncated.
After patch:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=3221225000
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
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>
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>
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>
This patch replaces lseek64 with lseek() having #define _FILE_OFFSET_BITS 64.
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
To align f2fs_io functionality with chattr +/-c and +/-m, the
do_clearflags function has been added to clear the FS_COMPR_FL and
FS_NOCOMP_FL flags.
Signed-off-by: Qi Han <hanqi@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This replaces the mmmap read flow to get the maximum performance.
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
external/f2fs-tools/tools/f2fs_io/f2fs_io.c:1452:3: error: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Werror,-Wformat]
range.start, range.len, ret);
^~~~~~~~~~~
external/f2fs-tools/tools/f2fs_io/f2fs_io.c:1452:16: error: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Werror,-Wformat]
range.start, range.len, ret);
^~~~~~~~~
2 errors generated.
20:35:27 ninja failed with: exit status 1
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Expend fallocate command to support more flags.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'gc_range' in f2fs_io to trigger
gc to move blocks in specified range via F2FS_IOC_GARBAGE_COLLECT_RANGE
ioctl.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
When using fiemap to obtain the block address of files
larger than 2GB ((2147483647+1) bytes), an integer
multiplication overflow error will occur.
This issue is caused by the following code:
start = atoi(argv[1]) * F2FS_BLKSIZE;
length = atoi(argv[2]) * F2FS_BLKSIZE;
Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Disk quota file is controlled by filesystem quota subsystem, access time
of quota file is almost random, and should be meanless to user, so let's
add noatime to quota file.
Meanwhile, set quota file w/ F2FS_IMMUTABLE_FL instead of FS_IMMUTABLE_FL,
since F2FS_IMMUTABLE_FL is on-disk flag, however FS_IMMUTABLE_FL is in-memory
one.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'move_range' in f2fs_io
to move a range of data blocks from source file to destination
file via F2FS_IOC_MOVE_RANGE ioctl.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'precache_extents' in f2fs_io
to trigger precache extents via F2FS_IOC_PRECACHE_EXTENTS ioctl.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This patch supports a new sub-command 'checkpoint' in f2fs_io to
trigger filesystem checkpoint via F2FS_IOC_WRITE_CHECKPOINT ioctl.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
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>
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>
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>
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>
__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>
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>
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>
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>
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>
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>
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>