Mark Fasheh | ccd979b | 2005-12-15 14:31:24 -0800 | [diff] [blame^] | 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); |
| 67 | mlog(0, "inode (%"MLFu64") deleted, returning false\n", |
| 68 | OCFS2_I(inode)->ip_blkno); |
| 69 | goto bail; |
| 70 | } |
| 71 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
| 72 | |
| 73 | if (!inode->i_nlink) { |
| 74 | mlog(0, "Inode %"MLFu64" orphaned, returning false " |
| 75 | "dir = %d\n", OCFS2_I(inode)->ip_blkno, |
| 76 | S_ISDIR(inode->i_mode)); |
| 77 | goto bail; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | ret = 1; |
| 82 | |
| 83 | bail: |
| 84 | mlog_exit(ret); |
| 85 | |
| 86 | return ret; |
| 87 | } |
| 88 | |
| 89 | struct dentry_operations ocfs2_dentry_ops = { |
| 90 | .d_revalidate = ocfs2_dentry_revalidate, |
| 91 | }; |