ceph: set dir complete frag after adding capability
authorSage Weil <sage@newdream.net>
Tue, 26 Jul 2011 18:30:02 +0000 (11:30 -0700)
committerSage Weil <sage@newdream.net>
Tue, 26 Jul 2011 18:30:02 +0000 (11:30 -0700)
Curretly ceph_add_cap clears the complete bit if we are newly issued the
FILE_SHARED cap, which is normally the case for a newly issue cap on a new
directory.  That means we clear the just-set bit.  Move the check that sets
the flag to after the cap is added/updated.

Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/inode.c

index f51e873..2717dc4 100644 (file)
@@ -560,7 +560,8 @@ static int fill_inode(struct inode *inode,
        struct ceph_mds_reply_inode *info = iinfo->in;
        struct ceph_inode_info *ci = ceph_inode(inode);
        int i;
-       int issued, implemented;
+       int issued = 0, implemented;
+       int updating_inode = 0;
        struct timespec mtime, atime, ctime;
        u32 nsplits;
        struct ceph_buffer *xattr_blob = NULL;
@@ -599,7 +600,8 @@ static int fill_inode(struct inode *inode,
        if (le64_to_cpu(info->version) > 0 &&
            (ci->i_version & ~1) >= le64_to_cpu(info->version))
                goto no_change;
-
+       
+       updating_inode = 1;
        issued = __ceph_caps_issued(ci, &implemented);
        issued |= implemented | __ceph_caps_dirty(ci);
 
@@ -707,17 +709,6 @@ static int fill_inode(struct inode *inode,
                ci->i_rfiles = le64_to_cpu(info->rfiles);
                ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
                ceph_decode_timespec(&ci->i_rctime, &info->rctime);
-
-               /* set dir completion flag? */
-               if (ci->i_files == 0 && ci->i_subdirs == 0 &&
-                   ceph_snap(inode) == CEPH_NOSNAP &&
-                   (le32_to_cpu(info->cap.caps) & CEPH_CAP_FILE_SHARED) &&
-                   (issued & CEPH_CAP_FILE_EXCL) == 0 &&
-                   (ci->i_ceph_flags & CEPH_I_COMPLETE) == 0) {
-                       dout(" marking %p complete (empty)\n", inode);
-                       /* ci->i_ceph_flags |= CEPH_I_COMPLETE; */
-                       ci->i_max_offset = 2;
-               }
                break;
        default:
                pr_err("fill_inode %llx.%llx BAD mode 0%o\n",
@@ -774,6 +765,19 @@ no_change:
                __ceph_get_fmode(ci, cap_fmode);
        }
 
+       /* set dir completion flag? */
+       if (S_ISDIR(inode->i_mode) &&
+           updating_inode &&                 /* didn't jump to no_change */
+           ci->i_files == 0 && ci->i_subdirs == 0 &&
+           ceph_snap(inode) == CEPH_NOSNAP &&
+           (le32_to_cpu(info->cap.caps) & CEPH_CAP_FILE_SHARED) &&
+           (issued & CEPH_CAP_FILE_EXCL) == 0 &&
+           (ci->i_ceph_flags & CEPH_I_COMPLETE) == 0) {
+               dout(" marking %p complete (empty)\n", inode);
+               /* ci->i_ceph_flags |= CEPH_I_COMPLETE; */
+               ci->i_max_offset = 2;
+       }
+
        /* update delegation info? */
        if (dirinfo)
                ceph_fill_dirfrag(inode, dirinfo);