From 956c35a3ac31d67c47e807a1f302ffc518c4961c Mon Sep 17 00:00:00 2001 From: Dongsheng Yang Date: Tue, 28 Jun 2016 04:34:49 -0400 Subject: [PATCH] cleanup: rbd: to set omaps in a batch way in create(). Signed-off-by: Dongsheng Yang --- src/cls/rbd/cls_rbd.cc | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index ffa7523b532..db6ad3345d0 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -295,33 +295,24 @@ int create(cls_method_context_t hctx, bufferlist *in, bufferlist *out) } bufferlist sizebl; - ::encode(size, sizebl); - r = cls_cxx_map_set_val(hctx, "size", &sizebl); - if (r < 0) - return r; - bufferlist orderbl; - ::encode(order, orderbl); - r = cls_cxx_map_set_val(hctx, "order", &orderbl); - if (r < 0) - return r; - bufferlist featuresbl; - ::encode(features, featuresbl); - r = cls_cxx_map_set_val(hctx, "features", &featuresbl); - if (r < 0) - return r; - bufferlist object_prefixbl; - ::encode(object_prefix, object_prefixbl); - r = cls_cxx_map_set_val(hctx, "object_prefix", &object_prefixbl); - if (r < 0) - return r; - bufferlist snap_seqbl; uint64_t snap_seq = 0; + ::encode(size, sizebl); + ::encode(order, orderbl); + ::encode(features, featuresbl); + ::encode(object_prefix, object_prefixbl); ::encode(snap_seq, snap_seqbl); - r = cls_cxx_map_set_val(hctx, "snap_seq", &snap_seqbl); + + map omap_vals; + omap_vals["size"] = sizebl; + omap_vals["order"] = orderbl; + omap_vals["features"] = featuresbl; + omap_vals["object_prefix"] = object_prefixbl; + omap_vals["snap_seq"] = snap_seqbl; + r = cls_cxx_map_set_vals(hctx, &omap_vals); if (r < 0) return r;