Merge pull request #9572 from xiexingguo/xxg-wip-fix-ll_read_block

client: fix wrong lock logic of ll_read_block() method

Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
John Spray 2016-06-14 17:44:23 +01:00 committed by GitHub
commit 40547be1ef

View File

@ -11409,13 +11409,10 @@ int Client::ll_read_block(Inode *in, uint64_t blockid,
file_layout_t* layout)
{
Mutex::Locker lock(client_lock);
Mutex flock("Client::ll_read_block flock");
Cond cond;
vinodeno_t vino = ll_get_vino(in);
object_t oid = file_object_t(vino.ino, blockid);
int r = 0;
bool done = false;
Context *onfinish = new C_SafeCond(&flock, &cond, &done, &r);
C_SaferCond cond;
bufferlist bl;
objecter->read(oid,
@ -11425,10 +11422,11 @@ int Client::ll_read_block(Inode *in, uint64_t blockid,
vino.snapid,
&bl,
CEPH_OSD_FLAG_READ,
onfinish);
&cond);
while (!done)
cond.Wait(client_lock);
client_lock.Unlock();
r = cond.wait();
client_lock.Lock(); // lock is going to unlock on exit.
if (r >= 0) {
bl.copy(0, bl.length(), buf);