* Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
@ 2018-01-22 20:45 Libor Bukata
2018-01-23 8:08 ` Timofey Titovets
2018-01-25 4:27 ` Mike Frysinger
0 siblings, 2 replies; 7+ messages in thread
From: Libor Bukata @ 2018-01-22 20:45 UTC (permalink / raw)
To: util-linux; +Cc: Nefelim4ag, kzak
[-- Attachment #1: Type: text/plain, Size: 216 bytes --]
Dear developers of Linux utils,
I extended the zramctl utility to handle also lz4hc and deflate formats.
The patch is included in the attachment. Thank you in advance for your
comments.
Kind regards,
Libor Bukata.
[-- Attachment #2: new_comp_alg.patch --]
[-- Type: text/x-patch, Size: 2186 bytes --]
diff --git a/sys-utils/zramctl.8 b/sys-utils/zramctl.8
index 9ca2983b9..ef44435ed 100644
--- a/sys-utils/zramctl.8
+++ b/sys-utils/zramctl.8
@@ -44,7 +44,7 @@ query the status of used zram devices.
If no option is given, all non-zero size zram devices are shown.
.SH OPTIONS
.TP
-.BR \-a , " \-\-algorithm lzo" | lz4
+.BR \-a , " \-\-algorithm lzo" | lz4 | lz4hc | deflate
Set the compression algorithm to be used for compressing data in the zram device.
.TP
.BR \-f , " \-\-find"
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index fb64150d6..9117ddce3 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -424,13 +424,16 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
char *alg = sysfs_strdup(sysfs, "comp_algorithm");
if (!alg)
break;
- if (strstr(alg, "[lzo]") == NULL) {
- if (strstr(alg, "[lz4]") == NULL)
- ;
- else
- str = xstrdup("lz4");
- } else
+
+ if (strstr(alg, "[lzo]") != NULL)
str = xstrdup("lzo");
+ else if (strstr(alg, "[lz4]") != NULL)
+ str = xstrdup("lz4");
+ else if (strstr(alg, "[lz4hc]") != NULL)
+ str = xstrdup("lz4hc");
+ else if (strstr(alg, "[deflate]") != NULL)
+ str = xstrdup("deflate");
+
free(alg);
break;
}
@@ -539,7 +542,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Set up and control zram devices.\n"), out);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --algorithm lzo|lz4 compression algorithm to use\n"), out);
+ fputs(_(" -a, --algorithm lzo|lz4|lz4hc|deflate compression algorithm to use\n"), out);
fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
fputs(_(" -f, --find find a free device\n"), out);
fputs(_(" -n, --noheadings don't print headings\n"), out);
@@ -611,7 +614,8 @@ int main(int argc, char **argv)
switch (c) {
case 'a':
- if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
+ if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4")
+ && strcmp(optarg,"lz4hc") && strcmp(optarg, "deflate"))
errx(EXIT_FAILURE, _("unsupported algorithm: %s"),
optarg);
algorithm = optarg;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-22 20:45 Patch to add support for lz4hc and deflate optimization algorithms in zramctl Libor Bukata
@ 2018-01-23 8:08 ` Timofey Titovets
2018-01-23 13:21 ` Timofey Titovets
2018-01-25 4:27 ` Mike Frysinger
1 sibling, 1 reply; 7+ messages in thread
From: Timofey Titovets @ 2018-01-23 8:08 UTC (permalink / raw)
To: Libor Bukata; +Cc: util-linux, Karel Zak
https://patchwork.kernel.org/patch/9144717/
I think your patch miss support of 842 algo
2018-01-22 23:45 GMT+03:00 Libor Bukata <lbukata@gmail.com>:
> Dear developers of Linux utils,
>
> I extended the zramctl utility to handle also lz4hc and deflate formats.
> The patch is included in the attachment. Thank you in advance for your
> comments.
>
> Kind regards,
> Libor Bukata.
--
Have a nice day,
Timofey.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-23 8:08 ` Timofey Titovets
@ 2018-01-23 13:21 ` Timofey Titovets
2018-01-23 17:57 ` Libor Bukata
0 siblings, 1 reply; 7+ messages in thread
From: Timofey Titovets @ 2018-01-23 13:21 UTC (permalink / raw)
To: Libor Bukata; +Cc: util-linux, Karel Zak
Also, use https://github.com/karelzak/util-linux and PR,
also add comment + Signed-off-by to patch.
2018-01-23 11:08 GMT+03:00 Timofey Titovets <nefelim4ag@gmail.com>:
> https://patchwork.kernel.org/patch/9144717/
>
> I think your patch miss support of 842 algo
>
> 2018-01-22 23:45 GMT+03:00 Libor Bukata <lbukata@gmail.com>:
>> Dear developers of Linux utils,
>>
>> I extended the zramctl utility to handle also lz4hc and deflate formats.
>> The patch is included in the attachment. Thank you in advance for your
>> comments.
>>
>> Kind regards,
>> Libor Bukata.
>
>
>
> --
> Have a nice day,
> Timofey.
--
Have a nice day,
Timofey.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-23 13:21 ` Timofey Titovets
@ 2018-01-23 17:57 ` Libor Bukata
2018-01-23 18:33 ` Timofey Titovets
2018-01-24 13:38 ` Karel Zak
0 siblings, 2 replies; 7+ messages in thread
From: Libor Bukata @ 2018-01-23 17:57 UTC (permalink / raw)
To: Timofey Titovets; +Cc: util-linux, Karel Zak
[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]
Thank you for your comments. I added the support for 842 compression
algorithm. The included patch is signed and tested on the latest
versions of both Git repositories:
git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
git://github.com/karelzak/util-linux.git
I am not sure what you meant by: "Also, use
https://github.com/karelzak/util-linux and PR, .."
If it is important, please do not hesitate to provide me more
information in order to fix it.
Have a nice day,
Libor.
Dne 23.1.2018 v 14:21 Timofey Titovets napsal(a):
> Also, use https://github.com/karelzak/util-linux and PR,
> also add comment + Signed-off-by to patch.
>
> 2018-01-23 11:08 GMT+03:00 Timofey Titovets <nefelim4ag@gmail.com>:
>> https://patchwork.kernel.org/patch/9144717/
>>
>> I think your patch miss support of 842 algo
>>
>> 2018-01-22 23:45 GMT+03:00 Libor Bukata <lbukata@gmail.com>:
>>> Dear developers of Linux utils,
>>>
>>> I extended the zramctl utility to handle also lz4hc and deflate formats.
>>> The patch is included in the attachment. Thank you in advance for your
>>> comments.
>>>
>>> Kind regards,
>>> Libor Bukata.
>>
>>
>> --
>> Have a nice day,
>> Timofey.
>
>
[-- Attachment #2: 0001-Added-the-support-for-lz4hc-deflate-and-842.patch --]
[-- Type: text/x-patch, Size: 2740 bytes --]
>From 9b48fba08a630bd90c29078a621e2725fb0c940e Mon Sep 17 00:00:00 2001
From: Libor Bukata <lbukata@gmail.com>
Date: Tue, 23 Jan 2018 18:34:01 +0100
Subject: [PATCH] Added the support for lz4hc, deflate, and 842 compression
algorithms in zramctl utility.
Signed-off-by: Libor Bukata <lbukata@gmail.com>
---
sys-utils/zramctl.8 | 2 +-
sys-utils/zramctl.c | 22 ++++++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/sys-utils/zramctl.8 b/sys-utils/zramctl.8
index 9ca2983b9..679a8a175 100644
--- a/sys-utils/zramctl.8
+++ b/sys-utils/zramctl.8
@@ -44,7 +44,7 @@ query the status of used zram devices.
If no option is given, all non-zero size zram devices are shown.
.SH OPTIONS
.TP
-.BR \-a , " \-\-algorithm lzo" | lz4
+.BR \-a , " \-\-algorithm lzo" | lz4 | lz4hc | deflate | 842
Set the compression algorithm to be used for compressing data in the zram device.
.TP
.BR \-f , " \-\-find"
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index fb64150d6..0331045c8 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -424,13 +424,18 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
char *alg = sysfs_strdup(sysfs, "comp_algorithm");
if (!alg)
break;
- if (strstr(alg, "[lzo]") == NULL) {
- if (strstr(alg, "[lz4]") == NULL)
- ;
- else
- str = xstrdup("lz4");
- } else
+
+ if (strstr(alg, "[lzo]") != NULL)
str = xstrdup("lzo");
+ else if (strstr(alg, "[lz4]") != NULL)
+ str = xstrdup("lz4");
+ else if (strstr(alg, "[lz4hc]") != NULL)
+ str = xstrdup("lz4hc");
+ else if (strstr(alg, "[deflate]") != NULL)
+ str = xstrdup("deflate");
+ else if (strstr(alg, "[842]") != NULL)
+ str = xstrdup("842");
+
free(alg);
break;
}
@@ -539,7 +544,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Set up and control zram devices.\n"), out);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --algorithm lzo|lz4 compression algorithm to use\n"), out);
+ fputs(_(" -a, --algorithm lzo|lz4|lz4hc|deflate|842 compression algorithm to use\n"), out);
fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
fputs(_(" -f, --find find a free device\n"), out);
fputs(_(" -n, --noheadings don't print headings\n"), out);
@@ -611,7 +616,8 @@ int main(int argc, char **argv)
switch (c) {
case 'a':
- if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
+ if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4") && strcmp(optarg,"lz4hc")
+ && strcmp(optarg,"deflate") && strcmp(optarg,"842"))
errx(EXIT_FAILURE, _("unsupported algorithm: %s"),
optarg);
algorithm = optarg;
--
2.13.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-23 17:57 ` Libor Bukata
@ 2018-01-23 18:33 ` Timofey Titovets
2018-01-24 13:38 ` Karel Zak
1 sibling, 0 replies; 7+ messages in thread
From: Timofey Titovets @ 2018-01-23 18:33 UTC (permalink / raw)
To: Libor Bukata; +Cc: util-linux, Karel Zak
I mean, that you can use GitHub and pull request for that change =)
Instead of mail and patch in attachment
2018-01-23 20:57 GMT+03:00 Libor Bukata <lbukata@gmail.com>:
> Thank you for your comments. I added the support for 842 compression
> algorithm. The included patch is signed and tested on the latest
> versions of both Git repositories:
>
> git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
> git://github.com/karelzak/util-linux.git
>
> I am not sure what you meant by: "Also, use
> https://github.com/karelzak/util-linux and PR, .."
> If it is important, please do not hesitate to provide me more
> information in order to fix it.
>
> Have a nice day,
> Libor.
>
> Dne 23.1.2018 v 14:21 Timofey Titovets napsal(a):
>> Also, use https://github.com/karelzak/util-linux and PR,
>> also add comment + Signed-off-by to patch.
>>
>> 2018-01-23 11:08 GMT+03:00 Timofey Titovets <nefelim4ag@gmail.com>:
>>> https://patchwork.kernel.org/patch/9144717/
>>>
>>> I think your patch miss support of 842 algo
>>>
>>> 2018-01-22 23:45 GMT+03:00 Libor Bukata <lbukata@gmail.com>:
>>>> Dear developers of Linux utils,
>>>>
>>>> I extended the zramctl utility to handle also lz4hc and deflate formats.
>>>> The patch is included in the attachment. Thank you in advance for your
>>>> comments.
>>>>
>>>> Kind regards,
>>>> Libor Bukata.
>>>
>>>
>>> --
>>> Have a nice day,
>>> Timofey.
>>
>>
>
--
Have a nice day,
Timofey.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-23 17:57 ` Libor Bukata
2018-01-23 18:33 ` Timofey Titovets
@ 2018-01-24 13:38 ` Karel Zak
1 sibling, 0 replies; 7+ messages in thread
From: Karel Zak @ 2018-01-24 13:38 UTC (permalink / raw)
To: Libor Bukata; +Cc: Timofey Titovets, util-linux
On Tue, Jan 23, 2018 at 06:57:06PM +0100, Libor Bukata wrote:
> Thank you for your comments. I added the support for 842 compression
> algorithm.
@@ -424,13 +424,18 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
char *alg = sysfs_strdup(sysfs, "comp_algorithm");
if (!alg)
break;
- if (strstr(alg, "[lzo]") == NULL) {
- if (strstr(alg, "[lz4]") == NULL)
- ;
- else
- str = xstrdup("lz4");
- } else
+
+ if (strstr(alg, "[lzo]") != NULL)
str = xstrdup("lzo");
+ else if (strstr(alg, "[lz4]") != NULL)
+ str = xstrdup("lz4");
+ else if (strstr(alg, "[lz4hc]") != NULL)
+ str = xstrdup("lz4hc");
+ else if (strstr(alg, "[deflate]") != NULL)
+ str = xstrdup("deflate");
+ else if (strstr(alg, "[842]") != NULL)
+ str = xstrdup("842");
+
The question is if we really need to care about the algorithm string
at all. I think it would be better to accept arbitrary string from
sysfs and just remove "[" and "]" from the string only.
switch (c) {
case 'a':
- if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
+ if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4") && strcmp(optarg,"lz4hc")
+ && strcmp(optarg,"deflate") && strcmp(optarg,"842"))
errx(EXIT_FAILURE, _("unsupported algorithm: %s"),
The same situation. I guess we can accept arbitrary string here and
assume that kernel is smart enough to reject requests to use wrong
algorithm name.
Karel
--
2.13.6
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
2018-01-22 20:45 Patch to add support for lz4hc and deflate optimization algorithms in zramctl Libor Bukata
2018-01-23 8:08 ` Timofey Titovets
@ 2018-01-25 4:27 ` Mike Frysinger
1 sibling, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2018-01-25 4:27 UTC (permalink / raw)
To: Libor Bukata; +Cc: util-linux, Nefelim4ag, kzak
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
On 22 Jan 2018 21:45, Libor Bukata wrote:
> + if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4")
> + && strcmp(optarg,"lz4hc") && strcmp(optarg, "deflate"))
not exactly a new issue, but there should be a space after each of those commas
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-25 4:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 20:45 Patch to add support for lz4hc and deflate optimization algorithms in zramctl Libor Bukata
2018-01-23 8:08 ` Timofey Titovets
2018-01-23 13:21 ` Timofey Titovets
2018-01-23 17:57 ` Libor Bukata
2018-01-23 18:33 ` Timofey Titovets
2018-01-24 13:38 ` Karel Zak
2018-01-25 4:27 ` Mike Frysinger
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).