From 608785a0079f807ff860c56d96b1b67bf6a2ed74 Mon Sep 17 00:00:00 2001 From: yaoning Date: Fri, 24 Jun 2016 09:51:07 +0800 Subject: [PATCH] os: make zero values noops for set_alloc_hint() in FileStore Signed-off-by: yaoning (cherry picked from commit e2ec24f61b55457caccefecd56f9f08b98264802) --- src/os/ObjectStore.h | 2 ++ src/os/filestore/FileStore.cc | 5 ++++- src/osd/osd_types.cc | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 93ae4bb4a348..ae0584da3aac 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1718,6 +1718,8 @@ public: data.ops++; } + /// Set allocation hint for an object + /// make 0 values(expected_object_size, expected_write_size) noops for all implementations void set_alloc_hint( coll_t cid, const ghobject_t &oid, diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index ce1cfe262046..9196bfbb172a 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -5494,7 +5494,10 @@ int FileStore::_set_alloc_hint(const coll_t& cid, const ghobject_t& oid, dout(15) << "set_alloc_hint " << cid << "/" << oid << " object_size " << expected_object_size << " write_size " << expected_write_size << dendl; FDRef fd; - int ret; + int ret = 0; + + if (expected_object_size == 0 || expected_write_size == 0) + goto out; ret = lfn_open(cid, oid, false, &fd); if (ret < 0) diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 6035e4217b99..eeb10dbb8cf8 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -4754,6 +4754,7 @@ void object_info_t::encode(bufferlist& bl) const ::encode(omap_digest, bl); ::encode(expected_object_size, bl); ::encode(expected_write_size, bl); + ::encode(alloc_hint_flags, bl); ENCODE_FINISH(bl); } @@ -4836,9 +4837,11 @@ void object_info_t::decode(bufferlist::iterator& bl) if (struct_v >= 16) { ::decode(expected_object_size, bl); ::decode(expected_write_size, bl); + ::decode(alloc_hint_flags, bl); } else { expected_object_size = 0; expected_write_size = 0; + alloc_hint_flags = 0; } DECODE_FINISH(bl); } -- 2.47.3