Skip to content

Commit

Permalink
Merge pull request ceph#3485 from jdurgin/wip-merge-diff-testing
Browse files Browse the repository at this point in the history
Improve merge-diff test
  • Loading branch information
liewegas committed Feb 2, 2015
2 parents de3b5c4 + f6406c9 commit 0af16c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
41 changes: 17 additions & 24 deletions qa/workunits/rbd/merge_diff.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash
#!/bin/bash -ex

pool=rbd
gen=$pool/gen
out=$pool/out

set -x
testno=1

mkdir -p merge_diff_test
pushd merge_diff_test
Expand All @@ -16,27 +15,21 @@ function expect_false()

function clear_all()
{
umount mnt || true
while [ 1 ];
do
rbd snap purge $gen 2>/dev/null >/dev/null
rbd rm $gen 2>/dev/null >/dev/null
rbd snap purge $out 2>/dev/null >/dev/null
rbd rm $out 2>/dev/null >/dev/null

sleep 5

rbd info $gen 2>/dev/null >/dev/null && continue
rbd info $out 2>/dev/null >/dev/null && continue

break
done
rm -rf diffs
fusermount -u mnt || true

rbd snap purge --no-progress $gen || true
rbd rm --no-progress $gen || true
rbd snap purge --no-progress $out || true
rbd rm --no-progress $out || true

rm -rf diffs || true
}

function rebuild()
{
clear_all
echo Starting test $testno
((testno++))
rbd create $gen --size 100 --order $1 --stripe_unit $2 --stripe_count $3 --image-format $4
rbd create $out --size 1 --order 19
mkdir -p mnt diffs
Expand All @@ -55,7 +48,7 @@ function snap()

function resize()
{
rbd resize $gen --size $1 --allow-shrink
rbd resize --no-progress $gen --size $1 --allow-shrink
}

function export_diff()
Expand All @@ -66,9 +59,9 @@ function export_diff()
target="$gen@$2"
fi
if [ $1 == "null" ]; then
rbd export-diff $target diffs/$1.$2
rbd export-diff --no-progress $target diffs/$1.$2
else
rbd export-diff $target --from-snap $1 diffs/$1.$2
rbd export-diff --no-progress $target --from-snap $1 diffs/$1.$2
fi
}

Expand All @@ -79,7 +72,7 @@ function merge_diff()

function check()
{
rbd import-diff diffs/$1.$2 $out || return -1
rbd import-diff --no-progress diffs/$1.$2 $out || return -1
if [ "$2" == "head" ]; then
sum1=`rbd export $gen - | md5sum`
else
Expand Down Expand Up @@ -472,4 +465,4 @@ clear_all
popd
rm -rf merge_diff_test

exit 0
echo OK
2 changes: 1 addition & 1 deletion src/include/rados/librados.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ CEPH_RADOS_API rados_config_t rados_ioctx_cct(rados_ioctx_t io);
/**
* Get the cluster handle used by this rados_ioctx_t
* Note that this is a weak reference, and should not
* be destroyed via rados_destroy().
* be destroyed via rados_shutdown().
*
* @param io the io context
* @returns the cluster handle for this io context
Expand Down
17 changes: 16 additions & 1 deletion src/rbd_fuse/rbd-fuse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,21 @@ rbdfs_init(struct fuse_conn_info *conn)
return NULL;
}

void
rbdfs_destroy(void *unused)
{
if (!gotrados)
return;
for (int i = 0; i < MAX_RBD_IMAGES; ++i) {
if (opentbl[i].image) {
rbd_close(opentbl[i].image);
opentbl[i].image = NULL;
}
}
rados_ioctx_destroy(ioctx);
rados_shutdown(cluster);
}

// return -errno on error. fi->fh is not set until open time

int
Expand Down Expand Up @@ -670,7 +685,7 @@ const static struct fuse_operations rbdfs_oper = {
releasedir: rbdfs_releasedir,
fsyncdir: 0,
init: rbdfs_init,
destroy: 0,
destroy: rbdfs_destroy,
access: 0,
create: rbdfs_create,
/* skip unimplemented */
Expand Down

0 comments on commit 0af16c3

Please sign in to comment.