]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: snaptable -> snapserver+snapclient
authorSage Weil <sage@newdream.net>
Wed, 16 Jul 2008 22:41:11 +0000 (15:41 -0700)
committerSage Weil <sage@newdream.net>
Wed, 16 Jul 2008 22:41:11 +0000 (15:41 -0700)
19 files changed:
src/Makefile.am
src/mds/Anchor.h
src/mds/AnchorClient.cc
src/mds/AnchorServer.cc
src/mds/MDCache.cc
src/mds/MDS.cc
src/mds/MDS.h
src/mds/MDSTableClient.h
src/mds/MDSTableServer.cc
src/mds/Server.cc
src/mds/SnapClient.h
src/mds/SnapServer.cc [new file with mode: 0644]
src/mds/SnapServer.h [new file with mode: 0644]
src/mds/SnapTable.cc [deleted file]
src/mds/SnapTable.h [deleted file]
src/mds/journal.cc
src/mds/mds_table_types.h
src/mds/snap.cc
src/mds/snap.h

index d504fea2d41c29e478f87a1e2e153b7db6590d9e..110a203eadb7d3f038da7977c9caf5dff66d6c32 100644 (file)
@@ -208,7 +208,7 @@ libmds_a_SOURCES = \
        mds/MDSTableServer.cc \
        mds/AnchorServer.cc \
        mds/AnchorClient.cc \
-       mds/SnapTable.cc \
+       mds/SnapServer.cc \
        mds/snap.cc \
        mds/SessionMap.cc \
        mds/MDLog.cc
index 214ac3bf94ad880529a199a9d19c4866bc1d917e..b07ee6ffa7280ca123db5ba98568186045c4255d 100644 (file)
@@ -22,21 +22,6 @@ using std::string;
 #include "mdstypes.h"
 #include "include/buffer.h"
 
-enum {
-  ANCHOR_OP_CREATE,
-  ANCHOR_OP_DESTROY,
-  ANCHOR_OP_UPDATE,
-};
-
-inline const char* get_anchor_opname(int o) {
-  switch (o) {
-  case ANCHOR_OP_CREATE: return "create";
-  case ANCHOR_OP_DESTROY: return "destroy";
-  case ANCHOR_OP_UPDATE: return "update";
-  default: assert(0); return 0;
-  }
-}
-
 
 // identifies a anchor table mutation
 
index 830074d095feefaf4ed430de915e25a1c56d5bc3..a90fae826809ffe20e272d189ba0eb9d8ce98e4c 100644 (file)
  * 
  */
 
-#include <iostream>
-using std::cout;
-using std::cerr;
-
 #include "AnchorClient.h"
 #include "MDSMap.h"
 #include "LogSegment.h"
