mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
f2fs-tools: support F2FS_IOC_START_ATOMIC_REPLACE
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>
This commit is contained in:
parent
76a88baa90
commit
4c2d71c5b6
@ -513,7 +513,9 @@ static void do_erase(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
" osync : O_SYNC\n" \
|
||||
" atomic_commit : atomic write & commit\n" \
|
||||
" atomic_abort : atomic write & abort\n" \
|
||||
"{delay} is in ms unit and optional only for atomic_commit and atomic_abort\n"
|
||||
" atomic_rcommit: atomic replace & commit\n" \
|
||||
" atomic_rabort : atomic replace & abort\n" \
|
||||
"{delay} is in ms unit and optional only for atomic operations\n"
|
||||
|
||||
static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
@ -524,7 +526,7 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
int flags = 0;
|
||||
int fd;
|
||||
u64 total_time = 0, max_time = 0, max_time_t = 0;
|
||||
bool atomic_commit = false, atomic_abort = false;
|
||||
bool atomic_commit = false, atomic_abort = false, replace = false;
|
||||
int useconds = 0;
|
||||
|
||||
srand(time(0));
|
||||
@ -551,18 +553,25 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
else if (strcmp(argv[4], "inc_num") && strcmp(argv[4], "rand"))
|
||||
die("Wrong pattern type");
|
||||
|
||||
if (!strcmp(argv[5], "dio"))
|
||||
if (!strcmp(argv[5], "dio")) {
|
||||
flags |= O_DIRECT;
|
||||
else if (!strcmp(argv[5], "dsync"))
|
||||
} else if (!strcmp(argv[5], "dsync")) {
|
||||
flags |= O_DIRECT | O_DSYNC;
|
||||
else if (!strcmp(argv[5], "osync"))
|
||||
} else if (!strcmp(argv[5], "osync")) {
|
||||
flags |= O_SYNC;
|
||||
else if (!strcmp(argv[5], "atomic_commit"))
|
||||
} else if (!strcmp(argv[5], "atomic_commit")) {
|
||||
atomic_commit = true;
|
||||
else if (!strcmp(argv[5], "atomic_abort"))
|
||||
} else if (!strcmp(argv[5], "atomic_abort")) {
|
||||
atomic_abort = true;
|
||||
else if (strcmp(argv[5], "buffered"))
|
||||
} else if (!strcmp(argv[5], "atomic_rcommit")) {
|
||||
atomic_commit = true;
|
||||
replace = true;
|
||||
} else if (!strcmp(argv[5], "atomic_rabort")) {
|
||||
atomic_abort = true;
|
||||
replace = true;
|
||||
} else if (strcmp(argv[5], "buffered")) {
|
||||
die("Wrong IO type");
|
||||
}
|
||||
|
||||
fd = xopen(argv[6], O_CREAT | O_WRONLY | flags, 0755);
|
||||
|
||||
@ -572,7 +581,11 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
if (argc == 8)
|
||||
useconds = atoi(argv[7]) * 1000;
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE);
|
||||
if (replace)
|
||||
ret = ioctl(fd, F2FS_IOC_START_ATOMIC_REPLACE);
|
||||
else
|
||||
ret = ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE);
|
||||
|
||||
if (ret < 0) {
|
||||
fputs("setting atomic file mode failed\n", stderr);
|
||||
exit(1);
|
||||
|
@ -90,6 +90,7 @@ typedef u32 __be32;
|
||||
struct f2fs_comp_option)
|
||||
#define F2FS_IOC_DECOMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 23)
|
||||
#define F2FS_IOC_COMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 24)
|
||||
#define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25)
|
||||
|
||||
#ifndef FSCRYPT_POLICY_V1
|
||||
#define FSCRYPT_POLICY_V1 0
|
||||
|
Loading…
Reference in New Issue
Block a user