Merge ~bladernr/plainbox-provider-checkbox:1467520-disk-tests-mapper-devs into plainbox-provider-checkbox:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Paul Larson
Approved revision: 3f5eaf35e8d78d2b01d75bb2f9c03872df45f82e
Merged at revision: 6f0cb0155bc146431ee060d63cf9a46481a12014
Proposed branch: ~bladernr/plainbox-provider-checkbox:1467520-disk-tests-mapper-devs
Merge into: plainbox-provider-checkbox:master
Diff against target: 152 lines (+89/-19)
2 files modified
bin/disk_stress_ng (+22/-7)
bin/storage_test (+67/-12)
Reviewer Review Type Date Requested Status
Paul Larson Approve
Jeff Lane  Needs Resubmitting
Review via email: mp+323189@code.launchpad.net

Description of the change

Modified disk_stress_ng to work with devmapper devices.

Tested with xenial and zesty on Power8

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

A couple of minor comments, and a question. Does this really make sense for selecting a disk to run a destructive test on? Would it be better to either 1. insist that we have a configured value for the disk we can use for this, or 2. Look for the largest *unmounted" partition that is also not part of a mounted logical volume that is mounted?

I see this is a pretty critical bug though, so if you can address these things, great. But they are not worth blocking on if you need to land this and it's well tested. I don't think I have a way to really test it myself, but I saw that you had commented on the tests done with it.

review: Approve
Revision history for this message
Jeff Lane  (bladernr) wrote :

Made some changes

review: Needs Resubmitting
Revision history for this message
Paul Larson (pwlars) wrote :

