From: Yan, Zheng Date: Tue, 18 Aug 2020 14:20:45 +0000 (+0800) Subject: client: make Client::open() pass proper cap mask to path_walk X-Git-Tag: v15.2.9~122^2~36^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=82f52ee1022629226a05a4281734958133879cf1;p=ceph.git client: make Client::open() pass proper cap mask to path_walk 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" (cherry picked from commit 135936bb34ba2fe671c4c85abcdab3144191a881) Conflicts: src/client/Client.cc - 1198a47b97dc8dc6293e3f9b6aa2aaf0e2ff39b1 is not being backported to octopus --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 52e818482a04..86675caf9eb6 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; }