]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix SnapRealm::resolve_snapname for long name 27849/head
authorYan, Zheng <zyan@redhat.com>
Thu, 11 Apr 2019 08:42:35 +0000 (16:42 +0800)
committerVicente Cheng <freeze.bilsted@gmail.com>
Mon, 29 Apr 2019 06:36:20 +0000 (06:36 +0000)
Fixes: https://tracker.ceph.com/issues/38832
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 7c6ec030cd9dece9e89347cdbf83514376eb29da)

src/mds/SnapRealm.cc

index 242d8fc7bb091947b05432d7c09ee755815b36b4..ee906a3a48d357da423491c1bc2b5dcb3c3c2dc4 100644 (file)
@@ -454,15 +454,12 @@ snapid_t SnapRealm::resolve_snapname(std::string_view n, inodeno_t atino, snapid
   // first try me
   dout(10) << "resolve_snapname '" << n << "' in [" << first << "," << last << "]" << dendl;
 
-  //snapid_t num;
-  //if (n[0] == '~') num = atoll(n.c_str()+1);
-
   bool actual = (atino == inode->ino());
   string pname;
   inodeno_t pino;
   if (n.length() && n[0] == '_') {
-    int next_ = n.find('_', 1);
-    if (next_ > 1) {
+    size_t next_ = n.find_last_of('_');
+    if (next_ > 1 && next_ + 1 < n.length()) {
       pname = n.substr(1, next_ - 1);
       pino = atoll(n.data() + next_ + 1);
       dout(10) << " " << n << " parses to name '" << pname << "' dirino " << pino << dendl;