Calling atomic_read() twice may return different value, so introduce a variable to avoid it. Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx> --- fs/ceph/dir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 82928cea0209..c5e74949ab69 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1200,14 +1200,16 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) struct ceph_inode_info *ci = ceph_inode(dir); struct ceph_dentry_info *di = ceph_dentry(dentry); int valid = 0; + int shared_gen; spin_lock(&ci->i_ceph_lock); - if (atomic_read(&ci->i_shared_gen) == di->lease_shared_gen) + shared_gen = atomic_read(&ci->i_shared_gen); + if (shared_gen == di->lease_shared_gen) valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1); spin_unlock(&ci->i_ceph_lock); dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n", - dir, (unsigned)atomic_read(&ci->i_shared_gen), - dentry, (unsigned)di->lease_shared_gen, valid); + dir, (unsigned int)shared_gen, + dentry, (unsigned int)di->lease_shared_gen, valid); return valid; } -- 2.17.1