xfs_iocore.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include "xfs.h"
  33. #include "xfs_macros.h"
  34. #include "xfs_types.h"
  35. #include "xfs_inum.h"
  36. #include "xfs_log.h"
  37. #include "xfs_trans.h"
  38. #include "xfs_sb.h"
  39. #include "xfs_ag.h"
  40. #include "xfs_dir.h"
  41. #include "xfs_dir2.h"
  42. #include "xfs_dmapi.h"
  43. #include "xfs_mount.h"
  44. #include "xfs_alloc_btree.h"
  45. #include "xfs_bmap_btree.h"
  46. #include "xfs_ialloc_btree.h"
  47. #include "xfs_itable.h"
  48. #include "xfs_btree.h"
  49. #include "xfs_alloc.h"
  50. #include "xfs_ialloc.h"
  51. #include "xfs_attr_sf.h"
  52. #include "xfs_dir_sf.h"
  53. #include "xfs_dir2_sf.h"
  54. #include "xfs_dinode.h"
  55. #include "xfs_inode_item.h"
  56. #include "xfs_inode.h"
  57. #include "xfs_bmap.h"
  58. #include "xfs_error.h"
  59. #include "xfs_bit.h"
  60. #include "xfs_rw.h"
  61. #include "xfs_quota.h"
  62. #include "xfs_trans_space.h"
  63. #include "xfs_iomap.h"
  64. STATIC xfs_fsize_t
  65. xfs_size_fn(
  66. xfs_inode_t *ip)
  67. {
  68. return (ip->i_d.di_size);
  69. }
  70. STATIC int
  71. xfs_ioinit(
  72. struct vfs *vfsp,
  73. struct xfs_mount_args *mntargs,
  74. int flags)
  75. {
  76. return xfs_mountfs(vfsp, XFS_VFSTOM(vfsp), flags);
  77. }
  78. xfs_ioops_t xfs_iocore_xfs = {
  79. .xfs_ioinit = (xfs_ioinit_t) xfs_ioinit,
  80. .xfs_bmapi_func = (xfs_bmapi_t) xfs_bmapi,
  81. .xfs_bmap_eof_func = (xfs_bmap_eof_t) xfs_bmap_eof,
  82. .xfs_iomap_write_direct =
  83. (xfs_iomap_write_direct_t) xfs_iomap_write_direct,
  84. .xfs_iomap_write_delay =
  85. (xfs_iomap_write_delay_t) xfs_iomap_write_delay,
  86. .xfs_iomap_write_allocate =
  87. (xfs_iomap_write_allocate_t) xfs_iomap_write_allocate,
  88. .xfs_iomap_write_unwritten =
  89. (xfs_iomap_write_unwritten_t) xfs_iomap_write_unwritten,
  90. .xfs_ilock = (xfs_lock_t) xfs_ilock,
  91. .xfs_lck_map_shared = (xfs_lck_map_shared_t) xfs_ilock_map_shared,
  92. .xfs_ilock_demote = (xfs_lock_demote_t) xfs_ilock_demote,
  93. .xfs_ilock_nowait = (xfs_lock_nowait_t) xfs_ilock_nowait,
  94. .xfs_unlock = (xfs_unlk_t) xfs_iunlock,
  95. .xfs_size_func = (xfs_size_t) xfs_size_fn,
  96. .xfs_iodone = (xfs_iodone_t) fs_noerr,
  97. };
  98. void
  99. xfs_iocore_inode_reinit(
  100. xfs_inode_t *ip)
  101. {
  102. xfs_iocore_t *io = &ip->i_iocore;
  103. io->io_flags = 0;
  104. if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
  105. io->io_flags |= XFS_IOCORE_RT;
  106. io->io_dmevmask = ip->i_d.di_dmevmask;
  107. io->io_dmstate = ip->i_d.di_dmstate;
  108. }
  109. void
  110. xfs_iocore_inode_init(
  111. xfs_inode_t *ip)
  112. {
  113. xfs_iocore_t *io = &ip->i_iocore;
  114. xfs_mount_t *mp = ip->i_mount;
  115. io->io_mount = mp;
  116. #ifdef DEBUG
  117. io->io_lock = &ip->i_lock;
  118. io->io_iolock = &ip->i_iolock;
  119. #endif
  120. io->io_obj = (void *)ip;
  121. xfs_iocore_inode_reinit(ip);
  122. }