dcache.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #include <linux/fs.h>
  26. #include <linux/types.h>
  27. #include <linux/slab.h>
  28. #include <linux/namei.h>
  29. #define MLOG_MASK_PREFIX ML_DCACHE
  30. #include <cluster/masklog.h>
  31. #include "ocfs2.h"
  32. #include "alloc.h"
  33. #include "dcache.h"
  34. #include "file.h"
  35. #include "inode.h"
  36. static int ocfs2_dentry_revalidate(struct dentry *dentry,
  37. struct nameidata *nd)
  38. {
  39. struct inode *inode = dentry->d_inode;
  40. int ret = 0; /* if all else fails, just return false */
  41. struct ocfs2_super *osb;
  42. mlog_entry("(0x%p, '%.*s')\n", dentry,
  43. dentry->d_name.len, dentry->d_name.name);
  44. /* Never trust a negative dentry - force a new lookup. */
  45. if (inode == NULL) {
  46. mlog(0, "negative dentry: %.*s\n", dentry->d_name.len,
  47. dentry->d_name.name);
  48. goto bail;
  49. }
  50. osb = OCFS2_SB(inode->i_sb);
  51. BUG_ON(!osb);
  52. if (inode != osb->root_inode) {
  53. spin_lock(&OCFS2_I(inode)->ip_lock);
  54. /* did we or someone else delete this inode? */
  55. if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) {
  56. spin_unlock(&OCFS2_I(inode)->ip_lock);
  57. mlog(0, "inode (%"MLFu64") deleted, returning false\n",
  58. OCFS2_I(inode)->ip_blkno);
  59. goto bail;
  60. }
  61. spin_unlock(&OCFS2_I(inode)->ip_lock);
  62. if (!inode->i_nlink) {
  63. mlog(0, "Inode %"MLFu64" orphaned, returning false "
  64. "dir = %d\n", OCFS2_I(inode)->ip_blkno,
  65. S_ISDIR(inode->i_mode));
  66. goto bail;
  67. }
  68. }
  69. ret = 1;
  70. bail:
  71. mlog_exit(ret);
  72. return ret;
  73. }
  74. struct dentry_operations ocfs2_dentry_ops = {
  75. .d_revalidate = ocfs2_dentry_revalidate,
  76. };