From: mychoxin Date: Sat, 12 Aug 2017 08:48:20 +0000 (+0800) Subject: os/bluestore: function collect_metadata, use 'const string&' to reduce copy X-Git-Tag: v13.0.0~79^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e6855210e0b408e1a5b2f9c366ab7ee95f396c2d;p=ceph.git os/bluestore: function collect_metadata, use 'const string&' to reduce copy Signed-off-by: mychoxin --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 0014c686320..a90cedeb854 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -115,7 +115,7 @@ public: uint64_t get_size() const { return size; } uint64_t get_block_size() const { return block_size; } - virtual int collect_metadata(std::string prefix, std::map *pm) const = 0; + virtual int collect_metadata(const std::string& prefix, std::map *pm) const = 0; virtual int read( uint64_t off, diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index b0a4cde589c..1ed767333e7 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -198,7 +198,7 @@ static string get_dev_property(const char *dev, const char *property) return val; } -int KernelDevice::collect_metadata(string prefix, map *pm) const +int KernelDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = stringify((int)(bool)rotational); (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index 26e9c9a0519..e5a21a10a2e 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -75,7 +75,7 @@ public: void aio_submit(IOContext *ioc) override; - int collect_metadata(std::string prefix, map *pm) const override; + int collect_metadata(const std::string& prefix, map *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 6c791dbf997..2ff5dac3357 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -929,7 +929,7 @@ void NVMEDevice::close() dout(1) << __func__ << " end" << dendl; } -int NVMEDevice::collect_metadata(string prefix, map *pm) const +int NVMEDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = "0"; (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 4ce6b7ec577..21ce0d91535 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -227,7 +227,7 @@ class NVMEDevice : public BlockDevice { int invalidate_cache(uint64_t off, uint64_t len) override; int open(const string& path) override; void close() override; - int collect_metadata(string prefix, map *pm) const override; + int collect_metadata(const string& prefix, map *pm) const override; }; #endif diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 517870162a6..8b0494a64a9 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -146,7 +146,7 @@ static string get_dev_property(const char *dev, const char *property) return val; } -int PMEMDevice::collect_metadata(string prefix, map *pm) const +int PMEMDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = stringify((int)(bool)rotational); (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/PMEMDevice.h b/src/os/bluestore/PMEMDevice.h index ab3507192c8..d7dd248402c 100644 --- a/src/os/bluestore/PMEMDevice.h +++ b/src/os/bluestore/PMEMDevice.h @@ -41,7 +41,7 @@ public: void aio_submit(IOContext *ioc) override; - int collect_metadata(std::string prefix, map *pm) const override; + int collect_metadata(const std::string& prefix, map *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc,