ceph: fix wrong check for the case of updating link count
authorYan, Zheng <zyan@redhat.com>
Fri, 25 May 2018 03:22:56 +0000 (11:22 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 4 Jun 2018 18:46:01 +0000 (20:46 +0200)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c

index 477b822..0ae4185 100644 (file)
@@ -3059,7 +3059,6 @@ static void handle_cap_grant(struct inode *inode,
        int used, wanted, dirty;
        u64 size = le64_to_cpu(grant->size);
        u64 max_size = le64_to_cpu(grant->max_size);
-       struct timespec mtime, atime, ctime;
        int check_caps = 0;
        bool wake = false;
        bool writeback = false;
@@ -3124,7 +3123,7 @@ static void handle_cap_grant(struct inode *inode,
                     from_kgid(&init_user_ns, inode->i_gid));
        }
 
-       if ((newcaps & CEPH_CAP_AUTH_SHARED) &&
+       if ((newcaps & CEPH_CAP_LINK_SHARED) &&
            (extra_info->issued & CEPH_CAP_LINK_EXCL) == 0) {
                set_nlink(inode, le32_to_cpu(grant->nlink));
                if (inode->i_nlink == 0 &&
@@ -3149,6 +3148,7 @@ static void handle_cap_grant(struct inode *inode,
        }
 
        if (newcaps & CEPH_CAP_ANY_RD) {
+               struct timespec mtime, atime, ctime;
                /* ctime/mtime/atime? */
                ceph_decode_timespec(&mtime, &grant->mtime);
                ceph_decode_timespec(&atime, &grant->atime);