Skip to content

Commit dfabbed

Browse files
committed
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>
1 parent 029bcbd commit dfabbed

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

‎fs/ceph/inode.c‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ static int fill_inode(struct inode *inode,
560560
struct ceph_mds_reply_inode *info = iinfo->in;
561561
struct ceph_inode_info *ci = ceph_inode(inode);
562562
int i;
563-
int issued, implemented;
563+
int issued = 0, implemented;
564+
int updating_inode = 0;
564565
struct timespec mtime, atime, ctime;
565566
u32 nsplits;
566567
struct ceph_buffer *xattr_blob = NULL;
@@ -599,7 +600,8 @@ static int fill_inode(struct inode *inode,
599600
if (le64_to_cpu(info->version) > 0 &&
600601
(ci->i_version & ~1) >= le64_to_cpu(info->version))
601602
goto no_change;
602-
603+
604+
updating_inode = 1;
603605
issued = __ceph_caps_issued(ci, &implemented);
604606
issued |= implemented | __ceph_caps_dirty(ci);
605607

@@ -707,17 +709,6 @@ static int fill_inode(struct inode *inode,
707709
ci->i_rfiles = le64_to_cpu(info->rfiles);
708710
ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
709711
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-
}
721712
break;
722713
default:
723714
pr_err("fill_inode %llx.%llx BAD mode 0%o\n",
@@ -774,6 +765,19 @@ static int fill_inode(struct inode *inode,
774765
__ceph_get_fmode(ci, cap_fmode);
775766
}
776767

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;
779+
}
780+
777781
/* update delegation info? */
778782
if (dirinfo)
779783
ceph_fill_dirfrag(inode, dirinfo);

0 commit comments

Comments
 (0)