[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-lvm
Subject: [linux-lvm] [PATCH 30/35] test: add helper to compute aligned lv
From: Lukas Czerner <lczerner () redhat ! com>
Date: 2011-09-21 16:45:49
Message-ID: 1316623554-28975-31-git-send-email-lczerner () redhat ! com
[Download RAW message or body]
For test purposes add a helper function to compute lv size as it
would be done by lvm tools.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
test/lib/utils.sh | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 4c3cd93..c555e45 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -177,6 +177,29 @@ kernel_at_least() {
return 1
}
+align_size_up() {
+ size=$1
+ [ -z $2 ] && stripes=0
+ [ -z $3 ] && extent=4
+
+ [ -z $size ] || [ -z $stripes ] || [ -z $extent ] && exit 1
+
+ tmp=$((size%extent))
+ if [ $tmp -ne 0 ]; then
+ size=$(($size+($extent-$tmp)))
+ fi
+ if [ $stripes -eq 0 ]; then
+ echo "$size"
+ return 0
+ fi
+ extents=$(($size/$extent))
+ tmp=$(($extents%$stripes))
+ if [ $tmp -ne 0 ]; then
+ extents=$(($extents-$tmp+$stripes))
+ fi
+ echo "$(($extents*$extent))"
+}
+
. lib/paths || { echo >&2 you must run make first; exit 1; }
PATH=$abs_top_builddir/test/lib:$PATH
--
1.7.4.4
_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic