]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: ceph-disk.sh /dev/disk/by-partuuid and /dev/loop fixes
authorLoic Dachary <ldachary@redhat.com>
Tue, 10 Mar 2015 13:19:20 +0000 (14:19 +0100)
committerLoic Dachary <ldachary@redhat.com>
Wed, 11 Mar 2015 12:55:10 +0000 (13:55 +0100)
On CentOS 6.X and RHEL 6.X:

* /dev/disk/by-partuuid is not updated, support files must be installed
  to create them when udev notices a partition modification.

* /dev/loop is not configured to handle partition tables, the default
  2.6.32 kernel must be configured with loop.max_part=16

Sanity checks are added to verify the above, attempt to fix it and fail
if it cannot be fixed or if a machine reboot is necessary.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/test/ceph-disk.sh

index 5981226ed95758d599117e8e1612a2800aaaffd9..05041a99bd9cfb1f79dbc41587e8aa9311cc2d4f 100755 (executable)
@@ -299,6 +299,73 @@ function test_activate_dir() {
     $rm -fr $osd_data
 }
 
+function loop_sanity_check_body() {
+    local dev=$1
+    local guid=$2
+
+    #
+    # Check if /dev/loop is configured with max_part > 0 to handle
+    # partition tables and expose the partition devices in /dev
+    #
+    sgdisk --largest-new=1 --partition-guid=1:$guid $dev
+    if ! test -e ${dev}p1 ; then
+        if grep loop.max_part /proc/cmdline ; then
+            echo "the loop module max_part parameter is configured but when"
+            echo "creating a new partition on $dev, it the expected node"
+            echo "${dev}p1 does not exist"
+            return 1
+        fi
+        perl -pi -e 's/$/ loop.max_part=16/ if(/kernel/ && !/max_part/)' /boot/grub/grub.conf
+        echo "the loop.max_part=16 was added to the kernel in /boot/grub/grub.conf"
+        cat /boot/grub/grub.conf
+        echo "you need to reboot for it to be taken into account"
+        return 1
+    fi
+    
+    #
+    # Install the minimal files supporting the maintenance of /dev/disk/by-partuuid
+    #
+    udevadm trigger --sysname-match=$(basename $dev)
+    udevadm settle
+    if test ! -e /dev/disk/by-partuuid/$guid ; then
+        cp -a ../udev/95-ceph-osd-alt.rules /lib/udev/rules.d/95-ceph-osd.rules
+        cp -a ceph-disk ceph-disk-udev /usr/sbin
+        udevadm trigger --sysname-match=$(basename $dev)
+        if test ! -e /dev/disk/by-partuuid/$guid ; then
+            echo "/dev/disk/by-partuuid/$guid not found although the"
+            echo "following support files are installed: "
+            ls -l /lib/udev/rules.d/95-ceph-osd.rules /usr/sbin/ceph-disk{,-udev}
+            return 1
+        fi
+    fi
+
+    return 0
+}
+
+function loop_sanity_check() {
+    local id=$(lsb_release -si)
+    local major=$(lsb_release -rs | cut -f1 -d.)
+    if test $major != 6 || test $id != CentOS -a $id != RedHatEnterpriseServer ; then
+        echo "/dev/loop is assumed to be configured with max_part > 0"
+        echo "and /dev/disk/by-partuuid to be populated by udev"
+        return 0
+    fi
+    local name=$DIR/sanity.disk
+    dd if=/dev/zero of=$name bs=1024k count=10 > /dev/null
+    losetup --find $name
+    local dev=$(losetup --associated $name | cut -f1 -d:)
+    local guid=$($uuidgen)
+
+    loop_sanity_check_body $dev $guid
+    status=$?
+
+    losetup --detach $dev
+    rm $name
+    rm -f /dev/disk/by-partuuid/$guid
+
+    return $status
+}
+
 function create_dev() {
     local name=$1
 
@@ -382,6 +449,8 @@ function test_activate_dev() {
         return 0
     fi
 
+    loop_sanity_check || return 1
+
     local disk=$(create_dev vdf.disk)
     local journal=$(create_dev vdg.disk)
     local newdisk=$(create_dev vdh.disk)
@@ -432,6 +501,8 @@ function test_activate_dmcrypt_dev() {
         return 0
     fi
 
+    loop_sanity_check || return 1
+
     local disk=$(create_dev vdf.disk)
     local journal=$(create_dev vdg.disk)
     local newdisk=$(create_dev vdh.disk)