From 135936bb34ba2fe671c4c85abcdab3144191a881 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 18 Aug 2020 22:20:45 +0800 Subject: [PATCH] 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" --- src/client/Client.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index e7eb2c23ef76d..c7f69f5543554 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6517,6 +6517,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()) { @@ -8739,10 +8741,12 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms, if (!mref_reader.is_state_satisfied()) return -ENOTCONN; - 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; tout(cct) << "open" << std::endl; tout(cct) << relpath << std::endl; - tout(cct) << ceph_flags_sys2wire(flags) << std::endl; + tout(cct) << cflags << std::endl; Fh *fh = NULL; @@ -8759,9 +8763,10 @@ 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 mask = ceph_caps_for_mode(ceph_flags_to_mode(cflags)); std::scoped_lock lock(client_lock); - int r = path_walk(path, &in, perms, followsym, ceph_caps_for_mode(mode)); + int r = path_walk(path, &in, perms, followsym, mask); if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL)) return -EEXIST; @@ -8814,7 +8819,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; } -- 2.39.5