From 70b66b6c06b554bc1557e08d6b00394a2f94be7b Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 05:21:30 +0100 Subject: [PATCH 1/7] flashcache tab file, for cache volume listing --- systemd/flashcachetab | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 systemd/flashcachetab diff --git a/systemd/flashcachetab b/systemd/flashcachetab new file mode 100644 index 0000000..968c0b5 --- /dev/null +++ b/systemd/flashcachetab @@ -0,0 +1,2 @@ +# This file contains a list of devices from which to load flashcache volumes +# From 767fd766d0840e57ee1b328969ab0eb22cba51b8 Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 05:24:47 +0100 Subject: [PATCH 2/7] Flashcache volumes loader --- systemd/flashcache_loader | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 systemd/flashcache_loader diff --git a/systemd/flashcache_loader b/systemd/flashcache_loader new file mode 100755 index 0000000..c8873f7 --- /dev/null +++ b/systemd/flashcache_loader @@ -0,0 +1,21 @@ +#!/bin/bash + +# Parse the flashcachetab file and load the cache volumes + +# Tools +EGREP=$(which egrep) + +# File with cache volumes listing +FLASHCACHETAB=/etc/flashcachetab + +cat "$FLASHCACHETAB" | $EGREP -v "^#" | while read line ; + do + items=($line) + echo "Loading ${items[0]} (${items[1]})" + if flashcache_load ${items[0]} ${items[1]} 2> /dev/null; then + echo "Flashcache volume ${items[1]} loaded from ${items[0]}" + else + (>&2 echo "ERROR loading Flashcache volume ${items[1]} loaded from ${items[0]}") + fi + done + From c0811ff3c5168cba4609f8912cac84214b8c362d Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 05:26:04 +0100 Subject: [PATCH 3/7] Flashcache Systemd service definition --- systemd/flashcache.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 systemd/flashcache.service diff --git a/systemd/flashcache.service b/systemd/flashcache.service new file mode 100644 index 0000000..f4d036f --- /dev/null +++ b/systemd/flashcache.service @@ -0,0 +1,15 @@ +[Unit] +Description=Flashcache volumes loading service +DefaultDependencies=no +Requires=lvm2-monitor.service -.mount boot.mount lvm2-activation-early.service lvm2-activation.service systemd-fsck-root.service systemd-remount-fs.service +After=lvm2-monintor.service -.mount boot.mount lvm2-activation-early.service lvm2-activation.service systemd-fsck-root.service systemd-remount-fs.service +Wants=lvm2-monitor.service lvm2-activation-early.service lvm2-activation.service +Before=checkfs.service mountall.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/etc/init.d/flashcache_loader + +[Install] +WantedBy=default.target From e2e183d913062e3742404dc0532e760d09ec5a40 Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 05:32:26 +0100 Subject: [PATCH 4/7] Documentation on using Systemd files --- systemd/README | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 systemd/README diff --git a/systemd/README b/systemd/README new file mode 100644 index 0000000..95bb9b0 --- /dev/null +++ b/systemd/README @@ -0,0 +1,14 @@ +Systemd bootup for Flashcache +Author: Manuel Bernal Llinares +------------------------------ + +This folder contains three files for loading flashcache volumes when booting +the system: + - flashcache.service, contains the service definition, usually placed at /etc/systemd/system/flashcache.service, + with permissions 664. + - flashcache_loader, this script is called by the service "start" action, it parses the flashcachetab file, and + calls flashcache_load to activate the cache volumes specified on the file. + - flashcachetab, this file contains a flashcache volume per line, with optional volume name, to be activated by + flashcache_loader script. It should be placed at /etc + +This files have been tested on a Debian 8.4, using flashcache compiled from its source code at github.com/facebookarchive/flashcache From cf01e0b695c0319b2dc7813272ed504aed381ce8 Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 05:37:55 +0100 Subject: [PATCH 5/7] Main README file updated to refer to systemd components --- README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README b/README index 502cab3..0faf2d0 100644 --- a/README +++ b/README @@ -27,5 +27,12 @@ This builds both the flashcache.ko and 3 utilities. flascache-sa-guide.txt has details on how to create and load flashcache volumes. +Loading flashcache volumes on Systemd : +------------------------------------- +On folder "systemd" you will find the necessary components and a +README file that describes how to set up those files to load +flashcache volumes when using this init system. + Mohan Srinivasan Paul Saab +Manuel Bernal-Llinares From 5df412376201581d2c49a95d597517263f51a3db Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 14:01:30 +0100 Subject: [PATCH 6/7] New settings folder under /etc, and cache volumes configuration file --- systemd/flashcache_loader | 17 ++++++++++++----- systemd/flashcache_vol.conf | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 systemd/flashcache_vol.conf diff --git a/systemd/flashcache_loader b/systemd/flashcache_loader index c8873f7..92ef926 100755 --- a/systemd/flashcache_loader +++ b/systemd/flashcache_loader @@ -1,12 +1,14 @@ #!/bin/bash -# Parse the flashcachetab file and load the cache volumes - -# Tools +# PATH +#PATH=/sbin:/bin:/usr/bin EGREP=$(which egrep) +SYSCTL=$(which sysctl) # File with cache volumes listing -FLASHCACHETAB=/etc/flashcachetab +ETC_FLASHCACHE=/etc/flashcache +FLASHCACHETAB=$ETC_FLASHCACHE/flashcachetab +VOLUMES_SYSCTL_PARAMS=$ETC_FLASHCACHE/flashcache_vol.conf cat "$FLASHCACHETAB" | $EGREP -v "^#" | while read line ; do @@ -18,4 +20,9 @@ cat "$FLASHCACHETAB" | $EGREP -v "^#" | while read line ; (>&2 echo "ERROR loading Flashcache volume ${items[1]} loaded from ${items[0]}") fi done - +if [ -f "$VOLUMES_SYSCTL_PARAMS" ] ; then + echo "Loading cache volumes configuration from $VOLUMES_SYSCTL_PARAMS" + $SYSCTL -p "$VOLUMES_SYSCTL_PARAMS" +else + echo "No cache volumes configuration file has been found!" +fi diff --git a/systemd/flashcache_vol.conf b/systemd/flashcache_vol.conf new file mode 100644 index 0000000..05c1fbd --- /dev/null +++ b/systemd/flashcache_vol.conf @@ -0,0 +1,6 @@ +# Configuration parameters for the flashcache cache volumes +# +# The easiest way to customize your cache volumes parameters is, once the volumes +# have been created, run +# sysctl -a | grep flashcache >> /etc/flashcache/flashcache_vol.conf +# Then, edit the file to tweak the parameters for each volume From 908b5ed182af64e7616de3d81a2bb5f596d3f84d Mon Sep 17 00:00:00 2001 From: Manuel Bernal Llinares Date: Mon, 16 May 2016 14:02:24 +0100 Subject: [PATCH 7/7] Instructions on where to place the files --- systemd/README | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/systemd/README b/systemd/README index 95bb9b0..bc3ac8f 100644 --- a/systemd/README +++ b/systemd/README @@ -9,6 +9,13 @@ the system: - flashcache_loader, this script is called by the service "start" action, it parses the flashcachetab file, and calls flashcache_load to activate the cache volumes specified on the file. - flashcachetab, this file contains a flashcache volume per line, with optional volume name, to be activated by - flashcache_loader script. It should be placed at /etc + flashcache_loader script. + - flashcache_vol.conf, sysctl style file with configuration parameters for the cache volumes + +All these files should be installed at: +/etc/systemd/system/flashcache.service +/etc/init.d/flashcache_loader +/etc/flashcache/flashcachetab +/etc/flashcache/flashcache_vol.conf (optional) This files have been tested on a Debian 8.4, using flashcache compiled from its source code at github.com/facebookarchive/flashcache