]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: convert to allocator agnostic string_view
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 15 Jan 2018 22:30:55 +0000 (14:30 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 7 Feb 2018 14:40:30 +0000 (06:40 -0800)
This is necessary to allow many interfaces to take mempool allocated strings.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
63 files changed:
src/client/Client.cc
src/client/MetaRequest.h
src/common/Formatter.cc
src/common/Formatter.h
src/common/HTMLFormatter.cc
src/common/HTMLFormatter.h
src/include/encoding.h
src/include/filepath.h
src/mds/Beacon.cc
src/mds/Beacon.h
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/DamageTable.cc
src/mds/DamageTable.h
src/mds/FSMap.cc
src/mds/FSMap.h
src/mds/FSMapUser.h
src/mds/Locker.cc
src/mds/Locker.h
src/mds/LogEvent.cc
src/mds/LogEvent.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSAuthCaps.cc
src/mds/MDSAuthCaps.h
src/mds/MDSDaemon.cc
src/mds/MDSDaemon.h
src/mds/MDSMap.h
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/Mantle.cc
src/mds/Mantle.h
src/mds/Migrator.cc
src/mds/ScrubHeader.h
src/mds/ScrubStack.cc
src/mds/Server.cc
src/mds/Server.h
src/mds/SessionMap.cc
src/mds/SnapClient.h
src/mds/SnapRealm.cc
src/mds/SnapRealm.h
src/mds/events/EMetaBlob.h
src/mds/inode_backtrace.h
src/mds/journal.cc
src/mds/mdstypes.h
src/mds/snap.cc
src/mds/snap.h
src/messages/MCacheExpire.h
src/messages/MClientLease.h
src/messages/MClientRequest.h
src/messages/MCommandReply.h
src/messages/MDentryLink.h
src/messages/MDentryUnlink.h
src/messages/MDiscoverReply.h
src/messages/MMDSBeacon.h
src/messages/MMDSCacheRejoin.h
src/mgr/PyFormatter.cc
src/mgr/PyFormatter.h
src/rgw/rgw_formats.cc
src/rgw/rgw_formats.h

index 4265fa79b604e6a3b01592023458a96dbd1f9a23..69e0d74fb0081ed4821a4e804db14c047cebdd49 100644 (file)
@@ -7610,7 +7610,7 @@ int Client::_readdir_get_frag(dir_result_t *dirp)
   req->head.args.readdir.frag = fg;
   req->head.args.readdir.flags = CEPH_READDIR_REPLY_BITFLAGS;
   if (dirp->last_name.length()) {
-    req->path2.set_path(dirp->last_name.c_str());
+    req->path2.set_path(dirp->last_name);
   } else if (dirp->hash_order()) {
     req->head.args.readdir.offset_hash = dirp->offset_high();
   }
index 76c430fc0212e04488c277a8575944defe17fc2b..dddd87cdddd002e48a72409a79431cff2034dc78 100644 (file)
@@ -169,7 +169,7 @@ public:
   void set_retry_attempt(int a) { head.num_retry = a; }
   void set_filepath(const filepath& fp) { path = fp; }
   void set_filepath2(const filepath& fp) { path2 = fp; }
-  void set_string2(const char *s) { path2.set_path(s, 0); }
+  void set_string2(const char *s) { path2.set_path(std::string_view(s), 0); }
   void set_caller_perms(const UserPerm& _perms) {
     perms.shallow_copy(_perms);
     head.caller_uid = perms.uid();
index 3b3589db805ca18ce52458ecb1de89f98ba8ead2..3375cb792c390eda4edff3c6ae155de84b140fb9 100644 (file)
@@ -52,11 +52,11 @@ Formatter::Formatter() { }
 
 Formatter::~Formatter() { }
 
-Formatter *Formatter::create(const std::string &type,
-                            const std::string& default_type,
-                            const std::string& fallback)
+Formatter *Formatter::create(std::string_view type,
+                            std::string_view default_type,
+                            std::string_view fallback)
 {
-  std::string mytype = type;
+  std::string mytype(type);
   if (mytype == "")
     mytype = default_type;
 
@@ -161,11 +161,11 @@ void JSONFormatter::print_comma(json_formatter_stack_entry_d& entry)
     m_ss << "    ";
 }
 
-void JSONFormatter::print_quoted_string(const std::string& s)
+void JSONFormatter::print_quoted_string(std::string_view s)
 {
-  int len = escape_json_attr_len(s.c_str(), s.size());
+  int len = escape_json_attr_len(s.data(), s.size());
   char escaped[len];
-  escape_json_attr(s.c_str(), s.size(), escaped);
+  escape_json_attr(s.data(), s.size(), escaped);
   m_ss << '\"' << escaped << '\"';
 }
 
@@ -272,7 +272,7 @@ void JSONFormatter::dump_float(const char *name, double d)
   m_ss << foo;
 }
 
-void JSONFormatter::dump_string(const char *name, const std::string& s)
+void JSONFormatter::dump_string(const char *name, std::string_view s)
 {
   print_name(name);
   print_quoted_string(s);
@@ -443,19 +443,19 @@ void XMLFormatter::dump_float(const char *name, double d)
     m_ss << "\n";
 }
 
-void XMLFormatter::dump_string(const char *name, const std::string& s)
+void XMLFormatter::dump_string(const char *name, std::string_view s)
 {
   std::string e(name);
   std::transform(e.begin(), e.end(), e.begin(),
       [this](char c) { return this->to_lower_underscore(c); });
 
   print_spaces();
-  m_ss << "<" << e << ">" << escape_xml_str(s.c_str()) << "</" << e << ">";
+  m_ss << "<" << e << ">" << escape_xml_str(s.data()) << "</" << e << ">";
   if (m_pretty)
     m_ss << "\n";
 }
 
-void XMLFormatter::dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
+void XMLFormatter::dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs)
 {
   std::string e(name);
   std::transform(e.begin(), e.end(), e.begin(),
@@ -464,7 +464,7 @@ void XMLFormatter::dump_string_with_attrs(const char *name, const std::string& s
   std::string attrs_str;
   get_attrs_str(&attrs, attrs_str);
   print_spaces();
-  m_ss << "<" << e << attrs_str << ">" << escape_xml_str(s.c_str()) << "</" << e << ">";
+  m_ss << "<" << e << attrs_str << ">" << escape_xml_str(s.data()) << "</" << e << ">";
   if (m_pretty)
     m_ss << "\n";
 }
@@ -564,11 +564,11 @@ void XMLFormatter::print_spaces()
   }
 }
 
-std::string XMLFormatter::escape_xml_str(const char *str)
+std::string XMLFormatter::escape_xml_str(std::string_view str)
 {
-  int len = escape_xml_attr_len(str);
+  size_t len = escape_xml_attr_len(str.data());
   std::vector<char> escaped(len, '\0');
-  escape_xml_attr(str, &escaped[0]);
+  escape_xml_attr(str.data(), &escaped[0]);
   return std::string(&escaped[0]);
 }
 
@@ -837,7 +837,7 @@ void TableFormatter::dump_float(const char *name, double d)
   m_ss.str("");
 }
 
-void TableFormatter::dump_string(const char *name, const std::string& s)
+void TableFormatter::dump_string(const char *name, std::string_view s)
 {
   finish_pending_string();
   size_t i = m_vec_index(name);
@@ -848,7 +848,7 @@ void TableFormatter::dump_string(const char *name, const std::string& s)
   m_ss.str("");
 }
 
