Browse code

Merge "lib/swift variable changes and dd replaced by truncate"

Jenkins authored on 2013/10/15 03:47:21
Showing 1 changed files
... ...
@@ -39,6 +39,7 @@ SWIFT3_DIR=$DEST/swift3
39 39
 # Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects.
40 40
 # Default is the common DevStack data directory.
41 41
 SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift}
42
+SWIFT_DISK_IMAGE=${SWIFT_DATA_DIR}/drives/images/swift.img
42 43
 
43 44
 # Set ``SWIFT_CONF_DIR`` to the location of the configuration files.
44 45
 # Default is ``/etc/swift``.
... ...
@@ -55,10 +56,10 @@ fi
55 55
 # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in
56 56
 # kilobytes.
57 57
 # Default is 1 gigabyte.
58
-SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1048576
58
+SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1G
59 59
 # if tempest enabled the default size is 4 Gigabyte.
60 60
 if is_service_enabled tempest; then
61
-    SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-4194304}
61
+    SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-4G}
62 62
 fi
63 63
 
64 64
 SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-$SWIFT_LOOPBACK_DISK_SIZE_DEFAULT}
... ...
@@ -107,8 +108,8 @@ function cleanup_swift() {
107 107
    if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
108 108
       sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
109 109
    fi
110
-   if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
111
-      rm ${SWIFT_DATA_DIR}/drives/images/swift.img
110
+   if [[ -e ${SWIFT_DISK_IMAGE} ]]; then
111
+      rm ${SWIFT_DISK_IMAGE}
112 112
    fi
113 113
    rm -rf ${SWIFT_DATA_DIR}/run/
114 114
    if is_apache_enabled_service swift; then
... ...
@@ -420,28 +421,27 @@ function create_swift_disk() {
420 420
     sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
421 421
 
422 422
     # Create a loopback disk and format it to XFS.
423
-    if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
423
+    if [[ -e ${SWIFT_DISK_IMAGE} ]]; then
424 424
         if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
425 425
             sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
426
-            sudo rm -f ${SWIFT_DATA_DIR}/drives/images/swift.img
426
+            sudo rm -f ${SWIFT_DISK_IMAGE}
427 427
         fi
428 428
     fi
429 429
 
430 430
     mkdir -p ${SWIFT_DATA_DIR}/drives/images
431
-    sudo touch ${SWIFT_DATA_DIR}/drives/images/swift.img
432
-    sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img
431
+    sudo touch ${SWIFT_DISK_IMAGE}
432
+    sudo chown $USER: ${SWIFT_DISK_IMAGE}
433 433
 
434
-    dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \
435
-        bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
434
+    truncate -s ${SWIFT_LOOPBACK_DISK_SIZE} ${SWIFT_DISK_IMAGE}
436 435
 
437 436
     # Make a fresh XFS filesystem
438
-    mkfs.xfs -f -i size=1024  ${SWIFT_DATA_DIR}/drives/images/swift.img
437
+    mkfs.xfs -f -i size=1024  ${SWIFT_DISK_IMAGE}
439 438
 
440 439
     # Mount the disk with mount options to make it as efficient as possible
441 440
     mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1
442 441
     if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
443 442
         sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8  \
444
-            ${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1
443
+            ${SWIFT_DISK_IMAGE} ${SWIFT_DATA_DIR}/drives/sdb1
445 444
     fi
446 445
 
447 446
     # Create a link to the above mount and