]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd image_read.sh: allocate local file at create time
authorAlex Elder <elder@inktank.com>
Tue, 21 May 2013 15:05:03 +0000 (10:05 -0500)
committerAlex Elder <elder@inktank.com>
Tue, 21 May 2013 19:44:35 +0000 (14:44 -0500)
Move the dd command that touches the last byte in a local file
into create_image() where it belongs (out of fill_original()).

Signed-off-by: Alex Elder <elder@inktank.com>
qa/workunits/rbd/image_read.sh

index 9e2228a0e1180511bf6f31f18a8329857c71cabb..6fbe0c92bae5922f290880d3577bb905276125ba 100755 (executable)
@@ -245,11 +245,14 @@ function create_image() {
        [ $# -eq 1 ] || exit 99
        local image_name="$1"
        local image_path
+       local bytes
 
        verbose "creating image \"${image_name}\""
        if [ "${LOCAL_FILES}" = true ]; then
                image_path=$(image_dev_path "${image_name}")
-               touch "${image_path}"
+               bytes=$(echo "${IMAGE_SIZE} * 1024 * 1024 - 1" | bc)
+               quiet dd if=/dev/zero bs=1 count=1 seek="${bytes}" \
+                       of="${image_path}"
                return
        fi
 
@@ -425,18 +428,12 @@ function source_data() {
 
 function fill_original() {
        local image_path=$(image_dev_path "${ORIGINAL}")
-       local bytes=$(echo "${IMAGE_SIZE} * 1024 * 1024 - 1" | bc)
 
        verbose "filling original image"
        # Fill 16 objects worth of "random" data
        source_data |
        quiet dd bs="${PAGE_SIZE}" count=$((16 * OBJECT_PAGES)) \
                of="${image_path}"
-       if [ "${LOCAL_FILES}" = true ]; then
-               # Extend it another 16 objects, as a hole in the image
-               quiet dd if=/dev/zero bs=1 count=1 seek=${bytes} \
-                       of="${image_path}"
-       fi
 }
 
 function do_read() {