]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: translate error -ENOENT to 0 for list APIs
authorrunsisi <runsisi@zte.com.cn>
Mon, 15 May 2017 07:50:47 +0000 (15:50 +0800)
committerrunsisi <runsisi@hust.edu.cn>
Wed, 17 May 2017 15:14:15 +0000 (23:14 +0800)
Signed-off-by: runsisi <runsisi@zte.com.cn>
src/librbd/api/Group.cc
src/librbd/internal.cc
src/librbd/librbd.cc

index 22339ea4e44a7a1a64826bcc977571cf542cced2..090a98074c0525b789a281463775d1272a6ada20 100644 (file)
@@ -137,8 +137,12 @@ int Group<I>::list(IoCtx& io_ctx, vector<string> *names)
     r = cls_client::group_dir_list(&io_ctx, RBD_GROUP_DIRECTORY, last_read,
                                    max_read, &groups);
     if (r < 0) {
-      lderr(cct) << "error listing group in directory: "
-                << cpp_strerror(r) << dendl;
+      if (r != -ENOENT) {
+        lderr(cct) << "error listing group in directory: "
+                   << cpp_strerror(r) << dendl;
+      } else {
+        r = 0;
+      }
       return r;
     }
     for (pair<string, string> group : groups) {
index 64ebf9545f7647595f21ef549a8bf90f36f7dc03..941c3ba510244fc2417e86b83845b876a0b71608 100644 (file)
@@ -546,8 +546,12 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     bufferlist bl;
     int r = io_ctx.read(RBD_DIRECTORY, bl, 0, 0);
-    if (r < 0)
+    if (r < 0) {
+      if (r == -ENOENT) {
+        r = 0;
+      }
       return r;
+    }
 
     // old format images are in a tmap
     if (bl.length()) {
@@ -1479,6 +1483,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       if (r != -ENOENT) {
         lderr(cct) << "error listing rbd_trash entries: " << cpp_strerror(r)
                    << dendl;
+      } else {
+        r = 0;
       }
       return r;
     }
index 77d272283e5af2c26469c4d33b08450daf568a20..86ddd0a857354f6a247d912ee17d5fe1cd44ce0b 100644 (file)
@@ -2141,11 +2141,6 @@ extern "C" int rbd_list(rados_ioctx_t p, char *names, size_t *size)
   tracepoint(librbd, list_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id());
   vector<string> cpp_names;
   int r = librbd::list(io_ctx, cpp_names);
-  if (r == -ENOENT) {
-    tracepoint(librbd, list_exit, 0, *size);
-    return 0;
-  }
-
   if (r < 0) {
     tracepoint(librbd, list_exit, r, *size);
     return r;
@@ -4038,14 +4033,6 @@ extern "C" int rbd_group_list(rados_ioctx_t p, char *names, size_t *size)
 
   vector<string> cpp_names;
   int r = librbd::list(io_ctx, cpp_names);
-
-  if (r == -ENOENT) {
-    *size = 0;
-    *names = '\0';
-    tracepoint(librbd, group_list_exit, 0);
-    return 0;
-  }
-
   if (r < 0) {
     tracepoint(librbd, group_list_exit, r);
     return r;