auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1);
auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
if (ux_key && ux_attrs) {
- rgw_fh->decode_attrs(ux_key, ux_attrs);
+ bool old_key = rgw_fh->decode_attrs(ux_key, ux_attrs);
+ if (old_key) {
+ update_fhk(rgw_fh);
+ }
}
if (! (flags & RGWFileHandle::FLAG_LOCKED)) {
rgw_fh->mtx.unlock();
auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1);
auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
if (ux_key && ux_attrs) {
- rgw_fh->decode_attrs(ux_key, ux_attrs);
+ bool old_key = rgw_fh->decode_attrs(ux_key, ux_attrs);
+ if (old_key) {
+ update_fhk(rgw_fh);
+ }
}
}
goto done;
auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1);
auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1);
if (ux_key && ux_attrs) {
- rgw_fh->decode_attrs(ux_key, ux_attrs);
+ bool old_key = rgw_fh->decode_attrs(ux_key, ux_attrs);
+ if (old_key) {
+ update_fhk(rgw_fh);
+ }
}
}
goto done;
return 0;
} /* RGWLibFS::setattr */
+ /* called under rgw_fh->mtx held */
+ void RGWLibFS::update_fhk(RGWFileHandle *rgw_fh)
+ {
+ int rc, rc2;
+ string obj_name{rgw_fh->relative_object_name()};
+ buffer::list ux_key, ux_attrs;
+
+ if (rgw_fh->is_dir() &&
+ (likely(! rgw_fh->is_bucket()))) {
+ obj_name += "/";
+ }
+
+ lsubdout(get_context(), rgw, 17)
+ << __func__
+ << " update old versioned fhk : " << obj_name
+ << dendl;
+
+ RGWSetAttrsRequest req(cct, get_user(), rgw_fh->bucket_name(), obj_name);
+
+ rgw_fh->encode_attrs(ux_key, ux_attrs);
+
+ /* update ux_key only */
+ req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
+
+ rc = rgwlib.get_fe()->execute_req(&req);
+ rc2 = req.get_ret();
+
+ if ((rc != 0) || (rc2 != 0)) {
+ lsubdout(get_context(), rgw, 17)
+ << __func__
+ << " update fhk failed : " << obj_name
+ << dendl;
+ }
+ } /* RGWLibFS::update_fhk */
+
void RGWLibFS::close()
{
state.flags |= FLAG_CLOSED;
rgw::encode(*this, ux_attrs1);
} /* RGWFileHandle::encode_attrs */
- void RGWFileHandle::decode_attrs(const ceph::buffer::list* ux_key1,
+ bool RGWFileHandle::decode_attrs(const ceph::buffer::list* ux_key1,
const ceph::buffer::list* ux_attrs1)
{
+ bool old_key = false;
fh_key fhk;
auto bl_iter_key1 = const_cast<buffer::list*>(ux_key1)->begin();
rgw::decode(fhk, bl_iter_key1);
- assert(this->fh.fh_hk == fhk.fh_hk);
+ if (fhk.version >= 2) {
+ assert(this->fh.fh_hk == fhk.fh_hk);
+ } else {
+ old_key = true;
+ }
auto bl_iter_unix1 = const_cast<buffer::list*>(ux_attrs1)->begin();
rgw::decode(*this, bl_iter_unix1);
+
+ return old_key;
} /* RGWFileHandle::decode_attrs */
bool RGWFileHandle::reclaim() {
int RGWWriteRequest::exec_start() {
struct req_state* s = get_state();
+ auto compression_type =
+ get_store()->get_zone_params().get_compression_type(
+ s->bucket_info.placement_rule);
+
/* not obviously supportable */
assert(! dlo_manifest);
assert(! slo_info);
processor = select_processor(*static_cast<RGWObjectCtx *>(s->obj_ctx),
&multipart);
op_ret = processor->prepare(get_store(), NULL);
+ if (op_ret < 0) {
+ ldout(s->cct, 20) << "processor->prepare() returned ret=" << op_ret
+ << dendl;
+ goto done;
+ }
+
+ filter = processor;
+ if (compression_type != "none") {
+ plugin = Compressor::create(s->cct, compression_type);
+ if (! plugin) {
+ ldout(s->cct, 1) << "Cannot load plugin for rgw_compression_type "
+ << compression_type << dendl;
+ } else {
+ compressor.emplace(s->cct, plugin, filter);
+ filter = &*compressor;
+ }
+ }
done:
return op_ret;
orig_data = data;
}
hash.Update((const byte *)data.c_str(), data.length());
- op_ret = put_data_and_throttle(processor, data, ofs,
- need_to_wait);
+ op_ret = put_data_and_throttle(filter, data, ofs, need_to_wait);
if (op_ret < 0) {
if (!need_to_wait || op_ret != -EEXIST) {
ldout(s->cct, 20) << "processor->thottle_data() returned ret="
dispose_processor(processor);
processor = select_processor(*static_cast<RGWObjectCtx *>(s->obj_ctx),
&multipart);
+ filter = processor;
string oid_rand;
char buf[33];
goto done;
}
- op_ret = put_data_and_throttle(processor, data, ofs, false);
+ /* restore compression filter, if any */
+ if (compressor) {
+ compressor.emplace(s->cct, plugin, filter);
+ filter = &*compressor;
+ }
+
+ op_ret = put_data_and_throttle(filter, data, ofs, false);
if (op_ret < 0) {
goto done;
}
hash.Final(m);
+ if (compressor && compressor->is_compressed()) {
+ bufferlist tmp;
+ RGWCompressionInfo cs_info;
+ cs_info.compression_type = plugin->get_type_name();
+ cs_info.orig_size = s->obj_size;
+ cs_info.blocks = std::move(compressor->get_compression_blocks());
+ ::encode(cs_info, tmp);
+ attrs[RGW_ATTR_COMPRESSION] = tmp;
+ ldout(s->cct, 20) << "storing " << RGW_ATTR_COMPRESSION
+ << " with type=" << cs_info.compression_type
+ << ", orig_size=" << cs_info.orig_size
+ << ", blocks=" << cs_info.blocks.size() << dendl;
+ }
+
buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
etag = calc_md5;
return -ENOENT;
}
} else {
- /* lookup in a readdir callback */
- enum rgw_fh_type fh_type = fh_type_of(flags);
-
- uint32_t sl_flags = (flags & RGW_LOOKUP_FLAG_RCB)
- ? RGWFileHandle::FLAG_NONE
- : RGWFileHandle::FLAG_EXACT_MATCH;
-
- fhr = fs->stat_leaf(parent, path, fh_type, sl_flags);
- if (! get<0>(fhr)) {
- if (! (flags & RGW_LOOKUP_FLAG_CREATE))
- return -ENOENT;
- else
- fhr = fs->lookup_fh(parent, path, RGWFileHandle::FLAG_CREATE);
+ /* special: after readdir--note extra ref()! */
+ if (unlikely((strcmp(path, "..") == 0))) {
+ rgw_fh = parent;
+ lsubdout(fs->get_context(), rgw, 17)
+ << __func__ << "BANG"<< *rgw_fh
+ << dendl;
+ fs->ref(rgw_fh);
+ } else {
+ /* lookup in a readdir callback */
+ enum rgw_fh_type fh_type = fh_type_of(flags);
+
+ uint32_t sl_flags = (flags & RGW_LOOKUP_FLAG_RCB)
+ ? RGWFileHandle::FLAG_NONE
+ : RGWFileHandle::FLAG_EXACT_MATCH;
+
+ fhr = fs->stat_leaf(parent, path, fh_type, sl_flags);
+ if (! get<0>(fhr)) {
+ if (! (flags & RGW_LOOKUP_FLAG_CREATE))
+ return -ENOENT;
+ else
+ fhr = fs->lookup_fh(parent, path, RGWFileHandle::FLAG_CREATE);
+ }
+ rgw_fh = get<0>(fhr);
}
- rgw_fh = get<0>(fhr);
} /* !root */
struct rgw_file_handle *rfh = rgw_fh->get_fh();