]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: make Client::open() pass proper cap mask to path_walk
authorYan, Zheng <zyan@redhat.com>
Tue, 18 Aug 2020 14:20:45 +0000 (22:20 +0800)
committerNathan Cutler <ncutler@suse.com>
Wed, 23 Sep 2020 13:08:04 +0000 (15:08 +0200)
variable 'mode' is new file's mode. It shouldn't be passed to
ceph_caps_for_mode().

Fixes: https://tracker.ceph.com/issues/47011
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 135936bb34ba2fe671c4c85abcdab3144191a881)

Conflicts:
src/client/Client.cc
1198a47b97dc8dc6293e3f9b6aa2aaf0e2ff39b1 is not being backported to
  octopus

src/client/Client.cc

index 52e818482a04ac6cf1b26c0d005b7555d2c9df09..86675caf9eb6b9fe1d76e6bb707b1afaa986cd6e 100755 (executable)
@@ -6408,6 +6408,8 @@ int Client::_lookup(Inode *dir, const string& dname, int mask, InodeRef *target,
 {
   int r = 0;
   Dentry *dn = NULL;
+  // can only request shared caps
+  mask &= CEPH_CAP_ANY_SHARED;
 
   if (dname == "..") {
     if (dir->dentries.empty()) {
@@ -8578,11 +8580,13 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
                 mode_t mode, int stripe_unit, int stripe_count,
                 int object_size, const char *data_pool)
 {
-  ldout(cct, 3) << "open enter(" << relpath << ", " << ceph_flags_sys2wire(flags) << "," << mode << ")" << dendl;
+  int cflags = ceph_flags_sys2wire(flags);
+
+  ldout(cct, 3) << "open enter(" << relpath << ", " << cflags << "," << mode << ")" << dendl;
   std::lock_guard lock(client_lock);
   tout(cct) << "open" << std::endl;
   tout(cct) << relpath << std::endl;
-  tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
+  tout(cct) << cflags << std::endl;
 
   if (unmounting)
     return -ENOTCONN;
@@ -8602,7 +8606,9 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
   bool created = false;
   /* O_CREATE with O_EXCL enforces O_NOFOLLOW. */
   bool followsym = !((flags & O_NOFOLLOW) || ((flags & O_CREAT) && (flags & O_EXCL)));
-  int r = path_walk(path, &in, perms, followsym, ceph_caps_for_mode(mode));
+  int mask = ceph_caps_for_mode(ceph_flags_to_mode(cflags));
+
+  int r = path_walk(path, &in, perms, followsym, mask);
 
   if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
     return -EEXIST;
@@ -8655,7 +8661,7 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
   
  out:
   tout(cct) << r << std::endl;
-  ldout(cct, 3) << "open exit(" << path << ", " << ceph_flags_sys2wire(flags) << ") = " << r << dendl;
+  ldout(cct, 3) << "open exit(" << path << ", " << cflags << ") = " << r << dendl;
   return r;
 }