]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
systemd: activate disks via systemd service instead of udev
authorDavid Disseldorp <ddiss@suse.de>
Mon, 11 May 2015 23:45:34 +0000 (01:45 +0200)
committerSage Weil <sage@redhat.com>
Sat, 1 Aug 2015 13:58:34 +0000 (09:58 -0400)
The udev(7) man page states:
  RUN
  ...
  This can only be used for very short-running foreground tasks. Running
  an event process for a long period of time may block all further
  events for this or a dependent device.

  Starting daemons or other long-running processes is not appropriate
  for udev; the forked processes, detached or not, will be
  unconditionally killed after the event handling has finished.

ceph-disk activate is far from a short-running task:
- check whether path is a block dev, for dirs call through to
  activate_dir()
- call blkid to obtain the filesystem type for the block dev
- pull mount options from hard-coded ceph.conf file
- mount the OSD dev at a temporary path
- check the ceph magic for mounted filesystem
- read cluster uuid and locate corresponding /etc/ceph/{cluster}.conf
  path
- read or generate (if missing) the OSD uuid
- create a file indicating init system usage (systemd)
- mount the device at a second (final) location
- umount (lazy) the temporary mount path
- enable the systemd ceph-osd@{osd_id} service
- start the systemd ceph-osd@{osd_id} service

This logic is therefore best left in a systemd service for execution. As
it is less limited in terms of execution time, and also allows for
improved event handling in future (fsck, dmcrypt mapping etc.).

This change sees 95-ceph-osd.rules.systemd trigger ceph-disk activate or
ceph-disk activate-journal via new ceph-disk-activate-journal@.service,
ceph-disk-activate@.service and ceph-disk-dmcrypt-activate@.service
systemd service files.

ceph-disk-dmcrypt-activate@.service makes use of the newly added
--dmcrypt parameter for ceph-disk activate.

Signed-off-by: David Disseldorp <ddiss@suse.de>
systemd/Makefile.am
systemd/ceph-disk-activate-journal@.service [new file with mode: 0644]
systemd/ceph-disk-activate@.service [new file with mode: 0644]
systemd/ceph-disk-dmcrypt-activate@.service [new file with mode: 0644]
udev/95-ceph-osd.rules.systemd [new file with mode: 0644]

index efe7245c9ce56cce76b464c8d17b074148547eb6..e6d73e7facca67d82475aef698e86c048a5bc3bb 100644 (file)
@@ -4,7 +4,10 @@ unitfiles = \
        ceph-mon@.service \
        ceph-create-keys@.service \
        ceph-osd@.service \
-       ceph-radosgw@.service
+       ceph-radosgw@.service \
+       ceph-disk-activate-journal@.service \
+       ceph-disk-activate@.service \
+       ceph-disk-dmcrypt-activate@.service
 
 unitdir = $(systemd_unit_dir)
 
diff --git a/systemd/ceph-disk-activate-journal@.service b/systemd/ceph-disk-activate-journal@.service
new file mode 100644 (file)
index 0000000..ac7cb46
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Ceph disk journal activation: %f
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/ceph-disk --verbose --log-stdout activate-journal --mark-init systemd %f
+TimeoutSec=0
diff --git a/systemd/ceph-disk-activate@.service b/systemd/ceph-disk-activate@.service
new file mode 100644 (file)
index 0000000..b6e75af
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Ceph disk activation: %f
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/ceph-disk --verbose --log-stdout activate --mark-init systemd %f
+TimeoutSec=0
diff --git a/systemd/ceph-disk-dmcrypt-activate@.service b/systemd/ceph-disk-dmcrypt-activate@.service
new file mode 100644 (file)
index 0000000..b17df10
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Ceph disk dmcrypt activation: %f
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/ceph-disk --verbose --log-stdout activate --dmcrypt --mark-init systemd %f
+TimeoutSec=0
diff --git a/udev/95-ceph-osd.rules.systemd b/udev/95-ceph-osd.rules.systemd
new file mode 100644 (file)
index 0000000..dccfe34
--- /dev/null
@@ -0,0 +1,28 @@
+# activate ceph-tagged partitions
+ACTION=="add", SUBSYSTEM=="block", \
+  ENV{DEVTYPE}=="partition", \
+  ENV{ID_PART_ENTRY_TYPE}=="4fbd7e29-9d25-41b8-afd0-062c0ceff05d", \
+  TAG+="systemd", \
+  ENV{SYSTEMD_WANTS}+="ceph-disk-activate@/dev/$name.service"
+
+# activate ceph-tagged partitions
+ACTION=="add", SUBSYSTEM=="block", \
+  ENV{DEVTYPE}=="partition", \
+  ENV{ID_PART_ENTRY_TYPE}=="45b0969e-9b03-4f30-b4c6-b4b80ceff106", \
+  TAG+="systemd", \
+  ENV{SYSTEMD_WANTS}+="ceph-disk-activate-journal@/dev/$name.service"
+
+# Map journal if using dm-crypt
+ACTION=="add" SUBSYSTEM=="block", \
+  ENV{DEVTYPE}=="partition", \
+  ENV{ID_PART_ENTRY_TYPE}=="45b0969e-9b03-4f30-b4c6-5ec00ceff106", \
+  RUN+="/sbin/cryptsetup --key-file /etc/ceph/dmcrypt-keys/$env{ID_PART_ENTRY_UUID} --key-size 256 create $env{ID_PART_ENTRY_UUID} /dev/$name"
+
+# Map data device and
+# activate ceph-tagged partitions
+# for dm-crypted data devices
+ACTION=="add" SUBSYSTEM=="block", \
+  ENV{DEVTYPE}=="partition", \
+  ENV{ID_PART_ENTRY_TYPE}=="4fbd7e29-9d25-41b8-afd0-5ec00ceff05d", \
+  TAG+="systemd", \
+  ENV{SYSTEMD_WANTS}+="ceph-disk-dmcrypt-activate@/dev/$name.service"