]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls: load layout xattr in cephfs cls
authorJohn Spray <john.spray@redhat.com>
Mon, 3 Aug 2015 13:23:53 +0000 (14:23 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 13 Aug 2015 10:01:14 +0000 (11:01 +0100)
Do it with FAILOK because, like the backtrace,
its presence is optional.

Signed-off-by: John Spray <john.spray@redhat.com>
src/cls/cephfs/cls_cephfs_client.cc
src/cls/cephfs/cls_cephfs_client.h

index d135922699e2b04c6fee203c01176ff017071076..c471fdeb70a53e6f75945a51a081a5f19f4c510d 100644 (file)
@@ -54,6 +54,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result(
   librados::IoCtx &ctx,
   const std::string &oid,
   inode_backtrace_t *backtrace,
+  ceph_file_layout *layout,
   AccumulateResult *result)
 {
   assert(backtrace != NULL);
@@ -76,12 +77,16 @@ int ClsCephFSClient::fetch_inode_accumulate_result(
   int parent_r = 0;
   bufferlist parent_bl;
   op.getxattr("parent", &parent_bl, &parent_r);
+  op.set_op_flags2(librados::OP_FAILOK);
+
+  int layout_r = 0;
+  bufferlist layout_bl;
+  op.getxattr("layout", &layout_bl, &layout_r);
+  op.set_op_flags2(librados::OP_FAILOK);
 
   bufferlist op_bl;
   int r = ctx.operate(oid, &op, &op_bl);
-  if (r < 0 && r != -ENODATA) {
-    // ENODATA acceptable from parent getxattr (just means there happens
-    // not to be a backtrace)
+  if (r < 0) {
     return r;
   }
 
@@ -126,6 +131,16 @@ int ClsCephFSClient::fetch_inode_accumulate_result(
     }
   }
 
+  // Deserialize layout
+  if (layout_bl.length()) {
+    try {
+      bufferlist::iterator q = layout_bl.begin();
+      ::decode(*layout, q);
+    } catch (buffer::error &e) {
+      return -EINVAL;
+    }
+  }
+
   return 0;
 }
 
index 5448a31505b4b15b1de622cb161b56e3d17af3c0..45d3c4bb6997f6b22d85170d89f8cc69e410f7db 100644 (file)
@@ -20,6 +20,7 @@ class ClsCephFSClient
       librados::IoCtx &ctx,
       const std::string &oid,
       inode_backtrace_t *backtrace,
+      ceph_file_layout *layout,
       AccumulateResult *result);
 };