aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_dentry.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2006-01-16 11:50:04 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-01-16 11:50:04 -0500
commitb3b94faa5fe5968827ba0640ee9fba4b3e7f736e (patch)
tree70bd6068b050d2c46e338484f8b03fae4365c6c3 /fs/gfs2/ops_dentry.c
parentf7825dcf8c7301cfd3724eb40c5b443cc85ab7b8 (diff)
[GFS2] The core of GFS2
This patch contains all the core files for GFS2. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_dentry.c')
-rw-r--r--fs/gfs2/ops_dentry.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c
new file mode 100644
index 000000000000..5c618611c11b
--- /dev/null
+++ b/fs/gfs2/ops_dentry.c
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
4 *
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.
8 */
9
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>
17
18#include "gfs2.h"
19#include "dir.h"
20#include "glock.h"
21#include "ops_dentry.h"
22
23/**
24 * gfs2_drevalidate - Check directory lookup consistency
25 * @dentry: the mapping to check
26 * @nd:
27 *
28 * Check to make sure the lookup necessary to arrive at this inode from its
29 * parent is still good.
30 *
31 * Returns: 1 if the dentry is ok, 0 if it isn't
32 */
33
34static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
35{
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;
39 struct inode *inode;
40 struct gfs2_holder d_gh;
41 struct gfs2_inode *ip;
42 struct gfs2_inum inum;
43 unsigned int type;
44 int error;
45
46 lock_kernel();
47
48 atomic_inc(&sdp->sd_ops_dentry);
49
50 inode = dentry->d_inode;
51 if (inode && is_bad_inode(inode))
52 goto invalid;
53
54 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
55 if (error)
56 goto fail;
57
58 error = gfs2_dir_search(dip, &dentry->d_name, &inum, &type);
59 switch (error) {
60 case 0:
61 if (!inode)
62 goto invalid_gunlock;
63 break;
64 case -ENOENT:
65 if (!inode)
66 goto valid_gunlock;
67 goto invalid_gunlock;
68 default:
69 goto fail_gunlock;
70 }
71
72 ip = get_v2ip(inode);
73
74 if (!gfs2_inum_equal(&ip->i_num, &inum))
75 goto invalid_gunlock;
76
77 if (IF2DT(ip->i_di.di_mode) != type) {
78 gfs2_consist_inode(dip);
79 goto fail_gunlock;
80 }
81
82 valid_gunlock:
83 gfs2_glock_dq_uninit(&d_gh);
84
85 valid:
86 unlock_kernel();
87 dput(parent);
88 return 1;
89
90 invalid_gunlock:
91 gfs2_glock_dq_uninit(&d_gh);
92
93 invalid:
94 if (inode && S_ISDIR(inode->i_mode)) {
95 if (have_submounts(dentry))
96 goto valid;
97 shrink_dcache_parent(dentry);
98 }
99 d_drop(dentry);
100
101 unlock_kernel();
102 dput(parent);
103 return 0;
104
105 fail_gunlock:
106 gfs2_glock_dq_uninit(&d_gh);
107
108 fail:
109 unlock_kernel();
110 dput(parent);
111 return 0;
112}
113
114struct dentry_operations gfs2_dops = {
115 .d_revalidate = gfs2_drevalidate,
116};
117