From d00b917143e2afd72851bfd0400b2c2a1f3fc018 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 18 Nov 2009 12:25:46 -0800 Subject: [PATCH] uclient: replace C_Cond with C_SafeCond --- src/TODO | 1 + src/client/Client.cc | 14 ++++++++++---- src/common/Cond.h | 15 --------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/TODO b/src/TODO index 0f1102494dcd7..0964837b9a023 100644 --- 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 diff --git a/src/client/Client.cc b/src/client/Client.cc index 94eedd0acd9c0..9f34fa5d06301 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) diff --git a/src/common/Cond.h b/src/common/Cond.h index 59ea9350187c8..3b0c396aedc64 100644 --- a/src/common/Cond.h +++ b/src/common/Cond.h @@ -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; -- 2.39.5