Sync from SUSE:SLFO:Main zram-generator revision 198e0ca180cfb6925099ad92577dafc5

This commit is contained in:
Adrian Schröter 2024-08-28 11:05:12 +02:00
commit a02c5f0082
12 changed files with 557 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

26
_service Normal file
View File

@ -0,0 +1,26 @@
<services>
<service mode="disabled" name="obs_scm">
<param name="url">https://github.com/systemd/zram-generator.git</param>
<param name="versionformat">@PARENT_TAG@</param>
<param name="scm">git</param>
<param name="revision">v1.1.2</param>
<param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param>
<param name="versionrewrite-replacement">\1</param>
<param name="changesgenerate">enable</param>
<param name="changesauthor">bbrunner@suse.com</param>
</service>
<service mode="disabled" name="tar" />
<service mode="disabled" name="recompress">
<param name="file">*.tar</param>
<param name="compression">xz</param>
</service>
<service mode="disabled" name="set_version"/>
<service name="cargo_vendor" mode="disabled">
<param name="srcdir">zram-generator</param>
<param name="compression">xz</param>
<param name="update">true</param>
</service>
<service name="cargo_audit" mode="disabled">
<param name="srcdir">zram-generator</param>
</service>
</services>

4
_servicedata Normal file
View File

@ -0,0 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/systemd/zram-generator.git</param>
<param name="changesrevision">1bf6b08d8bd15624280482b1c125902f90c706aa</param></service></servicedata>

5
cargo_config Normal file
View File

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

BIN
vendor.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
zram-generator-1.1.2.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

1
zram-generator-rpmlintrc Normal file
View File

@ -0,0 +1 @@
addFilter(".*systemd-service-without-service.*")

89
zram-generator.8 Normal file
View File

