@@ -108,7 +108,7 @@ static unsigned fpos_off(loff_t p)
108108 * falling back to a "normal" sync readdir if any dentries in the dir
109109 * are dropped.
110110 *
111- * I_COMPLETE tells indicates we have all dentries in the dir. It is
111+ * D_COMPLETE tells indicates we have all dentries in the dir. It is
112112 * defined IFF we hold CEPH_CAP_FILE_SHARED (which will be revoked by
113113 * the MDS if/when the directory is modified).
114114 */
@@ -199,8 +199,8 @@ static int __dcache_readdir(struct file *filp,
199199 filp -> f_pos ++ ;
200200
201201 /* make sure a dentry wasn't dropped while we didn't have parent lock */
202- if (!ceph_i_test (dir , CEPH_I_COMPLETE )) {
203- dout (" lost I_COMPLETE on %p; falling back to mds\n" , dir );
202+ if (!ceph_dir_test_complete (dir )) {
203+ dout (" lost D_COMPLETE on %p; falling back to mds\n" , dir );
204204 err = - EAGAIN ;
205205 goto out ;
206206 }
@@ -285,7 +285,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
285285 if ((filp -> f_pos == 2 || fi -> dentry ) &&
286286 !ceph_test_mount_opt (fsc , NOASYNCREADDIR ) &&
287287 ceph_snap (inode ) != CEPH_SNAPDIR &&
288- ( ci -> i_ceph_flags & CEPH_I_COMPLETE ) &&
288+ ceph_dir_test_complete ( inode ) &&
289289 __ceph_caps_issued_mask (ci , CEPH_CAP_FILE_SHARED , 1 )) {
290290 spin_unlock (& inode -> i_lock );
291291 err = __dcache_readdir (filp , dirent , filldir );
@@ -351,7 +351,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
351351
352352 if (!req -> r_did_prepopulate ) {
353353 dout ("readdir !did_prepopulate" );
354- fi -> dir_release_count -- ; /* preclude I_COMPLETE */
354+ fi -> dir_release_count -- ; /* preclude D_COMPLETE */
355355 }
356356
357357 /* note next offset and last dentry name */
@@ -430,8 +430,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
430430 */
431431 spin_lock (& inode -> i_lock );
432432 if (ci -> i_release_count == fi -> dir_release_count ) {
433- dout (" marking %p complete\n" , inode );
434- /* ci->i_ceph_flags |= CEPH_I_COMPLETE; */
433+ ceph_dir_set_complete (inode );
435434 ci -> i_max_offset = filp -> f_pos ;
436435 }
437436 spin_unlock (& inode -> i_lock );
@@ -614,7 +613,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
614613 fsc -> mount_options -> snapdir_name ,
615614 dentry -> d_name .len ) &&
616615 !is_root_ceph_dentry (dir , dentry ) &&
617- ( ci -> i_ceph_flags & CEPH_I_COMPLETE ) &&
616+ ceph_dir_test_complete ( dir ) &&
618617 (__ceph_caps_issued_mask (ci , CEPH_CAP_FILE_SHARED , 1 ))) {
619618 spin_unlock (& dir -> i_lock );
620619 dout (" dir %p complete, -ENOENT\n" , dir );
@@ -934,7 +933,7 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
934933 */
935934
936935 /* d_move screws up d_subdirs order */
937- ceph_i_clear (new_dir , CEPH_I_COMPLETE );
936+ ceph_dir_clear_complete (new_dir );
938937
939938 d_move (old_dentry , new_dentry );
940939
@@ -1092,6 +1091,48 @@ static int ceph_snapdir_d_revalidate(struct dentry *dentry,
10921091 return 1 ;
10931092}
10941093
1094+ /*
1095+ * Set/clear/test dir complete flag on the dir's dentry.
1096+ */
1097+ static struct dentry * __d_find_any_alias (struct inode * inode )
1098+ {
1099+ struct dentry * alias ;
1100+
1101+ if (list_empty (& inode -> i_dentry ))
1102+ return NULL ;
1103+ alias = list_first_entry (& inode -> i_dentry , struct dentry , d_alias );
1104+ return alias ;
1105+ }
1106+
1107+ void ceph_dir_set_complete (struct inode * inode )
1108+ {
1109+ struct dentry * dentry = __d_find_any_alias (inode );
1110+
1111+ if (dentry && ceph_dentry (dentry )) {
1112+ dout (" marking %p (%p) complete\n" , inode , dentry );
1113+ set_bit (CEPH_D_COMPLETE , & ceph_dentry (dentry )-> flags );
1114+ }
1115+ }
1116+
1117+ void ceph_dir_clear_complete (struct inode * inode )
1118+ {
1119+ struct dentry * dentry = __d_find_any_alias (inode );
1120+
1121+ if (dentry && ceph_dentry (dentry )) {
1122+ dout (" marking %p (%p) NOT complete\n" , inode , dentry );
1123+ clear_bit (CEPH_D_COMPLETE , & ceph_dentry (dentry )-> flags );
1124+ }
1125+ }
1126+
1127+ bool ceph_dir_test_complete (struct inode * inode )
1128+ {
1129+ struct dentry * dentry = __d_find_any_alias (inode );
1130+
1131+ if (dentry && ceph_dentry (dentry ))
1132+ return test_bit (CEPH_D_COMPLETE , & ceph_dentry (dentry )-> flags );
1133+ return false;
1134+ }
1135+
10951136/*
10961137 * When the VFS prunes a dentry from the cache, we need to clear the
10971138 * complete flag on the parent directory.
0 commit comments