2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License v.2.
10 #include <linux/sched.h>
11 #include <linux/slab.h>
12 #include <linux/spinlock.h>
13 #include <linux/completion.h>
14 #include <linux/buffer_head.h>
15 #include <linux/smp_lock.h>
16 #include <asm/semaphore.h>
21 #include "ops_dentry.h"
24 * gfs2_drevalidate - Check directory lookup consistency
25 * @dentry: the mapping to check
28 * Check to make sure the lookup necessary to arrive at this inode from its
29 * parent is still good.
31 * Returns: 1 if the dentry is ok, 0 if it isn't
34 static int gfs2_drevalidate(struct dentry
*dentry
, struct nameidata
*nd
)
36 struct dentry
*parent
= dget_parent(dentry
);
37 struct gfs2_inode
*dip
= get_v2ip(parent
->d_inode
);
39 struct gfs2_holder d_gh
;
40 struct gfs2_inode
*ip
;
41 struct gfs2_inum inum
;
47 inode
= dentry
->d_inode
;
48 if (inode
&& is_bad_inode(inode
))
51 error
= gfs2_glock_nq_init(dip
->i_gl
, LM_ST_SHARED
, 0, &d_gh
);
55 error
= gfs2_dir_search(dip
, &dentry
->d_name
, &inum
, &type
);
71 if (!gfs2_inum_equal(&ip
->i_num
, &inum
))
74 if (IF2DT(ip
->i_di
.di_mode
) != type
) {
75 gfs2_consist_inode(dip
);
80 gfs2_glock_dq_uninit(&d_gh
);
88 gfs2_glock_dq_uninit(&d_gh
);
91 if (inode
&& S_ISDIR(inode
->i_mode
)) {
92 if (have_submounts(dentry
))
94 shrink_dcache_parent(dentry
);
103 gfs2_glock_dq_uninit(&d_gh
);
111 struct dentry_operations gfs2_dops
= {
112 .d_revalidate
= gfs2_drevalidate
,