2 * (C) 2001 Clemson University and The University of Chicago
4 * See COPYING in top-level directory.
8 * Implementation of dentry (directory cache) functions.
12 #include "pvfs2-kernel.h"
14 /* Returns 1 if dentry can still be trusted, else 0. */
15 static int pvfs2_revalidate_lookup(struct dentry
*dentry
)
17 struct dentry
*parent_dentry
= dget_parent(dentry
);
18 struct inode
*parent_inode
= parent_dentry
->d_inode
;
19 struct pvfs2_inode_s
*parent
= PVFS2_I(parent_inode
);
20 struct inode
*inode
= dentry
->d_inode
;
21 struct pvfs2_kernel_op_s
*new_op
;
25 gossip_debug(GOSSIP_DCACHE_DEBUG
, "%s: attempting lookup.\n", __func__
);
27 new_op
= op_alloc(PVFS2_VFS_OP_LOOKUP
);
31 new_op
->upcall
.req
.lookup
.sym_follow
= PVFS2_LOOKUP_LINK_NO_FOLLOW
;
32 new_op
->upcall
.req
.lookup
.parent_refn
= parent
->refn
;
33 strncpy(new_op
->upcall
.req
.lookup
.d_name
,
37 gossip_debug(GOSSIP_DCACHE_DEBUG
,
38 "%s:%s:%d interrupt flag [%d]\n",
42 get_interruptible_flag(parent_inode
));
44 err
= service_operation(new_op
, "pvfs2_lookup",
45 get_interruptible_flag(parent_inode
));
49 if (new_op
->downcall
.status
!= 0 ||
50 !match_handle(new_op
->downcall
.resp
.lookup
.refn
.khandle
, inode
)) {
51 gossip_debug(GOSSIP_DCACHE_DEBUG
,
53 "lookup failure |%s| or no match |%s|.\n",
57 new_op
->downcall
.status
? "true" : "false",
58 match_handle(new_op
->downcall
.resp
.lookup
.refn
.khandle
,
59 inode
) ? "false" : "true");
60 gossip_debug(GOSSIP_DCACHE_DEBUG
,
61 "%s:%s:%d revalidate failed\n",
62 __FILE__
, __func__
, __LINE__
);
78 * Verify that dentry is valid.
80 * Should return 1 if dentry can still be trusted, else 0
82 static int pvfs2_d_revalidate(struct dentry
*dentry
, unsigned int flags
)
87 if (flags
& LOOKUP_RCU
)
90 gossip_debug(GOSSIP_DCACHE_DEBUG
, "%s: called on dentry %p.\n",
93 /* find inode from dentry */
94 if (!dentry
->d_inode
) {
95 gossip_debug(GOSSIP_DCACHE_DEBUG
, "%s: negative dentry.\n",
100 gossip_debug(GOSSIP_DCACHE_DEBUG
, "%s: inode valid.\n", __func__
);
101 inode
= dentry
->d_inode
;
104 * first perform a lookup to make sure that the object not only
105 * exists, but is still in the expected place in the name space
107 if (!is_root_handle(inode
)) {
108 if (!pvfs2_revalidate_lookup(dentry
))
111 gossip_debug(GOSSIP_DCACHE_DEBUG
,
112 "%s: root handle, lookup skipped.\n",
116 /* now perform getattr */
117 gossip_debug(GOSSIP_DCACHE_DEBUG
,
118 "%s: doing getattr: inode: %p, handle: %pU\n",
121 get_khandle_from_ino(inode
));
122 ret
= pvfs2_inode_getattr(inode
, PVFS_ATTR_SYS_ALL_NOHINT
);
123 gossip_debug(GOSSIP_DCACHE_DEBUG
,
124 "%s: getattr %s (ret = %d), returning %s for dentry i_count=%d\n",
126 (ret
== 0 ? "succeeded" : "failed"),
128 (ret
== 0 ? "valid" : "INVALID"),
129 atomic_read(&inode
->i_count
));
133 /* dentry is valid! */
140 const struct dentry_operations pvfs2_dentry_operations
= {
141 .d_revalidate
= pvfs2_d_revalidate
,