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
);
38 struct gfs2_sbd
*sdp
= dip
->i_sbd
;
40 struct gfs2_holder d_gh
;
41 struct gfs2_inode
*ip
;
42 struct gfs2_inum inum
;
48 atomic_inc(&sdp
->sd_ops_dentry
);
50 inode
= dentry
->d_inode
;
51 if (inode
&& is_bad_inode(inode
))
54 error
= gfs2_glock_nq_init(dip
->i_gl
, LM_ST_SHARED
, 0, &d_gh
);
58 error
= gfs2_dir_search(dip
, &dentry
->d_name
, &inum
, &type
);
74 if (!gfs2_inum_equal(&ip
->i_num
, &inum
))
77 if (IF2DT(ip
->i_di
.di_mode
) != type
) {
78 gfs2_consist_inode(dip
);
83 gfs2_glock_dq_uninit(&d_gh
);
91 gfs2_glock_dq_uninit(&d_gh
);
94 if (inode
&& S_ISDIR(inode
->i_mode
)) {
95 if (have_submounts(dentry
))
97 shrink_dcache_parent(dentry
);
106 gfs2_glock_dq_uninit(&d_gh
);
114 struct dentry_operations gfs2_dops
= {
115 .d_revalidate
= gfs2_drevalidate
,