From d9c146f670ab433632d6d7536592a4240de616a4 Mon Sep 17 00:00:00 2001 From: Quentin Bouget Date: Tue, 11 Apr 2017 15:46:50 +0000 Subject: [PATCH] LU-7884 utils: mkfs prevents the creation of files in /dev/shm 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 Change-Id: I1422d8af947db5ba5b262a9acd2239e99f0843c2 Reviewed-on: https://review.whamcloud.com/18984 Reviewed-by: Henri Doreau Reviewed-by: Jian Yu Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/tests/test-framework.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index e4a7ec8..a3a43f4 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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 -- 1.8.3.1