Skip to content

Commit

Permalink
client: use SaferCond in check_pool_perm
Browse files Browse the repository at this point in the history
Just because it's easier to read.

Signed-off-by: John Spray <john.spray@redhat.com>
  • Loading branch information
John Spray committed May 7, 2015
1 parent 25c23c3 commit 289ee3b
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/client/Client.cc
Expand Up @@ -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)
Expand Down

0 comments on commit 289ee3b

Please sign in to comment.