From: Ilya Dryomov Date: Wed, 9 Jul 2014 13:59:02 +0000 (+0400) Subject: test_librbd_fsx: introduce rbd_image_has_parent() X-Git-Tag: v0.84~51^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6d1a920fddd2ecf0d1e8a224a85c55e0134c60c;p=ceph.git test_librbd_fsx: introduce rbd_image_has_parent() A helper to check whether the image associated with the ctx has a parent or not. Signed-off-by: Ilya Dryomov --- diff --git a/src/test/librbd/fsx.c b/src/test/librbd/fsx.c index c684383d039..b62a43a7bd1 100644 --- a/src/test/librbd/fsx.c +++ b/src/test/librbd/fsx.c @@ -28,8 +28,9 @@ #include #endif #include -#include +#include #include +#include #include #include #include @@ -719,6 +720,19 @@ const struct rbd_operations krbd_operations = { struct rbd_ctx ctx = RBD_CTX_INIT; const struct rbd_operations *ops = &librbd_operations; +static bool rbd_image_has_parent(struct rbd_ctx *ctx) +{ + int ret; + + ret = rbd_get_parent_info(ctx->image, NULL, 0, NULL, 0, NULL, 0); + if (ret < 0 && ret != -ENOENT) { + prterrcode("rbd_get_parent_info", ret); + exit(1); + } + + return !ret; +} + /* * fsx */ @@ -1470,8 +1484,7 @@ do_flatten() { int ret; - if (num_clones == 0 || - (rbd_get_parent_info(ctx.image, NULL, 0, NULL, 0, NULL, 0) == -ENOENT)) { + if (!rbd_image_has_parent(&ctx)) { log4(OP_SKIPPED, OP_FLATTEN, 0, 0); return; }