]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use SaferCond in check_pool_perm
authorJohn Spray <john.spray@redhat.com>
Thu, 7 May 2015 17:17:37 +0000 (18:17 +0100)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 8 May 2015 18:17:15 +0000 (11:17 -0700)
Just because it's easier to read.

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 289ee3b80ccce6bab2966f513a37332280d04a06)
Reviewed-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc

index c6a44778c13b289a9b4bdd7d31d2114487450923..e9e156a22c6da8846e22870b52d42687c9d2cfc6 100644 (file)
@@ -10647,31 +10647,25 @@ int Client::check_pool_perm(Inode *in, int need)
     snprintf(oid_buf, sizeof(oid_buf), "%llx.00000000", (unsigned long long)in->ino);
     object_t oid = oid_buf;
 
-    Mutex lock("Client::check_pool_perm::lock");
-    Cond cond;
-    bool done[2] = {false, false};
-    int rd_ret;
-    int wr_ret;
-
+    C_SaferCond rd_cond;
     ObjectOperation rd_op;
     rd_op.stat(NULL, (utime_t*)NULL, NULL);
 
     objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), rd_op,
                     in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0,
-                    new C_SafeCond(&lock, &cond, &done[0], &rd_ret), NULL);
+                    &rd_cond, NULL);
 
+    C_SaferCond wr_cond;
     ObjectOperation wr_op;
     wr_op.create(true);
 
     objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), wr_op,
                     in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0,
-                    new C_SafeCond(&lock, &cond, &done[1], &wr_ret), NULL);
+                    &wr_cond, NULL);
 
     client_lock.Unlock();
-    lock.Lock();
-    while (!done[0] || !done[1])
-      cond.Wait(lock);
-    lock.Unlock();
+    int rd_ret = rd_cond.wait();
+    int wr_ret = wr_cond.wait();
     client_lock.Lock();
 
     if (rd_ret == 0 || rd_ret == -ENOENT)