Project

General

Profile

patch

Zheng Yan, 04/09/2013 06:00 AM

Download (5.45 KB)

 
1
diff --git a/src/mds/Capability.h b/src/mds/Capability.h
2
index 946afdc..54d2312 100644
3
--- a/src/mds/Capability.h
4
+++ b/src/mds/Capability.h
5
@@ -272,6 +272,7 @@ public:
6
   Export make_export() {
7
     return Export(_wanted, issued(), pending(), client_follows, mseq+1, last_issue_stamp);
8
   }
9
+  void rejoin_import() { mseq++; }
10
   void merge(Export& other) {
11
     // issued + pending
12
     int newpending = other.pending | pending();
13
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
14
index ad7a509..f84569a 100644
15
--- a/src/mds/MDCache.cc
16
+++ b/src/mds/MDCache.cc
17
@@ -4103,20 +4103,25 @@ bool MDCache::parallel_fetch_traverse_dir(inodeno_t ino, filepath& path,
18
     frag_t fg = cur->pick_dirfrag(path[i]);
19
     CDir *dir = cur->get_or_open_dirfrag(this, fg);
20
     CDentry *dn = dir->lookup(path[i]);
21
-    CDentry::linkage_t *dnl = dn->get_linkage();
22
-    if (!dn || dnl->is_null()) {
23
-      if (!dir->is_complete()) {
24
-	// fetch dir
25
-	fetch_queue.insert(dir);
26
-	return false;
27
-      } else {
28
+    CDentry::linkage_t *dnl = dn ? dn->get_linkage() : NULL;
29
+
30
+    if (!dnl || dnl->is_null()) {
31
+      if (!dir->is_auth()) {
32
+	dout(10) << " not dirfrag auth " << *dir << dendl;
33
+	return true;
34
+      }
35
+      if (dnl || dir->is_complete()) {
36
 	// probably because the client created it and held a cap but it never committed
37
 	// to the journal, and the op hasn't replayed yet.
38
 	dout(5) << " dne (not created yet?) " << ino << " at " << path << dendl;
39
 	missing.insert(ino);
40
 	return true;
41
       }
42
+      // fetch dir
43
+      fetch_queue.insert(dir);
44
+      return false;
45
     }
46
+
47
     cur = dnl->get_inode();
48
     if (!cur) {
49
       assert(dnl->is_remote());
50
@@ -5047,8 +5052,32 @@ void MDCache::rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconn
51
 
52
   Capability *cap = in->reconnect_cap(client, icr, session);
53
 
54
-  if (frommds >= 0)
55
+  if (frommds >= 0) {
56
+    cap->rejoin_import();
57
     do_cap_import(session, in, cap);
58
+  }
59
+}
60
+
61
+void MDCache::export_remaining_imported_caps()
62
+{
63
+  dout(10) << "export_remaining_imported_caps" << dendl;
64
+
65
+  for (map<inodeno_t,map<client_t,map<int,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
66
+       p != cap_imports.end();
67
+       ++p) {
68
+    for (map<client_t,map<int,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
69
+	q != p->second.end();
70
+	++q) {
71
+      Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(q->first.v));
72
+      if (session) {
73
+	// mark client caps stale.
74
+	MClientCaps *stale = new MClientCaps(CEPH_CAP_OP_EXPORT, p->first, 0, 0, 0);
75
+	mds->send_message_client_counted(stale, q->first);
76
+      }
77
+    }
78
+  }
79
+
80
+  cap_imports.clear();
81
 }
82
 
83
 void MDCache::try_reconnect_cap(CInode *in, Session *session)
84
diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h
85
index 13201c9..3c73bef 100644
86
--- a/src/mds/MDCache.h
87
+++ b/src/mds/MDCache.h
88
@@ -489,6 +489,7 @@ public:
89
   void rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconnect& icr, int frommds);
90
   void finish_snaprealm_reconnect(client_t client, SnapRealm *realm, snapid_t seq);
91
   void try_reconnect_cap(CInode *in, Session *session);
92
+  void export_remaining_imported_caps();
93
 
94
   // cap imports.  delayed snap parent opens.
95
   //  realm inode -> client -> cap inodes needing to split to this realm
96
diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc
97
index 1bb1f80..16b857e 100644
98
--- a/src/mds/MDS.cc
99
+++ b/src/mds/MDS.cc
100
@@ -1503,6 +1503,7 @@ void MDS::active_start()
101
 
102
   mdcache->clean_open_file_lists();
103
   mdcache->scan_stray_dir();
104
+  mdcache->export_remaining_imported_caps();
105
   finish_contexts(g_ceph_context, waiting_for_replay);  // kick waiters
106
   finish_contexts(g_ceph_context, waiting_for_active);  // kick waiters
107
 }
108
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
109
index 5873647..a420be5 100644
110
--- a/src/mds/Server.cc
111
+++ b/src/mds/Server.cc
112
@@ -574,7 +574,7 @@ void Server::handle_client_reconnect(MClientReconnect *m)
113
 
114
   // notify client of success with an OPEN
115
   mds->messenger->send_message(new MClientSession(CEPH_SESSION_OPEN), m->get_connection());
116
-    
117
+
118
   if (session->is_closed()) {
119
     dout(10) << " session is closed, will make best effort to reconnect " 
120
 	     << m->get_source_inst() << dendl;
121
@@ -636,15 +636,12 @@ void Server::handle_client_reconnect(MClientReconnect *m)
122
     }
123
       
124
     filepath path(p->second.path, (uint64_t)p->second.capinfo.pathbase);
125
-    if ((in && !in->is_auth()) ||
126
-	!mds->mdcache->path_is_mine(path)) {
127
+    if (in && !in->is_auth()) {
128
       // not mine.
129
       dout(0) << "non-auth " << p->first << " " << path
130
 	      << ", will pass off to authority" << dendl;
131
       
132
       // mark client caps stale.
133
-      inode_t fake_inode;
134
-      fake_inode.ino = p->first;
135
       MClientCaps *stale = new MClientCaps(CEPH_CAP_OP_EXPORT, p->first, 0, 0, 0);
136
       //stale->head.migrate_seq = 0; // FIXME ******
137
       mds->send_message_client_counted(stale, session);
138
@@ -652,11 +649,11 @@ void Server::handle_client_reconnect(MClientReconnect *m)
139
       // add to cap export list.
140
       mdcache->rejoin_export_caps(p->first, from, p->second);
141
     } else {
142
-      // mine.  fetch later.
143
+      // don't know if the inode is mine
144
       dout(0) << "missing " << p->first << " " << path
145
-	      << " (mine), will load later" << dendl;
146
-      mdcache->rejoin_recovered_caps(p->first, from, p->second, 
147
-				     -1);  // "from" me.
148
+	      << " will load or export later" << dendl;
149
+      mdcache->rejoin_recovered_caps(p->first, from, p->second, -1);
150
+      mdcache->rejoin_export_caps(p->first, from, p->second);
151
     }
152
   }
153