Mail archive
alpine-aports

[alpine-aports] [PATCH] main/mkinitfs: backport cryptdiscards patch

From: Sören Tempel <soeren+git_at_soeren-tempel.net>
Date: Sat, 10 Jun 2017 12:05:53 +0200

---
 ...nit-kopt-for-enabling-discards-with-crypt.patch | 80 ++++++++++++++++++++++
 main/mkinitfs/APKBUILD                             |  6 +-
 2 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 main/mkinitfs/0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch
diff --git a/main/mkinitfs/0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch b/main/mkinitfs/0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch
new file mode 100644
index 0000000000..f380296764
--- /dev/null
+++ b/main/mkinitfs/0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch
_at_@ -0,0 +1,80 @@
+From b74571bef6d579b385b4b3f387e189d89be1d64b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git_at_soeren-tempel.net>
+Date: Sat, 10 Jun 2017 10:42:07 +0200
+Subject: [PATCH] initramfs-init: kopt for enabling discards with cryptsetup
+
+When enabled allows the use of discard (TRIM) requests for the device.
+See cryptsetup(1) for more information.
+---
+ initramfs-init.in | 7 +++++--
+ nlplug-findfs.c   | 8 +++++++-
+ 2 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/initramfs-init.in b/initramfs-init.in
+index 8a1c867..bbb37d2 100755
+--- a/initramfs-init.in
++++ b/initramfs-init.in
+_at_@ -261,8 +261,8 @@ setup_nbd() {
+ set -- $(cat /proc/cmdline)
+ 
+ myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm cryptheader cryptoffset
+-	debug_init dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
+-	usbdelay ip alpine_repo apkovl alpine_start splash blacklist
++	cryptdiscards debug_init dma init_args keep_apk_new modules ovl_dev pkgs quiet
++	root_size root usbdelay ip alpine_repo apkovl alpine_start splash blacklist
+ 	overlaytmpfs rootfstype rootflags nbd resume"
+ 
+ for opt; do
+_at_@ -353,6 +353,9 @@ eend 0
+ 
+ if [ -n "$KOPT_cryptroot" ]; then
+ 	cryptopts="-c ${KOPT_cryptroot}"
++	if [ "$KOPT_cryptdiscards" = "yes" ]; then
++		cryptopts="$cryptopts -D"
++	fi
+ 	if [ -n "$KOPT_cryptdm" ]; then
+ 		cryptopts="$cryptopts -m ${KOPT_cryptdm}"
+ 	fi
+diff --git a/nlplug-findfs.c b/nlplug-findfs.c
+index f23d0dd..be525cc 100644
+--- a/nlplug-findfs.c
++++ b/nlplug-findfs.c
+_at_@ -22,6 +22,7 @@
+ #include <string.h>
+ #include <termios.h>
+ #include <unistd.h>
++#include <stdint.h>
+ 
+ #include <sys/eventfd.h>
+ #include <sys/signalfd.h>
+_at_@ -317,6 +318,7 @@ struct cryptconf {
+ 	size_t payload_offset;
+ 	pthread_t tid;
+ 	pthread_mutex_t mutex;
++	uint32_t flags;
+ };
+ 
+ struct ueventconf {
+_at_@ -605,7 +607,8 @@ static void *cryptsetup_thread(void *data)
+ 		pthread_mutex_lock(&c->crypt.mutex);
+ 		r = crypt_activate_by_passphrase(cd, c->crypt.data.name,
+ 						 CRYPT_ANY_SLOT,
+-						 pass, strlen(pass), 0);
++						 pass, strlen(pass),
++						 c->crypt.flags);
+ 		pthread_mutex_unlock(&c->crypt.mutex);
+ 		memset(pass, 0, sizeof(pass)); /* wipe pass after use */
+ 
+_at_@ -1240,6 +1243,9 @@ int main(int argc, char *argv[])
+ 	case 'n':
+ 		not_found_is_ok = 1;
+ 		break;
++	case 'D':
++		conf.crypt.flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
++		break;
+ 	case 'd':
+ 		dodebug = 1;
+ 		break;
+-- 
+2.13.0
+
diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD
index ce2bac871c..a82279ec7c 100644
--- a/main/mkinitfs/APKBUILD
+++ b/main/mkinitfs/APKBUILD
_at_@ -2,7 +2,7 @@
 pkgname=mkinitfs
 pkgver=3.1.0_rc1
 _ver=${pkgver%_git*}
-pkgrel=0
+pkgrel=1
 pkgdesc="Tool to generate initramfs images for Alpine"
 url="http://git.alpinelinux.org/cgit/mkinitfs"
 makedepends_build=""
_at_@ -12,6 +12,7 @@ depends="busybox apk-tools>=2.0 lddtree>=1.25"
 install="$pkgname.pre-upgrade $pkgname.post-install $pkgname.post-upgrade"
 triggers="$pkgname.trigger=/usr/share/kernel/*"
 source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$_ver.tar.xz
+	0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch
 	"
 arch="all"
 license="GPL2"
_at_@ -27,4 +28,5 @@ package() {
 	make install DESTDIR="$pkgdir" || return 1
 }
 
-sha512sums="b1ec1d07bae813d105779112b407e07f4a89b03664ece87e63b1db8060e8f304c0855b64252ade5910b1981d5711612ed96fbce77d33c27909650efbcb7e769a  mkinitfs-3.1.0_rc1.tar.xz"
+sha512sums="b1ec1d07bae813d105779112b407e07f4a89b03664ece87e63b1db8060e8f304c0855b64252ade5910b1981d5711612ed96fbce77d33c27909650efbcb7e769a  mkinitfs-3.1.0_rc1.tar.xz
+d418247e5d4c4ea24dcd15c9f32abb0b96fc9ecee0594cce9e95d3f02ee9eb0c1d08f935de57a6acc81b909e5b3dafe2b3916ea3634987f896046973a0061277  0001-initramfs-init-kopt-for-enabling-discards-with-crypt.patch"
-- 
2.13.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sat Jun 10 2017 - 12:05:53 GMT