From: Yehuda Sadeh Date: Tue, 13 Nov 2012 20:09:05 +0000 (-0800) Subject: rgw: fix RGWCache api X-Git-Tag: v0.55~112 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e0e33d2c99fe7c056bb91d5cbbe1ccfb6bbcfb1b;p=ceph.git rgw: fix RGWCache api RGWCache api diverted form RGWRados, crippling the cache. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 2f92b8d1946c..ecc01c436d74 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -49,25 +49,27 @@ WRITE_CLASS_ENCODER(ObjectMetaInfo) struct ObjectCacheInfo { int status; uint32_t flags; + uint64_t epoch; bufferlist data; map xattrs; map rm_xattrs; ObjectMetaInfo meta; - ObjectCacheInfo() : status(0), flags(0) {} + ObjectCacheInfo() : status(0), flags(0), epoch(0) {} void encode(bufferlist& bl) const { - ENCODE_START(3, 3, bl); + ENCODE_START(4, 3, bl); ::encode(status, bl); ::encode(flags, bl); ::encode(data, bl); ::encode(xattrs, bl); ::encode(meta, bl); ::encode(rm_xattrs, bl); + ::encode(epoch, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl); ::decode(status, bl); ::decode(flags, bl); ::decode(data, bl); @@ -75,6 +77,8 @@ struct ObjectCacheInfo { ::decode(meta, bl); if (struct_v >= 2) ::decode(rm_xattrs, bl); + if (struct_v >= 4) + ::decode(epoch, bl); DECODE_FINISH(bl); } void dump(Formatter *f) const; @@ -186,7 +190,7 @@ public: map& attrs, map* rmattrs); int put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mtime, - map& attrs, RGWObjCategory category, bool exclusive, + map& attrs, RGWObjCategory category, int flags, map* rmattrs, const bufferlist *data, RGWObjManifest *manifest, const string *ptag); @@ -195,7 +199,7 @@ public: int get_obj(void *ctx, void **handle, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end); - int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map *attrs, bufferlist *first_chunk); + int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, map *attrs, bufferlist *first_chunk); int delete_obj(void *ctx, rgw_obj& obj); }; @@ -341,7 +345,7 @@ int RGWCache::set_attrs(void *ctx, rgw_obj& obj, template int RGWCache::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mtime, - map& attrs, RGWObjCategory category, bool exclusive, + map& attrs, RGWObjCategory category, int flags, map* rmattrs, const bufferlist *data, RGWObjManifest *manifest, const string *ptag) { @@ -360,7 +364,7 @@ int RGWCache::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mt info.flags |= CACHE_FLAG_DATA; } } - int ret = T::put_obj_meta(ctx, obj, size, mtime, attrs, category, exclusive, rmattrs, data, manifest, ptag); + int ret = T::put_obj_meta(ctx, obj, size, mtime, attrs, category, flags, rmattrs, data, manifest, ptag); if (cacheable) { string name = normal_name(bucket, oid); if (ret >= 0) { @@ -412,18 +416,21 @@ int RGWCache::put_obj_data(void *ctx, rgw_obj& obj, const char *data, } template -int RGWCache::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map *attrs, bufferlist *first_chunk) +int RGWCache::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, + uint64_t *pepoch, map *attrs, + bufferlist *first_chunk) { rgw_bucket bucket; string oid; normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid); if (bucket.name[0] != '.') - return T::obj_stat(ctx, obj, psize, pmtime, attrs, first_chunk); + return T::obj_stat(ctx, obj, psize, pmtime, pepoch, attrs, first_chunk); string name = normal_name(bucket, oid); uint64_t size; time_t mtime; + uint64_t epoch; ObjectCacheInfo info; int r = cache.get(name, info, CACHE_FLAG_META | CACHE_FLAG_XATTRS); @@ -433,9 +440,10 @@ int RGWCache::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmti size = info.meta.size; mtime = info.meta.mtime; + epoch = info.epoch; goto done; } - r = T::obj_stat(ctx, obj, &size, &mtime, &info.xattrs, first_chunk); + r = T::obj_stat(ctx, obj, &size, &mtime, &epoch, &info.xattrs, first_chunk); if (r < 0) { if (r == -ENOENT) { info.status = r; @@ -444,6 +452,7 @@ int RGWCache::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmti return r; } info.status = 0; + info.epoch = epoch; info.meta.mtime = mtime; info.meta.size = size; info.flags = CACHE_FLAG_META | CACHE_FLAG_XATTRS; @@ -453,6 +462,8 @@ done: *psize = size; if (pmtime) *pmtime = mtime; + if (pepoch) + *pepoch = epoch; if (attrs) *attrs = info.xattrs; return 0;