ceph: queue vmtruncate if necessary when handing cap grant/revoke
authorYan, Zheng <zheng.z.yan@intel.com>
Fri, 11 Apr 2014 02:18:07 +0000 (10:18 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Fri, 6 Jun 2014 01:29:51 +0000 (09:29 +0800)
cap grant/revoke message from non-auth MDS can update inode's size
and truncate_seq/truncate_size. (the message arrives before auth
MDS's cap trunc message)

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
fs/ceph/caps.c

index c561b628ebce519d111d159f541b9df88242a5b1..de39a03f5b7118c0360a0846417faf16f8e2e137 100644 (file)
@@ -2418,11 +2418,12 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
        u64 max_size = le64_to_cpu(grant->max_size);
        struct timespec mtime, atime, ctime;
        int check_caps = 0;
-       int wake = 0;
-       int writeback = 0;
-       int queue_invalidate = 0;
-       int deleted_inode = 0;
-       int queue_revalidate = 0;
+       bool wake = 0;
+       bool writeback = 0;
+       bool queue_trunc = 0;
+       bool queue_invalidate = 0;
+       bool queue_revalidate = 0;
+       bool deleted_inode = 0;
 
        dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
             inode, cap, mds, seq, ceph_cap_string(newcaps));
@@ -2512,9 +2513,10 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
                queue_revalidate = 1;
 
        /* size/ctime/mtime/atime? */
-       ceph_fill_file_size(inode, issued,
-                           le32_to_cpu(grant->truncate_seq),
-                           le64_to_cpu(grant->truncate_size), size);
+       queue_trunc = ceph_fill_file_size(inode, issued,
+                                         le32_to_cpu(grant->truncate_seq),
+                                         le64_to_cpu(grant->truncate_size),
+                                         size);
        ceph_decode_timespec(&mtime, &grant->mtime);
        ceph_decode_timespec(&atime, &grant->atime);
        ceph_decode_timespec(&ctime, &grant->ctime);
@@ -2595,6 +2597,12 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
 
        spin_unlock(&ci->i_ceph_lock);
 
+       if (queue_trunc) {
+               ceph_queue_vmtruncate(inode);
+               ceph_queue_revalidate(inode);
+       } else if (queue_revalidate)
+               ceph_queue_revalidate(inode);
+
        if (writeback)
                /*
                 * queue inode for writeback: we can't actually call
@@ -2606,8 +2614,6 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
                ceph_queue_invalidate(inode);
        if (deleted_inode)
                invalidate_aliases(inode);
-       if (queue_revalidate)
-               ceph_queue_revalidate(inode);
        if (wake)
                wake_up_all(&ci->i_cap_wq);