From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Daeho Jeong <daeho43@gmail.com>
Cc: Daeho Jeong <daehojeong@google.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs_io: add get/set compression option
Date: Mon, 2 Nov 2020 08:16:35 -0800 [thread overview]
Message-ID: <20201102161635.GC529594@google.com> (raw)
In-Reply-To: <20201102002940.1450284-1-daeho43@gmail.com>
On 11/02, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> 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>
> ---
> tools/f2fs_io/f2fs_io.c | 61 +++++++++++++++++++++++++++++++++++++++++
> tools/f2fs_io/f2fs_io.h | 9 ++++++
> 2 files changed, 70 insertions(+)
>
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index 5a2d06e..dab0d14 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -905,6 +905,65 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd
> exit(0);
> }
>
> +#define get_coption_desc "get compression option of a compressed file"
> +#define get_coption_help \
> +"f2fs_io get_coption [file]\n\n" \
> +" algorithm : compression algorithm (0:lzo, 1: lz4, 2:zstd, 3:lzorle)\n" \
> +" log_cluster_size : compression cluster log size (2 <= log_size <= 8)\n"
> +
> +static void do_get_coption(int argc, char **argv, const struct cmd_desc *cmd)
> +{
> + struct f2fs_comp_option option;
> + int ret, fd;
> +
> + if (argc != 2) {
> + fputs("Excess arguments\n\n", stderr);
> + fputs(cmd->cmd_help, stderr);
> + exit(1);
> + }
> +
> + fd = xopen(argv[1], O_RDONLY, 0);
> +
> + ret = ioctl(fd, F2FS_IOC_GET_COMPRESS_OPTION, &option);
> + if (ret < 0)
> + die_errno("F2FS_IOC_GET_COMPRESS_OPTION failed");
> +
> + printf("compression algorithm:%u\n", option.algorithm);
> + printf("compression cluster log size:%u\n", option.log_cluster_size);
> +
> + exit(0);
> +}
> +
> +#define set_coption_desc "set compression option of a compressed file"
> +#define set_coption_help \
> +"f2fs_io set_coption [algorithm] [log_cluster_size] [file_path]\n\n" \
> +" algorithm : compression algorithm (0:lzo, 1: lz4, 2:zstd, 3:lzorle)\n" \
> +" log_cluster_size : compression cluster log size (2 <= log_size <= 8)\n"
> +
> +static void do_set_coption(int argc, char **argv, const struct cmd_desc *cmd)
> +{
> + struct f2fs_comp_option option;
> + int fd, ret;
> +
> + if (argc != 4) {
> + fputs("Excess arguments\n\n", stderr);
> + fputs(cmd->cmd_help, stderr);
> + exit(1);
> + }
> +
> + option.algorithm = atoi(argv[1]);
> + option.log_cluster_size = atoi(argv[2]);
> +
> + fd = xopen(argv[3], O_RDONLY, 0);
O_WRONLY?
> +
> + ret = ioctl(fd, F2FS_IOC_SET_COMPRESS_OPTION, &option);
> + if (ret < 0)
> + die_errno("F2FS_IOC_SET_COMPRESS_OPTION failed");
> +
> + printf("set compression option: algorithm=%u, log_cluster_size=%u\n",
> + option.algorithm, option.log_cluster_size);
> + exit(0);
> +}
>
> #define CMD_HIDDEN 0x0001
> #define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 }
> @@ -930,6 +989,8 @@ const struct cmd_desc cmd_list[] = {
> CMD(get_cblocks),
> CMD(release_cblocks),
> CMD(reserve_cblocks),
> + CMD(get_coption),
> + CMD(set_coption),
> { NULL, NULL, NULL, NULL, 0 }
> };
>
> diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
> index 05d4cfe..cb56e8c 100644
> --- a/tools/f2fs_io/f2fs_io.h
> +++ b/tools/f2fs_io/f2fs_io.h
> @@ -84,6 +84,10 @@ typedef u32 __be32;
> _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
> #define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
> _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
> +#define F2FS_IOC_GET_COMPRESS_OPTION _IOR(F2FS_IOCTL_MAGIC, 21, \
> + struct f2fs_comp_option)
> +#define F2FS_IOC_SET_COMPRESS_OPTION _IOW(F2FS_IOCTL_MAGIC, 22, \
> + struct f2fs_comp_option)
>
> #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
> #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
> @@ -164,3 +168,8 @@ struct f2fs_flush_device {
> u32 dev_num; /* device number to flush */
> u32 segments; /* # of segments to flush */
> };
> +
> +struct f2fs_comp_option {
> + u8 algorithm;
> + u8 log_cluster_size;
> +};
> --
> 2.29.1.341.ge80a0c044ae-goog
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2020-11-02 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-02 0:29 [f2fs-dev] [PATCH] f2fs_io: add get/set compression option Daeho Jeong
2020-11-02 16:16 ` Jaegeuk Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201102161635.GC529594@google.com \
--to=jaegeuk@kernel.org \
--cc=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).