Skip to content

Commit b58dc41

Browse files
committed
ceph: clear parent D_COMPLETE flag when on dentry prune
When the VFS prunes a dentry from the cache, clear the D_COMPLETE flag on the parent dentry. Do this for the live and snapshotted namespaces. Do not bother for the .snap dir contents, since we do not cache that. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent 3f8ddb0 commit b58dc41

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎fs/ceph/dir.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,33 @@ static int ceph_snapdir_d_revalidate(struct dentry *dentry,
10921092
return 1;
10931093
}
10941094

1095+
/*
1096+
* When the VFS prunes a dentry from the cache, we need to clear the
1097+
* complete flag on the parent directory.
1098+
*
1099+
* Called under dentry->d_lock.
1100+
*/
1101+
static void ceph_d_prune(struct dentry *dentry)
1102+
{
1103+
struct ceph_dentry_info *di;
1104+
1105+
dout("d_release %p\n", dentry);
1106+
1107+
/* do we have a valid parent? */
1108+
if (!dentry->d_parent || IS_ROOT(dentry))
1109+
return;
1110+
1111+
/* if we are not hashed, we don't affect D_COMPLETE */
1112+
if (d_unhashed(dentry))
1113+
return;
10951114

1115+
/*
1116+
* we hold d_lock, so d_parent is stable, and d_fsdata is never
1117+
* cleared until d_release
1118+
*/
1119+
di = ceph_dentry(dentry->d_parent);
1120+
clear_bit(CEPH_D_COMPLETE, &di->flags);
1121+
}
10961122

10971123
/*
10981124
* read() on a dir. This weird interface hack only works if mounted
@@ -1306,6 +1332,7 @@ const struct inode_operations ceph_dir_iops = {
13061332
const struct dentry_operations ceph_dentry_ops = {
13071333
.d_revalidate = ceph_d_revalidate,
13081334
.d_release = ceph_d_release,
1335+
.d_prune = ceph_d_prune,
13091336
};
13101337

13111338
const struct dentry_operations ceph_snapdir_dentry_ops = {
@@ -1315,4 +1342,5 @@ const struct dentry_operations ceph_snapdir_dentry_ops = {
13151342

13161343
const struct dentry_operations ceph_snap_dentry_ops = {
13171344
.d_release = ceph_d_release,
1345+
.d_prune = ceph_d_prune,
13181346
};

‎fs/ceph/super.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ struct ceph_inode_xattr {
203203
* Ceph dentry state
204204
*/
205205
struct ceph_dentry_info {
206+
unsigned long flags;
206207
struct ceph_mds_session *lease_session;
207208
u32 lease_gen, lease_shared_gen;
208209
u32 lease_seq;
@@ -213,6 +214,18 @@ struct ceph_dentry_info {
213214
u64 offset;
214215
};
215216

217+
/*
218+
* dentry flags
219+
*
220+
* The locking for D_COMPLETE is a bit odd:
221+
* - we can clear it at almost any time (see ceph_d_prune)
222+
* - it is only meaningful if:
223+
* - we hold dir inode i_lock
224+
* - we hold dir FILE_SHARED caps
225+
* - the dentry D_COMPLETE is set
226+
*/
227+
#define CEPH_D_COMPLETE 1 /* if set, d_u.d_subdirs is complete directory */
228+
216229
struct ceph_inode_xattrs_info {
217230
/*
218231
* (still encoded) xattr blob. we avoid the overhead of parsing

0 commit comments

Comments
 (0)