journal_xfs.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  2.  * vim:expandtab:shiftwidth=8:tabstop=8:
  3.  *
  4.  *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
  5.  *
  6.  *   This file is part of InterMezzo, http://www.inter-mezzo.org.
  7.  *
  8.  *   InterMezzo is free software; you can redistribute it and/or
  9.  *   modify it under the terms of version 2 of the GNU General Public
  10.  *   License as published by the Free Software Foundation.
  11.  *
  12.  *   InterMezzo is distributed in the hope that it will be useful,
  13.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *   GNU General Public License for more details.
  16.  *
  17.  *   You should have received a copy of the GNU General Public License
  18.  *   along with InterMezzo; if not, write to the Free Software
  19.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  */
  21. #include <linux/types.h>
  22. #include <linux/kernel.h>
  23. #include <linux/sched.h>
  24. #include <linux/fs.h>
  25. #include <linux/slab.h>
  26. #include <linux/vmalloc.h>
  27. #include <linux/stat.h>
  28. #include <linux/errno.h>
  29. #include <linux/locks.h>
  30. #include <asm/segment.h>
  31. #include <asm/uaccess.h>
  32. #include <linux/string.h>
  33. #if 0
  34. /* XFS Support not there yet */
  35. #ifdef CONFIG_FS_XFS
  36. #include <linux/xfs_fs.h>
  37. #endif
  38. #include <linux/intermezzo_fs.h>
  39. #include <linux/intermezzo_psdev.h>
  40. #include <linux/intermezzo_journal.h>
  41. #if 0
  42. /* XFS has journalling, but these functions do nothing yet... */
  43. static unsigned long presto_xfs_freespace(struct presto_file_set *fset,
  44.                                          struct super_block *sb)
  45. {
  46. #if 0
  47.         vfs_t *vfsp = LINVFS_GET_VFS(sb);
  48.         struct statvfs_t stat; 
  49.         bhv_desc_t *bdp;
  50.         unsigned long avail; 
  51.         int rc;
  52.         VFS_STATVFS(vfsp, &stat, NULL, rc);
  53.         avail = statp.f_bfree;
  54.         return sbp->sb_fdblocks;; 
  55. #endif
  56.         return 0x0fffffff;
  57. }
  58. /* start the filesystem journal operations */
  59. static void *
  60. presto_xfs_trans_start(struct presto_file_set *fset,
  61.        struct inode *inode, int op)
  62. {
  63. int xfs_op;
  64. /* do a free blocks check as in journal_ext3? does anything protect
  65.  * the space in that case or can it disappear out from under us
  66.  * anyway? */
  67. /* copied from xfs_trans.h, skipping header maze for now */
  68. #define XFS_TRANS_SETATTR_NOT_SIZE      1
  69. #define XFS_TRANS_SETATTR_SIZE          2
  70. #define XFS_TRANS_INACTIVE              3
  71. #define XFS_TRANS_CREATE                4
  72. #define XFS_TRANS_CREATE_TRUNC          5
  73. #define XFS_TRANS_TRUNCATE_FILE         6
  74. #define XFS_TRANS_REMOVE                7
  75. #define XFS_TRANS_LINK                  8
  76. #define XFS_TRANS_RENAME                9
  77. #define XFS_TRANS_MKDIR                 10
  78. #define XFS_TRANS_RMDIR                 11
  79. #define XFS_TRANS_SYMLINK               12
  80. /* map the op onto the values for XFS so it can do reservation. if
  81.  * we don't have enough info to differentiate between e.g. setattr
  82.  * with or without size, what do we do? will it adjust? */
  83. switch (op) {
  84. case PRESTO_OP_SETATTR:
  85. /* or XFS_TRANS_SETATTR_NOT_SIZE? */
  86.         xfs_op = XFS_TRANS_SETATTR_SIZE;
  87. break;
  88. case PRESTO_OP_CREATE:
  89. /* or CREATE_TRUNC? */
  90. xfs_op = XFS_TRANS_CREATE;
  91. break;
  92. case PRESTO_OP_LINK:
  93. xfs_op = XFS_TRANS_LINK;
  94. break;
  95. case PRESTO_OP_UNLINK:
  96. xfs_op = XFS_TRANS_REMOVE;
  97. break;
  98. case PRESTO_OP_SYMLINK:
  99. xfs_op = XFS_TRANS_SYMLINK;
  100. break;
  101. case PRESTO_OP_MKDIR:
  102. xfs_op = XFS_TRANS_MKDIR;
  103. break;
  104. case PRESTO_OP_RMDIR:
  105. xfs_op = XFS_TRANS_RMDIR;
  106. break;
  107. case PRESTO_OP_MKNOD:
  108. /* XXX can't find an analog for mknod? */
  109. xfs_op = XFS_TRANS_CREATE;
  110. break;
  111. case PRESTO_OP_RENAME:
  112. xfs_op = XFS_TRANS_RENAME;
  113. break;
  114. default:
  115. CDEBUG(D_JOURNAL, "invalid operation %d for journaln", op);
  116. return NULL;
  117. }
  118. return xfs_trans_start(inode, xfs_op);
  119. }
  120. static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle)
  121. {
  122. /* assert (handle == current->j_handle) */
  123. xfs_trans_stop(handle);
  124. }
  125. static void presto_xfs_journal_file_data(struct inode *inode)
  126. {
  127.         return; 
  128. }
  129. static int presto_xfs_has_all_data(struct inode *inode)
  130. {
  131.         BUG();
  132.         return 0;
  133. }
  134. struct journal_ops presto_xfs_journal_ops = {
  135.         .tr_all_data     = presto_xfs_has_all_data,
  136.         .tr_avail        = presto_xfs_freespace,
  137.         .tr_start        = presto_xfs_trans_start,
  138.         .tr_commit       = presto_xfs_trans_commit,
  139.         .tr_journal_data = presto_xfs_journal_file_data
  140. };
  141. #endif
  142. #endif /* CONFIG_XFS_FS */