From 65a1340c58b3a18e406099eeea4e913375bf234d Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 10 Oct 2018 15:12:02 -0400 Subject: [PATCH] rgw: add rgw::putobj::ManifestObjectProcessor Signed-off-by: Casey Bodley --- src/rgw/rgw_putobj_processor.cc | 27 +++++++++++++++++++++++++++ src/rgw/rgw_putobj_processor.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 12fccedd5b6..c671fffd0b1 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -163,4 +163,31 @@ RadosWriter::~RadosWriter() } } + +// advance to the next stripe +int ManifestObjectProcessor::next(uint64_t offset, uint64_t *pstripe_size) +{ + // advance the manifest + int r = manifest_gen.create_next(offset); + if (r < 0) { + return r; + } + + rgw_raw_obj stripe_obj = manifest_gen.get_cur_obj(store); + + uint64_t chunk_size = 0; + r = store->get_max_chunk_size(stripe_obj.pool, &chunk_size); + if (r < 0) { + return r; + } + r = writer.set_stripe_obj(std::move(stripe_obj)); + if (r < 0) { + return r; + } + + chunk = ChunkProcessor(&writer, chunk_size); + *pstripe_size = manifest_gen.cur_stripe_max_size(); + return 0; +} + } // namespace rgw::putobj diff --git a/src/rgw/rgw_putobj_processor.h b/src/rgw/rgw_putobj_processor.h index 2057cc26d51..3e5a9077e81 100644 --- a/src/rgw/rgw_putobj_processor.h +++ b/src/rgw/rgw_putobj_processor.h @@ -104,4 +104,36 @@ class RadosWriter : public DataProcessor { void clear_written() { written.clear(); } }; +// a rados object processor that stripes according to RGWObjManifest +class ManifestObjectProcessor : public HeadObjectProcessor, + public StripeGenerator { + protected: + RGWRados *const store; + const RGWBucketInfo& bucket_info; + const rgw_user& owner; + RGWObjectCtx& obj_ctx; + rgw_obj head_obj; + + RadosWriter writer; + RGWObjManifest manifest; + RGWObjManifest::generator manifest_gen; + ChunkProcessor chunk; + StripeProcessor stripe; + + // implements StripeGenerator + int next(uint64_t offset, uint64_t *stripe_size) override; + + public: + ManifestObjectProcessor(Aio *aio, RGWRados *store, + const RGWBucketInfo& bucket_info, + const rgw_user& owner, RGWObjectCtx& obj_ctx, + const rgw_obj& head_obj) + : HeadObjectProcessor(0), + store(store), bucket_info(bucket_info), owner(owner), + obj_ctx(obj_ctx), head_obj(head_obj), + writer(aio, store, bucket_info, obj_ctx, head_obj), + chunk(&writer, 0), stripe(&chunk, this, 0) + {} +}; + } // namespace rgw::putobj -- 2.39.5