@@ -91,7 +87,7 @@ void AnchorClient::prepare_create(inodeno_t ino, vector<Anchor>& trace,
 {
   dout(10) << "prepare_create " << ino << " " << trace << dendl;
   bufferlist bl;
-  __u32 op = ANCHOR_OP_CREATE;
+  __u32 op = TABLE_OP_CREATE;
   ::encode(op, bl);
   ::encode(ino, bl);
   ::encode(trace, bl);
@@ -103,7 +99,7 @@ void AnchorClient::prepare_destroy(inodeno_t ino,
 {
   dout(10) << "prepare_destroy " << ino << dendl;
   bufferlist bl;
-  __u32 op = ANCHOR_OP_DESTROY;
+  __u32 op = TABLE_OP_DESTROY;
   ::encode(op, bl);
   ::encode(ino, bl);
   _prepare(bl, patid, onfinish);
@@ -115,7 +111,7 @@ void AnchorClient::prepare_update(inodeno_t ino, vector<Anchor>& trace,
 {
   dout(10) << "prepare_update " << ino << " " << trace << dendl;
   bufferlist bl;
-  __u32 op = ANCHOR_OP_UPDATE;
+  __u32 op = TABLE_OP_UPDATE;
   ::encode(op, bl);
   ::encode(ino, bl);
   _prepare(bl, patid, onfinish);
index 8e37fe2530375f4bc065301cd427cc8f635e8053..5f0dd13fed898e61ed8af0597fe7e38014927b56 100644 (file)
@@ -127,7 +127,7 @@ void AnchorServer::_prepare(bufferlist &bl, __u64 reqid, int bymds)
   ::decode(trace, p);
 
   switch (what) {
-  case ANCHOR_OP_CREATE:
+  case TABLE_OP_CREATE:
     version++;
 
     // make sure trace is in table
@@ -138,12 +138,12 @@ void AnchorServer::_prepare(bufferlist &bl, __u64 reqid, int bymds)
     break;
 
 
-  case ANCHOR_OP_DESTROY:
+  case TABLE_OP_DESTROY:
     version++;
     pending_destroy[version] = ino;
     break;
     
-  case ANCHOR_OP_UPDATE:
+  case TABLE_OP_UPDATE:
     version++;
     pending_update[version].first = ino;
     pending_update[version].second = trace;
@@ -232,8 +232,6 @@ void AnchorServer::_rollback(version_t tid)
   else
     assert(0);
 
-  pending_for_mds.erase(tid);
-
   // bump version.
   version++;
   //dump();
index 9ee21fdbac55d4555bc6ba5fea66349fe718b111..0a3558f283b66ccf031a3a81ca14dd1b9eb041a6 100644 (file)
@@ -4271,7 +4271,7 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req,     // who
     }
     if (snapid == CEPH_SNAPDIR) {
       SnapRealm *realm = cur->find_snaprealm();
-      snapid = realm->resolve_snapname(path[depth]);
+      snapid = realm->resolve_snapname(path[depth], cur->ino());
       dout(10) << "traverse: snap " << path[depth] << " -> " << snapid << dendl;
       if (!snapid)
        return -ENOENT;
index e619f9df9bad8c3b2116b646225eaed247c10af6..d2e84138032db4a45a7aa6c3c145fcc1ece9f3b4 100644 (file)
 
 #include "AnchorServer.h"
 #include "AnchorClient.h"
+#include "SnapServer.h"
+#include "SnapClient.h"
 
 #include "InoTable.h"
-#include "SnapTable.h"
 
 #include "common/Logger.h"
 #include "common/LogType.h"
@@ -91,8 +92,8 @@ MDS::MDS(int whoami, Messenger *m, MonMap *mm) :
   balancer = new MDBalancer(this);
 
   inotable = new InoTable(this);
-  snaptable = new SnapTable(this);
-
+  snapserver = new SnapServer(this);
+  snapclient = new SnapClient(this);
   anchorserver = new AnchorServer(this);
   anchorclient = new AnchorClient(this);
 
@@ -128,7 +129,8 @@ MDS::~MDS() {
   if (balancer) { delete balancer; balancer = NULL; }
   if (inotable) { delete inotable; inotable = NULL; }
   if (anchorserver) { delete anchorserver; anchorserver = NULL; }
-  if (snaptable) { delete snaptable; snaptable = NULL; }
+  if (snapserver) { delete snapserver; snapserver = NULL; }
+  if (snapclient) { delete snapclient; snapclient = NULL; }
   if (anchorclient) { delete anchorclient; anchorclient = NULL; }
   if (osdmap) { delete osdmap; osdmap = 0; }
   if (mdsmap) { delete mdsmap; mdsmap = 0; }
@@ -244,7 +246,7 @@ MDSTableClient *MDS::get_table_client(int t)
 {
   switch (t) {
   case TABLE_ANCHOR: return anchorclient;
-    //case TABLE_SNAP: return snapserver;
+  case TABLE_SNAP: return snapclient;
   default: assert(0);
   }
 }
@@ -253,7 +255,7 @@ MDSTableServer *MDS::get_table_server(int t)
 {
   switch (t) {
   case TABLE_ANCHOR: return anchorserver;
-    //case TABLE_SNAP: return snapserver;
+  case TABLE_SNAP: return snapserver;
   default: assert(0);
   }
 }
@@ -778,8 +780,8 @@ void MDS::boot_create()
 
   if (whoami == 0) {
     dout(10) << "boot_create creating fresh snaptable" << dendl;
-    snaptable->reset();
-    snaptable->save(fin->new_sub());
+    snapserver->reset();
+    snapserver->save(fin->new_sub());
   }
 }
 
@@ -825,7 +827,7 @@ void MDS::boot_start(int step, int r)
       }
       if (whoami == 0) {
        dout(2) << "boot_start " << step << ": opening snap table" << dendl;    
-       snaptable->load(gather->new_sub());
+       snapserver->load(gather->new_sub());
       }
       
       dout(2) << "boot_start " << step << ": opening mds log" << dendl;
index a5bbc1ac0b6b7ab56fa00a5cfd79df182c4f43b8..ed71152a57fbf67a32618da3bb51e7541759f5e4 100644 (file)
@@ -73,13 +73,14 @@ class MHashReaddirReply;
 class MMDSBeacon;
 
 class InoTable;
-class SnapTable;
-
-class MDSTableClient;
-class MDSTableServer;
+class SnapServer;
+class SnapClient;
 class AnchorServer;
 class AnchorClient;
 
+class MDSTableServer;
+class MDSTableClient;
+
 class MDS : public Dispatcher {
  public:
   Mutex        mds_lock;
@@ -109,7 +110,8 @@ class MDS : public Dispatcher {
   AnchorServer *anchorserver;
   AnchorClient *anchorclient;
 
-  SnapTable    *snaptable;
+  SnapServer   *snapserver;
+  SnapClient   *snapclient;
 
   MDSTableClient *get_table_client(int t);
   MDSTableServer *get_table_server(int t);
index 18fd464ee41a2ee067bc852378f6e0159c75cbc3..bb3c7f549c7cc62ca89dcb27b5e2774241d35331 100644 (file)
@@ -12,8 +12,8 @@
  * 
  */
 
-#ifndef __SNAPCLIENT_H
-#define __SNAPCLIENT_H
+#ifndef __MDSTABLECLIENT_H
+#define __MDSTABLECLIENT_H
 
 #include <vector>
 using std::vector;
index af0be983c515cf459391f6cc724e0830cbc7c6ad..ed39405b5ad090c222014e70e2ed46640cb8687f 100644 (file)
@@ -72,6 +72,7 @@ void MDSTableServer::handle_commit(MMDSTableRequest *req)
 
   if (_is_prepared(tid)) {
     _commit(tid);
+    pending_for_mds.erase(tid);
     mds->mdlog->submit_entry(new ETableServer(table, TABLE_OP_COMMIT, 0, -1, tid, version));
     mds->mdlog->wait_for_sync(new C_Commit(this, req));
   }
index b096096f4e42e0feedf552fb4ab69fa55887ace7..68e1588a71ed9b597c269700fee5b42bc4b1599a 100644 (file)
@@ -21,7 +21,7 @@
 #include "MDBalancer.h"
 #include "AnchorClient.h"
 #include "InoTable.h"
-#include "SnapTable.h"
+#include "SnapClient.h"
 
 #include "msg/Messenger.h"
 
@@ -643,7 +643,7 @@ void Server::set_trace_dist(Session *session, MClientReply *reply, CInode *in, C
 
   if (snapid != CEPH_NOSNAP && in == snapdiri) {
     // do the snap name dentry
-    const string& snapname = in->find_snaprealm()->get_snapname(snapid);
+    const string& snapname = in->find_snaprealm()->get_snapname(snapid, in->ino());
     dout(10) << " snapname " << snapname << dendl;
     ::encode(snapname, bl);
     encode_empty_lease(bl);
@@ -4894,10 +4894,16 @@ void Server::handle_client_mksnap(MDRequest *mdr)
     mdr->now = g_clock.now();
 
   // allocate a snapid
-  // HACK
-  version_t stid;
-  snapid_t snapid = mds->snaptable->create(diri->ino(), snapname, mdr->now, &stid);
-  dout(10) << " snapid is " << snapid << " stid " << &stid << dendl;
+  if (!mdr->more()->stid) {
+    // prepare an stid
+    mds->snapclient->prepare_create(diri->ino(), snapname, mdr->now, 
+                                   &mdr->more()->stid, new C_MDS_RetryRequest(mds->mdcache, mdr));
+    return;
+  }
+
+  version_t stid = mdr->more()->stid;
+  snapid_t snapid = stid;
+  dout(10) << " snapid/stid is " << snapid << dendl;
 
   // journal
   SnapInfo info;
@@ -4927,6 +4933,8 @@ void Server::_mksnap_finish(MDRequest *mdr, CInode *diri, SnapInfo &info)
   diri->pop_and_dirty_projected_inode(mdr->ls);
   mdr->apply();
 
+  mds->snapclient->commit(mdr->more()->stid, mdr->ls);
+
   snapid_t snapid = info.snapid;
 
   // create realm?
index 5c7a1b0574db1ba63bffde173a6a66e83aea500c..afaa33b7c1cca68de9499f17439751163e3066ba 100644 (file)
 #ifndef __SNAPCLIENT_H
 #define __SNAPCLIENT_H
 
-#include <vector>
-using std::vector;
-#include <ext/hash_map>
-using __gnu_cxx::hash_map;
-
-#include "include/types.h"
-#include "msg/Dispatcher.h"
-
+#include "MDSTableClient.h"
 #include "snap.h"
 
 class Context;
 class MDS;
 class LogSegment;
 
-class MDSTableClient : public Dispatcher {
-  MDS *mds;
-
-  // prepares
-  struct _pending_prepare {
-    Context *onfinish;
-    version_t *patid;
-    bufferlist mutation;
-  };
-
-  hash_map<metareqid_t, _pending_prepare> pending_prepare;
-
-  // pending commits
-  map<version_t, LogSegment*> pending_commit;
-  map<version_t, list<Context*> > ack_waiters;
-
-  void handle_reply(class MAnchor *m);  
-
-
+class SnapClient : public MDSTableClient {
+public:
+  SnapClient(MDS *m) : MDSTableClient(m, TABLE_SNAP) {}
+
+  void resend_queries() {}
+  void handle_query_result(MMDSTableRequest *m) {}
+
+  void prepare_create(inodeno_t dirino, const string& name, utime_t stamp,
+                     version_t *pstid, Context *onfinish) {
+    bufferlist bl;
+    __u32 op = TABLE_OP_CREATE;
+    ::encode(op, bl);
+    ::encode(dirino, bl);
+    ::encode(name, bl);
+    ::encode(stamp, bl);
+    _prepare(bl, pstid, onfinish);
+  }
 };
 
 #endif
diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc
new file mode 100644 (file)
index 0000000..c238ee5
--- /dev/null
@@ -0,0 +1,176 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#include "SnapServer.h"
+#include "MDS.h"
+
+#include "include/types.h"
+#include "messages/MMDSTableRequest.h"
+
+#include "config.h"
+
+#define dout(x)  if (x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << mds->get_nodeid() << ".snap: "
+
+void SnapServer::init_inode()
+{
+  ino = MDS_INO_SNAPTABLE;
+  layout = g_default_file_layout;
+}
+
+void SnapServer::reset_state()
+{
+  last_snap = 0;
+  snaps.clear();
+  pending_removal.clear();
+}
+
+snapid_t SnapServer::create(inodeno_t base, const string& name, utime_t stamp, version_t *psnapv)
+{
+  assert(is_active());
+  
+  snapid_t sn = ++last_snap;
+  snaps[sn].snapid = sn;
+  snaps[sn].dirino = base;
+  snaps[sn].name = name;
+  snaps[sn].stamp = stamp;
+  *psnapv = ++version;
+
+  dout(10) << "create(" << base << "," << name << ") = " << sn << dendl;
+
+  return sn;
+}
+
+void SnapServer::remove(snapid_t sn) 
+{
+  assert(is_active());
+
+  snaps.erase(sn);
+  pending_removal.insert(sn);
+  version++;
+}
+
+
+// SERVER
+
+void SnapServer::_prepare(bufferlist &bl, __u64 reqid, int bymds)
+{
+  bufferlist::iterator p = bl.begin();
+  __u32 what;
+  ::decode(what, p);
+
+  switch (what) {
+  case TABLE_OP_CREATE:
+    {
+      SnapInfo info;
+      ::decode(info.dirino, p);
+      ::decode(info.name, p);
+      ::decode(info.stamp, p);
+      info.snapid = ++version;
+      pending_create[version] = info;
+    }
+    break;
+
+  case TABLE_OP_DESTROY:
+    {
+      snapid_t snapid;
+      ::decode(snapid, p);
+      version++;
+      pending_destroy[version] = snapid;
+    }
+    break;
+    
+  default:
+    assert(0);
+  }
+  //dump();
+}
+
+bool SnapServer::_is_prepared(version_t tid)
+{
+  return 
+    pending_create.count(tid) ||
+    pending_destroy.count(tid);
+}
+
+void SnapServer::_commit(version_t tid)
+{
+  if (pending_create.count(tid)) {
+    dout(7) << "commit " << tid << " create " << pending_create[tid] << dendl;
+    snaps[pending_create[tid].snapid] = pending_create[tid];
+    pending_create.erase(tid);
+  } 
+
+  else if (pending_destroy.count(tid)) {
+    dout(7) << "commit " << tid << " destroy " << pending_destroy[tid] << dendl;
+    snaps.erase(pending_destroy[tid]);
+    pending_destroy.erase(tid);
+  }
+  else
+    assert(0);
+
+  // bump version.
+  version++;
+  //dump();
+}
+
+void SnapServer::_rollback(version_t tid) 
+{
+  if (pending_create.count(tid)) {
+    dout(7) << "rollback " << tid << " create " << pending_create[tid] << dendl;
+    pending_create.erase(tid);
+  } 
+
+  else if (pending_destroy.count(tid)) {
+    dout(7) << "rollback " << tid << " destroy " << pending_destroy[tid] << dendl;
+    pending_destroy.erase(tid);
+  }
+
+  else
+    assert(0);
+
+  // bump version.
+  version++;
+  //dump();
+}
+
+void SnapServer::handle_query(MMDSTableRequest *req)
+{
+  /*  bufferlist::iterator p = req->bl.begin();
+  inodeno_t curino;
+  ::decode(curino, p);
+  dout(7) << "handle_lookup " << *req << " ino " << curino << dendl;
+
+  vector<Anchor> trace;
+  while (true) {
+    assert(anchor_map.count(curino) == 1);
+    Anchor &anchor = anchor_map[curino];
+    
+    dout(10) << "handle_lookup  adding " << anchor << dendl;
+    trace.insert(trace.begin(), anchor);  // lame FIXME
+    
+    if (anchor.dirino < MDS_INO_BASE) break;
+    curino = anchor.dirino;
+  }
+
+  // reply
+  MMDSTableRequest *reply = new MMDSTableRequest(table, TABLE_OP_QUERY_REPLY, req->reqid, version);
+  ::encode(curino, req->bl);
+  ::encode(trace, req->bl);
+  mds->send_message_mds(reply, req->get_source().num());
+
+  */
+  delete req;
+}
+
+
diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h
new file mode 100644 (file)
index 0000000..2c349d7
--- /dev/null
@@ -0,0 +1,68 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#ifndef __SNAPSERVER_H
+#define __SNAPSERVER_H
+
+#include "MDSTableServer.h"
+#include "snap.h"
+
+class MDS;
+
+class SnapServer : public MDSTableServer {
+public:
+  
+protected:
+  snapid_t last_snap;
+  map<snapid_t, SnapInfo> snaps;
+  set<snapid_t> pending_removal;
+  
+  map<version_t, SnapInfo> pending_create;
+  map<version_t, snapid_t> pending_destroy;
+
+public:
+  SnapServer(MDS *m) : MDSTableServer(m, TABLE_SNAP) { }
+  
+  // alloc or reclaim ids
+  snapid_t create(inodeno_t base, const string& name, utime_t stamp, version_t *snapv);
+  void remove(snapid_t sn);
+  
+  void init_inode();
+  void reset_state();
+  void encode_state(bufferlist& bl) {
+    ::encode(last_snap, bl);
+    ::encode(snaps, bl);
+    ::encode(pending_removal, bl);
+    ::encode(pending_create, bl);
+    ::encode(pending_destroy, bl);
+    ::encode(pending_for_mds, bl);
+  }
+  void decode_state(bufferlist::iterator& bl) {
+    ::decode(last_snap, bl);
+    ::decode(snaps, bl);
+    ::decode(pending_removal, bl);
+    ::decode(pending_create, bl);
+    ::decode(pending_destroy, bl);
+    ::decode(pending_for_mds, bl);
+  }
+
+  // server bits
+  void _prepare(bufferlist &bl, __u64 reqid, int bymds);
+  bool _is_prepared(version_t tid);
+  void _commit(version_t tid);
+  void _rollback(version_t tid);
+  void handle_query(MMDSTableRequest *m);
+};
+
+#endif
diff --git a/src/mds/SnapTable.cc b/src/mds/SnapTable.cc
deleted file mode 100644 (file)
index 16b4ead..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include "SnapTable.h"
-#include "MDS.h"
-
-#include "include/types.h"
-
-#include "config.h"
-
-#define dout(x)  if (x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << mds->get_nodeid() << ".snap: "
-
-void SnapTable::init_inode()
-{
-  ino = MDS_INO_SNAPTABLE;
-  layout = g_default_file_layout;
-}
-
-void SnapTable::reset_state()
-{
-  last_snap = 0;
-  snaps.clear();
-  pending_removal.clear();
-}
-
-snapid_t SnapTable::create(inodeno_t base, const string& name, utime_t stamp, version_t *psnapv)
-{
-  assert(is_active());
-  
-  snapid_t sn = ++last_snap;
-  snaps[sn].snapid = sn;
-  snaps[sn].dirino = base;
-  snaps[sn].name = name;
-  snaps[sn].stamp = stamp;
-  *psnapv = ++version;
-
-  dout(10) << "create(" << base << "," << name << ") = " << sn << dendl;
-
-  return sn;
-}
-
-void SnapTable::remove(snapid_t sn) 
-{
-  assert(is_active());
-
-  snaps.erase(sn);
-  pending_removal.insert(sn);
-  version++;
-}
-
diff --git a/src/mds/SnapTable.h b/src/mds/SnapTable.h
deleted file mode 100644 (file)
index a4ee380..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-
-#ifndef __SNAPTABLE_H
-#define __SNAPTABLE_H
-
-#include "MDSTable.h"
-#include "include/interval_set.h"
-#include "snap.h"
-
-class MDS;
-
-class SnapTable : public MDSTable {
-public:
-  
-protected:
-  snapid_t last_snap;
-  map<snapid_t, SnapInfo> snaps;
-  set<snapid_t> pending_removal;
-
-public:
-  SnapTable(MDS *m) : MDSTable(m, "snap") { }
-  
-  // alloc or reclaim ids
-  snapid_t create(inodeno_t base, const string& name, utime_t stamp, version_t *snapv);
-  void remove(snapid_t sn);
-  
-  void init_inode();
-  void reset_state();
-  void encode_state(bufferlist& bl) {
-    ::encode(last_snap, bl);
-    ::encode(snaps, bl);
-    ::encode(pending_removal, bl);
-  }
-  void decode_state(bufferlist::iterator& bl) {
-    ::decode(last_snap, bl);
-    ::decode(snaps, bl);
-    ::decode(pending_removal, bl);
-  }
-};
-
-#endif
index 9a28b1e4a01d41bf0a47610c5cb30702a6b6ae5f..48f30bd3c79eafad1c581df48ff9103b37327968 100644 (file)
@@ -42,9 +42,8 @@
 #include "MDCache.h"
 #include "Server.h"
 #include "Migrator.h"
-#include "InoTable.h"
-#include "SnapTable.h"
 
+#include "InoTable.h"
 #include "MDSTableClient.h"
 #include "MDSTableServer.h"
 
index e01383149e017fc0604650b871b9a4a8ffa1cea6..6dcd7d63a1bb8509a7360eb3d65f584830dbd571 100644 (file)
@@ -40,6 +40,12 @@ enum {
   TABLE_OP_ROLLBACK     =  7,
 };
 
+enum {
+  TABLE_OP_CREATE,
+  TABLE_OP_UPDATE,
+  TABLE_OP_DESTROY,
+};
+
 inline const char *get_mdstable_opname(int op) {
   switch (op) {
   case TABLE_OP_QUERY: return "query";
index b0d1c93cabc5aacffe06e1779c086337b5f4ffb5..db4ed20d366197d57bab251641a11a220f635f34 100644 (file)
@@ -174,10 +174,10 @@ const string& SnapInfo::get_long_name()
   return long_name;
 }
 
-const string& SnapRealm::get_snapname(snapid_t snapid, bool actual)
+const string& SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
 {
   if (snaps.count(snapid)) {
-    if (actual)
+    if (atino == inode->ino())
       return snaps[snapid].name;
     else
       return snaps[snapid].get_long_name();
@@ -189,20 +189,21 @@ const string& SnapRealm::get_snapname(snapid_t snapid, bool actual)
     assert(oldparent);  // call open_parents first!
     assert(oldparent->snaprealm);
     
-    return oldparent->snaprealm->get_snapname(snapid, false);
+    return oldparent->snaprealm->get_snapname(snapid, atino);
   }
 
-  return parent->get_snapname(snapid, false);
+  return parent->get_snapname(snapid, atino);
 }
 
-snapid_t SnapRealm::resolve_snapname(const string& n, bool actual, snapid_t first, snapid_t last)
+snapid_t SnapRealm::resolve_snapname(const string& n, inodeno_t atino, snapid_t first, snapid_t last)
 {
   // first try me
   dout(10) << "resolve_snapname '" << n << "' in [" << first << "," << last << "]" << dendl;
 
-  snapid_t num;
-  if (n[0] == '~') num = atoll(n.c_str()+1);
+  //snapid_t num;
+  //if (n[0] == '~') num = atoll(n.c_str()+1);
 
+  bool actual = (atino == inode->ino());
   string pname;
   inodeno_t pdirino;
   if (!actual) {
@@ -212,14 +213,15 @@ snapid_t SnapRealm::resolve_snapname(const string& n, bool actual, snapid_t firs
     if (next_ < 0) return 0;
     pname = n.substr(1, next_ - 1);
     pdirino = atoll(n.c_str() + next_ + 1);
-    dout(10) << " " << n << " -> " << pname << " dirino " << pdirino << dendl;
+    dout(10) << " " << n << " parses to name '" << pname << "' dirino " << pdirino << dendl;
   }
 
   for (map<snapid_t, SnapInfo>::iterator p = snaps.lower_bound(first); // first element >= first
        p != snaps.end() && p->first <= last;
        p++) {
-    if (num && p->second.snapid == num)
-      return p->first;
+    dout(15) << " ? " << p->second << dendl;
+    //if (num && p->second.snapid == num)
+    //return p->first;
     if (actual && p->second.name == n)
        return p->first;
     if (!actual && p->second.name == pname && p->second.dirino == pdirino)
@@ -236,7 +238,7 @@ snapid_t SnapRealm::resolve_snapname(const string& n, bool actual, snapid_t firs
     assert(oldparent->snaprealm);
     
     thru = MIN(last, p->first);
-    snapid_t r = oldparent->snaprealm->resolve_snapname(n, false,
+    snapid_t r = oldparent->snaprealm->resolve_snapname(n, atino,
                                                        MAX(first, p->second.first),
                                                        thru);
     if (r)
@@ -244,7 +246,7 @@ snapid_t SnapRealm::resolve_snapname(const string& n, bool actual, snapid_t firs
     ++thru;
   }
   if (thru <= last && parent)
-    return parent->resolve_snapname(n, false, thru, last);
+    return parent->resolve_snapname(n, atino, thru, last);
   return 0;
 }
 
index f587cc9e43e1a307e332775c31b5836f773d5112..6db91c4a60b632300603ee161541529677d2ba53 100644 (file)
@@ -133,8 +133,8 @@ struct SnapRealm {
   void build_snap_set(set<snapid_t>& s, snapid_t first, snapid_t last);
   void get_snap_info(map<snapid_t,SnapInfo*>& infomap, snapid_t first=0, snapid_t last=CEPH_NOSNAP);
 
-  const string& get_snapname(snapid_t snapid, bool actual=true);
-  snapid_t resolve_snapname(const string &name, bool actual=true, snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+  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);
 
   const set<snapid_t>& get_snaps();
   const vector<snapid_t>& get_snap_vector();