]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/gnu/fs/xfs/xfs_iocore.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / gnu / fs / xfs / xfs_iocore.c
1 /*
2  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * 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.
13  *
14  * 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
17  */
18 #include "xfs.h"
19 #include "xfs_fs.h"
20 #include "xfs_types.h"
21 #include "xfs_bit.h"
22 #include "xfs_log.h"
23 #include "xfs_inum.h"
24 #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_dfrag.h"
30 #include "xfs_dmapi.h"
31 #include "xfs_mount.h"
32 #include "xfs_bmap_btree.h"
33 #include "xfs_alloc_btree.h"
34 #include "xfs_ialloc_btree.h"
35 #include "xfs_dir_sf.h"
36 #include "xfs_dir2_sf.h"
37 #include "xfs_attr_sf.h"
38 #include "xfs_dinode.h"
39 #include "xfs_inode.h"
40 #include "xfs_inode_item.h"
41 #include "xfs_itable.h"
42 #include "xfs_btree.h"
43 #include "xfs_alloc.h"
44 #include "xfs_ialloc.h"
45 #include "xfs_bmap.h"
46 #include "xfs_error.h"
47 #include "xfs_rw.h"
48 #include "xfs_quota.h"
49 #include "xfs_trans_space.h"
50 #include "xfs_iomap.h"
51
52
53
54 STATIC xfs_fsize_t
55 xfs_size_fn(
56         xfs_inode_t             *ip)
57 {
58         return (ip->i_d.di_size);
59 }
60
61 STATIC int
62 xfs_ioinit(
63         struct xfs_vfs          *vfsp,
64         struct xfs_mount_args   *mntargs,
65         int                     flags)
66 {
67         return xfs_mountfs(vfsp, XFS_VFSTOM(vfsp), flags);
68 }
69
70 xfs_ioops_t     xfs_iocore_xfs = {
71         .xfs_ioinit             = (xfs_ioinit_t) xfs_ioinit,
72         .xfs_bmapi_func         = (xfs_bmapi_t) xfs_bmapi,
73         .xfs_bunmapi_func       = (xfs_bunmapi_t) xfs_bunmapi,
74         .xfs_bmap_eof_func      = (xfs_bmap_eof_t) xfs_bmap_eof,
75         .xfs_iomap_write_direct =
76                         (xfs_iomap_write_direct_t) xfs_iomap_write_direct,
77         .xfs_iomap_write_delay =
78                         (xfs_iomap_write_delay_t) xfs_iomap_write_delay,
79         .xfs_iomap_write_allocate =
80                         (xfs_iomap_write_allocate_t) xfs_iomap_write_allocate,
81         .xfs_iomap_write_unwritten =
82                         (xfs_iomap_write_unwritten_t) xfs_iomap_write_unwritten,
83         .xfs_ilock              = (xfs_lock_t) xfs_ilock,
84         .xfs_lck_map_shared     = (xfs_lck_map_shared_t) xfs_ilock_map_shared,
85         .xfs_ilock_demote       = (xfs_lock_demote_t) xfs_ilock_demote,
86         .xfs_ilock_nowait       = (xfs_lock_nowait_t) xfs_ilock_nowait,
87         .xfs_unlock             = (xfs_unlk_t) xfs_iunlock,
88         .xfs_size_func          = (xfs_size_t) xfs_size_fn,
89         .xfs_iodone             = (xfs_iodone_t) fs_noerr,
90         .xfs_swap_extents_func  = (xfs_swap_extents_t) xfs_swap_extents,
91 };
92
93 void
94 xfs_iocore_inode_reinit(
95         xfs_inode_t     *ip)
96 {
97         xfs_iocore_t    *io = &ip->i_iocore;
98
99         io->io_flags = 0;
100         if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
101                 io->io_flags |= XFS_IOCORE_RT;
102         io->io_dmevmask = ip->i_d.di_dmevmask;
103         io->io_dmstate = ip->i_d.di_dmstate;
104 }
105
106 void
107 xfs_iocore_inode_init(
108         xfs_inode_t     *ip)
109 {
110         xfs_iocore_t    *io = &ip->i_iocore;
111         xfs_mount_t     *mp = ip->i_mount;
112
113         io->io_mount = mp;
114 #ifdef DEBUG
115         io->io_lock = &ip->i_lock;
116         io->io_iolock = &ip->i_iolock;
117 #endif
118
119         io->io_obj = (void *)ip;
120
121         xfs_iocore_inode_reinit(ip);
122 }
123