@ -0,0 +1,89 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ZRAM\-GENERATOR" "8" "November 2021" "zram-generator developers" ""
.
.SH "NAME"
\fBzram\-generator\fR \- Systemd unit generator for zram swap devices
.
.SH "SYNOPSIS"
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \fBTARGET_DIR\fR [\fI2RGET_DIR\fR \fI3RGET_DIR\fR]
.
.br
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \-\-setup\-device \fBDEVICE\fR
.
.br
\fB/usr/lib/systemd/system\-generators/zram\-generator\fR \-\-reset\-device \fBDEVICE\fR
.
.SH "DESCRIPTION"
\fBzram\-generator\fR is a generator that creates systemd units to format and use compressed RAM devices, either as swap or a file system\.
.
.P
The generator will be invoked by systemd early at boot\. The generator will then:
.
.IP "1." 4
read configuration files from \fI{/etc,/lib}/systemd/zram\-generator\.conf[\.d]\fR (see zram\-generator\.conf(5) for details);
.
.IP "2." 4
generate systemd\.swap(5) and/or systemd\.mount(5) units into \fBTARGET_DIR\fR and connect them to \fBswap\.target\fR or \fBlocal\-fs\.target\fR as appropriate;
.
.IP "3." 4
ensure the \fBzram\fR module is loaded and create the requested devices\.
.
.IP "" 0
.
.P
The generator does nothing if run inside a container (as determined by \fIsystemd\-detect\-virt(8) \-\-container\fR)\.
.
.P
The generator also understands the kernel command\-line option \fBsystemd\.zram\fR\. See zram\-generator\.conf(5) for details\.
.
.P
Setting the \fBZRAM_GENERATOR_ROOT\fR environment variable makes the generator run in test mode, in which case containerisation is ignored and step \fB3\fR is skipped\.
.
.br
For the ramifications of \fBZRAM_GENERATOR_ROOT\fR on config handling, see zram\-generator\.conf(5)\.
.
.P
Generated \fIdev\-zramN\.swap\fR units depend on \fBsystemd\-zram\-setup@zramN\.service\fR, which will:
.
.IP "1." 4
read configuration files from \fI{/etc,/lib}/systemd/zram\-generator\.conf[\.d]\fR (see zram\-generator\.conf(5) for details);
.
.IP "2." 4
set the desired compression algorithm, if any; if the current kernel doesn\'t understand the specified algorithm, a warning is issued, but execution continues;
.
.IP "3." 4
set the desired blockdev size and format it as swap with \fIsystemd\-makefs(8)\fR\.
.
.IP "" 0
.
.P
Generated \fIpath\-to\-mount\-point\.mount\fR units depend on \fBsystemd\-zram\-setup@zramN\.service\fR\. The effect is similar to what happens for swap units, but of course they are formatted with a file system\.
.
.P
When the unit is stopped, the zram device is reset, freeing memory and allowing the device to be reused\.
.
.P
\fBzram\-generator\fR implements systemd\.generator(7)\.
.
.SS "Applying config changes"
This generator is invoked in early boot, and the devices it configures will be created very early too, so the easiest way to apply config changes is to simply reboot the machine\.
.
.P
Nevertheless, sometimes it may be useful to add new devices or apply config changes at runtime\. Applying new configuration means restarting the units, and that in turn means recreating the zram devices\. This means that \fIfile systems are temporarily unmounted and their contents lost\fR, and \fIpages are moved out of the compressed swap device\fR into other memory\. If this is acceptable, \fBsystemctl restart systemd\-zram\-setup@zramN\fR or \fBsystemctl restart systemd\-zram\-setup@*\fR may be used to recreate a specific device or all configured devices\. (If the device didn\'t exist, \fBrestart\fR will create it\.) If the way the device is used (e\.g\. the mount point or file system type) is changed, \fBsystemctl daemon\-reload\fR needs to be called first to recreate systemd units\. If a device or mount point is removed from configuration, the unit should be stopped before calling \fBdaemon\-reload\fR\. Otherwise, systemd will not know how to stop the unit properly\.
.
.SH "REPORTING BUGS"
\fIhttps://github\.com/systemd/zram\-generator/issues\fR
.
.SH "SEE ALSO"
zram\-generator\.conf(5), systemd\.generator(7), systemd\.swap(5)
.
.P
\fIhttps://github\.com/systemd/zram\-generator\fR
.
.P
Linux documentation of zram: \fIhttps://kernel\.org/doc/html/latest/admin\-guide/blockdev/zram\.html\fR
.
.br
and the zram sysfs ABI: \fIhttps://kernel\.org/doc/Documentation/ABI/testing/sysfs\-block\-zram\fR

70
zram-generator.changes Normal file
View File

@ -0,0 +1,70 @@
-------------------------------------------------------------------
Wed Jun 29 07:44:43 UTC 2022 - Benjamin Brunner <bbrunner@suse.com>
- Fixed typo in description (bsc#1200961)
- Updated vendor.tar.xz
-------------------------------------------------------------------
Mon May 2 07:54:51 UTC 2022 - Ferdinand Thiessen <rpm@fthiessen.de>
- Update to version 1.1.2:
* Stable release version
- Updated vendor.tar.xz
-------------------------------------------------------------------
Wed Mar 02 14:18:21 UTC 2022 - bbrunner@suse.com
- Update to version 1.1.1~git6.6923dc2:
* Suggest /var/compressed instead of /var/tmp in README
* Update install from source instruction
- Updated vendor.tar.xz
-------------------------------------------------------------------
Fri Jan 7 01:26:50 UTC 2022 - William Brown <william.brown@suse.com>
Updated vendor.tar.xz to
- not create uninitialized values in smallvec-crate
(bsc#1194113, CVE-2018-25023)
- fix a possible data race and memory corruption when using a closed
`oneshot` channel in tokio-crate (bsc#1194119, CVE-2021-45710)
-------------------------------------------------------------------
Fri Jan 07 01:25:47 UTC 2022 - bbrunner@suse.com
- Update to version 1.1.1~git5.8612dbb:
* Update install from source instruction
* Document workaround for making zram mounts user-writable (c.f. #146)
* Issue warning if /s/b/z0/backing_dev doesn't exist and wb-dev= set
* Skip test if unshare fails
* Accept NOMAN in Makefile, disabling build: and install: manpage processing
* Version 1.1.1
* Bump minimum rust-ini to 0.15, first one with ordered keys
* Don't CLONE_NEWUSER when already root. Privatise all mounts first
* Add Aqs around README mails
* Update my author mail
-------------------------------------------------------------------
Fri Nov 26 15:16:23 UTC 2021 - Benjamin Brunner <bbrunner@suse.com>
- Temporary pre-generate man-pages, to avoid dependency on
rubygem-ronn, which is no longer maintained
-------------------------------------------------------------------
Thu Nov 11 08:54:15 UTC 2021 - Benjamin Brunner <bbrunner@suse.com>
- Update to version 1.0.1~git25.5e0ec60:
* make: add BUILDTYPE switch
* make: add "clippy" target
* Use ?= instead of = for Makefile defaults
* Do not warn on deprecated options
* Fix the reference to the directory/device option name
* Fix clippy
* Fix clippy job
* Warn on deprecated memory-limit
* Remove deprecated values from test data, move their tests to 11-obsolete
* Obsolete zram-fraction and max-zram-size in favour of new, arbitrary-expression, zram-size
-------------------------------------------------------------------
Wed Nov 3 12:12:53 UTC 2021 - Benjamin Brunner <bbrunner@suse.com>
- Initial package for zram-generator (jsc#SLE-18818)

248
zram-generator.conf.5 Normal file
View File

@ -0,0 +1,248 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ZRAM\-GENERATOR\.CONF" "5" "November 2021" "zram-generator developers" ""
.
.SH "NAME"
\fBzram\-generator\.conf\fR \- Systemd unit generator for zram swap devices (configuration)
.
.SH "SYNOPSIS"
\fB/usr/lib/systemd/zram\-generator\.conf\fR
.
.br
\fB/usr/local/lib/systemd/zram\-generator\.conf\fR
.
.br
\fB/etc/systemd/zram\-generator\.conf\fR
.
.br
\fB/run/systemd/zram\-generator\.conf\fR
.
.P
\fB/usr/lib/systemd/zram\-generator\.conf\.d/*\.conf\fR
.
.br
\fB/usr/local/lib/systemd/zram\-generator\.conf\.d/*\.conf\fR
.
.br
\fB/etc/systemd/zram\-generator\.conf\.d/*\.conf\fR
.
.br
\fB/run/systemd/zram\-generator\.conf\.d/*\.conf\fR
.
.SH "DESCRIPTION"
These files configure devices created by zram\-generator(8)\. See systemd\.syntax(5) for a general description of the syntax\.
.
.SH "CONFIGURATION DIRECTORIES AND PRECEDENCE"
The default configuration doesn\'t specify any devices\. Consult \fI/usr/share/zram\-generator/zram\-generator\.conf\.example\fR for an example configuration file\.
.
.P
When packages need to customize the configuration, they can install configuration snippets in \fI/usr/lib/systemd/zram\-generator\.conf\.d/\fR\. Files in \fI/etc/\fR are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages\. The main configuration file is read before any of the configuration directories, and has the lowest precedence; entries in a file in any configuration directory override entries in the single configuration file\. Files in the \fI*\.conf\.d/\fR configuration subdirectories are sorted by their filename in lexicographic order, regardless of which of the subdirectories they reside in\. When multiple files specify the same option, for options which accept just a single value, the entry in the file with the lexicographically latest name takes precedence\. It is recommended to prefix all filenames in those subdirectories with a two\-digit number and a dash, to simplify the ordering of the files\.
.
.P
To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to \fI/dev/null\fR in the configuration directory in \fI/etc/\fR, with the same filename as the vendor configuration file\.
.
.P
The generator understands the following option on the kernel command\-line: \fBsystemd\.zram[=0|1]\fR\. When specified with a true argument (or no argument), the \fBzram0\fR device will be created\. Default options apply, but may be overridden by configuration on disk if present\. When specified with a false argument, no zram devices will be created by the generator\. This option thus has higher priority than the configuration files\.
.
.SH "OPTIONS"
Each device is configured independently in its \fB[zramN]\fR section, where N is a nonnegative integer\. Other sections are ignored\.
.
.P
Devices with the final size of \fI0\fR will be discarded\.
.
.IP "\(bu" 4
\fBhost\-memory\-limit\fR=
.
.IP
Sets the upper limit on the total usable RAM (as defined by \fIMemTotal\fR in \fB/proc/meminfo\fR, confer proc(5)) above which the device will \fInot\fR be created\.
.
.IP
This takes a nonnegative number, representing that limit in megabytes, or the literal string \fInone\fR, which can be used to override a limit set earlier\.
.
.IP
Defaults to \fInone\fR\.
.
.IP "\(bu" 4
\fBzram\-size\fR=
.
.IP
Sets the size of the zram device as a function of \fIMemTotal\fR, available as the \fBram\fR variable\.
.
.IP
Arithmetic operators (^%/*\-+), e, π, SI suffixes, log(), int(), ceil(), floor(), round(), abs(), min(), max(), and trigonometric functions are supported\.
.
.IP
Defaults to \fImin(ram / 2, 4096)\fR\.
.
.IP "\(bu" 4
\fBcompression\-algorithm\fR=
.
.IP
Specifies the algorithm used to compress the zram device\.
.
.IP
This takes a literal string, representing the algorithm to use\.
.
.br
Consult \fI/sys/block/zram0/comp_algorithm\fR for a list of currently loaded compression algorithms, but note that additional ones may be loaded on demand\.
.
.IP
If unset, none will be configured and the kernel\'s default will be used\.
.
.IP "\(bu" 4
\fBswap\-priority\fR=
.
.IP
Controls the relative swap priority, a value between \-1 and 32767\. Higher numbers indicate higher priority\.
.
.IP
If unset, 100 is used\.
.
.IP "\(bu" 4
\fBmount\-point\fR=
.
.IP
Format the device with a file system (not as swap) and mount this file system over the specified directory\. When neither this option nor \fBfs\-type\fR= is specified, the device will be formatted as swap\.
.
.IP
Note that the device is temporary: contents will be destroyed automatically after the file system is unmounted (to release the backing memory)\.
.
.IP "\(bu" 4
\fBfs\-type\fR=
.
.IP
Specifies how the device shall be formatted\. The default is \fIext2\fR if \fBmount\-point\fR is specified, and \fIswap\fR otherwise\. (Effectively, the device will be formatted as swap, if neither \fBfs\-type\fR= nor \fBmount\-point\fR= are specified\.)
.
.IP
Note that the device is temporary: contents will be destroyed automatically after the file system is unmounted (to release the backing memory)\.
.
.IP
Also see systemd\-makefs(8)\.
.
.IP "\(bu" 4
\fBoptions\fR=
.
.IP
Sets mount or swapon options\. Availability depends on \fBfs\-type\fR\.
.
.IP
Defaults to \fIdiscard\fR\.
.
.IP "" 0
.
.SH "ENVIRONMENT VARIABLES"
Setting \fBZRAM_GENERATOR_ROOT\fR during parsing will cause \fI/proc/meminfo\fR to be read from \fI$ZRAM_GENERATOR_ROOT/proc/meminfo\fR instead, and \fI{/usr/lib,/usr/local/lib,/etc,/run}/systemd/zram\-generator\.conf\fR to be read from \fI$ZRAM_GENERATOR_ROOT/{/usr/lib,/usr/local/lib,/etc,/run}/systemd/zram\-generator\.conf\fR\.
.
.SH "EXAMPLES"
The default configuration will yield the following:
.
.IP "" 4
.
.nf
zram device size
^
4G>│ ooooooooooooo
│ o
│ o
│ o
2G>│ o
│ o
│ o
512M>│ o
0───────────────────────> total usable RAM
^ ^ ^
1G 4G 8G
.
.fi
.
.IP "" 0
.
.P
A piecewise\-linear size 1:1 for the first 4G, then 1:2 above, up to a max of 32G:
.
.br
\~\~\fBzram\-size = min(min(ram, 4096) + max(ram \- 4096, 0) / 2, 32 * 1024)\fR
.
.IP "" 4
.
.nf
zram device size
^
32G>| oooooooooooooo
| o
30G>| o
|
/=/
|
8G>│ o
│ o
│ o
│ o
│ o
4G>│ o
│ o
│ o
1G>│ o
0───────────────────────────────────||──────────────────────> total usable RAM
^ ^ ^ ^ ^ ^ ^
1G 4G 8G 12G 56G 60G 64G
.
.fi
.
.IP "" 0
.
.SH "OBSOLETE OPTIONS"
.
.IP "\(bu" 4
\fBmemory\-limit\fR=
.
.IP
Compatibility alias for \fBhost\-memory\-limit\fR\.
.
.IP "\(bu" 4
\fBzram\-fraction\fR=
.
.IP
Defines the scaling factor of the zram device\'s size with relation to the total usable RAM\.
.
.IP
This takes a nonnegative floating\-point number representing that factor\.
.
.IP
Defaulted to \fI0\.5\fR\. Setting this or \fBmax\-zram\-size\fR overrides \fBzram\-size\fR\.
.
.IP "\(bu" 4
\fBmax\-zram\-size\fR=
.
.IP
Sets the limit on the zram device\'s size obtained by \fBzram\-fraction\fR\.
.
.IP
This takes a nonnegative number, representing that limit in megabytes, or the literal string \fInone\fR, which can be used to override a limit set earlier\.
.
.IP
Defaulted to \fI4096\fR\. Setting this or \fBzram\-fraction\fR overrides \fBzram\-size\fR\.
.
.IP "" 0
.
.SH "REPORTING BUGS"
\fIhttps://github\.com/systemd/zram\-generator/issues\fR
.
.SH "SEE ALSO"
zram\-generator(8), systemd\.syntax(5), proc(5)
.
.P
\fIhttps://github\.com/systemd/zram\-generator\fR
.
.P
Linux documentation of zram: \fIhttps://kernel\.org/doc/html/latest/admin\-guide/blockdev/zram\.html\fR
.
.br
and the zram sysfs ABI: \fIhttps://kernel\.org/doc/Documentation/ABI/testing/sysfs\-block\-zram\fR
.
.P
\fBfasteval\fR documentation for the entire \fBzram\-size\fR arithmetic DSL: \fIhttps://docs\.rs/fasteval/0\.2\.4/fasteval/#the\-fasteval\-expression\-mini\-language\fR

4
zram-generator.obsinfo Normal file
View File

@ -0,0 +1,4 @@
name: zram-generator
version: 1.1.2
mtime: 1648455525
commit: 1bf6b08d8bd15624280482b1c125902f90c706aa

81
zram-generator.spec Normal file
View File

@ -0,0 +1,81 @@
#
# spec file for package zram-generator
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global _systemd_util_dir /usr/lib/systemd
Name: zram-generator
Version: 1.1.2
Release: 0
Summary: Systemd unit generator for zram swap devices
License: MIT
Group: Development/Libraries/Rust
# Upstream license specification: MIT
URL: https://github.com/systemd/zram-generator
Source0: %{name}-%{version}.tar.xz
Source1: vendor.tar.xz
Source2: cargo_config
Source3: zram-generator-rpmlintrc
# pregenerated man-pages to avoid dependency on ronn
Source4: zram-generator.conf.5
Source5: zram-generator.8
BuildRequires: cargo-packaging
BuildRequires: pkgconfig(systemd)
%description
This is a systemd unit generator that enables swap on zram.
(With zram, there is no physical swap device. Part of the avaialable RAM
is used to store compressed pages, essentially trading CPU cycles for memory.)
To configure and activate swap and zram devices with file-systems, create a configuration file in /etc/systemd/zram-generator.conf. You can consult %{_datadir}/doc/%{name}/zram-generator.conf.example for an example and a list of available settings.
%prep
%autosetup -a1 -p1 -n %{name}-%{version}
mkdir .cargo
cp %{SOURCE2} .cargo/config
cp %{SOURCE4} man/
cp %{SOURCE5} man/
%build
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
export LC_ALL=C.UTF-8
%{cargo_build}
%make_build SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} \
systemd-service
%install
%make_install SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} NOBUILD=1
%check
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
%{cargo_test}
%files
%doc README.md
%dir %{_datadir}/doc/%{name}
%{_datadir}/doc/%{name}/zram-generator.conf.example
%dir %{_systemdgeneratordir}
%{_systemdgeneratordir}/zram-generator
%{_unitdir}/systemd-zram-setup@.service
%{_mandir}/man8/zram-generator.8*
%{_mandir}/man5/zram-generator.conf.5*
%changelog