ceph: don't take refs to want mask unless we have all bits
authorYan, Zheng <ukernel@gmail.com>
Tue, 18 Feb 2020 13:17:08 +0000 (08:17 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Mar 2020 10:42:41 +0000 (12:42 +0200)
If we don't have all of the cap bits for the want mask in
try_get_cap_refs, then just take refs on the need bits.

Signed-off-by: "Yan, Zheng" <ukernel@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c

index d327412..d09b9d9 100644 (file)
@@ -2666,7 +2666,10 @@ again:
                                }
                                snap_rwsem_locked = true;
                        }
-                       *got = need | (have & want);
+                       if ((have & want) == want)
+                               *got = need | want;
+                       else
+                               *got = need;
                        if (S_ISREG(inode->i_mode) &&
                            (need & CEPH_CAP_FILE_RD) &&
                            !(*got & CEPH_CAP_FILE_CACHE))