Skip to content

Commit

Permalink
ceph: don't take refs to want mask unless we have all bits
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yan, Zheng authored and Ilya Dryomov committed Mar 30, 2020
1 parent a25949b commit 173e70e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,10 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
}
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))
Expand Down

0 comments on commit 173e70e

Please sign in to comment.