X-Original-To: alpine-devel@lists.alpinelinux.org Received: from magnesium.8pit.net (magnesium.8pit.net [45.76.88.171]) by lists.alpinelinux.org (Postfix) with ESMTP id 3E5685C4AED; Sat, 10 Jun 2017 10:12:24 +0000 (GMT) Received: from localhost (dslb-092-077-019-181.092.077.pools.vodafone-ip.de [92.77.19.181]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 3cb11d5f (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sat, 10 Jun 2017 12:12:19 +0200 (CEST) From: =?UTF-8?q?S=C3=B6ren=20Tempel?= To: alpine-devel@lists.alpinelinux.org Cc: ncopa@alpinelinux.org Subject: [alpine-devel] [PATCH] initramfs-init: kopt for enabling discards with cryptsetup Date: Sat, 10 Jun 2017 12:12:15 +0200 Message-Id: <20170610101215.3129-1-soeren+git@soeren-tempel.net> X-Mailer: git-send-email 2.13.0 X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: 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 @@ -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 @@ -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 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -317,6 +318,7 @@ struct cryptconf { size_t payload_offset; pthread_t tid; pthread_mutex_t mutex; + uint32_t flags; }; struct ueventconf { @@ -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 */ @@ -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 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---