]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix locking in Client::getcwd 17205/head
authorJeff Layton <jlayton@redhat.com>
Wed, 23 Aug 2017 17:49:40 +0000 (13:49 -0400)
committerJeff Layton <jlayton@redhat.com>
Wed, 23 Aug 2017 17:49:40 +0000 (13:49 -0400)
Currently, it doesn't take the client_lock at all, which is problematic
as make_request may very well end up unlocking it. Rename the current
function to _getcwd, and add a new getcwd wrapper that takes the mutex
before calling _getcwd.

This fixes: http://tracker.ceph.com/issues/21082

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h

index 65b7181f9404c19148d11932dc6d52acd932e0e6..2a2033216269a6b5c22b024017f012837542ea49 100644 (file)
@@ -9380,11 +9380,11 @@ int Client::chdir(const char *relpath, std::string &new_cwd,
     cwd.swap(in);
   ldout(cct, 3) << "chdir(" << relpath << ")  cwd now " << cwd->ino << dendl;
 
-  getcwd(new_cwd, perms);
+  _getcwd(new_cwd, perms);
   return 0;
 }
 
-void Client::getcwd(string& dir, const UserPerm& perms)
+void Client::_getcwd(string& dir, const UserPerm& perms)
 {
   filepath path;
   ldout(cct, 10) << "getcwd " << *cwd << dendl;
@@ -9424,6 +9424,12 @@ void Client::getcwd(string& dir, const UserPerm& perms)
   dir += path.get_path();
 }
 
+void Client::getcwd(string& dir, const UserPerm& perms)
+{
+  Mutex::Locker l(client_lock);
+  _getcwd(dir, perms);
+}
+
 int Client::statfs(const char *path, struct statvfs *stbuf,
                   const UserPerm& perms)
 {
index beefa1eba5c8aa2db27777c7cb2e2aa5419cf531..8a1852e7af067e68b7c33b6cfafb17c0e670e7f6 100644 (file)
@@ -956,6 +956,7 @@ public:
 
   // crap
   int chdir(const char *s, std::string &new_cwd, const UserPerm& perms);
+  void _getcwd(std::string& cwd, const UserPerm& perms);
   void getcwd(std::string& cwd, const UserPerm& perms);
 
   // namespace ops