]>
Commit | Line | Data |
---|---|---|
ccd979bd MF |
1 | /* -*- mode: c; c-basic-offset: 8; -*- |
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | |
3 | * | |
4 | * dcache.c | |
5 | * | |
6 | * dentry cache handling code | |
7 | * | |
8 | * Copyright (C) 2002, 2004 Oracle. All rights reserved. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU General Public | |
12 | * License as published by the Free Software Foundation; either | |
13 | * version 2 of the License, or (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public | |
21 | * License along with this program; if not, write to the | |
22 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | * Boston, MA 021110-1307, USA. | |
24 | */ | |
25 | ||
26 | #include <linux/fs.h> | |
27 | #include <linux/types.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/namei.h> | |
30 | ||
31 | #define MLOG_MASK_PREFIX ML_DCACHE | |
32 | #include <cluster/masklog.h> | |
33 | ||
34 | #include "ocfs2.h" | |
35 | ||
36 | #include "alloc.h" | |
37 | #include "dcache.h" | |
38 | #include "file.h" | |
39 | #include "inode.h" | |
40 | ||
41 | static int ocfs2_dentry_revalidate(struct dentry *dentry, | |
42 | struct nameidata *nd) | |
43 | { | |
44 | struct inode *inode = dentry->d_inode; | |
45 | int ret = 0; /* if all else fails, just return false */ | |
46 | struct ocfs2_super *osb; | |
47 | ||
48 | mlog_entry("(0x%p, '%.*s')\n", dentry, | |
49 | dentry->d_name.len, dentry->d_name.name); | |
50 | ||
51 | /* Never trust a negative dentry - force a new lookup. */ | |
52 | if (inode == NULL) { | |
53 | mlog(0, "negative dentry: %.*s\n", dentry->d_name.len, | |
54 | dentry->d_name.name); | |
55 | goto bail; | |
56 | } | |
57 | ||
58 | osb = OCFS2_SB(inode->i_sb); | |
59 | ||
60 | BUG_ON(!osb); | |
61 | ||
62 | if (inode != osb->root_inode) { | |
63 | spin_lock(&OCFS2_I(inode)->ip_lock); | |
64 | /* did we or someone else delete this inode? */ | |
65 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { | |
66 | spin_unlock(&OCFS2_I(inode)->ip_lock); | |
b0697053 MF |
67 | mlog(0, "inode (%llu) deleted, returning false\n", |
68 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | |
ccd979bd MF |
69 | goto bail; |
70 | } | |
71 | spin_unlock(&OCFS2_I(inode)->ip_lock); | |
72 | ||
73 | if (!inode->i_nlink) { | |
b0697053 MF |
74 | mlog(0, "Inode %llu orphaned, returning false " |
75 | "dir = %d\n", | |
76 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | |
ccd979bd MF |
77 | S_ISDIR(inode->i_mode)); |
78 | goto bail; | |
79 | } | |
80 | } | |
81 | ||
82 | ret = 1; | |
83 | ||
84 | bail: | |
85 | mlog_exit(ret); | |
86 | ||
87 | return ret; | |
88 | } | |
89 | ||
90 | struct dentry_operations ocfs2_dentry_ops = { | |
91 | .d_revalidate = ocfs2_dentry_revalidate, | |
92 | }; |