Merge ~rodsmith/plainbox-provider-checkbox:disk-stress-ng-support-lvm into plainbox-provider-checkbox:master

Proposed by Rod Smith
Status: Merged
Approved by: Jeff Lane 
Approved revision: 84e11f3c313a072a242874d6b46807c721a321eb
Merged at revision: 154bcb32978ca9636bc5cb668ccf1dd9df72aadf
Proposed branch: ~rodsmith/plainbox-provider-checkbox:disk-stress-ng-support-lvm
Merge into: plainbox-provider-checkbox:master
Diff against target: 66 lines (+38/-5)
1 file modified
bin/disk_stress_ng (+38/-5)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+312578@code.launchpad.net

Description of the change

Adds support for LVM to the disk-stress-ng test. When the test detects that the biggest partition is an LVM, it scans the LVM for logical volumes and, if one of them is the biggest device, tests on it rather than on a small partition (or nothing at all).

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

Tested, and a bit cleaner than my attempt.

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 8445488..802d116 100755
3--- a/bin/disk_stress_ng
4+++ b/bin/disk_stress_ng
5@@ -63,11 +63,40 @@ get_params() {
6 } # get_params()
7
8
9-# Find the largest partition that holds a supported filesystem on $disk_device.
10+# Find the largest logical volume in an LVM partition.
11 # Output:
12 # $largest_part -- Device filename of largest qualifying partition
13 # $largest_size -- Size of largest qualifying partition
14 # $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition
15+# Note: Above variables are initialized in find_largest_partition(), which
16+# calls this function.
17+# Caveat: If LVM is used, there can be no guarantee that a specific disk
18+# device is actually being tested. Thus, an LVM configuration should span
19+# just one disk device. LVM may be used on one disk, but subsequent disks
20+# should use "raw" partitions.
21+find_largest_lv() {
22+ local partonly=$(echo $partition | cut -f 3 -d "/")
23+ for syslv in $(ls -d /sys/block/dm-*/slaves/$partonly) ; do
24+ lv=$(echo "$syslv" | cut -f 4 -d "/")
25+ size=$(cat /sys/block/$lv/size)
26+ sector_size=$(cat /sys/block/$lv/queue/hw_sector_size)
27+ let size=$size*$sector_size
28+ local blkid_info=$(blkid -s TYPE /dev/$lv | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)
29+ if [ "$size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
30+ local blkid_info=$(blkid -s TYPE /dev/$lv)
31+ largest_size=$size
32+ largest_part="/dev/$lv"
33+ largest_fs=$(blkid -s TYPE "/dev/$lv" | cut -d "=" -f 2)
34+ fi
35+ done
36+} # find_largest_lv()
37+
38+
39+# Find the largest partition that holds a supported filesystem on $disk_device.
40+# Output:
41+# $largest_part -- Device filename of largest qualifying partition or logical volume
42+# $largest_size -- Size of largest qualifying partition or logical volume
43+# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition or logicl volume
44 # $unsupported_fs -- Empty or contains name of unsupported filesystem found on disk
45 find_largest_partition() {
46 largest_part=""
47@@ -76,11 +105,15 @@ find_largest_partition() {
48 unsupported_fs=""
49 for partition in $(echo "$partitions" | cut -d " " -f 1) ; do
50 part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)
51- local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)
52+ local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
53 if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
54- largest_size=$part_size
55- largest_part="/dev/$partition"
56- largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
57+ if [[ "$blkid_info" =~ .*LVM2_member.* ]] ; then
58+ find_largest_lv
59+ else
60+ largest_size=$part_size
61+ largest_part="/dev/$partition"
62+ largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
63+ fi
64 fi
65 local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs)
66 if [ -n "$blkid_info" ] ; then

Subscribers

People subscribed via source and target branches