]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_librbd_fsx: introduce rbd_image_has_parent()
authorIlya Dryomov <ilya.dryomov@inktank.com>
Wed, 9 Jul 2014 13:59:02 +0000 (17:59 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Mon, 28 Jul 2014 09:53:54 +0000 (13:53 +0400)
A helper to check whether the image associated with the ctx has
a parent or not.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
src/test/librbd/fsx.c

index c684383d039aa2c733fa97538151a2de014bb8e3..b62a43a7bd1a8335bfeb966c023f6582f60233c8 100644 (file)
@@ -28,8 +28,9 @@
 #include <err.h>
 #endif
 #include <signal.h>
-#include <stdio.h>
+#include <stdbool.h>
 #include <stddef.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
@@ -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;
        }