-void TableFormatter::dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
+void TableFormatter::dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs)
 {
   finish_pending_string();
   size_t i = m_vec_index(name);
index df6c0a99a5ebaf4743d850dc84369990cff3f9c9..6cfe60dac04a156c8fab3850cc5ddfc989b76903 100644 (file)
@@ -23,14 +23,14 @@ namespace ceph {
 
   class Formatter {
   public:
-    static Formatter *create(const std::string& type,
-                            const std::string& default_type,
-                            const std::string& fallback);
-    static Formatter *create(const std::string& type,
-                            const std::string& default_type) {
+    static Formatter *create(std::string_view type,
+                            std::string_view default_type,
+                            std::string_view fallback);
+    static Formatter *create(std::string_view type,
+                            std::string_view default_type) {
       return create(type, default_type, "");
     }
-    static Formatter *create(const std::string& type) {
+    static Formatter *create(std::string_view type) {
       return create(type, "json-pretty", "");
     }
 
@@ -54,7 +54,7 @@ namespace ceph {
     virtual void dump_unsigned(const char *name, uint64_t u) = 0;
     virtual void dump_int(const char *name, int64_t s) = 0;
     virtual void dump_float(const char *name, double d) = 0;
-    virtual void dump_string(const char *name, const std::string& s) = 0;
+    virtual void dump_string(const char *name, std::string_view s) = 0;
     virtual void dump_bool(const char *name, bool b)
     {
       dump_format_unquoted(name, "%s", (b ? "true" : "false"));
@@ -81,7 +81,7 @@ namespace ceph {
     {
       open_object_section(name);
     }
-    virtual void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
+    virtual void dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs)
     {
       dump_string(name, s);
     }
@@ -106,7 +106,7 @@ namespace ceph {
     void dump_unsigned(const char *name, uint64_t u) override;
     void dump_int(const char *name, int64_t u) override;
     void dump_float(const char *name, double d) override;
-    void dump_string(const char *name, const std::string& s) override;
+    void dump_string(const char *name, std::string_view s) override;
     std::ostream& dump_stream(const char *name) override;
     void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
     int get_len() const override;
@@ -122,7 +122,7 @@ namespace ceph {
 
     bool m_pretty;
     void open_section(const char *name, bool is_array);
-    void print_quoted_string(const std::string& s);
+    void print_quoted_string(std::string_view s);
     void print_name(const char *name);
     void print_comma(json_formatter_stack_entry_d& entry);
     void finish_pending_string();
@@ -154,7 +154,7 @@ namespace ceph {
     void dump_unsigned(const char *name, uint64_t u) override;
     void dump_int(const char *name, int64_t u) override;
     void dump_float(const char *name, double d) override;
-    void dump_string(const char *name, const std::string& s) override;
+    void dump_string(const char *name, std::string_view s) override;
     std::ostream& dump_stream(const char *name) override;
     void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
     int get_len() const override;
@@ -163,13 +163,13 @@ namespace ceph {
     /* with attrs */
     void open_array_section_with_attrs(const char *name, const FormatterAttrs& attrs) override;
     void open_object_section_with_attrs(const char *name, const FormatterAttrs& attrs) override;
-    void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs) override;
+    void dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs) override;
 
   protected:
     void open_section_in_ns(const char *name, const char *ns, const FormatterAttrs *attrs);
     void finish_pending_string();
     void print_spaces();
-    static std::string escape_xml_str(const char *str);
+    static std::string escape_xml_str(std::string_view str);
     void get_attrs_str(const FormatterAttrs *attrs, std::string& attrs_str);
     char to_lower_underscore(char c) const;
 
@@ -206,9 +206,9 @@ namespace ceph {
     void dump_unsigned(const char *name, uint64_t u) override;
     void dump_int(const char *name, int64_t u) override;
     void dump_float(const char *name, double d) override;
-    void dump_string(const char *name, const std::string& s) override;
+    void dump_string(const char *name, std::string_view s) override;
     void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
-    void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs) override;
+    void dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs) override;
     std::ostream& dump_stream(const char *name) override;
 
     int get_len() const override;
index 02ef744c4cbc7f254d3200f760b3f4d81d64476d..c096ec5ceea6403c5b2d2f56dfdc9640a1554fe9 100644 (file)
@@ -107,18 +107,18 @@ void HTMLFormatter::dump_float(const char *name, double d)
   dump_template(name, d);
 }
 
-void HTMLFormatter::dump_string(const char *name, const std::string& s)
+void HTMLFormatter::dump_string(const char *name, std::string_view s)
 {
-  dump_template(name, escape_xml_str(s.c_str()));
+  dump_template(name, escape_xml_str(s.data()));
 }
 
-void HTMLFormatter::dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
+void HTMLFormatter::dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs)
 {
   std::string e(name);
   std::string attrs_str;
   get_attrs_str(&attrs, attrs_str);
   print_spaces();
-  m_ss << "<li>" << e << ": " << escape_xml_str(s.c_str()) << attrs_str << "</li>";
+  m_ss << "<li>" << e << ": " << escape_xml_str(s.data()) << attrs_str << "</li>";
   if (m_pretty)
     m_ss << "\n";
 }
index c59296922478b0ebaae8133912e47cbdbe1e6d84..ab725062bebae2a6f917bd996598f9650048c196 100644 (file)
@@ -18,12 +18,12 @@ namespace ceph {
     void dump_unsigned(const char *name, uint64_t u) override;
     void dump_int(const char *name, int64_t u) override;
     void dump_float(const char *name, double d) override;
-    void dump_string(const char *name, const std::string& s) override;
+    void dump_string(const char *name, std::string_view s) override;
     std::ostream& dump_stream(const char *name) override;
     void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
 
     /* with attrs */
-    void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs) override;
+    void dump_string_with_attrs(const char *name, std::string_view s, const FormatterAttrs& attrs) override;
   private:
     template <typename T> void dump_template(const char *name, T arg);
 
index 943b42c8a1b3c1da81fd8771279d65e7bb8188a5..a13393ccfd42064b0fe3502974b2b15276e39db3 100644 (file)
@@ -19,6 +19,7 @@
 #include <deque>
 #include <vector>
 #include <string>
+#include <string_view>
 #include <tuple>
 #include <boost/optional/optional_io.hpp>
 #include <boost/tuple/tuple.hpp>
@@ -179,13 +180,17 @@ WRITE_INTTYPE_ENCODER(int16_t, le16)
 
 
 // string
-inline void encode(const std::string& s, bufferlist& bl, uint64_t features=0)
+inline void encode(std::string_view s, bufferlist& bl, uint64_t features=0)
 {
   __u32 len = s.length();
   encode(len, bl);
   if (len)
     bl.append(s.data(), len);
 }
+inline void encode(const std::string& s, bufferlist& bl, uint64_t features=0)
+{
+  return encode(std::string_view(s), bl, features);
+}
 inline void decode(std::string& s, bufferlist::iterator& p)
 {
   __u32 len;
@@ -194,10 +199,14 @@ inline void decode(std::string& s, bufferlist::iterator& p)
   p.copy(len, s);
 }
 
-inline void encode_nohead(const std::string& s, bufferlist& bl)
+inline void encode_nohead(std::string_view s, bufferlist& bl)
 {
   bl.append(s.data(), s.length());
 }
+inline void encode_nohead(const std::string& s, bufferlist& bl)
+{
+  encode_nohead(std::string_view(s), bl);
+}
 inline void decode_nohead(int len, std::string& s, bufferlist::iterator& p)
 {
   s.clear();
@@ -207,10 +216,7 @@ inline void decode_nohead(int len, std::string& s, bufferlist::iterator& p)
 // const char* (encode only, string compatible)
 inline void encode(const char *s, bufferlist& bl) 
 {
-  __u32 len = strlen(s);
-  encode(len, bl);
-  if (len)
-    bl.append(s, len);
+  encode(std::string_view(s, strlen(s)), bl);
 }
 
 
index ae3430f6f80f80e0e851322f54ffe1708a5cfa23..096e40388eafb9d131cda28ff408380465c7315b 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <iosfwd>
 #include <string>
+#include <string_view>
 #include <vector>
 
 #include "buffer.h"
@@ -72,6 +73,7 @@ class filepath {
 
  public:
   filepath() : ino(0), encoded(false) { }
+  filepath(std::string_view s, inodeno_t i) : ino(i), path(s), encoded(false) { }
   filepath(const string& s, inodeno_t i) : ino(i), path(s), encoded(false) { }
   filepath(const char* s, inodeno_t i) : ino(i), path(s), encoded(false) { }
   filepath(const filepath& o) {
@@ -82,21 +84,24 @@ class filepath {
   }
   filepath(inodeno_t i) : ino(i), encoded(false) { }
   
-  void set_path(const char *s, inodeno_t b) {
-    path = s;
-    ino = b;
-  }
-
   /*
    * if we are fed a relative path as a string, either set ino=0 (strictly
    * relative) or 1 (absolute).  throw out any leading '/'.
    */
-  filepath(const char *s) : encoded(false) {
+  filepath(std::string_view s) : encoded(false) {
     set_path(s);
   }
-  void set_path(const char *s) {
+  filepath(const char *s) : encoded(false) {
+    set_path(std::string_view(s));
+  }
+
+  void set_path(std::string_view s, inodeno_t b) {
+    path = s;
+    ino = b;
+  }
+  void set_path(std::string_view s) {
     if (s[0] == '/') {
-      path = s + 1;    
+      path = s.substr(1);
       ino = 1;
     } else {
       ino = 0;
@@ -162,17 +167,19 @@ class filepath {
     bits.pop_back();
     rebuild_path();
   }    
-  void push_dentry(const string& s) {
+  void push_dentry(std::string_view s) {
     if (bits.empty() && path.length() > 0) 
       parse_bits();
     if (!bits.empty())
       path += "/";
     path += s;
-    bits.push_back(s);
+    bits.emplace_back(s);
+  }
+  void push_dentry(const string& s) {
+    push_dentry(std::string_view(s));
   }
   void push_dentry(const char *cs) {
-    string s = cs;
-    push_dentry(s);
+    push_dentry(std::string_view(cs, strlen(cs)));
   }
   void push_front_dentry(const string& s) {
     bits.insert(bits.begin(), s);
index 10a6529854010ca925466fa694db4e19236c4566..7993585a68f268e0328caf2dc0dc1413caa544ef 100644 (file)
@@ -34,7 +34,7 @@
 #define dout_prefix *_dout << "mds.beacon." << name << ' '
 
 
-Beacon::Beacon(CephContext *cct_, MonClient *monc_, std::string name_) :
+Beacon::Beacon(CephContext *cct_, MonClient *monc_, std::string_view name_) :
   Dispatcher(cct_), lock("Beacon"), monc(monc_), timer(g_ceph_context, lock),
   name(name_), standby_for_rank(MDS_RANK_NONE),
   standby_for_fscid(FS_CLUSTER_ID_NONE), want_state(MDSMap::STATE_BOOT),
index 8b5ac30b6f4de088a2584d9740b2e5f343a3d3bd..f176588dd324f619500e30876c419f104477d74e 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef BEACON_STATE_H
 #define BEACON_STATE_H
 
+#include <string_view>
+
 #include "include/types.h"
 #include "include/Context.h"
 #include "common/Mutex.h"
@@ -40,7 +42,7 @@ class MDSRank;
 class Beacon : public Dispatcher
 {
 public:
-  Beacon(CephContext *cct_, MonClient *monc_, std::string name);
+  Beacon(CephContext *cct_, MonClient *monc_, std::string_view name);
   ~Beacon() override;
 
   void init(MDSMap const *mdsmap);
index 27a6419c5578492cd85eddb8f0fad90c07fc4537..689f0ffe6c2cb49813286fa2649125ff70f5ff37 100644 (file)
@@ -18,6 +18,7 @@
 #define CEPH_CDENTRY_H
 
 #include <string>
+#include <string_view>
 #include <set>
 
 #include "include/counter.h"
@@ -101,7 +102,7 @@ public:
   static const unsigned EXPORT_NONCE = 1;
 
 
-  CDentry(const std::string& n, __u32 h,
+  CDentry(std::string_view n, __u32 h,
          snapid_t f, snapid_t l) :
     name(n), hash(h),
     first(f), last(l),
@@ -109,7 +110,7 @@ public:
     lock(this, &lock_type),
     versionlock(this, &versionlock_type)
   {}
-  CDentry(const std::string& n, __u32 h, inodeno_t ino, unsigned char dt,
+  CDentry(std::string_view n, __u32 h, inodeno_t ino, unsigned char dt,
          snapid_t f, snapid_t l) :
     name(n), hash(h),
     first(f), last(l),
@@ -146,7 +147,7 @@ public:
 
   const CDir *get_dir() const { return dir; }
   CDir *get_dir() { return dir; }
-  const std::string& get_name() const { return name; }
+  std::string_view get_name() const { return std::string_view(name); }
 
   __u32 get_hash() const { return hash; }
 
index 97d9c3fe85f69bffd1bee374063138263ff69c4e..c7be753a246b2c5327170c7d1aa02d94923eb346 100644 (file)
@@ -12,6 +12,7 @@
  * 
  */
 
+#include <string_view>
 
 #include "include/types.h"
 
@@ -291,14 +292,14 @@ bool CDir::check_rstats(bool scrub)
   return good;
 }
 
-CDentry *CDir::lookup(const string& name, snapid_t snap)
+CDentry *CDir::lookup(std::string_view name, snapid_t snap)
 { 
   dout(20) << "lookup (" << snap << ", '" << name << "')" << dendl;
-  map_t::iterator iter = items.lower_bound(dentry_key_t(snap, name.c_str(),
+  map_t::iterator iter = items.lower_bound(dentry_key_t(snap, name,
                                                        inode->hash_dentry_name(name)));
   if (iter == items.end())
     return 0;
-  if (iter->second->name == name &&
+  if (iter->second->get_name() == name &&
       iter->second->first <= snap &&
       iter->second->last >= snap) {
     dout(20) << "  hit -> " << iter->first << dendl;
@@ -308,8 +309,8 @@ CDentry *CDir::lookup(const string& name, snapid_t snap)
   return 0;
 }
 
-CDentry *CDir::lookup_exact_snap(const string& name, snapid_t last) {
-  map_t::iterator p = items.find(dentry_key_t(last, name.c_str(),
+CDentry *CDir::lookup_exact_snap(std::string_view name, snapid_t last) {
+  map_t::iterator p = items.find(dentry_key_t(last, name,
                                              inode->hash_dentry_name(name)));
   if (p == items.end())
     return NULL;
@@ -320,7 +321,7 @@ CDentry *CDir::lookup_exact_snap(const string& name, snapid_t last) {
  * linking fun
  */
 
-CDentry* CDir::add_null_dentry(const string& dname,
+CDentry* CDir::add_null_dentry(std::string_view dname,
                               snapid_t first, snapid_t last)
 {
   // foreign
@@ -339,7 +340,7 @@ CDentry* CDir::add_null_dentry(const string& dname,
   
   // add to dir
   assert(items.count(dn->key()) == 0);
-  //assert(null_items.count(dn->name) == 0);
+  //assert(null_items.count(dn->get_name()) == 0);
 
   items[dn->key()] = dn;
   if (last == CEPH_NOSNAP)
@@ -363,7 +364,7 @@ CDentry* CDir::add_null_dentry(const string& dname,
 }
 
 
-CDentry* CDir::add_primary_dentry(const string& dname, CInode *in,
+CDentry* CDir::add_primary_dentry(std::string_view dname, CInode *in,
                                  snapid_t first, snapid_t last) 
 {
   // primary
@@ -385,7 +386,7 @@ CDentry* CDir::add_primary_dentry(const string& dname, CInode *in,
   
   // add to dir
   assert(items.count(dn->key()) == 0);
-  //assert(null_items.count(dn->name) == 0);
+  //assert(null_items.count(dn->get_name()) == 0);
 
   items[dn->key()] = dn;
 
@@ -413,7 +414,7 @@ CDentry* CDir::add_primary_dentry(const string& dname, CInode *in,
   return dn;
 }
 
-CDentry* CDir::add_remote_dentry(const string& dname, inodeno_t ino, unsigned char d_type,
+CDentry* CDir::add_remote_dentry(std::string_view dname, inodeno_t ino, unsigned char d_type,
                                 snapid_t first, snapid_t last) 
 {
   // foreign
@@ -430,7 +431,7 @@ CDentry* CDir::add_remote_dentry(const string& dname, inodeno_t ino, unsigned ch
   
   // add to dir
   assert(items.count(dn->key()) == 0);
-  //assert(null_items.count(dn->name) == 0);
+  //assert(null_items.count(dn->get_name()) == 0);
 
   items[dn->key()] = dn;
   if (last == CEPH_NOSNAP)
@@ -678,14 +679,14 @@ void CDir::add_to_bloom(CDentry *dn)
     bloom.reset(new bloom_filter(size, 1.0 / size, 0));
   }
   /* This size and false positive probability is completely random.*/
-  bloom->insert(dn->name.c_str(), dn->name.size());
+  bloom->insert(dn->get_name().data(), dn->get_name().size());
 }
 
-bool CDir::is_in_bloom(const string& name)
+bool CDir::is_in_bloom(std::string_view name)
 {
   if (!bloom)
     return false;
-  return bloom->contains(name.c_str(), name.size());
+  return bloom->contains(name.data(), name.size());
 }
 
 void CDir::remove_null_dentries() {
@@ -1009,7 +1010,7 @@ void CDir::split(int bits, list<CDir*>& subs, list<MDSInternalContextBase*>& wai
     CDir::map_t::iterator p = items.begin();
     
     CDentry *dn = p->second;
-    frag_t subfrag = inode->pick_dirfrag(dn->name);
+    frag_t subfrag = inode->pick_dirfrag(dn->get_name());
     int n = (subfrag.value() & (subfrag.mask() ^ frag.mask())) >> subfrag.mask_shift();
     dout(15) << " subfrag " << subfrag << " n=" << n << " for " << p->first << dendl;
     CDir *f = subfrags[n];
@@ -1212,7 +1213,7 @@ void CDir::assimilate_dirty_rstat_inodes_finish(MutationRef& mut, EMetaBlob *blo
  * WAITING
  */
 
-void CDir::add_dentry_waiter(const string& dname, snapid_t snapid, MDSInternalContextBase *c) 
+void CDir::add_dentry_waiter(std::string_view dname, snapid_t snapid, MDSInternalContextBase *c) 
 {
   if (waiting_on_dentry.empty())
     get(PIN_DNWAITER);
@@ -1222,7 +1223,7 @@ void CDir::add_dentry_waiter(const string& dname, snapid_t snapid, MDSInternalCo
           << " " << c << " on " << *this << dendl;
 }
 
-void CDir::take_dentry_waiting(const string& dname, snapid_t first, snapid_t last,
+void CDir::take_dentry_waiting(std::string_view dname, snapid_t first, snapid_t last,
                               list<MDSInternalContextBase*>& ls)
 {
   if (waiting_on_dentry.empty())
@@ -1456,7 +1457,7 @@ void CDir::fetch(MDSInternalContextBase *c, bool ignore_authpinnability)
   return fetch(c, want, ignore_authpinnability);
 }
 
-void CDir::fetch(MDSInternalContextBase *c, const string& want_dn, bool ignore_authpinnability)
+void CDir::fetch(MDSInternalContextBase *c, std::string_view want_dn, bool ignore_authpinnability)
 {
   dout(10) << "fetch on " << *this << dendl;
   
@@ -1494,7 +1495,7 @@ void CDir::fetch(MDSInternalContextBase *c, const string& want_dn, bool ignore_a
   }
 
   if (c) add_waiter(WAIT_COMPLETE, c);
-  if (!want_dn.empty()) wanted_items.insert(want_dn);
+  if (!want_dn.empty()) wanted_items.insert(std::string(want_dn));
   
   // already fetching?
   if (state_test(CDir::STATE_FETCHING)) {
@@ -1645,8 +1646,8 @@ void CDir::_omap_fetch_more(
 }
 
 CDentry *CDir::_load_dentry(
-    const std::string &key,
-    const std::string &dname,
+    std::string_view key,
+    std::string_view dname,
     const snapid_t last,
     bufferlist &bl,
     const int pos,
@@ -1697,7 +1698,7 @@ CDentry *CDir::_load_dentry(
 
     if (stale) {
       if (!dn) {
-        stale_items.insert(key);
+        stale_items.insert(std::string(key));
         *force_dirty = true;
       }
       return dn;
@@ -1732,7 +1733,7 @@ CDentry *CDir::_load_dentry(
     
     if (stale) {
       if (!dn) {
-        stale_items.insert(key);
+        stale_items.insert(std::string(key));
         *force_dirty = true;
       }
       return dn;
@@ -2006,11 +2007,14 @@ void CDir::_go_bad()
   finish_waiting(WAIT_COMPLETE, -EIO);
 }
 
-void CDir::go_bad_dentry(snapid_t last, const std::string &dname)
+void CDir::go_bad_dentry(snapid_t last, std::string_view dname)
 {
   dout(10) << __func__ << " " << dname << dendl;
+  std::string path(get_path());
+  path += "/";
+  path += dname;
   const bool fatal = cache->mds->damage_table.notify_dentry(
-      inode->ino(), frag, last, dname, get_path() + "/" + dname);
+      inode->ino(), frag, last, dname, path);
   if (fatal) {
     cache->mds->damaged();
     ceph_abort();  // unreachable, damaged() respawns us
@@ -2138,11 +2142,11 @@ void CDir::_omap_commit(int op_prio)
     }
 
     if (dn->get_linkage()->is_null()) {
-      dout(10) << " rm " << dn->name << " " << *dn << dendl;
+      dout(10) << " rm " << dn->get_name() << " " << *dn << dendl;
       write_size += key.length();
       to_remove.insert(key);
     } else {
-      dout(10) << " set " << dn->name << " " << *dn << dendl;
+      dout(10) << " set " << dn->get_name() << " " << *dn << dendl;
       bufferlist dnbl;
       _encode_dentry(dn, dnbl, snaps);
       write_size += key.length() + dnbl.length();
@@ -2231,7 +2235,7 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl,
   if (dn->linkage.is_remote()) {
     inodeno_t ino = dn->linkage.get_remote_ino();
     unsigned char d_type = dn->linkage.get_remote_d_type();
-    dout(14) << " pos " << bl.length() << " dn '" << dn->name << "' remote ino " << ino << dendl;
+    dout(14) << " pos " << bl.length() << " dn '" << dn->get_name() << "' remote ino " << ino << dendl;
     
     // marker, name, ino
     bl.append('L');         // remote link
@@ -2242,7 +2246,7 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl,
     CInode *in = dn->linkage.get_inode();
     assert(in);
     
-    dout(14) << " pos " << bl.length() << " dn '" << dn->name << "' inode " << *in << dendl;
+    dout(14) << " pos " << bl.length() << " dn '" << dn->get_name() << "' inode " << *in << dendl;
     
     // marker, name, inode, [symlink string]
     bl.append('I');         // inode
index b18a5f8dd4c6e6dec86cac78e4af1cea2adb52f6..13079557798ed1ef2fc129e335016d6a7f3aa02c 100644 (file)
 #ifndef CEPH_CDIR_H
 #define CEPH_CDIR_H
 
+#include <iosfwd>
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+#include <string_view>
+
 #include "include/counter.h"
 #include "include/types.h"
 #include "include/buffer_fwd.h"
 
 #include "MDSCacheObject.h"
 
-#include <iosfwd>
-
-#include <list>
-#include <set>
-#include <map>
-#include <string>
-
 
 #include "CInode.h"
 
@@ -435,17 +435,17 @@ protected:
 
   // -- dentries and inodes --
  public:
-  CDentry* lookup_exact_snap(const std::string& dname, snapid_t last);
-  CDentry* lookup(const std::string& n, snapid_t snap=CEPH_NOSNAP);
+  CDentry* lookup_exact_snap(std::string_view dname, snapid_t last);
+  CDentry* lookup(std::string_view n, snapid_t snap=CEPH_NOSNAP);
   CDentry* lookup(const char *n, snapid_t snap=CEPH_NOSNAP) {
-    return lookup(std::string(n), snap);
+    return lookup(std::string_view(n), snap);
   }
 
-  CDentry* add_null_dentry(const std::string& dname, 
+  CDentry* add_null_dentry(std::string_view dname,
                           snapid_t first=2, snapid_t last=CEPH_NOSNAP);
-  CDentry* add_primary_dentry(const std::string& dname, CInode *in, 
+  CDentry* add_primary_dentry(std::string_view dname, CInode *in,
                              snapid_t first=2, snapid_t last=CEPH_NOSNAP);
-  CDentry* add_remote_dentry(const std::string& dname, inodeno_t ino, unsigned char d_type, 
+  CDentry* add_remote_dentry(std::string_view dname, inodeno_t ino, unsigned char d_type,
                             snapid_t first=2, snapid_t last=CEPH_NOSNAP);
   void remove_dentry( CDentry *dn );         // delete dentry
   void link_remote_inode( CDentry *dn, inodeno_t ino, unsigned char d_type);
@@ -455,7 +455,7 @@ protected:
   void try_remove_unlinked_dn(CDentry *dn);
 
   void add_to_bloom(CDentry *dn);
-  bool is_in_bloom(const std::string& name);
+  bool is_in_bloom(std::string_view name);
   bool has_bloom() { return (bloom ? true : false); }
   void remove_bloom() {
     bloom.reset();
@@ -591,7 +591,7 @@ private:
     return file_object_t(ino(), frag);
   }
   void fetch(MDSInternalContextBase *c, bool ignore_authpinnability=false);
-  void fetch(MDSInternalContextBase *c, const std::string& want_dn, bool ignore_authpinnability=false);
+  void fetch(MDSInternalContextBase *c, std::string_view want_dn, bool ignore_authpinnability=false);
   void fetch(MDSInternalContextBase *c, const std::set<dentry_key_t>& keys);
 protected:
   compact_set<string> wanted_items;
@@ -601,8 +601,8 @@ protected:
     bufferlist& hdrbl, std::map<std::string, bufferlist>& omap,
     MDSInternalContextBase *fin);
   CDentry *_load_dentry(
-      const std::string &key,
-      const std::string &dname,
+      std::string_view key,
+      std::string_view dname,
       snapid_t last,
       bufferlist &bl,
       int pos,
@@ -618,7 +618,7 @@ protected:
   /**
    * Go bad due to a damaged dentry (register with damagetable and go BADFRAG)
    */
-  void go_bad_dentry(snapid_t last, const std::string &dname);
+  void go_bad_dentry(snapid_t last, std::string_view dname);
 
   /**
    * Go bad due to a damaged header (register with damagetable and go BADFRAG)
@@ -668,11 +668,11 @@ protected:
   compact_map< string_snap_t, std::list<MDSInternalContextBase*> > waiting_on_dentry;
 
 public:
-  bool is_waiting_for_dentry(const std::string& dname, snapid_t snap) {
+  bool is_waiting_for_dentry(std::string_view dname, snapid_t snap) {
     return waiting_on_dentry.count(string_snap_t(dname, snap));
   }
-  void add_dentry_waiter(const std::string& dentry, snapid_t snap, MDSInternalContextBase *c);
-  void take_dentry_waiting(const std::string& dentry, snapid_t first, snapid_t last, std::list<MDSInternalContextBase*>& ls);
+  void add_dentry_waiter(std::string_view dentry, snapid_t snap, MDSInternalContextBase *c);
+  void take_dentry_waiting(std::string_view dentry, snapid_t first, snapid_t last, std::list<MDSInternalContextBase*>& ls);
   void take_sub_waiting(std::list<MDSInternalContextBase*>& ls);  // dentry or ino
 
   void add_waiter(uint64_t mask, MDSInternalContextBase *c) override;
index 60b18b978ef8f174bca4796beb40804bdb309103..ed2ecde96553f95d260482d1f33763779dd52707 100644 (file)
@@ -499,7 +499,7 @@ void CInode::pop_projected_snaprealm(sr_t *next_snaprealm)
 
 // dirfrags
 
-__u32 InodeStoreBase::hash_dentry_name(const string &dn)
+__u32 InodeStoreBase::hash_dentry_name(std::string_view dn)
 {
   int which = inode.dir_layout.dl_dir_hash;
   if (!which)
@@ -508,7 +508,7 @@ __u32 InodeStoreBase::hash_dentry_name(const string &dn)
   return ceph_str_hash(which, dn.data(), dn.length());
 }
 
-frag_t InodeStoreBase::pick_dirfrag(const string& dn)
+frag_t InodeStoreBase::pick_dirfrag(std::string_view dn)
 {
   if (dirfragtree.empty())
     return frag_t();          // avoid the string hash if we can.
@@ -1135,7 +1135,7 @@ void CInode::build_backtrace(int64_t pool, inode_backtrace_t& bt)
   CDentry *pdn = get_parent_dn();
   while (pdn) {
     CInode *diri = pdn->get_dir()->get_inode();
-    bt.ancestors.push_back(inode_backpointer_t(diri->ino(), pdn->name, in->inode.version));
+    bt.ancestors.push_back(inode_backpointer_t(diri->ino(), pdn->get_name(), in->inode.version));
     in = diri;
     pdn = in->get_parent_dn();
   }
@@ -1310,7 +1310,7 @@ void CInode::verify_diri_backtrace(bufferlist &bl, int err)
     decode(backtrace, bl);
     CDentry *pdn = get_parent_dn();
     if (backtrace.ancestors.empty() ||
-       backtrace.ancestors[0].dname != pdn->name ||
+       backtrace.ancestors[0].dname != pdn->get_name() ||
        backtrace.ancestors[0].dirino != pdn->get_dir()->ino())
       err = -EINVAL;
   }
@@ -3912,7 +3912,7 @@ void CInode::validate_disk_state(CInode::validated_data *results,
     /**
      * Fetch backtrace and set tag if tag is non-empty
      */
-    void fetch_backtrace_and_tag(CInode *in, std::string tag,
+    void fetch_backtrace_and_tag(CInode *in, std::string_view tag,
                                  Context *fin, int *bt_r, bufferlist *bt)
     {
       const int64_t pool = in->get_backtrace_pool();
@@ -3954,7 +3954,7 @@ void CInode::validate_disk_state(CInode::validated_data *results,
       // present)
       if (in->scrub_infop) {
         // I'm a non-orphan, so look up my ScrubHeader via my linkage
-        const std::string &tag = in->scrub_infop->header->get_tag();
+        std::string_view tag = in->scrub_infop->header->get_tag();
         // Rather than using the usual CInode::fetch_backtrace,
         // use a special variant that optionally writes a tag in the same
         // operation.
index 39d5292e43259c1aeb6c25ee2afa2f072daada7e..41f066240b176efd112a153a88166732fde62f6b 100644 (file)
 #ifndef CEPH_CINODE_H
 #define CEPH_CINODE_H
 
+#include <list>
+#include <map>
+#include <set>
+#include <string_view>
+
 #include "common/config.h"
 #include "include/counter.h"
 #include "include/elist.h"
 #include "SnapRealm.h"
 #include "Mutation.h"
 
-#include <list>
-#include <set>
-#include <map>
-
 #define dout_context g_ceph_context
 
 class Context;
@@ -102,8 +103,8 @@ public:
   void dump(Formatter *f) const;
 
   /* For use by offline tools */
-  __u32 hash_dentry_name(const std::string &dn);
-  frag_t pick_dirfrag(const std::string &dn);
+  __u32 hash_dentry_name(std::string_view dn);
+  frag_t pick_dirfrag(std::string_view dn);
 };
 
 class InodeStore : public InodeStoreBase {
index f7d023c1337fccca1a6ba3d23df975088749df2f..de6a5ee4b34f0938f0e5ea73fce0e487ff20087a 100644 (file)
@@ -70,7 +70,7 @@ class DentryDamage : public DamageEntry
   DentryDamage(
       inodeno_t ino_,
       frag_t frag_,
-      std::string dname_,
+      std::string_view dname_,
       snapid_t snap_id_)
     : ino(ino_), frag(frag_), dname(dname_), snap_id(snap_id_)
   {}
@@ -129,7 +129,7 @@ DamageEntry::~DamageEntry()
 
 bool DamageTable::notify_dentry(
     inodeno_t ino, frag_t frag,
-    snapid_t snap_id, const std::string &dname, const std::string &path)
+    snapid_t snap_id, std::string_view dname, std::string_view path)
 {
   if (oversized()) {
     return true;
@@ -160,7 +160,7 @@ bool DamageTable::notify_dentry(
 }
 
 bool DamageTable::notify_dirfrag(inodeno_t ino, frag_t frag,
-                                 const std::string &path)
+                                 std::string_view path)
 {
   // Special cases: damage to these dirfrags is considered fatal to
   // the MDS rank that owns them.
@@ -189,7 +189,7 @@ bool DamageTable::notify_dirfrag(inodeno_t ino, frag_t frag,
   return false;
 }
 
-bool DamageTable::notify_remote_damaged(inodeno_t ino, const std::string &path)
+bool DamageTable::notify_remote_damaged(inodeno_t ino, std::string_view path)
 {
   if (oversized()) {
     return true;
@@ -212,7 +212,7 @@ bool DamageTable::oversized() const
 
 bool DamageTable::is_dentry_damaged(
         const CDir *dir_frag,
-        const std::string &dname,
+        std::string_view dname,
         const snapid_t snap_id) const
 {
   if (dentries.count(
index 34c7da02e73c8ed3e0962d04f93f4d403931bfcd..ba0f55fb8b046bc2a1a8ea67d2e7aee7d0a4bc16 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef DAMAGE_TABLE_H_
 #define DAMAGE_TABLE_H_
 
+#include <string_view>
+
 #include "mdstypes.h"
 #include "include/random.h"
 
@@ -93,7 +95,7 @@ class DentryIdent
     }
   }
 
-  DentryIdent(const std::string &dname_, snapid_t snap_id_)
+  DentryIdent(std::string_view dname_, snapid_t snap_id_)
     : dname(dname_), snap_id(snap_id_)
   {}
 };
@@ -161,7 +163,7 @@ public:
    *
    * @return true if fatal
    */
-  bool notify_dirfrag(inodeno_t ino, frag_t frag, const std::string &path);
+  bool notify_dirfrag(inodeno_t ino, frag_t frag, std::string_view path);
 
   /**
    * Indicate that a particular dentry cannot be loaded.
@@ -170,17 +172,17 @@ public:
    */
   bool notify_dentry(
     inodeno_t ino, frag_t frag,
-    snapid_t snap_id, const std::string &dname, const std::string &path);
+    snapid_t snap_id, std::string_view dname, std::string_view path);
 
   /**
    * Indicate that a particular Inode could not be loaded by number
    */
   bool notify_remote_damaged(
-      inodeno_t ino, const std::string &path);
+      inodeno_t ino, std::string_view path);
 
   bool is_dentry_damaged(
       const CDir *dir_frag,
-      const std::string &dname,
+      std::string_view dname,
       const snapid_t snap_id) const;
 
   bool is_dirfrag_damaged(
index 9cec722cceb9e6e930cdb49c91293563a3bab845..9737798b0bc0a65ba19d9a889461df68f7c5ae29 100644 (file)
@@ -225,7 +225,7 @@ void FSMap::print_summary(Formatter *f, ostream *out) const
 }
 
 
-void FSMap::create_filesystem(const std::string &name,
+void FSMap::create_filesystem(std::string_view name,
                               int64_t metadata_pool, int64_t data_pool,
                               uint64_t features)
 {
@@ -642,15 +642,16 @@ void Filesystem::decode(bufferlist::iterator& p)
 }
 
 int FSMap::parse_filesystem(
-      std::string const &ns_str,
+      std::string_view ns_str,
       std::shared_ptr<const Filesystem> *result
       ) const
 {
   std::string ns_err;
-  fs_cluster_id_t fscid = strict_strtol(ns_str.c_str(), 10, &ns_err);
+  std::string s(ns_str);
+  fs_cluster_id_t fscid = strict_strtol(s.c_str(), 10, &ns_err);
   if (!ns_err.empty() || filesystems.count(fscid) == 0) {
     for (auto &fs : filesystems) {
-      if (fs.second->mds_map.fs_name == ns_str) {
+      if (fs.second->mds_map.fs_name == s) {
         *result = std::const_pointer_cast<const Filesystem>(fs.second);
         return 0;
       }
@@ -669,7 +670,7 @@ void Filesystem::print(std::ostream &out) const
   mds_map.print(out);
 }
 
-mds_gid_t FSMap::find_standby_for(mds_role_t role, const std::string& name) const
+mds_gid_t FSMap::find_standby_for(mds_role_t role, std::string_view name) const
 {
   mds_gid_t result = MDS_GID_NONE;
 
@@ -744,7 +745,7 @@ mds_gid_t FSMap::find_unused_for(mds_role_t role,
   return MDS_GID_NONE;
 }
 
-mds_gid_t FSMap::find_replacement_for(mds_role_t role, const std::string& name,
+mds_gid_t FSMap::find_replacement_for(mds_role_t role, std::string_view name,
                                bool force_standby_active) const {
   const mds_gid_t standby = find_standby_for(role, name);
   if (standby)
@@ -994,7 +995,7 @@ std::list<mds_gid_t> FSMap::stop(mds_gid_t who)
  * if legacy_client_ns is set.
  */
 int FSMap::parse_role(
-    const std::string &role_str,
+    std::string_view role_str,
     mds_role_t *role,
     std::ostream &ss) const
 {
@@ -1018,7 +1019,7 @@ int FSMap::parse_role(
 
   mds_rank_t rank;
   std::string err;
-  std::string rank_str = role_str.substr(rank_pos);
+  std::string rank_str(role_str.substr(rank_pos));
   long rank_i = strict_strtol(rank_str.c_str(), 10, &err);
   if (rank_i < 0 || !err.empty()) {
     ss << "Invalid rank '" << rank_str << "'";
index 388abd4b1c171a386c7032962ca051d140abd7c7..4e123367194b58072ba6d1fd8f8cddb3f7288c22 100644 (file)
 #ifndef CEPH_FSMAP_H
 #define CEPH_FSMAP_H
 
+#include <map>
+#include <set>
+#include <string>
+#include <string_view>
+
 #include <errno.h>
 
 #include "include/types.h"
 #include "msg/Message.h"
 #include "mds/MDSMap.h"
 
-#include <set>
-#include <map>
-#include <string>
-
 #include "common/config.h"
 
 #include "include/CompatSet.h"
@@ -199,7 +200,7 @@ public:
   /**
    * Resolve daemon name to GID
    */
-  mds_gid_t find_mds_gid_by_name(const std::string& s) const
+  mds_gid_t find_mds_gid_by_name(std::string_view s) const
   {
     const auto info = get_mds_info();
     for (const auto &p : info) {
@@ -213,7 +214,7 @@ public:
   /**
    * Resolve daemon name to status
    */
-  const MDSMap::mds_info_t* find_by_name(const std::string& name) const
+  const MDSMap::mds_info_t* find_by_name(std::string_view name) const
   {
     std::map<mds_gid_t, MDSMap::mds_info_t> result;
     for (const auto &i : standby_daemons) {
@@ -304,7 +305,7 @@ public:
    * Caller must already have validated all arguments vs. the existing
    * FSMap and OSDMap contents.
    */
-  void create_filesystem(const std::string &name,
+  void create_filesystem(std::string_view name,
                          int64_t metadata_pool, int64_t data_pool,
                          uint64_t features);
 
@@ -419,7 +420,7 @@ public:
   bool filesystem_exists(fs_cluster_id_t fscid) const {return filesystems.count(fscid) > 0;}
   std::shared_ptr<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const {return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));}
   std::shared_ptr<const Filesystem> get_filesystem(void) const {return std::const_pointer_cast<const Filesystem>(filesystems.begin()->second);}
-  std::shared_ptr<const Filesystem> get_filesystem(const std::string &name) const
+  std::shared_ptr<const Filesystem> get_filesystem(std::string_view name) const
   {
     for (const auto &i : filesystems) {
       if (i.second->mds_map.fs_name == name) {
@@ -438,12 +439,12 @@ public:
     }
 
   int parse_filesystem(
-      std::string const &ns_str,
+      std::string_view ns_str,
       std::shared_ptr<const Filesystem> *result
       ) const;
 
   int parse_role(
-      const std::string &role_str,
+      std::string_view role_str,
       mds_role_t *role,
       std::ostream &ss) const;
 
@@ -460,11 +461,11 @@ public:
     return false;
   }
 
-  mds_gid_t find_standby_for(mds_role_t mds, const std::string& name) const;
+  mds_gid_t find_standby_for(mds_role_t mds, std::string_view name) const;
 
   mds_gid_t find_unused_for(mds_role_t mds, bool force_standby_active) const;
 
-  mds_gid_t find_replacement_for(mds_role_t mds, const std::string& name,
+  mds_gid_t find_replacement_for(mds_role_t mds, std::string_view name,
                                  bool force_standby_active) const;
 
   void get_health(list<pair<health_status_t,std::string> >& summary,
index cfc6687d348f4d61721e69b3414b73e3e7f0dc54..2ae0792ffd01683adc2fba86c5d172b80293de4b 100644 (file)
 #ifndef CEPH_FSMAPCOMPACT_H
 #define CEPH_FSMAPCOMPACT_H
 
-#include "mds/mdstypes.h"
 #include <map>
 #include <string>
+#include <string_view>
+
+#include "mds/mdstypes.h"
 
 class FSMapUser {
 public:
@@ -37,7 +39,7 @@ public:
 
   epoch_t get_epoch() const { return epoch; }
 
-  fs_cluster_id_t get_fs_cid(const std::string &name) const {
+  fs_cluster_id_t get_fs_cid(std::string_view name) const {
     for (auto &p : filesystems) {
       if (p.second.name == name)
        return p.first;
index a79305335cd11b11f6bdc92823918a418e9e5e6d..3d9fa6c3a56a0033b538049718d23e8b880612bb 100644 (file)
@@ -12,6 +12,7 @@
  * 
  */
 
+#include <string_view>
 
 #include "MDSRank.h"
 #include "MDCache.h"
@@ -2966,7 +2967,7 @@ public:
 };
 
 void Locker::process_request_cap_release(MDRequestRef& mdr, client_t client, const ceph_mds_request_release& item,
-                                        const string &dname)
+                                        std::string_view dname)
 {
   inodeno_t ino = (uint64_t)item.ino;
   uint64_t cap_id = item.cap_id;
index b878451712864c5e95b51ca5a171e26daf6d63a1..1c0d3888e0869dfd1cf663e85ac7ab5d30307c08 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_LOCKER_H
 #define CEPH_MDS_LOCKER_H
 
+#include <string_view>
+
 #include "include/types.h"
 
 #include <map>
@@ -177,7 +179,7 @@ public:
   bool should_defer_client_cap_frozen(CInode *in);
 
   void process_request_cap_release(MDRequestRef& mdr, client_t client, const ceph_mds_request_release& r,
-                                  const string &dname);
+                                  std::string_view dname);
 
   void kick_cap_releases(MDRequestRef& mdr);
   void kick_issue_caps(CInode *in, client_t client, ceph_seq_t seq);
index 3aaea4eb85b404ef1e77abd83d1e50e548a75d9d..19e090490668073a3dce0d27cbaa9e5212fae2cb 100644 (file)
@@ -95,34 +95,34 @@ std::string LogEvent::get_type_str() const
   }
 }
 
+const std::map<std::string, LogEvent::EventType> LogEvent::types = {
+  {"SUBTREEMAP", EVENT_SUBTREEMAP},
+  {"SUBTREEMAP_TEST", EVENT_SUBTREEMAP_TEST},
+  {"EXPORT", EVENT_EXPORT},
+  {"IMPORTSTART", EVENT_IMPORTSTART},
+  {"IMPORTFINISH", EVENT_IMPORTFINISH},
+  {"FRAGMENT", EVENT_FRAGMENT},
+  {"RESETJOURNAL", EVENT_RESETJOURNAL},
+  {"SESSION", EVENT_SESSION},
+  {"SESSIONS_OLD", EVENT_SESSIONS_OLD},
+  {"SESSIONS", EVENT_SESSIONS},
+  {"UPDATE", EVENT_UPDATE},
+  {"SLAVEUPDATE", EVENT_SLAVEUPDATE},
+  {"OPEN", EVENT_OPEN},
+  {"COMMITTED", EVENT_COMMITTED},
+  {"TABLECLIENT", EVENT_TABLECLIENT},
+  {"TABLESERVER", EVENT_TABLESERVER},
+  {"NOOP", EVENT_NOOP}
+};
 
 /*
  * Resolve type string to type enum
  *
  * Return -1 if not found
  */
-LogEvent::EventType LogEvent::str_to_type(std::string const &str)
+LogEvent::EventType LogEvent::str_to_type(std::string_view str)
 {
-  std::map<std::string, EventType> types;
-  types["SUBTREEMAP"] = EVENT_SUBTREEMAP;
-  types["SUBTREEMAP_TEST"] = EVENT_SUBTREEMAP_TEST;
-  types["EXPORT"] = EVENT_EXPORT;
-  types["IMPORTSTART"] = EVENT_IMPORTSTART;
-  types["IMPORTFINISH"] = EVENT_IMPORTFINISH;
-  types["FRAGMENT"] = EVENT_FRAGMENT;
-  types["RESETJOURNAL"] = EVENT_RESETJOURNAL;
-  types["SESSION"] = EVENT_SESSION;
-  types["SESSIONS_OLD"] = EVENT_SESSIONS_OLD;
-  types["SESSIONS"] = EVENT_SESSIONS;
-  types["UPDATE"] = EVENT_UPDATE;
-  types["SLAVEUPDATE"] = EVENT_SLAVEUPDATE;
-  types["OPEN"] = EVENT_OPEN;
-  types["COMMITTED"] = EVENT_COMMITTED;
-  types["TABLECLIENT"] = EVENT_TABLECLIENT;
-  types["TABLESERVER"] = EVENT_TABLESERVER;
-  types["NOOP"] = EVENT_NOOP;
-
-  return types[str];
+  return LogEvent::types.at(std::string(str));
 }
 
 
index 5e6e918c5cf4cd98f2c303b7c0bbecf06ec5a5f0..681a957e506254514e738376cd6024bbbe8be084 100644 (file)
@@ -73,7 +73,7 @@ public:
   virtual ~LogEvent() { }
 
   string get_type_str() const;
-  static EventType str_to_type(std::string const &str);
+  static EventType str_to_type(std::string_view str);
   EventType get_type() const { return _type; }
   void set_type(EventType t) { _type = t; }
 
@@ -117,6 +117,9 @@ public:
    * tools can examine metablobs while traversing lists of LogEvent.
    */
   virtual EMetaBlob *get_metablob() { return NULL; }
+
+private:
+  static const std::map<std::string, LogEvent::EventType> types;
 };
 
 inline ostream& operator<<(ostream& out, const LogEvent &le) {
index ab2ae7b4fed4c2be9ddee6af157f03a1b5516390..2b119046e162a08ae2cf3a97e7dc132ef2fd5518 100644 (file)
@@ -17,6 +17,7 @@
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <string_view>
 #include <map>
 
 #include "MDCache.h"
@@ -1602,7 +1603,7 @@ void MDCache::journal_cow_dentry(MutationImpl *mut, EMetaBlob *metablob,
        snapid_t oldfirst = dn->first;
        dn->first = dir_follows+1;
        if (realm->has_snaps_in_range(oldfirst, dir_follows)) {
-         CDentry *olddn = dn->dir->add_remote_dentry(dn->name, in->ino(),  in->d_type(),
+         CDentry *olddn = dn->dir->add_remote_dentry(dn->get_name(), in->ino(),  in->d_type(),
                                                      oldfirst, dir_follows);
          olddn->pre_dirty();
          dout(10) << " olddn " << *olddn << dendl;
@@ -1668,7 +1669,7 @@ void MDCache::journal_cow_dentry(MutationImpl *mut, EMetaBlob *metablob,
       mut->add_cow_inode(oldin);
       if (pcow_inode)
        *pcow_inode = oldin;
-      CDentry *olddn = dn->dir->add_primary_dentry(dn->name, oldin, oldfirst, follows);
+      CDentry *olddn = dn->dir->add_primary_dentry(dn->get_name(), oldin, oldfirst, follows);
       oldin->inode.version = olddn->pre_dirty();
       dout(10) << " olddn " << *olddn << dendl;
       bool need_snapflush = !oldin->client_snap_caps.empty();
@@ -1680,7 +1681,7 @@ void MDCache::journal_cow_dentry(MutationImpl *mut, EMetaBlob *metablob,
       mut->add_cow_dentry(olddn);
     } else {
       assert(dnl->is_remote());
-      CDentry *olddn = dn->dir->add_remote_dentry(dn->name, dnl->get_remote_ino(), dnl->get_remote_d_type(),
+      CDentry *olddn = dn->dir->add_remote_dentry(dn->get_name(), dnl->get_remote_ino(), dnl->get_remote_d_type(),
                                                  oldfirst, follows);
       olddn->pre_dirty();
       dout(10) << " olddn " << *olddn << dendl;
@@ -4182,7 +4183,7 @@ void MDCache::rejoin_walk(CDir *dir, MMDSCacheRejoin *rejoin)
       assert(dnl->is_primary());
       CInode *in = dnl->get_inode();
       assert(dnl->get_inode()->is_dir());
-      rejoin->add_weak_primary_dentry(dir->ino(), dn->name.c_str(), dn->first, dn->last, in->ino());
+      rejoin->add_weak_primary_dentry(dir->ino(), dn->get_name(), dn->first, dn->last, in->ino());
       in->get_nested_dirfrags(nested);
       if (in->is_dirty_scattered()) {
        dout(10) << " sending scatterlock state on " << *in << dendl;
@@ -4230,7 +4231,7 @@ void MDCache::rejoin_walk(CDir *dir, MMDSCacheRejoin *rejoin)
       }
 
       dout(15) << " add_strong_dentry " << *dn << dendl;
-      rejoin->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last,
+      rejoin->add_strong_dentry(dir->dirfrag(), dn->get_name(), dn->first, dn->last,
                                dnl->is_primary() ? dnl->get_inode()->ino():inodeno_t(0),
                                dnl->is_remote() ? dnl->get_remote_ino():inodeno_t(0),
                                dnl->is_remote() ? dnl->get_remote_d_type():0, 
@@ -4460,7 +4461,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
       unsigned dnonce = dn->add_replica(from);
       dout(10) << " have " << *dn << dendl;
       if (ack) 
-       ack->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last,
+       ack->add_strong_dentry(dir->dirfrag(), dn->get_name(), dn->first, dn->last,
                               dnl->get_inode()->ino(), inodeno_t(0), 0, 
                               dnonce, dn->lock.get_replica_state());
 
@@ -4594,7 +4595,7 @@ void MDCache::rejoin_scour_survivor_replicas(mds_rank_t from, MMDSCacheRejoin *a
        if (dn->is_replica(from) &&
            (ack == NULL ||
             ack->strong_dentries.count(dir->dirfrag()) == 0 ||
-            ack->strong_dentries[dir->dirfrag()].count(string_snap_t(dn->name, dn->last)) == 0)) {
+            ack->strong_dentries[dir->dirfrag()].count(string_snap_t(dn->get_name(), dn->last)) == 0)) {
          dentry_remove_replica(dn, from, gather_locks);
          dout(10) << " rem " << *dn << dendl;
        }
@@ -6054,7 +6055,7 @@ void MDCache::rejoin_send_acks()
          auto it = acks.find(r.first);
          if (it == acks.end())
            continue;
-         it->second->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last,
+         it->second->add_strong_dentry(dir->dirfrag(), dn->get_name(), dn->first, dn->last,
                                           dnl->is_primary() ? dnl->get_inode()->ino():inodeno_t(0),
                                           dnl->is_remote() ? dnl->get_remote_ino():inodeno_t(0),
                                           dnl->is_remote() ? dnl->get_remote_d_type():0,
@@ -6750,7 +6751,7 @@ bool MDCache::trim_dentry(CDentry *dn, map<mds_rank_t, MCacheExpire*>& expiremap
       assert(a != mds->get_nodeid());
       if (expiremap.count(a) == 0) 
        expiremap[a] = new MCacheExpire(mds->get_nodeid());
-      expiremap[a]->add_dentry(con->dirfrag(), dir->dirfrag(), dn->name, dn->last, dn->get_replica_nonce());
+      expiremap[a]->add_dentry(con->dirfrag(), dir->dirfrag(), dn->get_name(), dn->last, dn->get_replica_nonce());
     }
   }
 
@@ -8228,7 +8229,7 @@ CInode *MDCache::cache_traverse(const filepath& fp)
     return NULL;
 
   for (unsigned i = 0; i < fp.depth(); i++) {
-    const string& dname = fp[i];
+    std::string_view dname = fp[i];
     frag_t fg = in->pick_dirfrag(dname);
     dout(20) << " " << i << " " << dname << " frag " << fg << " from " << *in << dendl;
     CDir *curdir = in->get_dirfrag(fg);
@@ -8337,7 +8338,8 @@ void MDCache::_open_remote_dentry_finish(CDentry *dn, inodeno_t ino, MDSInternal
       CDir *dir = dn->get_dir();
       if (dir) {
        dir->get_inode()->make_path_string(path);
-       path =  path + "/" + dn->get_name();
+       path += "/";
+        path += dn->get_name();
       }
 
       bool fatal = mds->damage_table.notify_remote_damaged(ino, path);
@@ -8760,7 +8762,7 @@ void MDCache::handle_open_ino(MMDSOpenIno *m, int err)
        if (!pdn)
          break;
        CInode *diri = pdn->get_dir()->get_inode();
-       reply->ancestors.push_back(inode_backpointer_t(diri->ino(), pdn->name,
+       reply->ancestors.push_back(inode_backpointer_t(diri->ino(), pdn->get_name(),
                                                       in->inode.version));
        in = diri;
       }
@@ -10262,7 +10264,7 @@ void MDCache::replicate_dir(CDir *dir, mds_rank_t to, bufferlist& bl)
 
 void MDCache::replicate_dentry(CDentry *dn, mds_rank_t to, bufferlist& bl)
 {
-  encode(dn->name, bl);
+  encode(dn->get_name(), bl);
   encode(dn->last, bl);
   dn->encode_replica(to, bl, mds->get_state() < MDSMap::STATE_ACTIVE);
 }
@@ -10507,7 +10509,7 @@ void MDCache::send_dentry_link(CDentry *dn, MDRequestRef& mdr)
       continue;
     CDentry::linkage_t *dnl = dn->get_linkage();
     MDentryLink *m = new MDentryLink(subtree->dirfrag(), dn->get_dir()->dirfrag(),
-                                    dn->name, dnl->is_primary());
+                                    dn->get_name(), dnl->is_primary());
     if (dnl->is_primary()) {
       dout(10) << "  primary " << *dnl->get_inode() << dendl;
       replicate_inode(dnl->get_inode(), p.first, m->bl,
@@ -10593,7 +10595,7 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequestRef& md
         rejoin_gather.count(*it)))
       continue;
 
-    MDentryUnlink *unlink = new MDentryUnlink(dn->get_dir()->dirfrag(), dn->name);
+    MDentryUnlink *unlink = new MDentryUnlink(dn->get_dir()->dirfrag(), dn->get_name());
     if (straydn)
       replicate_stray(straydn, *it, unlink->straybl);
     mds->send_message_mds(unlink, *it);
@@ -11963,27 +11965,27 @@ int MDCache::cache_status(Formatter *f)
   return 0;
 }
 
-int MDCache::dump_cache(std::string const &file_name)
+int MDCache::dump_cache(std::string_view file_name)
 {
-  return dump_cache(file_name.c_str(), NULL);
+  return dump_cache(file_name, NULL);
 }
 
 int MDCache::dump_cache(Formatter *f)
 {
-  return dump_cache(NULL, f);
+  return dump_cache(std::string_view(""), f);
 }
 
-int MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
+int MDCache::dump_cache(std::string_view dump_root, int depth, Formatter *f)
 {
-  return dump_cache(NULL, f, dump_root, depth);
+  return dump_cache(std::string_view(""), f, dump_root, depth);
 }
 
 /**
  * Dump the metadata cache, either to a Formatter, if
  * provided, else to a plain text file.
  */
-int MDCache::dump_cache(const char *fn, Formatter *f,
-                        const string& dump_root, int depth)
+int MDCache::dump_cache(std::string_view fn, Formatter *f,
+                        std::string_view dump_root, int depth)
 {
   int r = 0;
   int fd = -1;
@@ -11991,17 +11993,18 @@ int MDCache::dump_cache(const char *fn, Formatter *f,
   if (f) {
     f->open_array_section("inodes");
   } else {
-    char deffn[200];
-    if (!fn) {
-      snprintf(deffn, sizeof(deffn), "cachedump.%d.mds%d", (int)mds->mdsmap->get_epoch(), int(mds->get_nodeid()));
-      fn = deffn;
+    char path[PATH_MAX] = "";
+    if (fn.length()) {
+      snprintf(path, sizeof path, "%s", fn.data());
+    } else {
+      snprintf(path, sizeof path, "cachedump.%d.mds%d", (int)mds->mdsmap->get_epoch(), int(mds->get_nodeid()));
     }
 
-    dout(1) << "dump_cache to " << fn << dendl;
+    dout(1) << "dump_cache to " << path << dendl;
 
-    fd = ::open(fn, O_WRONLY|O_CREAT|O_EXCL, 0600);
+    fd = ::open(path, O_WRONLY|O_CREAT|O_EXCL, 0600);
     if (fd < 0) {
-      derr << "failed to open " << fn << ": " << cpp_strerror(errno) << dendl;
+      derr << "failed to open " << path << ": " << cpp_strerror(errno) << dendl;
       return errno;
     }
   }
@@ -12154,14 +12157,14 @@ public:
 };
 
 void MDCache::enqueue_scrub(
-    const string& path,
-    const std::string &tag,
+    std::string_view path,
+    std::string_view tag,
     bool force, bool recursive, bool repair,
     Formatter *f, Context *fin)
 {
   dout(10) << __func__ << path << dendl;
   MDRequestRef mdr = request_start_internal(CEPH_MDS_OP_ENQUEUE_SCRUB);
-  filepath fp(path.c_str());
+  filepath fp(path);
   mdr->set_filepath(fp);
 
   C_MDS_EnqueueScrub *cs = new C_MDS_EnqueueScrub(f, fin);
@@ -12451,7 +12454,7 @@ do_rdlocks:
   mds->server->respond_to_request(mdr, 0);
 }
 
-void MDCache::flush_dentry(const string& path, Context *fin)
+void MDCache::flush_dentry(std::string_view path, Context *fin)
 {
   if (is_readonly()) {
     dout(10) << __func__ << ": read-only FS" << dendl;
@@ -12460,7 +12463,7 @@ void MDCache::flush_dentry(const string& path, Context *fin)
   }
   dout(10) << "flush_dentry " << path << dendl;
   MDRequestRef mdr = request_start_internal(CEPH_MDS_OP_FLUSH);
-  filepath fp(path.c_str());
+  filepath fp(path);
   mdr->set_filepath(fp);
   mdr->internal_op_finish = fin;
   flush_dentry_work(mdr);
index f05ecb6d3c37dff7ddcccf09396ca52704efa102..7107fb1a358b5781582daac0d9857ab749c230a8 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef CEPH_MDCACHE_H
 #define CEPH_MDCACHE_H
 
+#include <string_view>
+
 #include "include/types.h"
 #include "include/filepath.h"
 #include "include/elist.h"
@@ -805,7 +807,7 @@ public:
       return NULL;
     return in->get_dirfrag(df.frag);
   }
-  CDir* get_dirfrag(inodeno_t ino, const string& dn) {
+  CDir* get_dirfrag(inodeno_t ino, std::string_view dn) {
     CInode *in = get_inode(ino);
     if (!in)
       return NULL;
@@ -1170,14 +1172,14 @@ public:
   void discard_delayed_expire(CDir *dir);
 
 protected:
-  int dump_cache(const char *fn, Formatter *f,
-                 const std::string& dump_root = "",
+  int dump_cache(std::string_view fn, Formatter *f,
+                 std::string_view dump_root = "",
                  int depth = -1);
 public:
   int dump_cache() { return dump_cache(NULL, NULL); }
-  int dump_cache(const std::string &filename);
+  int dump_cache(std::string_view filename);
   int dump_cache(Formatter *f);
-  int dump_cache(const std::string& dump_root, int depth, Formatter *f);
+  int dump_cache(std::string_view dump_root, int depth, Formatter *f);
 
   int cache_status(Formatter *f);
 
@@ -1212,11 +1214,11 @@ protected:
   void repair_dirfrag_stats_work(MDRequestRef& mdr);
   friend class C_MDC_RepairDirfragStats;
 public:
-  void flush_dentry(const string& path, Context *fin);
+  void flush_dentry(std::string_view path, Context *fin);
   /**
    * Create and start an OP_ENQUEUE_SCRUB
    */
-  void enqueue_scrub(const string& path, const std::string &tag,
+  void enqueue_scrub(std::string_view path, std::string_view tag,
                      bool force, bool recursive, bool repair,
                     Formatter *f, Context *fin);
   void repair_inode_stats(CInode *diri);
index 9ecfbd9f510e1e838c1a3ad9f6fdba3582add2fe..aeb86d8851d90c3a664f9d7478c0145cd04e4da7 100644 (file)
@@ -12,6 +12,7 @@
  * 
  */
 
+#include <string_view>
 
 #include <errno.h>
 #include <fcntl.h>
@@ -110,7 +111,7 @@ void MDSCapMatch::normalize_path()
   // drop ..
 }
 
-bool MDSCapMatch::match(const std::string &target_path,
+bool MDSCapMatch::match(std::string_view target_path,
                        const int caller_uid,
                        const int caller_gid,
                        const vector<uint64_t> *caller_gid_list) const
@@ -142,7 +143,7 @@ bool MDSCapMatch::match(const std::string &target_path,
   return true;
 }
 
-bool MDSCapMatch::match_path(const std::string &target_path) const
+bool MDSCapMatch::match_path(std::string_view target_path) const
 {
   if (path.length()) {
     if (target_path.find(path) != 0)
@@ -162,7 +163,7 @@ bool MDSCapMatch::match_path(const std::string &target_path) const
  * Is the client *potentially* able to access this path?  Actual
  * permission will depend on uids/modes in the full is_capable.
  */
-bool MDSAuthCaps::path_capable(const std::string &inode_path) const
+bool MDSAuthCaps::path_capable(std::string_view inode_path) const
 {
   for (const auto &i : grants) {
     if (i.match.match_path(inode_path)) {
@@ -180,7 +181,7 @@ bool MDSAuthCaps::path_capable(const std::string &inode_path) const
  * This is true if any of the 'grant' clauses in the capability match the
  * requested path + op.
  */
-bool MDSAuthCaps::is_capable(const std::string &inode_path,
+bool MDSAuthCaps::is_capable(std::string_view inode_path,
                             uid_t inode_uid, gid_t inode_gid,
                             unsigned inode_mode,
                             uid_t caller_uid, gid_t caller_gid,
@@ -280,7 +281,7 @@ void MDSAuthCaps::set_allow_all()
                        MDSCapMatch()));
 }
 
-bool MDSAuthCaps::parse(CephContext *c, const std::string& str, ostream *err)
+bool MDSAuthCaps::parse(CephContext *c, std::string_view str, ostream *err)
 {
   // Special case for legacy caps
   if (str == "allow") {
@@ -289,9 +290,9 @@ bool MDSAuthCaps::parse(CephContext *c, const std::string& str, ostream *err)
     return true;
   }
 
-  MDSCapParser<std::string::const_iterator> g;
-  std::string::const_iterator iter = str.begin();
-  std::string::const_iterator end = str.end();
+  auto iter = str.begin();
+  auto end = str.end();
+  MDSCapParser<decltype(iter)> g;
 
   bool r = qi::phrase_parse(iter, end, g, ascii::space, *this);
   cct = c;  // set after parser self-assignment
index bb7d8f661034119999c5c462f17c732cee8eeb29..1e6cda68cc2b023d6f3228fd011256d6fd34f658 100644 (file)
 #ifndef MDS_AUTH_CAPS_H
 #define MDS_AUTH_CAPS_H
 
-#include <vector>
-#include <string>
 #include <sstream>
+#include <string>
+#include <string_view>
+#include <vector>
+
 #include "include/types.h"
 #include "common/debug.h"
 
@@ -91,7 +93,7 @@ struct MDSCapMatch {
   }
 
   // check whether this grant matches against a given file and caller uid:gid
-  bool match(const std::string &target_path,
+  bool match(std::string_view target_path,
             const int caller_uid,
             const int caller_gid,
             const vector<uint64_t> *caller_gid_list) const;
@@ -102,7 +104,7 @@ struct MDSCapMatch {
    *
    * @param target_path filesystem path without leading '/'
    */
-  bool match_path(const std::string &target_path) const;
+  bool match_path(std::string_view target_path) const;
 };
 
 struct MDSCapGrant {
@@ -128,14 +130,14 @@ public:
     : cct(NULL), grants(grants_) { }
 
   void set_allow_all();
-  bool parse(CephContext *cct, const std::string &str, std::ostream *err);
+  bool parse(CephContext *cct, std::string_view str, std::ostream *err);
 
   bool allow_all() const;
-  bool is_capable(const std::string &inode_path,
+  bool is_capable(std::string_view inode_path,
                  uid_t inode_uid, gid_t inode_gid, unsigned inode_mode,
                  uid_t uid, gid_t gid, const vector<uint64_t> *caller_gid_list,
                  unsigned mask, uid_t new_uid, gid_t new_gid) const;
-  bool path_capable(const std::string &inode_path) const;
+  bool path_capable(std::string_view inode_path) const;
 
   friend std::ostream &operator<<(std::ostream &out, const MDSAuthCaps &cap);
 };
index 04fcc3d7f0b38f60c3544db7dfa67c5298e90466..ca0dc8cfed8404a3fcebffdad4d1ea2520ab6cef 100644 (file)
@@ -69,7 +69,7 @@
 #define dout_prefix *_dout << "mds." << name << ' '
 
 // cons/des
-MDSDaemon::MDSDaemon(const std::string &n, Messenger *m, MonClient *mc) :
+MDSDaemon::MDSDaemon(std::string_view n, Messenger *m, MonClient *mc) :
   Dispatcher(m->cct),
   mds_lock("MDSDaemon::mds_lock"),
   stopping(false),
@@ -564,7 +564,7 @@ void MDSDaemon::tick()
 
 void MDSDaemon::send_command_reply(MCommand *m, MDSRank *mds_rank,
                                   int r, bufferlist outbl,
-                                  const std::string& outs)
+                                  std::string_view outs)
 {
   Session *session = static_cast<Session *>(m->get_connection()->get_priv());
   assert(session != NULL);
index 7eaf9755982cf0d8d08072eb15cd257deeb24a6c..29a273afadcda92ccaa36580cd0d0c6439a9f79d 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_H
 #define CEPH_MDS_H
 
+#include <string_view>
+
 #include "common/LogClient.h"
 #include "common/Mutex.h"
 #include "common/Timer.h"
@@ -63,7 +65,7 @@ class MDSDaemon : public Dispatcher, public md_config_obs_t {
   MDSRankDispatcher *mds_rank;
 
  public:
-  MDSDaemon(const std::string &n, Messenger *m, MonClient *mc);
+  MDSDaemon(std::string_view n, Messenger *m, MonClient *mc);
   ~MDSDaemon() override;
   int orig_argc;
   const char **orig_argv;
@@ -141,7 +143,7 @@ protected:
   // special message types
   friend class C_MDS_Send_Command_Reply;
   static void send_command_reply(MCommand *m, MDSRank* mds_rank, int r,
-                                bufferlist outbl, const std::string& outs);
+                                bufferlist outbl, std::string_view outs);
   int _handle_command(
       const cmdmap_t &cmdmap,
       MCommand *m,
index a6cd411f64d7df175609a167e3952926ca13562f..e46cbb05ad4a45baacf8e99a56acab930bd9f600 100644 (file)
 #ifndef CEPH_MDSMAP_H
 #define CEPH_MDSMAP_H
 
+#include <algorithm>
+#include <map>
+#include <set>
+#include <string>
+#include <string_view>
+
 #include <errno.h>
 
 #include "include/types.h"
 #include "msg/Message.h"
 #include "include/health.h"
 
-#include <set>
-#include <map>
-#include <string>
-#include <algorithm>
-
 #include "common/config.h"
 
 #include "include/CompatSet.h"
@@ -268,7 +269,7 @@ public:
   void set_flag(int f) { flags |= f; }
   void clear_flag(int f) { flags &= ~f; }
 
-  const std::string &get_fs_name() const {return fs_name;}
+  std::string_view get_fs_name() const {return fs_name;}
 
   void set_snaps_allowed() {
     set_flag(CEPH_MDSMAP_ALLOW_SNAPS);
@@ -349,7 +350,7 @@ public:
     assert(up.count(m) && mds_info.count(up.at(m)));
     return mds_info.at(up.at(m));
   }
-  mds_gid_t find_mds_gid_by_name(const std::string& s) const {
+  mds_gid_t find_mds_gid_by_name(std::string_view s) const {
     for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p) {
index b9af92eca3c0373a10fe1468b3b3b668b1ad7358..fc27554632988566e6679de20b9ad0e931473369 100644 (file)
@@ -12,6 +12,8 @@
  *
  */
 
+#include <string_view>
+
 #include "common/debug.h"
 #include "common/errno.h"
 
@@ -2002,7 +2004,7 @@ protected:
 public:
   C_MDS_Send_Command_Reply(MDSRank *_mds, MCommand *_m) :
     MDSInternalContext(_mds), m(_m) { m->get(); }
-  void send (int r, const std::string& out_str) {
+  void send (int r, std::string_view out_str) {
     bufferlist bl;
     MDSDaemon::send_command_reply(m, mds, r, bl, out_str);
     m->put();
@@ -2098,7 +2100,7 @@ void MDSRankDispatcher::dump_sessions(const SessionFilter &filter, Formatter *f)
   f->close_section(); //sessions
 }
 
-void MDSRank::command_scrub_path(Formatter *f, const string& path, vector<string>& scrubop_vec)
+void MDSRank::command_scrub_path(Formatter *f, std::string_view path, vector<string>& scrubop_vec)
 {
   bool force = false;
   bool recursive = false;
@@ -2121,7 +2123,7 @@ void MDSRank::command_scrub_path(Formatter *f, const string& path, vector<string
 }
 
 void MDSRank::command_tag_path(Formatter *f,
-    const string& path, const std::string &tag)
+    std::string_view path, std::string_view tag)
 {
   C_SaferCond scond;
   {
@@ -2131,7 +2133,7 @@ void MDSRank::command_tag_path(Formatter *f,
   scond.wait();
 }
 
-void MDSRank::command_flush_path(Formatter *f, const string& path)
+void MDSRank::command_flush_path(Formatter *f, std::string_view path)
 {
   C_SaferCond scond;
   {
@@ -2309,7 +2311,7 @@ void MDSRank::command_get_subtrees(Formatter *f)
 
 
 void MDSRank::command_export_dir(Formatter *f,
-    const std::string &path,
+    std::string_view path,
     mds_rank_t target)
 {
   int r = _command_export_dir(path, target);
@@ -2319,11 +2321,11 @@ void MDSRank::command_export_dir(Formatter *f,
 }
 
 int MDSRank::_command_export_dir(
-    const std::string &path,
+    std::string_view path,
     mds_rank_t target)
 {
   Mutex::Locker l(mds_lock);
-  filepath fp(path.c_str());
+  filepath fp(path);
 
   if (target == whoami || !mdsmap->is_up(target) || !mdsmap->is_in(target)) {
     derr << "bad MDS target " << target << dendl;
index 26c76fef8611de5f69f34d22d582241d75d65a6d..2f69c94924334532e76b35fbdd62dd6ec57594ef 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef MDS_RANK_H_
 #define MDS_RANK_H_
 
+#include <string_view>
+
 #include "common/DecayCounter.h"
 #include "common/LogClient.h"
 #include "common/Timer.h"
@@ -414,14 +416,14 @@ class MDSRank {
 
   protected:
     void dump_clientreplay_status(Formatter *f) const;
-    void command_scrub_path(Formatter *f, const string& path, vector<string>& scrubop_vec);
-    void command_tag_path(Formatter *f, const string& path,
-                          const string &tag);
-    void command_flush_path(Formatter *f, const string& path);
+    void command_scrub_path(Formatter *f, std::string_view path, vector<string>& scrubop_vec);
+    void command_tag_path(Formatter *f, std::string_view path,
+                          std::string_view tag);
+    void command_flush_path(Formatter *f, std::string_view path);
     void command_flush_journal(Formatter *f);
     void command_get_subtrees(Formatter *f);
     void command_export_dir(Formatter *f,
-        const std::string &path, mds_rank_t dest);
+        std::string_view path, mds_rank_t dest);
     bool command_dirfrag_split(
         cmdmap_t cmdmap,
         std::ostream &ss);
@@ -432,7 +434,7 @@ class MDSRank {
         cmdmap_t cmdmap,
         std::ostream &ss,
         Formatter *f);
-    int _command_export_dir(const std::string &path, mds_rank_t dest);
+    int _command_export_dir(std::string_view path, mds_rank_t dest);
     int _command_flush_journal(std::stringstream *ss);
     CDir *_command_dirfrag_get(
         const cmdmap_t &cmdmap,
index 18d1bc697e13020241019350d05179380a56f294..1be12108515ffa0691ee8a33daf8f653762b0aeb 100644 (file)
@@ -44,7 +44,7 @@ static int dout_wrapper(lua_State *L)
   return 0;
 }
 
-int Mantle::balance(const std::string &script,
+int Mantle::balance(std::string_view script,
                     mds_rank_t whoami,
                     const std::vector<std::map<std::string, double>> &metrics,
                     std::map<mds_rank_t, double> &my_targets)
@@ -52,7 +52,7 @@ int Mantle::balance(const std::string &script,
   lua_settop(L, 0); /* clear the stack */
 
   /* load the balancer */
-  if (luaL_loadstring(L, script.c_str())) {
+  if (luaL_loadstring(L, script.data())) {
     mantle_dout(0) << "WARNING: mantle could not load balancer: "
             << lua_tostring(L, -1) << mantle_dendl;
     return -EINVAL;
index 7970562846f7ae9b07ab9126c77de130d891304a..ffc1843a5e68fc92770299af8c74fdcd07a21fad 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MANTLE_H
 #define CEPH_MANTLE_H
 
+#include <string_view>
+
 #include <lua.hpp>
 #include <vector>
 #include <map>
@@ -26,7 +28,7 @@ class Mantle {
   public:
     Mantle();
     ~Mantle() { if (L) lua_close(L); }
-    int balance(const std::string &script,
+    int balance(std::string_view script,
                 mds_rank_t whoami,
                 const std::vector <std::map<std::string, double>> &metrics,
                 std::map<mds_rank_t,double> &my_targets);
index df83c171f58f7a471d13c1de68580fce9bfd8381..7851c3b1720b068b1ec80fc66da41f948b4a0506 100644 (file)
@@ -1607,7 +1607,7 @@ uint64_t Migrator::encode_export_dir(bufferlist& exportbl,
     dout(7) << "encode_export_dir exporting " << *dn << dendl;
     
     // dn name
-    encode(dn->name, exportbl);
+    encode(dn->get_name(), exportbl);
     encode(dn->last, exportbl);
     
     // state
index c22683d0280814fcbefa3a1fd053da9eb04584f0..753216199a1c1c335d353f365ac2254986197323 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef SCRUB_HEADER_H_
 #define SCRUB_HEADER_H_
 
+#include <string_view>
+
 class CInode;
 
 /**
@@ -24,7 +26,7 @@ class CInode;
  */
 class ScrubHeader {
 public:
-  ScrubHeader(const std::string &tag_, bool force_, bool recursive_,
+  ScrubHeader(std::string_view tag_, bool force_, bool recursive_,
               bool repair_, Formatter *f_)
       : tag(tag_), force(force_), recursive(recursive_), repair(repair_),
         formatter(f_), origin(nullptr)
@@ -40,7 +42,7 @@ public:
   bool get_repair() const { return repair; }
   bool get_force() const { return force; }
   const CInode *get_origin() const { return origin; }
-  const std::string &get_tag() const { return tag; }
+  std::string_view get_tag() const { return tag; }
   Formatter &get_formatter() const { return *formatter; }
 
   bool get_repaired() const { return repaired; }
index cb31a93f0fd64ed19cde4c194a3cd418323ac892..290c30a5d26d8f870f4c11546fdf369c74f7b93d 100644 (file)
@@ -390,7 +390,7 @@ void ScrubStack::_validate_inode_done(CInode *in, int r,
     if (parent) {
       auto dir = parent->get_dir();
       mdcache->mds->damage_table.notify_dentry(
-          dir->inode->ino(), dir->frag, parent->last, parent->name, path);
+          dir->inode->ino(), dir->frag, parent->last, parent->get_name(), path);
     }
   }
 
index 294cc243a43bee2c79d5decdb2e88d4e3975f925..460632fe910507ddd22860a38b273e3288eee3fe 100644 (file)
@@ -61,6 +61,7 @@
 
 #include <list>
 #include <iostream>
+#include <string_view>
 
 #include "common/config.h"
 
@@ -2470,7 +2471,7 @@ bool Server::check_fragment_space(MDRequestRef &mdr, CDir *in)
  * verify that the dir exists and would own the dname.
  * do not check if the dentry exists.
  */
-CDir *Server::validate_dentry_dir(MDRequestRef& mdr, CInode *diri, const string& dname)
+CDir *Server::validate_dentry_dir(MDRequestRef& mdr, CInode *diri, std::string_view dname)
 {
   // make sure parent is a dir?
   if (!diri->is_dir()) {
@@ -2500,7 +2501,7 @@ CDir *Server::validate_dentry_dir(MDRequestRef& mdr, CInode *diri, const string&
  * prepare a null (or existing) dentry in given dir. 
  * wait for any dn lock.
  */
-CDentry* Server::prepare_null_dentry(MDRequestRef& mdr, CDir *dir, const string& dname, bool okexist)
+CDentry* Server::prepare_null_dentry(MDRequestRef& mdr, CDir *dir, std::string_view dname, bool okexist)
 {
   dout(10) << "prepare_null_dentry " << dname << " in " << *dir << dendl;
   assert(dir->is_auth());
@@ -2896,7 +2897,7 @@ CDentry* Server::rdlock_path_xlock_dentry(MDRequestRef& mdr, int n,
   }
 
   // make a null dentry?
-  const string &dname = refpath.last_dentry();
+  std::string_view dname = refpath.last_dentry();
   CDentry *dn;
   if (mustexist) {
     dn = dir->lookup(dname);
@@ -3843,7 +3844,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
     }
     assert(in);
 
-    if ((int)(dnbl.length() + dn->name.length() + sizeof(__u32) + sizeof(LeaseStat)) > bytes_left) {
+    if ((int)(dnbl.length() + dn->get_name().length() + sizeof(__u32) + sizeof(LeaseStat)) > bytes_left) {
       dout(10) << " ran out of room, stopping at " << dnbl.length() << " < " << bytes_left << dendl;
       break;
     }
@@ -3852,7 +3853,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
 
     // dentry
     dout(12) << "including    dn " << *dn << dendl;
-    encode(dn->name, dnbl);
+    encode(dn->get_name(), dnbl);
     mds->locker->issue_client_lease(dn, client, dnbl, now, mdr->session);
 
     // inode
@@ -6198,7 +6199,7 @@ bool Server::_rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, vector<CD
                                               MMDSSlaveRequest::OP_RMDIRPREP);
   req->srcdnpath = filepath(trace.front()->get_dir()->ino());
   for (auto dn : trace)
-    req->srcdnpath.push_dentry(dn->name);
+    req->srcdnpath.push_dentry(dn->get_name());
   mdcache->replicate_stray(straydn, who, req->stray);
 
   req->op_stamp = mdr->get_op_stamp();
@@ -6260,9 +6261,9 @@ void Server::handle_slave_rmdir_prep(MDRequestRef& mdr)
   rmdir_rollback rollback;
   rollback.reqid = mdr->reqid;
   rollback.src_dir = dn->get_dir()->dirfrag();
-  rollback.src_dname = dn->name;
+  rollback.src_dname = dn->get_name();
   rollback.dest_dir = straydn->get_dir()->dirfrag();
-  rollback.dest_dname = straydn->name;
+  rollback.dest_dname = straydn->get_name();
   encode(rollback, mdr->more()->rollback_bl);
   dout(20) << " rollback is " << mdr->more()->rollback_bl.length() << " bytes" << dendl;
 
@@ -6602,7 +6603,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
     respond_to_request(mdr, -EINVAL);
     return;
   }
-  const string &destname = destpath.last_dentry();
+  std::string_view destname = destpath.last_dentry();
 
   vector<CDentry*>& srctrace = mdr->dn[1];
   vector<CDentry*>& desttrace = mdr->dn[0];
@@ -6707,7 +6708,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
   }
 
   // src == dest?
-  if (srcdn->get_dir() == destdir && srcdn->name == destname) {
+  if (srcdn->get_dir() == destdir && srcdn->get_name() == destname) {
     dout(7) << "rename src=dest, noop" << dendl;
     respond_to_request(mdr, 0);
     return;
@@ -7053,10 +7054,10 @@ bool Server::_rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set<mds_
 
   req->srcdnpath = filepath(srctrace.front()->get_dir()->ino());
   for (auto dn : srctrace)
-    req->srcdnpath.push_dentry(dn->name);
+    req->srcdnpath.push_dentry(dn->get_name());
   req->destdnpath = filepath(dsttrace.front()->get_dir()->ino());
   for (auto dn : dsttrace)
-    req->destdnpath.push_dentry(dn->name);
+    req->destdnpath.push_dentry(dn->get_name());
   if (straydn)
     mdcache->replicate_stray(straydn, who, req->stray);
 
@@ -7785,7 +7786,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
   rollback.orig_src.dirfrag = srcdn->get_dir()->dirfrag();
   rollback.orig_src.dirfrag_old_mtime = srcdn->get_dir()->get_projected_fnode()->fragstat.mtime;
   rollback.orig_src.dirfrag_old_rctime = srcdn->get_dir()->get_projected_fnode()->rstat.rctime;
-  rollback.orig_src.dname = srcdn->name;
+  rollback.orig_src.dname = srcdn->get_name();
   if (srcdnl->is_primary())
     rollback.orig_src.ino = srcdnl->get_inode()->ino();
   else {
@@ -7797,7 +7798,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
   rollback.orig_dest.dirfrag = destdn->get_dir()->dirfrag();
   rollback.orig_dest.dirfrag_old_mtime = destdn->get_dir()->get_projected_fnode()->fragstat.mtime;
   rollback.orig_dest.dirfrag_old_rctime = destdn->get_dir()->get_projected_fnode()->rstat.rctime;
-  rollback.orig_dest.dname = destdn->name;
+  rollback.orig_dest.dname = destdn->get_name();
   if (destdnl->is_primary())
     rollback.orig_dest.ino = destdnl->get_inode()->ino();
   else if (destdnl->is_remote()) {
@@ -7809,7 +7810,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
     rollback.stray.dirfrag = straydn->get_dir()->dirfrag();
     rollback.stray.dirfrag_old_mtime = straydn->get_dir()->get_projected_fnode()->fragstat.mtime;
     rollback.stray.dirfrag_old_rctime = straydn->get_dir()->get_projected_fnode()->rstat.rctime;
-    rollback.stray.dname = straydn->name;
+    rollback.stray.dname = straydn->get_name();
   }
   encode(rollback, mdr->more()->rollback_bl);
   dout(20) << " rollback is " << mdr->more()->rollback_bl.length() << " bytes" << dendl;
@@ -8601,7 +8602,7 @@ void Server::handle_client_mksnap(MDRequestRef& mdr)
     return;
   }
   
-  const string &snapname = req->get_filepath().last_dentry();
+  std::string_view snapname = req->get_filepath().last_dentry();
 
   if (mdr->client_request->get_caller_uid() < g_conf->mds_snap_min_uid || mdr->client_request->get_caller_uid() > g_conf->mds_snap_max_uid) {
     dout(20) << "mksnap " << snapname << " on " << *diri << " denied to uid " << mdr->client_request->get_caller_uid() << dendl;
@@ -8740,7 +8741,7 @@ void Server::handle_client_rmsnap(MDRequestRef& mdr)
     return;
   }
 
-  const string &snapname = req->get_filepath().last_dentry();
+  std::string_view snapname = req->get_filepath().last_dentry();
 
   if (mdr->client_request->get_caller_uid() < g_conf->mds_snap_min_uid || mdr->client_request->get_caller_uid() > g_conf->mds_snap_max_uid) {
     dout(20) << "rmsnap " << snapname << " on " << *diri << " denied to uid " << mdr->client_request->get_caller_uid() << dendl;
@@ -8878,8 +8879,8 @@ void Server::handle_client_renamesnap(MDRequestRef& mdr)
     return;
   }
 
-  const string &dstname = req->get_filepath().last_dentry();
-  const string &srcname = req->get_filepath2().last_dentry();
+  std::string_view dstname = req->get_filepath().last_dentry();
+  std::string_view srcname = req->get_filepath2().last_dentry();
   dout(10) << "renamesnap " << srcname << "->" << dstname << " on " << *diri << dendl;
 
   if (srcname.length() == 0 || srcname[0] == '_') {
index ade5d7ba09a82cd8effbffed4898fb3514da920e..925bac9898bba93a50e55028f2197339d602345d 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_SERVER_H
 #define CEPH_MDS_SERVER_H
 
+#include <string_view>
+
 #include "MDSRank.h"
 #include "Mutation.h"
 
@@ -166,9 +168,9 @@ public:
   bool check_fragment_space(MDRequestRef& mdr, CDir *in);
   bool check_access(MDRequestRef& mdr, CInode *in, unsigned mask);
   bool _check_access(Session *session, CInode *in, unsigned mask, int caller_uid, int caller_gid, int setattr_uid, int setattr_gid);
-  CDir *validate_dentry_dir(MDRequestRef& mdr, CInode *diri, const string& dname);
+  CDir *validate_dentry_dir(MDRequestRef& mdr, CInode *diri, std::string_view dname);
   CDir *traverse_to_auth_dir(MDRequestRef& mdr, vector<CDentry*> &trace, filepath refpath);
-  CDentry *prepare_null_dentry(MDRequestRef& mdr, CDir *dir, const string& dname, bool okexist=false);
+  CDentry *prepare_null_dentry(MDRequestRef& mdr, CDir *dir, std::string_view dname, bool okexist=false);
   CDentry *prepare_stray_dentry(MDRequestRef& mdr, CInode *in);
   CInode* prepare_new_inode(MDRequestRef& mdr, CDir *dir, inodeno_t useino, unsigned mode,
                            file_layout_t *layout=NULL);
index 93580d2399d03214704dc67122e20fa9e1558e23..dff223cf61171f87dc40d88cbe1f72edf54fa05b 100644 (file)
@@ -972,7 +972,7 @@ int SessionFilter::parse(
        * Strict boolean parser.  Allow true/false/0/1.
        * Anything else is -EINVAL.
        */
-      auto is_true = [](const std::string &bstr, bool *out) -> bool
+      auto is_true = [](std::string_view bstr, bool *out) -> bool
       {
         assert(out != nullptr);
 
index 486bd22daaefb47f5f97a2e3f5bdec1458047179..4cda3956ab5b87433d799b816deba84e35c6860a 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_SNAPCLIENT_H
 #define CEPH_SNAPCLIENT_H
 
+#include <string_view>
+
 #include "MDSTableClient.h"
 #include "snap.h"
 
@@ -29,7 +31,7 @@ public:
   void resend_queries() override {}
   void handle_query_result(MMDSTableRequest *m) override {}
 
-  void prepare_create(inodeno_t dirino, const string& name, utime_t stamp,
+  void prepare_create(inodeno_t dirino, std::string_view name, utime_t stamp,
                      version_t *pstid, bufferlist *pbl, MDSInternalContextBase *onfinish) {
     bufferlist bl;
     __u32 op = TABLE_OP_CREATE;
@@ -57,7 +59,7 @@ public:
     _prepare(bl, pstid, pbl, onfinish);
   }
 
-  void prepare_update(inodeno_t ino, snapid_t snapid, const string& name, utime_t stamp,
+  void prepare_update(inodeno_t ino, snapid_t snapid, std::string_view name, utime_t stamp,
                      version_t *pstid, MDSInternalContextBase *onfinish) {
     bufferlist bl;
     __u32 op = TABLE_OP_UPDATE;
index 438373a4cba45e2cd78b1deffa1b46bba9dfff47..4307fdd78bff673a7e81d37a73297cb250313e93 100644 (file)
@@ -16,6 +16,8 @@
 #include "MDCache.h"
 #include "MDSRank.h"
 
+#include <string_view>
+
 #include "messages/MClientSnap.h"
 
 
@@ -338,7 +340,7 @@ void SnapRealm::get_snap_info(map<snapid_t,SnapInfo*>& infomap, snapid_t first,
     parent->get_snap_info(infomap, std::max(first, srnode.current_parent_since), last);
 }
 
-const string& SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
+std::string_view SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
 {
   auto srnode_snaps_entry = srnode.snaps.find(snapid);
   if (srnode_snaps_entry != srnode.snaps.end()) {
@@ -361,7 +363,7 @@ const string& SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
   return parent->get_snapname(snapid, atino);
 }
 
-snapid_t SnapRealm::resolve_snapname(const string& n, inodeno_t atino, snapid_t first, snapid_t last)
+snapid_t SnapRealm::resolve_snapname(std::string_view n, inodeno_t atino, snapid_t first, snapid_t last)
 {
   // first try me
   dout(10) << "resolve_snapname '" << n << "' in [" << first << "," << last << "]" << dendl;
@@ -378,7 +380,7 @@ snapid_t SnapRealm::resolve_snapname(const string& n, inodeno_t atino, snapid_t
     int next_ = n.find('_', 1);
     if (next_ < 0) return 0;
     pname = n.substr(1, next_ - 1);
-    pino = atoll(n.c_str() + next_ + 1);
+    pino = atoll(n.data() + next_ + 1);
     dout(10) << " " << n << " parses to name '" << pname << "' dirino " << pino << dendl;
   }
 
index 4a99d639140a16d57e66e7d45ba94b5ebac958bf..c0723882996e7d0def54b1b0c47c590f643e460f 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_SNAPREALM_H
 #define CEPH_MDS_SNAPREALM_H
 
+#include <string_view>
+
 #include "mdstypes.h"
 #include "snap.h"
 #include "include/xlist.h"
@@ -63,7 +65,7 @@ public:
     inodes_with_caps(0) 
   { }
 
-  bool exists(const string &name) const {
+  bool exists(std::string_view name) const {
     for (map<snapid_t,SnapInfo>::const_iterator p = srnode.snaps.begin();
         p != srnode.snaps.end();
         ++p) {
@@ -94,8 +96,8 @@ public:
   const bufferlist& get_snap_trace();
   void build_snap_trace(bufferlist& snapbl) const;
 
-  const string& get_snapname(snapid_t snapid, inodeno_t atino);
-  snapid_t resolve_snapname(const string &name, inodeno_t atino, snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+  std::string_view get_snapname(snapid_t snapid, inodeno_t atino);
+  snapid_t resolve_snapname(std::string_view name, inodeno_t atino, snapid_t first=0, snapid_t last=CEPH_NOSNAP);
 
   const set<snapid_t>& get_snaps() const;
   const SnapContext& get_snap_context() const;
index 97a8a66b41384c472e7e2c124bf7fc22a94061e5..55db2db31ec4cc47d41bde73d8df2b18c193358a 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_EMETABLOB_H
 #define CEPH_MDS_EMETABLOB_H
 
+#include <string_view>
+
 #include <stdlib.h>
 
 #include "../CInode.h"
@@ -64,7 +66,7 @@ public:
     static const int STATE_DIRTYPOOL   = (1<<2);
     static const int STATE_NEED_SNAPFLUSH = (1<<3);
     typedef compact_map<snapid_t, old_inode_t> old_inodes_t;
-    string  dn;         // dentry
+    std::string  dn;         // dentry
     snapid_t dnfirst, dnlast;
     version_t dnv{0};
     inode_t inode;      // if it's not
@@ -79,7 +81,7 @@ public:
     fullbit(const fullbit& o);
     const fullbit& operator=(const fullbit& o);
 
-    fullbit(const string& d, snapid_t df, snapid_t dl, 
+    fullbit(std::string_view d, snapid_t df, snapid_t dl, 
            version_t v, const inode_t& i, const fragtree_t &dft, 
            const map<string,bufferptr> &xa, const string& sym,
            snapid_t os, const bufferlist &sbl, __u8 st,
@@ -137,14 +139,14 @@ public:
   /* remotebit - a dentry + remote inode link (i.e. just an ino)
    */
   struct remotebit {
-    string dn;
+    std::string dn;
     snapid_t dnfirst, dnlast;
     version_t dnv;
     inodeno_t ino;
     unsigned char d_type;
     bool dirty;
 
-    remotebit(const string& d, snapid_t df, snapid_t dl, version_t v, inodeno_t i, unsigned char dt, bool dr) : 
+    remotebit(std::string_view d, snapid_t df, snapid_t dl, version_t v, inodeno_t i, unsigned char dt, bool dr) : 
       dn(d), dnfirst(df), dnlast(dl), dnv(v), ino(i), d_type(dt), dirty(dr) { }
     explicit remotebit(bufferlist::iterator &p) { decode(p); }
     remotebit(): dnfirst(0), dnlast(0), dnv(0), ino(0),
@@ -166,12 +168,12 @@ public:
    * nullbit - a null dentry
    */
   struct nullbit {
-    string dn;
+    std::string dn;
     snapid_t dnfirst, dnlast;
     version_t dnv;
     bool dirty;
 
-    nullbit(const string& d, snapid_t df, snapid_t dl, version_t v, bool dr) : 
+    nullbit(std::string_view d, snapid_t df, snapid_t dl, version_t v, bool dr) :
       dn(d), dnfirst(df), dnlast(dl), dnv(v), dirty(dr) { }
     explicit nullbit(bufferlist::iterator &p) { decode(p); }
     nullbit(): dnfirst(0), dnlast(0), dnv(0), dirty(false) {}
index 08cbf65af9084c58c841dcc95b7fe74262717516..87b988f82821da03a06252dc155b0c7a3e400c38 100644 (file)
@@ -3,6 +3,8 @@
 #ifndef CEPH_INODE_BACKTRACE_H
 #define CEPH_INODE_BACKTRACE_H
 
+#include <string_view>
+
 #include "mdstypes.h"
 
 namespace ceph {
@@ -25,7 +27,7 @@ struct inode_backpointer_t {
   version_t version;   // child's version at time of backpointer creation
 
   inode_backpointer_t() : version(0) {}
-  inode_backpointer_t(inodeno_t i, const string &d, version_t v) : dirino(i), dname(d), version(v) {}
+  inode_backpointer_t(inodeno_t i, std::string_view d, version_t v) : dirino(i), dname(d), version(v) {}
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator &bl);
index 5efb3fe3d6563c932380bd335c38fbc5f2921841..a0feaed3bec88bf7a67554dea9e291b236e27610 100644 (file)
@@ -984,21 +984,21 @@ void EMetaBlob::get_paths(
 
     for (list<ceph::shared_ptr<fullbit> >::const_iterator
         iter = fb_list.begin(); iter != fb_list.end(); ++iter) {
-      std::string const &dentry = (*iter)->dn;
-      children[dir_ino].push_back(dentry);
+      std::string_view dentry = (*iter)->dn;
+      children[dir_ino].emplace_back(dentry);
       ino_locations[(*iter)->inode.ino] = Location(dir_ino, dentry);
     }
 
     for (list<nullbit>::const_iterator
        iter = nb_list.begin(); iter != nb_list.end(); ++iter) {
-      std::string const &dentry = iter->dn;
-      children[dir_ino].push_back(dentry);
+      std::string_view dentry = iter->dn;
+      children[dir_ino].emplace_back(dentry);
     }
 
     for (list<remotebit>::const_iterator
        iter = rb_list.begin(); iter != rb_list.end(); ++iter) {
-      std::string const &dentry = iter->dn;
-      children[dir_ino].push_back(dentry);
+      std::string_view dentry = iter->dn;
+      children[dir_ino].emplace_back(dentry);
     }
   }
 
@@ -1015,7 +1015,7 @@ void EMetaBlob::get_paths(
     list<ceph::shared_ptr<fullbit> > const &fb_list = dl.get_dfull();
     for (list<ceph::shared_ptr<fullbit> >::const_iterator
         iter = fb_list.begin(); iter != fb_list.end(); ++iter) {
-      std::string const &dentry = (*iter)->dn;
+      std::string_view dentry = (*iter)->dn;
       if (children.find((*iter)->inode.ino) == children.end()) {
         leaf_locations.push_back(Location(dir_ino, dentry));
       }
@@ -1024,14 +1024,14 @@ void EMetaBlob::get_paths(
     list<nullbit> const &nb_list = dl.get_dnull();
     for (list<nullbit>::const_iterator
        iter = nb_list.begin(); iter != nb_list.end(); ++iter) {
-      std::string const &dentry = iter->dn;
+      std::string_view dentry = iter->dn;
       leaf_locations.push_back(Location(dir_ino, dentry));
     }
 
     list<remotebit> const &rb_list = dl.get_dremote();
     for (list<remotebit>::const_iterator
        iter = rb_list.begin(); iter != rb_list.end(); ++iter) {
-      std::string const &dentry = iter->dn;
+      std::string_view dentry = iter->dn;
       leaf_locations.push_back(Location(dir_ino, dentry));
     }
   }
index 36bca15d7a35562584f0761eb1ca2deaaac343ba..380cea18f4296a13fa88c5c5666012cb95c9947f 100644 (file)
@@ -9,6 +9,7 @@
 #include <ostream>
 #include <set>
 #include <map>
+#include <string_view>
 
 #include "common/config.h"
 #include "common/Clock.h"
@@ -723,13 +724,13 @@ WRITE_CLASS_ENCODER_FEATURES(session_info_t)
 
 struct dentry_key_t {
   snapid_t snapid = 0;
-  const char *name = nullptr;
+  std::string_view name;
   __u32 hash = 0;
   dentry_key_t() {}
-  dentry_key_t(snapid_t s, const char *n, __u32 h=0) :
+  dentry_key_t(snapid_t s, std::string_view n, __u32 h=0) :
     snapid(s), name(n), hash(h) {}
 
-  bool is_valid() { return name || snapid; }
+  bool is_valid() { return name.length() || snapid; }
 
   // encode into something that can be decoded as a string.
   // name_ (head) or name_%x (!head)
@@ -756,19 +757,20 @@ struct dentry_key_t {
     decode(key, bl);
     decode_helper(key, nm, sn);
   }
-  static void decode_helper(const string& key, string& nm, snapid_t& sn) {
+  static void decode_helper(std::string_view key, string& nm, snapid_t& sn) {
     size_t i = key.find_last_of('_');
     assert(i != string::npos);
-    if (key.compare(i+1, string::npos, "head") == 0) {
+    if (key.compare(i+1, std::string_view::npos, "head") == 0) {
       // name_head
       sn = CEPH_NOSNAP;
     } else {
       // name_%x
       long long unsigned x = 0;
-      sscanf(key.c_str() + i + 1, "%llx", &x);
+      std::string x_str(key.substr(i+1));
+      sscanf(x_str.c_str(), "%llx", &x);
       sn = x;
     }  
-    nm = string(key.c_str(), i);
+    nm = key.substr(0, i);
   }
 };
 
@@ -785,7 +787,7 @@ inline bool operator<(const dentry_key_t& k1, const dentry_key_t& k2)
   int c = ceph_frag_value(k1.hash) - ceph_frag_value(k2.hash);
   if (c)
     return c < 0;
-  c = strcmp(k1.name, k2.name);
+  c = k1.name.compare(k2.name);
   if (c)
     return c < 0;
   return k1.snapid < k2.snapid;
@@ -799,7 +801,7 @@ struct string_snap_t {
   string name;
   snapid_t snapid;
   string_snap_t() {}
-  string_snap_t(const string& n, snapid_t s) : name(n), snapid(s) {}
+  string_snap_t(std::string_view n, snapid_t s) : name(n), snapid(s) {}
   string_snap_t(const char *n, snapid_t s) : name(n), snapid(s) {}
 
   void encode(bufferlist& bl) const;
@@ -810,7 +812,7 @@ struct string_snap_t {
 WRITE_CLASS_ENCODER(string_snap_t)
 
 inline bool operator<(const string_snap_t& l, const string_snap_t& r) {
-  int c = strcmp(l.name.c_str(), r.name.c_str());
+  int c = l.name.compare(r.name);
   return c < 0 || (c == 0 && l.snapid < r.snapid);
 }
 
@@ -901,7 +903,7 @@ struct cap_reconnect_t {
     memset(&capinfo, 0, sizeof(capinfo));
     snap_follows = 0;
   }
-  cap_reconnect_t(uint64_t cap_id, inodeno_t pino, const string& p, int w, int i,
+  cap_reconnect_t(uint64_t cap_id, inodeno_t pino, std::string_view p, int w, int i,
                  inodeno_t sr, snapid_t sf, bufferlist& lb) :
     path(p) {
     capinfo.cap_id = cap_id;
index 1d8106b0321966641c584f39e6b9642dbabe3ce6..525bccf5b8592d08c8966d9e81894a90d212fbcd 100644 (file)
@@ -12,6 +12,8 @@
  * 
  */
 
+#include <string_view>
+
 #include "snap.h"
 
 #include "common/Formatter.h"
@@ -66,7 +68,7 @@ ostream& operator<<(ostream& out, const SnapInfo &sn)
             << "' " << sn.stamp << ")";
 }
 
-const string& SnapInfo::get_long_name()
+std::string_view SnapInfo::get_long_name()
 {
   if (long_name.length() == 0) {
     char nm[80];
index 4032520c605a86733453eab7a43e6b9e0f94b4e1..0c44c83cfc6bd53fa36f42a285e8926295b17a91 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MDS_SNAP_H
 #define CEPH_MDS_SNAP_H
 
+#include <string_view>
+
 #include "mdstypes.h"
 #include "common/snap_types.h"
 
@@ -34,7 +36,7 @@ struct SnapInfo {
   void dump(Formatter *f) const;
   static void generate_test_instances(list<SnapInfo*>& ls);
 
-  const string& get_long_name();
+  std::string_view get_long_name();
 };
 WRITE_CLASS_ENCODER(SnapInfo)
 
index 21acb5005bc03d2a1c9c16aa1c6f5f42af4513b5..d2b6ca579c8b5a6f42004e017b513229cef3430f 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MCACHEEXPIRE_H
 #define CEPH_MCACHEEXPIRE_H
 
+#include <string_view>
+
 #include "mds/mdstypes.h"
 
 class MCacheExpire : public Message {
@@ -78,7 +80,7 @@ public:
   void add_dir(dirfrag_t r, dirfrag_t df, unsigned nonce) {
     realms[r].dirs[df] = nonce;
   }
-  void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, unsigned nonce) {
+  void add_dentry(dirfrag_t r, dirfrag_t df, std::string_view dn, snapid_t last, unsigned nonce) {
     realms[r].dentries[df][pair<string,snapid_t>(dn,last)] = nonce;
   }
 
index ecbaa8ddd4414073ef16981f2031c6d0f1e48889..15b95024c94158703a425bbc988131c187f06234 100644 (file)
 #ifndef CEPH_MCLIENTLEASE_H
 #define CEPH_MCLIENTLEASE_H
 
+#include <string_view>
+
 #include "msg/Message.h"
 
 struct MClientLease : public Message {
   struct ceph_mds_lease h;
-  string dname;
+  std::string dname;
   
   int get_action() const { return h.action; }
   ceph_seq_t get_seq() const { return h.seq; }
@@ -40,7 +42,7 @@ struct MClientLease : public Message {
     h.last = sl;
     h.duration_ms = 0;
   }
-  MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, const string& d) :
+  MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, std::string_view d) :
     Message(CEPH_MSG_CLIENT_LEASE),
     dname(d) {
     h.action = ac;
index 1baa12f068cfbe6ef7cdc2b266a80032ca486791..5732c5f08a056a5902c58c1d318af6822c1202e9 100644 (file)
@@ -33,6 +33,8 @@
  *  
  */
 
+#include <string_view>
+
 #include "msg/Message.h"
 #include "include/filepath.h"
 #include "mds/mdstypes.h"
@@ -137,7 +139,7 @@ public:
   void set_retry_attempt(int a) { head.num_retry = a; }
   void set_filepath(const filepath& fp) { path = fp; }
   void set_filepath2(const filepath& fp) { path2 = fp; }
-  void set_string2(const char *s) { path2.set_path(s, 0); }
+  void set_string2(const char *s) { path2.set_path(std::string_view(s), 0); }
   void set_caller_uid(unsigned u) { head.caller_uid = u; }
   void set_caller_gid(unsigned g) { head.caller_gid = g; }
   void set_gid_list(int count, const gid_t *gids) {
index 4af21e4da045d927249cdde49ae2bc364dbe46fa..63e45c8a356e93144c4802d01babeb94d5ed7f82 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MCOMMANDREPLY_H
 #define CEPH_MCOMMANDREPLY_H
 
+#include <string_view>
+
 #include "msg/Message.h"
 #include "MCommand.h"
 
@@ -29,7 +31,7 @@ class MCommandReply : public Message {
     : Message(MSG_COMMAND_REPLY), r(_r) {
     header.tid = m->get_tid();
   }
-  MCommandReply(int _r, string s)
+  MCommandReply(int _r, std::string_view s)
     : Message(MSG_COMMAND_REPLY),
       r(_r), rs(s) { }
 private:
index 0e1c16064796f67c6ecfdbea2aa0ffa6423f58d4..fe686d1daa7b3be385b81522b59e9c00682baea1 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef CEPH_MDENTRYLINK_H
 #define CEPH_MDENTRYLINK_H
 
+#include <string_view>
+
 class MDentryLink : public Message {
   dirfrag_t subtree;
   dirfrag_t dirfrag;
@@ -32,7 +34,7 @@ class MDentryLink : public Message {
 
   MDentryLink() :
     Message(MSG_MDS_DENTRYLINK) { }
-  MDentryLink(dirfrag_t r, dirfrag_t df, string& n, bool p) :
+  MDentryLink(dirfrag_t r, dirfrag_t df, std::string_view n, bool p) :
     Message(MSG_MDS_DENTRYLINK),
     subtree(r),
     dirfrag(df),
index 86f5f3d5f935412e31f1ce17f925dc873913eff5..c6f98369ce1bccc4d60cfa4f9dfb36479f45424d 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef CEPH_MDENTRYUNLINK_H
 #define CEPH_MDENTRYUNLINK_H
 
+#include <string_view>
+
 class MDentryUnlink : public Message {
   dirfrag_t dirfrag;
   string dn;
@@ -28,7 +30,7 @@ class MDentryUnlink : public Message {
 
   MDentryUnlink() :
     Message(MSG_MDS_DENTRYUNLINK) { }
-  MDentryUnlink(dirfrag_t df, string& n) :
+  MDentryUnlink(dirfrag_t df, std::string_view n) :
     Message(MSG_MDS_DENTRYUNLINK),
     dirfrag(df),
     dn(n) {}
index 6e064c2ddb32b24497abee930dc1504d43529406..54784ba81af664fc9b2631a71f62e834a10db722 100644 (file)
@@ -97,7 +97,7 @@ class MDiscoverReply : public Message {
 
   bool is_flag_error_dn() { return flag_error_dn; }
   bool is_flag_error_dir() { return flag_error_dir; }
-  std::string& get_error_dentry() { return error_dentry; }
+  const std::string& get_error_dentry() { return error_dentry; }
 
   int get_starts_with() { return starts_with; }
 
@@ -158,7 +158,7 @@ public:
   }
 
   //  void set_flag_forward() { flag_forward = true; }
-  void set_flag_error_dn(const std::string& dn) { 
+  void set_flag_error_dn(std::string_view dn) { 
     flag_error_dn = true; 
     error_dentry = dn; 
   }
@@ -168,7 +168,7 @@ public:
   void set_dir_auth_hint(int a) {
     dir_auth_hint = a;
   }
-  void set_error_dentry(const std::string& dn) {
+  void set_error_dentry(std::string_view dn) {
     error_dentry = dn;
   }
 
index 1d3bac8eb355b6de29b41bd7e7ec95827c3acd96..44a3eb9c63cb7975b3610dc7cab477e49187e507 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MMDSBEACON_H
 #define CEPH_MMDSBEACON_H
 
+#include <string_view>
+
 #include "messages/PaxosServiceMessage.h"
 
 #include "include/types.h"
@@ -138,7 +140,7 @@ struct MDSHealthMetric
   }
 
   MDSHealthMetric() : type(MDS_HEALTH_NULL), sev(HEALTH_OK) {}
-  MDSHealthMetric(mds_metric_t type_, health_status_t sev_, std::string const &message_)
+  MDSHealthMetric(mds_metric_t type_, health_status_t sev_, std::string_view message_)
     : type(type_), sev(sev_), message(message_) {}
 };
 WRITE_CLASS_ENCODER(MDSHealthMetric)
index b572be12069f78d99ae74cfe679710b0bfe29ef4..a3d12eca2231ddc7c3288d93cda0074a1e54451e 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef CEPH_MMDSCACHEREJOIN_H
 #define CEPH_MMDSCACHEREJOIN_H
 
+#include <string_view>
+
 #include "msg/Message.h"
 
 #include "include/types.h"
@@ -280,20 +282,20 @@ public:
   void add_weak_dirfrag(dirfrag_t df) {
     weak_dirfrags.insert(df);
   }
-  void add_weak_dentry(inodeno_t dirino, const string& dname, snapid_t last, dn_weak& dnw) {
+  void add_weak_dentry(inodeno_t dirino, std::string_view dname, snapid_t last, dn_weak& dnw) {
     weak[dirino][string_snap_t(dname, last)] = dnw;
   }
-  void add_weak_primary_dentry(inodeno_t dirino, const string& dname, snapid_t first, snapid_t last, inodeno_t ino) {
+  void add_weak_primary_dentry(inodeno_t dirino, std::string_view dname, snapid_t first, snapid_t last, inodeno_t ino) {
     weak[dirino][string_snap_t(dname, last)] = dn_weak(first, ino);
   }
-  void add_strong_dentry(dirfrag_t df, const string& dname, snapid_t first, snapid_t last, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
+  void add_strong_dentry(dirfrag_t df, std::string_view dname, snapid_t first, snapid_t last, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
     strong_dentries[df][string_snap_t(dname, last)] = dn_strong(first, pi, ri, rdt, n, ls);
   }
-  void add_dentry_authpin(dirfrag_t df, const string& dname, snapid_t last,
+  void add_dentry_authpin(dirfrag_t df, std::string_view dname, snapid_t last,
                          const metareqid_t& ri, __u32 attempt) {
     authpinned_dentries[df][string_snap_t(dname, last)].push_back(slave_reqid(ri, attempt));
   }
-  void add_dentry_xlock(dirfrag_t df, const string& dname, snapid_t last,
+  void add_dentry_xlock(dirfrag_t df, std::string_view dname, snapid_t last,
                        const metareqid_t& ri, __u32 attempt) {
     xlocked_dentries[df][string_snap_t(dname, last)] = slave_reqid(ri, attempt);
   }
index 4c9aec30537135287ec6678fec1b2cbfd5736aa0..f2ef0de0b6f32ef756baead7ed03ea12caefc4af 100644 (file)
@@ -55,9 +55,9 @@ void PyFormatter::dump_float(const char *name, double d)
   dump_pyobject(name, PyFloat_FromDouble(d));
 }
 
-void PyFormatter::dump_string(const char *name, const std::string& s)
+void PyFormatter::dump_string(const char *name, std::string_view s)
 {
-  dump_pyobject(name, PyString_FromString(s.c_str()));
+  dump_pyobject(name, PyString_FromString(s.data()));
 }
 
 void PyFormatter::dump_bool(const char *name, bool b)
index e74f2fe7c49e0768dcb247e5ef827a62b0416cb8..8b44916a047584daf18ec9bf9e06b7180c114f0a 100644 (file)
@@ -85,7 +85,7 @@ public:
   void dump_unsigned(const char *name, uint64_t u) override;
   void dump_int(const char *name, int64_t u) override;
   void dump_float(const char *name, double d) override;
-  void dump_string(const char *name, const std::string& s) override;
+  void dump_string(const char *name, std::string_view s) override;
   std::ostream& dump_stream(const char *name) override;
   void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
 
index 96c709789af46edebb8631f44b48521f98c52ae4..0803a614ff85eccd68f66b0253f0e062b20c6a02 100644 (file)
@@ -125,9 +125,9 @@ void RGWFormatter_Plain::dump_float(const char *name, double d)
   dump_value_int(name, "%f", d);
 }
 
-void RGWFormatter_Plain::dump_string(const char *name, const std::string& s)
+void RGWFormatter_Plain::dump_string(const char *name, std::string_view s)
 {
-  dump_format(name, "%s", s.c_str());
+  dump_format(name, "%s", s.data());
 }
 
 std::ostream& RGWFormatter_Plain::dump_stream(const char *name)
index a50965873836fe07a255a7d1a4d888f3159758ac..81cc5478d0627edffd9db1e5586aa08301529e63 100644 (file)
@@ -41,7 +41,7 @@ public:
   void dump_unsigned(const char *name, uint64_t u) override;
   void dump_int(const char *name, int64_t u) override;
   void dump_float(const char *name, double d) override;
-  void dump_string(const char *name, const std::string& s) override;
+  void dump_string(const char *name, std::string_view s) override;
   std::ostream& dump_stream(const char *name) override;
   void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap) override;
   int get_len() const override;