From 8bd31d42a25ffb162ced98b3c1fa75cc09444036 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 25 Jun 2013 11:05:15 -0700 Subject: [PATCH] rgw: filter read xattrs We're only interested in object xattrs that have specific rgw.user prefix. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e8638a8173a..a382f21467b 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4419,7 +4419,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, io_ctx.locator_set_key(key); - map attrset; + map unfiltered_attrset; uint64_t size = 0; time_t mtime = 0; @@ -4427,7 +4427,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, if (objv_tracker) { objv_tracker->prepare_op_for_read(&op); } - op.getxattrs(&attrset, NULL); + op.getxattrs(&unfiltered_attrset, NULL); op.stat(&size, &mtime, NULL); if (first_chunk) { op.read(0, RGW_MAX_CHUNK_SIZE, first_chunk, NULL); @@ -4441,6 +4441,16 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, if (r < 0) return r; + map attrset; + map::iterator iter; + string check_prefix = RGW_ATTR_PREFIX; + for (iter = unfiltered_attrset.lower_bound(check_prefix); + iter != unfiltered_attrset.end(); ++iter) { + if (!str_startswith(iter->first, check_prefix)) + break; + attrset[iter->first] = iter->second; + } + if (psize) *psize = size; if (pmtime) -- 2.47.3