From: John Spray Date: Thu, 7 May 2015 17:17:37 +0000 (+0100) Subject: client: use SaferCond in check_pool_perm X-Git-Tag: v9.0.2~215^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=289ee3b80ccce6bab2966f513a37332280d04a06;p=ceph.git client: use SaferCond in check_pool_perm Just because it's easier to read. Signed-off-by: John Spray --- diff --git a/src/client/Client.cc b/src/client/Client.cc index de2856764482..814ed358652b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10781,31 +10781,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)