blob: a07815661a8ce0063be641e7a6367841f087ec9e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
Nathan Scotta844f452005-11-02 14:38:42 +110019#include "xfs_fs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "xfs_types.h"
Nathan Scotta844f452005-11-02 14:38:42 +110021#include "xfs_bit.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include "xfs_log.h"
Nathan Scotta844f452005-11-02 14:38:42 +110023#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include "xfs_trans.h"
25#include "xfs_sb.h"
26#include "xfs_ag.h"
27#include "xfs_dir.h"
28#include "xfs_dir2.h"
29#include "xfs_dmapi.h"
30#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110032#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_ialloc_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110034#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include "xfs_itable.h"
41#include "xfs_btree.h"
42#include "xfs_alloc.h"
43#include "xfs_ialloc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include "xfs_bmap.h"
45#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include "xfs_rw.h"
47#include "xfs_quota.h"
48#include "xfs_trans_space.h"
49#include "xfs_iomap.h"
50
51
52STATIC xfs_fsize_t
53xfs_size_fn(
54 xfs_inode_t *ip)
55{
56 return (ip->i_d.di_size);
57}
58
59STATIC int
60xfs_ioinit(
61 struct vfs *vfsp,
62 struct xfs_mount_args *mntargs,
63 int flags)
64{
65 return xfs_mountfs(vfsp, XFS_VFSTOM(vfsp), flags);
66}
67
68xfs_ioops_t xfs_iocore_xfs = {
69 .xfs_ioinit = (xfs_ioinit_t) xfs_ioinit,
70 .xfs_bmapi_func = (xfs_bmapi_t) xfs_bmapi,
71 .xfs_bmap_eof_func = (xfs_bmap_eof_t) xfs_bmap_eof,
72 .xfs_iomap_write_direct =
73 (xfs_iomap_write_direct_t) xfs_iomap_write_direct,
74 .xfs_iomap_write_delay =
75 (xfs_iomap_write_delay_t) xfs_iomap_write_delay,
76 .xfs_iomap_write_allocate =
77 (xfs_iomap_write_allocate_t) xfs_iomap_write_allocate,
78 .xfs_iomap_write_unwritten =
79 (xfs_iomap_write_unwritten_t) xfs_iomap_write_unwritten,
80 .xfs_ilock = (xfs_lock_t) xfs_ilock,
81 .xfs_lck_map_shared = (xfs_lck_map_shared_t) xfs_ilock_map_shared,
82 .xfs_ilock_demote = (xfs_lock_demote_t) xfs_ilock_demote,
83 .xfs_ilock_nowait = (xfs_lock_nowait_t) xfs_ilock_nowait,
84 .xfs_unlock = (xfs_unlk_t) xfs_iunlock,
85 .xfs_size_func = (xfs_size_t) xfs_size_fn,
86 .xfs_iodone = (xfs_iodone_t) fs_noerr,
87};
88
89void
90xfs_iocore_inode_reinit(
91 xfs_inode_t *ip)
92{
93 xfs_iocore_t *io = &ip->i_iocore;
94
95 io->io_flags = 0;
96 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
97 io->io_flags |= XFS_IOCORE_RT;
98 io->io_dmevmask = ip->i_d.di_dmevmask;
99 io->io_dmstate = ip->i_d.di_dmstate;
100}
101
102void
103xfs_iocore_inode_init(
104 xfs_inode_t *ip)
105{
106 xfs_iocore_t *io = &ip->i_iocore;
107 xfs_mount_t *mp = ip->i_mount;
108
109 io->io_mount = mp;
110#ifdef DEBUG
111 io->io_lock = &ip->i_lock;
112 io->io_iolock = &ip->i_iolock;
113#endif
114
115 io->io_obj = (void *)ip;
116
117 xfs_iocore_inode_reinit(ip);
118}