Commit dfabbed6fdd509dc2beb89c954bc36014a1bc7cb

Authored by Sage Weil
1 parent 029bcbd8b0

ceph: set dir complete frag after adding capability

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>

Showing 1 changed file with 17 additions and 13 deletions Side-by-side Diff

... ... @@ -560,7 +560,8 @@
560 560 struct ceph_mds_reply_inode *info = iinfo->in;
561 561 struct ceph_inode_info *ci = ceph_inode(inode);
562 562 int i;
563   - int issued, implemented;
  563 + int issued = 0, implemented;
  564 + int updating_inode = 0;
564 565 struct timespec mtime, atime, ctime;
565 566 u32 nsplits;
566 567 struct ceph_buffer *xattr_blob = NULL;
... ... @@ -599,7 +600,8 @@
599 600 if (le64_to_cpu(info->version) > 0 &&
600 601 (ci->i_version & ~1) >= le64_to_cpu(info->version))
601 602 goto no_change;
602   -
  603 +
  604 + updating_inode = 1;
603 605 issued = __ceph_caps_issued(ci, &implemented);
604 606 issued |= implemented | __ceph_caps_dirty(ci);
605 607  
... ... @@ -707,17 +709,6 @@
707 709 ci->i_rfiles = le64_to_cpu(info->rfiles);
708 710 ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
709 711 ceph_decode_timespec(&ci->i_rctime, &info->rctime);
710   -
711   - /* set dir completion flag? */
712   - if (ci->i_files == 0 && ci->i_subdirs == 0 &&
713   - ceph_snap(inode) == CEPH_NOSNAP &&
714   - (le32_to_cpu(info->cap.caps) & CEPH_CAP_FILE_SHARED) &&
715   - (issued & CEPH_CAP_FILE_EXCL) == 0 &&
716   - (ci->i_ceph_flags & CEPH_I_COMPLETE) == 0) {
717   - dout(" marking %p complete (empty)\n", inode);
718   - /* ci->i_ceph_flags |= CEPH_I_COMPLETE; */
719   - ci->i_max_offset = 2;
720   - }
721 712 break;
722 713 default:
723 714 pr_err("fill_inode %llx.%llx BAD mode 0%o\n",
... ... @@ -772,6 +763,19 @@
772 763 pr_warning("mds issued no caps on %llx.%llx\n",
773 764 ceph_vinop(inode));
774 765 __ceph_get_fmode(ci, cap_fmode);
  766 + }
  767 +
  768 + /* set dir completion flag? */
  769 + if (S_ISDIR(inode->i_mode) &&
  770 + updating_inode && /* didn't jump to no_change */
  771 + ci->i_files == 0 && ci->i_subdirs == 0 &&
  772 + ceph_snap(inode) == CEPH_NOSNAP &&
  773 + (le32_to_cpu(info->cap.caps) & CEPH_CAP_FILE_SHARED) &&
  774 + (issued & CEPH_CAP_FILE_EXCL) == 0 &&
  775 + (ci->i_ceph_flags & CEPH_I_COMPLETE) == 0) {
  776 + dout(" marking %p complete (empty)\n", inode);
  777 + /* ci->i_ceph_flags |= CEPH_I_COMPLETE; */
  778 + ci->i_max_offset = 2;
775 779 }
776 780  
777 781 /* update delegation info? */