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
diff --git a/bin/disk_stress_ng b/bin/disk_stress_ng
index 8445488..802d116 100755
--- a/bin/disk_stress_ng
+++ b/bin/disk_stress_ng
@@ -63,11 +63,40 @@ get_params() {
63} # get_params()63} # get_params()
6464
6565
66# Find the largest partition that holds a supported filesystem on $disk_device.66# Find the largest logical volume in an LVM partition.
67# Output:67# Output:
68# $largest_part -- Device filename of largest qualifying partition68# $largest_part -- Device filename of largest qualifying partition
69# $largest_size -- Size of largest qualifying partition69# $largest_size -- Size of largest qualifying partition
70# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition70# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition
71# Note: Above variables are initialized in find_largest_partition(), which
72# calls this function.
73# Caveat: If LVM is used, there can be no guarantee that a specific disk
74# device is actually being tested. Thus, an LVM configuration should span
75# just one disk device. LVM may be used on one disk, but subsequent disks
76# should use "raw" partitions.
77find_largest_lv() {
78 local partonly=$(echo $partition | cut -f 3 -d "/")
79 for syslv in $(ls -d /sys/block/dm-*/slaves/$partonly) ; do
80 lv=$(echo "$syslv" | cut -f 4 -d "/")
81 size=$(cat /sys/block/$lv/size)
82 sector_size=$(cat /sys/block/$lv/queue/hw_sector_size)
83 let size=$size*$sector_size
84 local blkid_info=$(blkid -s TYPE /dev/$lv | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)
85 if [ "$size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
86 local blkid_info=$(blkid -s TYPE /dev/$lv)
87 largest_size=$size
88 largest_part="/dev/$lv"
89 largest_fs=$(blkid -s TYPE "/dev/$lv" | cut -d "=" -f 2)
90 fi
91 done
92} # find_largest_lv()
93
94
95# Find the largest partition that holds a supported filesystem on $disk_device.
96# Output:
97# $largest_part -- Device filename of largest qualifying partition or logical volume
98# $largest_size -- Size of largest qualifying partition or logical volume
99# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition or logicl volume
71# $unsupported_fs -- Empty or contains name of unsupported filesystem found on disk100# $unsupported_fs -- Empty or contains name of unsupported filesystem found on disk
72find_largest_partition() {101find_largest_partition() {
73 largest_part=""102 largest_part=""
@@ -76,11 +105,15 @@ find_largest_partition() {
76 unsupported_fs=""105 unsupported_fs=""
77 for partition in $(echo "$partitions" | cut -d " " -f 1) ; do106 for partition in $(echo "$partitions" | cut -d " " -f 1) ; do
78 part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)107 part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2)
79 local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)108 local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
80 if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then109 if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
81 largest_size=$part_size110 if [[ "$blkid_info" =~ .*LVM2_member.* ]] ; then
82 largest_part="/dev/$partition"111 find_largest_lv
83 largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)112 else
113 largest_size=$part_size
114 largest_part="/dev/$partition"
115 largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2)
116 fi
84 fi117 fi
85 local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs)118 local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs)
86 if [ -n "$blkid_info" ] ; then119 if [ -n "$blkid_info" ] ; then

Subscribers

People subscribed via source and target branches