From 553bc3ff8e51f7af4a589c80118e8594d5964588 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 3 Aug 2015 14:23:53 +0100 Subject: [PATCH] cls: load layout xattr in cephfs cls Do it with FAILOK because, like the backtrace, its presence is optional. Signed-off-by: John Spray --- src/cls/cephfs/cls_cephfs_client.cc | 21 ++++++++++++++++++--- src/cls/cephfs/cls_cephfs_client.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cls/cephfs/cls_cephfs_client.cc b/src/cls/cephfs/cls_cephfs_client.cc index d135922699e2b..c471fdeb70a53 100644 --- a/src/cls/cephfs/cls_cephfs_client.cc +++ b/src/cls/cephfs/cls_cephfs_client.cc @@ -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; } diff --git a/src/cls/cephfs/cls_cephfs_client.h b/src/cls/cephfs/cls_cephfs_client.h index 5448a31505b4b..45d3c4bb6997f 100644 --- a/src/cls/cephfs/cls_cephfs_client.h +++ b/src/cls/cephfs/cls_cephfs_client.h @@ -20,6 +20,7 @@ class ClsCephFSClient librados::IoCtx &ctx, const std::string &oid, inode_backtrace_t *backtrace, + ceph_file_layout *layout, AccumulateResult *result); }; -- 2.39.5