}
-Aio::OpFunc d3n_cache_aio_abstract(const DoutPrefixProvider *dpp, optional_yield y, off_t read_ofs, off_t read_len, std::string& location) {
- return [dpp, y, read_ofs, read_len, location] (Aio* aio, AioResult& r) mutable {
+Aio::OpFunc d3n_cache_aio_abstract(const DoutPrefixProvider *dpp, optional_yield y, off_t read_ofs, off_t read_len, std::string& cache_location) {
+ return [dpp, y, read_ofs, read_len, cache_location] (Aio* aio, AioResult& r) mutable {
// d3n data cache requires yield context (rgw_beast_enable_async=true)
ceph_assert(y);
auto& ref = r.obj.get_ref();
auto c = std::make_unique<D3nL1CacheRequest>();
lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: d3n_cache_aio_abstract(): libaio Read From Cache, oid=" << ref.obj.oid << dendl;
- c->file_aio_read_abstract(dpp, y.get_io_context(), y.get_yield_context(), location, read_ofs, read_len, aio, r);
+ c->file_aio_read_abstract(dpp, y.get_io_context(), y.get_yield_context(), cache_location, read_ofs, read_len, aio, r);
};
}
}
Aio::OpFunc Aio::d3n_cache_op(const DoutPrefixProvider *dpp, optional_yield y,
- off_t read_ofs, off_t read_len, std::string& location) {
- return d3n_cache_aio_abstract(dpp, y, read_ofs, read_len, location);
+ off_t read_ofs, off_t read_len, std::string& cache_location) {
+ return d3n_cache_aio_abstract(dpp, y, read_ofs, read_len, cache_location);
}
} // namespace rgw
using Signature = void(boost::system::error_code, bufferlist);
using Completion = ceph::async::Completion<Signature, AsyncFileReadOp>;
- int init(const DoutPrefixProvider *dpp, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg) {
- ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): file_path=" << file_path << dendl;
+ int init_async_read(const DoutPrefixProvider *dpp, const std::string& location, off_t read_ofs, off_t read_len, void* arg) {
+ ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl;
aio_cb.reset(new struct aiocb);
memset(aio_cb.get(), 0, sizeof(struct aiocb));
- aio_cb->aio_fildes = TEMP_FAILURE_RETRY(::open(file_path.c_str(), O_RDONLY|O_CLOEXEC|O_BINARY));
+ aio_cb->aio_fildes = TEMP_FAILURE_RETRY(::open(location.c_str(), O_RDONLY|O_CLOEXEC|O_BINARY));
if(aio_cb->aio_fildes < 0) {
int err = errno;
- ldpp_dout(dpp, 1) << "ERROR: D3nDataCache: " << __func__ << "(): can't open " << file_path << " : " << cpp_strerror(err) << dendl;
+ ldpp_dout(dpp, 1) << "ERROR: D3nDataCache: " << __func__ << "(): can't open " << location << " : " << cpp_strerror(err) << dendl;
return -err;
}
if (g_conf()->rgw_d3n_l1_fadvise != POSIX_FADV_NORMAL)
};
template <typename ExecutionContext, typename CompletionToken>
- auto async_read(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& file_path,
+ auto async_read(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& location,
off_t read_ofs, off_t read_len, CompletionToken&& token) {
using Op = AsyncFileReadOp;
using Signature = typename Op::Signature;
auto p = Op::create(ctx.get_executor(), init.completion_handler);
auto& op = p->user_data;
- ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): file_path=" << file_path << dendl;
- int ret = op.init(dpp, file_path, read_ofs, read_len, p.get());
+ ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl;
+ int ret = op.init_async_read(dpp, location, read_ofs, read_len, p.get());
if(0 == ret) {
ret = ::aio_read(op.aio_cb.get());
}
};
void file_aio_read_abstract(const DoutPrefixProvider *dpp, boost::asio::io_context& context, yield_context yield,
- std::string& file_path, off_t read_ofs, off_t read_len,
+ std::string& cache_location, off_t read_ofs, off_t read_len,
rgw::Aio* aio, rgw::AioResult& r) {
using namespace boost::asio;
async_completion<yield_context, void()> init(yield);
auto& ref = r.obj.get_ref();
ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): oid=" << ref.obj.oid << dendl;
- async_read(dpp, context, file_path+"/"+ref.obj.oid, read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r}));
+ async_read(dpp, context, cache_location+"/"+url_encode(ref.obj.oid, true), read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r}));
}
};
using namespace std;
-int D3nCacheAioWriteRequest::d3n_prepare_libaio_write_op(bufferlist& bl, unsigned int len, string oid, string cache_location)
+int D3nCacheAioWriteRequest::d3n_libaio_prepare_write_op(bufferlist& bl, unsigned int len, string oid, string cache_location)
{
- std::string location = cache_location + oid;
+ std::string location = cache_location + url_encode(oid, true);
int r = 0;
lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): Write To Cache, location=" << location << dendl;
int D3nDataCache::d3n_io_write(bufferlist& bl, unsigned int len, std::string oid)
{
D3nChunkDataInfo* chunk_info = new D3nChunkDataInfo;
- std::string location = cache_location + oid;
+ std::string location = cache_location + url_encode(oid, true);
lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl;
FILE *cache_file = nullptr;
lsubdout(g_ceph_context, rgw_datacache, 30) << "D3nDataCache: " << __func__ << "(): Write To Cache, oid=" << oid << ", len=" << len << dendl;
struct D3nCacheAioWriteRequest* wr = new struct D3nCacheAioWriteRequest(cct);
int r=0;
- if ((r = wr->d3n_prepare_libaio_write_op(bl, len, oid, cache_location)) < 0) {
+ if ((r = wr->d3n_libaio_prepare_write_op(bl, len, oid, cache_location)) < 0) {
ldout(cct, 0) << "ERROR: D3nDataCache: " << __func__ << "() prepare libaio write op r=" << r << dendl;
goto done;
}
{
const std::lock_guard l(d3n_cache_lock);
bool exist = false;
- string location = cache_location + oid;
+ string location = cache_location + url_encode(oid, true);
lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl;
std::unordered_map<string, D3nChunkDataInfo*>::iterator iter = d3n_cache_map.find(oid);
d3n_cache_map.erase(del_oid); // oid
}
- location = cache_location + del_oid;
+ location = cache_location + url_encode(del_oid, true);
::remove(location.c_str());
return freed_size;
}
}
freed_size = del_entry->size;
delete del_entry;
- location = cache_location + del_oid;
+ location = cache_location + url_encode(del_oid, true);
::remove(location.c_str());
return freed_size;
}
CephContext *cct;
D3nCacheAioWriteRequest(CephContext *_cct) : cct(_cct) {}
- int d3n_prepare_libaio_write_op(bufferlist& bl, unsigned int len, std::string oid, std::string cache_location);
+ int d3n_libaio_prepare_write_op(bufferlist& bl, unsigned int len, std::string oid, std::string cache_location);
~D3nCacheAioWriteRequest() {
::close(fd);