Skip to content

Commit

Permalink
f2fs_io: {set,clear}flags: support nocow flag
Browse files Browse the repository at this point in the history
This patch supports to set or clear nocow flag in f2fs_io

Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
chaseyu authored and Jaegeuk Kim committed Oct 21, 2024
1 parent bce0e1e commit 43d6b66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions man/f2fs_io.8
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Get the flags associated with the specified file.
.TP
\fBsetflags\fR \fI[flag] [file]\fR
Set an f2fs file on specified file. The flag can be casefold,
compression, nocompression, and immutable.
compression, nocompression, immutable, and nocow.
.TP
\fBclearflags\fR \fI[flag] [file]\fR
Clear the specified flag on the target file, which can be compression,
nocompression and immutable.
nocompression, immutable, and nocow.
.TP
\fBshutdown\fR \fIshutdown filesystem\fR
Freeze and stop all IOs for the file system mounted on
Expand Down
10 changes: 8 additions & 2 deletions tools/f2fs_io/f2fs_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)
" casefold\n" \
" compression\n" \
" nocompression\n" \
" immutable\n"
" immutable\n" \
" nocow\n"

static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
{
Expand Down Expand Up @@ -346,6 +347,8 @@ static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
flag |= FS_NOCOMP_FL;
else if (!strcmp(argv[1], "immutable"))
flag |= FS_IMMUTABLE_FL;
else if (!strcmp(argv[1], "nocow"))
flag |= FS_NOCOW_FL;

ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
printf("set a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
Expand All @@ -359,7 +362,8 @@ static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
"flag can be\n" \
" compression\n" \
" nocompression\n" \
" immutable\n"
" immutable\n" \
" nocow\n"

static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
{
Expand All @@ -385,6 +389,8 @@ static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
flag &= ~FS_NOCOMP_FL;
else if (!strcmp(argv[1], "immutable"))
flag &= ~FS_IMMUTABLE_FL;
else if (!strcmp(argv[1], "nocow"))
flag &= ~FS_NOCOW_FL;

ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
printf("clear a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
Expand Down

0 comments on commit 43d6b66

Please sign in to comment.