Looks good, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/disk_stress_ng b/bin/disk_stress_ng
2index de96f46..0b5de83 100755
3--- a/bin/disk_stress_ng
4+++ b/bin/disk_stress_ng
5@@ -101,21 +101,36 @@ find_largest_lv() {
6 find_largest_partition() {
7 largest_part=""
8 largest_size=0
9- partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk_device | grep part | tr -s " ")
10+ mapper_string="dm-"
11+ if [ "${disk_device#*$mapper_string}" = "$disk_device" ]; then
12+ partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk_device | grep part | tr -s " ")
13+ else
14+ partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk_device)
15+ fi
16 unsupported_fs=""
17 for partition in $(echo "$partitions" | cut -d " " -f 1) ; do
18- part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)
19- local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
20- if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
21+ if [ -b "/dev/$partition" ]; then
22+ part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)
23+ part_location="/dev/$partition"
24+ elif [ -b "/dev/mapper/$partition" ]; then
25+ part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 3)
26+ part_location="/dev/mapper/$partition"
27+ else
28+ echo "$partition not found!"
29+ echo "Aborting test"
30+ exit 1
31+ fi
32+ local blkid_info=$(blkid -s TYPE $part_location | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
33+ if [ "$part_size" > "$largest_size" ] && [ -n "$blkid_info" ] ; then
34 if [[ "$blkid_info" =~ .*LVM2_member.* ]] ; then
35 find_largest_lv
36 else
37 largest_size=$part_size
38- largest_part="/dev/$partition"
39- largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
40+ largest_part="$part_location"
41+ largest_fs=$(blkid -s TYPE "$part_location" | cut -d "=" -f 2)
42 fi
43 fi
44- local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs)
45+ local blkid_info=$(blkid -s TYPE $part_location | grep -E ntfs\|vfat\|hfs)
46 if [ -n "$blkid_info" ] ; then
47 # If there's an NTFS, HFS+, or FAT filesystem on the disk make note of it....
48 unsupported_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
49diff --git a/bin/storage_test b/bin/storage_test
50index 1aed0da..5f7516b 100755
51--- a/bin/storage_test
52+++ b/bin/storage_test
53@@ -30,6 +30,35 @@ function run_bonnie() {
54 fi
55 }
56
57+# Find the largest logical volume in an LVM partition.
58+# Output:
59+# $largest_part -- Device filename of largest qualifying partition
60+# $largest_size -- Size of largest qualifying partition
61+# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition
62+# Note: Above variables are initialized in find_largest_partition(), which
63+# calls this function.
64+# Caveat: If LVM is used, there can be no guarantee that a specific disk
65+# device is actually being tested. Thus, an LVM configuration should span
66+# just one disk device. LVM may be used on one disk, but subsequent disks
67+# should use "raw" partitions.
68+find_largest_lv() {
69+ local partonly=$(echo $partition | cut -f 3 -d "/")
70+ for syslv in $(ls -d /sys/block/dm-*/slaves/$partonly) ; do
71+ lv=$(echo "$syslv" | cut -f 4 -d "/")
72+ size=$(cat /sys/block/$lv/size)
73+ sector_size=$(cat /sys/block/$lv/queue/hw_sector_size)
74+ let size=$size*$sector_size
75+ local blkid_info=$(blkid -s TYPE /dev/$lv | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)
76+ if [ "$size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
77+ local blkid_info=$(blkid -s TYPE /dev/$lv)
78+ largest_size=$size
79+ largest_part="/dev/$lv"
80+ largest_fs=$(blkid -s TYPE "/dev/$lv" | cut -d "=" -f 2)
81+ fi
82+ done
83+} # find_largest_lv()
84+
85+
86 # Find the largest partition that holds a supported filesystem on $disk_device.
87 # This code is adapted from a similar function in `disk_stress_ng`.
88 # Output:
89@@ -40,25 +69,51 @@ function run_bonnie() {
90 find_largest_partition() {
91 largest_part=""
92 largest_size=0
93- partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk | grep part | tr -s " ")
94+ mapper_string="dm-"
95+ if [ "${disk_device#*$mapper_string}" = "$disk_device" ]; then
96+ partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk_device | grep part | tr -s " ")
97+ else
98+ partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk_device)
99+ fi
100 unsupported_fs=""
101 for partition in $(echo "$partitions" | cut -d " " -f 1) ; do
102 part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)
103- local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)
104- if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
105- largest_size=$part_size
106- largest_part="/dev/$partition"
107- largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
108+ if [ -b "/dev/$partition" ]; then
109+ part_location="/dev/$partition"
110+ elif [ -b "/dev/mapper/$partition" ]; then
111+ part_location="/dev/mapper/$partition"
112+ else
113+ echo "$partition not found!"
114+ echo "Aborting test"
115+ exit 1
116 fi
117- local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs)
118- if [ -n "$blkid_info" ] ; then
119- # If there's an NTFS, HFS+, or FAT filesystem on the disk make note of it....
120- unsupported_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
121+ local blkid_info=$(blkid -s TYPE $part_location | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
122+ if [ "$part_size" > "$largest_size" ] && [ -n "$blkid_info" ] ; then
123+ if [[ "$blkid_info" =~ .*LVM2_member.* ]] ; then
124+ find_largest_lv
125+ else
126+ largest_size=$part_size
127+ largest_part="$part_location"
128+ largest_fs=$(blkid -s TYPE "$part_location" | cut -d "=" -f 2)
129+ fi
130 fi
131- done
132+ local blkid_info=$(blkid -s TYPE $part_location | grep -E ntfs\|vfat\|hfs)
133+ if [ -n "$blkid_info" ] ; then
134+ # If there's an NTFS, HFS+, or FAT filesystem on the disk make note of it....
135+ unsupported_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
136+ fi
137+ done
138 } # find_largest_partition()
139
140-disk=/dev/$1
141+
142+if [[ "$1}" =~ dm-.* ]]; then
143+ # assume lvm or multipath and look for the dev/mapper device
144+ disk=/dev/mapper/`ls -l /dev/mapper/ | grep $1 | awk '{print $9}'`
145+else
146+ # if the disk doesn't look like dm-0
147+ disk=/dev/$1
148+fi
149+echo "Set disk to $disk"
150 scripted_mount=0
151
152 if [ -b $disk ]

Subscribers

People subscribed via source and target branches