diff mbox series

[f2fs-dev] f2fs_io: support unset subcommand for pinfile

Message ID 20240329102542.3577458-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs_io: support unset subcommand for pinfile | expand

Commit Message

Chao Yu March 29, 2024, 10:25 a.m. UTC
This patch adds unset subcommand for pinfile command.

Usage: f2fs_io pinfile unset [target_file]

Signed-off-by: Chao Yu <chao@kernel.org>
---
 man/f2fs_io.8           |  2 +-
 tools/f2fs_io/f2fs_io.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Chao Yu April 10, 2024, 3:24 a.m. UTC | #1
Ping,

Missed to check this patch?

On 2024/3/29 18:25, Chao Yu wrote:
> This patch adds unset subcommand for pinfile command.
> 
> Usage: f2fs_io pinfile unset [target_file]
> 
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>   man/f2fs_io.8           |  2 +-
>   tools/f2fs_io/f2fs_io.c | 11 +++++++++--
>   2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
> index f097bde..b9c9dc8 100644
> --- a/man/f2fs_io.8
> +++ b/man/f2fs_io.8
> @@ -44,7 +44,7 @@ going down with metadata flush
>   going down with fsck mark
>   .RE
>   .TP
> -\fBpinfile\fR \fI[get|set] [file]\fR
> +\fBpinfile\fR \fI[get|set|unset] [file]\fR
>   Get or set the pinning status on a file.
>   .TP
>   \fBfadvise\fR \fI[advice] [offset] [length] [file]\fR
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index b8e4f02..a7b593a 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -442,7 +442,7 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
>   
>   #define pinfile_desc "pin file control"
>   #define pinfile_help						\
> -"f2fs_io pinfile [get|set] [file]\n\n"			\
> +"f2fs_io pinfile [get|set|unset] [file]\n\n"			\
>   "get/set pinning given the file\n"				\
>   
>   static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
> @@ -464,7 +464,14 @@ static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
>   		ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
>   		if (ret != 0)
>   			die_errno("F2FS_IOC_SET_PIN_FILE failed");
> -		printf("set_pin_file: %u blocks moved in %s\n", ret, argv[2]);
> +		printf("%s pinfile: %u blocks moved in %s\n",
> +					argv[1], ret, argv[2]);
> +	} else if (!strcmp(argv[1], "unset")) {
> +		pin = 0;
> +		ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
> +		if (ret != 0)
> +			die_errno("F2FS_IOC_SET_PIN_FILE failed");
> +		printf("%s pinfile in %s\n", argv[1], argv[2]);
>   	} else if (!strcmp(argv[1], "get")) {
>   		unsigned int flags;
>
Daeho Jeong April 10, 2024, 5:55 p.m. UTC | #2
On Tue, Apr 9, 2024 at 8:27 PM Chao Yu <chao@kernel.org> wrote:
>
> Ping,
>
> Missed to check this patch?
>
> On 2024/3/29 18:25, Chao Yu wrote:
> > This patch adds unset subcommand for pinfile command.
> >
> > Usage: f2fs_io pinfile unset [target_file]
> >
> > Signed-off-by: Chao Yu <chao@kernel.org>
> > ---
> >   man/f2fs_io.8           |  2 +-
> >   tools/f2fs_io/f2fs_io.c | 11 +++++++++--
> >   2 files changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
> > index f097bde..b9c9dc8 100644
> > --- a/man/f2fs_io.8
> > +++ b/man/f2fs_io.8
> > @@ -44,7 +44,7 @@ going down with metadata flush
> >   going down with fsck mark
> >   .RE
> >   .TP
> > -\fBpinfile\fR \fI[get|set] [file]\fR
> > +\fBpinfile\fR \fI[get|set|unset] [file]\fR
> >   Get or set the pinning status on a file.
> >   .TP
> >   \fBfadvise\fR \fI[advice] [offset] [length] [file]\fR
> > diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> > index b8e4f02..a7b593a 100644
> > --- a/tools/f2fs_io/f2fs_io.c
> > +++ b/tools/f2fs_io/f2fs_io.c
> > @@ -442,7 +442,7 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
> >
> >   #define pinfile_desc "pin file control"
> >   #define pinfile_help                                                \
> > -"f2fs_io pinfile [get|set] [file]\n\n"                       \
> > +"f2fs_io pinfile [get|set|unset] [file]\n\n"                 \
> >   "get/set pinning given the file\n"                          \
> >
> >   static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
> > @@ -464,7 +464,14 @@ static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
> >               ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
> >               if (ret != 0)
> >                       die_errno("F2FS_IOC_SET_PIN_FILE failed");
> > -             printf("set_pin_file: %u blocks moved in %s\n", ret, argv[2]);
> > +             printf("%s pinfile: %u blocks moved in %s\n",
> > +                                     argv[1], ret, argv[2]);
> > +     } else if (!strcmp(argv[1], "unset")) {
> > +             pin = 0;
> > +             ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
> > +             if (ret != 0)
> > +                     die_errno("F2FS_IOC_SET_PIN_FILE failed");
> > +             printf("%s pinfile in %s\n", argv[1], argv[2]);
> >       } else if (!strcmp(argv[1], "get")) {
> >               unsigned int flags;
> >
>

Reviewed-by: Daeho Jeong <daehojeong@google.com>

Thanks,

>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
diff mbox series

Patch

diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index f097bde..b9c9dc8 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -44,7 +44,7 @@  going down with metadata flush
 going down with fsck mark
 .RE
 .TP
-\fBpinfile\fR \fI[get|set] [file]\fR
+\fBpinfile\fR \fI[get|set|unset] [file]\fR
 Get or set the pinning status on a file.
 .TP
 \fBfadvise\fR \fI[advice] [offset] [length] [file]\fR
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index b8e4f02..a7b593a 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -442,7 +442,7 @@  static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
 
 #define pinfile_desc "pin file control"
 #define pinfile_help						\
-"f2fs_io pinfile [get|set] [file]\n\n"			\
+"f2fs_io pinfile [get|set|unset] [file]\n\n"			\
 "get/set pinning given the file\n"				\
 
 static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
@@ -464,7 +464,14 @@  static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
 		ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
 		if (ret != 0)
 			die_errno("F2FS_IOC_SET_PIN_FILE failed");
-		printf("set_pin_file: %u blocks moved in %s\n", ret, argv[2]);
+		printf("%s pinfile: %u blocks moved in %s\n",
+					argv[1], ret, argv[2]);
+	} else if (!strcmp(argv[1], "unset")) {
+		pin = 0;
+		ret = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &pin);
+		if (ret != 0)
+			die_errno("F2FS_IOC_SET_PIN_FILE failed");
+		printf("%s pinfile in %s\n", argv[1], argv[2]);
 	} else if (!strcmp(argv[1], "get")) {
 		unsigned int flags;