diff options
-rw-r--r-- | src/common/buffer.cc | 9 | ||||
-rw-r--r-- | src/common/lru_map.h | 48 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 28 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 2 |
5 files changed, 54 insertions, 35 deletions
diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 0424887139e..24a61724c8e 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -990,11 +990,14 @@ void buffer::list::rebuild_page_aligned() */ char *buffer::list::c_str() { - if (_buffers.size() == 0) + if (_buffers.empty()) return 0; // no buffers - if (_buffers.size() > 1) + + std::list<ptr>::const_iterator iter = _buffers.begin(); + iter++; + + if (iter != _buffers.end()) rebuild(); - assert(_buffers.size() == 1); return _buffers.front().c_str(); // good, we're already contiguous. } diff --git a/src/common/lru_map.h b/src/common/lru_map.h index fb637478884..6e7f7b3786f 100644 --- a/src/common/lru_map.h +++ b/src/common/lru_map.h @@ -13,8 +13,8 @@ class lru_map { typename std::list<K>::iterator lru_iter; }; - std::map<K, entry> tokens; - std::list<K> tokens_lru; + std::map<K, entry> entries; + std::list<K> entries_lru; Mutex lock; @@ -33,19 +33,19 @@ template <class K, class V> bool lru_map<K, V>::find(const K& key, V& value) { lock.Lock(); - typename std::map<K, entry>::iterator iter = tokens.find(key); - if (iter == tokens.end()) { + typename std::map<K, entry>::iterator iter = entries.find(key); + if (iter == entries.end()) { lock.Unlock(); return false; } entry& e = iter->second; - tokens_lru.erase(e.lru_iter); + entries_lru.erase(e.lru_iter); value = e.value; - tokens_lru.push_front(key); - e.lru_iter = tokens_lru.begin(); + entries_lru.push_front(key); + e.lru_iter = entries_lru.begin(); lock.Unlock(); @@ -56,23 +56,23 @@ template <class K, class V> void lru_map<K, V>::add(const K& key, V& value) { lock.Lock(); - typename std::map<K, entry>::iterator iter = tokens.find(key); - if (iter != tokens.end()) { + typename std::map<K, entry>::iterator iter = entries.find(key); + if (iter != entries.end()) { entry& e = iter->second; - tokens_lru.erase(e.lru_iter); + entries_lru.erase(e.lru_iter); } - tokens_lru.push_front(key); - entry& e = tokens[key]; + entries_lru.push_front(key); + entry& e = entries[key]; e.value = value; - e.lru_iter = tokens_lru.begin(); - - while (tokens_lru.size() > max) { - typename std::list<K>::reverse_iterator riter = tokens_lru.rbegin(); - iter = tokens.find(*riter); - // assert(iter != tokens.end()); - tokens.erase(iter); - tokens_lru.pop_back(); + e.lru_iter = entries_lru.begin(); + + while (entries.size() > max) { + typename std::list<K>::reverse_iterator riter = entries_lru.rbegin(); + iter = entries.find(*riter); + // assert(iter != entries.end()); + entries.erase(iter); + entries_lru.pop_back(); } lock.Unlock(); @@ -82,13 +82,13 @@ template <class K, class V> void lru_map<K, V>::erase(const K& key) { Mutex::Locker l(lock); - typename std::map<K, entry>::iterator iter = tokens.find(key); - if (iter == tokens.end()) + typename std::map<K, entry>::iterator iter = entries.find(key); + if (iter == entries.end()) return; entry& e = iter->second; - tokens_lru.erase(e.lru_iter); - tokens.erase(iter); + entries_lru.erase(e.lru_iter); + entries.erase(iter); } #endif diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 85dcf576271..1bbf628fe7e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2154,7 +2154,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) osdmap.get_inst(i)); } r = 0; - ss << " instructed to " << whostr; + ss << " instructed to " << pvec.back(); } else { long osd = parse_osd_id(whostr.c_str(), &ss); if (osd < 0) { diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5ec61b965a1..3db7c719a82 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2493,6 +2493,22 @@ static void set_copy_attrs(map<string, bufferlist>& src_attrs, map<string, buffe } } +class GetObjHandleDestructor { + RGWRados *store; + void **handle; + +public: + GetObjHandleDestructor(RGWRados *_store) : store(_store), handle(NULL) {} + ~GetObjHandleDestructor() { + if (handle) { + store->finish_get_obj(handle); + } + } + void set_handle(void **_h) { + handle = _h; + } +}; + /** * Copy an object. * dest_obj: the object to copy into @@ -2547,6 +2563,7 @@ int RGWRados::copy_obj(void *ctx, ldout(cct, 5) << "Copy object " << src_obj.bucket << ":" << src_obj.object << " => " << dest_obj.bucket << ":" << dest_obj.object << dendl; void *handle = NULL; + GetObjHandleDestructor handle_destructor(this); map<string, bufferlist> src_attrs; off_t ofs = 0; @@ -2556,6 +2573,8 @@ int RGWRados::copy_obj(void *ctx, mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &obj_size, NULL, &handle, err); if (ret < 0) return ret; + + handle_destructor.set_handle(&handle); } else { /* source is in a different region, copy it there */ @@ -2699,7 +2718,7 @@ set_err_state: return 0; } else if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */ - return copy_obj_data(ctx, handle, end, dest_obj, src_obj, mtime, src_attrs, category, ptag, err); + return copy_obj_data(ctx, &handle, end, dest_obj, src_obj, mtime, src_attrs, category, ptag, err); } map<uint64_t, RGWObjManifestPart>::iterator miter = astate->manifest.objs.begin(); @@ -2804,7 +2823,7 @@ done_ret: int RGWRados::copy_obj_data(void *ctx, - void *handle, off_t end, + void **handle, off_t end, rgw_obj& dest_obj, rgw_obj& src_obj, time_t *mtime, @@ -2830,7 +2849,7 @@ int RGWRados::copy_obj_data(void *ctx, do { bufferlist bl; - ret = get_obj(ctx, NULL, &handle, src_obj, bl, ofs, end); + ret = get_obj(ctx, NULL, handle, src_obj, bl, ofs, end); if (ret < 0) return ret; @@ -2877,12 +2896,9 @@ int RGWRados::copy_obj_data(void *ctx, if (mtime) obj_stat(ctx, dest_obj, NULL, mtime, NULL, NULL, NULL, NULL); - finish_get_obj(&handle); - return ret; done_err: delete_obj(ctx, shadow_obj); - finish_get_obj(&handle); return r; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index a55f1c1f94c..65765c414aa 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1130,7 +1130,7 @@ public: void *progress_data); int copy_obj_data(void *ctx, - void *handle, off_t end, + void **handle, off_t end, rgw_obj& dest_obj, rgw_obj& src_obj, time_t *mtime, |