Browse code

Create new swift data store filesystem every time

The Swift data store was not cleaned out between stack.sh runs; although
the contents were not visible they were still taking up space. Create a
new XFS filesystem on every stack.sh run.

Fixes bug 1000827

Change-Id: Ieab6b5f65b7964906f244975cbcdf2cf50344ca5

Dean Troyer authored on 2012/05/18 01:10:36
Showing 1 changed files
... ...
@@ -1347,16 +1347,20 @@ if is_service_enabled swift; then
1347 1347
     sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
1348 1348
 
1349 1349
     # We then create a loopback disk and format it to XFS.
1350
-    # TODO: Reset disks on new pass.
1351
-    if [[ ! -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
1350
+    if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
1351
+        if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
1352
+            sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
1353
+        fi
1354
+    else
1352 1355
         mkdir -p  ${SWIFT_DATA_DIR}/drives/images
1353 1356
         sudo touch  ${SWIFT_DATA_DIR}/drives/images/swift.img
1354 1357
         sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img
1355 1358
 
1356 1359
         dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \
1357 1360
             bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
1358
-        mkfs.xfs -f -i size=1024  ${SWIFT_DATA_DIR}/drives/images/swift.img
1359 1361
     fi
1362
+    # Make a fresh XFS filesystem
1363
+    mkfs.xfs -f -i size=1024  ${SWIFT_DATA_DIR}/drives/images/swift.img
1360 1364
 
1361 1365
     # After the drive being created we mount the disk with a few mount
1362 1366
     # options to make it most efficient as possible for swift.