]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: replace C_Cond with C_SafeCond
authorSage Weil <sage@newdream.net>
Wed, 18 Nov 2009 20:25:46 +0000 (12:25 -0800)
committerSage Weil <sage@newdream.net>
Wed, 18 Nov 2009 20:25:46 +0000 (12:25 -0800)
src/TODO
src/client/Client.cc
src/common/Cond.h

index 0f1102494dcd7b85b3fd6e70f91ad24d951db208..0964837b9a023e0868af5efcd337e23297ab680a 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -222,6 +222,7 @@ osd
 - optimize remove wrt recovery pushes?
 
 uclient
+- fix client_lock vs other mutex with C_SafeCond
 - clean up check_caps to more closely mirror kclient logic
 - readdir from cache
 - fix readdir vs fragment race by keeping a separate frag pos, and ignoring dentries below it
index 94eedd0acd9c083946eac1ce99ea4e463cbbbe6d..9f34fa5d06301625f32b8aff1b6b6935598bb4dd 100644 (file)
@@ -4766,13 +4766,19 @@ int Client::statfs(const char *path, struct statvfs *stbuf)
 
   ceph_statfs stats;
 
+  Mutex lock("Client::statfs::lock");
   Cond cond;
   bool done;
+  int rval;
 
-  objecter->get_fs_stats(stats, new C_Cond(&cond, &done));
+  objecter->get_fs_stats(stats, new C_SafeCond(&lock, &cond, &done, &rval));
 
-  while(!done) 
-    cond.Wait(client_lock);
+  client_lock.Unlock();
+  lock.Lock();
+  while (!done) 
+    cond.Wait(lock);
+  lock.Unlock();
+  client_lock.Lock();
 
   memset(stbuf, 0, sizeof(*stbuf));
   //divide the results by 4 to give them as Posix expects
@@ -4789,7 +4795,7 @@ int Client::statfs(const char *path, struct statvfs *stbuf)
   stbuf->f_flag = 0;        // ??
   stbuf->f_namemax = PAGE_SIZE;  // ??
 
-  return 0;
+  return rval;
 }
 
 int Client::ll_statfs(vinodeno_t vino, struct statvfs *stbuf)
index 59ea9350187c815888d7b52461e72276cf41d587..3b0c396aedc6460ee20406b01d6135e8841ef555 100644 (file)
@@ -82,21 +82,6 @@ class Cond {
   }
 };
 
-class C_Cond : public Context {
-  Cond *cond;
-  bool *done;
-  int *rval;
-public:
-  C_Cond(Cond *c, bool *d, int *r=0) : cond(c), done(d), rval(r) {
-    *done = false;
-  }
-  void finish(int r) {
-    if (rval) *rval = r;
-    *done = true;
-    cond->Signal();
-  }
-};
-
 class C_SafeCond : public Context {
   Mutex *lock;
   Cond *cond;