]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: rbd: small optimization to script
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 30 Dec 2010 08:09:11 +0000 (00:09 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 30 Dec 2010 18:38:36 +0000 (10:38 -0800)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
qa/rbd/common.sh

index 14e8c67ad9a5e7109da17ac7b8da5ba3dc9cc9f9..aa6efe7de83e2c1eefcaee5af0aa4867799eeefe 100644 (file)
@@ -67,9 +67,10 @@ rbd_add() {
        pushd /sys/bus/rbd/devices &> /dev/null
        [ $? -eq 0 ] || die "failed to cd"
        devid=""
-       # We 'should' start at the end (sorting numerically)
-       # TODO: rewrite this to be more efficient if it's important
-       for f in *; do
+       rm -f "$TDIR/rbd_devs"
+       for f in *; do echo $f >> "$TDIR/rbd_devs"; done
+       sort -nr "$TDIR/rbd_devs" > "$TDIR/rev_rbd_devs"
+       while read f < "$TDIR/rev_rbd_devs"; do
          read d_img_name < "$f/name"
          if [ "x$d_img_name" == "x$img_name.$id" ]; then
            devid=$f