Whamcloud - gitweb
LU-7884 utils: mkfs prevents the creation of files in /dev/shm 84/18984/16
authorQuentin Bouget <quentin.bouget@cea.fr>
Tue, 11 Apr 2017 15:46:50 +0000 (15:46 +0000)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 7 Jun 2017 20:31:12 +0000 (20:31 +0000)
When configuring llmount to use /dev/shm as its TMP directory
(for loopback files), mkfs.lustre complains that the loopback does
not exist and will not be created.
This patch fixes this by adding a "touch" instruction before any use
of mkfs.lustre in test-framework.sh

Signed-off-by: Quentin Bouget <quentin.bouget@cea.fr>
Change-Id: I1422d8af947db5ba5b262a9acd2239e99f0843c2
Reviewed-on: https://review.whamcloud.com/18984
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/tests/test-framework.sh

index e4a7ec8..a3a43f4 100755 (executable)
@@ -3636,6 +3636,34 @@ check_ost_indices() {
        done
 }
 
+__touch_device()
+{
+       local facet_type=$1 # mgs || mds || ost
+       local facet_num=$2
+       local facet=${1}${2}
+       local device
+
+       case "$(facet_fstype $facet)" in
+       ldiskfs)
+               device=$(${facet_type}devname $facet_num)
+               ;;
+       zfs)
+               device=$(${facet_type}vdevname $facet_num)
+               ;;
+       *)
+               error "Unhandled filesystem type"
+               ;;
+       esac
+
+       do_facet $facet "[ -e \"$device\" ]" && return
+
+       # Note: the following check only works with absolute paths
+       [[ ! "$device" =~ ^/dev/ ]] || [[ "$device" =~ ^/dev/shm/ ]] ||
+               error "$facet: device '$device' does not exist"
+
+       do_facet $facet "touch \"${device}\""
+}
+
 format_mgs() {
        local quiet
 
@@ -3644,6 +3672,12 @@ format_mgs() {
        fi
        echo "Format mgs: $(mgsdevname)"
        reformat_external_journal mgs
+
+       # touch "device" in case it is a loopback file for testing and needs to
+       # be created. mkfs.lustre doesn't do this to avoid accidentally writing
+       # to non-existent files in /dev if the admin made a typo during setup
+       __touch_device mgs
+
        add mgs $(mkfs_opts mgs $(mgsdevname)) $(mountfs_opts mgs) --reformat \
                $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} || exit 10
 }
@@ -3657,6 +3691,9 @@ format_mdt() {
        fi
        echo "Format mds$num: $(mdsdevname $num)"
        reformat_external_journal mds$num
+
+       __touch_device mds $num
+
        add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
                $(mountfs_opts mds$num) --reformat $(mdsdevname $num) \
                $(mdsvdevname $num) ${quiet:+>/dev/null} || exit 10
@@ -3670,6 +3707,9 @@ format_ost() {
        fi
        echo "Format ost$num: $(ostdevname $num)"
        reformat_external_journal ost$num
+
+       __touch_device ost $num
+
        add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
                $(mountfs_opts ost$num) --reformat $(ostdevname $num) \
                $(ostvdevname ${num}) ${quiet:+>/dev/null} || exit 10